From 8c845cde99dcfc9821f1182623248dee9ebb4227 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 28 Sep 2015 16:01:13 +0200 Subject: gc: demonstrate failure with stale remote HEAD Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index 63194d8..ed22dcc 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_failure '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 -- cgit v0.10.2-6-g49f6 From 14886b40c552d3ad4d5492d922948d76762af198 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 28 Sep 2015 16:01:25 +0200 Subject: 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 https://github.com/git-for-windows/git/issues/423 Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano diff --git a/reachable.c b/reachable.c index 69fa685..4cfd0de 100644 --- a/reachable.c +++ b/reachable.c @@ -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; diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh index ed22dcc..5d7d414 100755 --- a/t/t6500-gc.sh +++ b/t/t6500-gc.sh @@ -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 && -- cgit v0.10.2-6-g49f6