summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--reachable.c8
-rwxr-xr-xt/t6500-gc.sh13
2 files changed, 20 insertions, 1 deletions
diff --git a/reachable.c b/reachable.c
index 9cff25b..43616d4 100644
--- a/reachable.c
+++ b/reachable.c
@@ -25,9 +25,15 @@ static void update_progress(struct connectivity_progress *cp)
static int add_one_ref(const char *path, const struct object_id *oid,
int flag, void *cb_data)
{
- struct object *object = parse_object_or_die(oid->hash, 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(oid->hash, path);
add_pending_object(revs, object, "");
return 0;
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
index 63194d8..5d7d414 100755
--- a/t/t6500-gc.sh
+++ b/t/t6500-gc.sh
@@ -30,4 +30,17 @@ test_expect_success 'gc -h with invalid configuration' '
test_i18ngrep "[Uu]sage" broken/usage
'
+test_expect_success 'gc is not aborted due to a stale symref' '
+ git init remote &&
+ (
+ cd remote &&
+ test_commit initial &&
+ git clone . ../client &&
+ git branch -m develop &&
+ cd ../client &&
+ git fetch --prune &&
+ git gc
+ )
+'
+
test_done