From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Daniels Umanovskis <daniels@umanovskis.se>,
Git List <git@vger.kernel.org>
Subject: Re: [PATCH v5] branch: introduce --show-current display option
Date: Fri, 26 Oct 2018 09:52:24 +0900 [thread overview]
Message-ID: <xmqqefcdfs1j.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <CAPig+cRVdogY8VLXcftbY=n9tQ9wDo4YrnrdU6+pZ3ch6uhZGA@mail.gmail.com> (Eric Sunshine's message of "Thu, 25 Oct 2018 15:30:23 -0400")
Eric Sunshine <sunshine@sunshineco.com> writes:
>> + test_when_finished "git tag -d branch-and-tag-name" &&
>> + git tag branch-and-tag-name &&
>
> If git-tag crashes before actually creating the new tag, then "git tag
> -d", passed to test_when_finished(), will error out too, which is
> probably undesirable since "cleanup code" isn't expected to error out.
Ah, I somehow thought that clean-up actions set up via when_finished
are allowed to fail without affecting the outcome, but apparently I
was mistaken.
This however can be argued both ways---if you create a tag first and
try to set up the clean-up action, during which you may get in
trouble and end up leaving the tag behind. So rather than swapping
the two lines, explicitly preparing for the case the clean-up action
fails, i.e. the first alternative below, would be a good fix.
Also it is a good question if the tag need to be even cleaned up.
> You could fix it this way:
>
> test_when_finished "git tag -d branch-and-tag-name || :" &&
> git tag branch-and-tag-name &&
>
> or, even better, just swap the two lines:
>
> git tag branch-and-tag-name &&
> test_when_finished "git tag -d branch-and-tag-name" &&
> However, do you even need to clean up the tag? Are there tests
> following this one which expect a certain set of tags and fail if this
> new one is present? If not, a simpler approach might be just to leave
> the tag alone (and the branch too if that doesn't need to be cleaned
> up).
>
>> + git branch --show-current >actual &&
>> + test_cmp expect actual
>> +'
A bigger question we may want to ask ourselves is if we want to
detect failures from these clean-up actions in the first place.
There are many hits from "git grep 'when_finished .*|| :' t/", which
may be a sign that the when_finished mechanism was misdesigned and
we should simply ignore the exit status from the clean-up actions
instead.
I haven't gone through the list of when_finished clean-up actions
that do not end with "|| :"; I suspect some of them are simply being
sloppy and would want to have "|| :", but what I want to find out
out of such an audit is if there is a legitimate case where it helps
to catch failures in the clean-up actions. If there is none, then
...
next prev parent reply other threads:[~2018-10-26 0:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 19:04 [PATCH v5] branch: introduce --show-current display option Daniels Umanovskis
2018-10-25 19:30 ` Eric Sunshine
2018-10-26 0:52 ` Junio C Hamano [this message]
2018-11-01 22:01 ` Jeff King
2018-10-26 1:53 ` Junio C Hamano
2018-11-07 22:56 ` [PATCH] branch: make --show-current use already resolved HEAD Rafael Ascensão
2018-11-08 1:11 ` Junio C Hamano
2018-11-08 4:36 ` Rafael Ascensão
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqefcdfs1j.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=daniels@umanovskis.se \
--cc=git@vger.kernel.org \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).