diff --git a/resources/com/google/gerrit/server/commit-msg_test.sh b/resources/com/google/gerrit/server/commit-msg_test.sh index c016a8925b..d797be30fd 100755 --- a/resources/com/google/gerrit/server/commit-msg_test.sh +++ b/resources/com/google/gerrit/server/commit-msg_test.sh @@ -63,9 +63,9 @@ index 625fd613d9..03aeba3b21 100755 @@ -38,6 +38,7 @@ context line - + +hello, world - + context line EOF @@ -111,7 +111,7 @@ EOF } # Change-Id goes after existing trailers. -function test_at_start { +function test_at_end { cat << EOF > input bla bla @@ -119,16 +119,16 @@ Bug: #123 EOF ${hook} input || fail "failed hook execution" - result=$(git interpret-trailers --parse input | head -1 | grep ^Change-Id) + result=$(tail -1 input | grep ^Change-Id) if [[ -z "${result}" ]] ; then echo "after: " cat input - fail "did not find Change-Id at start" + fail "did not find Change-Id at end" fi } -function test_dash_at_start { +function test_dash_at_end { if [[ ! -x /bin/dash ]] ; then echo "/bin/dash not installed; skipping dash test." return @@ -142,12 +142,12 @@ EOF /bin/dash ${hook} input || fail "failed hook execution" - result=$(git interpret-trailers --parse input | head -1 | grep ^Change-Id) + result=$(tail -1 input | grep ^Change-Id) if [[ -z "${result}" ]] ; then echo "after: " cat input - fail "did not find Change-Id at start" + fail "did not find Change-Id at end" fi } diff --git a/resources/com/google/gerrit/server/tools/root/hooks/commit-msg b/resources/com/google/gerrit/server/tools/root/hooks/commit-msg index 42dbfb99bc..290123258b 100755 --- a/resources/com/google/gerrit/server/tools/root/hooks/commit-msg +++ b/resources/com/google/gerrit/server/tools/root/hooks/commit-msg @@ -48,7 +48,9 @@ if test ! -s "${dest}" ; then exit 1 fi -if ! git -c trailer.ifexists=doNothing interpret-trailers --where start \ +# Avoid the --in-place option which only appeared in Git 2.8 +# Avoid the --if-exists option which only appeared in Git 2.15 +if ! git -c trailer.ifexists=doNothing interpret-trailers \ --trailer "Change-Id: I${random}" < "$1" > "${dest}" ; then echo "cannot insert change-id line in $1" exit 1