зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
f8948e2fbc
Коммит
057e71384a
|
@ -268,16 +268,18 @@ int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
|
||||||
char fullref[PATH_MAX];
|
char fullref[PATH_MAX];
|
||||||
unsigned char sha1_from_ref[20];
|
unsigned char sha1_from_ref[20];
|
||||||
unsigned char *this_result;
|
unsigned char *this_result;
|
||||||
|
int flag;
|
||||||
|
|
||||||
this_result = refs_found ? sha1_from_ref : sha1;
|
this_result = refs_found ? sha1_from_ref : sha1;
|
||||||
mksnpath(fullref, sizeof(fullref), *p, len, str);
|
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 (r) {
|
||||||
if (!refs_found++)
|
if (!refs_found++)
|
||||||
*ref = xstrdup(r);
|
*ref = xstrdup(r);
|
||||||
if (!warn_ambiguous_refs)
|
if (!warn_ambiguous_refs)
|
||||||
break;
|
break;
|
||||||
}
|
} else if (flag & REF_ISSYMREF)
|
||||||
|
warning("ignoring dangling symref %s.", fullref);
|
||||||
}
|
}
|
||||||
free(last_branch);
|
free(last_branch);
|
||||||
return refs_found;
|
return refs_found;
|
||||||
|
|
|
@ -421,6 +421,12 @@ test_expect_success 'remote prune to cause a dangling symref' '
|
||||||
git branch -a
|
git branch -a
|
||||||
) 2>err &&
|
) 2>err &&
|
||||||
! grep "points nowhere" err
|
! grep "points nowhere" err
|
||||||
|
(
|
||||||
|
cd seven &&
|
||||||
|
test_must_fail git branch nomore origin
|
||||||
|
) 2>err &&
|
||||||
|
grep "dangling symref" err
|
||||||
'
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче