@matheusbsbs / matheus-bagliano / commits / f59774add4
Fork 0

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>

Jeff King committed Apr 9, 2008 at 20:03 UTC f59774add488a6c5fb440a4aaa7255f594b1027d
1 file changed +13 -15
builtin-fetch.c
+13 -15
@@ -215,13 +215,6 @@ static int update_local_ref(struct ref *ref,
215 if (type < 0)
216 die("object %s not found", sha1_to_hex(ref->new_sha1));
217
218 - if (!*ref->name) {
219 - /* Not storing */
220 - if (verbose)
221 - sprintf(display, "* branch %s -> FETCH_HEAD", remote);
222 - return 0;
223 - }
224 -
218 if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
219 if (verbose)
220 sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH,
@@ -365,16 +358,21 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
358 rm->merge ? "" : "not-for-merge",
359 note);
360
368 - if (ref) {
361 + if (ref)
362 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;
374 }
375 + fprintf(stderr, " %s\n", note);
376 }
377 }
378 fclose(fp);