git-fetch: fix status output when not storing tracking ref

There was code in update_local_ref for handling this case,
but it never actually got called. It assumed that storing in
FETCH_HEAD meant a blank peer_ref name, but we actually have
a NULL peer_ref in this case, so we never even made it to
the update_local_ref function.

On top of that, the display formatting was different from
all of the other cases, probably owing to the fact that
nobody had ever actually seen the output.

This patch harmonizes the output with the other cases and
moves the detection of this case into store_updated_refs,
where we can actually trigger it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2008-04-09 20:03:49 -04:00 committed by Junio C Hamano
parent 179c94b24a
commit f59774add4

View File

@ -215,13 +215,6 @@ static int update_local_ref(struct ref *ref,
if (type < 0) if (type < 0)
die("object %s not found", sha1_to_hex(ref->new_sha1)); die("object %s not found", sha1_to_hex(ref->new_sha1));
if (!*ref->name) {
/* Not storing */
if (verbose)
sprintf(display, "* branch %s -> FETCH_HEAD", remote);
return 0;
}
if (!hashcmp(ref->old_sha1, ref->new_sha1)) { if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
if (verbose) if (verbose)
sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH, sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH,
@ -365,16 +358,21 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
rm->merge ? "" : "not-for-merge", rm->merge ? "" : "not-for-merge",
note); note);
if (ref) { if (ref)
update_local_ref(ref, what, verbose, note); update_local_ref(ref, what, verbose, note);
if (*note) { else if (verbose)
if (!shown_url) { sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
fprintf(stderr, "From %.*s\n", SUMMARY_WIDTH, *kind ? kind : "branch",
url_len, url); REFCOL_WIDTH, *what ? what : "HEAD");
shown_url = 1; else
} *note = '\0';
fprintf(stderr, " %s\n", note); if (*note) {
if (!shown_url) {
fprintf(stderr, "From %.*s\n",
url_len, url);
shown_url = 1;
} }
fprintf(stderr, " %s\n", note);
} }
} }
fclose(fp); fclose(fp);