git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alexandr Miloslavskiy via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 0/2] checkout: die() on ambiguous tracking branches
Date: Wed, 27 Nov 2019 16:43:08 +0000	[thread overview]
Message-ID: <pull.477.v2.git.1574872991.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.477.git.1574848137.gitgitgadget@gmail.com>

Please refer to commit messages for details.

Rationale: this issue was standing in my way while working on my 
--pathspec-from-file patches. Since this looks like an oversight, I decided
to fix it.


----------------------------------------------------------------------------

Changes from v1:

1) As suggested, removed parentheses in '&& (num_matches > 1)' 2) As
suggested, added additional checks in test. 3) Added some code comments in
test

Alexandr Miloslavskiy (2):
  parse_branchname_arg(): extract part as new function
  checkout: die() on ambiguous tracking branches

 builtin/checkout.c       | 71 ++++++++++++++++++++++------------------
 t/t2024-checkout-dwim.sh | 28 ++++++++++++++--
 2 files changed, 65 insertions(+), 34 deletions(-)


base-commit: d9f6f3b6195a0ca35642561e530798ad1469bd41
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-477%2FSyntevoAlex%2F%230224(git)_deny_ambiguous_checkout-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-477/SyntevoAlex/#0224(git)_deny_ambiguous_checkout-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/477

Range-diff vs v1:

 1:  c5b92ce3ed = 1:  1e40cc485b parse_branchname_arg(): extract part as new function
 2:  7dde1a3b4e ! 2:  575eeb97ba checkout: die() on ambiguous tracking branches
     @@ -54,7 +54,7 @@
       		    arg);
       	}
       
     -+	if (!remote && (num_matches > 1)) {
     ++	if (!remote && num_matches > 1) {
      +	    if (advice_checkout_ambiguous_remote_branch_name) {
      +		    advise(_("If you meant to check out a remote tracking branch on, e.g. 'origin',\n"
      +			     "you can do so by fully qualifying the name with the --track option:\n"
     @@ -174,17 +174,22 @@
       '
       
      +test_expect_success 'when arg matches multiple remotes, do not fallback to interpreting as pathspec' '
     ++	# create a file with name matching remote branch name
      +	git checkout -b t_ambiguous_branch_and_file &&
      +	>ambiguous_branch_and_file &&
      +	git add ambiguous_branch_and_file &&
      +	git commit -m "ambiguous_branch_and_file" &&
      +
     ++	# modify file to verify that it will not be touched by checkout
      +	test_when_finished "git checkout -- ambiguous_branch_and_file" &&
      +	echo "file contents" >ambiguous_branch_and_file &&
      +	cp ambiguous_branch_and_file expect &&
      +
     -+	test_must_fail git checkout ambiguous_branch_and_file &&
     ++	test_must_fail git checkout ambiguous_branch_and_file 2>err &&
      +
     ++	test_i18ngrep "matched multiple (2) remote tracking branches" err &&
     ++	
     ++	# file must not be altered
      +	test_cmp expect ambiguous_branch_and_file
      +'
      +

-- 
gitgitgadget

  parent reply	other threads:[~2019-11-27 16:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27  9:48 [PATCH 0/2] checkout: die() on ambiguous tracking branches Alexandr Miloslavskiy via GitGitGadget
2019-11-27  9:48 ` [PATCH 1/2] parse_branchname_arg(): extract part as new function Alexandr Miloslavskiy via GitGitGadget
2019-11-27  9:48 ` [PATCH 2/2] checkout: die() on ambiguous tracking branches Alexandr Miloslavskiy via GitGitGadget
2019-11-27 14:46   ` Derrick Stolee
2019-11-27 16:42     ` Alexandr Miloslavskiy
2019-11-27 15:43   ` Ævar Arnfjörð Bjarmason
2019-11-27 16:09     ` Alexandr Miloslavskiy
2019-12-05 15:34       ` Alexandr Miloslavskiy
2019-11-27 16:43 ` Alexandr Miloslavskiy via GitGitGadget [this message]
2019-11-27 16:43   ` [PATCH v2 1/2] parse_branchname_arg(): extract part as new function Alexandr Miloslavskiy via GitGitGadget
2019-11-27 16:43   ` [PATCH v2 2/2] checkout: die() on ambiguous tracking branches Alexandr Miloslavskiy via GitGitGadget
2019-12-01 15:47   ` [PATCH v2 0/2] " Junio C Hamano
2019-12-01 16:52     ` Alexandr Miloslavskiy

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.477.v2.git.1574872991.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=alexandr.miloslavskiy@syntevo.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
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 NNTP newsgroup(s).