From: Johan Herland <johan@herland.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh
Date: Fri, 15 May 2009 02:12:12 +0200 [thread overview]
Message-ID: <200905150212.12979.johan@herland.net> (raw)
The following changes are made:
- Rename $MESSAGE to $MSG_FILE which better describes its purpose
- Make sure not only $MSG_FILE is removed upopn completion, but also
$GIT_INDEX_FILE
- Remove stray "GIT_NOTES_REF=" in front of "git log ..." command
Signed-off-by: Johan Herland <johan@herland.net>
---
git-notes.sh | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/git-notes.sh b/git-notes.sh
index 6ec33c9..7c3b8b9 100755
--- a/git-notes.sh
+++ b/git-notes.sh
@@ -20,15 +20,16 @@ edit)
die "Refusing to edit notes in $GIT_NOTES_REF (outside of refs/notes/)"
fi
- MESSAGE="$GIT_DIR"/new-notes-$COMMIT
+ MSG_FILE="$GIT_DIR/new-notes-$COMMIT"
+ GIT_INDEX_FILE="MSG_FILE.idx"
+ export GIT_INDEX_FILE
+
trap '
- test -f "$MESSAGE" && rm "$MESSAGE"
+ test -f "$MSG_FILE" && rm "$MSG_FILE"
+ test -f "$GIT_INDEX_FILE" && rm "$GIT_INDEX_FILE"
' 0
- GIT_NOTES_REF= git log -1 $COMMIT | sed "s/^/#/" > "$MESSAGE"
-
- GIT_INDEX_FILE="$MESSAGE".idx
- export GIT_INDEX_FILE
+ git log -1 $COMMIT | sed "s/^/#/" > "$MSG_FILE"
CURRENT_HEAD=$(git show-ref "$GIT_NOTES_REF" | cut -f 1 -d ' ')
if [ -z "$CURRENT_HEAD" ]; then
@@ -36,16 +37,16 @@ edit)
else
PARENT="-p $CURRENT_HEAD"
git read-tree "$GIT_NOTES_REF" || die "Could not read index"
- git cat-file blob :$COMMIT >> "$MESSAGE" 2> /dev/null
+ git cat-file blob :$COMMIT >> "$MSG_FILE" 2> /dev/null
fi
core_editor="$(git config core.editor)"
- ${GIT_EDITOR:-${core_editor:-${VISUAL:-${EDITOR:-vi}}}} "$MESSAGE"
+ ${GIT_EDITOR:-${core_editor:-${VISUAL:-${EDITOR:-vi}}}} "$MSG_FILE"
- grep -v ^# < "$MESSAGE" | git stripspace > "$MESSAGE".processed
- mv "$MESSAGE".processed "$MESSAGE"
- if [ -s "$MESSAGE" ]; then
- BLOB=$(git hash-object -w "$MESSAGE") ||
+ grep -v ^# < "$MSG_FILE" | git stripspace > "$MSG_FILE".processed
+ mv "$MSG_FILE".processed "$MSG_FILE"
+ if [ -s "$MSG_FILE" ]; then
+ BLOB=$(git hash-object -w "$MSG_FILE") ||
die "Could not write into object database"
git update-index --add --cacheinfo 0644 $BLOB $COMMIT ||
die "Could not write index"
--
1.6.3.rc0.1.gf800
next reply other threads:[~2009-05-15 0:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-15 0:12 Johan Herland [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-04-21 0:39 [PATCH 0/2] Add "-m" and "-F" options to "git notes edit" Johan Herland
2009-04-21 0:41 ` [PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh Johan Herland
2009-04-21 0:49 ` Johannes Schindelin
2009-04-21 0:51 ` Johan Herland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200905150212.12979.johan@herland.net \
--to=johan@herland.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.