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

From: Jonathan Nieder <[email-masked]>
Date: Wed, 8 Jan 2014 14:01:19 -0800

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