repack: add --keep-unreachable option
[gitweb.git] / t / t7701-repack-unpack-unreachable.sh
index b66e3838665ea47d748a7e1a64facd755ee32fb8..f13df432992dc6da82fcca9317447b2d8381279b 100755 (executable)
@@ -122,4 +122,19 @@ test_expect_success 'keep packed objects found only in index' '
        git cat-file blob :file
 '
 
+test_expect_success 'repack -k keeps unreachable packed objects' '
+       # create packed-but-unreachable object
+       sha1=$(echo unreachable-packed | git hash-object -w --stdin) &&
+       pack=$(echo $sha1 | git pack-objects .git/objects/pack/pack) &&
+       git prune-packed &&
+
+       # -k should keep it
+       git repack -adk &&
+       git cat-file -p $sha1 &&
+
+       # and double check that without -k it would have been removed
+       git repack -ad &&
+       test_must_fail git cat-file -p $sha1
+'
+
 test_done