branch -d: avoid repeated symref resolution
If a repository gets in a broken state with too much symref nesting, it cannot be repaired with "git branch -d": $ git symbolic-ref refs/heads/nonsense refs/heads/nonsense $ git branch -d nonsense error: branch 'nonsense' not found. Worse, "git update-ref --no-deref -d" doesn't work for such repairs either: $ git update-ref -d refs/heads/nonsense error: unable to resolve reference refs/heads/nonsense: Too many levels of symbolic links Fix both by teaching resolve_ref_unsafe a new RESOLVE_REF_NO_RECURSE flag and passing it when appropriate. Callers can still read the value of a symref (for example to print a message about it) with that flag set --- resolve_ref_unsafe will resolve one level of symrefs and stop there. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Reviewed-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
014e7db3f5
commit
62a2d52514
2
refs.h
2
refs.h
@ -177,10 +177,12 @@ extern int peel_ref(const char *refname, unsigned char *sha1);
|
||||
* ref_transaction_create(), etc.
|
||||
* REF_NODEREF: act on the ref directly, instead of dereferencing
|
||||
* symbolic references.
|
||||
* REF_DELETING: tolerate broken refs
|
||||
*
|
||||
* Flags >= 0x100 are reserved for internal use.
|
||||
*/
|
||||
#define REF_NODEREF 0x01
|
||||
#define REF_DELETING 0x02
|
||||
/*
|
||||
* This function sets errno to something meaningful on failure.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user