{"thread":{"id":"24371","subject":"[PATCH 1/2] lib-rebase.sh: fake-editor.sh: Allow checking of commit header(s) in $GIT_EDITOR","startedAt":"2010-07-12T01:04:22Z","lastAt":"2010-07-12T01:04:23Z","messageCount":2,"participants":["Nazri Ramliy"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"145337","messageId":"1278896663-3922-1-git-send-email-ayiehere@gmail.com","threadId":"24371","inReplyTo":null,"subject":"[PATCH 1/2] lib-rebase.sh: fake-editor.sh: Allow checking of commit header(s) in $GIT_EDITOR","fromName":"Nazri Ramliy","fromEmail":"ayiehere@gmail.com","sentAt":"2010-07-12T01:04:22Z","receivedAt":"2010-07-12T01:04:22Z","isPatch":true,"sender":{"key":"ayiehere@gmail.com","avatar":"https://avatars.githubusercontent.com/u/164756?v=4"},"body":"Signed-off-by: Nazri Ramliy <ayiehere@gmail.com>\n---\n t/lib-rebase.sh |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/t/lib-rebase.sh b/t/lib-rebase.sh\nindex 6aefe27..5804d23 100644\n--- a/t/lib-rebase.sh\n+++ b/t/lib-rebase.sh\n@@ -4,6 +4,8 @@\n #\n # - override the commit message with $FAKE_COMMIT_MESSAGE\n # - amend the commit message with $FAKE_COMMIT_AMEND\n+# - check that commit header(s) in the editor matches that in the\n+#   file $EXPECT_HEADER.\n # - check that non-commit messages have a certain line count with $EXPECT_COUNT\n # - check the commit count in the commit message header with $EXPECT_HEADER_COUNT\n # - rewrite a rebase -i script as directed by $FAKE_LINES.\n@@ -34,6 +36,12 @@ case \"$1\" in\n \texit\n \t;;\n esac\n+test -z \"$EXPECT_HEADER\" ||\n+\t(\n+\t\tgrep '^pick' < \"$1\" | cut -d' ' -f3- > commit_headers.$$ &&\n+\t\tdiff \"$EXPECT_HEADER\" commit_headers.$$ > /dev/null\n+\t) ||\n+\texit\n test -z \"$EXPECT_COUNT\" ||\n \ttest \"$EXPECT_COUNT\" = $(sed -e '/^#/d' -e '/^$/d' < \"$1\" | wc -l) ||\n \texit\n-- \n1.7.2.rc2\n"},{"id":"145338","messageId":"1278896663-3922-2-git-send-email-ayiehere@gmail.com","threadId":"24371","inReplyTo":"1278896663-3922-1-git-send-email-ayiehere@gmail.com","subject":"[PATCH 2/2] rebase -i: Preserve whitespace at beginning of commit header in $GIT_EDITOR","fromName":"Nazri Ramliy","fromEmail":"ayiehere@gmail.com","sentAt":"2010-07-12T01:04:23Z","receivedAt":"2010-07-12T01:04:23Z","isPatch":true,"sender":{"key":"ayiehere@gmail.com","avatar":"https://avatars.githubusercontent.com/u/164756?v=4"},"body":"During \"git rebase -i\", when the commit headers are shown in the editor\nfor action (pick/squash/etc), the whitespace (if any) at the beginning\nof commit headers are stripped out due to the use of \"read shortsha1 rest\"\nfor reading the output of \"git rev-list\".\n\nThe missing beginning whitespace do not pose any harm but this could be\nannoying when you want to identify these commits to perform actions on,\nfor example, rewording them to remove the beginning whitespace.\n\nNot having the whitespace makes them hard to spot, and you have to rely\non something like \"git log --oneline\" to identify them.\n\nThis patch:\n\n\t1. Ensures that the commit header shown in $GIT_EDITOR is\n\t   identical to the actual commit header\n\t2. Add a test for it\n\nSigned-off-by: Nazri Ramliy <ayiehere@gmail.com>\n---\nThis series is based on maint.\n\nRunning all test shows no breakage. \n\n git-rebase--interactive.sh    |   17 ++++++++++-------\n t/t3404-rebase-interactive.sh |   12 ++++++++++++\n 2 files changed, 22 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 6b86abc..80991a8 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -683,6 +683,10 @@ parse_onto () {\n \tgit rev-parse --verify \"$1^0\"\n }\n \n+pick () {\n+\tgit log -1 --abbrev-commit --abbrev=7 --format=\"pick %h %s\" $sha1\n+}\n+\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -887,16 +891,15 @@ first and then run 'git rebase --continue' again.\"\n \t\t\tREVISIONS=$ONTO...$HEAD\n \t\t\tSHORTREVISIONS=$SHORTHEAD\n \t\tfi\n-\t\tgit rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n-\t\t\t--abbrev=7 --reverse --left-right --topo-order \\\n-\t\t\t$REVISIONS | \\\n-\t\t\tsed -n \"s/^>//p\" | while read shortsha1 rest\n+\n+\t\tgit rev-list $MERGES_OPTION --reverse --left-right \\\n+\t\t\t--topo-order $REVISIONS | sed -n \"s/^>//p\" |\n+\t\twhile read sha1\n \t\tdo\n \t\t\tif test t != \"$PRESERVE_MERGES\"\n \t\t\tthen\n-\t\t\t\techo \"pick $shortsha1 $rest\" >> \"$TODO\"\n+\t\t\t\tpick $sha1 >> \"$TODO\"\n \t\t\telse\n-\t\t\t\tsha1=$(git rev-parse $shortsha1)\n \t\t\t\tif test -z \"$REBASE_ROOT\"\n \t\t\t\tthen\n \t\t\t\t\tpreserve=t\n@@ -913,7 +916,7 @@ first and then run 'git rebase --continue' again.\"\n \t\t\t\tif test f = \"$preserve\"\n \t\t\t\tthen\n \t\t\t\t\ttouch \"$REWRITTEN\"/$sha1\n-\t\t\t\t\techo \"pick $shortsha1 $rest\" >> \"$TODO\"\n+\t\t\t\t\tpick $sha1 >> \"$TODO\"\n \t\t\t\tfi\n \t\t\tfi\n \t\tdone\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex ee9a1b2..e346174 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -630,4 +630,16 @@ test_expect_success 'always cherry-pick with --no-ff' '\n \ttest_cmp empty out\n '\n \n+cat >expect_header <<EOF\n+  Commit header with beginning whitespace\n+EOF\n+\n+test_expect_success 'preserve whitespace in commit summary' '\n+\tgit checkout -b preserve-whitespace master &&\n+\techo a >whitespace_test &&\n+\tgit add whitespace_test &&\n+\tgit commit -m\"  Commit header with beginning whitespace\" &&\n+\tEXPECT_HEADER=\"expect_header\" git rebase -i HEAD~1\n+'\n+\n test_done\n-- \n1.7.2.rc2\n"}]}