{"thread":{"id":"29888","subject":"[PATCHv2 1/2] rebase -i: optimize the creation of the todo file","startedAt":"2012-03-08T13:52:56Z","lastAt":"2012-03-09T09:52:03Z","messageCount":7,"participants":["Dominique Quatravaux","David Barr","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"186450","messageId":"1331214777-9455-1-git-send-email-domq@google.com","threadId":"29888","inReplyTo":null,"subject":"[PATCHv2 1/2] rebase -i: optimize the creation of the todo file","fromName":"Dominique Quatravaux","fromEmail":"domq@google.com","sentAt":"2012-03-08T13:52:56Z","receivedAt":"2012-03-08T13:52:56Z","isPatch":false,"sender":{"key":"domq@google.com","avatar":"https://gravatar.com/avatar/121b20f85f75e3366ecd70be7f2777189ed53d0cc5472531cde13e4ed9e4f61e?d=mp&s=160"},"body":"Instead of obtaining short SHA1's from \"git rev-list\" and hitting the repository\nonce more with \"git rev-parse\" for the full-size SHA1's, obtain both short and\nlong SHA1's from \"git log\" at once.\n---\n git-rebase--interactive.sh |    5 ++---\n 1 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 5812222..e408e94 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -774,17 +774,16 @@ else\n \trevisions=$onto...$orig_head\n \tshortrevisions=$shorthead\n fi\n-git rev-list $merges_option --pretty=oneline --abbrev-commit \\\n+git rev-list $merges_option --format=\"%m%H %h %s\" --abbrev-commit \\\n \t--abbrev=7 --reverse --left-right --topo-order \\\n \t$revisions | \\\n \tsed -n \"s/^>//p\" |\n-while read -r shortsha1 rest\n+while read -r sha1 shortsha1 rest\n do\n \tif test t != \"$preserve_merges\"\n \tthen\n \t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$todo\"\n \telse\n-\t\tsha1=$(git rev-parse $shortsha1)\n \t\tif test -z \"$rebase_root\"\n \t\tthen\n \t\t\tpreserve=t\n-- \n1.7.7.3\n"},{"id":"186451","messageId":"1331214777-9455-2-git-send-email-domq@google.com","threadId":"29888","inReplyTo":"1331214777-9455-1-git-send-email-domq@google.com","subject":"[PATCHv2 2/2] rebase -i: new option --name-rev","fromName":"Dominique Quatravaux","fromEmail":"domq@google.com","sentAt":"2012-03-08T13:52:57Z","receivedAt":"2012-03-08T13:52:57Z","isPatch":false,"sender":{"key":"domq@google.com","avatar":"https://gravatar.com/avatar/121b20f85f75e3366ecd70be7f2777189ed53d0cc5472531cde13e4ed9e4f61e?d=mp&s=160"},"body":"If set, the second column of the rebase todo contains named revisions (obtained\nwith git name-rev) instead of short SHA1s.\n---\n Documentation/git-rebase.txt  |    7 +++++++\n git-rebase--interactive.sh    |   10 ++++++++--\n git-rebase.sh                 |   10 ++++++++++\n t/t3404-rebase-interactive.sh |   10 ++++++++++\n t/t3415-rebase-autosquash.sh  |   24 ++++++++++++++++++++++++\n 5 files changed, 59 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 504945c..da2aca7 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -365,6 +365,13 @@ If the '--autosquash' option is enabled by default using the\n configuration variable `rebase.autosquash`, this option can be\n used to override and disable this setting.\n \n+--name-rev::\n+\tInstead of showing short SHA1 hashes in the todo list, show\n+\thuman-readable revisions obtained with linkgit:git-name-rev[1].\n++\n+This option is only valid when the '--interactive' option is used. It can also\n+be set through the `rebase.interactiveNameRev` configuration variable.\n+\n --no-ff::\n \tWith --interactive, cherry-pick all rebased commits instead of\n \tfast-forwarding over the unchanged ones.  This ensures that the\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex e408e94..c597b6b 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -780,9 +780,15 @@ git rev-list $merges_option --format=\"%m%H %h %s\" --abbrev-commit \\\n \tsed -n \"s/^>//p\" |\n while read -r sha1 shortsha1 rest\n do\n+\tif test t = \"$name_rev\"\n+\tthen\n+\t\trev=\"$(git name-rev $sha1 | cut -d\\  -f2)\"\n+\telse\n+\t\trev=\"$shortsha1\"\n+\tfi\n \tif test t != \"$preserve_merges\"\n \tthen\n-\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$todo\"\n+\t\tprintf '%s\\n' \"pick $rev $rest\" >> \"$todo\"\n \telse\n \t\tif test -z \"$rebase_root\"\n \t\tthen\n@@ -800,7 +806,7 @@ do\n \t\tif test f = \"$preserve\"\n \t\tthen\n \t\t\ttouch \"$rewritten\"/$sha1\n-\t\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$todo\"\n+\t\t\tprintf '%s\\n' \"pick $rev $rest\" >> \"$todo\"\n \t\tfi\n \tfi\n done\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 69c1374..9330be3 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -43,6 +43,8 @@ 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+name-rev           show revisions by name in the list of commits\n+no-name-rev        show revisions by short SHA1 in the list (default)\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 stat!              display a diffstat of what changed upstream\n@@ -98,6 +100,8 @@ action=\n preserve_merges=\n autosquash=\n test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n+name_rev=\n+test \"$(git config --bool rebase.interactivenamerev)\" = \"true\" && name_rev=t\n \n read_basic_state () {\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n@@ -287,6 +291,12 @@ do\n \t-f|--no-ff)\n \t\tforce_rebase=t\n \t\t;;\n+\t--name-rev)\n+\t\tname_rev=t\n+\t\t;;\n+\t--no-name-rev)\n+\t\tname_rev=\n+\t\t;;\n \t--rerere-autoupdate|--no-rerere-autoupdate)\n \t\tallow_rerere_autoupdate=\"$1\"\n \t\t;;\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex b981572..f3b4214 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -163,6 +163,16 @@ test_expect_success 'exchange two commits' '\n \ttest G = $(git cat-file commit HEAD | sed -ne \\$p)\n '\n \n+cat > expect-rebase-todo <<EOF\n+pick branch1~1 H\n+pick branch1 G\n+EOF\n+\n+test_expect_success 'Symbolic revisions in --name-rev' '\n+\tFAKE_LINES=\"exec_cp_.git/rebase-merge/git-rebase-todo_rebase-todo 1 2\" git rebase -i --name-rev HEAD~2 &&\n+\ttest_cmp expect-rebase-todo rebase-todo\n+'\n+\n cat > expect << EOF\n diff --git a/file1 b/file1\n index f70f10e..fd79235 100644\ndiff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh\nindex b38be8e..3062e24 100755\n--- a/t/t3415-rebase-autosquash.sh\n+++ b/t/t3415-rebase-autosquash.sh\n@@ -169,6 +169,30 @@ test_expect_success 'auto squash that matches longer sha1' '\n \ttest 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)\n '\n \n+test_expect_success 'auto fixup with --name-rev' '\n+\tgit reset --hard base &&\n+\techo 2 >file1 &&\n+\tgit add -u &&\n+\ttest_tick &&\n+\tgit commit -m \"changing file1\" &&\n+\techo 4 >file2 &&\n+\tgit add -u &&\n+\ttest_tick &&\n+\tgit commit -m \"changing file2\" &&\n+\techo 1 >file1 &&\n+\tgit add -u &&\n+\ttest_tick &&\n+\tgit commit -m \"fixup! changing file1\" &&\n+\tgit tag final-fixup-name-rev &&\n+\ttest_tick &&\n+\tgit rebase -i --autosquash --name-rev HEAD^^^ &&\n+\tgit log --oneline base..HEAD >actual &&\n+\ttest 2 = $(wc -l <actual) &&\n+\tgit diff --exit-code final-fixup-name-rev &&\n+\ttest 2 = \"$(git cat-file blob HEAD^:file2)\" &&\n+\ttest 1 = $(git cat-file commit HEAD^ | grep changing | wc -l)\n+'\n+\n test_auto_commit_flags () {\n \tgit reset --hard base &&\n \techo 1 >file1 &&\n-- \n1.7.7.3\n"},{"id":"186521","messageId":"CAFfmPPMt_o1Rg-Pvuh_KpARrASwfYSq74UN3ayp=LVzLJ0oj=A@mail.gmail.com","threadId":"29888","inReplyTo":"1331214777-9455-1-git-send-email-domq@google.com","subject":"Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file","fromName":"David Barr","fromEmail":"davidbarr@google.com","sentAt":"2012-03-09T05:00:19Z","receivedAt":"2012-03-09T05:00:19Z","isPatch":false,"sender":{"key":"davidbarr@google.com","avatar":"https://avatars.githubusercontent.com/u/220594?v=4"},"body":"On Fri, Mar 9, 2012 at 12:52 AM, Dominique Quatravaux <domq@google.com> wrote:\n> Instead of obtaining short SHA1's from \"git rev-list\" and hitting the repository\n> once more with \"git rev-parse\" for the full-size SHA1's, obtain both short and\n> long SHA1's from \"git log\" at once.\n> ---\n>  git-rebase--interactive.sh |    5 ++---\n>  1 files changed, 2 insertions(+), 3 deletions(-)\n>\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index 5812222..e408e94 100644\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -774,17 +774,16 @@ else\n>        revisions=$onto...$orig_head\n>        shortrevisions=$shorthead\n>  fi\n> -git rev-list $merges_option --pretty=oneline --abbrev-commit \\\n> +git rev-list $merges_option --format=\"%m%H %h %s\" --abbrev-commit \\\n>        --abbrev=7 --reverse --left-right --topo-order \\\n>        $revisions | \\\n>        sed -n \"s/^>//p\" |\n> -while read -r shortsha1 rest\n> +while read -r sha1 shortsha1 rest\n>  do\n>        if test t != \"$preserve_merges\"\n>        then\n>                printf '%s\\n' \"pick $shortsha1 $rest\" >> \"$todo\"\n>        else\n> -               sha1=$(git rev-parse $shortsha1)\n>                if test -z \"$rebase_root\"\n>                then\n>                        preserve=t\n> --\n> 1.7.7.3\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nAck. Yay, less forking.\n\nI do notice however that the output being fed to sed expands like so:\n\n  commit >634a5f265ad729b91266de65272e2b5a35d05b1c\n  >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]\n  commit >828ea97de486c1693d6e4f2c7347acb50235a85d\n  >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9\n\nMaybe the format spec and sed command could use a little tuning.\n\n--\nDavid Barr\n"},{"id":"186542","messageId":"CAJh6GrHMb-H6ktEGGHxMxbZXujKFe=unYzAyS-zoGnfzMfcKQA@mail.gmail.com","threadId":"29888","inReplyTo":"CAFfmPPMt_o1Rg-Pvuh_KpARrASwfYSq74UN3ayp=LVzLJ0oj=A@mail.gmail.com","subject":"Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file","fromName":"Dominique Quatravaux","fromEmail":"domq@google.com","sentAt":"2012-03-09T09:18:57Z","receivedAt":"2012-03-09T09:18:57Z","isPatch":false,"sender":{"key":"domq@google.com","avatar":"https://gravatar.com/avatar/121b20f85f75e3366ecd70be7f2777189ed53d0cc5472531cde13e4ed9e4f61e?d=mp&s=160"},"body":"On Fri, Mar 9, 2012 at 6:00 AM, David Barr <davidbarr@google.com> wrote:\n> I do notice however that the output being fed to sed expands like so:\n>\n>  commit >634a5f265ad729b91266de65272e2b5a35d05b1c\n>  >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]\n>  commit >828ea97de486c1693d6e4f2c7347acb50235a85d\n>  >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9\n>\n> Maybe the format spec and sed command could use a little tuning.\n\nHmm, from rev-list.c it appears that \"oneline\" is the only format that has git\nrev-list output one line per commit:\n\n102 \tif (revs->commit_format == CMIT_FMT_ONELINE)\n103 \t\tputchar(' ');\n104 \telse\n105 \t\tputchar('\\n');\n\n[...]\n\n362 \t\tif (revs.commit_format == CMIT_FMT_ONELINE)\n363 \t\t\tinfo.header_prefix = \"\";\n364 \t\telse\n365 \t\t\tinfo.header_prefix = \"commit \";\n\nI could fix that by using \"git log\" instead (hence the erroneous log message for\nthis patch, that I'll fix in the next attempt), but I don't know about the\nimplications of that (semantic or performance-wise). On the other hand, I can't\nimagine how sed skipping every other \"commit 12345abcdef\" line could be a\nnoticeable performance drain. Advice welcome.\n\n-- \n  Dominique Quatravaux\n  +41 79 609 40 72\n"},{"id":"186543","messageId":"CAJh6GrEv5FJTeH7qZ1knBY_f2ZgSLBV=smP8vA+EHqUdG1p_JA@mail.gmail.com","threadId":"29888","inReplyTo":"CAJh6GrHMb-H6ktEGGHxMxbZXujKFe=unYzAyS-zoGnfzMfcKQA@mail.gmail.com","subject":"Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file","fromName":"Dominique Quatravaux","fromEmail":"domq@google.com","sentAt":"2012-03-09T09:21:46Z","receivedAt":"2012-03-09T09:21:46Z","isPatch":false,"sender":{"key":"domq@google.com","avatar":"https://gravatar.com/avatar/121b20f85f75e3366ecd70be7f2777189ed53d0cc5472531cde13e4ed9e4f61e?d=mp&s=160"},"body":"On Fri, Mar 9, 2012 at 6:00 AM, David Barr <davidbarr@google.com> wrote:\n>> I do notice however that the output being fed to sed expands like so:\n>>\n>>  commit >634a5f265ad729b91266de65272e2b5a35d05b1c\n>>  >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]\n>>  commit >828ea97de486c1693d6e4f2c7347acb50235a85d\n>>  >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9\n>>\n>> Maybe the format spec and sed command could use a little tuning.\n\nNever mind, I missed the \"and sed command\" part and now I get what you\nhave in mind. This is a bit beyond my sed skillz at the moment but\nI'll get back to you :)\n\n-- \n  Dominique Quatravaux\n  +41 79 609 40 72\n"},{"id":"186546","messageId":"7vpqcm85rs.fsf@alter.siamese.dyndns.org","threadId":"29888","inReplyTo":"CAFfmPPMt_o1Rg-Pvuh_KpARrASwfYSq74UN3ayp=LVzLJ0oj=A@mail.gmail.com","subject":"Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-09T09:47:51Z","receivedAt":"2012-03-09T09:47:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Barr <davidbarr@google.com> writes:\n\n> I do notice however that the output being fed to sed expands like so:\n>\n>   commit >634a5f265ad729b91266de65272e2b5a35d05b1c\n>   >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]\n>   commit >828ea97de486c1693d6e4f2c7347acb50235a85d\n>   >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9\n>\n> Maybe the format spec and sed command could use a little tuning.\n\nWhy would that be a problem, though?  The sed script picks only\nlines that begin with '>' and discards the traditional diff-tree\nstyle per commit header, no?\n"},{"id":"186549","messageId":"CAJh6GrH3x-Fz5gqKdu_fcmH0OH3KG8En3H2vURKhkYuiC+s59g@mail.gmail.com","threadId":"29888","inReplyTo":"7vpqcm85rs.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 1/2] rebase -i: optimize the creation of the todo file","fromName":"Dominique Quatravaux","fromEmail":"domq@google.com","sentAt":"2012-03-09T09:52:03Z","receivedAt":"2012-03-09T09:52:03Z","isPatch":false,"sender":{"key":"domq@google.com","avatar":"https://gravatar.com/avatar/121b20f85f75e3366ecd70be7f2777189ed53d0cc5472531cde13e4ed9e4f61e?d=mp&s=160"},"body":"On Fri, Mar 9, 2012 at 10:47 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> David Barr <davidbarr@google.com> writes:\n>\n>> I do notice however that the output being fed to sed expands like so:\n>>\n>>   commit >634a5f265ad729b91266de65272e2b5a35d05b1c\n>>   >634a5f265ad729b91266de65272e2b5a35d05b1c 634a5f2 INSTALL: warn [...]\n>>   commit >828ea97de486c1693d6e4f2c7347acb50235a85d\n>>   >828ea97de486c1693d6e4f2c7347acb50235a85d 828ea97 Git 1.7.9\n>>\n>> Maybe the format spec and sed command could use a little tuning.\n>\n> Why would that be a problem, though?  The sed script picks only\n> lines that begin with '>' and discards the traditional diff-tree\n> style per commit header, no?\n\nI assume that David wants to have\n\n  commit >634a5f265ad729b91266de65272e2b5a35d05b1c\n  634a5f2 INSTALL: warn [...]\n\nand chew on that with sed.\n\n-- \n  Dominique Quatravaux\n  +41 79 609 40 72\n"}]}