From: Kong Lucien <hidden> Date: 2016-06-15 22:53:58
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable. At this point, you can't use --exec without the
interactive mode (-i).
Tests about this new command are also added in
t3404-rebase-interactive.sh.
Signed-off-by: Kong Lucien <redacted>
Signed-off-by: Valentin Duperray <redacted>
Signed-off-by: Franck Jonas <redacted>
Signed-off-by: Thomas Nguy <redacted>
Signed-off-by: Huynh Khoi Nguyen Nguyen <redacted>
Signed-off-by: Matthieu Moy <redacted>
---
Documentation/git-rebase.txt | 43 ++++++++++++++++++++++-
git-rebase--interactive.sh | 13 +++++++
git-rebase.sh | 35 +++++++++++++++++--
t/t3404-rebase-interactive.sh | 74 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 159 insertions(+), 6 deletions(-)
@@ -210,6 +210,17 @@ rebase.autosquash:: OPTIONS -------+<cmd>::+ Shell command executed between each commit applications. The+ --exec option has to be specified.+++You may execute several commands between each commit applications.+Therefore, you can use one instance of exec:+ git rebase -i --exec "cmd1; cmd2; ...".+You can also insert several instances of exec, if you wish to+only have one command per line for example:+ git rebase -i --exec "cmd1" --exec "cmd2" ...+ <newbase>:: Starting point at which to create the new commits. If the --onto option is not specified, the starting point is
@@ -336,6 +347,13 @@ link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for details). user edit that list before rebasing. This mode can also be used to split commits (see SPLITTING COMMITS below).+-x::+--exec::+ Automatically add "exec" followed by <cmd> between each commit+ applications (see INTERACTIVE MODE below).+++This has to be used along with the `--interactive` option explicitly.+ -p:: --preserve-merges:: Instead of ignoring merges, try to recreate them.
@@ -521,6 +539,27 @@ in `$SHELL`, or the default shell if `$SHELL` is not set), so you can use shell features (like "cd", ">", ";" ...). The command is run from the root of the working tree.+----------------------------------+$ git rebase -i --exec "make test"+----------------------------------++This command lets you check that intermediate commits are compilable.+The todo list becomes like that:++--------------------+pick 5928aea one+exec make test+pick 04d0fda two+exec make test+pick ba46169 three+exec make test+pick f4593f9 four+exec make test+--------------------++If the option '-i' is missing, The command will return the usage page+of "git rebase". Same if there is no <cmd> specified behind --exec.+ SPLITTING COMMITS -----------------
@@ -43,6 +44,7 @@ s,strategy=! use the given merge strategy no-ff!cherry-pickallcommits,evenifunchanged m,merge!usemergingstrategiestorebase i,interactive!lettheusereditthelistofcommitstorebase+x,exec=!addexeclinesaftereachcommitoftheeditablelist k,keep-emptypreserveemptycommitsduringrebase f,force-rebase!forcerebaseevenifbranchisuptodate X,strategy-option=!passtheargumentthroughtothemergestrategy
@@ -76,6 +78,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". Tocheckouttheoriginalbranchandstoprebasingrun\"gitrebase--abort\"."unsetonto+unsetcmdstrategy=strategy_opts=do_merge=
@@ -219,6 +222,24 @@ doonto="$2"shift;;+-x)+exec_flag=true+test3-le"$#"||usage+iforig_head=$(gitrev-parse-q--verify"$2")||+test`exprsubstr"$2"11`=-+then+echo"You must specify a command after --exec option\n"+usage+else+iftest-n"$cmd"+then+cmd="$2,$cmd"+else+cmd="$2"+fi+fi+shift+;;-i)interactive_rebase=explicit;;
@@ -304,6 +325,13 @@ dodonetest$#-gt2&&usage+iftest-n"$exec_flag"&&+test-z"$interactive_rebase"+then+echo"--exec option must be used with --interactive option\n"+usage+fi+iftest-n"$action"thentest-z"$in_progress"&&die"No rebase in progress?"
@@ -348,7 +376,6 @@ abort)exit;;esac-# Make sure no rebase is in progressiftest-n"$in_progress"then
@@ -755,4 +755,78 @@ test_expect_success 'rebase-i history with funny messages' 'test_cmpexpectactual'++test_expect_success'running "git rebase -i --exec git show HEAD"''+gitcheckoutmaster&&+gitcheckout-bexecute&&+test_commitone_execmain.txtone_exec&&+test_committwo_execmain.txttwo_exec&&+test_committhree_execmain.txtthree_exec&&+gitrebase-i--exec"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase --exec git show HEAD -i"''+gitrebase--exec"git show HEAD"-iHEAD~2>actual&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase -ix git show HEAD"''+gitrebase-ix"git show HEAD"HEAD~2>actual&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several <CMD>''+gitrebase-ix"git show HEAD; pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several instances of --exec''+gitrebase-i--exec"git show HEAD"--exec"pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2+exec_git_show_HEADexec_pwd" &&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,11d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase --exec without -i shows error message and usage ''+test_must_failgitrebase--exec"git show HEAD"HEAD~2>actual&&+echo"--exec option must be used with --interactive option\n">expected&&+test_must_failgitrebase-h>>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -i --exec without <CMD> shows error message and usage ''+test_must_failgitrebase-i--execHEAD~2>actual&&+echo"You must specify a command after --exec option\n">expected&&+test_must_failgitrebase-h>>expected&&+test_cmpexpectedactual&&+gitcheckoutmaster+'+ test_done
From: Lucien Kong <hidden> Date: 2016-06-15 22:53:59
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable. It is also compatible with the option --autosquash. At
this point, you can't use --exec without the interactive mode (-i).
Tests about this new command are also added in
t3404-rebase-interactive.sh.
Signed-off-by: Lucien Kong <redacted>
Signed-off-by: Valentin Duperray <redacted>
Signed-off-by: Franck Jonas <redacted>
Signed-off-by: Thomas Nguy <redacted>
Signed-off-by: Huynh Khoi Nguyen Nguyen <redacted>
Signed-off-by: Matthieu Moy <redacted>
---
The part of --onto in the documentation is changed to be consistent
with the other options. The exec line, when using the option --autosquash,
is now only added after the squash/fixup series.
Documentation/git-rebase.txt | 54 +++++++++++++++--
git-rebase--interactive.sh | 19 ++++++
git-rebase.sh | 20 ++++++-
t/t3404-rebase-interactive.sh | 124 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 207 insertions(+), 10 deletions(-)
@@ -210,11 +210,29 @@ rebase.autosquash:: OPTIONS --------<newbase>::- Starting point at which to create the new commits. If the- --onto option is not specified, the starting point is- <upstream>. May be any valid commit, and not just an- existing branch name.+-x <cmd>::+--exec <cmd>::+ Automatically add "exec" followed by <cmd> between each commit+ applications. Using this option along with --autosquash adds+ the exec line after the squash/fixeup series only. <cmd>+ stands for shell commands. The --exec option has to be+ specified. (see INTERACTIVE MODE below)+++This has to be used along with the `--interactive` option explicitly.+You may execute several commands between each commit applications.+For this, you can use one instance of exec:+ git rebase -i --exec "cmd1; cmd2; ...".+You can also insert several instances of exec, if you wish to+only have one command per line for example:+ git rebase -i --exec "cmd1" --exec "cmd2" ...++--onto <newbase>::+ With this option, git rebase takes all commits from <branch>,+ that are not in <upstream>, and transplant them on top of+ <newbase>. <newbase> is the starting point at which to create+ the new commits. If the --onto option is not specified, the+ starting point is <upstream>. May be any valid commit, and+ not just an existing branch name. + As a special case, you may use "A\...B" as a shortcut for the merge base of A and B if there is exactly one merge base. You can
@@ -521,6 +539,28 @@ in `$SHELL`, or the default shell if `$SHELL` is not set), so you can use shell features (like "cd", ">", ";" ...). The command is run from the root of the working tree.+----------------------------------+$ git rebase -i --exec "make test"+----------------------------------++This command lets you check that intermediate commits are compilable.+The todo list becomes like that:++--------------------+pick 5928aea one+exec make test+pick 04d0fda two+exec make test+pick ba46169 three+exec make test+pick f4593f9 four+exec make test+--------------------++If the option '-i' is missing, The command will return a message+error. If there is no <cmd> specified behind --exec, the command will+return a message error and the usage page of 'git rebase'.+ SPLITTING COMMITS -----------------
@@ -684,6 +684,23 @@ rearrange_squash () {rm-f"$1.sq""$1.rearranged"}+# Add commands after a pick or after a squash/fixup serie+# in the todo list.+add_exec_commands(){+OIFS=$IFS+IFS=$LF+foriin$cmd+do+tmp=$(sed"/^pick .*/i\+exec$i" "$1")+echo"$tmp">"$1"+tmp=$(sed'1d'"$1")+echo"$tmp">"$1"+echo"exec $i">>"$1"+done+IFS=$OIFS+}+case"$action"incontinue)# do we have anything to commit?
@@ -857,6 +874,8 @@ fitest-s"$todo"||echonoop>>"$todo"test-n"$autosquash"&&rearrange_squash"$todo"+test-n"$cmd"&&add_exec_commands"$todo"+ cat>>"$todo"<<EOF# Rebase $shortrevisions onto $shortonto
@@ -43,6 +44,7 @@ s,strategy=! use the given merge strategy no-ff!cherry-pickallcommits,evenifunchanged m,merge!usemergingstrategiestorebase i,interactive!lettheusereditthelistofcommitstorebase+x,exec=!addexeclinesaftereachcommitoftheeditablelist k,keep-emptypreserveemptycommitsduringrebase f,force-rebase!forcerebaseevenifbranchisuptodate X,strategy-option=!passtheargumentthroughtothemergestrategy
@@ -76,6 +78,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". Tocheckouttheoriginalbranchandstoprebasingrun\"gitrebase--abort\"."unsetonto+cmd=strategy=strategy_opts=do_merge=
@@ -304,6 +312,12 @@ dodonetest$#-gt2&&usage+iftest-n"$cmd"&&+test"$interactive_rebase"!=explicit+then+die"--exec option must be used with --interactive option\n"+fi+iftest-n"$action"thentest-z"$in_progress"&&die"No rebase in progress?"
@@ -755,4 +755,128 @@ test_expect_success 'rebase-i history with funny messages' 'test_cmpexpectactual'++test_expect_success'prepare for rebase -i --exec''+gitcheckoutmaster&&+gitcheckout-bexecute&&+test_commitone_execmain.txtone_exec&&+test_committwo_execmain.txttwo_exec&&+test_committhree_execmain.txtthree_exec+'+++test_expect_success'running "git rebase -i --exec git show HEAD"''+gitrebase-i--exec"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase --exec git show HEAD -i"''+gitreset--hardexecute&&+gitrebase--exec"git show HEAD"-iHEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase -ix git show HEAD"''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several <CMD>''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD; pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several instances of --exec''+gitreset--hardexecute&&+gitrebase-i--exec"git show HEAD"--exec"pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2+exec_git_show_HEADexec_pwd" &&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,11d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with --autosquash''+gitreset--hardexecute&&+gitcheckout-bautosquash&&+echosecond>second.txt&&+gitaddsecond.txt&&+gitcommit-m"fixup! two_exec"&&+echobis>bis.txt&&+gitaddbis.txt&&+gitcommit-m"fixup! two_exec"&&+(+gitcheckout-bautosquash_actual&&+gitrebase-i--exec"git show HEAD"--autosquashHEAD~4>actual+)&&+gitcheckoutautosquash&&+(+gitcheckout-bautosquash_expected&&+FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~4>expected+)&&+sed'1,13d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase --exec without -i shows error message''+gitreset--hardexecute&&+test_must_failgitrebase--exec"git show HEAD"HEAD~22>actual&&+echo"--exec option must be used with --interactive option\n">expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -i --exec without <CMD> shows error message and usage''+gitreset--hardexecute&&+test_must_failgitrebase-i--exec2>actual&&+sed'1d'actual>tmp&&+mvtmpactual&&+test_must_failgitrebase-h>expected&&+test_cmpexpectedactual&&+gitcheckoutmaster+'+ test_done
From: Junio C Hamano <hidden> Date: 2016-06-15 22:54:00
Lucien Kong [off-list ref] writes:
The part of --onto in the documentation is changed to be consistent
with the other options. The exec line, when using the option --autosquash,
is now only added after the squash/fixup series.
Thanks.
Inserting "exec" before each "pick" and then adjusting the result
(i.e. removing the very first one and adding one at the end) is a
clever idea. I wonder if that can be done without temporary variable
whose value can grow to be a large string, though.
Queued, but I've tweaked the log message a bit before queuing.
From: Zbigniew Jędrzejewski-Szmek <hidden> Date: 2016-06-15 22:54:00
On 06/06/2012 12:34 PM, Lucien Kong wrote:
quoted hunk
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable. It is also compatible with the option --autosquash. At
this point, you can't use --exec without the interactive mode (-i).
Tests about this new command are also added in
t3404-rebase-interactive.sh.
Signed-off-by: Lucien Kong <redacted>
Signed-off-by: Valentin Duperray <redacted>
Signed-off-by: Franck Jonas <redacted>
Signed-off-by: Thomas Nguy <redacted>
Signed-off-by: Huynh Khoi Nguyen Nguyen <redacted>
Signed-off-by: Matthieu Moy <redacted>
---
The part of --onto in the documentation is changed to be consistent
with the other options. The exec line, when using the option --autosquash,
is now only added after the squash/fixup series.
Documentation/git-rebase.txt | 54 +++++++++++++++--
git-rebase--interactive.sh | 19 ++++++
git-rebase.sh | 20 ++++++-
t/t3404-rebase-interactive.sh | 124 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 207 insertions(+), 10 deletions(-)
@@ -210,11 +210,29 @@ rebase.autosquash:: OPTIONS --------<newbase>::- Starting point at which to create the new commits. If the- --onto option is not specified, the starting point is- <upstream>. May be any valid commit, and not just an- existing branch name.+-x <cmd>::+--exec <cmd>::+ Automatically add "exec" followed by <cmd> between each commit+ applications. Using this option along with --autosquash adds+ the exec line after the squash/fixeup series only. <cmd>+ stands for shell commands. The --exec option has to be+ specified. (see INTERACTIVE MODE below)
Hi,
this still doesn't seem right:
- "exec" is added *after* other lines, not *between*
- --exec is not mandatory
Maybe something along these lines:
-x <cmd>::
--exec <cmd>::
Append "exec <cmd>" after each commit application line. <cmd> will
be interpreted as one or more shell commands.
+
If --autosquash is used, the "exec" lines will not be appended for
the intermediate commits, and will only appear at the end of each
squash/fixup series.
++
+This has to be used along with the `--interactive` option explicitly.
This sentence is very unclear. (E.g. is 'this'?)
+You may execute several commands between each commit applications.
+For this, you can use one instance of exec:
+ git rebase -i --exec "cmd1; cmd2; ...".
+You can also insert several instances of exec, if you wish to
+only have one command per line for example:
+ git rebase -i --exec "cmd1" --exec "cmd2" ...
s/per line for example/per line. For example/ ?
+
+--onto <newbase>::
+ With this option, git rebase takes all commits from <branch>,
+ that are not in <upstream>, and transplant them on top of
+ <newbase>. <newbase> is the starting point at which to create
+ the new commits. If the --onto option is not specified, the
+ starting point is <upstream>. May be any valid commit, and
+ not just an existing branch name.
Shouldn't this chunk be a separate patch?
s/transplant/transplants/
--
Zbyszek
From: Johannes Sixt <hidden> Date: 2016-06-15 22:54:00
Am 06.06.2012 12:34, schrieb Lucien Kong:
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable.
While I won't be a heavy user of this feature, I think it has some merit
as a porcelain feature, particularly because it is rather cumbersome to
achieve the same effect as in the given example without plumbing commands.
+-x <cmd>::
+--exec <cmd>::
...
++
+This has to be used along with the `--interactive` option explicitly.
...
+
+If the option '-i' is missing, The command will return a message
+error. If there is no <cmd> specified behind --exec, the command will
+return a message error and the usage page of 'git rebase'.
The important part (that -x needs -i) of this paragraph are already
spelled out above, and the exact error behavior does not need a
description in the manual. Drop this paragraph.
BTW, I don't think it is a good idea to dump the usage if -x was used
without -i.
+# Add commands after a pick or after a squash/fixup serie
+# in the todo list.
+add_exec_commands () {
+ OIFS=$IFS
+ IFS=$LF
+ for i in $cmd
+ do
+ tmp=$(sed "/^pick .*/i\
+ exec $i" "$1")
Does this white-space before 'exec' not end up in the todo list?
I think it is wise to use introduce sed expressions by using -e. This
applies to all 'sed' invocations that this patch introduces (also in the
test-suite).
+ echo "$tmp" >"$1"
Some 'echo' implementations expand escape sequences in the supplied
texts. To avoid it (this is user-supplied text!), do this:
printf "%s\n" "$tmp" >"$1"
The quoting here is *very* odd. The outer dquotes do extend their effect
into the replacement word after the :+ operator. I am surprised that so
many shells grok it. ash does not, by the way. Also, you don't need the
space anymore. Therefore:
cmd="${cmd:+$cmd$LF}$2"
+ shift
+ ;;
+test_expect_success 'running "git rebase -i --exec git show HEAD"' '
+ git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
+ (
+ FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
+ export FAKE_LINES &&
+ git rebase -i HEAD~2 >expected
+ ) &&
+ sed '1,9d' expected >expect &&
Here and everywhere else: Single quotes do not nest :-) use dquotes (and
-e).
+ mv expect expected &&
Why not
( ... git rebase ... >expect ) &&
sed -e ... expect >expected &&
without the mv?
You could even line up the commands in a pipeline, but since the first
one contains a git command, it is better not to do that because breakage
of the git command would not be detected if it is not the last command
in the pipeline.
+test_expect_success 'rebase --exec without -i shows error message' '
+ git reset --hard execute &&
+ test_must_fail git rebase --exec "git show HEAD" HEAD~2 2>actual &&
+ echo "--exec option must be used with --interactive option\n" >expected &&
+ test_cmp expected actual
Sooner or later this text will be translated. Therefore:
test_i18ncmp ...
-- Hannes
From: Lucien Kong <hidden> Date: 2016-06-15 22:54:01
The description of the option "--onto" is changed to be consistent
with the format of the other options.
Signed-off-by: Lucien Kong <redacted>
Signed-off-by: Valentin Duperray <redacted>
Signed-off-by: Franck Jonas <redacted>
Signed-off-by: Thomas Nguy <redacted>
Signed-off-by: Huynh Khoi Nguyen Nguyen <redacted>
Signed-off-by: Matthieu Moy <redacted>
---
Documentation/git-rebase.txt | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
@@ -210,11 +210,13 @@ rebase.autosquash:: OPTIONS --------<newbase>::- Starting point at which to create the new commits. If the- --onto option is not specified, the starting point is- <upstream>. May be any valid commit, and not just an- existing branch name.+--onto <newbase>::+ With this option, git rebase takes all commits from <branch>,+ that are not in <upstream>, and transplants them on top of+ <newbase>. <newbase is the starting point at which to create+ the new commits. If the --onto option is not specified, the+ starting point is <upstream>. May be any valid commit, and+ not just an existing branch name. + As a special case, you may use "A\...B" as a shortcut for the merge base of A and B if there is exactly one merge base. You can
From: Lucien Kong <hidden> Date: 2016-06-15 22:54:01
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable. It is also compatible with the option --autosquash. At
this point, you can't use --exec without the interactive mode (-i).
Tests about this new command are also added in
t3404-rebase-interactive.sh.
Signed-off-by: Lucien Kong <redacted>
Signed-off-by: Valentin Duperray <redacted>
Signed-off-by: Franck Jonas <redacted>
Signed-off-by: Thomas Nguy <redacted>
Signed-off-by: Huynh Khoi Nguyen Nguyen <redacted>
Signed-off-by: Matthieu Moy <redacted>
---
Should now work on MacOS.
Documentation/git-rebase.txt | 43 ++++++++++++++-
git-rebase--interactive.sh | 18 ++++++
git-rebase.sh | 20 ++++++-
t/t3404-rebase-interactive.sh | 118 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 194 insertions(+), 5 deletions(-)
@@ -210,6 +210,27 @@ rebase.autosquash:: OPTIONS -------+-x <cmd>::+--exec <cmd>::+ Append "exec <cmd>" after each commit application line. <cmd>+ will be interpreted as one or more shell commands (see+ INTERACTIVE MODE below).+++This option has to be used along with the `--interactive` option+explicitly. You may execute several commands between each commit+applications. For this, you can use one instance of exec:+++ git rebase -i --exec "cmd1; cmd2; ...".+++You can also insert several instances of exec, if you wish to only+have one command per line. For example:+++ git rebase -i --exec "cmd1" --exec "cmd2" ...+++If --autosquash is used, the "exec" lines will not be appended for the+intermediate commits, and will only appear at the end of each+squash/fixup series.+ --onto <newbase>:: With this option, git rebase takes all commits from <branch>, that are not in <upstream>, and transplants them on top of
@@ -523,6 +544,24 @@ in `$SHELL`, or the default shell if `$SHELL` is not set), so you can use shell features (like "cd", ">", ";" ...). The command is run from the root of the working tree.+----------------------------------+$ git rebase -i --exec "make test"+----------------------------------++This command lets you check that intermediate commits are compilable.+The todo list becomes like that:++--------------------+pick 5928aea one+exec make test+pick 04d0fda two+exec make test+pick ba46169 three+exec make test+pick f4593f9 four+exec make test+--------------------+ SPLITTING COMMITS -----------------
@@ -684,6 +684,22 @@ rearrange_squash () {rm-f"$1.sq""$1.rearranged"}+# Add commands after a pick or after a squash/fixup serie+# in the todo list.+add_exec_commands(){+OIFS=$IFS+IFS=$LF+foriin$cmd+do+sed-e"/^pick .*/i\\+exec$i" "$1" >"$1.exec"+sed-e'1d'"$1.exec">"$1"+printf"%s\n""exec $i">>"$1"+done+IFS=$OIFS+rm-f"$1.exec"+}+case"$action"incontinue)# do we have anything to commit?
@@ -857,6 +873,8 @@ fitest-s"$todo"||echonoop>>"$todo"test-n"$autosquash"&&rearrange_squash"$todo"+test-n"$cmd"&&add_exec_commands"$todo"+ cat>>"$todo"<<EOF# Rebase $shortrevisions onto $shortonto
@@ -43,6 +44,7 @@ s,strategy=! use the given merge strategy no-ff!cherry-pickallcommits,evenifunchanged m,merge!usemergingstrategiestorebase i,interactive!lettheusereditthelistofcommitstorebase+x,exec=!addexeclinesaftereachcommitoftheeditablelist k,keep-emptypreserveemptycommitsduringrebase f,force-rebase!forcerebaseevenifbranchisuptodate X,strategy-option=!passtheargumentthroughtothemergestrategy
@@ -76,6 +78,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". Tocheckouttheoriginalbranchandstoprebasingrun\"gitrebase--abort\"."unsetonto+cmd=strategy=strategy_opts=do_merge=
@@ -304,6 +312,12 @@ dodonetest$#-gt2&&usage+iftest-n"$cmd"&&+test"$interactive_rebase"!=explicit+then+die"--exec option must be used with --interactive option\n"+fi+iftest-n"$action"thentest-z"$in_progress"&&die"No rebase in progress?"
@@ -755,4 +755,122 @@ test_expect_success 'rebase-i history with funny messages' 'test_cmpexpectactual'++test_expect_success'prepare for rebase -i --exec''+gitcheckoutmaster&&+gitcheckout-bexecute&&+test_commitone_execmain.txtone_exec&&+test_committwo_execmain.txttwo_exec&&+test_committhree_execmain.txtthree_exec+'+++test_expect_success'running "git rebase -i --exec git show HEAD"''+gitrebase-i--exec"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase --exec git show HEAD -i"''+gitreset--hardexecute&&+gitrebase--exec"git show HEAD"-iHEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed'1,9d'expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase -ix git show HEAD"''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed'1,9d'expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several <CMD>''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD; pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed'1,9d'expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several instances of --exec''+gitreset--hardexecute&&+gitrebase-i--exec"git show HEAD"--exec"pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2+exec_git_show_HEADexec_pwd" &&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed'1,11d'expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with --autosquash''+gitreset--hardexecute&&+gitcheckout-bautosquash&&+echosecond>second.txt&&+gitaddsecond.txt&&+gitcommit-m"fixup! two_exec"&&+echobis>bis.txt&&+gitaddbis.txt&&+gitcommit-m"fixup! two_exec"&&+(+gitcheckout-bautosquash_actual&&+gitrebase-i--exec"git show HEAD"--autosquashHEAD~4>actual+)&&+gitcheckoutautosquash&&+(+gitcheckout-bautosquash_expected&&+FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~4>expect+)&&+sed'1,13d'expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase --exec without -i shows error message''+gitreset--hardexecute&&+test_must_failgitrebase--exec"git show HEAD"HEAD~22>actual&&+echo"--exec option must be used with --interactive option\n">expected&&+test_i18ncmpexpectedactual+'+++test_expect_success'rebase -i --exec without <CMD> shows error message and usage''+gitreset--hardexecute&&+test_must_failgitrebase-i--exec2>actual&&+sed'1d'actual>tmp&&+mvtmpactual&&+test_must_failgitrebase-h>expected&&+test_cmpexpectedactual&&+gitcheckoutmaster+'+ test_done
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable. It is also compatible with the option --autosquash. At
this point, you can't use --exec without the interactive mode (-i).
Tests about this new command are also added in
t3404-rebase-interactive.sh.
Should now work on MacOS.
Hej,
I'm not sure on which commit to apply the patch.
(may be we shoud improve git format-patch to tell us the original commit ID),
but if I remove the non applying part, it looks like this:
=================
ok 54 - rebase-i history with funny messages
expecting success:
git checkout master &&
git checkout -b execute &&
test_commit one_exec main.txt one_exec &&
test_commit two_exec main.txt two_exec &&
test_commit three_exec main.txt three_exec
Switched to branch 'master'
Switched to a new branch 'execute'
[execute 925b01e] one_exec
Author: A U Thor [off-list ref]
1 file changed, 1 insertion(+)
create mode 100644 main.txt
[execute 7f87cbe] two_exec
Author: A U Thor [off-list ref]
1 file changed, 1 insertion(+), 1 deletion(-)
[execute f0f177e] three_exec
Author: A U Thor [off-list ref]
1 file changed, 1 insertion(+), 1 deletion(-)
ok 55 - prepare for rebase -i --exec
expecting success:
git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
(
FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
export FAKE_LINES &&
git rebase -i HEAD~2 >expected
) &&
sed 1,9d expected >expect &&
mv expect expected &&
test_cmp expected actual
error: unknown option `exec'
usage: git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]
or: git rebase [-i] [options] --onto <newbase> --root [<branch>]
or: git-rebase [-i] --continue | --abort | --skip
Available options are
-v, --verbose display a diffstat of what changed upstream
-q, --quiet be quiet. implies --no-stat
--onto ... rebase onto given branch instead of upstream
-p, --preserve-merges
try to recreate merges instead of ignoring them
-s, --strategy ... use the given merge strategy
--no-ff cherry-pick all commits, even if unchanged
-m, --merge use merging strategies to rebase
-i, --interactive let the user edit the list of commits to rebase
-k, --keep-empty preserve empty commits during rebase
-f, --force-rebase force rebase even if branch is up to date
-X, --strategy-option ...
pass the argument through to the merge strategy
--stat display a diffstat of what changed upstream
-n, --no-stat do not show diffstat of what changed upstream
--verify allow pre-rebase hook to run
--rerere-autoupdate allow rerere to update index with resolved conflicts
--root rebase all reachable commits up to the root(s)
--autosquash move commits that begin with squash!/fixup! under -i
--committer-date-is-author-date
passed to 'git am'
--ignore-date passed to 'git am'
--whitespace ... passed to 'git apply'
--ignore-whitespace passed to 'git apply'
-C ... passed to 'git apply'
Actions:
--continue continue
--abort abort and check out the original branch
--skip skip current patch and continue
not ok - 56 running "git rebase -i --exec git show HEAD"
#
# git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
# (
# FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
# export FAKE_LINES &&
# git rebase -i HEAD~2 >expected
# ) &&
# sed 1,9d expected >expect &&
# mv expect expected &&
# test_cmp expected actual
#
expecting success:
git reset --hard execute &&
git rebase --exec "git show HEAD" -i HEAD~2 >actual &&
(
FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
export FAKE_LINES &&
git rebase -i HEAD~2 >expected
) &&
sed 1,9d expected >expect &&
mv expect expected &&
test_cmp expected actual
HEAD is now at f0f177e three_exec
error: unknown option `exec'
usage: git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]
or: git rebase [-i] [options] --onto <newbase> --root [<branch>]
or: git-rebase [-i] --continue | --abort | --skip
Available options are
-v, --verbose display a diffstat of what changed upstream
-q, --quiet be quiet. implies --no-stat
--onto ... rebase onto given branch instead of upstream
-p, --preserve-merges
try to recreate merges instead of ignoring them
-s, --strategy ... use the given merge strategy
--no-ff cherry-pick all commits, even if unchanged
-m, --merge use merging strategies to rebase
-i, --interactive let the user edit the list of commits to rebase
-k, --keep-empty preserve empty commits during rebase
-f, --force-rebase force rebase even if branch is up to date
-X, --strategy-option ...
pass the argument through to the merge strategy
--stat display a diffstat of what changed upstream
-n, --no-stat do not show diffstat of what changed upstream
--verify allow pre-rebase hook to run
--rerere-autoupdate allow rerere to update index with resolved conflicts
--root rebase all reachable commits up to the root(s)
--autosquash move commits that begin with squash!/fixup! under -i
--committer-date-is-author-date
passed to 'git am'
--ignore-date passed to 'git am'
--whitespace ... passed to 'git apply'
--ignore-whitespace passed to 'git apply'
-C ... passed to 'git apply'
Actions:
--continue continue
--abort abort and check out the original branch
--skip skip current patch and continue
not ok - 57 running "git rebase --exec git show HEAD -i"
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable. It is also compatible with the option --autosquash. At
this point, you can't use --exec without the interactive mode (-i).
Tests about this new command are also added in
t3404-rebase-interactive.sh.
quoted
Should now work on MacOS.
Hej,
I'm not sure on which commit to apply the patch.
(may be we shoud improve git format-patch to tell us the original commit ID),
but if I remove the non applying part, it looks like this:
Which part does not apply ? If you skip the part that's implementing the
exec option, of course Git will not recognize it.
Which part does not apply ? If you skip the part that's implementing the
exec option, of course Git will not recognize it.
Hej,
2 questions:
a) Where should it apply ?
I tried to apply it on commit f623ca1cae600e97cb0b38131fdd33e4fb669cf8
b) Does the line from my log
"error: unknown option `exec'"
tell us anything?
/Torsten
Which part does not apply ? If you skip the part that's implementing the
exec option, of course Git will not recognize it.
Hej,
2 questions:
a) Where should it apply ?
I tried to apply it on commit f623ca1cae600e97cb0b38131fdd33e4fb669cf8
I just tried to apply it on that commit and it works for me. What's the
error message ?
quoted
b) Does the line from my log
"error: unknown option `exec'"
tell us anything?
Yes, that the patch was not applied ^^'.
------------------------------------------------
That's the outcome, if I try to re-apply it:
Applying: Fwd: [PATCHv3 2/2] rebase [-i --exec | -ix] <CMD>...
error: patch failed: Documentation/git-rebase.txt:210
error: Documentation/git-rebase.txt: patch does not apply
Patch failed at 0001 Fwd: [PATCHv3 2/2] rebase [-i --exec | -ix] <CMD>...
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
=====================
And after my fumbling, the diff looks like this (see below).
It seems that something changed, because the error line is different-
Sorry if I messed something up here, it looks as if the functionality implementing
the "exec" is missing in my code base.
For me it looks as if I only picked up the test cases, and I'm missing something.
In this case it would be helpful if you just re-send the patch to my email,
and I can try to re-do the patch based on f623ca1cae600e97cb0b38,
or whatever you specify.
Does that makes sense?
/Torsten
------------------------
git diff f623ca1cae600e97cb0b38..63884a991c9d8
=================================================
@@ -210,11 +210,29 @@ rebase.autosquash:: OPTIONS --------<newbase>::- Starting point at which to create the new commits. If the- --onto option is not specified, the starting point is- <upstream>. May be any valid commit, and not just an- existing branch name.+-x <cmd>::+--exec <cmd>::+ Automatically add "exec" followed by <cmd> between each commit+ applications. Using this option along with --autosquash adds+ the exec line after the squash/fixeup series only. <cmd>+ stands for shell commands. The --exec option has to be+ specified. (see INTERACTIVE MODE below)+++This has to be used along with the `--interactive` option explicitly.+You may execute several commands between each commit applications.+For this, you can use one instance of exec:+ git rebase -i --exec "cmd1; cmd2; ...".+You can also insert several instances of exec, if you wish to+only have one command per line for example:+ git rebase -i --exec "cmd1" --exec "cmd2" ...++--onto <newbase>::+ With this option, git rebase takes all commits from <branch>,+ that are not in <upstream>, and transplant them on top of+ <newbase>. <newbase> is the starting point at which to create+ the new commits. If the --onto option is not specified, the+ starting point is <upstream>. May be any valid commit, and+ not just an existing branch name. + As a special case, you may use "A\...B" as a shortcut for the merge base of A and B if there is exactly one merge base. You can
@@ -521,6 +539,28 @@ in `$SHELL`, or the default shell if `$SHELL` is not set), so you can use shell features (like "cd", ">", ";" ...). The command is run from the root of the working tree.+----------------------------------+$ git rebase -i --exec "make test"+----------------------------------++This command lets you check that intermediate commits are compilable.+The todo list becomes like that:++--------------------+pick 5928aea one+exec make test+pick 04d0fda two+exec make test+pick ba46169 three+exec make test+pick f4593f9 four+exec make test+--------------------++If the option '-i' is missing, The command will return a message+error. If there is no <cmd> specified behind --exec, the command will+return a message error and the usage page of 'git rebase'.+ SPLITTING COMMITS -----------------
@@ -684,6 +684,22 @@ rearrange_squash () {rm-f"$1.sq""$1.rearranged"}+# Add commands after a pick or after a squash/fixup serie+# in the todo list.+add_exec_commands(){+OIFS=$IFS+IFS=$LF+foriin$cmd+do+tmp=$(sed"/^pick .*/i\exec $i""$1")+echo"$tmp">"$1"+tmp=$(sed'1d'"$1")+echo"$tmp">"$1"+echo"exec $i">>"$1"+done+IFS=$OIFS+}+case"$action"incontinue)# do we have anything to commit?
@@ -857,6 +873,8 @@ fitest-s"$todo"||echonoop>>"$todo"test-n"$autosquash"&&rearrange_squash"$todo"+test-n"$cmd"&&add_exec_commands"$todo"+ cat>>"$todo"<<EOF# Rebase $shortrevisions onto $shortonto
@@ -43,6 +44,7 @@ s,strategy=! use the given merge strategy no-ff!cherry-pickallcommits,evenifunchanged m,merge!usemergingstrategiestorebase i,interactive!lettheusereditthelistofcommitstorebase+x,exec=!addexeclinesaftereachcommitoftheeditablelist k,keep-emptypreserveemptycommitsduringrebase f,force-rebase!forcerebaseevenifbranchisuptodate X,strategy-option=!passtheargumentthroughtothemergestrategy
@@ -76,6 +78,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". Tocheckouttheoriginalbranchandstoprebasingrun\"gitrebase--abort\"."unsetonto+cmd=strategy=strategy_opts=do_merge=
@@ -305,6 +313,12 @@ dodonetest$#-gt2&&usage+iftest-n"$cmd"&&+test"$interactive_rebase"!=explicit+then+die"--exec option must be used with --interactive option\n"+fi+iftest-n"$action"thentest-z"$in_progress"&&die"No rebase in progress?"
@@ -755,4 +755,128 @@ test_expect_success 'rebase-i history with funny messages' 'test_cmpexpectactual'++test_expect_success'prepare for rebase -i --exec''+gitcheckoutmaster&&+gitcheckout-bexecute&&+test_commitone_execmain.txtone_exec&&+test_committwo_execmain.txttwo_exec&&+test_committhree_execmain.txtthree_exec+'+++test_expect_success'running "git rebase -i --exec git show HEAD"''+gitrebase-i--exec"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase --exec git show HEAD -i"''+gitreset--hardexecute&&+gitrebase--exec"git show HEAD"-iHEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase -ix git show HEAD"''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several <CMD>''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD; pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,9d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several instances of --exec''+gitreset--hardexecute&&+gitrebase-i--exec"git show HEAD"--exec"pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2+exec_git_show_HEADexec_pwd" &&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expected+)&&+sed'1,11d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with --autosquash''+gitreset--hardexecute&&+gitcheckout-bautosquash&&+echosecond>second.txt&&+gitaddsecond.txt&&+gitcommit-m"fixup! two_exec"&&+echobis>bis.txt&&+gitaddbis.txt&&+gitcommit-m"fixup! two_exec"&&+(+gitcheckout-bautosquash_actual&&+gitrebase-i--exec"git show HEAD"--autosquashHEAD~4>actual+)&&+gitcheckoutautosquash&&+(+gitcheckout-bautosquash_expected&&+FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~4>expected+)&&+sed'1,13d'expected>expect&&+mvexpectexpected&&+test_cmpexpectedactual+'+++test_expect_success'rebase --exec without -i shows error message''+gitreset--hardexecute&&+test_must_failgitrebase--exec"git show HEAD"HEAD~22>actual&&+echo"--exec option must be used with --interactive option\n">expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -i --exec without <CMD> shows error message and usage''+gitreset--hardexecute&&+test_must_failgitrebase-i--exec2>actual&&+sed'1d'actual>tmp&&+mvtmpactual&&+test_must_failgitrebase-h>expected&&+test_cmpexpectedactual&&+gitcheckoutmaster+'+ test_done
Which part does not apply ? If you skip the part that's implementing the
exec option, of course Git will not recognize it.
Hej,
2 questions:
a) Where should it apply ?
I tried to apply it on commit f623ca1cae600e97cb0b38131fdd33e4fb669cf8
I just tried to apply it on that commit and it works for me. What's the
error message ?
quoted
b) Does the line from my log
"error: unknown option `exec'"
tell us anything?
Yes, that the patch was not applied ^^'.
------------------------------------------------
That's the outcome, if I try to re-apply it:
Applying: Fwd: [PATCHv3 2/2] rebase [-i --exec | -ix] <CMD>...
error: patch failed: Documentation/git-rebase.txt:210
error: Documentation/git-rebase.txt: patch does not apply
Patch failed at 0001 Fwd: [PATCHv3 2/2] rebase [-i --exec | -ix] <CMD>...
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
Did you first apply the first part [PATCHv3 1/2] of the patch ?
Lucien Kong.
Which part does not apply ? If you skip the part that's implementing the
exec option, of course Git will not recognize it.
Hej,
2 questions:
a) Where should it apply ?
I tried to apply it on commit f623ca1cae600e97cb0b38131fdd33e4fb669cf8
I just tried to apply it on that commit and it works for me. What's the
error message ?
quoted
b) Does the line from my log
"error: unknown option `exec'"
tell us anything?
Yes, that the patch was not applied ^^'.
------------------------------------------------
That's the outcome, if I try to re-apply it:
Applying: Fwd: [PATCHv3 2/2] rebase [-i --exec | -ix] <CMD>...
error: patch failed: Documentation/git-rebase.txt:210
error: Documentation/git-rebase.txt: patch does not apply
Patch failed at 0001 Fwd: [PATCHv3 2/2] rebase [-i --exec | -ix] <CMD>...
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
Did you first apply the first part [PATCHv3 1/2] of the patch ?
Lucien Kong.
Hej,
I have 2 patches with the headline "[PATCHv3 1/2" in my in box.
None of them is dealing in any kind with upgrading a command to understand "exec".
To be able to test under Mac OS it could be helpful if you just re-send
one patch to my email.
Then I can try to re-do the patch based on f623ca1cae600e97cb0b38 and
test it under Mac OS.
Does that makes sense?
/Torsten
Hej,
I have 2 patches with the headline "[PATCHv3 1/2" in my in box.
None of them is dealing in any kind with upgrading a command to
understand "exec".
To be able to test under Mac OS it could be helpful if you just re-send
one patch to my email.
Then I can try to re-do the patch based on f623ca1cae600e97cb0b38 and
test it under Mac OS.
Alright, gonna send you the patch in one part so that it can be applied
alone :).
Lucien Kong
From: Lucien Kong <hidden> Date: 2016-06-15 22:54:01
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable. It is also compatible with the option --autosquash. At
this point, you can't use --exec without the interactive mode (-i).
Tests about this new command are also added in
t3404-rebase-interactive.sh.
Helped-by: Johannes Sixt [off-list ref]
Signed-off-by: Lucien Kong <redacted>
Signed-off-by: Valentin Duperray <redacted>
Signed-off-by: Franck Jonas <redacted>
Signed-off-by: Thomas Nguy <redacted>
Signed-off-by: Huynh Khoi Nguyen Nguyen <redacted>
Signed-off-by: Matthieu Moy <redacted>
---
The change in git-rebase.txt about the option --onto
was done in another patch. This patch can be applied
independently.
Documentation/git-rebase.txt | 43 ++++++++++++++-
git-rebase--interactive.sh | 23 ++++++++
git-rebase.sh | 20 ++++++-
t/t3404-rebase-interactive.sh | 118 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 199 insertions(+), 5 deletions(-)
@@ -210,6 +210,27 @@ rebase.autosquash:: OPTIONS -------+-x <cmd>::+--exec <cmd>::+ Append "exec <cmd>" after each commit application line. <cmd>+ will be interpreted as one or more shell commands (see+ INTERACTIVE MODE below).+++This option has to be used along with the `--interactive` option+explicitly. You may execute several commands between each commit+applications. For this, you can use one instance of exec:+++ git rebase -i --exec "cmd1; cmd2; ...".+++You can also insert several instances of exec, if you wish to only+have one command per line. For example:+++ git rebase -i --exec "cmd1" --exec "cmd2" ...+++If --autosquash is used, the "exec" lines will not be appended for the+intermediate commits, and will only appear at the end of each+squash/fixup series.+ <newbase>:: Starting point at which to create the new commits. If the --onto option is not specified, the starting point is
@@ -521,6 +542,24 @@ in `$SHELL`, or the default shell if `$SHELL` is not set), so you can use shell features (like "cd", ">", ";" ...). The command is run from the root of the working tree.+----------------------------------+$ git rebase -i --exec "make test"+----------------------------------++This command lets you check that intermediate commits are compilable.+The todo list becomes like that:++--------------------+pick 5928aea one+exec make test+pick 04d0fda two+exec make test+pick ba46169 three+exec make test+pick f4593f9 four+exec make test+--------------------+ SPLITTING COMMITS -----------------
@@ -684,6 +684,27 @@ rearrange_squash () {rm-f"$1.sq""$1.rearranged"}+# Add commands after a pick or after a squash/fixup serie+# in the todo list.+add_exec_commands(){+{+first=t+whileread-rinsnrest+do+case$insnin+pick)+test-n"$first"||+printf"%s""$cmd"+;;+esac+printf"%s %s\n""$insn""$rest"+first=+done+printf"%s""$cmd"+}<"$1">"$1.new"&&+mv"$1.new""$1"+}+case"$action"incontinue)# do we have anything to commit?
@@ -857,6 +878,8 @@ fitest-s"$todo"||echonoop>>"$todo"test-n"$autosquash"&&rearrange_squash"$todo"+test-n"$cmd"&&add_exec_commands"$todo"+ cat>>"$todo"<<EOF# Rebase $shortrevisions onto $shortonto
@@ -43,6 +44,7 @@ s,strategy=! use the given merge strategy no-ff!cherry-pickallcommits,evenifunchanged m,merge!usemergingstrategiestorebase i,interactive!lettheusereditthelistofcommitstorebase+x,exec=!addexeclinesaftereachcommitoftheeditablelist k,keep-emptypreserveemptycommitsduringrebase f,force-rebase!forcerebaseevenifbranchisuptodate X,strategy-option=!passtheargumentthroughtothemergestrategy
@@ -76,6 +78,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". Tocheckouttheoriginalbranchandstoprebasingrun\"gitrebase--abort\"."unsetonto+cmd=strategy=strategy_opts=do_merge=
@@ -304,6 +312,12 @@ dodonetest$#-gt2&&usage+iftest-n"$cmd"&&+test"$interactive_rebase"!=explicit+then+die"--exec option must be used with --interactive option"+fi+iftest-n"$action"thentest-z"$in_progress"&&die"No rebase in progress?"
@@ -755,4 +755,122 @@ test_expect_success 'rebase-i history with funny messages' 'test_cmpexpectactual'++test_expect_success'prepare for rebase -i --exec''+gitcheckoutmaster&&+gitcheckout-bexecute&&+test_commitone_execmain.txtone_exec&&+test_committwo_execmain.txttwo_exec&&+test_committhree_execmain.txtthree_exec+'+++test_expect_success'running "git rebase -i --exec git show HEAD"''+gitrebase-i--exec"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase --exec git show HEAD -i"''+gitreset--hardexecute&&+gitrebase--exec"git show HEAD"-iHEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase -ix git show HEAD"''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several <CMD>''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD; pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several instances of --exec''+gitreset--hardexecute&&+gitrebase-i--exec"git show HEAD"--exec"pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2+exec_git_show_HEADexec_pwd" &&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,11d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with --autosquash''+gitreset--hardexecute&&+gitcheckout-bautosquash&&+echosecond>second.txt&&+gitaddsecond.txt&&+gitcommit-m"fixup! two_exec"&&+echobis>bis.txt&&+gitaddbis.txt&&+gitcommit-m"fixup! two_exec"&&+(+gitcheckout-bautosquash_actual&&+gitrebase-i--exec"git show HEAD"--autosquashHEAD~4>actual+)&&+gitcheckoutautosquash&&+(+gitcheckout-bautosquash_expected&&+FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~4>expect+)&&+sed-e"1,13d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase --exec without -i shows error message''+gitreset--hardexecute&&+test_must_failgitrebase--exec"git show HEAD"HEAD~22>actual&&+echo"--exec option must be used with --interactive option">expected&&+test_i18ncmpexpectedactual+'+++test_expect_success'rebase -i --exec without <CMD> shows error message and usage''+gitreset--hardexecute&&+test_must_failgitrebase-i--exec2>actual&&+sed'1d'actual>tmp&&+mvtmpactual&&+test_must_failgitrebase-h>expected&&+test_cmpexpectedactual&&+gitcheckoutmaster+'+ test_done
From: Johannes Sixt <hidden> Date: 2016-06-15 22:54:01
Am 10.06.2012 12:44, schrieb Lucien Kong:
+test_expect_success 'rebase -i --exec without <CMD> shows error message and usage' '
+ git reset --hard execute &&
+ test_must_fail git rebase -i --exec 2>actual &&
+ sed '1d' actual >tmp &&
+ mv tmp actual &&
+ test_must_fail git rebase -h >expected &&
+ test_cmp expected actual &&
+ git checkout master
+'
IMO, it is more important to check that the error message is present
rather than whether the usage blurb is correct. But since the error is
generated by the option parsing machinery, it is probably sufficient to
check *only* for failure, and don't verify the output at all.
Then change the headline of the text to the neutral
test_expect_success 'rebase -i --exec without <CMD>' '
And, BTW, next time I point out that sed 'xy'... should be changed to
sed -e "xy"... you review *ALL* sed commands you introduce, not just
those that I point out, OK?
And, BTW, when I point out that ...>expected && sed <expected >expect &&
mv expect expected should be ...>expect && sed <expect >expected, you
extrapolate *yourself* that the same pattern applies even if the files
are named "tmp" and "actual", OK?
That's expected from thoughtful contributors.
-- Hannes
From: Lucien Kong <hidden> Date: 2016-06-15 22:54:03
This patch provides a way to automatically add these "exec" lines
between each commit applications. For instance, running 'git rebase -i
--exec "make test"' lets you check that intermediate commits are
compilable. It is also compatible with the option --autosquash. At
this point, you can't use --exec without the interactive mode (-i).
Tests about this new command are also added in
t3404-rebase-interactive.sh.
Helped-by: Johannes Sixt [off-list ref]
Signed-off-by: Lucien Kong <redacted>
Signed-off-by: Valentin Duperray <redacted>
Signed-off-by: Franck Jonas <redacted>
Signed-off-by: Thomas Nguy <redacted>
Signed-off-by: Huynh Khoi Nguyen Nguyen <redacted>
Signed-off-by: Matthieu Moy <redacted>
---
The last test is changed to be consistent with the other
(thanks Johannes for reviewing the code).
Documentation/git-rebase.txt | 43 ++++++++++++++-
git-rebase--interactive.sh | 23 ++++++++
git-rebase.sh | 20 ++++++-
t/t3404-rebase-interactive.sh | 117 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 198 insertions(+), 5 deletions(-)
@@ -210,6 +210,27 @@ rebase.autosquash:: OPTIONS -------+-x <cmd>::+--exec <cmd>::+ Append "exec <cmd>" after each commit application line. <cmd>+ will be interpreted as one or more shell commands (see+ INTERACTIVE MODE below).+++This option has to be used along with the `--interactive` option+explicitly. You may execute several commands between each commit+applications. For this, you can use one instance of exec:+++ git rebase -i --exec "cmd1; cmd2; ...".+++You can also insert several instances of exec, if you wish to only+have one command per line. For example:+++ git rebase -i --exec "cmd1" --exec "cmd2" ...+++If --autosquash is used, the "exec" lines will not be appended for the+intermediate commits, and will only appear at the end of each+squash/fixup series.+ <newbase>:: Starting point at which to create the new commits. If the --onto option is not specified, the starting point is
@@ -521,6 +542,24 @@ in `$SHELL`, or the default shell if `$SHELL` is not set), so you can use shell features (like "cd", ">", ";" ...). The command is run from the root of the working tree.+----------------------------------+$ git rebase -i --exec "make test"+----------------------------------++This command lets you check that intermediate commits are compilable.+The todo list becomes like that:++--------------------+pick 5928aea one+exec make test+pick 04d0fda two+exec make test+pick ba46169 three+exec make test+pick f4593f9 four+exec make test+--------------------+ SPLITTING COMMITS -----------------
@@ -684,6 +684,27 @@ rearrange_squash () {rm-f"$1.sq""$1.rearranged"}+# Add commands after a pick or after a squash/fixup serie+# in the todo list.+add_exec_commands(){+{+first=t+whileread-rinsnrest+do+case$insnin+pick)+test-n"$first"||+printf"%s""$cmd"+;;+esac+printf"%s %s\n""$insn""$rest"+first=+done+printf"%s""$cmd"+}<"$1">"$1.new"&&+mv"$1.new""$1"+}+case"$action"incontinue)# do we have anything to commit?
@@ -857,6 +878,8 @@ fitest-s"$todo"||echonoop>>"$todo"test-n"$autosquash"&&rearrange_squash"$todo"+test-n"$cmd"&&add_exec_commands"$todo"+ cat>>"$todo"<<EOF# Rebase $shortrevisions onto $shortonto
@@ -43,6 +44,7 @@ s,strategy=! use the given merge strategy no-ff!cherry-pickallcommits,evenifunchanged m,merge!usemergingstrategiestorebase i,interactive!lettheusereditthelistofcommitstorebase+x,exec=!addexeclinesaftereachcommitoftheeditablelist k,keep-emptypreserveemptycommitsduringrebase f,force-rebase!forcerebaseevenifbranchisuptodate X,strategy-option=!passtheargumentthroughtothemergestrategy
@@ -76,6 +78,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". Tocheckouttheoriginalbranchandstoprebasingrun\"gitrebase--abort\"."unsetonto+cmd=strategy=strategy_opts=do_merge=
@@ -304,6 +312,12 @@ dodonetest$#-gt2&&usage+iftest-n"$cmd"&&+test"$interactive_rebase"!=explicit+then+die"--exec option must be used with --interactive option"+fi+iftest-n"$action"thentest-z"$in_progress"&&die"No rebase in progress?"
@@ -755,4 +755,121 @@ test_expect_success 'rebase-i history with funny messages' 'test_cmpexpectactual'++test_expect_success'prepare for rebase -i --exec''+gitcheckoutmaster&&+gitcheckout-bexecute&&+test_commitone_execmain.txtone_exec&&+test_committwo_execmain.txttwo_exec&&+test_committhree_execmain.txtthree_exec+'+++test_expect_success'running "git rebase -i --exec git show HEAD"''+gitrebase-i--exec"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase --exec git show HEAD -i"''+gitreset--hardexecute&&+gitrebase--exec"git show HEAD"-iHEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'running "git rebase -ix git show HEAD"''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several <CMD>''+gitreset--hardexecute&&+gitrebase-ix"git show HEAD; pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd"&&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,9d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with several instances of --exec''+gitreset--hardexecute&&+gitrebase-i--exec"git show HEAD"--exec"pwd"HEAD~2>actual&&+(+FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2+exec_git_show_HEADexec_pwd" &&+exportFAKE_LINES&&+gitrebase-iHEAD~2>expect+)&&+sed-e"1,11d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase -ix with --autosquash''+gitreset--hardexecute&&+gitcheckout-bautosquash&&+echosecond>second.txt&&+gitaddsecond.txt&&+gitcommit-m"fixup! two_exec"&&+echobis>bis.txt&&+gitaddbis.txt&&+gitcommit-m"fixup! two_exec"&&+(+gitcheckout-bautosquash_actual&&+gitrebase-i--exec"git show HEAD"--autosquashHEAD~4>actual+)&&+gitcheckoutautosquash&&+(+gitcheckout-bautosquash_expected&&+FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD"&&+exportFAKE_LINES&&+gitrebase-iHEAD~4>expect+)&&+sed-e"1,13d"expect>expected&&+test_cmpexpectedactual+'+++test_expect_success'rebase --exec without -i shows error message''+gitreset--hardexecute&&+test_must_failgitrebase--exec"git show HEAD"HEAD~22>actual&&+echo"--exec option must be used with --interactive option">expected&&+test_i18ncmpexpectedactual+'+++test_expect_success'rebase -i --exec without <CMD>''+gitreset--hardexecute&&+test_must_failgitrebase-i--exec2>tmp&&+sed-e"1d"tmp>actual&&+test_must_failgitrebase-h>expected&&+test_cmpexpectedactual&&+gitcheckoutmaster+'+ test_done
From: Zbigniew Jędrzejewski-Szmek <hidden> Date: 2016-06-15 22:54:03
On 06/12/2012 10:05 AM, Lucien Kong wrote:
+-x <cmd>::
+--exec <cmd>::
+ Append "exec <cmd>" after each commit application line. <cmd>
+ will be interpreted as one or more shell commands (see
+ INTERACTIVE MODE below).
++
+This option has to be used along with the `--interactive` option
+explicitly. You may execute several commands between each commit
+applications. For this, you can use one instance of exec:
Hi,
this is still grammatically fishy, and has "between each commit
applications", which was corrected above, but not here.
+ git rebase -i --exec "cmd1; cmd2; ...".
++
+You can also insert several instances of exec, if you wish to only
+have one command per line. For example:
s/instances of exec/instances of --exec/
+ git rebase -i --exec "cmd1" --exec "cmd2" ...
++
+If --autosquash is used, the "exec" lines will not be appended for the
+intermediate commits, and will only appear at the end of each
+squash/fixup series.
+