]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Meta/post-applypatch: use bidirectional notes mapping in amlog
authorJunio C Hamano <gitster@pobox.com>
Fri, 28 Sep 2012 01:20:39 +0000 (18:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Sep 2012 01:22:55 +0000 (18:22 -0700)
amlook
post-applypatch

diff --git a/amlook b/amlook
index 809386b97a549c6d3da21babc9d101e36e942bd2..0544f402eec1c6c52c31bdacb92f3ef10566caff 100755 (executable)
--- a/amlook
+++ b/amlook
@@ -5,8 +5,19 @@
 # Meta/amlook --gc
 
 find_commit () {
-       in=
-       commits=$(sed -ne "s|^\([0-9a-f]\{40\}\) $1|\1|p" .git/am.log)
+       in= commits=
+
+       if test -z "$commits"
+       then
+               blob=$(echo "Message-Id: $1" | git hash-object --stdin)
+               commits=$(git notes --ref amlog show $blob | sed -e '/^$/d')
+       fi
+
+       if test -z "$commits"
+       then
+               commits=$(sed -ne "s|^\([0-9a-f]\{40\}\) $1|\1|p" .git/am.log)
+       fi
+
        if test -z "$commits"
        then
                # I know I know there should be "notes grep" command...
@@ -15,11 +26,13 @@ find_commit () {
                        sed -e 's|^notes/amlog:||' -e 's|/||g'
                )
        fi
+
        if test -z "$commits"
        then
                echo "Never applied"
                return
        fi
+
        found=$(
                echo "$commits" |
                while read commit
index 1aa18f54e5d5bb3fe7011e0241f11d20bbb95043..886ad76d00d7377375ce710165d7ef14f13d3c7e 100755 (executable)
@@ -22,7 +22,7 @@ message_id=$(sed -ne '
        }
        # Hold this new line, and look at what is in the hold space
        x
-       # Is it the Message-ID line?  If so, spit out and finish.
+       # Is it the Message-ID line?  If so, spit it out and finish.
        /^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]:[       ]*/{
                s///p
                q
@@ -36,6 +36,8 @@ message_id=$(sed -ne '
        # And start the next cycle
        b
 : end
+       # ??? do we want to check if we held onto the last message-id line
+       # and process it here if we did???
        q
 ' "$dotest/$msgnum") &&
 
@@ -43,7 +45,11 @@ if   test -n "$message_id" &&
        head=$(git rev-parse --verify HEAD 2>/dev/null)
 then
        echo "$head $message_id" >>"$GIT_DIR"/am.log &&
-       GIT_NOTES_REF=refs/notes/amlog \
+       (
+               GIT_NOTES_REF=refs/notes/amlog
+               export GIT_NOTES_REF
                git notes add -f -m "Message-Id: $message_id" "$head"
+               blob=$(git notes list "$head") &&
+               git notes append -m "$head" $blob
+       )
 fi
-