Re: [PATCH v5] branch: introduce --show-current display option

Eric Sunshine <sunshine@xxxxxxxxxxxxxx> writes:
>> + test_when_finished "
>> + git checkout branch-one
>> + git branch -D branch-and-tag-name
>> + " &&
>> + git checkout -b branch-and-tag-name &&
>> + test_when_finished "git tag -d branch-and-tag-name" &&
>> + git tag branch-and-tag-name &&
We've discussed about the exit status from clean-up code already,
but another thing worth noticing is that it probably is easier to
see what is going on if we use a single when-finished to clear both
branch and the tag with the same name. Something like
test_when_finished "
git checkout branch-one
git branch -D branch-and-tag-name
git tag -d branch-and-tag-name
:
" &&
upfront before doing anything else. "checkout" may break if the
test that follows when-finished accidentally removes branch-one
and that would cascade to a failure to remove branch-and-tag-name
branch (because we fail to move away from it), but because there is
no && in between, we'd clean as much as we could in such a case,
which may or may not be a good thing. And then we hide the exit
code by having a ":" at the end.