Skip to content

Commit 14886b4

Browse files
dschogitster
authored andcommitted
pack-objects: do not get distracted by broken symrefs
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 #423 Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c845cd commit 14886b4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

reachable.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ static void update_progress(struct connectivity_progress *cp)
2424

2525
static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
2626
{
27-
struct object *object = parse_object_or_die(sha1, path);
2827
struct rev_info *revs = (struct rev_info *)cb_data;
28+
struct object *object;
2929

30+
if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
31+
warning("symbolic ref is dangling: %s", path);
32+
return 0;
33+
}
34+
35+
object = parse_object_or_die(sha1, path);
3036
add_pending_object(revs, object, "");
3137

3238
return 0;

t/t6500-gc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test_expect_success 'gc -h with invalid configuration' '
3030
test_i18ngrep "[Uu]sage" broken/usage
3131
'
3232

33-
test_expect_failure 'gc is not aborted due to a stale symref' '
33+
test_expect_success 'gc is not aborted due to a stale symref' '
3434
git init remote &&
3535
(
3636
cd remote &&

0 commit comments

Comments
 (0)