From 3b4a9d55350b426a6f8776765d9c6b76b7fc9fac Mon Sep 17 00:00:00 2001 From: Max Gaukler Date: Tue, 9 Jan 2018 14:35:36 +0100 Subject: [PATCH 1/3] add .gitattributes to enforce LF end-of-line even on Windows --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..50ca329 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh eol=lf From 237530e32da56fc50e1fd150807595335e4da13e Mon Sep 17 00:00:00 2001 From: Max Gaukler Date: Mon, 30 Jul 2018 14:44:01 +0200 Subject: [PATCH 2/3] Fix ZIP for submodules --- git-archive-all.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/git-archive-all.sh b/git-archive-all.sh index b72dc4d..71d29a3 100755 --- a/git-archive-all.sh +++ b/git-archive-all.sh @@ -49,6 +49,7 @@ IFS="$(printf '\n \t')" function cleanup () { rm -f $TMPFILE rm -f $TMPLIST + rm -rf $TMP_UNPACK_FOLDER rm -f $TOARCHIVE IFS="$OLD_IFS" } @@ -190,6 +191,7 @@ OLD_PWD="`pwd`" TMPDIR=${TMPDIR:-/tmp} TMPFILE=`mktemp "$TMPDIR/$PROGRAM.XXXXXX"` # Create a place to store our work's progress TMPLIST=`mktemp "$TMPDIR/$PROGRAM.submodules.XXXXXX"` +TMP_UNPACK_FOLDER=`mktemp -d "$TMPDIR/$PROGRAM.tmp_unpack_folder.XXXXXX"` TOARCHIVE=`mktemp "$TMPDIR/$PROGRAM.toarchive.XXXXXX"` OUT_FILE=$OLD_PWD # assume "this directory" without a name change by default @@ -286,12 +288,14 @@ if [ $SEPARATE -eq 0 -o "-" == "$OUT_FILE" ]; then $TARCMD --concatenate -f "$superfile" "$file" && rm -f "$file" done elif [ $FORMAT == 'zip' ]; then + # unpack all zip files, then re-pack + # unfortunately, more intelligent options don't work: + # zipmerge is broken (kills the x bit of directories), and zip --grow does not unpack input zipfiles. + cd $TMP_UNPACK_FOLDER sed -e '1d' $TMPFILE | while read file; do - # zip incorrectly stores the full path, so cd and then grow - cd `dirname "$file"` - zip -g "$superfile" `basename "$file"` && rm -f "$file" + unzip -q "$file" && rm -f "$file" done - cd "$OLD_PWD" + zip --quiet --recurse-paths "$superfile" . fi echo "$superfile" >| $TMPFILE # clobber on purpose From 18d629c0c919508a71699a9d67a590bab5cac96b Mon Sep 17 00:00:00 2001 From: Maximilian Gaukler Date: Wed, 3 Jun 2020 13:50:41 +0200 Subject: [PATCH 3/3] Fix regression: Secure temporary directory, fix output file parameter --- git-archive-all.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-archive-all.sh b/git-archive-all.sh index 71d29a3..9f1a5d0 100755 --- a/git-archive-all.sh +++ b/git-archive-all.sh @@ -47,10 +47,7 @@ OLD_IFS=$IFS IFS="$(printf '\n \t')" function cleanup () { - rm -f $TMPFILE - rm -f $TMPLIST - rm -rf $TMP_UNPACK_FOLDER - rm -f $TOARCHIVE + rm -rf $MYTMPDIR IFS="$OLD_IFS" } @@ -189,6 +186,8 @@ done OLD_PWD="`pwd`" TMPDIR=${TMPDIR:-/tmp} +MYTMPDIR=`mktemp -d "$TMPDIR/$PROGRAM.XXXXXX"` +TMPDIR=$MYTMPDIR TMPFILE=`mktemp "$TMPDIR/$PROGRAM.XXXXXX"` # Create a place to store our work's progress TMPLIST=`mktemp "$TMPDIR/$PROGRAM.submodules.XXXXXX"` TMP_UNPACK_FOLDER=`mktemp -d "$TMPDIR/$PROGRAM.tmp_unpack_folder.XXXXXX"` @@ -296,6 +295,7 @@ if [ $SEPARATE -eq 0 -o "-" == "$OUT_FILE" ]; then unzip -q "$file" && rm -f "$file" done zip --quiet --recurse-paths "$superfile" . + cd "$OLD_PWD" fi echo "$superfile" >| $TMPFILE # clobber on purpose