Skip to content

Commit 83d0289

Browse files
drafnelgitster
authored andcommitted
repack: only unpack-unreachable if we are deleting redundant packs
The -A option calls pack-objects with the --unpack-unreachable option so that the unreachable objects in local packs are left in the local object store loose. But if the -d option to repack was _not_ used, then these unpacked loose objects are redundant and unnecessary. Update tests in t7701. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3289b9d commit 83d0289

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

Documentation/git-repack.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ OPTIONS
3838
dangling.
3939

4040
-A::
41-
Same as `-a`, but any unreachable objects in a previous
42-
pack become loose, unpacked objects, instead of being
43-
left in the old pack. Unreachable objects are never
44-
intentionally added to a pack, even when repacking.
45-
When used with '-d', this option
46-
prevents unreachable objects from being immediately
41+
Same as `-a`, unless '-d' is used. Then any unreachable
42+
objects in a previous pack become loose, unpacked objects,
43+
instead of being left in the old pack. Unreachable objects
44+
are never intentionally added to a pack, even when repacking.
45+
This option prevents unreachable objects from being immediately
4746
deleted by way of being left in the old pack and then
4847
removed. Instead, the loose unreachable objects
4948
will be pruned according to normal expiry rules

git-repack.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ case ",$all_into_one," in
7171
existing="$existing $e"
7272
fi
7373
done
74-
if test -n "$args" -a -n "$unpack_unreachable"
74+
if test -n "$args" -a -n "$unpack_unreachable" -a \
75+
-n "$remove_redundant"
7576
then
7677
args="$args $unpack_unreachable"
7778
fi

t/t7701-repack-unpack-unreachable.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fsha1=
88
csha1=
99
tsha1=
1010

11-
test_expect_success '-A option leaves unreachable objects unpacked' '
11+
test_expect_success '-A with -d option leaves unreachable objects unpacked' '
1212
echo content > file1 &&
1313
git add . &&
1414
git commit -m initial_commit &&
@@ -58,7 +58,7 @@ compare_mtimes ()
5858
' -- "$@"
5959
}
6060

61-
test_expect_success 'unpacked objects receive timestamp of pack file' '
61+
test_expect_success '-A without -d option leaves unreachable objects packed' '
6262
fsha1path=$(echo "$fsha1" | sed -e "s|\(..\)|\1/|") &&
6363
fsha1path=".git/objects/$fsha1path" &&
6464
csha1path=$(echo "$csha1" | sed -e "s|\(..\)|\1/|") &&
@@ -75,7 +75,19 @@ test_expect_success 'unpacked objects receive timestamp of pack file' '
7575
git branch -D transient_branch &&
7676
sleep 1 &&
7777
git repack -A -l &&
78-
compare_mtimes "$packfile" "$fsha1path" "$csha1path" "$tsha1path"
78+
test ! -f "$fsha1path" &&
79+
test ! -f "$csha1path" &&
80+
test ! -f "$tsha1path" &&
81+
git show $fsha1 &&
82+
git show $csha1 &&
83+
git show $tsha1
84+
'
85+
86+
test_expect_success 'unpacked objects receive timestamp of pack file' '
87+
tmppack=".git/objects/pack/tmp_pack" &&
88+
ln "$packfile" "$tmppack" &&
89+
git repack -A -l -d &&
90+
compare_mtimes "$tmppack" "$fsha1path" "$csha1path" "$tsha1path"
7991
'
8092

8193
test_done

0 commit comments

Comments
 (0)