Skip to content

Commit 057e713

Browse files
committed
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 <[email protected]>
1 parent f8948e2 commit 057e713

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

sha1_name.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,18 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
268268
char fullref[PATH_MAX];
269269
unsigned char sha1_from_ref[20];
270270
unsigned char *this_result;
271+
int flag;
271272

272273
this_result = refs_found ? sha1_from_ref : sha1;
273274
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);
275276
if (r) {
276277
if (!refs_found++)
277278
*ref = xstrdup(r);
278279
if (!warn_ambiguous_refs)
279280
break;
280-
}
281+
} else if (flag & REF_ISSYMREF)
282+
warning("ignoring dangling symref %s.", fullref);
281283
}
282284
free(last_branch);
283285
return refs_found;

t/t5505-remote.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ test_expect_success 'remote prune to cause a dangling symref' '
421421
git branch -a
422422
) 2>err &&
423423
! grep "points nowhere" err
424+
(
425+
cd seven &&
426+
test_must_fail git branch nomore origin
427+
) 2>err &&
428+
grep "dangling symref" err
424429
'
425430

426431
test_done
432+

0 commit comments

Comments
 (0)