Skip to content

Commit c5380d0

Browse files
committed
Fix ZIP for submodules
1 parent 3b4a9d5 commit c5380d0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

git-archive-all.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ IFS="$(printf '\n \t')"
4949
function cleanup () {
5050
rm -f $TMPFILE
5151
rm -f $TMPLIST
52+
rm -rf $TMP_UNPACK_FOLDER
5253
rm -f $TOARCHIVE
5354
IFS="$OLD_IFS"
5455
}
@@ -190,6 +191,7 @@ OLD_PWD="`pwd`"
190191
TMPDIR=${TMPDIR:-/tmp}
191192
TMPFILE=`mktemp "$TMPDIR/$PROGRAM.XXXXXX"` # Create a place to store our work's progress
192193
TMPLIST=`mktemp "$TMPDIR/$PROGRAM.submodules.XXXXXX"`
194+
TMP_UNPACK_FOLDER=`mktemp -d "$TMPDIR/$PROGRAM.tmp_unpack_folder.XXXXXX"`
193195
TOARCHIVE=`mktemp "$TMPDIR/$PROGRAM.toarchive.XXXXXX"`
194196
OUT_FILE=$OLD_PWD # assume "this directory" without a name change by default
195197

@@ -286,12 +288,14 @@ if [ $SEPARATE -eq 0 -o "-" == "$OUT_FILE" ]; then
286288
$TARCMD --concatenate -f "$superfile" "$file" && rm -f "$file"
287289
done
288290
elif [ $FORMAT == 'zip' ]; then
291+
# unpack all zip files, then re-pack
292+
# unfortunately, more intelligent options don't work:
293+
# zipmerge is broken (kills the x bit of directories), and zip --grow does not unpack input zipfiles.
294+
cd $TMP_UNPACK_FOLDER
289295
sed -e '1d' $TMPFILE | while read file; do
290-
# zip incorrectly stores the full path, so cd and then grow
291-
cd `dirname "$file"`
292-
zip -g "$superfile" `basename "$file"` && rm -f "$file"
296+
unzip "$file" && rm -f "$file"
293297
done
294-
cd "$OLD_PWD"
298+
zip --quiet --recurse-paths "$superfile" .
295299
fi
296300

297301
echo "$superfile" >| $TMPFILE # clobber on purpose

0 commit comments

Comments
 (0)