]> git.ipfire.org Git - thirdparty/git.git/commit
t3206: test_when_finished before dirtying operations, not after
authorJunio C Hamano <gitster@pobox.com>
Tue, 6 Aug 2024 17:04:13 +0000 (10:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Aug 2024 17:05:05 +0000 (10:05 -0700)
commit6caa96c2049a8f201a48c6890dbdbbe6b61ff06d
treeec295fa5a13ea2f4260efa567923902399375b71
parent406f326d271e0bacecdb00425422c5fa3f314930
t3206: test_when_finished before dirtying operations, not after

Many existing tests in this script perform operation(s) and then use
test_when_finished to define how to undo the effect of the
operation(s).

This is backwards.  When your operation(s) fail before you manage to
successfully call test_when_finished (remember, that these commands
must be all &&-chained, so a failure of an earlier operation mean
your test_when_finished may not be executed at all).  You must
establish how to clean up your mess with test_when_finished before
you create the mess to be cleaned up.

Also make sure that the body of test_when_finished deals with case
where the cruft it wants to remove failed to be created, by using
"rm -f" (instead of "rm") to remove potential cruft files, and
having "|| :" after "git notes remove" to remove potential cruft
notes---both of these by default fail when asked to remove something
that does not exist, instead of being silently idempotent no-ops.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3206-range-diff.sh