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

Re: [PATCH v1 2/2] checkout: fix regression in checkout -b on intitial checkout

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Jan 19, 2019, 00:52 UTC
Message-ID
<20190119005202.GO840@szeder.dev>
In-Reply-To
<20190118185558.17688-3-peartben@gmail.com>
On Fri, Jan 18, 2019 at 01:55:58PM -0500, Ben Peart wrote:
Show 29 quoted lines
> From: Ben Peart <benpeart@microsoft.com>
> 
> When doing a 'checkout -b' do a full checkout including updating the working
> tree when doing the initial checkout.  This fixes the regression in behavior
> caused by fa655d8411 checkout: optimize "git checkout -b <new_branch>"
> 
> Signed-off-by: Ben Peart <benpeart@microsoft.com>
> ---
>  builtin/checkout.c         | 6 ++++++
>  t/t2018-checkout-branch.sh | 2 +-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 6fadf412e8..af6b5c8336 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -517,6 +517,12 @@ static int skip_merge_working_tree(const struct checkout_opts *opts,
>  	if (core_apply_sparse_checkout && !checkout_optimize_new_branch)
>  		return 0;
>  
> +	/*
> +	 * We must do the merge if this is the initial checkout
> +	 */
> +	if (is_cache_unborn())
> +		return 0;
> +
>  	/*
>  	 * We must do the merge if we are actually moving to a new commit.
>  	 */

This patch breaks 'checkout -b checkout.optimizeNewBranch interaction' in 't1090-sparse-checkout-scope.sh':

  + cp .git/info/sparse-checkout .git/info/sparse-checkout.bak
  + test_when_finished
                  mv -f .git/info/sparse-checkout.bak .git/info/sparse-checkout
                  git checkout master
  
  + test 0 = 0
  + test_cleanup={
                  mv -f .git/info/sparse-checkout.bak .git/info/sparse-checkout
                  git checkout master
  
                  } && (exit "$eval_ret"); eval_ret=$?; :
  + echo /b
  + git ls-files -t b
  + test S b = S b
  + git -c checkout.optimizeNewBranch=true checkout -b fast
  Switched to a new branch 'fast'
  + git ls-files -t b
  + test H b = S b
  error: last command exited with $?=1
  not ok 4 - checkout -b checkout.optimizeNewBranch interaction
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 of 30 in “Regression `git checkout $rev -b branch` while in a `--no-checkout` clone does not check out files”
  1. Anthony SottileJan 1, 2019
  2. Duy NguyenJan 2, 2019
  3. Anthony SottileJan 2, 2019
  4. Duy NguyenJan 3, 2019
  5. Junio C HamanoJan 3, 2019
  6. Anthony SottileJan 3, 2019
  7. Junio C HamanoJan 3, 2019
  8. Anthony SottileJan 3, 2019
  9. Ben PeartJan 16, 2019
  10. 0/2 Fix regression in checkout -bBen Peart, Jan 18, 2019
  11. 1/2 checkout: add test to demonstrate regression with checkout -b on initial commitBen Peart, Jan 18, 2019
  12. SZEDER GáborJan 18, 2019
  13. 2/2 checkout: fix regression in checkout -b on intitial checkoutBen Peart, Jan 18, 2019
  14. Junio C HamanoJan 18, 2019
  15. SZEDER GáborJan 19, 2019
  16. Junio C HamanoJan 19, 2019
  17. 0/2 Fix regression in checkout -bBen Peart, Jan 21, 2019
  18. 1/2 checkout: add test to demonstrate regression with checkout -b on initial commitBen Peart, Jan 21, 2019
  19. SZEDER GáborJan 23, 2019
  20. 2/2 checkout: fix regression in checkout -b on intitial checkoutBen Peart, Jan 21, 2019
  21. Johannes SchindelinJan 22, 2019
  22. Junio C HamanoJan 22, 2019
  23. Jeff KingJan 22, 2019
  24. Junio C HamanoJan 22, 2019
  25. Ben PeartJan 22, 2019
  26. Junio C HamanoJan 23, 2019
  27. 0/2 Fix regression in checkout -bBen Peart, Jan 23, 2019
  28. 1/2 checkout: add test demonstrating regression with checkout -b on initial commitBen Peart, Jan 23, 2019
  29. 2/2 checkout: fix regression in checkout -b on intitial checkoutBen Peart, Jan 23, 2019
  30. Junio C HamanoJan 23, 2019

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.