@matheusbsbs / matheus-bagliano / commits / 057e71384a
Fork 0

Warn use of "origin" when remotes/origin/HEAD is dangling

The previous one squelched the diagnositic message we used to issue every time we enumerated the refs and noticed a dangling ref. This adds the warning back to the place where the user actually attempts to use it. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Feb 8, 2009 at 23:52 UTC 057e71384a0eff83236268dcd3ff7ebc7789de74
2 files changed +10 -2
sha1_name.c
+4 -2
@@ -268,16 +268,18 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
268 char fullref[PATH_MAX];
269 unsigned char sha1_from_ref[20];
270 unsigned char *this_result;
271 + int flag;
272
273 this_result = refs_found ? sha1_from_ref : sha1;
274 mksnpath(fullref, sizeof(fullref), *p, len, str);
274 - r = resolve_ref(fullref, this_result, 1, NULL);
275 + r = resolve_ref(fullref, this_result, 1, &flag);
276 if (r) {
277 if (!refs_found++)
278 *ref = xstrdup(r);
279 if (!warn_ambiguous_refs)
280 break;
280 - }
281 + } else if (flag & REF_ISSYMREF)
282 + warning("ignoring dangling symref %s.", fullref);
283 }
284 free(last_branch);
285 return refs_found;
t/t5505-remote.sh
+6
@@ -421,6 +421,12 @@ test_expect_success 'remote prune to cause a dangling symref' '
421 git branch -a
422 ) 2>err &&
423 ! grep "points nowhere" err
424 + (
425 + cd seven &&
426 + test_must_fail git branch nomore origin
427 + ) 2>err &&
428 + grep "dangling symref" err
429 '
430
431 test_done
432 +