summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-12-23 18:40:41 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-12-23 18:40:41 -0500
commit81a06dee07d59095ed08241f406fa41835c678d9 (patch)
tree2c746f802ce81b251f1f8decbdd95dbffbc311ff
parent888d6d8eee3f0f887501f0b857e96f8681459c3f (diff)
git-rewrite-branch: change verbose() to use printf instead of interpolation
-rwxr-xr-xgit-rewrite-branch28
1 files changed, 16 insertions, 12 deletions
diff --git a/git-rewrite-branch b/git-rewrite-branch
index 390170b..c7b3e9f 100755
--- a/git-rewrite-branch
+++ b/git-rewrite-branch
@@ -52,8 +52,8 @@ panic() {
exit 1
}
-# Usage: verbose arg1 arg2...
-# Print the arguments, but only if in verbose mode.
+# Usage: verbose format arg1 arg2...
+# Print the printf string, but only if in verbose mode.
# Verbose mode works by redefining this function during option parsing if -v is
# encountered.
verbose() {
@@ -118,7 +118,11 @@ main() {
--no-tag) hastag=false; tag='git-rewrite-id'; shift 1 ;;
-h) usage; return 0;;
-v)
- verbose() { echo "$*"; }
+ verbose() {
+ local fmt=$1
+ shift
+ printf "${fmt}\n" "$@"
+ }
shift
;;
*) break;;
@@ -200,17 +204,17 @@ main() {
local commonish="$(c2c "$obranch" "$wbranch" "$obranch")"
cmd=(git rebase --onto "$obranch" "$commonish" "$wbranch")
- verbose
- verbose " o---o---o $obranch"
+ verbose ''
+ verbose ' o---o---o %s' "$obranch"
verbose ' :'
- verbose " o---o---o---o---o $ibranch"
+ verbose ' o---o---o---o---o %s' "$ibranch"
verbose ' \ :'
- verbose ' `-C---o---o '"$wbranch"
- verbose
- verbose " C = $commonish"
- verbose
- verbose " ${cmd[*]}"
- verbose
+ verbose ' `-C---o---o %s' "$wbranch"
+ verbose ''
+ verbose ' C = %s' "$commonish"
+ verbose ''
+ verbose ' %s' "$(printf '%q ' "${cmd[@]}")"
+ verbose ''
"${cmd[@]}"
git checkout "$obranch"