git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh

From
Johan Herland <johan@herland.net>
Date
Apr 21, 2009, 00:41 UTC
Message-ID
<200904210241.10073.johan@herland.net>
In-Reply-To
<200904210239.21974.johan@herland.net>
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
Previous: Johan HerlandNext: Johannes Schindelin
Message 2 of 8 in “Add "-m" and "-F" options to "git notes edit"”
  1. 0/2 Add "-m" and "-F" options to "git notes edit"Johan Herland, Apr 21, 2009
  2. 1/2 Minor cleanup and bugfixing in git-notes.shJohan Herland, Apr 21, 2009
  3. Johannes SchindelinApr 21, 2009
  4. Johan HerlandApr 21, 2009
  5. 2/2 Teach "-m <msg>" and "-F <file>" to "git notes edit"Johan Herland, Apr 21, 2009
  6. Johannes SchindelinApr 21, 2009
  7. 2/2 Teach "-m <msg>" and "-F <file>" to "git notes edit"Johan Herland, Apr 21, 2009
  8. Johannes SchindelinApr 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.