summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"