1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| | #!/bin/sh
awk -v origin_name="$1" '
@include ".git/hooks/commit-msg-files.awk"
# If the local SHA is all zeroes, ignore it.
$2 ~ /^0{40}$/ {
next
}
$2 ~ /^[a-z0-9]{40}$/ {
newref = $2
# If the remote SHA is all zeroes, go backwards until we find a SHA on
# an origin branch.
if ($4 ~ /^0{40}$/) {
back = 0
while ((("git branch -r -l '\''" origin_name "/*'\'' --contains " \
newref "~" back) | getline) == 0) {
back++
}
("git rev-parse " newref "~" back) | getline oldref
if (!(oldref ~ /^[a-z0-9]{40}$/)) {
# The SHA is misformatted?!
exit 2
}
} else if ($4 ~ /^[a-z0-9]{40}$/) {
oldref = $4
} else {
# The remote SHA is misformatted?!
exit 2
}
# Iterate over every SHA after oldref, up to (and including) newref.
while ((("git rev-list --reverse " oldref ".." newref) | getline) > 0) {
if (! check_commit_msg_files($0)) {
status = 1
}
}
}
END {
if (status != 0) {
print "Push aborted; please see the file '\''CONTRIBUTE'\''"
}
exit status
}
'
|