Skip to content

Commit

Permalink
pack-objects: do not get distracted by broken symrefs
Browse files Browse the repository at this point in the history
It is quite possible for, say, a remote HEAD to become broken, e.g.
when the default branch was renamed.

We should still be able to pack our objects when such a thing happens;
simply ignore broken symrefs (because they cannot matter for the packing
process anyway).

This fixes https://github.com/git-for-windows/git/issues/423

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Oct 8, 2015
1 parent 8c845cd commit 14886b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion reachable.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ static void update_progress(struct connectivity_progress *cp)

static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
struct object *object = parse_object_or_die(sha1, path);
struct rev_info *revs = (struct rev_info *)cb_data;
struct object *object;

if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
warning("symbolic ref is dangling: %s", path);
return 0;
}

object = parse_object_or_die(sha1, path);
add_pending_object(revs, object, "");

return 0;
Expand Down
2 changes: 1 addition & 1 deletion t/t6500-gc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test_expect_success 'gc -h with invalid configuration' '
test_i18ngrep "[Uu]sage" broken/usage
'

test_expect_failure 'gc is not aborted due to a stale symref' '
test_expect_success 'gc is not aborted due to a stale symref' '
git init remote &&
(
cd remote &&
Expand Down

0 comments on commit 14886b4

Please sign in to comment.