commit 1bf71407c6c1017115d398ac2bdd5feae6a0f988 Author: Egeyar Bagcioglu Date: Mon Apr 5 15:25:15 2021 +0200 The pre-push hook reports unfetched remote commits 2021-04-05 Egeyar Bagcioglu * etc/git-hooks/pre-push: Report it clearly when the pre-push hook fails due to remote containing unfetched commits. diff --git a/ChangeLog b/ChangeLog index c3955cbf..29c636da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ + +2021-04-05 Egeyar Bagcioglu + + * etc/git-hooks/pre-push: Report it clearly when the pre-push hook + fails due to remote containing unfetched commits. + 2021-04-05 Jose E. Marchesi * poke/poke.c (initialize): Load pk-hserver.pk directly. diff --git a/etc/git-hooks/pre-push b/etc/git-hooks/pre-push index b7c5d2ff..943945b9 100755 --- a/etc/git-hooks/pre-push +++ b/etc/git-hooks/pre-push @@ -42,8 +42,17 @@ do # New branch, examine all commits range="$local_sha" else - # Update to existing branch, examine new commits - range="$remote_sha..$local_sha" + # Without this check, the "git diff-tree" below fails and + # this hook falsely reports "ChangeLog is missing." when the + # remote has unfetched commits. + if test $(git cat-file -t $remote_sha^{commit}) + then + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + else + echo "Remote contains unfetched commits" + exit 1 + fi fi # Check for ChangeLog being in each commits