{"thread":{"id":"30736","subject":"commit a63d7ed3017e312ddc752ac89a7d292a745d5f11 broken on MacOS","startedAt":"2012-06-07T11:53:50Z","lastAt":"2012-06-08T15:34:55Z","messageCount":15,"participants":["Torsten Bögershausen","konglu@minatec.inpg.fr","Lucien Kong","Andreas Schwab","Matthieu Moy","Johannes Sixt","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"193053","messageId":"4FD0964E.7040302@web.de","threadId":"30736","inReplyTo":null,"subject":"commit a63d7ed3017e312ddc752ac89a7d292a745d5f11 broken on MacOS","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2012-06-07T11:53:50Z","receivedAt":"2012-06-07T11:53:50Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"\ncommit a63d7ed3017e312ddc752ac89a7d292a745d5f11\nAuthor: Lucien Kong <Lucien.Kong@ensimag.imag.fr>\nDate:   Wed Jun 6 12:34:16 2012 +0200\n\n    rebase [-i --exec | -ix] <cmd>...\n....\n    Tests about this new command are also added in t3404-rebase-interactive.sh.\n....\n\n\nThis test doesn't pass on my Mac Os box.\n\nI run it with --debug --verbose, and it looks like another sed problem on Mac OS, may be.\n(My sed is /usr/bin, Mac OS X 10.6.8)\n\nI haven't been able to dig very deep into this, but the line  \n\"sed: 1: \"/^pick .*/i\\t\\t\\t\\texec  gi ...\": command i expects \\ followed by text\"\nlooks suspicious.\n\nCould the same be achieved by using tail instead of sed?\nAnybody else having this problem?\n\n\n====================\n\nok 54 - rebase-i history with funny messages\n\nexpecting success: \n\tgit checkout master &&\n\tgit checkout -b execute &&\n\ttest_commit one_exec main.txt one_exec &&\n\ttest_commit two_exec main.txt two_exec &&\n\ttest_commit three_exec main.txt three_exec\n\nSwitched to branch 'master'\nSwitched to a new branch 'execute'\n[execute 925b01e] one_exec\n Author: A U Thor <author@example.com>\n 1 file changed, 1 insertion(+)\n create mode 100644 main.txt\n[execute 7f87cbe] two_exec\n Author: A U Thor <author@example.com>\n 1 file changed, 1 insertion(+), 1 deletion(-)\n[execute f0f177e] three_exec\n Author: A U Thor <author@example.com>\n 1 file changed, 1 insertion(+), 1 deletion(-)\nok 55 - prepare for rebase -i --exec\n\nexpecting success: \n\tgit rebase -i --exec \"git show HEAD\" HEAD~2 >actual &&\n\t(\n\t\tFAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n\t\texport FAKE_LINES &&\n\t\tgit rebase -i HEAD~2 >expected\n\t) &&\n\tsed 1,9d expected >expect &&\n\tmv expect expected &&\n\ttest_cmp expected actual\n\nsed: 1: \"/^pick .*/i\\t\\t\\t\\texec  gi ...\": command i expects \\ followed by text\nSuccessfully rebased and updated refs/heads/execute.\nSuccessfully rebased and updated refs/heads/execute.\n--- expected\t2012-06-07 11:46:53.000000000 +0000\n+++ actual\t2012-06-07 11:46:52.000000000 +0000\n@@ -1,18 +1,4 @@\n-Rebasing (2/4)\nExecuting: git show HEAD\n-commit 8f99a4f1fbbd214b25a070ad34ec5a8f833522cc\n-Author: A U Thor <author@example.com>\n-Date:   Thu Apr 7 15:17:13 2005 -0700\n-\n-    E\n-\n-diff --git a/file3 b/file3\n-new file mode 100644\n-index 0000000..1c50726\n---- /dev/null\n-+++ b/file3\n-@@ -0,0 +1 @@\n-+E\n-Rebasing (3/4)\nRebasing (4/4)\nExecuting: git show HEAD\n+Rebasing (1/1)\nExecuting: git show HEAD\n commit 925b01e149bd188d43f972ad86d1e4d6611c8fa0\n Author: A U Thor <author@example.com>\n Date:   Thu Apr 7 16:10:13 2005 -0700\nnot ok - 56 running \"git rebase -i --exec git show HEAD\"\n"},{"id":"193069","messageId":"20120607162032.Horde.3lGNYXwdC4BP0LiwzlCRupA@webmail.minatec.grenoble-inp.fr","threadId":"30736","inReplyTo":"4FD0964E.7040302@web.de","subject":"Re: commit a63d7ed3017e312ddc752ac89a7d292a745d5f11 broken on MacOS","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-07T14:20:32Z","receivedAt":"2012-06-07T14:20:32Z","isPatch":false,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nTorsten Bögershausen <tboegi@web.de> a écrit :\n\n> commit a63d7ed3017e312ddc752ac89a7d292a745d5f11\n> Author: Lucien Kong <Lucien.Kong@ensimag.imag.fr>\n> Date:   Wed Jun 6 12:34:16 2012 +0200\n>\n>     rebase [-i --exec | -ix] <cmd>...\n> ....\n>     Tests about this new command are also added in  \n> t3404-rebase-interactive.sh.\n> ....\n>\n>\n> This test doesn't pass on my Mac Os box.\n>\n> I run it with --debug --verbose, and it looks like another sed  \n> problem on Mac OS, may be.\n> (My sed is /usr/bin, Mac OS X 10.6.8)\n>\n> I haven't been able to dig very deep into this, but the line\n> \"sed: 1: \"/^pick .*/i\\t\\t\\t\\texec  gi ...\": command i expects \\  \n> followed by text\"\n> looks suspicious.\n\nDoes it work if the whitespaces are deleted so that it becomes\n/^pick .*/i\\exec gi...\" ? (see the patch corrected below).\n\n\n-------->8 ------\n From 1820dd24d6c93e0ba3b7a19a205f0fce79777751 Mon Sep 17 00:00:00 2001\nFrom: Kong Lucien <Lucien.Kong@ensimag.imag.fr>\nDate: Sat, 2 Jun 2012 13:04:19 +0200\nSubject: rebase [-i --exec | -ix] <CMD>...\n\nThis patch provides a way to automatically add these \"exec\" lines\nbetween each commit applications. For instance, running 'git rebase -i\n--exec \"make test\"' lets you check that intermediate commits are\ncompilable. It is also compatible with the option --autosquash. At\nthis point, you can't use --exec without the interactive mode (-i).\n\nTests about this new command are also added in\nt3404-rebase-interactive.sh.\n\nSigned-off-by: Lucien Kong <Lucien.Kong@ensimag.imag.fr>\n---\n  Documentation/git-rebase.txt  |   54 +++++++++++++++--\n  git-rebase--interactive.sh    |   18 ++++++\n  git-rebase.sh                 |   20 ++++++-\n  t/t3404-rebase-interactive.sh |  124  \n+++++++++++++++++++++++++++++++++++++++++\n  4 files changed, 206 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 147fa1a..1dd95c4 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -8,9 +8,9 @@ git-rebase - Forward-port local commits to the updated  \nupstream head\n  SYNOPSIS\n  --------\n  [verse]\n-'git rebase' [-i | --interactive] [options] [--onto <newbase>]\n+'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]\n  \t[<upstream>] [<branch>]\n-'git rebase' [-i | --interactive] [options] --onto <newbase>\n+'git rebase' [-i | --interactive] [options] [--exec <cmd>] --onto <newbase>\n  \t--root [<branch>]\n  'git rebase' --continue | --skip | --abort\n\n@@ -210,11 +210,29 @@ rebase.autosquash::\n\n  OPTIONS\n  -------\n-<newbase>::\n-\tStarting point at which to create the new commits. If the\n-\t--onto option is not specified, the starting point is\n-\t<upstream>.  May be any valid commit, and not just an\n-\texisting branch name.\n+-x <cmd>::\n+--exec <cmd>::\n+\tAutomatically add \"exec\" followed by <cmd> between each commit\n+\tapplications. Using this option along with --autosquash adds\n+\tthe exec line after the squash/fixeup series only. <cmd>\n+\tstands for shell commands. The --exec option has to be\n+\tspecified. (see INTERACTIVE MODE below)\n++\n+This has to be used along with the `--interactive` option explicitly.\n+You may execute several commands between each commit applications.\n+For this, you can use one instance of exec:\n+\tgit rebase -i --exec \"cmd1; cmd2; ...\".\n+You can also insert several instances of exec, if you wish to\n+only have one command per line for example:\n+\tgit rebase -i --exec \"cmd1\" --exec \"cmd2\" ...\n+\n+--onto <newbase>::\n+\tWith this option, git rebase takes all commits from <branch>,\n+\tthat are not in <upstream>, and transplant them on top of\n+\t<newbase>. <newbase> is the starting point at which to create\n+\tthe new commits. If the --onto option is not specified, the\n+\tstarting point is <upstream>.  May be any valid commit, and\n+\tnot just an existing branch name.\n  +\n  As a special case, you may use \"A\\...B\" as a shortcut for the\n  merge base of A and B if there is exactly one merge base. You can\n@@ -521,6 +539,28 @@ in `$SHELL`, or the default shell if `$SHELL` is  \nnot set), so you can\n  use shell features (like \"cd\", \">\", \";\" ...). The command is run from\n  the root of the working tree.\n\n+----------------------------------\n+$ git rebase -i --exec \"make test\"\n+----------------------------------\n+\n+This command lets you check that intermediate commits are compilable.\n+The todo list becomes like that:\n+\n+--------------------\n+pick 5928aea one\n+exec make test\n+pick 04d0fda two\n+exec make test\n+pick ba46169 three\n+exec make test\n+pick f4593f9 four\n+exec make test\n+--------------------\n+\n+If the option '-i' is missing, The command will return a message\n+error. If there is no <cmd> specified behind --exec, the command will\n+return a message error and the usage page of 'git rebase'.\n+\n  SPLITTING COMMITS\n  -----------------\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0c19b7c..dc9e7e9 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -684,6 +684,22 @@ rearrange_squash () {\n  \trm -f \"$1.sq\" \"$1.rearranged\"\n  }\n\n+# Add commands after a pick or after a squash/fixup serie\n+# in the todo list.\n+add_exec_commands () {\n+\tOIFS=$IFS\n+\tIFS=$LF\n+\tfor i in $cmd\n+\tdo\n+\t\ttmp=$(sed \"/^pick .*/i\\exec $i\" \"$1\")\n+\t\techo \"$tmp\" >\"$1\"\n+\t\ttmp=$(sed '1d' \"$1\")\n+\t\techo \"$tmp\" >\"$1\"\n+\t\techo \"exec $i\" >>\"$1\"\n+\tdone\n+\tIFS=$OIFS\n+}\n+\n  case \"$action\" in\n  continue)\n  \t# do we have anything to commit?\n@@ -857,6 +873,8 @@ fi\n\n  test -s \"$todo\" || echo noop >> \"$todo\"\n  test -n \"$autosquash\" && rearrange_squash \"$todo\"\n+test -n \"$cmd\" && add_exec_commands \"$todo\"\n+\n  cat >> \"$todo\" << EOF\n\n  # Rebase $shortrevisions onto $shortonto\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 24a2840..19ead1a 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -3,7 +3,8 @@\n  # Copyright (c) 2005 Junio C Hamano.\n  #\n\n-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff]  \n[--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'\n+USAGE='[--interactive | -i] [--exec | -x <cmd>] [-v] [--force-rebase | -f]\n+       [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>]  \n[--quiet | -q]'\n  LONG_USAGE='git-rebase replaces <branch> with a new branch of the\n  same name.  When the --onto option is provided the new branch starts\n  out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>\n@@ -30,8 +31,8 @@ Example:       git-rebase master~1 topic\n  SUBDIRECTORY_OK=Yes\n  OPTIONS_KEEPDASHDASH=\n  OPTIONS_SPEC=\"\\\n-git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]\n-git rebase [-i] [options] --onto <newbase> --root [<branch>]\n+git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>]  \n[<upstream>] [<branch>]\n+git rebase [-i] [options] [--exec <cmd>] --onto <newbase> --root [<branch>]\n  git-rebase [-i] --continue | --abort | --skip\n  --\n   Available options are\n@@ -43,6 +44,7 @@ s,strategy=!       use the given merge strategy\n  no-ff!             cherry-pick all commits, even if unchanged\n  m,merge!           use merging strategies to rebase\n  i,interactive!     let the user edit the list of commits to rebase\n+x,exec=!           add exec lines after each commit of the editable list\n  k,keep-empty\t   preserve empty commits during rebase\n  f,force-rebase!    force rebase even if branch is up to date\n  X,strategy-option=! pass the argument through to the merge strategy\n@@ -76,6 +78,7 @@ If you would prefer to skip this patch, instead run  \n\\\"git rebase --skip\\\".\n  To check out the original branch and stop rebasing run \\\"git rebase  \n--abort\\\".\n  \"\n  unset onto\n+cmd=\n  strategy=\n  strategy_opts=\n  do_merge=\n@@ -219,6 +222,11 @@ do\n  \t\tonto=\"$2\"\n  \t\tshift\n  \t\t;;\n+\t-x)\n+\t\ttest 2 -le \"$#\" || usage\n+\t\tcmd=\"${cmd:+\"$cmd$LF\"} $2\"\n+\t\tshift\n+\t\t;;\n  \t-i)\n  \t\tinteractive_rebase=explicit\n  \t\t;;\n@@ -304,6 +312,12 @@ do\n  done\n  test $# -gt 2 && usage\n\n+if test -n \"$cmd\" &&\n+   test \"$interactive_rebase\" != explicit\n+then\n+\tdie \"--exec option must be used with --interactive option\\n\"\n+fi\n+\n  if test -n \"$action\"\n  then\n  \ttest -z \"$in_progress\" && die \"No rebase in progress?\"\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 025c1c6..4fe98d5 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -755,4 +755,128 @@ test_expect_success 'rebase-i history with funny  \nmessages' '\n  \ttest_cmp expect actual\n  '\n\n+\n+test_expect_success 'prepare for rebase -i --exec' '\n+\tgit checkout master &&\n+\tgit checkout -b execute &&\n+\ttest_commit one_exec main.txt one_exec &&\n+\ttest_commit two_exec main.txt two_exec &&\n+\ttest_commit three_exec main.txt three_exec\n+'\n+\n+\n+test_expect_success 'running \"git rebase -i --exec git show HEAD\"' '\n+\tgit rebase -i --exec \"git show HEAD\" HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,9d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'running \"git rebase --exec git show HEAD -i\"' '\n+\tgit reset --hard execute &&\n+\tgit rebase --exec \"git show HEAD\" -i HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,9d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'running \"git rebase -ix git show HEAD\"' '\n+\tgit reset --hard execute &&\n+\tgit rebase -ix \"git show HEAD\" HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,9d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase -ix with several <CMD>' '\n+\tgit reset --hard execute &&\n+\tgit rebase -ix \"git show HEAD; pwd\" HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,9d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase -ix with several instances of --exec' '\n+\tgit reset --hard execute &&\n+\tgit rebase -i --exec \"git show HEAD\" --exec \"pwd\" HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD exec_pwd 2\n+\t\t\t\texec_git_show_HEAD exec_pwd\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,11d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase -ix with --autosquash' '\n+\tgit reset --hard execute &&\n+\tgit checkout -b autosquash &&\n+\techo second >second.txt &&\n+\tgit add second.txt &&\n+\tgit commit -m \"fixup! two_exec\" &&\n+\techo bis >bis.txt &&\n+\tgit add bis.txt &&\n+\tgit commit -m \"fixup! two_exec\" &&\n+\t(\n+\t\tgit checkout -b autosquash_actual &&\n+\t\tgit rebase -i --exec \"git show HEAD\" --autosquash HEAD~4 >actual\n+\t) &&\n+\tgit checkout autosquash &&\n+\t(\n+\t\tgit checkout -b autosquash_expected &&\n+\t\tFAKE_LINES=\"1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~4 >expected\n+\t) &&\n+\tsed '1,13d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase --exec without -i shows error message' '\n+\tgit reset --hard execute &&\n+\ttest_must_fail git rebase --exec \"git show HEAD\" HEAD~2 2>actual &&\n+\techo \"--exec option must be used with --interactive option\\n\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase -i --exec without <CMD> shows error  \nmessage and usage' '\n+\tgit reset --hard execute &&\n+\ttest_must_fail git rebase -i --exec 2>actual &&\n+\tsed '1d' actual >tmp &&\n+\tmv tmp actual &&\n+\ttest_must_fail git rebase -h >expected &&\n+\ttest_cmp expected actual &&\n+\tgit checkout master\n+'\n+\n  test_done\n-- \n1.7.8\n"},{"id":"193072","messageId":"4FD0D375.9060902@web.de","threadId":"30736","inReplyTo":"20120607162032.Horde.3lGNYXwdC4BP0LiwzlCRupA@webmail.minatec.grenoble-inp.fr","subject":"Re: commit a63d7ed3017e312ddc752ac89a7d292a745d5f11 broken on MacOS","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2012-06-07T16:14:45Z","receivedAt":"2012-06-07T16:14:45Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 07.06.12 16:20, konglu@minatec.inpg.fr wrote:\n> Does it work if the whitespaces are deleted so that it becomes\n> /^pick .*/i\\exec gi...\" ? (see the patch corrected below).\n\n\nI didn't manage to appy the patch, either \nfatal: corrupt patch at line 14\nor, if I remove that line\nline 14 is bad, or there is no email address.\n\nDoes the patch apply on your system ?\n/Torsten\n"},{"id":"193075","messageId":"20120607184011.Horde._TrvenwdC4BP0Nlr034iWHA@webmail.minatec.grenoble-inp.fr","threadId":"30736","inReplyTo":"4FD0D375.9060902@web.de","subject":"Re: commit a63d7ed3017e312ddc752ac89a7d292a745d5f11 broken on MacOS","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-07T16:40:11Z","receivedAt":"2012-06-07T16:40:11Z","isPatch":false,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nTorsten Bögershausen <tboegi@web.de> a écrit :\n\n> On 07.06.12 16:20, konglu@minatec.inpg.fr wrote:\n>> Does it work if the whitespaces are deleted so that it becomes\n>> /^pick .*/i\\exec gi...\" ? (see the patch corrected below).\n>\n>\n> I didn't manage to appy the patch, either\n> fatal: corrupt patch at line 14\n> or, if I remove that line\n> line 14 is bad, or there is no email address.\n>\n> Does the patch apply on your system ?\n> /Torsten\n\nSorry, doesn't work on mine too. Gonna send a proper patch.\n\nLucien Kong\n"},{"id":"193077","messageId":"1339087582-10040-1-git-send-email-Lucien.Kong@ensimag.imag.fr","threadId":"30736","inReplyTo":"4FD0D375.9060902@web.de","subject":"rebase [-i --exec | -ix] <CMD>...","fromName":"Lucien Kong","fromEmail":"lucien.kong@ensimag.imag.fr","sentAt":"2012-06-07T16:46:22Z","receivedAt":"2012-06-07T16:46:22Z","isPatch":false,"sender":{"key":"lucien.kong@ensimag.imag.fr","avatar":null},"body":"The whitespaces before exec have been deleted. Does it\nwork now on MacOS ?\n\n---\n Documentation/git-rebase.txt  |   54 +++++++++++++++--\n git-rebase--interactive.sh    |   18 ++++++\n git-rebase.sh                 |   20 ++++++-\n t/t3404-rebase-interactive.sh |  124 +++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 206 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 147fa1a..1dd95c4 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -8,9 +8,9 @@ git-rebase - Forward-port local commits to the updated upstream head\n SYNOPSIS\n --------\n [verse]\n-'git rebase' [-i | --interactive] [options] [--onto <newbase>]\n+'git rebase' [-i | --interactive] [options] [--exec <cmd>] [--onto <newbase>]\n \t[<upstream>] [<branch>]\n-'git rebase' [-i | --interactive] [options] --onto <newbase>\n+'git rebase' [-i | --interactive] [options] [--exec <cmd>] --onto <newbase>\n \t--root [<branch>]\n 'git rebase' --continue | --skip | --abort\n \n@@ -210,11 +210,29 @@ rebase.autosquash::\n \n OPTIONS\n -------\n-<newbase>::\n-\tStarting point at which to create the new commits. If the\n-\t--onto option is not specified, the starting point is\n-\t<upstream>.  May be any valid commit, and not just an\n-\texisting branch name.\n+-x <cmd>::\n+--exec <cmd>::\n+\tAutomatically add \"exec\" followed by <cmd> between each commit\n+\tapplications. Using this option along with --autosquash adds\n+\tthe exec line after the squash/fixeup series only. <cmd>\n+\tstands for shell commands. The --exec option has to be\n+\tspecified. (see INTERACTIVE MODE below)\n++\n+This has to be used along with the `--interactive` option explicitly.\n+You may execute several commands between each commit applications.\n+For this, you can use one instance of exec:\n+\tgit rebase -i --exec \"cmd1; cmd2; ...\".\n+You can also insert several instances of exec, if you wish to\n+only have one command per line for example:\n+\tgit rebase -i --exec \"cmd1\" --exec \"cmd2\" ...\n+\n+--onto <newbase>::\n+\tWith this option, git rebase takes all commits from <branch>,\n+\tthat are not in <upstream>, and transplant them on top of\n+\t<newbase>. <newbase> is the starting point at which to create\n+\tthe new commits. If the --onto option is not specified, the\n+\tstarting point is <upstream>.  May be any valid commit, and\n+\tnot just an existing branch name.\n +\n As a special case, you may use \"A\\...B\" as a shortcut for the\n merge base of A and B if there is exactly one merge base. You can\n@@ -521,6 +539,28 @@ in `$SHELL`, or the default shell if `$SHELL` is not set), so you can\n use shell features (like \"cd\", \">\", \";\" ...). The command is run from\n the root of the working tree.\n \n+----------------------------------\n+$ git rebase -i --exec \"make test\"\n+----------------------------------\n+\n+This command lets you check that intermediate commits are compilable.\n+The todo list becomes like that:\n+\n+--------------------\n+pick 5928aea one\n+exec make test\n+pick 04d0fda two\n+exec make test\n+pick ba46169 three\n+exec make test\n+pick f4593f9 four\n+exec make test\n+--------------------\n+\n+If the option '-i' is missing, The command will return a message\n+error. If there is no <cmd> specified behind --exec, the command will\n+return a message error and the usage page of 'git rebase'.\n+\n SPLITTING COMMITS\n -----------------\n \ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0c19b7c..dc9e7e9 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -684,6 +684,22 @@ rearrange_squash () {\n \trm -f \"$1.sq\" \"$1.rearranged\"\n }\n \n+# Add commands after a pick or after a squash/fixup serie\n+# in the todo list.\n+add_exec_commands () {\n+\tOIFS=$IFS\n+\tIFS=$LF\n+\tfor i in $cmd\n+\tdo\n+\t\ttmp=$(sed \"/^pick .*/i\\exec $i\" \"$1\")\n+\t\techo \"$tmp\" >\"$1\"\n+\t\ttmp=$(sed '1d' \"$1\")\n+\t\techo \"$tmp\" >\"$1\"\n+\t\techo \"exec $i\" >>\"$1\"\n+\tdone\n+\tIFS=$OIFS\n+}\n+\n case \"$action\" in\n continue)\n \t# do we have anything to commit?\n@@ -857,6 +873,8 @@ fi\n \n test -s \"$todo\" || echo noop >> \"$todo\"\n test -n \"$autosquash\" && rearrange_squash \"$todo\"\n+test -n \"$cmd\" && add_exec_commands \"$todo\"\n+\n cat >> \"$todo\" << EOF\n \n # Rebase $shortrevisions onto $shortonto\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 24a2840..19ead1a 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -3,7 +3,8 @@\n # Copyright (c) 2005 Junio C Hamano.\n #\n \n-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'\n+USAGE='[--interactive | -i] [--exec | -x <cmd>] [-v] [--force-rebase | -f]\n+       [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'\n LONG_USAGE='git-rebase replaces <branch> with a new branch of the\n same name.  When the --onto option is provided the new branch starts\n out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>\n@@ -30,8 +31,8 @@ Example:       git-rebase master~1 topic\n SUBDIRECTORY_OK=Yes\n OPTIONS_KEEPDASHDASH=\n OPTIONS_SPEC=\"\\\n-git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]\n-git rebase [-i] [options] --onto <newbase> --root [<branch>]\n+git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]\n+git rebase [-i] [options] [--exec <cmd>] --onto <newbase> --root [<branch>]\n git-rebase [-i] --continue | --abort | --skip\n --\n  Available options are\n@@ -43,6 +44,7 @@ s,strategy=!       use the given merge strategy\n no-ff!             cherry-pick all commits, even if unchanged\n m,merge!           use merging strategies to rebase\n i,interactive!     let the user edit the list of commits to rebase\n+x,exec=!           add exec lines after each commit of the editable list\n k,keep-empty\t   preserve empty commits during rebase\n f,force-rebase!    force rebase even if branch is up to date\n X,strategy-option=! pass the argument through to the merge strategy\n@@ -76,6 +78,7 @@ If you would prefer to skip this patch, instead run \\\"git rebase --skip\\\".\n To check out the original branch and stop rebasing run \\\"git rebase --abort\\\".\n \"\n unset onto\n+cmd=\n strategy=\n strategy_opts=\n do_merge=\n@@ -219,6 +222,11 @@ do\n \t\tonto=\"$2\"\n \t\tshift\n \t\t;;\n+\t-x)\n+\t\ttest 2 -le \"$#\" || usage\n+\t\tcmd=\"${cmd:+\"$cmd$LF\"} $2\"\n+\t\tshift\n+\t\t;;\n \t-i)\n \t\tinteractive_rebase=explicit\n \t\t;;\n@@ -304,6 +312,12 @@ do\n done\n test $# -gt 2 && usage\n \n+if test -n \"$cmd\" &&\n+   test \"$interactive_rebase\" != explicit\n+then\n+\tdie \"--exec option must be used with --interactive option\\n\"\n+fi\n+\n if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"No rebase in progress?\"\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 025c1c6..4fe98d5 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -755,4 +755,128 @@ test_expect_success 'rebase-i history with funny messages' '\n \ttest_cmp expect actual\n '\n \n+\n+test_expect_success 'prepare for rebase -i --exec' '\n+\tgit checkout master &&\n+\tgit checkout -b execute &&\n+\ttest_commit one_exec main.txt one_exec &&\n+\ttest_commit two_exec main.txt two_exec &&\n+\ttest_commit three_exec main.txt three_exec\n+'\n+\n+\n+test_expect_success 'running \"git rebase -i --exec git show HEAD\"' '\n+\tgit rebase -i --exec \"git show HEAD\" HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,9d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'running \"git rebase --exec git show HEAD -i\"' '\n+\tgit reset --hard execute &&\n+\tgit rebase --exec \"git show HEAD\" -i HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,9d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'running \"git rebase -ix git show HEAD\"' '\n+\tgit reset --hard execute &&\n+\tgit rebase -ix \"git show HEAD\" HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,9d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase -ix with several <CMD>' '\n+\tgit reset --hard execute &&\n+\tgit rebase -ix \"git show HEAD; pwd\" HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,9d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase -ix with several instances of --exec' '\n+\tgit reset --hard execute &&\n+\tgit rebase -i --exec \"git show HEAD\" --exec \"pwd\" HEAD~2 >actual &&\n+\t(\n+\t\tFAKE_LINES=\"1 exec_git_show_HEAD exec_pwd 2\n+\t\t\t\texec_git_show_HEAD exec_pwd\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~2 >expected\n+\t) &&\n+\tsed '1,11d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase -ix with --autosquash' '\n+\tgit reset --hard execute &&\n+\tgit checkout -b autosquash &&\n+\techo second >second.txt &&\n+\tgit add second.txt &&\n+\tgit commit -m \"fixup! two_exec\" &&\n+\techo bis >bis.txt &&\n+\tgit add bis.txt &&\n+\tgit commit -m \"fixup! two_exec\" &&\n+\t(\n+\t\tgit checkout -b autosquash_actual &&\n+\t\tgit rebase -i --exec \"git show HEAD\" --autosquash HEAD~4 >actual\n+\t) &&\n+\tgit checkout autosquash &&\n+\t(\n+\t\tgit checkout -b autosquash_expected &&\n+\t\tFAKE_LINES=\"1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n+\t\texport FAKE_LINES &&\n+\t\tgit rebase -i HEAD~4 >expected\n+\t) &&\n+\tsed '1,13d' expected >expect &&\n+\tmv expect expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase --exec without -i shows error message' '\n+\tgit reset --hard execute &&\n+\ttest_must_fail git rebase --exec \"git show HEAD\" HEAD~2 2>actual &&\n+\techo \"--exec option must be used with --interactive option\\n\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success 'rebase -i --exec without <CMD> shows error message and usage' '\n+\tgit reset --hard execute &&\n+\ttest_must_fail git rebase -i --exec 2>actual &&\n+\tsed '1d' actual >tmp &&\n+\tmv tmp actual &&\n+\ttest_must_fail git rebase -h >expected &&\n+\ttest_cmp expected actual &&\n+\tgit checkout master\n+'\n+\n test_done\n-- \n1.7.8\n"},{"id":"193089","messageId":"4FD0EB76.90501@web.de","threadId":"30736","inReplyTo":"1339087582-10040-1-git-send-email-Lucien.Kong@ensimag.imag.fr","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2012-06-07T17:57:10Z","receivedAt":"2012-06-07T17:57:10Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"Still no success :-(\nPlease see below:\n\n\n\ngit checkout a63d7ed3017e312ddc752ac89a7d292\ntb@birne:~/projects/git/git.git> git am --abort ; git am < 1339089425.H311811P3927.appes.lan\\:2\\,S\n\nApplying: rebase [-i --exec | -ix] <CMD>...\nerror: patch failed: Documentation/git-rebase.txt:8\nerror: Documentation/git-rebase.txt: patch does not apply\nerror: patch failed: git-rebase--interactive.sh:684\nerror: git-rebase--interactive.sh: patch does not apply\nerror: patch failed: git-rebase.sh:3\nerror: git-rebase.sh: patch does not apply\nerror: patch failed: t/t3404-rebase-interactive.sh:755\nerror: t/t3404-rebase-interactive.sh: patch does not apply\nPatch failed at 0001 rebase [-i --exec | -ix] <CMD>...\nWhen you have resolved this problem run \"git am --resolved\".\nIf you would prefer to skip this patch, instead run \"git am --skip\".\nTo restore the original branch and stop patching run \"git am --abort\".\n"},{"id":"193093","messageId":"20120607200731.Horde.xzrpWHwdC4BP0O3jZ46SyWA@webmail.minatec.grenoble-inp.fr","threadId":"30736","inReplyTo":"4FD0EB76.90501@web.de","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-07T18:07:31Z","receivedAt":"2012-06-07T18:07:31Z","isPatch":false,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nTorsten Bögershausen <tboegi@web.de> a écrit :\n\n> Still no success :-(\n> Please see below:\n>\n> git checkout a63d7ed3017e312ddc752ac89a7d292\n> tb@birne:~/projects/git/git.git> git am --abort ; git am <  \n> 1339089425.H311811P3927.appes.lan\\:2\\,S\n>\n> Applying: rebase [-i --exec | -ix] <CMD>...\n> error: patch failed: Documentation/git-rebase.txt:8\n> error: Documentation/git-rebase.txt: patch does not apply\n> error: patch failed: git-rebase--interactive.sh:684\n> error: git-rebase--interactive.sh: patch does not apply\n> error: patch failed: git-rebase.sh:3\n> error: git-rebase.sh: patch does not apply\n> error: patch failed: t/t3404-rebase-interactive.sh:755\n> error: t/t3404-rebase-interactive.sh: patch does not apply\n> Patch failed at 0001 rebase [-i --exec | -ix] <CMD>...\n> When you have resolved this problem run \"git am --resolved\".\n> If you would prefer to skip this patch, instead run \"git am --skip\".\n> To restore the original branch and stop patching run \"git am --abort\".\n\nOn which branch are you applying the patch ? It should works on\nbranch master (it works for me) but it won't on branch \"pu\", as\nit has already been queued.\n\nLucien Kong\n"},{"id":"193100","messageId":"4FD0FCAC.3070408@web.de","threadId":"30736","inReplyTo":"20120607200731.Horde.xzrpWHwdC4BP0O3jZ46SyWA@webmail.minatec.grenoble-inp.fr","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2012-06-07T19:10:36Z","receivedAt":"2012-06-07T19:10:36Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 07.06.12 20:07, konglu@minatec.inpg.fr wrote:\n> On which branch are you applying the patch ? It should works on\n> branch master (it works for me) but it won't on branch \"pu\", as\n> it has already been queued.\n>\n> Lucien Kong\n>\nThanks, now the patch applies on master.\nBut it seems that the problem is still there:\n================\n[snip]\nok 55 - prepare for rebase -i --exec\n\nexpecting success:\n    git rebase -i --exec \"git show HEAD\" HEAD~2 >actual &&\n    (\n        FAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n        export FAKE_LINES &&\n        git rebase -i HEAD~2 >expected\n    ) &&\n    sed 1,9d expected >expect &&\n    mv expect expected &&\n    test_cmp expected actual\n\nsed: 1: \"/^pick .*/i\\exec  git s ...\": extra characters after \\ at the end of i command\nSuccessfully rebased and updated refs/heads/execute.\nSuccessfully rebased and updated refs/heads/execute.\n--- expected    2012-06-07 19:07:51.000000000 +0000\n+++ actual    2012-06-07 19:07:50.000000000 +0000\n@@ -1,18 +1,4 @@\n-Rebasing (2/4)\nExecuting: git show HEAD\n-commit 8f99a4f1fbbd214b25a070ad34ec5a8f833522cc\n-Author: A U Thor <author@example.com>\n-Date:   Thu Apr 7 15:17:13 2005 -0700\n-\n-    E\n-\n-diff --git a/file3 b/file3\n-new file mode 100644\n-index 0000000..1c50726\n---- /dev/null\n-+++ b/file3\n-@@ -0,0 +1 @@\n-+E\n-Rebasing (3/4)\nRebasing (4/4)\nExecuting: git show HEAD\n+Rebasing (1/1)\nExecuting: git show HEAD\n commit 925b01e149bd188d43f972ad86d1e4d6611c8fa0\n Author: A U Thor <author@example.com>\n Date:   Thu Apr 7 16:10:13 2005 -0700\nnot ok - 56 running \"git rebase -i --exec git show HEAD\"\n[snip]\n"},{"id":"193103","messageId":"20120607215512.Horde.RVmScHwdC4BP0QcggMBjKUA@webmail.minatec.grenoble-inp.fr","threadId":"30736","inReplyTo":"4FD0FCAC.3070408@web.de","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-07T19:55:12Z","receivedAt":"2012-06-07T19:55:12Z","isPatch":false,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nTorsten Bögershausen <tboegi@web.de> a écrit :\n\n> On 07.06.12 20:07, konglu@minatec.inpg.fr wrote:\n>> On which branch are you applying the patch ? It should works on\n>> branch master (it works for me) but it won't on branch \"pu\", as\n>> it has already been queued.\n>>\n>> Lucien Kong\n>>\n> Thanks, now the patch applies on master.\n> But it seems that the problem is still there:\n> ================\n> [snip]\n> ok 55 - prepare for rebase -i --exec\n>\n> expecting success:\n>     git rebase -i --exec \"git show HEAD\" HEAD~2 >actual &&\n>     (\n>         FAKE_LINES=\"1 exec_git_show_HEAD 2 exec_git_show_HEAD\" &&\n>         export FAKE_LINES &&\n>         git rebase -i HEAD~2 >expected\n>     ) &&\n>     sed 1,9d expected >expect &&\n>     mv expect expected &&\n>     test_cmp expected actual\n>\n> sed: 1: \"/^pick .*/i\\exec  git s ...\": extra characters after \\ at  \n> the end of i command\n> Successfully rebased and updated refs/heads/execute.\n> Successfully rebased and updated refs/heads/execute.\n> --- expected    2012-06-07 19:07:51.000000000 +0000\n> +++ actual    2012-06-07 19:07:50.000000000 +0000\n> @@ -1,18 +1,4 @@\n> -Rebasing (2/4)\n> Executing: git show HEAD\n> -commit 8f99a4f1fbbd214b25a070ad34ec5a8f833522cc\n> -Author: A U Thor <author@example.com>\n> -Date:   Thu Apr 7 15:17:13 2005 -0700\n> -\n> -    E\n> -\n> -diff --git a/file3 b/file3\n> -new file mode 100644\n> -index 0000000..1c50726\n> ---- /dev/null\n> -+++ b/file3\n> -@@ -0,0 +1 @@\n> -+E\n> -Rebasing (3/4)\n> Rebasing (4/4)\n> Executing: git show HEAD\n> +Rebasing (1/1)\n> Executing: git show HEAD\n>  commit 925b01e149bd188d43f972ad86d1e4d6611c8fa0\n>  Author: A U Thor <author@example.com>\n>  Date:   Thu Apr 7 16:10:13 2005 -0700\n> not ok - 56 running \"git rebase -i --exec git show HEAD\"\n> [snip]\n\nAs you pointed out, the problem seems to come from this line\n\ttmp=$(sed \"/^pick .*/i\\exec $i\" \"$1\")\nI think that the dquote here doesn't work on MacOS, though i've\nnever tried it. Anyway, even if it's not the problem, this kind\nof quoting is quite odd so it will be removed in the next patch\n(I do not see other reasons of the issue, as sed's i command should\nwork on MacOS).\n"},{"id":"193107","messageId":"m2k3zivp0c.fsf@igel.home","threadId":"30736","inReplyTo":"20120607215512.Horde.RVmScHwdC4BP0QcggMBjKUA@webmail.minatec.grenoble-inp.fr","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-06-07T20:35:47Z","receivedAt":"2012-06-07T20:35:47Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"konglu@minatec.inpg.fr writes:\n\n> As you pointed out, the problem seems to come from this line\n> \ttmp=$(sed \"/^pick .*/i\\exec $i\" \"$1\")\n> I think that the dquote here doesn't work on MacOS, though i've\n> never tried it. Anyway, even if it's not the problem, this kind\n> of quoting is quite odd so it will be removed in the next patch\n> (I do not see other reasons of the issue, as sed's i command should\n> work on MacOS).\n\nYou need to put a newline after the backslash.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"193109","messageId":"20120607224459.Horde.GLRVL3wdC4BP0RLLE1gTU0A@webmail.minatec.grenoble-inp.fr","threadId":"30736","inReplyTo":"m2k3zivp0c.fsf@igel.home","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-07T20:44:59Z","receivedAt":"2012-06-07T20:44:59Z","isPatch":false,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nAndreas Schwab <schwab@linux-m68k.org> a écrit :\n\n> konglu@minatec.inpg.fr writes:\n>\n>> As you pointed out, the problem seems to come from this line\n>> \ttmp=$(sed \"/^pick .*/i\\exec $i\" \"$1\")\n>> I think that the dquote here doesn't work on MacOS, though i've\n>> never tried it. Anyway, even if it's not the problem, this kind\n>> of quoting is quite odd so it will be removed in the next patch\n>> (I do not see other reasons of the issue, as sed's i command should\n>> work on MacOS).\n>\n> You need to put a newline after the backslash.\n\nThat's what we originally did. Though we did it with indentations:\n         tmp=$(sed \"/^pick .*/i\\\n                            exec $i\" \"$1\")\nShould it be put that way (without indentations) ?\n         tmp=$(sed \"/^pick .*/i\\\nexec $i\" \"$1\")\n\nThanks,\n\nLucien Kong\n"},{"id":"193110","messageId":"vpqboku3l0s.fsf@bauges.imag.fr","threadId":"30736","inReplyTo":"20120607215512.Horde.RVmScHwdC4BP0QcggMBjKUA@webmail.minatec.grenoble-inp.fr","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-06-07T20:49:23Z","receivedAt":"2012-06-07T20:49:23Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"konglu@minatec.inpg.fr writes:\n\n> As you pointed out, the problem seems to come from this line\n> \ttmp=$(sed \"/^pick .*/i\\exec $i\" \"$1\")\n> I think that the dquote here doesn't work on MacOS, though i've\n> never tried it.\n\nI don't see a reason why it wouldn't. Anyway, quotes are managed by the\nshell, and in our case, sed is the one complaining.\n\nI experimented a bit, and it seems Mac OS's sed insists in having a \\\nand a newline after i (it seems POSIX requires it too). In your code\nabove, the \\ is included in double quotes, so you have to escape it.\n\nThis snippet works reliably on my Linux machine and on a Mac OS X one:\n\nx=$(echo 'pick foo' | sed -e \"/pick/i\\\\\nexec $1\")\necho \"$x\"\n\n> Anyway, even if it's not the problem, this kind of quoting is quite\n> odd so it will be removed in the next patch\n\nBe careful, you do need quoting around $i.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"193111","messageId":"4FD1162C.50405@kdbg.org","threadId":"30736","inReplyTo":"1339087582-10040-1-git-send-email-Lucien.Kong@ensimag.imag.fr","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-06-07T20:59:24Z","receivedAt":"2012-06-07T20:59:24Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 07.06.2012 18:46, schrieb Lucien Kong:\n> +# Add commands after a pick or after a squash/fixup serie\n> +# in the todo list.\n> +add_exec_commands () {\n> +\tOIFS=$IFS\n> +\tIFS=$LF\n> +\tfor i in $cmd\n> +\tdo\n> +\t\ttmp=$(sed \"/^pick .*/i\\exec $i\" \"$1\")\n> +\t\techo \"$tmp\" >\"$1\"\n> +\t\ttmp=$(sed '1d' \"$1\")\n> +\t\techo \"$tmp\" >\"$1\"\n> +\t\techo \"exec $i\" >>\"$1\"\n> +\tdone\n> +\tIFS=$OIFS\n> +}\n\nHow about this?\n\n\t{\n\t\tfirst=t\n\t\twhile read -r insn rest\n\t\tdo\n\t\t\tcase $insn in\n\t\t\tpick)\n\t\t\t\ttest -n \"$first\" ||\n\t\t\t\tprintf \"%s\" \"$cmd\"\n\t\t\t\t;;\n\t\t\tesac\n\t\t\tprintf \"%s %s\\n\" \"$insn\" \"$rest\"\n\t\t\tfirst=\n\t\tdone\n\t\tprintf \"%s\" \"$cmd\"\n\t} <\"$1\" >\"$1.new\" &&\n\tmv \"$1.new\" \"$1\"\n\ntogether with:\n\n> +\t-x)\n> +\t\ttest 2 -le \"$#\" || usage\n> +\t\tcmd=\"${cmd:+\"$cmd$LF\"} $2\"\n> +\t\tshift\n> +\t\t;;\n\n\t\tcmd=\"${cmd}exec $2${LF}\"\n\n(I did not test this.)\n\n-- Hannes\n"},{"id":"193114","messageId":"m2fwa6vnbs.fsf@igel.home","threadId":"30736","inReplyTo":"20120607224459.Horde.GLRVL3wdC4BP0RLLE1gTU0A@webmail.minatec.grenoble-inp.fr","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-06-07T21:12:07Z","receivedAt":"2012-06-07T21:12:07Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"konglu@minatec.inpg.fr writes:\n\n> That's what we originally did. Though we did it with indentations:\n>          tmp=$(sed \"/^pick .*/i\\\n>                             exec $i\" \"$1\")\n\nInside double quotes \\<newline> is removed.  You need to double the\nbackslash.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"193163","messageId":"7vr4tpddgg.fsf@alter.siamese.dyndns.org","threadId":"30736","inReplyTo":"4FD1162C.50405@kdbg.org","subject":"Re: rebase [-i --exec | -ix] <CMD>...","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-08T15:34:55Z","receivedAt":"2012-06-08T15:34:55Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> How about this?\n>\n> \t{\n> \t\tfirst=t\n> \t\twhile read -r insn rest\n> \t\tdo\n> \t\t\tcase $insn in\n> \t\t\tpick)\n> \t\t\t\ttest -n \"$first\" ||\n> \t\t\t\tprintf \"%s\" \"$cmd\"\n> \t\t\t\t;;\n> \t\t\tesac\n> \t\t\tprintf \"%s %s\\n\" \"$insn\" \"$rest\"\n> \t\t\tfirst=\n> \t\tdone\n> \t\tprintf \"%s\" \"$cmd\"\n> \t} <\"$1\" >\"$1.new\" &&\n> \tmv \"$1.new\" \"$1\"\n>\n> together with:\n> ...\n\nThis is my favorite version among the ones I've seen so far.\n"}]}