Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
*.sh: avoid hardcoding $GIT_DIR/hooks/...
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 30 Nov 2014 08:24:38 +0000
(15:24 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 1 Dec 2014 19:00:13 +0000
(11:00 -0800)
If $GIT_COMMON_DIR is set, it should be $GIT_COMMON_DIR/hooks/, not
$GIT_DIR/hooks/. Just let rev-parse --git-path handle it.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-am.sh
patch
|
blob
|
history
git-rebase--interactive.sh
patch
|
blob
|
history
git-rebase--merge.sh
patch
|
blob
|
history
git-rebase.sh
patch
|
blob
|
history
templates/hooks--applypatch-msg.sample
patch
|
blob
|
history
templates/hooks--pre-applypatch.sample
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
3bc5180
)
diff --git
a/git-am.sh
b/git-am.sh
index ee61a77d717a7210a1cf614914ab62788fd5e4fc..66803d12764d0df8970092ba057ded9442c86352 100755
(executable)
--- a/
git-am.sh
+++ b/
git-am.sh
@@
-810,10
+810,10
@@
To restore the original branch and stop patching run \"\$cmdline --abort\"."
continue
fi
continue
fi
- if test -x "$GIT_DIR"/hooks/applypatch-msg
+ hook="$(git rev-parse --git-path hooks/applypatch-msg)"
+ if test -x "$hook"
then
then
- "$GIT_DIR"/hooks/applypatch-msg "$dotest/final-commit" ||
- stop_here $this
+ "$hook" "$dotest/final-commit" || stop_here $this
fi
if test -f "$dotest/final-commit"
fi
if test -f "$dotest/final-commit"
@@
-887,9
+887,10
@@
did you forget to use 'git add'?"
stop_here_user_resolve $this
fi
stop_here_user_resolve $this
fi
- if test -x "$GIT_DIR"/hooks/pre-applypatch
+ hook="$(git rev-parse --git-path hooks/pre-applypatch)"
+ if test -x "$hook"
then
then
- "$
GIT_DIR"/hooks/pre-applypatch
|| stop_here $this
+ "$
hook"
|| stop_here $this
fi
tree=$(git write-tree) &&
fi
tree=$(git write-tree) &&
@@
-916,18
+917,17
@@
did you forget to use 'git add'?"
echo "$(cat "$dotest/original-commit") $commit" >> "$dotest/rewritten"
fi
echo "$(cat "$dotest/original-commit") $commit" >> "$dotest/rewritten"
fi
- if test -x "$GIT_DIR"/hooks/post-applypatch
- then
- "$GIT_DIR"/hooks/post-applypatch
- fi
+ hook="$(git rev-parse --git-path hooks/post-applypatch)"
+ test -x "$hook" && "$hook"
go_next
done
if test -s "$dotest"/rewritten; then
git notes copy --for-rewrite=rebase < "$dotest"/rewritten
go_next
done
if test -s "$dotest"/rewritten; then
git notes copy --for-rewrite=rebase < "$dotest"/rewritten
- if test -x "$GIT_DIR"/hooks/post-rewrite; then
- "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
+ hook="$(git rev-parse --git-path hooks/post-rewrite)"
+ if test -x "$hook"; then
+ "$hook" rebase < "$dotest"/rewritten
fi
fi
fi
fi
diff --git
a/git-rebase--interactive.sh
b/git-rebase--interactive.sh
index b64dd28acf86e0b3075a638ae3419fb3a79a1815..b32f797aa91bff965c8d35c0e2b591ff52f1fb4e 100644
(file)
--- a/
git-rebase--interactive.sh
+++ b/
git-rebase--interactive.sh
@@
-642,9
+642,9
@@
do_next () {
git notes copy --for-rewrite=rebase < "$rewritten_list" ||
true # we don't care if this copying failed
} &&
git notes copy --for-rewrite=rebase < "$rewritten_list" ||
true # we don't care if this copying failed
} &&
- if test -x "$GIT_DIR"/hooks/post-rewrite &&
-
test -s "$rewritten_list"; then
- "$
GIT_DIR"/hooks/post-rewrite
rebase < "$rewritten_list"
+ hook="$(git rev-parse --git-path hooks/post-rewrite)"
+
if test -x "$hook" &&
test -s "$rewritten_list"; then
+ "$
hook"
rebase < "$rewritten_list"
true # we don't care if this hook failed
fi &&
warn "Successfully rebased and updated $head_name."
true # we don't care if this hook failed
fi &&
warn "Successfully rebased and updated $head_name."
diff --git
a/git-rebase--merge.sh
b/git-rebase--merge.sh
index d3fb67d75bd3cdfebd048594cdb67eb179b1c435..2cc2a6d2734c0ef12222004f22d717f4f724d82f 100644
(file)
--- a/
git-rebase--merge.sh
+++ b/
git-rebase--merge.sh
@@
-94,10
+94,8
@@
finish_rb_merge () {
if test -s "$state_dir"/rewritten
then
git notes copy --for-rewrite=rebase <"$state_dir"/rewritten
if test -s "$state_dir"/rewritten
then
git notes copy --for-rewrite=rebase <"$state_dir"/rewritten
- if test -x "$GIT_DIR"/hooks/post-rewrite
- then
- "$GIT_DIR"/hooks/post-rewrite rebase <"$state_dir"/rewritten
- fi
+ hook="$(git rev-parse --git-path hooks/post-rewrite)"
+ test -x "$hook" && "$hook" rebase <"$state_dir"/rewritten
fi
say All done.
}
fi
say All done.
}
diff --git
a/git-rebase.sh
b/git-rebase.sh
index 55da9db818665f39ed205d3c77352987e3ca9963..fb935a03f3ababaa6359d6a7a4deafcbaa9f15c2 100755
(executable)
--- a/
git-rebase.sh
+++ b/
git-rebase.sh
@@
-202,9
+202,9
@@
run_specific_rebase () {
run_pre_rebase_hook () {
if test -z "$ok_to_skip_pre_rebase" &&
run_pre_rebase_hook () {
if test -z "$ok_to_skip_pre_rebase" &&
- test -x "$
GIT_DIR/hooks/pre-rebase
"
+ test -x "$
(git rev-parse --git-path hooks/pre-rebase)
"
then
then
- "$
GIT_DIR/hooks/pre-rebase
" ${1+"$@"} ||
+ "$
(git rev-parse --git-path hooks/pre-rebase)
" ${1+"$@"} ||
die "$(gettext "The pre-rebase hook refused to rebase.")"
fi
}
die "$(gettext "The pre-rebase hook refused to rebase.")"
fi
}
diff --git
a/templates/hooks--applypatch-msg.sample
b/templates/hooks--applypatch-msg.sample
index 8b2a2fe84feaeaba56953d6d4d0d649b3cf755eb..a5d7b84a673458d14d9aab082183a1968c2c7492 100755
(executable)
--- a/
templates/hooks--applypatch-msg.sample
+++ b/
templates/hooks--applypatch-msg.sample
@@
-10,6
+10,6
@@
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
-test -x "$GIT_DIR/hooks/commit-msg" &&
-
exec "$GIT_DIR/hooks/commit-
msg" ${1+"$@"}
+commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
+
test -x "$commitmsg" && exec "$commit
msg" ${1+"$@"}
:
:
diff --git
a/templates/hooks--pre-applypatch.sample
b/templates/hooks--pre-applypatch.sample
index b1f187c2e9acaba942639bca90a63c5b4f058967..4142082bcb939bbc17985a69ba748491ac6b62a5 100755
(executable)
--- a/
templates/hooks--pre-applypatch.sample
+++ b/
templates/hooks--pre-applypatch.sample
@@
-9,6
+9,6
@@
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
-test -x "$GIT_DIR/hooks/pre-commit" &&
-
exec "$GIT_DIR/hooks/pre-
commit" ${1+"$@"}
+precommit="$(git rev-parse --git-path hooks/pre-commit)"
+
test -x "$precommit" && exec "$pre
commit" ${1+"$@"}
:
: