diff options
author | Ronnie Sahlberg <sahlberg@google.com> | 2014-11-03 08:55:57 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-11-03 11:18:35 -0800 |
commit | 986781fccb2eba058d11b432e5c5c6259989981d (patch) | |
tree | 6043e6d0f478d13650f54b81b01d213ddf9972fe /cache.h | |
parent | 6a0103dc112c3f8c0d3e3f401fbd33ea6e273b31 (diff) | |
download | git-rs/ref-transaction-reflog.tar.gz |
refs.c: allow deleting refs with a broken sha1rs/ref-transaction-reflog
Add back support to make it possible to delete refs that have a broken
sha1.
Add new internal flags REF_ALLOW_BROKEN and RESOLVE_REF_ALLOW_BAD_SHA1
to pass intent from branch.c that we are willing to allow
resolve_ref_unsafe and lock_ref_sha1_basic to allow broken refs.
Since these refs can not actually be resolved to a sha1, they instead resolve
to null_sha1 when these flags are used.
For example, the ref:
echo "Broken ref" > .git/refs/heads/foo-broken-1
can now be deleted using git branch -d foo-broken-1
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r-- | cache.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1000,10 +1000,17 @@ extern int read_ref(const char *refname, unsigned char *sha1); * resolved. The function returns NULL for such ref names. * Caps and underscores refers to the special refs, such as HEAD, * FETCH_HEAD and friends, that all live outside of the refs/ directory. + * + * RESOLVE_REF_ALLOW_BAD_SHA1 when this flag is set and the ref contains + * an invalid sha1, resolve_ref_unsafe will clear the sha1 argument, + * set the REF_ISBROKEN flag and return the refname. + * This allows using resolve_ref_unsafe to check for existence of such + * broken refs. */ #define RESOLVE_REF_READING 0x01 #define RESOLVE_REF_NO_RECURSE 0x02 #define RESOLVE_REF_ALLOW_BAD_NAME 0x04 +#define RESOLVE_REF_ALLOW_BAD_SHA1 0x08 extern const char *resolve_ref_unsafe(const char *ref, int resolve_flags, unsigned char *sha1, int *flags); extern char *resolve_refdup(const char *ref, int resolve_flags, unsigned char *sha1, int *flags); |