Re: Regression `git checkout $rev -b branch` while in a `--no-checkout` clone does not check out files
- Date: Wed, 2 Jan 2019 08:18:02 -0800
- From: Anthony Sottile <asottile@xxxxxxxxx>
- Subject: Re: Regression `git checkout $rev -b branch` while in a `--no-checkout` clone does not check out files
On Wed, Jan 2, 2019 at 3:08 AM Duy Nguyen <pclouds@xxxxxxxxx> wrote:
> On Wed, Jan 2, 2019 at 6:36 AM Anthony Sottile <asottile@xxxxxxxxx> 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).
heated a small room but here's the results of the bisect!
fa655d8411cc2d7ffcf898e53a1493c737d7de68 is the first bad commit
Author: Ben Peart <Ben.Peart@xxxxxxxxxxxxx>
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
For comparison, running "git checkout -b <new_branch>" on a large
14.6 seconds - without this patch
0.3 seconds - with this patch
Signed-off-by: Ben Peart <Ben.Peart@xxxxxxxxxxxxx>
Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
: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:
set -euxo pipefail
rm -rf "$PWD/prefix"
make prefix="$PWD/prefix" -j8 install
rm -rf src dest
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
git bisect begin
git bisect bad HEAD
git bisect good v2.17.1
git bisect run ./bisect.sh