{"thread":{"id":"24138","subject":"[PATCH] Allow hashes in git rebase --interactive --autosquash.","startedAt":"2010-06-17T12:55:22Z","lastAt":"2010-06-17T13:17:47Z","messageCount":2,"participants":["Peter Krefting","Jay Soffian"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"143862","messageId":"20100617125746.E86B42FC00@perkele","threadId":"24138","inReplyTo":null,"subject":"[PATCH] Allow hashes in git rebase --interactive --autosquash.","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2010-06-17T12:55:22Z","receivedAt":"2010-06-17T12:55:22Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"In addition to matching the \"fixup!\" and \"squash!\" commits to the commit\nmessage, also match the commit hash. This allows a commit message like\n\"fixup! e83c5163316f89bfbde7d9ab23ca2e25604af290\" to be detected as a\nfixup commit.\n\nSigned-off-by: Peter Krefting <peter@softwolves.pp.se>\n---\n\nI actually misread the git-rebase manual page to think that this was how\n\"fixup!\" and \"squash!\" was supposed to be used, and now I have so many\n\"fixup! <hash>\" commits to rebase that I felt it worth it to implement\nsupport for it... :-)\n\n Documentation/git-rebase.txt |    8 ++++----\n git-rebase--interactive.sh   |   12 +++++++++---\n t/t3415-rebase-autosquash.sh |   17 +++++++++++++++++\n 3 files changed, 30 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 0d07b1b..e28d742 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -318,10 +318,10 @@ link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for details).\n --autosquash::\n \tWhen the commit log message begins with \"squash! ...\" (or\n \t\"fixup! ...\"), and there is a commit whose title begins with\n-\tthe same ..., automatically modify the todo list of rebase -i\n-\tso that the commit marked for squashing comes right after the\n-\tcommit to be modified, and change the action of the moved\n-\tcommit from `pick` to `squash` (or `fixup`).\n+\tthe same ..., or whose hash is ..., automatically modify the\n+        todo list of rebase -i so that the commit marked for squashing\n+        comes right after the commit to be modified, and change the\n+        action of the moved commit from `pick` to `squash` (or `fixup`).\n +\n This option is only valid when the '--interactive' option is used.\n \ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 436b7f5..d639ee6 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -634,9 +634,9 @@ get_saved_options () {\n }\n \n # Rearrange the todo list that has both \"pick sha1 msg\" and\n-# \"pick sha1 fixup!/squash! msg\" appears in it so that the latter\n-# comes immediately after the former, and change \"pick\" to\n-# \"fixup\"/\"squash\".\n+# \"pick sha1 fixup!/squash! msg\" or \"pick sha1 fixup!/squash!\n+# sha1\" appears in it so that the latter comes immediately\n+# after the former, and change \"pick\" to \"fixup\"/\"squash\".\n rearrange_squash () {\n \tsed -n -e 's/^pick \\([0-9a-f]*\\) \\(squash\\)! /\\1 \\2 /p' \\\n \t\t-e 's/^pick \\([0-9a-f]*\\) \\(fixup\\)! /\\1 \\2 /p' \\\n@@ -658,6 +658,12 @@ rearrange_squash () {\n \t\t\t\tused=\"$used$squash \"\n \t\t\t\t;;\n \t\t\tesac\n+\t\t\tcase \"$msg\" in\n+\t\t\t\"$sha1\"*)\n+\t\t\t\techo \"$action $squash $action! $msg\"\n+\t\t\t\tused=\"$used$squash \"\n+\t\t\t\t;;\n+\t\t\tesac\n \t\tdone <\"$1.sq\"\n \tdone >\"$1.rearranged\" <\"$1\"\n \tcat \"$1.rearranged\" >\"$1\"\ndiff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh\nindex b63f4e2..2f1a1b4 100755\n--- a/t/t3415-rebase-autosquash.sh\n+++ b/t/t3415-rebase-autosquash.sh\n@@ -38,6 +38,23 @@ test_expect_success 'auto fixup' '\n \ttest 1 = $(git cat-file commit HEAD^ | grep first | wc -l)\n '\n \n+test_expect_success 'auto fixup with hash' '\n+\tgit reset --hard base &&\n+\techo 1 >file1 &&\n+\tgit add -u &&\n+\ttest_tick &&\n+\tgit log -1 --pretty=\"fixup! %h\" HEAD^ | git commit -F -\n+\n+\tgit tag final-fixup-hash &&\n+\ttest_tick &&\n+\tgit rebase --autosquash -i HEAD^^^ &&\n+\tgit log --oneline >actual &&\n+\ttest 3 = $(wc -l <actual) &&\n+\tgit diff --exit-code final-fixup-hash &&\n+\ttest 1 = \"$(git cat-file blob HEAD^:file1)\" &&\n+\ttest 1 = $(git cat-file commit HEAD^ | grep first | wc -l)\n+'\n+\n test_expect_success 'auto squash' '\n \tgit reset --hard base &&\n \techo 1 >file1 &&\n-- \n1.7.1\n"},{"id":"143864","messageId":"AANLkTikJtNXg7Eac5CQkMBXt14tu8G7Kaxy-3t1wmhBF@mail.gmail.com","threadId":"24138","inReplyTo":"20100617125746.E86B42FC00@perkele","subject":"Re: [PATCH] Allow hashes in git rebase --interactive --autosquash.","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-06-17T13:17:47Z","receivedAt":"2010-06-17T13:17:47Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Jun 17, 2010 at 8:55 AM, Peter Krefting <peter@softwolves.pp.se> wrote:\n> In addition to matching the \"fixup!\" and \"squash!\" commits to the commit\n> message, also match the commit hash. This allows a commit message like\n> \"fixup! e83c5163316f89bfbde7d9ab23ca2e25604af290\" to be detected as a\n> fixup commit.\n>\n> Signed-off-by: Peter Krefting <peter@softwolves.pp.se>\n> ---\n>\n> I actually misread the git-rebase manual page to think that this was how\n> \"fixup!\" and \"squash!\" was supposed to be used, and now I have so many\n> \"fixup! <hash>\" commits to rebase that I felt it worth it to implement\n> support for it... :-)\n\nHeh. I have this alias for creating my fixup commits:\n\n$ git help fixup\n`git fixup' is aliased to `!f() { git commit -m \"$(git show -s\n--pretty='format:fixup! %s%n%nFixup for %h%n' \"$@\")\"; }; f'\n\n:-)\n\nj.\n"}]}