git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Taylor Blau <me@ttaylorr.com>,
	phillip.wood@dunelm.org.uk,
	Sangeeta via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Sangeeta <sangunb09@gmail.com>
Subject: Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
Date: Thu, 22 Oct 2020 09:52:44 -0700	[thread overview]
Message-ID: <xmqq7drinqxv.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <cfe33eef-974d-8ff9-ebb4-d1153abd497c@gmail.com> (Phillip Wood's message of "Thu, 22 Oct 2020 10:46:56 +0100")

Phillip Wood <phillip.wood123@gmail.com> writes:

> I think both bisect and rebase should be documented as running
> commands from the repository root as this is what rebase does and it
> gets around the missing directory problem.
>
> I'm not sure rebase is doing the right thing with a relative path
> though. My feeling is it would be less suprising to resolve relative 
> paths to the directory where the bisect/rebase is started and store
> the absolute path. The script may disappear while rebasing but that
> can happen now if the user points us to a script in a directory that 
> disappears while we're rebasing

If a step in the rebase sequence makes a directory disappear (or
turns a directory into a file), and the command given by -x is in
the directory (it is immaterial if it is given as relative or full
pathname from the command line), hopefully the step of the rebase
sequence that would lose the directory would error out, in order to
prevent an untracked but not ignored file from getting clobbered.

Even before speculating such an "advanced" mode of operation, do we
know that rebasing a history that makes a directory disappear and
reappear work?

For example, if there is a history like this:

    - commit #0: an empty tree
    - commit #1: adds a file D/F
    - commit #2: moves the file D/F to F (i.e. the toplevel)
    - commit #3: moves the file F to D (i.e. D becomes a file)
    - commit #4: moves the file D to E
    - commit #5: moves the file E to D/E (i.e. D becomes a directory again)

does it do what expect it to do if we replay the history c0..c5 on
top of a comit that records an empty tree if we start the rebase
in an empty directory D?

Here is what I tried in an empty directory, and the last "ls -la"
shows an empty directory, even if you try "ls -la D" from a separate
shell after everything is done, you'd see a file D/E there.  If a
platform exists that does not allow removing a directory that is the
$cwd of any process, I would not be surprised if the whole thing
failed in a mysterious (to the end user) way.

#!/bin/sh
test -d .git && exit ;# safety
rm -fr D E F
git init

git commit --allow-empty -m 'an empty tree'
git tag commit0

mkdir D && >D/F && git add D/F
git commit -m 'add a file D/F'

git mv D/F F && git commit -m 'move D/F to F'
rm -rf D

git mv F D && git commit -m 'move F to D'

git mv D E && git commit -m 'move D to E'

mkdir D && git mv E D/E && git commit -m 'move E to D/E'

git tag commit5

echo history made

git checkout --orphan rebuilt
git rm -r -f .
git commit --allow-empty -m 'another empty tree'

mkdir D
cd D

git rebase --onto HEAD commit0 commit5^0
ls -la

  reply	other threads:[~2020-10-22 16:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-21  9:09 [PATCH] bisect: allow `git bisect` to run from subdirectory Sangeeta via GitGitGadget
2020-10-21 13:41 ` [PATCH][OUTREACHY] " Phillip Wood
2020-10-21 16:20   ` Taylor Blau
2020-10-21 19:53     ` Junio C Hamano
2020-10-22  8:52       ` Johannes Schindelin
2020-10-22  9:46         ` Phillip Wood
2020-10-22 16:52           ` Junio C Hamano [this message]
2020-10-23 10:59             ` Sangeeta NB
2020-10-23 15:43               ` Junio C Hamano
2020-10-23 15:18             ` Phillip Wood
2020-10-22  8:47   ` Johannes Schindelin
2020-10-22  9:52     ` Phillip Wood
2020-10-22 17:04       ` Junio C Hamano
2020-10-23  8:37         ` Johannes Schindelin

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

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

  git send-email \
    --in-reply-to=xmqq7drinqxv.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=phillip.wood123@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=sangunb09@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.
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 NNTP newsgroup(s).