@matheusbsbs / matheus-bagliano / commits / 69310a34cb
Fork 0

send-pack: reword non-fast-forward error message.

Wnen refusing to push a head, we said cryptic "remote 'branch' object X does not exist on local" or "remote ref 'branch' is not a strict subset of local ref 'branch'". That was gittish. Since the most likely reason this happens is because the pushed head was not up-to-date, clarify the error message to say that straight, and suggest pulling first. First noticed by Johannes and seconded by Andreas. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 22, 2005 at 12:39 UTC 69310a34cb6dcca32b08cf3ea9e91ab19354a874
1 file changed +14 -16
send-pack.c
+14 -16
@@ -231,23 +231,21 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
231 if (!force_update &&
232 !is_zero_sha1(ref->old_sha1) &&
233 !ref->force) {
234 - if (!has_sha1_file(ref->old_sha1)) {
235 - error("remote '%s' object %s does not "
236 - "exist on local",
237 - ref->name, sha1_to_hex(ref->old_sha1));
238 - ret = -2;
239 - continue;
240 - }
241 -
242 - /* We assume that local is fsck-clean. Otherwise
243 - * you _could_ have an old tag which points at
244 - * something you do not have, which may or may not
245 - * be a commit.
246 - */
247 - if (!ref_newer(ref->peer_ref->new_sha1,
234 + if (!has_sha1_file(ref->old_sha1) ||
235 + !ref_newer(ref->peer_ref->new_sha1,
236 ref->old_sha1)) {
249 - error("remote ref '%s' is not a strict "
250 - "subset of local ref '%s'.", ref->name,
237 + /* We do not have the remote ref, or
238 + * we know that the remote ref is not
239 + * an ancestor of what we are trying to
240 + * push. Either way this can be losing
241 + * commits at the remote end and likely
242 + * we were not up to date to begin with.
243 + */
244 + error("remote '%s' is not a strict "
245 + "subset of local ref '%s'. "
246 + "maybe you are not up-to-date and "
247 + "need to pull first?",
248 + ref->name,
249 ref->peer_ref->name);
250 ret = -2;
251 continue;