Skip to content

Commit 0db974d

Browse files
committed
Support other tar format configured by git tar.FORMAT.command setting
1 parent fc86194 commit 0db974d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

git-archive-all.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,21 @@ if [ $VERBOSE -eq 1 ]; then
271271
fi
272272
# Concatenate archives into a super-archive.
273273
if [ $SEPARATE -eq 0 -o "-" == "$OUT_FILE" ]; then
274-
if [ $FORMAT == 'tar.gz' ]; then
274+
cmd=$(git config --get "tar.$FORMAT.command" || true)
275+
if [ $FORMAT == 'tar' ]; then
276+
sed -e '1d' $TMPFILE | while read file; do
277+
$TARCMD --concatenate -f "$superfile" "$file" && rm -f "$file"
278+
done
279+
elif [ -n "$cmd" ]; then
280+
superfile_=${superfile%.$FORMAT}.tar
281+
$cmd -d < "$superfile" > "$superfile_" && rm -f "$superfile"
282+
sed -e '1d' $TMPFILE | while read file; do
283+
file_=${file%.$FORMAT}.tar
284+
$cmd -d < "$file" > "$file_" && rm -f "$file"
285+
$TARCMD --concatenate -f "$superfile_" "$file_" && rm -f "$file_"
286+
done
287+
$cmd < "$superfile_" > "$superfile" && rm -f "$superfile_"
288+
elif [ $FORMAT == 'tar.gz' ]; then
275289
gunzip $superfile
276290
superfile=${superfile:0: -3} # Remove '.gz'
277291
sed -e '1d' $TMPFILE | while read file; do
@@ -281,10 +295,6 @@ if [ $SEPARATE -eq 0 -o "-" == "$OUT_FILE" ]; then
281295
done
282296
gzip $superfile
283297
superfile=$superfile.gz
284-
elif [ $FORMAT == 'tar' ]; then
285-
sed -e '1d' $TMPFILE | while read file; do
286-
$TARCMD --concatenate -f "$superfile" "$file" && rm -f "$file"
287-
done
288298
elif [ $FORMAT == 'zip' ]; then
289299
sed -e '1d' $TMPFILE | while read file; do
290300
# zip incorrectly stores the full path, so cd and then grow

0 commit comments

Comments
 (0)