#!/bin/sh ## General information on Git post-checkout hooks: # # This hook is invoked when a git checkout is run after having updated # the worktree. The hook is given three parameters: the ref of the # previous HEAD, the ref of the new HEAD (which may or may not have # changed), and a flag indicating whether the checkout was a branch # checkout (changing branches, flag=1) or a file checkout (retrieving # a file from the index, flag=0). This hook cannot affect the outcome # of git checkout. # # It is also run after git clone, unless the --no-checkout (-n) option # is used. The first parameter given to the hook is the null-ref, the # second the ref of the new HEAD and the flag is always 1. # # This hook can be used to perform repository validity checks, # auto-display differences from the previous HEAD if different, or set # working dir metadata properties. head_old=$1 head_new=$2 flag=$3 # We are interested only in branch checkouts. if [ "$flag" != "1" ]; then exit 0 fi # n.b. pwd will be this working copy's root directory. root=$(pwd) # printf "$0: %s - %s - %s\n" "$@" # ls -l "$root"/.git/BISECT* if [ -f "$root/.git/BISECT_LOG" ]; then # Currently bisecting. If the ONLY thing which has happened so # far is the "git bisect start" command, then mark our always-good # commits as "good". (This will append to the log, after which # the following test will fail.) tail -1 "$root/.git/BISECT_LOG" | grep -q '^git bisect .*\bstart\b' \ && [ -f "$root/etc/git-bisect-good-refs" ] \ && cp "$root/etc/git-bisect-good-refs" "$root/.git/BISECT_EMACS_GOOD_REFS" \ && printf %s\\n "Marking known-good references in Emacs repository." \ && cat "$root/.git/BISECT_EMACS_GOOD_REFS" | xargs git bisect good \ && git bisect log else # Not currently bisecting; just tidy up. [ -f "$root/.git/BISECT_EMACS_GOOD_REFS" ] \ && rm "$root/.git/BISECT_EMACS_GOOD_REFS" fi exit 0 # etc/git-bisect-good-refs is a file containing this commit ref: # 806734c1b1f433de43d59d9a5e3a1e89d64315f6