* [PATCH] bisect: allow `git bisect` to run from subdirectory
@ 2020-10-21 9:09 Sangeeta via GitGitGadget
2020-10-21 13:41 ` [PATCH][OUTREACHY] " Phillip Wood
0 siblings, 1 reply; 14+ messages in thread
From: Sangeeta via GitGitGadget @ 2020-10-21 9:09 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Sangeeta, Sangeeta Jain
From: Sangeeta Jain <sangunb09@gmail.com>
As `git rebase` was never prevented to run from subdirectory we shouldn't
prevent `git bisect` to run from subdirectories. This commit removes the
restriction on git bisect to run only from top level directory thereby
allowing it to run from any subdirectory.
Signed-off-by: Sangeeta Jain <sangunb09@gmail.com>
---
[Outreachy] bisect: allow git bisect to run from subdirectory
As git rebase was never prevented to run from subdirectory we shouldn't
prevent git bisect to run from subdirectories. This commit removes the
restriction on git bisect to run only from top level directory thereby
allowing it to run from any subdirectory.
Signed-off-by: Sangeeta Jain sangunb09@gmail.com [sangunb09@gmail.com]
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-765%2Fsangu09%2Fbisect_fix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-765/sangu09/bisect_fix-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/765
git-bisect.sh | 1 +
t/t6030-bisect-porcelain.sh | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/git-bisect.sh b/git-bisect.sh
index ea7e684ebb..9cd0fa0483 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -32,6 +32,7 @@ git bisect run <cmd>...
Please use "git help bisect" to get the full man page.'
OPTIONS_SPEC=
+SUBDIRECTORY_OK=Yes
. git-sh-setup
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index aa226381be..6b68cc01d0 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -49,6 +49,13 @@ test_expect_success 'bisect starts with only one bad' '
git bisect next
'
+test_expect_success 'bisect runs in a subdirectory' '
+ mkdir -p subdir &&
+ git -C subdir bisect start &&
+ git -C subdir bisect good &&
+ git -C subdir bisect reset
+'
+
test_expect_success 'bisect does not start with only one good' '
git bisect reset &&
git bisect start &&
base-commit: 69986e19ffcfb9af674ae5180689ab7bbf92ed28
--
gitgitgadget
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-21 9:09 [PATCH] bisect: allow `git bisect` to run from subdirectory Sangeeta via GitGitGadget
@ 2020-10-21 13:41 ` Phillip Wood
2020-10-21 16:20 ` Taylor Blau
2020-10-22 8:47 ` Johannes Schindelin
0 siblings, 2 replies; 14+ messages in thread
From: Phillip Wood @ 2020-10-21 13:41 UTC (permalink / raw)
To: Sangeeta via GitGitGadget, git; +Cc: Johannes Schindelin, Sangeeta
Hi Sangeeta
It's great to see you tackling another patch
On 21/10/2020 10:09, Sangeeta via GitGitGadget wrote:
> From: Sangeeta Jain <sangunb09@gmail.com>
>
> As `git rebase` was never prevented to run from subdirectory we shouldn't
> prevent `git bisect` to run from subdirectories.
I'm not sure it's relevant to bisect whether or not rebase can be run
from a subdirectory. What is important is that we want all commands to
be able to be run from a subdirectory unless there is a good reason not
to (and there isn't for bisect)
I'd recommend adding [Outreachy] to the beginning of the first line of
the commit message as well.
> This commit removes the
> restriction on git bisect to run only from top level directory thereby
> allowing it to run from any subdirectory.
>
> Signed-off-by: Sangeeta Jain <sangunb09@gmail.com>
> ---
> [Outreachy] bisect: allow git bisect to run from subdirectory
>
> As git rebase was never prevented to run from subdirectory we shouldn't
> prevent git bisect to run from subdirectories. This commit removes the
> restriction on git bisect to run only from top level directory thereby
> allowing it to run from any subdirectory.
>
> Signed-off-by: Sangeeta Jain sangunb09@gmail.com [sangunb09@gmail.com]
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-765%2Fsangu09%2Fbisect_fix-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-765/sangu09/bisect_fix-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/765
>
> git-bisect.sh | 1 +
> t/t6030-bisect-porcelain.sh | 7 +++++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/git-bisect.sh b/git-bisect.sh
> index ea7e684ebb..9cd0fa0483 100755
> --- a/git-bisect.sh
> +++ b/git-bisect.sh
> @@ -32,6 +32,7 @@ git bisect run <cmd>...
> Please use "git help bisect" to get the full man page.'
>
> OPTIONS_SPEC=
> +SUBDIRECTORY_OK=Yes
> . git-sh-setup
`git bisect run` takes an optional script that is run to determine if
the current commit is good or bad. If the script is given with a
relative path then we need to make sure it is invoked from the
subdirectory that `git bisect run` was started from. As far as I can see
git-bisect.sh does not change directory but it would be good to have a
test for `git bisect run <cmd>` from a subdirectory.
Best Wishes
Phillip
> _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index aa226381be..6b68cc01d0 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -49,6 +49,13 @@ test_expect_success 'bisect starts with only one bad' '
> git bisect next
> '
>
> +test_expect_success 'bisect runs in a subdirectory' '
> + mkdir -p subdir &&
> + git -C subdir bisect start &&
> + git -C subdir bisect good &&
> + git -C subdir bisect reset
> +'
> +
> test_expect_success 'bisect does not start with only one good' '
> git bisect reset &&
> git bisect start &&
>
> base-commit: 69986e19ffcfb9af674ae5180689ab7bbf92ed28
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
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:47 ` Johannes Schindelin
1 sibling, 1 reply; 14+ messages in thread
From: Taylor Blau @ 2020-10-21 16:20 UTC (permalink / raw)
To: phillip.wood
Cc: Sangeeta via GitGitGadget, git, Johannes Schindelin, Sangeeta
On Wed, Oct 21, 2020 at 02:41:39PM +0100, Phillip Wood wrote:
> Hi Sangeeta
>
> It's great to see you tackling another patch
>
> On 21/10/2020 10:09, Sangeeta via GitGitGadget wrote:
> > From: Sangeeta Jain <sangunb09@gmail.com>
> >
> > As `git rebase` was never prevented to run from subdirectory we shouldn't
> > prevent `git bisect` to run from subdirectories.
>
> I'm not sure it's relevant to bisect whether or not rebase can be run from a
> subdirectory. What is important is that we want all commands to be able to
> be run from a subdirectory unless there is a good reason not to (and there
> isn't for bisect)
I'm not sure that that's the case: Junio pointed out a while[1] ago that
we'd have to answer the question of "what happens if I'm in a
subdirectory that goes away during some point of the bisection?". I
think that you could probably find an answer to that question, but the
fact that there isn't an obvious one seems to indicate that we're going
down the wrong path.
I agree that it would be nice to run bisect from any directory, but it
may not be as easy as I'd hope.
[1]: https://lore.kernel.org/git/xmqqpnd359l6.fsf@gitster.c.googlers.com/
Thanks,
Taylor
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-21 16:20 ` Taylor Blau
@ 2020-10-21 19:53 ` Junio C Hamano
2020-10-22 8:52 ` Johannes Schindelin
0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2020-10-21 19:53 UTC (permalink / raw)
To: Taylor Blau
Cc: phillip.wood, Sangeeta via GitGitGadget, git, Johannes Schindelin,
Sangeeta
Taylor Blau <me@ttaylorr.com> writes:
> I'm not sure that that's the case: Junio pointed out a while[1] ago that
> we'd have to answer the question of "what happens if I'm in a
> subdirectory that goes away during some point of the bisection?". I
> think that you could probably find an answer to that question, but the
> fact that there isn't an obvious one seems to indicate that we're going
> down the wrong path.
>
> I agree that it would be nice to run bisect from any directory, but it
> may not be as easy as I'd hope.
True.
I would not mind all that much a single "git checkout ancient" that
makes the $cwd go away and confuse the user. But a bisect session
would jump around versions randomly (eh, logarithmically?) and you'd
end up switching out of a version in a non-existing $cwd to another
version that has the directory (created internally by mkdir(2)), and
I'm fairly certain that your phantom $cwd that is not connected to
any other filesystem entity and the directory that should be at the
same path in the newly checked-out version are different filesystem
entities. I'd rather not have to think about the interaction
between git and the system after that point.
Thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-21 13:41 ` [PATCH][OUTREACHY] " Phillip Wood
2020-10-21 16:20 ` Taylor Blau
@ 2020-10-22 8:47 ` Johannes Schindelin
2020-10-22 9:52 ` Phillip Wood
1 sibling, 1 reply; 14+ messages in thread
From: Johannes Schindelin @ 2020-10-22 8:47 UTC (permalink / raw)
To: phillip.wood; +Cc: Sangeeta via GitGitGadget, git, Sangeeta
Hi Phillip,
On Wed, 21 Oct 2020, Phillip Wood wrote:
> Hi Sangeeta
>
> It's great to see you tackling another patch
>
> On 21/10/2020 10:09, Sangeeta via GitGitGadget wrote:
> > From: Sangeeta Jain <sangunb09@gmail.com>
> >
> > As `git rebase` was never prevented to run from subdirectory we shouldn't
> > prevent `git bisect` to run from subdirectories.
>
> I'm not sure it's relevant to bisect whether or not rebase can be run from a
> subdirectory.
The relevance is this: _iff_ we want to prevent `git bisect` from running
in a subdirectory under the premise that that subdirectory might need to
be removed, then why don't we prevent `git rebase` from running in a
subdirectory when that command is equally likely to remove that
subdirectory?
> What is important is that we want all commands to be able to be run from
> a subdirectory unless there is a good reason not to (and there isn't for
> bisect)
There is a difference in quality here, though. If you run, say, `git
fetch` in a subdirectory, or `git commit` or `git show`, there is not the
same worry that that subdirectory will go away as with `git bisect`, `git
rebase`, `git switch`, `git pull` and other commands.
> I'd recommend adding [Outreachy] to the beginning of the first line of
> the commit message as well.
I am opposed to that. The fact that this comes in via Outreachy is
interesting at the moment, for reviewers, but not for posterity (i.e. in
the commit that will make it into the commit history).
> > diff --git a/git-bisect.sh b/git-bisect.sh
> > index ea7e684ebb..9cd0fa0483 100755
> > --- a/git-bisect.sh
> > +++ b/git-bisect.sh
> > @@ -32,6 +32,7 @@ git bisect run <cmd>...
> > Please use "git help bisect" to get the full man page.'
> >
> > OPTIONS_SPEC=
> > +SUBDIRECTORY_OK=Yes
> > . git-sh-setup
>
> `git bisect run` takes an optional script that is run to determine if the
> current commit is good or bad. If the script is given with a relative path
> then we need to make sure it is invoked from the subdirectory that `git bisect
> run` was started from. As far as I can see git-bisect.sh does not change
> directory but it would be good to have a test for `git bisect run <cmd>` from
> a subdirectory.
That's a very good point. We should first add a regression test for
exactly that use case, and then make sure that it passes.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-21 19:53 ` Junio C Hamano
@ 2020-10-22 8:52 ` Johannes Schindelin
2020-10-22 9:46 ` Phillip Wood
0 siblings, 1 reply; 14+ messages in thread
From: Johannes Schindelin @ 2020-10-22 8:52 UTC (permalink / raw)
To: Junio C Hamano
Cc: Taylor Blau, phillip.wood, Sangeeta via GitGitGadget, git,
Sangeeta
Hi Junio,
On Wed, 21 Oct 2020, Junio C Hamano wrote:
> Taylor Blau <me@ttaylorr.com> writes:
>
> > I'm not sure that that's the case: Junio pointed out a while[1] ago that
> > we'd have to answer the question of "what happens if I'm in a
> > subdirectory that goes away during some point of the bisection?". I
> > think that you could probably find an answer to that question, but the
> > fact that there isn't an obvious one seems to indicate that we're going
> > down the wrong path.
> >
> > I agree that it would be nice to run bisect from any directory, but it
> > may not be as easy as I'd hope.
>
> True.
>
> I would not mind all that much a single "git checkout ancient" that
> makes the $cwd go away and confuse the user. But a bisect session
> would jump around versions randomly (eh, logarithmically?) and you'd
> end up switching out of a version in a non-existing $cwd to another
> version that has the directory (created internally by mkdir(2)), and
> I'm fairly certain that your phantom $cwd that is not connected to
> any other filesystem entity and the directory that should be at the
> same path in the newly checked-out version are different filesystem
> entities. I'd rather not have to think about the interaction
> between git and the system after that point.
By that token, we should also prevent `git rebase` from running in a
subdirectory, but we don't.
Besides, this only becomes an issue when the directory becomes _empty_
(including untracked files) because we don't remove it otherwise.
I am actually more worried about bisecting between revisions that replace
the current subdirectory by a symlink or something.
But again, this is pretty much precisely the kind of scenario that we
_already_ allow running into with `git rebase`. So I see little point
refusing `git bisect` users to run in a subdirectory.
I know that _I_ often grumble after `git bisect start` fails, then try to
pull out the last remains of my patience and insert `-C ..` or `-C ../..`
between `git` and `bisect` and _still_ get what I want, all while shaking
my imaginary fist at `git bisect` for forcing me to type those extra
keystrokes.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-22 8:52 ` Johannes Schindelin
@ 2020-10-22 9:46 ` Phillip Wood
2020-10-22 16:52 ` Junio C Hamano
0 siblings, 1 reply; 14+ messages in thread
From: Phillip Wood @ 2020-10-22 9:46 UTC (permalink / raw)
To: Johannes Schindelin, Junio C Hamano
Cc: Taylor Blau, phillip.wood, Sangeeta via GitGitGadget, git,
Sangeeta
On 22/10/2020 09:52, Johannes Schindelin wrote:
> Hi Junio,
>
> On Wed, 21 Oct 2020, Junio C Hamano wrote:
>
>> Taylor Blau <me@ttaylorr.com> writes:
>>
>>> I'm not sure that that's the case: Junio pointed out a while[1] ago that
>>> we'd have to answer the question of "what happens if I'm in a
>>> subdirectory that goes away during some point of the bisection?". I
>>> think that you could probably find an answer to that question, but the
>>> fact that there isn't an obvious one seems to indicate that we're going
>>> down the wrong path.
>>>
>>> I agree that it would be nice to run bisect from any directory, but it
>>> may not be as easy as I'd hope.
>>
>> True.
>>
>> I would not mind all that much a single "git checkout ancient" that
>> makes the $cwd go away and confuse the user. But a bisect session
>> would jump around versions randomly (eh, logarithmically?) and you'd
>> end up switching out of a version in a non-existing $cwd to another
>> version that has the directory (created internally by mkdir(2)), and
>> I'm fairly certain that your phantom $cwd that is not connected to
>> any other filesystem entity and the directory that should be at the
>> same path in the newly checked-out version are different filesystem
>> entities. I'd rather not have to think about the interaction
>> between git and the system after that point.
>
> By that token, we should also prevent `git rebase` from running in a
> subdirectory, but we don't.
>
> Besides, this only becomes an issue when the directory becomes _empty_
> (including untracked files) because we don't remove it otherwise.
>
> I am actually more worried about bisecting between revisions that replace
> the current subdirectory by a symlink or something.
>
> But again, this is pretty much precisely the kind of scenario that we
> _already_ allow running into with `git rebase`. So I see little point
> refusing `git bisect` users to run in a subdirectory.
Except rebase always runs exec commands from the repository root and
assumes that any relative paths are relative to that directory rather
than the one it was started in.
cd t &&
cat >script <<\EOF &&
#!/bin/sh
exec pwd
EOF
chmod u+x script &&
git rebase -x ./script HEAD^
gives
Executing: ./script
fatal: cannot run ./script: No such file or directory
warning: execution failed: ./script
You can fix the problem, and then run
git rebase --continue
git rebase -x pwd HEAD^
shows
/home/phil/src/git
when run from /home/phil/src/git/t
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
Best wishes
Phillip
> I know that _I_ often grumble after `git bisect start` fails, then try to
> pull out the last remains of my patience and insert `-C ..` or `-C ../..`
> between `git` and `bisect` and _still_ get what I want, all while shaking
> my imaginary fist at `git bisect` for forcing me to type those extra
> keystrokes.
>
> Ciao,
> Dscho
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-22 8:47 ` Johannes Schindelin
@ 2020-10-22 9:52 ` Phillip Wood
2020-10-22 17:04 ` Junio C Hamano
0 siblings, 1 reply; 14+ messages in thread
From: Phillip Wood @ 2020-10-22 9:52 UTC (permalink / raw)
To: Johannes Schindelin, phillip.wood
Cc: Sangeeta via GitGitGadget, git, Sangeeta
Hi Dscho and Sangeeta
On 22/10/2020 09:47, Johannes Schindelin wrote:
> Hi Phillip,
>
> On Wed, 21 Oct 2020, Phillip Wood wrote:
>
>> Hi Sangeeta
>>
>> It's great to see you tackling another patch
>>
>> On 21/10/2020 10:09, Sangeeta via GitGitGadget wrote:
>>> From: Sangeeta Jain <sangunb09@gmail.com>
>>>
>>> As `git rebase` was never prevented to run from subdirectory we shouldn't
>>> prevent `git bisect` to run from subdirectories.
>>
>> I'm not sure it's relevant to bisect whether or not rebase can be run from a
>> subdirectory.
>
> The relevance is this: _iff_ we want to prevent `git bisect` from running
> in a subdirectory under the premise that that subdirectory might need to
> be removed, then why don't we prevent `git rebase` from running in a
> subdirectory when that command is equally likely to remove that
> subdirectory?
That's a good point, I'd completely missed the analogy with `rebase --exec`
>> What is important is that we want all commands to be able to be run from
>> a subdirectory unless there is a good reason not to (and there isn't for
>> bisect)
>
> There is a difference in quality here, though. If you run, say, `git
> fetch` in a subdirectory, or `git commit` or `git show`, there is not the
> same worry that that subdirectory will go away as with `git bisect`, `git
> rebase`, `git switch`, `git pull` and other commands.
>
>> I'd recommend adding [Outreachy] to the beginning of the first line of
>> the commit message as well.
>
> I am opposed to that. The fact that this comes in via Outreachy is
> interesting at the moment, for reviewers, but not for posterity (i.e. in
> the commit that will make it into the commit history).
I thought `am` would strip [Outreachy] the same way as it strips [PATCH]
>>> diff --git a/git-bisect.sh b/git-bisect.sh
>>> index ea7e684ebb..9cd0fa0483 100755
>>> --- a/git-bisect.sh
>>> +++ b/git-bisect.sh
>>> @@ -32,6 +32,7 @@ git bisect run <cmd>...
>>> Please use "git help bisect" to get the full man page.'
>>>
>>> OPTIONS_SPEC=
>>> +SUBDIRECTORY_OK=Yes
>>> . git-sh-setup
>>
>> `git bisect run` takes an optional script that is run to determine if the
>> current commit is good or bad. If the script is given with a relative path
>> then we need to make sure it is invoked from the subdirectory that `git bisect
>> run` was started from. As far as I can see git-bisect.sh does not change
>> directory but it would be good to have a test for `git bisect run <cmd>` from
>> a subdirectory.
>
> That's a very good point. We should first add a regression test for
> exactly that use case, and then make sure that it passes.
Though I'm now wondering if we should be running the command from the
repository root directory like rebase[1]
Best Wishes
Phillip
[1]
https://lore.kernel.org/git/cfe33eef-974d-8ff9-ebb4-d1153abd497c@gmail.com
> Ciao,
> Dscho
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-22 9:46 ` Phillip Wood
@ 2020-10-22 16:52 ` Junio C Hamano
2020-10-23 10:59 ` Sangeeta NB
2020-10-23 15:18 ` Phillip Wood
0 siblings, 2 replies; 14+ messages in thread
From: Junio C Hamano @ 2020-10-22 16:52 UTC (permalink / raw)
To: Phillip Wood
Cc: Johannes Schindelin, Taylor Blau, phillip.wood,
Sangeeta via GitGitGadget, git, Sangeeta
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-22 9:52 ` Phillip Wood
@ 2020-10-22 17:04 ` Junio C Hamano
2020-10-23 8:37 ` Johannes Schindelin
0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2020-10-22 17:04 UTC (permalink / raw)
To: Phillip Wood
Cc: Johannes Schindelin, phillip.wood, Sangeeta via GitGitGadget, git,
Sangeeta
Phillip Wood <phillip.wood123@gmail.com> writes:
>> The relevance is this: _iff_ we want to prevent `git bisect` from
>> running
>> in a subdirectory under the premise that that subdirectory might need to
>> be removed, then why don't we prevent `git rebase` from running in a
>> subdirectory when that command is equally likely to remove that
>> subdirectory?
>
> That's a good point, I'd completely missed the analogy with `rebase --exec`
I concur. Perhaps we should make rebase a bit more careful.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-22 17:04 ` Junio C Hamano
@ 2020-10-23 8:37 ` Johannes Schindelin
0 siblings, 0 replies; 14+ messages in thread
From: Johannes Schindelin @ 2020-10-23 8:37 UTC (permalink / raw)
To: Junio C Hamano
Cc: Phillip Wood, phillip.wood, Sangeeta via GitGitGadget, git,
Sangeeta
Hi Junio,
On Thu, 22 Oct 2020, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
> >> The relevance is this: _iff_ we want to prevent `git bisect` from
> >> running
> >> in a subdirectory under the premise that that subdirectory might need to
> >> be removed, then why don't we prevent `git rebase` from running in a
> >> subdirectory when that command is equally likely to remove that
> >> subdirectory?
> >
> > That's a good point, I'd completely missed the analogy with `rebase --exec`
>
> I concur. Perhaps we should make rebase a bit more careful.
That might be a rabbit hole that's a little too deep. If we want to make
rebase a bit more careful, we then also must make `git -C ..` more
careful. And `git -C ../..`...
I am fairly certain that I don't want to go there.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-22 16:52 ` Junio C Hamano
@ 2020-10-23 10:59 ` Sangeeta NB
2020-10-23 15:43 ` Junio C Hamano
2020-10-23 15:18 ` Phillip Wood
1 sibling, 1 reply; 14+ messages in thread
From: Sangeeta NB @ 2020-10-23 10:59 UTC (permalink / raw)
To: Junio C Hamano
Cc: Phillip Wood, Johannes Schindelin, Taylor Blau, phillip.wood,
Sangeeta via GitGitGadget, Git List
Hey everyone,
Sorry for participating in the discussions so late. I thought I need
to have enough knowledge first before participating.
>
> 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?
>
Yes, I agree. We need to make some changes in `git rebase` to make it
work from the subdirectory, but that doesn't mean that we should
completely restrict it from running in the subdirectory, and the same
follows for `git bisect`.
What I think that we should allow `git bisect` from any subdirectory.
We can add some warnings in case if there's some error while bisecting
from a subdirectory in the same way by which we handle the errors in
`git rebase` and let the user decide whether he still wants to
continue bisecting from that subdirectory or abort it and run it from
the top-level directory.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-22 16:52 ` Junio C Hamano
2020-10-23 10:59 ` Sangeeta NB
@ 2020-10-23 15:18 ` Phillip Wood
1 sibling, 0 replies; 14+ messages in thread
From: Phillip Wood @ 2020-10-23 15:18 UTC (permalink / raw)
To: Junio C Hamano
Cc: Johannes Schindelin, Taylor Blau, phillip.wood,
Sangeeta via GitGitGadget, git, Sangeeta
Hi Junio
On 22/10/2020 17:52, Junio C Hamano wrote:
> 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.
Thanks for the demonstration. There are several other commands
(checkout, merge, cherry-pick, reset --hard, revert and maybe apply and
am?) that can remove the current working directory of the shell that
they are run from when they are invoked from a subdirectory. Rebase and
cherry-pick/revert differ from checkout and merge in that they can
potentially delete and then recreate the directory they are invoked from
which adds another layer of confusion but having a checkout remove the
directory it is invoked from isn't great.
One way to avoid it would be to stop all of these commands from being
run from a subdirectory and also object if they are run as anything like
`git -C .. <cmd>` but that would be very restrictive.
Thinking out loud maybe another possibility would be to error out if the
command would remove the directory git was invoked from. I've not looked
into it but wonder if these cases could be covered by a checks in
unpack_trees() and apply.c but I don't know how realistic that is. (I've
a feeling Elijah mentioned his ort plans don't use unpack_trees() which
would complicate things)
All in all I'm not sure rebase is that much worse than checkout or merge
when it comes to removing the directory it is invoked from. If this is
something we care about a general solution might be better than just
stopping rebase and bisect from being run from a subdirectory.
Best Wishes
Phillip
> #!/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
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH][OUTREACHY] bisect: allow `git bisect` to run from subdirectory
2020-10-23 10:59 ` Sangeeta NB
@ 2020-10-23 15:43 ` Junio C Hamano
0 siblings, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2020-10-23 15:43 UTC (permalink / raw)
To: Sangeeta NB
Cc: Phillip Wood, Johannes Schindelin, Taylor Blau, phillip.wood,
Sangeeta via GitGitGadget, Git List
Sangeeta NB <sangunb09@gmail.com> writes:
> Yes, I agree. We need to make some changes in `git rebase` to make it
> work from the subdirectory, but that doesn't mean that we should
> completely restrict it from running in the subdirectory, and the same
> follows for `git bisect`.
You actually don't have to make "bisect" work from the subdirectory.
You instead can detect the case where your $cwd may be made to
disappear, and allow "git bisect" to continue if you are certain
that you are not in the funny situation. You need to protect the
user from funny situation by refusing to run from a subdirectory
only when needed.
Besides, as Phillip mentioned, there is a big difference between two
commands, isn't it?
"git rebase" would ask for help to the end-user by returning the
control when anything goes wrong (e.g. it may not be able to replay
a commit while the user is sitting in a directory that has already
gone), but "git bisect run" would just interpret any failure, not
just the ones that are caused by genuine test failure but caused by
$cwd going away, as "we saw a bad revision". It would cause a lot
of wasted cycles, instead of immediately stopping when there is
trouble. So the first thing that has to happen if we want to allow
"bisect" to run from anywhere is to teach it to detect when the $cwd
went away, and stop to give control back to the user to deal with
the situation (it might be the matter of "cd /path/to/top" at that
point), instead of blindly continuing. Only after that is in place,
we can safely allow it to start from a subdirectory.
Thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-10-23 15:48 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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).