threads / patch / 10089

patchrebase: add --signoff option

Subject: [PATCH] rebase: add --signoff option

## tl;dr

6 messages between Sep 30, 2007 and Oct 1, 2007. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Steffen Prohaska· Sep 30, 2007, 16:15 UTC · lore

When preparing a series of commits for upstream you may need to signoff commits if you forgot to do so earlier. This patch teaches git-rebase to signoff during rebase if you pass the option --signoff.

Notes
1) --signoff cannot be used simultaneously with --interactive.
2) --signoff forces a rebase even if current path is a
   descendant of <upstream>.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 Documentation/git-rebase.txt |    9 +++++++--
 git-rebase--interactive.sh   |    3 +++
 git-rebase.sh                |   10 ++++++++--
 3 files changed, 18 insertions(+), 4 deletions(-)
Show changes to 3 files +18 −4

Documentation/git-rebase.txt, git-rebase--interactive.sh, git-rebase.sh

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index e8e7579..befe337 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -8,8 +8,8 @@ git-rebase - Forward-port local commits to the updated upstream head
 SYNOPSIS
 --------
 [verse]
-'git-rebase' [-i | --interactive] [-v | --verbose] [-m | --merge]
-	[-C<n>] [ --whitespace=<option>] [-p | --preserve-merges]
+'git-rebase' [-i | --interactive] [-v | --verbose] [-m | --merge] [-C<n>]
+    [--signoff] [ --whitespace=<option>] [-p | --preserve-merges]
 	[--onto <newbase>] <upstream> [<branch>]
 'git-rebase' --continue | --skip | --abort
 
@@ -201,6 +201,11 @@ OPTIONS
 	is used instead (`git-merge-recursive` when merging a single
 	head, `git-merge-octopus` otherwise).  This implies --merge.
 
+--signoff::
+	Add `Signed-off-by:` line to each commit message, using
+	the committer identity of yourself.
+
+
 -v, \--verbose::
 	Display a diffstat of what changed upstream since the last rebase.
 
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 8568a4f..29cef17 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -395,6 +395,9 @@ do
 	-C*)
 		die "Interactive rebase uses merge, so $1 does not make sense"
 		;;
+	--si|--sig|--sign|--signo|--signof|--signoff)
+		die "Interactive rebase doesn't support simultaneous signoff."
+		;;
 	-v|--verbose)
 		VERBOSE=t
 		;;
diff --git a/git-rebase.sh b/git-rebase.sh
index 1583402..3b06bf4 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -46,6 +46,7 @@ dotest=$GIT_DIR/.dotest-merge
 prec=4
 verbose=
 git_am_opt=
+opt_signoff=
 
 continue_merge () {
 	test -n "$prev_head" || die "prev_head must be defined"
@@ -200,7 +201,7 @@ do
 		;;
 	-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
 		--strateg=*|--strategy=*|\
-	-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
+	-s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
 		case "$#,$1" in
 		*,*=*)
 			strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;;
@@ -221,6 +222,10 @@ do
 	-C*)
 		git_am_opt="$git_am_opt $1"
 		;;
+	--si|--sig|--sign|--signo|--signof|--signoff)
+		git_am_opt="$git_am_opt --signoff"
+		opt_signoff=t
+		;;
 	-*)
 		usage
 		;;
@@ -302,8 +307,9 @@ branch=$(git rev-parse --verify "${branch_name}^0") || exit
 
 # Check if we are already based on $onto with linear history,
 # but this should be done only when upstream and onto are the same.
+# The check must also be skipped if signoff is requested.
 mb=$(git merge-base "$onto" "$branch")
-if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
+if test "$upstream" = "$onto" && test "$mb" = "$onto" && test -z "$opt_signoff" &&
 	# linear history?
 	! git rev-list --parents "$onto".."$branch" | grep " .* " > /dev/null
 then
-- 
1.5.3.3.127.g40d17
Johannes Schindelin· Sep 30, 2007, 21:30 UTC · re: Steffen Prohaska · lore

Re: [PATCH] rebase: add --signoff option

