summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-24 23:25:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-24 23:25:34 (GMT)
commit954f7cfdac48b8d9fe91c29ecfa44ac0c639867c (patch)
tree6b31342c61da3b5c1642b40276db08b2c2cac991 /refs.c
parenta5ee8faaee15d2f53de3bd182550f506a3162fbe (diff)
parente01de1c9122c3cba118da19fe0ba0ce913fa7285 (diff)
downloadgit-954f7cfdac48b8d9fe91c29ecfa44ac0c639867c.zip
git-954f7cfdac48b8d9fe91c29ecfa44ac0c639867c.tar.gz
git-954f7cfdac48b8d9fe91c29ecfa44ac0c639867c.tar.bz2
Merge branch 'jc/maint-refs-dangling'
* jc/maint-refs-dangling: refs: ref entry with NULL sha1 is can be a dangling symref
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/refs.c b/refs.c
index 63e30d7..a7518b6 100644
--- a/refs.c
+++ b/refs.c
@@ -6,6 +6,7 @@
/* ISSYMREF=01 and ISPACKED=02 are public interfaces */
#define REF_KNOWS_PEELED 04
+#define REF_BROKEN 010
struct ref_list {
struct ref_list *next;
@@ -275,8 +276,10 @@ static struct ref_list *get_ref_dir(const char *base, struct ref_list *list)
list = get_ref_dir(ref, list);
continue;
}
- if (!resolve_ref(ref, sha1, 1, &flag))
+ if (!resolve_ref(ref, sha1, 1, &flag)) {
hashclr(sha1);
+ flag |= REF_BROKEN;
+ }
list = add_ref(ref, sha1, flag, list, NULL);
}
free(ref);
@@ -539,10 +542,10 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
{
if (strncmp(base, entry->name, trim))
return 0;
- /* Is this a "negative ref" that represents a deleted ref? */
- if (is_null_sha1(entry->sha1))
- return 0;
+
if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
+ if (entry->flag & REF_BROKEN)
+ return 0; /* ignore dangling symref */
if (!has_sha1_file(entry->sha1)) {
error("%s does not point to a valid object!", entry->name);
return 0;