Skip to content

Commit f59774a

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 179c94b commit f59774a

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

builtin-fetch.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,6 @@ static int update_local_ref(struct ref *ref,
215215
if (type < 0)
216216
die("object %s not found", sha1_to_hex(ref->new_sha1));
217217

218-
if (!*ref->name) {
219-
/* Not storing */
220-
if (verbose)
221-
sprintf(display, "* branch %s -> FETCH_HEAD", remote);
222-
return 0;
223-
}
224-
225218
if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
226219
if (verbose)
227220
sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH,
@@ -365,16 +358,21 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
365358
rm->merge ? "" : "not-for-merge",
366359
note);
367360

368-
if (ref) {
361+
if (ref)
369362
update_local_ref(ref, what, verbose, note);
370-
if (*note) {
371-
if (!shown_url) {
372-
fprintf(stderr, "From %.*s\n",
373-
url_len, url);
374-
shown_url = 1;
375-
}
376-
fprintf(stderr, " %s\n", note);
363+
else if (verbose)
364+
sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
365+
SUMMARY_WIDTH, *kind ? kind : "branch",
366+
REFCOL_WIDTH, *what ? what : "HEAD");
367+
else
368+
*note = '\0';
369+
if (*note) {
370+
if (!shown_url) {
371+
fprintf(stderr, "From %.*s\n",
372+
url_len, url);
373+
shown_url = 1;
377374
}
375+
fprintf(stderr, " %s\n", note);
378376
}
379377
}
380378
fclose(fp);

0 commit comments

Comments
 (0)