All of lore.kernel.org
 help / color / mirror / Atom feed
* Sample pre-push hook can crash
@ 2016-03-10 21:22 Stephen Morton
  2016-03-10 21:43 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Morton @ 2016-03-10 21:22 UTC (permalink / raw)
  To: git@vger.kernel.org

The sample pre-push hook provided with git [1] will crash if the local
repo is not up to date with the remote as $remote_sha is not present
in the local repo. I'm not sure if this patch is exactly correct, it's
just provided as an example.

Given that people are likely crafting their own solutions based on the
examples, it's probably good to get right.

diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
index 6187dbf..99ed984 100755
--- a/templates/hooks--pre-push.sample
+++ b/templates/hooks--pre-push.sample
@@ -36,9 +36,9 @@ do
                        # New branch, examine all commits
                        range="$local_sha"
                else
                        # Update to existing branch, examine new commits
-                       range="$remote_sha..$local_sha"
+                       range="@{u}..$local_sha"
                fi

                # Check for WIP commit
                commit=`git rev-list -n 1 --grep '^WIP' "$range"`


(This is just something I noticed and thought you might be interested
in, but is not important to me. I actually do care about the smudge
filter issue.)

Stephen

[1] https://github.com/git/git/blob/master/templates/hooks--pre-push.sample

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-11 20:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-10 21:22 Sample pre-push hook can crash Stephen Morton
2016-03-10 21:43 ` Junio C Hamano
2016-03-11 14:33   ` Stephen Morton
2016-03-11 20:04     ` Junio C Hamano
2016-03-11 20:35       ` Stephen Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.