git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] run-command: add hint when a hook is ignored

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 6, 2017, 05:43 UTC
Message-ID
<xmqqmv54x24j.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqq4lrcyj1p.fsf@gitster.mtv.corp.google.com>

Here is a suggested rewrite of t7519 (I used t7520 to avoid crashing with another topic in flight).

 - use unused/unallocated 7520 to avoid crashes with bp/fsmonitor
   topic
 - use setup inside test_expect_success
 - use test_i18ngrep to avoid gettext-poison build gotchas
 - look for specific advise message to make the test more robust
 - do not run Git on LHS of a pipe when we do not have to
 - use test_config and test_unconfig
 t/t7520-ignored-hook-warning.sh | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100755 t/t7520-ignored-hook-warning.sh
diff --git a/t/t7520-ignored-hook-warning.sh b/t/t7520-ignored-hook-warning.sh
new file mode 100755
index 0000000000..634fb7f23a
--- /dev/null
+++ b/t/t7520-ignored-hook-warning.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='ignored hook warning'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	hookdir="$(git rev-parse --git-dir)/hooks" &&
+	hook="$hookdir/pre-commit" &&
+	mkdir -p "$hookdir" &&
+	write_script "$hook" <<-\EOF
+	exit 0
+	EOF
+'
+
+test_expect_success 'no warning if hook is not ignored' '
+	git commit --allow-empty -m "more" 2>message &&
+	test_i18ngrep ! -e "hook was ignored" message
+'
+
+test_expect_success POSIXPERM 'warning if hook is ignored' '
+	chmod -x "$hook" &&
+	git commit --allow-empty -m "even more" 2>message &&
+	test_i18ngrep -e "hook was ignored" message
+'
+
+test_expect_success POSIXPERM 'no warning if advice.ignoredHook set to false' '
+	test_config advice.ignoredHook false &&
+	chmod -x "$hook" &&
+	git commit --allow-empty -m "even more" 2>message &&
+	test_i18ngrep ! -e "hook was ignored" message
+'
+
+test_expect_success 'no warning if unset advice.ignoredHook and hook removed' '
+	rm -f "$hook" &&
+	test_unconfig advice.ignoredHook &&
+	git commit --allow-empty -m "even more" 2>message &&
+	test_i18ngrep ! -e "hook was ignored" message
+'
+
+test_done
-- 
2.15.0-rc0-155-g07e9c1a78d
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 16 in “run-command.c: add hint when hook is not executable”
  1. run-command.c: add hint when hook is not executableDamien, Oct 3, 2017
  2. Junio C HamanoOct 4, 2017
  3. DamienOct 5, 2017
  4. run-command: add hint when a hook is ignoredDamien Marié, Oct 5, 2017
  5. Junio C HamanoOct 6, 2017
  6. Junio C HamanoOct 6, 2017
  7. Junio C HamanoOct 6, 2017
  8. Junio C HamanoOct 6, 2017
  9. DamienOct 6, 2017
  10. run-command: add hint when a hook is ignoredDamien Marié, Oct 6, 2017
  11. Junio C HamanoOct 10, 2017
  12. Junio C HamanoOct 11, 2017
  13. Jeff KingJan 3, 2018
  14. Junio C HamanoJan 5, 2018
  15. Jeff KingMar 3, 2018
  16. Junio C HamanoMar 5, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.