Hi,
On Sun, 30 Sep 2007, Steffen Prohaska wrote:
> When preparing a series of commits for upstream you may
> need to signoff commits if you forgot to do so earlier.
Why not use format-patch's --signoff option for that?

Ciao, Dscho

Steffen Prohaska· Sep 30, 2007, 21:38 UTC · re: Johannes Schindelin · lore

Re: [PATCH] rebase: add --signoff option

On Sep 30, 2007, at 11:30 PM, Johannes Schindelin wrote:
Show 6 quoted lines
> On Sun, 30 Sep 2007, Steffen Prohaska wrote:
>
>> When preparing a series of commits for upstream you may
>> need to signoff commits if you forgot to do so earlier.
>
> Why not use format-patch's --signoff option for that?

format-patch is fine for mail. But if I either push the commits to a shared repo (like msysgit's mob) or ask upstream to pull from my public repo format-patch doesn't help directly.

	Steffen
Johannes Schindelin· Sep 30, 2007, 21:41 UTC · re: Steffen Prohaska · lore

Re: [PATCH] rebase: add --signoff option

Hi,
On Sun, 30 Sep 2007, Steffen Prohaska wrote:
Show 12 quoted lines
> On Sep 30, 2007, at 11:30 PM, Johannes Schindelin wrote:
> 
> > On Sun, 30 Sep 2007, Steffen Prohaska wrote:
> > 
> > > When preparing a series of commits for upstream you may need to 
> > > signoff commits if you forgot to do so earlier.
> > 
> > Why not use format-patch's --signoff option for that?
> 
> format-patch is fine for mail. But if I either push the commits to a 
> shared repo (like msysgit's mob) or ask upstream to pull from my public 
> repo format-patch doesn't help directly.

Fair enough. But maybe "rebase --interactive" is not too difficult, either?

Ciao, Dscho

Steffen Prohaska· Oct 1, 2007, 04:59 UTC · re: Johannes Schindelin · lore

Re: [PATCH] rebase: add --signoff option

On Sep 30, 2007, at 11:41 PM, Johannes Schindelin wrote:
Show 18 quoted lines
> On Sun, 30 Sep 2007, Steffen Prohaska wrote:
>
>> On Sep 30, 2007, at 11:30 PM, Johannes Schindelin wrote:
>>
>>> On Sun, 30 Sep 2007, Steffen Prohaska wrote:
>>>
>>>> When preparing a series of commits for upstream you may need to
>>>> signoff commits if you forgot to do so earlier.
>>>
>>> Why not use format-patch's --signoff option for that?
>>
>> format-patch is fine for mail. But if I either push the commits to a
>> shared repo (like msysgit's mob) or ask upstream to pull from my  
>> public
>> repo format-patch doesn't help directly.
>
> Fair enough.  But maybe "rebase --interactive" is not too difficult,
> either?

But not too easy either because "rebase --interactive" is based on "git merge" and not "git am". You can just use a two step process instead and first "rebase --interactive" followed by "rebase --signoff".

	Steffen
Junio C Hamano· Oct 1, 2007, 08:20 UTC · re: Steffen Prohaska · lore

Re: [PATCH] rebase: add --signoff option

Steffen Prohaska <prohaska@zib.de> writes:
Show 11 quoted lines
> When preparing a series of commits for upstream you may
> need to signoff commits if you forgot to do so earlier.
> This patch teaches git-rebase to signoff during rebase
> if you pass the option --signoff.
>
> Notes
> 1) --signoff cannot be used simultaneously with --interactive.
> 2) --signoff forces a rebase even if current path is a
>    descendant of <upstream>.
>
> Signed-off-by: Steffen Prohaska <prohaska@zib.de>

I do not think it is fatal for --signoff to be incompatible with the "interactive" mode is fatal, but lack of mention in the documentation is. Also this would need test scripts to prevent it from getting broken by future changes by others. I'd like to see ones that test at least the cases where (1) nobody has sign-off, (2) you do not have sign-off but others do, and (3) you already have sign-off at the end.

But I do like the general concept.

← back to recent threads