]> git.ipfire.org Git - thirdparty/git.git/blame - post-applypatch
What's cooking (2023/08 #04)
[thirdparty/git.git] / post-applypatch
CommitLineData
0197e222
JH
1#!/bin/sh
2
3GIT_DIR=.git
4dotest="$GIT_DIR/rebase-apply"
5
6prec=4 &&
7this=$(cat 2>/dev/null "$dotest/next") &&
8msgnum=$(printf "%0${prec}d" $this) &&
9test -f "$dotest/$msgnum" &&
76adaf5a
JH
10message_id=$(sed -ne '
11 /^[ ]/{
24a23ec1 12 # Append continuation line to hold space
76adaf5a 13 H
24a23ec1 14 # Swap hold and pattern
76adaf5a 15 x
24a23ec1 16 # Remove the LF, making it a single line
76adaf5a 17 s/\n//
24a23ec1 18 # Swap hold and pattern back
76adaf5a 19 x
24a23ec1 20 # Discard the pattern and go on
76adaf5a
JH
21 n
22 }
23 # Hold this new line, and look at what is in the hold space
24 x
0c49ca33 25 # Is it the Message-ID line? If so, spit it out and finish.
76adaf5a
JH
26 /^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]:[ ]*/{
27 s///p
0197e222
JH
28 q
29 }
76adaf5a
JH
30 # Otherwise, check if this new line is empty
31 x
32 # Is it? Then we are done with the header
33 /^$/b end
34 # Otherwise we need to hold onto this header line
35 x
36 # And start the next cycle
37 b
38: end
0c49ca33
JH
39 # ??? do we want to check if we held onto the last message-id line
40 # and process it here if we did???
76adaf5a 41 q
0197e222
JH
42' "$dotest/$msgnum") &&
43
24a23ec1
JH
44if test -n "$message_id" &&
45 head=$(git rev-parse --verify HEAD 2>/dev/null)
46then
47 echo "$head $message_id" >>"$GIT_DIR"/am.log &&
0c49ca33
JH
48 (
49 GIT_NOTES_REF=refs/notes/amlog
50 export GIT_NOTES_REF
24a23ec1 51 git notes add -f -m "Message-Id: $message_id" "$head"
0c49ca33 52 )
24a23ec1 53fi