git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Anthony Sottile <asottile@umich.edu>, Ben Peart <peartben@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Regression `git checkout $rev -b branch` while in a `--no-checkout` clone does not check out files
Date: Thu, 3 Jan 2019 17:04:47 +0700	[thread overview]
Message-ID: <CACsJy8C=O=ZDvD0ReSJOyAsNDEb5Yz-iFvs7oV5zAXaFf-dw5g@mail.gmail.com> (raw)
In-Reply-To: <CA+dzEB=TPxng4YBC4Vfh=ZcctAzRQ+drJ3y2sXwP=JXf+UweSA@mail.gmail.com>

On Wed, Jan 2, 2019 at 11:18 PM Anthony Sottile <asottile@umich.edu> wrote:
> 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>"

I did test this commit before and could not reproduce. But one thing I
did not notice is I set sparsecheckout on by default. which always
forces this optimization off Turning off sparse checkout, I could
indeed reproduce.

I plan to revert this commit anyway when the new command "git
switch-branch" comes. The optimization will be unconditionally in the
new command without this hack and users are encouraged to use that one
instead of "git checkout".

Meanwhile, let's see if Ben wants to fix this or revert it.

>
>     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



-- 
Duy

  reply	other threads:[~2019-01-03 10:05 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01 23:17 Regression `git checkout $rev -b branch` while in a `--no-checkout` clone does not check out files Anthony Sottile
2019-01-02 11:08 ` Duy Nguyen
2019-01-02 16:18   ` Anthony Sottile
2019-01-03 10:04     ` Duy Nguyen [this message]
2019-01-03 20:25       ` Junio C Hamano
2019-01-03 20:35         ` Anthony Sottile
2019-01-03 21:51           ` Junio C Hamano
2019-01-03 22:05             ` Anthony Sottile
2019-01-16 14:39               ` Ben Peart
2019-01-18 18:55 ` [PATCH v1 0/2] Fix regression in checkout -b Ben Peart
2019-01-18 18:55   ` [PATCH v1 1/2] checkout: add test to demonstrate regression with checkout -b on initial commit Ben Peart
2019-01-18 19:23     ` SZEDER Gábor
2019-01-18 18:55   ` [PATCH v1 2/2] checkout: fix regression in checkout -b on intitial checkout Ben Peart
2019-01-18 20:00     ` Junio C Hamano
2019-01-19  0:52     ` SZEDER Gábor
2019-01-19  1:26   ` [PATCH v1 0/2] Fix regression in checkout -b Junio C Hamano
2019-01-21 19:50   ` [PATCH v2 " Ben Peart
2019-01-21 19:50     ` [PATCH v2 1/2] checkout: add test to demonstrate regression with checkout -b on initial commit Ben Peart
2019-01-23 17:57       ` SZEDER Gábor
2019-01-21 19:50     ` [PATCH v2 2/2] checkout: fix regression in checkout -b on intitial checkout Ben Peart
2019-01-22 14:35       ` Johannes Schindelin
2019-01-22 18:42         ` Junio C Hamano
2019-01-22 18:49         ` Jeff King
2019-01-22 18:54     ` [PATCH v2 0/2] Fix regression in checkout -b Junio C Hamano
2019-01-22 19:31       ` Ben Peart
2019-01-23 19:14         ` Junio C Hamano
2019-01-23 20:01   ` [PATCH v3 " Ben Peart
2019-01-23 20:02     ` [PATCH v3 1/2] checkout: add test demonstrating regression with checkout -b on initial commit Ben Peart
2019-01-23 20:02     ` [PATCH v3 2/2] checkout: fix regression in checkout -b on intitial checkout Ben Peart
2019-01-23 21:23     ` [PATCH v3 0/2] Fix regression in checkout -b Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CACsJy8C=O=ZDvD0ReSJOyAsNDEb5Yz-iFvs7oV5zAXaFf-dw5g@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=asottile@umich.edu \
    --cc=git@vger.kernel.org \
    --cc=peartben@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).