1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 04:36:10 +02:00

*.sh: avoid hardcoding $GIT_DIR/hooks/...

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>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2014-11-30 15:24:38 +07:00 committed by Junio C Hamano
parent 3bc518084a
commit b849b954d2
6 changed files with 22 additions and 24 deletions

View File

@ -810,10 +810,10 @@ To restore the original branch and stop patching run \"\$cmdline --abort\"."
continue continue
fi 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" || "$hook" "$dotest/final-commit" || stop_here $this
stop_here $this
fi fi
if test -f "$dotest/final-commit" if test -f "$dotest/final-commit"
@ -887,9 +887,10 @@ did you forget to use 'git add'?"
stop_here_user_resolve $this stop_here_user_resolve $this
fi 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 fi
tree=$(git write-tree) && tree=$(git write-tree) &&
@ -916,18 +917,17 @@ did you forget to use 'git add'?"
echo "$(cat "$dotest/original-commit") $commit" >> "$dotest/rewritten" echo "$(cat "$dotest/original-commit") $commit" >> "$dotest/rewritten"
fi fi
if test -x "$GIT_DIR"/hooks/post-applypatch hook="$(git rev-parse --git-path hooks/post-applypatch)"
then test -x "$hook" && "$hook"
"$GIT_DIR"/hooks/post-applypatch
fi
go_next go_next
done done
if test -s "$dotest"/rewritten; then if test -s "$dotest"/rewritten; then
git notes copy --for-rewrite=rebase < "$dotest"/rewritten git notes copy --for-rewrite=rebase < "$dotest"/rewritten
if test -x "$GIT_DIR"/hooks/post-rewrite; then hook="$(git rev-parse --git-path hooks/post-rewrite)"
"$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten if test -x "$hook"; then
"$hook" rebase < "$dotest"/rewritten
fi fi
fi fi

View File

@ -642,9 +642,9 @@ do_next () {
git notes copy --for-rewrite=rebase < "$rewritten_list" || git notes copy --for-rewrite=rebase < "$rewritten_list" ||
true # we don't care if this copying failed true # we don't care if this copying failed
} && } &&
if test -x "$GIT_DIR"/hooks/post-rewrite && hook="$(git rev-parse --git-path hooks/post-rewrite)"
test -s "$rewritten_list"; then if test -x "$hook" && test -s "$rewritten_list"; then
"$GIT_DIR"/hooks/post-rewrite rebase < "$rewritten_list" "$hook" rebase < "$rewritten_list"
true # we don't care if this hook failed true # we don't care if this hook failed
fi && fi &&
warn "Successfully rebased and updated $head_name." warn "Successfully rebased and updated $head_name."

View File

@ -94,10 +94,8 @@ finish_rb_merge () {
if test -s "$state_dir"/rewritten if test -s "$state_dir"/rewritten
then then
git notes copy --for-rewrite=rebase <"$state_dir"/rewritten git notes copy --for-rewrite=rebase <"$state_dir"/rewritten
if test -x "$GIT_DIR"/hooks/post-rewrite hook="$(git rev-parse --git-path hooks/post-rewrite)"
then test -x "$hook" && "$hook" rebase <"$state_dir"/rewritten
"$GIT_DIR"/hooks/post-rewrite rebase <"$state_dir"/rewritten
fi
fi fi
say All done. say All done.
} }

View File

@ -202,9 +202,9 @@ run_specific_rebase () {
run_pre_rebase_hook () { run_pre_rebase_hook () {
if test -z "$ok_to_skip_pre_rebase" && 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.")" die "$(gettext "The pre-rebase hook refused to rebase.")"
fi fi
} }

View File

@ -10,6 +10,6 @@
# To enable this hook, rename this file to "applypatch-msg". # To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup . git-sh-setup
test -x "$GIT_DIR/hooks/commit-msg" && commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
: :

View File

@ -9,6 +9,6 @@
# To enable this hook, rename this file to "pre-applypatch". # To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup . git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" && precommit="$(git rev-parse --git-path hooks/pre-commit)"
exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} test -x "$precommit" && exec "$precommit" ${1+"$@"}
: :