Skip to content

Commit

Permalink
Merge branch 'jc/maint-refs-dangling' into maint
Browse files Browse the repository at this point in the history
* jc/maint-refs-dangling:
  refs: ref entry with NULL sha1 is can be a dangling symref
  • Loading branch information
Junio C Hamano committed Mar 31, 2010
2 parents 4318d3b + e01de1c commit 970957d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions t/t5505-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,15 @@ test_expect_success 'remote prune to cause a dangling symref' '
(
cd seven &&
git remote prune origin
) 2>err &&
) >err 2>&1 &&
grep "has become dangling" err &&
: And the dangling symref will not cause other annoying errors
: And the dangling symref will not cause other annoying errors &&
(
cd seven &&
git branch -a
) 2>err &&
! grep "points nowhere" err
! grep "points nowhere" err &&
(
cd seven &&
test_must_fail git branch nomore origin
Expand Down

0 comments on commit 970957d

Please sign in to comment.