Meta/post-applypatch: use bidirectional notes mapping in amlog
Junio C Hamano committed
Sep 27, 2012 at 18:20 UTC
0c49ca33322de12633a0329008623c009da4e987
2 files changed
+24
-5
amlook
+15
-2
@@ -5,8 +5,19 @@
5
# Meta/amlook --gc
6
7
find_commit () {
8
- in=
9
- commits=$(sed -ne "s|^\([0-9a-f]\{40\}\) $1|\1|p" .git/am.log)
8
+ in= commits=
9
+
10
+ if test -z "$commits"
11
+ then
12
+ blob=$(echo "Message-Id: $1" | git hash-object --stdin)
13
+ commits=$(git notes --ref amlog show $blob | sed -e '/^$/d')
14
+ fi
15
+
16
+ if test -z "$commits"
17
+ then
18
+ commits=$(sed -ne "s|^\([0-9a-f]\{40\}\) $1|\1|p" .git/am.log)
19
+ fi
20
+
21
if test -z "$commits"
22
then
23
# I know I know there should be "notes grep" command...
@@ -15,11 +26,13 @@ find_commit () {
26
sed -e 's|^notes/amlog:||' -e 's|/||g'
27
)
28
fi
29
+
30
if test -z "$commits"
31
then
32
echo "Never applied"
33
return
34
fi
35
+
36
found=$(
37
echo "$commits" |
38
while read commit
post-applypatch
+9
-3
@@ -22,7 +22,7 @@ message_id=$(sed -ne '
22
}
23
# Hold this new line, and look at what is in the hold space
24
x
25
- # Is it the Message-ID line? If so, spit out and finish.
25
+ # Is it the Message-ID line? If so, spit it out and finish.
26
/^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]:[ ]*/{
27
s///p
28
q
@@ -36,6 +36,8 @@ message_id=$(sed -ne '
36
# And start the next cycle
37
b
38
: end
39
+ # ??? do we want to check if we held onto the last message-id line
40
+ # and process it here if we did???
41
q
42
' "$dotest/$msgnum") &&
43
@@ -43,7 +45,11 @@ if test -n "$message_id" &&
45
head=$(git rev-parse --verify HEAD 2>/dev/null)
46
then
47
echo "$head $message_id" >>"$GIT_DIR"/am.log &&
46
- GIT_NOTES_REF=refs/notes/amlog \
48
+ (
49
+ GIT_NOTES_REF=refs/notes/amlog
50
+ export GIT_NOTES_REF
51
git notes add -f -m "Message-Id: $message_id" "$head"
52
+ blob=$(git notes list "$head") &&
53
+ git notes append -m "$head" $blob
54
+ )
55
fi
49
-