mirror of
https://codeberg.org/andyscott/dotfiles.git
synced 2024-11-09 22:10:48 -05:00
31 lines
832 B
Bash
31 lines
832 B
Bash
#!/bin/sh
|
|
|
|
|
|
### Post checkout hook to update .git/info/exclude with
|
|
### branch specific .gitignore.[branch-name] files.
|
|
### Copy to .git/hooks and chmod +x after fresh clone
|
|
### to ensure proper .gitignore configuration.
|
|
|
|
branch_switched=$3
|
|
|
|
if [ "$branch_switched" != "1" ]
|
|
then
|
|
exit 0
|
|
fi
|
|
echo "---- POST CHECKOUT ----"
|
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
root_dir="$(pwd -P)"
|
|
info_dir="$root_dir/.git/info"
|
|
|
|
exclude_target='.gitignore'
|
|
if [ -f "$root_dir/$exclude_target.$current_branch" ]
|
|
then
|
|
echo "Prepare to use .gitignore.$current_branch as exclude file"
|
|
exclude_target=.gitignore.$current_branch
|
|
fi
|
|
cd "$info_dir" || exit
|
|
rm exclude
|
|
#ln -s $exclude_target exclude
|
|
echo "Copy .gitignore.$current_branch file in place of exclude"
|
|
cp "$root_dir/$exclude_target" exclude
|
|
echo "--- POST CHECKOUT END ---"
|