{"thread":{"id":"18979","subject":"[PATCH 0/2] Add \"-m\" and \"-F\" options to \"git notes edit\"","startedAt":"2009-04-21T00:39:21Z","lastAt":"2009-04-21T01:26:22Z","messageCount":8,"participants":["Johan Herland","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"111798","messageId":"200904210239.21974.johan@herland.net","threadId":"18979","inReplyTo":null,"subject":"[PATCH 0/2] Add \"-m\" and \"-F\" options to \"git notes edit\"","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2009-04-21T00:39:21Z","receivedAt":"2009-04-21T00:39:21Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Hi,\n\nThe following 2-patch series teaches \"git notes edit\" to support the\n\"-m <msg>\" and \"-F <file>\" options (inspired by git-tag and git-commit).\n\nThe first patch does some minor bugfixes and cleanups in preparation for\nthe second patch, which adds the options with associated documentation\nand selftests.\n\nThis series is based on top of the \"js/notes\" topic in a recent \"pu\".\n\nJohan Herland (2):\n  Minor cleanup and bugfixing in git-notes.sh\n  Teach \"-m <msg>\" and \"-F <file>\" to \"git notes edit\"\n\n Documentation/git-notes.txt |   12 +++++++-\n git-notes.sh                |   71 ++++++++++++++++++++++++++++++++----------\n t/t3301-notes.sh            |   57 ++++++++++++++++++++++++++++++++++\n 3 files changed, 122 insertions(+), 18 deletions(-)\n\n\nHave fun! :)\n\n...Johan\n"},{"id":"111800","messageId":"200904210241.10073.johan@herland.net","threadId":"18979","inReplyTo":"200904210239.21974.johan@herland.net","subject":"[PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2009-04-21T00:41:09Z","receivedAt":"2009-04-21T00:41:09Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"The following changes are made:\n- Rename $MESSAGE to $MSG_FILE which better describes its purpose\n- Make sure not only $MSG_FILE is removed upopn completion, but also\n  $GIT_INDEX_FILE\n- Remove stray \"GIT_NOTES_REF=\" in front of \"git log ...\" command\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n git-notes.sh |   25 +++++++++++++------------\n 1 files changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/git-notes.sh b/git-notes.sh\nindex 6ec33c9..7c3b8b9 100755\n--- a/git-notes.sh\n+++ b/git-notes.sh\n@@ -20,15 +20,16 @@ edit)\n \t\tdie \"Refusing to edit notes in $GIT_NOTES_REF (outside of refs/notes/)\"\n \tfi\n \n-\tMESSAGE=\"$GIT_DIR\"/new-notes-$COMMIT\n+\tMSG_FILE=\"$GIT_DIR/new-notes-$COMMIT\"\n+\tGIT_INDEX_FILE=\"MSG_FILE.idx\"\n+\texport GIT_INDEX_FILE\n+\n \ttrap '\n-\t\ttest -f \"$MESSAGE\" && rm \"$MESSAGE\"\n+\t\ttest -f \"$MSG_FILE\" && rm \"$MSG_FILE\"\n+\t\ttest -f \"$GIT_INDEX_FILE\" && rm \"$GIT_INDEX_FILE\"\n \t' 0\n \n-\tGIT_NOTES_REF= git log -1 $COMMIT | sed \"s/^/#/\" > \"$MESSAGE\"\n-\n-\tGIT_INDEX_FILE=\"$MESSAGE\".idx\n-\texport GIT_INDEX_FILE\n+\tgit log -1 $COMMIT | sed \"s/^/#/\" > \"$MSG_FILE\"\n \n \tCURRENT_HEAD=$(git show-ref \"$GIT_NOTES_REF\" | cut -f 1 -d ' ')\n \tif [ -z \"$CURRENT_HEAD\" ]; then\n@@ -36,16 +37,16 @@ edit)\n \telse\n \t\tPARENT=\"-p $CURRENT_HEAD\"\n \t\tgit read-tree \"$GIT_NOTES_REF\" || die \"Could not read index\"\n-\t\tgit cat-file blob :$COMMIT >> \"$MESSAGE\" 2> /dev/null\n+\t\tgit cat-file blob :$COMMIT >> \"$MSG_FILE\" 2> /dev/null\n \tfi\n \n \tcore_editor=\"$(git config core.editor)\"\n-\t${GIT_EDITOR:-${core_editor:-${VISUAL:-${EDITOR:-vi}}}} \"$MESSAGE\"\n+\t${GIT_EDITOR:-${core_editor:-${VISUAL:-${EDITOR:-vi}}}} \"$MSG_FILE\"\n \n-\tgrep -v ^# < \"$MESSAGE\" | git stripspace > \"$MESSAGE\".processed\n-\tmv \"$MESSAGE\".processed \"$MESSAGE\"\n-\tif [ -s \"$MESSAGE\" ]; then\n-\t\tBLOB=$(git hash-object -w \"$MESSAGE\") ||\n+\tgrep -v ^# < \"$MSG_FILE\" | git stripspace > \"$MSG_FILE\".processed\n+\tmv \"$MSG_FILE\".processed \"$MSG_FILE\"\n+\tif [ -s \"$MSG_FILE\" ]; then\n+\t\tBLOB=$(git hash-object -w \"$MSG_FILE\") ||\n \t\t\tdie \"Could not write into object database\"\n \t\tgit update-index --add --cacheinfo 0644 $BLOB $COMMIT ||\n \t\t\tdie \"Could not write index\"\n-- \n1.6.3.rc0.1.gf800\n"},{"id":"111801","messageId":"200904210242.16050.johan@herland.net","threadId":"18979","inReplyTo":"200904210239.21974.johan@herland.net","subject":"[PATCH 2/2] Teach \"-m <msg>\" and \"-F <file>\" to \"git notes edit\"","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2009-04-21T00:42:15Z","receivedAt":"2009-04-21T00:42:15Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"The \"-m\" and \"-F\" options are already the established method\n(in both git-commit and git-tag) to specify a commit/tag message\nwithout invoking the editor. This patch teaches \"git notes edit\"\nto respect the same options for specifying a notes message without\ninvoking the editor.\n\nThe patch also updates the \"git notes\" documentation and adds a\ncouple of selftests for the new functionality.\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n Documentation/git-notes.txt |   12 ++++++++-\n git-notes.sh                |   52 +++++++++++++++++++++++++++++++++------\n t/t3301-notes.sh            |   57 +++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 112 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt\nindex 7136016..55de7c0 100644\n--- a/Documentation/git-notes.txt\n+++ b/Documentation/git-notes.txt\n@@ -8,7 +8,7 @@ git-notes - Add/inspect commit notes\n SYNOPSIS\n --------\n [verse]\n-'git-notes' (edit | show) [commit]\n+'git-notes' (edit [-F <file> | -m <msg>] | show) [commit]\n \n DESCRIPTION\n -----------\n@@ -33,6 +33,16 @@ show::\n \tShow the notes for a given commit (defaults to HEAD).\n \n \n+OPTIONS\n+-------\n+-m <msg>::\n+\tUse the given note message (instead of prompting).\n+\n+-F <file>::\n+\tTake the note message from the given file.  Use '-' to\n+\tread the note message from the standard input.\n+\n+\n Author\n ------\n Written by Johannes Schindelin <johannes.schindelin@gmx.de>\ndiff --git a/git-notes.sh b/git-notes.sh\nindex 7c3b8b9..3911caa 100755\n--- a/git-notes.sh\n+++ b/git-notes.sh\n@@ -1,16 +1,47 @@\n #!/bin/sh\n \n-USAGE=\"(edit | show) [commit]\"\n+USAGE=\"(edit [-F <file> | -m <msg>] | show) [commit]\"\n . git-sh-setup\n \n-test -n \"$3\" && usage\n-\n test -z \"$1\" && usage\n ACTION=\"$1\"; shift\n \n test -z \"$GIT_NOTES_REF\" && GIT_NOTES_REF=\"$(git config core.notesref)\"\n test -z \"$GIT_NOTES_REF\" && GIT_NOTES_REF=\"refs/notes/commits\"\n \n+MESSAGE=\n+while test $# != 0\n+do\n+\tcase \"$1\" in\n+\t-m)\n+\t\ttest \"$ACTION\" = \"edit\" || usage\n+\t\tshift\n+\t\tif test \"$#\" = \"0\"; then\n+\t\t\tdie \"error: option -m needs an argument\"\n+\t\telse\n+\t\t\tMESSAGE=\"$1\"\n+\t\t\tshift\n+\t\tfi\n+\t\t;;\n+\t-F)\n+\t\ttest \"$ACTION\" = \"edit\" || usage\n+\t\tshift\n+\t\tif test \"$#\" = \"0\"; then\n+\t\t\tdie \"error: option -F needs an argument\"\n+\t\telse\n+\t\t\tMESSAGE=\"$(cat \"$1\")\"\n+\t\t\tshift\n+\t\tfi\n+\t\t;;\n+\t-*)\n+\t\tusage\n+\t\t;;\n+\t*)\n+\t\tbreak\n+\t\t;;\n+\tesac\n+done\n+\n COMMIT=$(git rev-parse --verify --default HEAD \"$@\") ||\n die \"Invalid commit: $@\"\n \n@@ -29,19 +60,24 @@ edit)\n \t\ttest -f \"$GIT_INDEX_FILE\" && rm \"$GIT_INDEX_FILE\"\n \t' 0\n \n-\tgit log -1 $COMMIT | sed \"s/^/#/\" > \"$MSG_FILE\"\n-\n \tCURRENT_HEAD=$(git show-ref \"$GIT_NOTES_REF\" | cut -f 1 -d ' ')\n \tif [ -z \"$CURRENT_HEAD\" ]; then\n \t\tPARENT=\n \telse\n \t\tPARENT=\"-p $CURRENT_HEAD\"\n \t\tgit read-tree \"$GIT_NOTES_REF\" || die \"Could not read index\"\n-\t\tgit cat-file blob :$COMMIT >> \"$MSG_FILE\" 2> /dev/null\n \tfi\n \n-\tcore_editor=\"$(git config core.editor)\"\n-\t${GIT_EDITOR:-${core_editor:-${VISUAL:-${EDITOR:-vi}}}} \"$MSG_FILE\"\n+\tif [ -n \"$MESSAGE\" ]; then\n+\t\techo \"$MESSAGE\" > \"$MSG_FILE\"\n+\telse\n+\t\tgit log -1 $COMMIT | sed \"s/^/#/\" > \"$MSG_FILE\"\n+\t\tif [ -n \"$CURRENT_HEAD\" ]; then\n+\t\t\tgit cat-file blob :$COMMIT >> \"$MSG_FILE\" 2> /dev/null\n+\t\tfi\n+\t\tcore_editor=\"$(git config core.editor)\"\n+\t\t${GIT_EDITOR:-${core_editor:-${VISUAL:-${EDITOR:-vi}}}} \"$MSG_FILE\"\n+\tfi\n \n \tgrep -v ^# < \"$MSG_FILE\" | git stripspace > \"$MSG_FILE\".processed\n \tmv \"$MSG_FILE\".processed \"$MSG_FILE\"\ndiff --git a/t/t3301-notes.sh b/t/t3301-notes.sh\nindex 73e53be..2ece75e 100755\n--- a/t/t3301-notes.sh\n+++ b/t/t3301-notes.sh\n@@ -110,5 +110,62 @@ test_expect_success 'show multi-line notes' '\n \tgit log -2 > output &&\n \ttest_cmp expect-multiline output\n '\n+test_expect_success 'create -m notes (setup)' '\n+\t: > a4 &&\n+\tgit add a4 &&\n+\ttest_tick &&\n+\tgit commit -m 4th &&\n+\tgit notes edit -m \"foo\n+bar\n+baz\"\n+'\n+\n+cat > expect-m << EOF\n+commit 15023535574ded8b1a89052b32673f84cf9582b8\n+Author: A U Thor <author@example.com>\n+Date:   Thu Apr 7 15:16:13 2005 -0700\n+\n+    4th\n+\n+Notes:\n+    foo\n+    bar\n+    baz\n+EOF\n+\n+printf \"\\n\" >> expect-m\n+cat expect-multiline >> expect-m\n+\n+test_expect_success 'show -m notes' '\n+\tgit log -3 > output &&\n+\ttest_cmp expect-m output\n+'\n+test_expect_success 'create -F notes (setup)' '\n+\t: > a5 &&\n+\tgit add a5 &&\n+\ttest_tick &&\n+\tgit commit -m 5th &&\n+\techo \"xyzzy\" > note5 &&\n+\tgit notes edit -F note5\n+'\n+\n+cat > expect-F << EOF\n+commit bd1753200303d0a0344be813e504253b3d98e74d\n+Author: A U Thor <author@example.com>\n+Date:   Thu Apr 7 15:17:13 2005 -0700\n+\n+    5th\n+\n+Notes:\n+    xyzzy\n+EOF\n+\n+printf \"\\n\" >> expect-F\n+cat expect-m >> expect-F\n+\n+test_expect_success 'show -F notes' '\n+\tgit log -4 > output &&\n+\ttest_cmp expect-F output\n+'\n \n test_done\n-- \n1.6.3.rc0.1.gf800\n"},{"id":"111802","messageId":"alpine.DEB.1.00.0904210248160.10279@pacific.mpi-cbg.de","threadId":"18979","inReplyTo":"200904210239.21974.johan@herland.net","subject":"Re: [PATCH 0/2] Add \"-m\" and \"-F\" options to \"git notes edit\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-21T00:48:34Z","receivedAt":"2009-04-21T00:48:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 21 Apr 2009, Johan Herland wrote:\n\n> The following 2-patch series teaches \"git notes edit\" to support the\n> \"-m <msg>\" and \"-F <file>\" options (inspired by git-tag and git-commit).\n\nGood idea!\n\nCiao,\nDscho\n"},{"id":"111803","messageId":"alpine.DEB.1.00.0904210248560.10279@pacific.mpi-cbg.de","threadId":"18979","inReplyTo":"200904210241.10073.johan@herland.net","subject":"Re: [PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-21T00:49:26Z","receivedAt":"2009-04-21T00:49:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 21 Apr 2009, Johan Herland wrote:\n\n> The following changes are made:\n> - Rename $MESSAGE to $MSG_FILE which better describes its purpose\n> - Make sure not only $MSG_FILE is removed upopn completion, but also\n>   $GIT_INDEX_FILE\n> - Remove stray \"GIT_NOTES_REF=\" in front of \"git log ...\" command\n\nValid points.  Mind if I squash this into the commit adding git-notes.sh?\n\nCiao,\nDscho\n"},{"id":"111804","messageId":"200904210251.34945.johan@herland.net","threadId":"18979","inReplyTo":"alpine.DEB.1.00.0904210248560.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2009-04-21T00:51:34Z","receivedAt":"2009-04-21T00:51:34Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Tuesday 21 April 2009, Johannes Schindelin wrote:\n> On Tue, 21 Apr 2009, Johan Herland wrote:\n> > The following changes are made:\n> > - Rename $MESSAGE to $MSG_FILE which better describes its purpose\n> > - Make sure not only $MSG_FILE is removed upopn completion, but also\n> >   $GIT_INDEX_FILE\n> > - Remove stray \"GIT_NOTES_REF=\" in front of \"git log ...\" command\n>\n> Valid points.  Mind if I squash this into the commit adding git-notes.sh?\n\nNo problem\n\n\nHave fun! :)\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"111805","messageId":"alpine.DEB.1.00.0904210251220.10279@pacific.mpi-cbg.de","threadId":"18979","inReplyTo":"200904210242.16050.johan@herland.net","subject":"Re: [PATCH 2/2] Teach \"-m <msg>\" and \"-F <file>\" to \"git notes edit\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-04-21T00:53:30Z","receivedAt":"2009-04-21T00:53:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 21 Apr 2009, Johan Herland wrote:\n\n> The \"-m\" and \"-F\" options are already the established method\n> (in both git-commit and git-tag) to specify a commit/tag message\n> without invoking the editor. This patch teaches \"git notes edit\"\n> to respect the same options for specifying a notes message without\n> invoking the editor.\n> \n> The patch also updates the \"git notes\" documentation and adds a\n> couple of selftests for the new functionality.\n> \n> Signed-off-by: Johan Herland <johan@herland.net>\n> ---\n\nNice!\n\n> +MESSAGE=\n> +while test $# != 0\n> +do\n> +\tcase \"$1\" in\n> +\t-m)\n> +\t\ttest \"$ACTION\" = \"edit\" || usage\n> +\t\tshift\n> +\t\tif test \"$#\" = \"0\"; then\n> +\t\t\tdie \"error: option -m needs an argument\"\n> +\t\telse\n> +\t\t\tMESSAGE=\"$1\"\n> +\t\t\tshift\n> +\t\tfi\n> +\t\t;;\n> +\t-F)\n> +\t\ttest \"$ACTION\" = \"edit\" || usage\n> +\t\tshift\n> +\t\tif test \"$#\" = \"0\"; then\n> +\t\t\tdie \"error: option -F needs an argument\"\n> +\t\telse\n> +\t\t\tMESSAGE=\"$(cat \"$1\")\"\n> +\t\t\tshift\n> +\t\tfi\n> +\t\t;;\n> +\t-*)\n> +\t\tusage\n> +\t\t;;\n> +\t*)\n> +\t\tbreak\n> +\t\t;;\n> +\tesac\n> +done\n\nWell, either you forbid multiple -F/-m options, or you merge the messages, \nright?  AFAIR 'git commit -m A -m B' combines 'A' and 'B'...\n\n> +\tif [ -n \"$MESSAGE\" ]; then\n\nHere's a chance for me to learn: I was under the impression that \"! -z\" is \nmore portable than \"-n\".  Am I completely off the track?\n\nCiao,\nDscho\n"},{"id":"111819","messageId":"200904210326.22864.johan@herland.net","threadId":"18979","inReplyTo":"alpine.DEB.1.00.0904210251220.10279@pacific.mpi-cbg.de","subject":"[PATCH v2 2/2] Teach \"-m <msg>\" and \"-F <file>\" to \"git notes edit\"","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2009-04-21T01:26:22Z","receivedAt":"2009-04-21T01:26:22Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"The \"-m\" and \"-F\" options are already the established method\n(in both git-commit and git-tag) to specify a commit/tag message\nwithout invoking the editor. This patch teaches \"git notes edit\"\nto respect the same options for specifying a notes message without\ninvoking the editor.\n\nMultiple \"-m\" and/or \"-F\" options are concatenated as separate\nparagraphs.\n\nThe patch also updates the \"git notes\" documentation and adds\nselftests for the new functionality.\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n\nOn Tuesday 21 April 2009, Johannes Schindelin wrote:\n> Well, either you forbid multiple -F/-m options, or you merge the\n> messages, right?  AFAIR 'git commit -m A -m B' combines 'A' and 'B'...\n\nHere's a second version that merges the messages.\n\n> > +\tif [ -n \"$MESSAGE\" ]; then\n> Here's a chance for me to learn: I was under the impression that \"! -z\"\n> is more portable than \"-n\".  Am I completely off the track?\n\nNo, I haven't checked this at all, so you're probably right. This second\nversion of the patch does not use \"-n\".\n\nNote that I changed the selftest to test the -m/-F merge behaviour.\nThis causes the expected output to have a couple of lines with 4 trailing\nspaces. I know that trailing spaces is frowned upon on this list, but I'm\nhoping these'll make it through, as the test needs them...\n\n\nHave fun! :)\n\n...Johan\n\n Documentation/git-notes.txt |   16 ++++++++++-\n git-notes.sh                |   64 +++++++++++++++++++++++++++++++++++++-----\n t/t3301-notes.sh            |   35 +++++++++++++++++++++++\n 3 files changed, 106 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt\nindex 7136016..94cceb1 100644\n--- a/Documentation/git-notes.txt\n+++ b/Documentation/git-notes.txt\n@@ -8,7 +8,7 @@ git-notes - Add/inspect commit notes\n SYNOPSIS\n --------\n [verse]\n-'git-notes' (edit | show) [commit]\n+'git-notes' (edit [-F <file> | -m <msg>] | show) [commit]\n \n DESCRIPTION\n -----------\n@@ -33,6 +33,20 @@ show::\n \tShow the notes for a given commit (defaults to HEAD).\n \n \n+OPTIONS\n+-------\n+-m <msg>::\n+\tUse the given note message (instead of prompting).\n+\tIf multiple `-m` (or `-F`) options are given, their\n+\tvalues are concatenated as separate paragraphs.\n+\n+-F <file>::\n+\tTake the note message from the given file.  Use '-' to\n+\tread the note message from the standard input.\n+\tIf multiple `-F` (or `-m`) options are given, their\n+\tvalues are concatenated as separate paragraphs.\n+\n+\n Author\n ------\n Written by Johannes Schindelin <johannes.schindelin@gmx.de>\ndiff --git a/git-notes.sh b/git-notes.sh\nindex 7c3b8b9..5ff82f2 100755\n--- a/git-notes.sh\n+++ b/git-notes.sh\n@@ -1,16 +1,59 @@\n #!/bin/sh\n \n-USAGE=\"(edit | show) [commit]\"\n+USAGE=\"(edit [-F <file> | -m <msg>] | show) [commit]\"\n . git-sh-setup\n \n-test -n \"$3\" && usage\n-\n test -z \"$1\" && usage\n ACTION=\"$1\"; shift\n \n test -z \"$GIT_NOTES_REF\" && GIT_NOTES_REF=\"$(git config core.notesref)\"\n test -z \"$GIT_NOTES_REF\" && GIT_NOTES_REF=\"refs/notes/commits\"\n \n+MESSAGE=\n+while test $# != 0\n+do\n+\tcase \"$1\" in\n+\t-m)\n+\t\ttest \"$ACTION\" = \"edit\" || usage\n+\t\tshift\n+\t\tif test \"$#\" = \"0\"; then\n+\t\t\tdie \"error: option -m needs an argument\"\n+\t\telse\n+\t\t\tif [ -z \"$MESSAGE\" ]; then\n+\t\t\t\tMESSAGE=\"$1\"\n+\t\t\telse\n+\t\t\t\tMESSAGE=\"$MESSAGE\n+\n+$1\"\n+\t\t\tfi\n+\t\t\tshift\n+\t\tfi\n+\t\t;;\n+\t-F)\n+\t\ttest \"$ACTION\" = \"edit\" || usage\n+\t\tshift\n+\t\tif test \"$#\" = \"0\"; then\n+\t\t\tdie \"error: option -F needs an argument\"\n+\t\telse\n+\t\t\tif [ -z \"$MESSAGE\" ]; then\n+\t\t\t\tMESSAGE=\"$(cat \"$1\")\"\n+\t\t\telse\n+\t\t\t\tMESSAGE=\"$MESSAGE\n+\n+$(cat \"$1\")\"\n+\t\t\tfi\n+\t\t\tshift\n+\t\tfi\n+\t\t;;\n+\t-*)\n+\t\tusage\n+\t\t;;\n+\t*)\n+\t\tbreak\n+\t\t;;\n+\tesac\n+done\n+\n COMMIT=$(git rev-parse --verify --default HEAD \"$@\") ||\n die \"Invalid commit: $@\"\n \n@@ -29,19 +72,24 @@ edit)\n \t\ttest -f \"$GIT_INDEX_FILE\" && rm \"$GIT_INDEX_FILE\"\n \t' 0\n \n-\tgit log -1 $COMMIT | sed \"s/^/#/\" > \"$MSG_FILE\"\n-\n \tCURRENT_HEAD=$(git show-ref \"$GIT_NOTES_REF\" | cut -f 1 -d ' ')\n \tif [ -z \"$CURRENT_HEAD\" ]; then\n \t\tPARENT=\n \telse\n \t\tPARENT=\"-p $CURRENT_HEAD\"\n \t\tgit read-tree \"$GIT_NOTES_REF\" || die \"Could not read index\"\n-\t\tgit cat-file blob :$COMMIT >> \"$MSG_FILE\" 2> /dev/null\n \tfi\n \n-\tcore_editor=\"$(git config core.editor)\"\n-\t${GIT_EDITOR:-${core_editor:-${VISUAL:-${EDITOR:-vi}}}} \"$MSG_FILE\"\n+\tif [ -z \"$MESSAGE\" ]; then\n+\t\tgit log -1 $COMMIT | sed \"s/^/#/\" > \"$MSG_FILE\"\n+\t\tif [ ! -z \"$CURRENT_HEAD\" ]; then\n+\t\t\tgit cat-file blob :$COMMIT >> \"$MSG_FILE\" 2> /dev/null\n+\t\tfi\n+\t\tcore_editor=\"$(git config core.editor)\"\n+\t\t${GIT_EDITOR:-${core_editor:-${VISUAL:-${EDITOR:-vi}}}} \"$MSG_FILE\"\n+\telse\n+\t\techo \"$MESSAGE\" > \"$MSG_FILE\"\n+\tfi\n \n \tgrep -v ^# < \"$MSG_FILE\" | git stripspace > \"$MSG_FILE\".processed\n \tmv \"$MSG_FILE\".processed \"$MSG_FILE\"\ndiff --git a/t/t3301-notes.sh b/t/t3301-notes.sh\nindex 73e53be..9eaa338 100755\n--- a/t/t3301-notes.sh\n+++ b/t/t3301-notes.sh\n@@ -110,5 +110,40 @@ test_expect_success 'show multi-line notes' '\n \tgit log -2 > output &&\n \ttest_cmp expect-multiline output\n '\n+test_expect_success 'create -m and -F notes (setup)' '\n+\t: > a4 &&\n+\tgit add a4 &&\n+\ttest_tick &&\n+\tgit commit -m 4th &&\n+\techo \"xyzzy\" > note5 &&\n+\tgit notes edit -m spam -F note5 -m \"foo\n+bar\n+baz\"\n+'\n+\n+cat > expect-m-and-F << EOF\n+commit 15023535574ded8b1a89052b32673f84cf9582b8\n+Author: A U Thor <author@example.com>\n+Date:   Thu Apr 7 15:16:13 2005 -0700\n+\n+    4th\n+\n+Notes:\n+    spam\n+    \n+    xyzzy\n+    \n+    foo\n+    bar\n+    baz\n+EOF\n+\n+printf \"\\n\" >> expect-m-and-F\n+cat expect-multiline >> expect-m-and-F\n+\n+test_expect_success 'show -m and -F notes' '\n+\tgit log -3 > output &&\n+\ttest_cmp expect-m-and-F output\n+'\n \n test_done\n-- \n1.6.3.rc0.1.gf800\n"}]}