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

Re: Regression `git checkout $rev -b branch` while in a `--no-checkout` clone does not check out files

From
Anthony Sottile <asottile@umich.edu>
Date
Jan 2, 2019, 16:18 UTC
Message-ID
<CA+dzEB=TPxng4YBC4Vfh=ZcctAzRQ+drJ3y2sXwP=JXf+UweSA@mail.gmail.com>
In-Reply-To
<CACsJy8B=-V7XY+=5pwwSzg8B6Goa55DPPU3ErgjOEsSJVni18Q@mail.gmail.com>
On Wed, Jan 2, 2019 at 3:08 AM Duy Nguyen <pclouds@gmail.com> wrote:
Show 13 quoted lines
>
> On Wed, Jan 2, 2019 at 6:36 AM Anthony Sottile <asottile@umich.edu> wrote:
> >
> > Here's a simple regression test -- haven't had time to bisect this
>
> I can't reproduce with either 2.20.0, 2.20.1 or 'master'. It would be
> great if you could bisect this.
>
> There are no suspicious commits from 2.27.1 touching
> builtin/checkout.c. Though there are some more changes in
> unpack-trees.c that might cause this (big wild guess).
> --
> Duy
heated a small room but here's the results of the bisect!
fa655d8411cc2d7ffcf898e53a1493c737d7de68 is the first bad commit
commit fa655d8411cc2d7ffcf898e53a1493c737d7de68
Author: Ben Peart <Ben.Peart@microsoft.com>
Date:   Thu Aug 16 18:27:11 2018 +0000
    checkout: optimize "git checkout -b <new_branch>"
    Skip merging the commit, updating the index and working directory if and
    only if we are creating a new branch via "git checkout -b <new_branch>."
    Any other checkout options will still go through the former code path.
    If sparse_checkout is on, require the user to manually opt in to this
    optimzed behavior by setting the config setting checkout.optimizeNewBranch
    to true as we will no longer update the skip-worktree bit in the index, nor
    add/remove files in the working directory to reflect the current sparse
    checkout settings.
    For comparison, running "git checkout -b <new_branch>" on a large
repo takes:
    14.6 seconds - without this patch
    0.3 seconds - with this patch
    Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>

:040000 040000 817bfb8ef961545a554005d42967b5ab7cfdb041 e57e576d0d4fb7f25c12a5dcc7651ef6698e961b M Documentation :040000 040000 c089f91f4532caa2a17e4f10a1a7ed3aa5d2023c 7cf16a0aa288f898a880ffefe82ee7506b83bef4 M builtin :040000 040000 adfdb05964a692e03ee07d2e43841f6304d996bd 8681416093802b9051599ebea8f63f5a45968e6f M t bisect run success

Here's the script and invocations:

``` #!/usr/bin/env bash set -euxo pipefail

rm -rf "$PWD/prefix" make prefix="$PWD/prefix" -j8 install export PATH="$PWD/prefix/bin:$PATH"

rm -rf src dest
git --version

git init src echo hi > src/a git -C src add . git -C src commit -m "initial commit" rev="$(git -C src rev-parse HEAD)"

git clone --no-checkout src dest git -C dest checkout "$rev" -b branch test -f dest/a

: 'SUCCESS!' ```

``` git bisect begin git bisect bad HEAD git bisect good v2.17.1 git bisect run ./bisect.sh ```

Anthony
Previous: Duy NguyenNext: Duy Nguyen
Message 3 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.