From: Eric Sunshine <sunshine@sunshineco.com>
To: Daniels Umanovskis <daniels@umanovskis.se>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH v5] branch: introduce --show-current display option
Date: Thu, 25 Oct 2018 15:30:23 -0400 [thread overview]
Message-ID: <CAPig+cRVdogY8VLXcftbY=n9tQ9wDo4YrnrdU6+pZ3ch6uhZGA@mail.gmail.com> (raw)
In-Reply-To: <20181025190421.15022-1-daniels@umanovskis.se>
On Thu, Oct 25, 2018 at 3:04 PM Daniels Umanovskis
<daniels@umanovskis.se> wrote:
> When called with --show-current, git branch will print the current
> branch name and terminate. Only the actual name gets printed,
> without refs/heads. In detached HEAD state, nothing is output.
>
> Signed-off-by: Daniels Umanovskis <daniels@umanovskis.se>
> ---
> diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
> @@ -100,6 +100,50 @@ test_expect_success 'git branch -v pattern does not show branch summaries' '
> +test_expect_success 'git branch `--show-current` works properly when tag exists' '
> + cat >expect <<-\EOF &&
> + branch-and-tag-name
> + EOF
> + 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 &&
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.
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
> +'
next prev parent reply other threads:[~2018-10-25 19:30 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 [this message]
2018-10-26 0:52 ` Junio C Hamano
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='CAPig+cRVdogY8VLXcftbY=n9tQ9wDo4YrnrdU6+pZ3ch6uhZGA@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=daniels@umanovskis.se \
--cc=git@vger.kernel.org \
/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).