From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johan Herland Subject: [PATCH 1/2] Minor cleanup and bugfixing in git-notes.sh Date: Tue, 21 Apr 2009 02:41:09 +0200 Message-ID: <200904210241.10073.johan@herland.net> References: <200904210239.21974.johan@herland.net> Mime-Version: 1.0 Content-Type: Text/Plain; charset=utf-8 Content-Transfer-Encoding: 7BIT Cc: git@vger.kernel.org, Johannes Schindelin To: Junio C Hamano X-From: git-owner@vger.kernel.org Tue Apr 21 02:42:50 2009 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lw44W-0002cu-SM for gcvg-git-2@gmane.org; Tue, 21 Apr 2009 02:42:49 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753497AbZDUAlN (ORCPT ); Mon, 20 Apr 2009 20:41:13 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753266AbZDUAlN (ORCPT ); Mon, 20 Apr 2009 20:41:13 -0400 Received: from mx.getmail.no ([84.208.15.66]:64621 "EHLO get-mta-out01.get.basefarm.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752690AbZDUAlN (ORCPT ); Mon, 20 Apr 2009 20:41:13 -0400 Content-disposition: inline Received: from mx.getmail.no ([10.5.16.4]) by get-mta-out01.get.basefarm.net (Sun Java(tm) System Messaging Server 7.0-0.04 64bit (built Jun 20 2008)) with ESMTP id <0KIF004CHDWNEWC0@get-mta-out01.get.basefarm.net> for git@vger.kernel.org; Tue, 21 Apr 2009 02:41:11 +0200 (MEST) Received: from alpha.localnet ([84.215.102.95]) by get-mta-in02.get.basefarm.net (Sun Java(tm) System Messaging Server 7.0-0.04 64bit (built Jun 20 2008)) with ESMTP id <0KIF00KZNDWME4C0@get-mta-in02.get.basefarm.net> for git@vger.kernel.org; Tue, 21 Apr 2009 02:41:11 +0200 (MEST) X-PMX-Version: 5.5.3.366731, Antispam-Engine: 2.7.0.366912, Antispam-Data: 2009.4.21.2822 User-Agent: KMail/1.11.2 (Linux/2.6.29-ARCH; KDE/4.2.2; x86_64; ; ) In-reply-to: <200904210239.21974.johan@herland.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 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 --- 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