Skip to content

Commit cad6bbb

Browse files
committed
bin/check-warn.sh: use full git syntax
By using rev-parse on the old and the new commit we are guaranteeing that the value is a known commit and we are opening the syntax for things like HEAD~4 and other fun things. Signed-off-by: Randolph Sapp <[email protected]>
1 parent 57594ad commit cad6bbb

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

bin/check-warn.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ generate_log()
8383
grep "WARNING:" "${log_path}" > "${warning_log_path}"
8484
}
8585

86+
rev-parse()
87+
{
88+
local rev
89+
if ! rev=$(git rev-parse "$1"); then
90+
printf '%s\n' 'Unable to parse given revisions:'
91+
printf ' %s\n' "$1"
92+
exit 2
93+
fi
94+
echo "$rev"
95+
}
96+
8697
main()
8798
{
8899
if [[ "$(head -1 Makefile 2> /dev/null)" != "# Makefile for Sphinx"* ]]
@@ -98,23 +109,11 @@ main()
98109
exit 4
99110
fi
100111

101-
# do nothing if target ${_new} doesn't exist,
102-
# don't wait for it fails after ${_old} was built
103-
if ! git cat-file -t "${_new}" > /dev/null 2>&1; then
104-
echo "${_new} not found"
105-
exit 5
106-
fi
107-
108-
# convert 'HEAD' to its commit ID
109-
if [ "$_new" = "HEAD" ]; then
110-
_new=$(git rev-parse HEAD)
111-
fi
112-
if [ "$_old" = "HEAD" ]; then
113-
_old=$(git rev-parse HEAD)
114-
fi
115-
116112
save_branch
117113

114+
_old=$(rev-parse "${_old}")
115+
_new=$(rev-parse "${_new}")
116+
118117
generate_log "${_old}" "_a"
119118
generate_log "${_new}" "_b"
120119

@@ -136,7 +135,7 @@ done
136135
[ -n "$_dev" ] || usage 1
137136
[ -n "$_os" ] || _os=linux
138137

139-
if [ -z "$_old" ] || [ -z "$_new" ]; then
138+
if [ -z "${_new}" ] || [ -z "${_old}" ]; then
140139
usage 2
141140
fi
142141

0 commit comments

Comments
 (0)