git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: git@vger.kernel.org
Cc: Chris Packham <judge.packham@gmail.com>
Subject: [RFC/PATCH] rebase--interactive: Add "sign" command
Date: Wed,  3 Aug 2016 20:47:43 +1200	[thread overview]
Message-ID: <20160803084743.3299-1-judge.packham@gmail.com> (raw)

This is similar to the existing "reword" command in that it can be used
to update the commit message the difference is that the editor presented
to the user for the commit. It provides a useful shorthand for "exec git
commit --amend --no-edit -s"

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
Hi,

At $dayjob we have a patch based work-flow where committers sign patches on the
way through. Occasionally when a larger patch series is involved it's easier
pull from the submitter's repo and use git rebase -i to add the required sign
off either by using 'reword' or 'exec git commit --amend -s'.

This is my attempt at making this a little less cumbersome by adding a
'sign' command. I decided not to add a short version of the command,
partly because 's' was taken and partly because it is a bit of a niche
use-case.

Thanks,
Chris

 git-rebase--interactive.sh    | 10 +++++++++-
 t/lib-rebase.sh               |  2 +-
 t/t3404-rebase-interactive.sh |  9 +++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index ded4595..1cd8bc6 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -148,6 +148,7 @@ append_todo_help () {
 Commands:
  p, pick = use commit
  r, reword = use commit, but edit the commit message
+ sign = use commit, add sign-off to the commit message
  e, edit = use commit, but stop for amending
  s, squash = use commit, but meld into previous commit
  f, fixup = like \"squash\", but discard this commit's log message
@@ -594,6 +595,13 @@ you are able to reword the commit.")"
 		}
 		record_in_rewritten $sha1
 		;;
+	sign)
+		comment_for_reflog sign
+		mark_action_done
+		do_pick $sha1 "$rest"
+		git commit --amend -s --no-post-rewrite --no-edit ${gpg_sign_opt:+"$gpg_sign_opt"}
+		record_in_rewritten $sha1
+		;;
 	edit|e)
 		comment_for_reflog edit
 
@@ -959,7 +967,7 @@ check_bad_cmd_and_sha () {
 			# Work around CR left by "read" (e.g. with Git for
 			# Windows' Bash).
 			;;
-		pick|p|drop|d|reword|r|edit|e|squash|s|fixup|f)
+		pick|p|drop|d|reword|r|sign|edit|e|squash|s|fixup|f)
 			if ! check_commit_sha "${rest%%[ 	]*}" "$lineno" "$1"
 			then
 				retval=1
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 25a77ee..5a54228 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -47,7 +47,7 @@ set_fake_editor () {
 	action=pick
 	for line in $FAKE_LINES; do
 		case $line in
-		squash|fixup|edit|reword|drop)
+		squash|fixup|edit|reword|sign|drop)
 			action="$line";;
 		exec*)
 			echo "$line" | sed 's/_/ /g' >> "$1";;
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 197914b..e473ffb 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -690,6 +690,15 @@ test_expect_success 'reword' '
 	git show HEAD~2 | grep "C changed"
 '
 
+test_expect_success 'sign-off' '
+	git checkout -b sign-off-branch master &&
+	set_fake_editor &&
+	FAKE_LINES="1 2 3 sign 4" git rebase -i A &&
+	git show HEAD | grep "Signed-off-by:" &&
+	test $(git rev-parse master) != $(git rev-parse HEAD) &&
+	test $(git rev-parse master^) = $(git rev-parse HEAD^)
+'
+
 test_expect_success 'rebase -i can copy notes' '
 	git config notes.rewrite.rebase true &&
 	git config notes.rewriteRef "refs/notes/*" &&
-- 
2.9.2.518.ged577c6.dirty


             reply	other threads:[~2016-08-03  8:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03  8:47 Chris Packham [this message]
2016-08-03 14:31 ` [RFC/PATCH] rebase--interactive: Add "sign" command Johannes Schindelin
2016-08-03 15:19   ` Johannes Schindelin
2016-08-03 16:08   ` Junio C Hamano
2016-08-03 16:15     ` Johannes Schindelin
2016-08-03 18:08     ` Jeff King
2016-08-04  0:53       ` Chris Packham
2016-08-04 16:05       ` Junio C Hamano
2016-08-05 16:04       ` Johannes Schindelin
2016-08-04  0:41   ` Chris Packham
2016-08-03 15:58 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160803084743.3299-1-judge.packham@gmail.com \
    --to=judge.packham@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).