Skip to content

Commit fc86194

Browse files
committed
Fix archive creation errors when creating the archive a second time.
Thanks, @angeloc.
2 parents af81ea7 + 0760d02 commit fc86194

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

git-archive-all.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
###############################################################################
3636

3737
# DEBUGGING
38-
set -e
38+
set -e # Exit on error (i.e., "be strict").
3939
set -C # noclobber
4040

4141
# TRAP SIGNALS
@@ -220,6 +220,7 @@ fi
220220
if [ $VERBOSE -eq 1 ]; then
221221
echo -n "creating superproject archive..."
222222
fi
223+
rm -f $TMPDIR/$(basename "$(pwd)").$FORMAT
223224
git archive --format=$FORMAT --prefix="$PREFIX" $ARCHIVE_OPTS $TREEISH > $TMPDIR/$(basename "$(pwd)").$FORMAT
224225
if [ $VERBOSE -eq 1 ]; then
225226
echo "done"
@@ -252,10 +253,11 @@ git submodule >>"$TMPLIST"
252253
while read path; do
253254
TREEISH=$(grep "^ .*${path%/} " "$TMPLIST" | cut -d ' ' -f 2) # git submodule does not list trailing slashes in $path
254255
cd "$path"
256+
rm -f "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT
255257
git archive --format=$FORMAT --prefix="${PREFIX}$path" $ARCHIVE_OPTS ${TREEISH:-HEAD} > "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT
256258
if [ $FORMAT == 'zip' ]; then
257259
# delete the empty directory entry; zipped submodules won't unzip if we don't do this
258-
zip -d "$(tail -n 1 $TMPFILE)" "${PREFIX}${path%/}" >/dev/null # remove trailing '/'
260+
zip -d "$(tail -n 1 $TMPFILE)" "${PREFIX}${path%/}" >/dev/null 2>&1 || true # remove trailing '/'
259261
fi
260262
echo "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT >> $TMPFILE
261263
cd "$OLD_PWD"

0 commit comments

Comments
 (0)