git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[TopGit PATCH 07/11] tg-mail: accept -i/-w

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Oct 9, 2010, 20:56 UTC
Message-ID
<65565f00635372ad3677c0187c33da4d3ceb4b73.1286657607.git.bert.wesarg@googlemail.com>
In-Reply-To
<62e3424559a93dc0f7c3ed55aafce738f2b0f6d3.1286657607.git.bert.wesarg@googlemail.com>
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 README                     |    4 ++++
 contrib/tg-completion.bash |    8 ++++++++
 tg-mail.sh                 |   12 +++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/README b/README
index eea0d72..538659a 100644 README
--- a/README
+++ b/README
@@ -315,6 +315,10 @@ tg mail
 
 	to let `git send-email` ask for confirmation before sending any mail.
 
+	Options:
+	  -i		base patch generation on index instead of branch
+	  -w		base patch generation on working tree instead of branch
+
 	TODO: 'tg mail patchfile' to mail an already exported patch
 	TODO: mailing patch series
 	TODO: specifying additional options and addresses on command
diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash
index 6a1e182..b7051b8 100755 contrib/tg-completion.bash
--- a/contrib/tg-completion.bash
+++ b/contrib/tg-completion.bash
@@ -359,6 +359,14 @@ _tg_mail ()
 	local cur="${COMP_WORDS[COMP_CWORD]}"
 
 	case "$cur" in
+	-*)
+		__tgcomp "
+			-i
+			-w
+			-s
+			-r
+		"
+		;;
 	*)
 		__tgcomp "$(__tg_topics)"
 	esac
diff --git a/tg-mail.sh b/tg-mail.sh
index 8167ade..6ddcf08 100644 tg-mail.sh
--- a/tg-mail.sh
+++ b/tg-mail.sh
@@ -3,6 +3,7 @@
 # GPLv2
 
 name=
+head_from=
 send_email_args=
 in_reply_to=
 
@@ -12,12 +13,15 @@ in_reply_to=
 while [ -n "$1" ]; do
 	arg="$1"; shift
 	case "$arg" in
+	-i|-w)
+		[ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+		head_from="$arg";;
 	-s)
 		send_email_args="$1"; shift;;
 	-r)
 		in_reply_to="$1"; shift;;
 	-*)
-		echo "Usage: tg [...] mail [-s SEND_EMAIL_ARGS] [-r REFERENCE_MSGID] [NAME]" >&2
+		echo "Usage: tg [...] mail [-s SEND_EMAIL_ARGS] [-r REFERENCE_MSGID] [-i | -w] [NAME]" >&2
 		exit 1;;
 	*)
 		[ -z "$name" ] || die "name already specified ($name)"
@@ -25,7 +29,8 @@ while [ -n "$1" ]; do
 	esac
 done
 
-[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+head="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+[ -n "$name" ] || name="$head"
 base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
 	die "not a TopGit-controlled branch"
 
@@ -36,7 +41,8 @@ fi
 
 patchfile="$(mktemp -t tg-mail.XXXXXX)"
 
-$tg patch "$name" >"$patchfile"
+# let tg patch sort out whether $head_from makes sense for $name
+$tg patch "$name" $head_from >"$patchfile"
 
 header="$(sed -e '/^$/,$d' -e "s,','\\\\'',g" "$patchfile")"
 
-- 
1.7.1.1067.g5aeb7
Previous: Bert WesargNext: Bert Wesarg
Message 7 of 11 in “cat_file: take -i/-w parameters”
  1. 01/11 cat_file: take -i/-w parametersBert Wesarg, Oct 9, 2010
  2. 02/11 pretty_tree: globalize and respect -i/-w optionsBert Wesarg, Oct 9, 2010
  3. 03/11 branch_empty: use pretty_tree and therefore respect -i/-wBert Wesarg, Oct 9, 2010
  4. 04/11 tg-path: use pretty_tree and diff-tree to generate the patchBert Wesarg, Oct 9, 2010
  5. 05/11 list_deps: accept -i/-wBert Wesarg, Oct 9, 2010
  6. 06/11 tg-summary: accept -i/-wBert Wesarg, Oct 9, 2010
  7. 07/11 tg-mail: accept -i/-wBert Wesarg, Oct 9, 2010
  8. 08/11 tg-files: list files changed by the topic branchBert Wesarg, Oct 9, 2010
  9. 09/11 tg-prev/tg-next: commands to explore dependenciesBert Wesarg, Oct 9, 2010
  10. 10/11 [RFC] tg-patch: use ui diff when pager is activeBert Wesarg, Oct 9, 2010
  11. 11/11 [RFC] tg-patch: simulate mnemonic prefixesBert Wesarg, Oct 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.