-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-checkout
executable file
·24 lines (20 loc) · 1.04 KB
/
post-checkout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
#
# A hook script to call trk with the new branch name.
# 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)
# 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.
# To track branches with trk, it is recommended to do either of the following:
# * Copy this file to ./.git/hooks/post-checkout
# * Append the below lines to ./.git/hooks/post-checkout
# The Makefile can also be used to copy the hooks to the .git/hooks directory
# $> make sync-hook
if [ "$3" = 1 ]; then
# Checked out a branch - what branch are we on now?
# (Skip the rest if we're on a detached HEAD.)
curbranch=$(git symbolic-ref --short HEAD 2>/dev/null) || exit 1
# echo "switching to as-yet-unvisited-branch $curbranch"
trk branch $curbranch
fi