chiark / gitweb /
tg export: Fix exporting remote-based branches
[topgit.git] / tg-mail.sh
index f3abd2c0285493e748fd9809e0cb921b985dccc9..7e394b894cc630bf01fcef92fc09956aaed87a77 100644 (file)
@@ -19,7 +19,6 @@ while [ -n "$1" ]; do
        esac
 done
 
-# TODO refactor me into something common?
 [ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
 base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
        die "not a TopGit-controlled branch"
@@ -30,7 +29,7 @@ patchfile="$(mktemp -t tg-mail.XXXXXX)"
 $tg patch $name >"$patchfile"
 
 hlines=$(grep -n -m 1 '^---' "$patchfile" | sed 's/:---//')
-header=$(head -$(($hlines - 1)) "$patchfile")
+header=$(head -$(($hlines - 1)) "$patchfile")
 
 
 
@@ -38,16 +37,14 @@ from="$(echo "$header" | grep '^From:' | sed 's/From:\s*//')"
 to="$(echo "$header" | grep '^To:' | sed 's/To:\s*//')"
 
 
-# XXX I can't get quoting right without arrays
-[ -n "$from" ] && from=(--from "$from")
-[ -n "$to"   ] && to=(--to "$to") # FIXME there could be multimple To
-
+# XXX: I can't get quoting right without arrays
 people=()
-[ -n "$from" ] && people=("${people[@]}" "${from[@]}")
-[ -n "$to" ]   && people=("${people[@]}" "${to[@]}")
+[ -n "$from" ] && people=("${people[@]}" --from "$from")
+# FIXME: there could be multimple To
+[ -n "$to" ]   && people=("${people[@]}" --to "$to")
 
 
-# NOTE git-send-email handles cc itself
+# NOTE: git-send-email handles cc itself
 git send-email "${people[@]}" "$patchfile"
 
 rm "$patchfile"