Thread (1 message) 1 message, 1 author, 2020-03-23

Re: [PATCH] bisect: remove root directory restriction for git bisect

From: Junio C Hamano <hidden>
Date: 2020-03-23 16:18:02

SZEDER Gábor [off-list ref] writes:
On Sun, Mar 22, 2020 at 09:15:47AM +0000, Sheikh hamza via GitGitGadget wrote:
quoted
From: sheikh hamza <redacted>

    according to the open issue #486
What issue #486?  Where?  The Git project doesn't use issues.
quoted
the git bisect
    command should be able to run from inside any
    subdirectory
Why should 'git bisect' be able to run from inside any subdirectory
(of the working tree, I presume)?

In particular, what happens, if someone starts 'git bisect' from
within 'subdir/', and 'git bisect' then checks out an old commit,
where said 'subdir/' didn't exist?  What happens, if the user runs
'git bisect run ./script' from within 'subdir/', and that 'subdir/'
doesn't exist in that old commit?  What happens, if 'subdir' does
exists in that old commit, but it's a file, not a directory?  What
happens, if all this is on Windows?
Hmm, I am of two minds.  Most certainly, the bisection would break
when the directory cannot be removed, and if it can be, then $pwd
would become in a weird state and the iteration with the bisect
machinery (be it interactive test before saying "bisect good/bad",
or the command execution during "bisect run") would fail in a
strange and unpredictable ways.

So from that perspective, it does make sense to forbid running "git
bisect" from a subdirectory, and we should probably do so on the
same principle for "git checkout", "git pull" and many other things.

But even then, it would not probably be foolproof.  Another process
that the end-user is not even aware of its execution (e.g. virus
scanners?) may have a file open in the subdirectory on a filesystem
that does not allow directories to be removed while there is an open
file descriptor on a file it contains, and would cause the command
to fail in a similar way.

So it probably is being too draconian to forbid these commands (not
just "git bisect") from being run in a subdirectory for no good
reason (i.e. being strict is not helping us much).  What would help
is to make sure we fail in an understandable way (i.e. "cannot
remove directory /foo/bar/boz, so checkout of version v1.2.3 failed"
is clearly conveyed to the end user, which we may be already doing
in which case that is wonderful).
quoted
and in the same disscusion "dscho"
    gave the directions and those directions lead me
    the fix of adding SUBDIRECTORY_OK=Yes on L#34
    before sourcing git-sh-setup that made it work as
    in git-sh-setup there was a check on SUBDIRECTORY_OK
    that prevents it to run in sub directories if it is not
    set to "ok" as this file was also sourced in other commands
    that are required to only run from root one of such scripts
    is git-filter-branch
Please don't indent the commit message and use punctuation to make it
more readable.
This is a good point.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help