git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 2/4] worktree: add --[no-]track option to the add subcommand

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Nov 25, 2017, 16:58 UTC
Message-ID
<20171125165833.GA14993@hank>
In-Reply-To
<xmqqa7zcnozj.fsf@gitster.mtv.corp.google.com>
On 11/24, Junio C Hamano wrote:
Show 35 quoted lines
> Thomas Gummerer <t.gummerer@gmail.com> writes:
> 
> > diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
> > index b5c47ac602..53042ce565 100755
> > --- a/t/t2025-worktree-add.sh
> > +++ b/t/t2025-worktree-add.sh
> > @@ -313,5 +313,60 @@ test_expect_success 'checkout a branch under bisect' '
> >  test_expect_success 'rename a branch under bisect not allowed' '
> >  	test_must_fail git branch -M under-bisect bisect-with-new-name
> >  '
> > +# Is branch "refs/heads/$1" set to pull from "$2/$3"?
> > +test_branch_upstream () {
> > +	printf "%s\n" "$2" "refs/heads/$3" >expect.upstream &&
> > +	{
> > +		git config "branch.$1.remote" &&
> > +		git config "branch.$1.merge"
> > +	} >actual.upstream &&
> > +	test_cmp expect.upstream actual.upstream
> > +}
> 
> OK.
> 
> > +test_expect_success '--track sets up tracking' '
> > +	test_when_finished rm -rf track &&
> > +	git worktree add --track -b track track master &&
> > +	git config "branch.track.merge" &&
> > +	(
> > +		test_branch_upstream track . master
> > +	)
> > +'
> 
> Is this "git config" necessary, or is it a remnant of a debugging
> session?  It is tested in the helper that branch.track.merge is set
> to something, and otherwise the helper would fail the same way as
> this standalnoe "git config" would, no?

It's a remnant of a debugging session, sorry. It would indeed fail in the same way, so just leaving the 'test_branch_upstream' is enough. Also looking at that, there's no need for it to be in a subshell, will fix that as well.

Show 38 quoted lines
> > +# setup remote repository $1 and repository $2 with $1 set up as
> > +# remote.  The remote has two branches, master and foo.
> > +setup_remote_repo () {
> > +	git init $1 &&
> > +	(
> > +		cd $1 &&
> > +		test_commit $1_master &&
> > +		git checkout -b foo &&
> > +		test_commit upstream_foo
> > +	) &&
> > +	git init $2 &&
> > +	(
> > +		cd $2 &&
> > +		test_commit $2_master &&
> > +		git remote add $1 ../$1 &&
> > +		git config remote.$1.fetch \
> > +			"refs/heads/*:refs/remotes/$1/*" &&
> > +		git fetch --all
> > +	)
> > +}
> > +
> > +test_expect_success '--no-track avoids setting up tracking' '
> > +	test_when_finished rm -rf repo_upstream repo_local foo &&
> > +	setup_remote_repo repo_upstream repo_local &&
> > +	(
> > +		cd repo_local &&
> > +		git worktree add --no-track -b foo ../foo repo_upstream/foo
> > +	) &&
> > +	(
> > +		cd foo &&
> > +		! test_branch_upstream foo repo_upstream foo &&
> 
> It is true that this test helper must yield failure.  But what you
> expect probably is more than that, no?  For example, the test helper
> would fail even if branch.foo.remote is set to the upstream as long
> as branch.foo.merge is not set to point at their foo, but what you
> really want to make sure is that neither configuration variable is
> set.

Yeah you're right, this test is a bit too loose. Will fix that in the re-roll. Thanks!

Show 7 quoted lines
> > +		git rev-parse repo_upstream/foo >expect &&
> > +		git rev-parse foo >actual &&
> > +		test_cmp expect actual
> > +	)
> > +'
> >  
> >  test_done
Previous: Junio C HamanoNext: Thomas Gummerer
Message 18 of 36 in “make git worktree add dwim more”
  1. 0/4 make git worktree add dwim moreThomas Gummerer, Nov 22, 2017
  2. 4/4 worktree: make add <path> dwimThomas Gummerer, Nov 22, 2017
  3. Junio C HamanoNov 24, 2017
  4. Thomas GummererNov 25, 2017
  5. Paul SmithNov 25, 2017
  6. Thomas GummererNov 25, 2017
  7. Randall S. BeckerNov 25, 2017
  8. Thomas GummererNov 25, 2017
  9. Paul SmithNov 25, 2017
  10. Junio C HamanoNov 26, 2017
  11. Thomas GummererNov 26, 2017
  12. 3/4 worktree: make add <path> <branch> dwimThomas Gummerer, Nov 22, 2017
  13. Junio C HamanoNov 24, 2017
  14. 1/4 checkout: factor out functions to new lib fileThomas Gummerer, Nov 22, 2017
  15. Junio C HamanoNov 24, 2017
  16. 2/4 worktree: add --[no-]track option to the add subcommandThomas Gummerer, Nov 22, 2017
  17. Junio C HamanoNov 24, 2017
  18. Thomas GummererNov 25, 2017
  19. 0/6 make git worktree add dwim moreThomas Gummerer, Nov 26, 2017
  20. 1/6 checkout: factor out functions to new lib fileThomas Gummerer, Nov 26, 2017
  21. 2/6 worktree: add can be created from any commit-ishThomas Gummerer, Nov 26, 2017
  22. 3/6 worktree: add --[no-]track option to the add subcommandThomas Gummerer, Nov 26, 2017
  23. 4/6 worktree: make add <path> <branch> dwimThomas Gummerer, Nov 26, 2017
  24. 6/6 add worktree.guessRemote config optionThomas Gummerer, Nov 26, 2017
  25. Junio C HamanoNov 27, 2017
  26. Thomas GummererNov 27, 2017
  27. 5/6 worktree: add --guess-remote flag to add subcommandThomas Gummerer, Nov 26, 2017
  28. Junio C HamanoNov 27, 2017
  29. Thomas GummererNov 27, 2017
  30. 0/6 make git worktree add dwim moreThomas Gummerer, Nov 29, 2017
  31. 1/6 checkout: factor out functions to new lib fileThomas Gummerer, Nov 29, 2017
  32. 2/6 worktree: add can be created from any commit-ishThomas Gummerer, Nov 29, 2017
  33. 3/6 worktree: add --[no-]track option to the add subcommandThomas Gummerer, Nov 29, 2017
  34. 5/6 worktree: add --guess-remote flag to add subcommandThomas Gummerer, Nov 29, 2017
  35. 6/6 add worktree.guessRemote config optionThomas Gummerer, Nov 29, 2017
  36. 4/6 worktree: make add <path> <branch> dwimThomas Gummerer, Nov 29, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.