]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
scripts/git: Quote shell arguments where possible
authorteor <teor@torproject.org>
Thu, 29 Aug 2019 12:53:44 +0000 (22:53 +1000)
committerteor <teor@torproject.org>
Thu, 29 Aug 2019 12:53:44 +0000 (22:53 +1000)
Most shell arguments should be quoted to avoid mistakes.

But since all branch names are hard-coded, or supplied by the script user,
we don't need to be too concerned about command injection.

Quoting all shell arguments would take a major refactor.
(Probably using arrays.)

Part of 31314.

scripts/git/git-merge-forward.sh
scripts/git/git-push-all.sh

index b9591eaa7e265a32c30b42e6e175b7c3be2ee8f1..720320c9fedef71ccd8ec9316605802f243fd10d 100755 (executable)
@@ -227,7 +227,7 @@ function validate_ret
 # Switch to the given branch name.
 function switch_branch
 {
-  local cmd="git checkout $1"
+  local cmd="git checkout '$1'"
   printf "  %s Switching branch to %s..." "$MARKER" "$1"
   if [ $DRY_RUN -eq 0 ]; then
     msg=$( eval "$cmd" 2>&1 )
@@ -240,7 +240,7 @@ function switch_branch
 # Checkout a new branch with the given branch name.
 function new_branch
 {
-  local cmd="git checkout -b $1"
+  local cmd="git checkout -b '$1'"
   printf "  %s Creating new branch %s..." "$MARKER" "$1"
   if [ $DRY_RUN -eq 0 ]; then
     msg=$( eval "$cmd" 2>&1 )
@@ -254,7 +254,7 @@ function new_branch
 # branch name.
 function switch_or_new_branch
 {
-  local cmd="git rev-parse --verify $1"
+  local cmd="git rev-parse --verify '$1'"
   if [ $DRY_RUN -eq 0 ]; then
     # Call switch_branch if there is a branch, or new_branch if there is not
     msg=$( eval "$cmd" 2>&1 )
@@ -292,7 +292,7 @@ function pull_branch
 # Merge the given branch name ($1) into the current branch ($2).
 function merge_branch
 {
-  local cmd="git merge --no-edit $1"
+  local cmd="git merge --no-edit '$1'"
   printf "  %s Merging branch %s into %s..." "$MARKER" "$1" "$2"
   if [ $DRY_RUN -eq 0 ]; then
     msg=$( eval "$cmd" 2>&1 )
@@ -305,7 +305,7 @@ function merge_branch
 # Pull the given branch name.
 function merge_branch_origin
 {
-  local cmd="git merge --ff-only origin/$1"
+  local cmd="git merge --ff-only 'origin/$1'"
   printf "  %s Merging branch origin/%s..." "$MARKER" "$1"
   if [ $DRY_RUN -eq 0 ]; then
     msg=$( eval "$cmd" 2>&1 )
index 0b3cfcd88ee3579b3abf806ac4b7370d4e3c7ea9..37a73ec95fbe515c8870fa50c6407c8ab5325271 100755 (executable)
@@ -171,7 +171,7 @@ fi
 if [ "$PUSH_SAME" -eq 0 -a "$TEST_BRANCH_PREFIX" ]; then
   NEW_PUSH_BRANCHES=
   for b in $PUSH_BRANCHES; do
-    PUSH_COMMIT=`git rev-parse $b`
+    PUSH_COMMIT=`git rev-parse "$b"`
     SKIP_UPSTREAM=
     for u in $DEFAULT_UPSTREAM_BRANCHES $UPSTREAM_BRANCHES; do
       UPSTREAM_COMMIT=`git rev-parse "$u"`