{"thread":{"id":"19356","subject":"[PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh","startedAt":"2009-05-15T00:12:12Z","lastAt":"2009-05-15T00:12:12Z","messageCount":1,"participants":["Johan Herland"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"113977","messageId":"200905150212.12979.johan@herland.net","threadId":"19356","inReplyTo":null,"subject":"[PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2009-05-15T00:12:12Z","receivedAt":"2009-05-15T00:12:12Z","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\n\n\n"}]}