summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sha1_name.c6
-rwxr-xr-xt/t5505-remote.sh6
2 files changed, 10 insertions, 2 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 5d0ac0263d..3bd2ef0e7c 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -268,16 +268,18 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
char fullref[PATH_MAX];
unsigned char sha1_from_ref[20];
unsigned char *this_result;
+ int flag;
this_result = refs_found ? sha1_from_ref : sha1;
mksnpath(fullref, sizeof(fullref), *p, len, str);
- r = resolve_ref(fullref, this_result, 1, NULL);
+ r = resolve_ref(fullref, this_result, 1, &flag);
if (r) {
if (!refs_found++)
*ref = xstrdup(r);
if (!warn_ambiguous_refs)
break;
- }
+ } else if (flag & REF_ISSYMREF)
+ warning("ignoring dangling symref %s.", fullref);
}
free(last_branch);
return refs_found;
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 2067dc558f..eb637184a0 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -421,6 +421,12 @@ test_expect_success 'remote prune to cause a dangling symref' '
git branch -a
) 2>err &&
! grep "points nowhere" err
+ (
+ cd seven &&
+ test_must_fail git branch nomore origin
+ ) 2>err &&
+ grep "dangling symref" err
'
test_done
+