Skip to content

Commit 66da4be

Browse files
committed
Added protection against running when there are no packs available to unpack.
Prior to this change, the command is not idempotent, and in-fact the rsync will delete your object store on the second run.
1 parent 6d4dbd5 commit 66da4be

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

git-unpack

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
#!/bin/sh
22

3-
mkdir /tmp/tmpgit.$$
4-
GIT_DIR=/tmp/tmpgit.$$ git init
3+
if [ -f .git/objects/pack/*.pack ]; then
4+
mkdir /tmp/tmpgit.$$
5+
GIT_DIR=/tmp/tmpgit.$$ git init
56

6-
for pack in .git/objects/pack/*.pack; do
7+
for pack in .git/objects/pack/*.pack; do
78
GIT_DIR=/tmp/tmpgit.$$ git unpack-objects < $pack
8-
done
9+
done
910

10-
rsync -a --info=PROGRESS2 --delete /tmp/tmpgit.$$/objects/ .git/objects/
11+
rsync -a --info=PROGRESS2 --delete /tmp/tmpgit.$$/objects/ .git/objects/
1112

12-
rm -fr /tmp/tmpgit.$$
13+
rm -fr /tmp/tmpgit.$$
14+
else
15+
echo "No packs to unpack"
16+
exit 1
17+
fi

0 commit comments

Comments
 (0)