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

[PATCH 3/7] test patch hunk editing with "commit -p -m"

From
Benoit Pierre <benoit.pierre@gmail.com>
Date
Mar 15, 2014, 21:42 UTC
Message-ID
<1394919750-28432-3-git-send-email-benoit.pierre@gmail.com>
In-Reply-To
<1394919750-28432-1-git-send-email-benoit.pierre@gmail.com>

Add (failing) tests: with commit changing the environment to let hooks know that no editor will be used (by setting GIT_EDITOR to ":"), the "edit hunk" functionality does not work (no editor is launched and the whole hunk is committed).

Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
---
 t/t7513-commit-patch.sh | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100755 t/t7513-commit-patch.sh
diff --git a/t/t7513-commit-patch.sh b/t/t7513-commit-patch.sh
new file mode 100755
index 0000000..9311b0c
--- /dev/null
+++ b/t/t7513-commit-patch.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+test_description='hunk edit with "commit -p -m"'
+. ./test-lib.sh
+
+if ! test_have_prereq PERL
+then
+	skip_all="skipping '$test_description' tests, perl not available"
+	test_done
+fi
+
+test_expect_success 'setup (initial)' '
+	echo line1 >file &&
+	git add file &&
+	git commit -m commit1
+'
+
+test_expect_failure 'edit hunk "commit -p -m message"' '
+	test_when_finished "rm -f editor_was_started" &&
+	echo more >>file &&
+	echo e | env GIT_EDITOR="touch editor_was_started" git commit -p -m commit2 file &&
+	test -r editor_was_started
+'
+
+test_expect_failure 'edit hunk "commit --dry-run -p -m message"' '
+	test_when_finished "rm -f editor_was_started" &&
+	echo more >>file &&
+	echo e | env GIT_EDITOR="touch editor_was_started" git commit -p -m commit3 file &&
+	test -r editor_was_started
+'
+
+test_done
-- 
1.9.0
Previous: Benoit PierreNext: Junio C Hamano
Message 14 of 50 in “fix hunk editing with 'commit -p -m'”
  1. 0/7 fix hunk editing with 'commit -p -m'Benoit Pierre, Mar 10, 2014
  2. 1/7 merge hook tests: fix missing '&&' in testBenoit Pierre, Mar 10, 2014
  3. 2/7 merge hook tests: use 'test_must_fail' instead of '!'Benoit Pierre, Mar 10, 2014
  4. 3/7 test patch hunk editing with "commit -p -m"Benoit Pierre, Mar 10, 2014
  5. Eric SunshineMar 10, 2014
  6. Junio C HamanoMar 11, 2014
  7. Philip OakleyMar 10, 2014
  8. Junio C HamanoMar 11, 2014
  9. Torsten BögershausenMar 15, 2014
  10. Benoit PierreMar 15, 2014
  11. Torsten BögershausenMar 15, 2014
  12. 1/7 merge hook tests: fix missing '&&' in testBenoit Pierre, Mar 15, 2014
  13. 2/7 merge hook tests: use 'test_must_fail' instead of '!'Benoit Pierre, Mar 15, 2014
  14. 3/7 test patch hunk editing with "commit -p -m"Benoit Pierre, Mar 15, 2014
  15. Junio C HamanoMar 17, 2014
  16. Benoit PierreMar 17, 2014
  17. Eric SunshineMar 17, 2014
  18. Benoit PierreMar 17, 2014
  19. Junio C HamanoMar 17, 2014
  20. Junio C HamanoMar 17, 2014
  21. Benoit PierreMar 17, 2014
  22. Junio C HamanoMar 17, 2014
  23. 1/7 merge hook tests: fix missing '&&' in testBenoit Pierre, Mar 18, 2014
  24. 2/7 merge hook tests: use 'test_must_fail' instead of '!'Benoit Pierre, Mar 18, 2014
  25. 3/7 test patch hunk editing with "commit -p -m"Benoit Pierre, Mar 18, 2014
  26. 4/7 commit: fix patch hunk editing with "commit -p -m"Benoit Pierre, Mar 18, 2014
  27. Torsten BögershausenMar 19, 2014
  28. Junio C HamanoMar 19, 2014
  29. 5/7 merge: fix GIT_EDITOR override for commit hookBenoit Pierre, Mar 18, 2014
  30. 6/7 merge hook tests: fix and update testsBenoit Pierre, Mar 18, 2014
  31. 7/7 run-command: mark run_hook_with_custom_index as deprecatedBenoit Pierre, Mar 18, 2014
  32. Junio C HamanoMar 18, 2014
  33. 4/7 commit: fix patch hunk editing with "commit -p -m"Benoit Pierre, Mar 15, 2014
  34. 5/7 merge: fix GIT_EDITOR override for commit hookBenoit Pierre, Mar 15, 2014
  35. 6/7 merge hook tests: fix and update testsBenoit Pierre, Mar 15, 2014
  36. 7/7 run-command: mark run_hook_with_custom_index as deprecatedBenoit Pierre, Mar 15, 2014
  37. 4/7 commit: fix patch hunk editing with "commit -p -m"Benoit Pierre, Mar 10, 2014
  38. Jeff KingMar 10, 2014
  39. Jun HaoMar 11, 2014
  40. Benoit PierreMar 11, 2014
  41. Jeff KingMar 11, 2014
  42. Jun HaoMar 11, 2014
  43. Junio C HamanoMar 11, 2014
  44. 5/7 merge: fix GIT_EDITOR override for commit hookBenoit Pierre, Mar 10, 2014
  45. 6/7 merge hook tests: fix and update testsBenoit Pierre, Mar 10, 2014
  46. Eric SunshineMar 10, 2014
  47. 7/7 run-command: mark run_hook_with_custom_index as deprecatedBenoit Pierre, Mar 10, 2014
  48. brian m. carlsonMar 11, 2014
  49. Benoit PierreMar 11, 2014
  50. Jonathan NiederApr 3, 2014

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.