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

Re: [PATCH] merge: make merge state available to prepare-commit-msg hook

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 8, 2014, 22:01 UTC
Message-ID
<20140108220119.GN3881@google.com>
In-Reply-To
<vpqtxdenoug.fsf@anie.imag.fr>
Matthieu Moy wrote:
> Jonathan's answer is an option. Another one is
[...]
> So if the cleanup goes wrong, one can notice.
test_when_finished also makes the test fail if the cleanup failed.
Another common strategy is
	test_expect_success 'my exciting test' '
		# this test will rely on these files being absent
		rm -f a b c etc &&
		... rest of the test goes here ...
	'

which can be a handy way for an especially picky test to protect itself (for example with 'git clean -fdx') regardless of the state other test assertions create for it.

This particular example (merge --abort) seems like a good use for test_when_finished because it is about a specific test having made a mess and needing to clean up after itself to restore sanity.

Hoping that clarifies, Jonathan

Previous: Matthieu MoyNext: Matthieu Moy
Message 7 of 18 in “merge: make merge state available to prepare-commit-msg hook”
  1. merge: make merge state available to prepare-commit-msg hookRyan Biesemeyer, Jan 8, 2014
  2. Ryan BiesemeyerJan 8, 2014
  3. Matthieu MoyJan 8, 2014
  4. Ryan BiesemeyerJan 8, 2014
  5. Jonathan NiederJan 8, 2014
  6. Matthieu MoyJan 8, 2014
  7. Jonathan NiederJan 8, 2014
  8. Matthieu MoyJan 9, 2014
  9. Ryan BiesemeyerJan 8, 2014
  10. 0/4 merge: make merge state available to prepare-commit-msg hookRyan Biesemeyer, Jan 9, 2014
  11. 1/4 t7505: add missing &&Ryan Biesemeyer, Jan 9, 2014
  12. 2/4 t7505: ensure cleanup after hook blocks mergeRyan Biesemeyer, Jan 9, 2014
  13. Matthieu MoyJan 9, 2014
  14. Junio C HamanoJan 10, 2014
  15. 3/4 merge: make prepare_to_commit responsible for write_merge_stateRyan Biesemeyer, Jan 9, 2014
  16. Junio C HamanoJan 11, 2014
  17. Junio C HamanoJan 11, 2014
  18. 4/4 merge: drop unused arg from abort_commit method signatureRyan Biesemeyer, Jan 9, 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.