From e3910c5675e38d1749b3ff1930d2ac73f83cbc38 Mon Sep 17 00:00:00 2001 From: "G.raud" Date: Sat, 28 Apr 2018 13:12:25 +0200 Subject: [PATCH] archives2git: [fix] support whitespace and glob chars in option supplied args --- archives2git | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/archives2git b/archives2git index 7017300..3a825fb 100755 --- a/archives2git +++ b/archives2git @@ -131,6 +131,8 @@ strip_extension () { -e '$s;\.(tar|t[Zz]|tzo|tbz|tgz|tbz2|txz|t7z|tlz|lha|lzh|7z|alz|arj|zip|rar|jar|war|ace|cab|a|cpio|shar|rpm|deb)$;;' \ -e '$s;\.(orig)$;;' } +NL=' +' # default parameters UNPACK= @@ -189,7 +191,7 @@ do --keep-filter) shift; FILTER=$1 ;; --gitadd-arg) - shift; ADDARGS="$ADDARGS $1" ;; + shift; ADDARGS="$ADDARGS$NL$1" ;; --date) shift; DATE=$1 ;; --author) @@ -199,7 +201,7 @@ do --body) shift; BODY=$1 ;; --gitci-arg) - shift; CIARGS="$CIARGS $1" ;; + shift; CIARGS="$CIARGS$NL$1" ;; --gitfilter) shift; FILTERHEAD=$1 ;; --tag) @@ -232,8 +234,6 @@ do shift done # setup -NL=' -' [ -z "$KEEP_TEMPDIR" ] && trap 'rm -rf "$TMPDIR"' EXIT INT QUIT TERM TMPDIR=$(mktemp -d) || { @@ -297,7 +297,9 @@ do echo >&2 "WARNING: conflicting file removed: \`$name'" fi mv "$archdir"/"$file" ./"$name" + IFS=$NL; set -f git add $ADDARGS ./"$name" + set +f; IFS=$OLDIFS else rm -R "$archdir"/"$file" fi @@ -308,14 +310,14 @@ do date=$(eval "$DATE") author=$(eval "$AUTHOR") title=$(eval "$TITLE") - git commit ${AUTHOR:+--author "$author"} -m "$title"${BODY:+"$NL$NL$BODY"} ${DATE:+--date "$date"} $CIARGS + IFS=$NL; set -f + git commit ${AUTHOR:+--author$NL"$author"} -m "$title"${BODY:+"$NL$NL$BODY"} ${DATE:+--date$NL"$date"} $CIARGS if [ -n "$FILTERHEAD" ] then - IFS=$NL; set -f git filter-branch $FILTERHEAD -- HEAD^..HEAD rm -R "$(git rev-parse --git-dir)"/refs/original/ - set +f; IFS=$OLDIFS fi + set +f; IFS=$OLDIFS if [ -n "$TAG" ] then tagmessage=$(eval "$TAG" | LC_ALL=C tail -n +2) -- 2.11.4.GIT