-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add post-merge hook, related documentation, and tests.
The post-merge hook enables one to hook in for `git pull` operations in order to check and/or change attributes of a work tree from the hook. As an example, it can be used in combination with a pre-commit hook to save/restore file ownership and permissions data (or file ACLs) within the repository and transparently update the working tree after a `git pull` operation. Signed-off-by: Josh England <jjengla@sandia.gov> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Josh England
authored and
Junio C Hamano
committed
Sep 19, 2007
1 parent
89df580
commit 4623291
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2006 Josh England | ||
# | ||
|
||
test_description='Test the post-merge hook.' | ||
. ./test-lib.sh | ||
|
||
test_expect_success setup ' | ||
echo Data for commit0. >a && | ||
git update-index --add a && | ||
tree0=$(git write-tree) && | ||
commit0=$(echo setup | git commit-tree $tree0) && | ||
echo Changed data for commit1. >a && | ||
git update-index a && | ||
tree1=$(git write-tree) && | ||
commit1=$(echo modify | git commit-tree $tree1 -p $commit0) && | ||
git update-ref refs/heads/master $commit0 && | ||
git-clone ./. clone1 && | ||
GIT_DIR=clone1/.git git update-index --add a && | ||
git-clone ./. clone2 && | ||
GIT_DIR=clone2/.git git update-index --add a | ||
' | ||
|
||
for clone in 1 2; do | ||
cat >clone${clone}/.git/hooks/post-merge <<'EOF' | ||
#!/bin/sh | ||
echo $@ >> $GIT_DIR/post-merge.args | ||
EOF | ||
chmod u+x clone${clone}/.git/hooks/post-merge | ||
done | ||
|
||
test_expect_failure 'post-merge does not run for up-to-date ' ' | ||
GIT_DIR=clone1/.git git merge $commit0 && | ||
test -e clone1/.git/post-merge.args | ||
' | ||
|
||
test_expect_success 'post-merge runs as expected ' ' | ||
GIT_DIR=clone1/.git git merge $commit1 && | ||
test -e clone1/.git/post-merge.args | ||
' | ||
|
||
test_expect_success 'post-merge from normal merge receives the right argument ' ' | ||
grep 0 clone1/.git/post-merge.args | ||
' | ||
|
||
test_expect_success 'post-merge from squash merge runs as expected ' ' | ||
GIT_DIR=clone2/.git git merge --squash $commit1 && | ||
test -e clone2/.git/post-merge.args | ||
' | ||
|
||
test_expect_success 'post-merge from squash merge receives the right argument ' ' | ||
grep 1 clone2/.git/post-merge.args | ||
' | ||
|
||
test_done |