{"thread":{"id":"53055","subject":"[PATCH] bisect: remove root directory restriction for git bisect","startedAt":"2020-03-22T09:15:52Z","lastAt":"2020-03-23T16:18:02Z","messageCount":7,"participants":["Sheikh hamza via GitGitGadget","SZEDER Gábor","sheikh hamza","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"393695","messageId":"pull.736.git.git.1584868547682.gitgitgadget@gmail.com","threadId":"53055","inReplyTo":null,"subject":"[PATCH] bisect: remove root directory restriction for git bisect","fromName":"Sheikh hamza via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-03-22T09:15:47Z","receivedAt":"2020-03-22T09:15:52Z","isPatch":true,"sender":{"key":"name:Sheikh hamza","avatar":null},"body":"From: sheikh hamza <sheikhhamza012@gmail.com>\n\n    according to the open issue #486 the git bisect\n    command should be able to run from inside any\n    subdirectory and in the same disscusion \"dscho\"\n    gave the directions and those directions lead me\n    the fix of adding SUBDIRECTORY_OK=Yes on L#34\n    before sourcing git-sh-setup that made it work as\n    in git-sh-setup there was a check on SUBDIRECTORY_OK\n    that prevents it to run in sub directories if it is not\n    set to \"ok\" as this file was also sourced in other commands\n    that are required to only run from root one of such scripts\n    is git-filter-branch\n\nSigned-off-by: sheikh hamza <sheikhhamza012@gmail.com>\n---\n    bisect: remove root directory restriction for git bisect\n    \n    according to the open issue #486 the git bisect\n    command should be able to run from inside any\n    subdirectory and in the same disscusion \"dscho\"\n    gave the directions and those directions lead me\n    the fix of adding SUBDIRECTORY_OK=Yes on L#34\n    before sourcing git-sh-setup that made it work as\n    in git-sh-setup there was a check on SUBDIRECTORY_OK\n    that prevents it to run in sub directories if it is not\n    set to \"ok\" as this file was also sourced in other commands\n    that are required to only run from root one of such scripts\n    is git-filter-branch\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-736%2Fsheikhhamza012%2Fbisect_subdirectory_fix-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-736/sheikhhamza012/bisect_subdirectory_fix-v1\nPull-Request: https://github.com/git/git/pull/736\n\n git-bisect.sh            | 1 +\n t/perf/bisect_regression | 6 ++----\n 2 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex efee12b8b1e..8c1da200e41 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -31,6 +31,7 @@ git bisect run <cmd>...\n \n Please use \"git help bisect\" to get the full man page.'\n \n+SUBDIRECTORY_OK=Yes\n OPTIONS_SPEC=\n . git-sh-setup\n \ndiff --git a/t/perf/bisect_regression b/t/perf/bisect_regression\nindex ce47e1662a9..d6b96f49e46 100755\n--- a/t/perf/bisect_regression\n+++ b/t/perf/bisect_regression\n@@ -57,11 +57,9 @@ tmpdir=$(mktemp -d -t bisect_regression_XXXXXX) || die \"Failed to create temp di\n echo \"$oldtime\" >\"$tmpdir/oldtime\" || die \"Failed to write to '$tmpdir/oldtime'\"\n echo \"$newtime\" >\"$tmpdir/newtime\" || die \"Failed to write to '$tmpdir/newtime'\"\n \n-# Bisecting must be performed from the top level directory (even with --no-checkout)\n-(\n-\ttoplevel_dir=$(git rev-parse --show-toplevel) || die \"Failed to find top level directory\"\n-\tcd \"$toplevel_dir\" || die \"Failed to cd into top level directory '$toplevel_dir'\"\n \n+(\n+\t \n \tgit bisect start --no-checkout \"$newrev\" \"$oldrev\" || die \"Failed to start bisecting\"\n \n \tgit bisect run t/perf/bisect_run_script \"$test_script\" \"$test_number\" \"$tmpdir\"\n\nbase-commit: 98cedd0233ee88e69711f79d1126b6bd772ff5bd\n-- \ngitgitgadget\n"},{"id":"393699","messageId":"20200322104826.GB2224@szeder.dev","threadId":"53055","inReplyTo":"pull.736.git.git.1584868547682.gitgitgadget@gmail.com","subject":"Re: [PATCH] bisect: remove root directory restriction for git bisect","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2020-03-22T10:48:26Z","receivedAt":"2020-03-22T10:48:33Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Sun, Mar 22, 2020 at 09:15:47AM +0000, Sheikh hamza via GitGitGadget wrote:\n> From: sheikh hamza <sheikhhamza012@gmail.com>\n> \n>     according to the open issue #486\n\nWhat issue #486?  Where?  The Git project doesn't use issues.\n\n> the git bisect\n>     command should be able to run from inside any\n>     subdirectory\n\nWhy should 'git bisect' be able to run from inside any subdirectory\n(of the working tree, I presume)?\n\nIn particular, what happens, if someone starts 'git bisect' from\nwithin 'subdir/', and 'git bisect' then checks out an old commit,\nwhere said 'subdir/' didn't exist?  What happens, if the user runs\n'git bisect run ./script' from within 'subdir/', and that 'subdir/'\ndoesn't exist in that old commit?  What happens, if 'subdir' does\nexists in that old commit, but it's a file, not a directory?  What\nhappens, if all this is on Windows?\n\n\n> and in the same disscusion \"dscho\"\n>     gave the directions and those directions lead me\n>     the fix of adding SUBDIRECTORY_OK=Yes on L#34\n>     before sourcing git-sh-setup that made it work as\n>     in git-sh-setup there was a check on SUBDIRECTORY_OK\n>     that prevents it to run in sub directories if it is not\n>     set to \"ok\" as this file was also sourced in other commands\n>     that are required to only run from root one of such scripts\n>     is git-filter-branch\n\nPlease don't indent the commit message and use punctuation to make it\nmore readable.\n\n> \n> Signed-off-by: sheikh hamza <sheikhhamza012@gmail.com>\n> ---\n>     bisect: remove root directory restriction for git bisect\n>     \n>     according to the open issue #486 the git bisect\n>     command should be able to run from inside any\n>     subdirectory and in the same disscusion \"dscho\"\n>     gave the directions and those directions lead me\n>     the fix of adding SUBDIRECTORY_OK=Yes on L#34\n>     before sourcing git-sh-setup that made it work as\n>     in git-sh-setup there was a check on SUBDIRECTORY_OK\n>     that prevents it to run in sub directories if it is not\n>     set to \"ok\" as this file was also sourced in other commands\n>     that are required to only run from root one of such scripts\n>     is git-filter-branch\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-736%2Fsheikhhamza012%2Fbisect_subdirectory_fix-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-736/sheikhhamza012/bisect_subdirectory_fix-v1\n> Pull-Request: https://github.com/git/git/pull/736\n> \n>  git-bisect.sh            | 1 +\n>  t/perf/bisect_regression | 6 ++----\n>  2 files changed, 3 insertions(+), 4 deletions(-)\n> \n> diff --git a/git-bisect.sh b/git-bisect.sh\n> index efee12b8b1e..8c1da200e41 100755\n> --- a/git-bisect.sh\n> +++ b/git-bisect.sh\n> @@ -31,6 +31,7 @@ git bisect run <cmd>...\n>  \n>  Please use \"git help bisect\" to get the full man page.'\n>  \n> +SUBDIRECTORY_OK=Yes\n>  OPTIONS_SPEC=\n>  . git-sh-setup\n>  \n> diff --git a/t/perf/bisect_regression b/t/perf/bisect_regression\n> index ce47e1662a9..d6b96f49e46 100755\n> --- a/t/perf/bisect_regression\n> +++ b/t/perf/bisect_regression\n> @@ -57,11 +57,9 @@ tmpdir=$(mktemp -d -t bisect_regression_XXXXXX) || die \"Failed to create temp di\n>  echo \"$oldtime\" >\"$tmpdir/oldtime\" || die \"Failed to write to '$tmpdir/oldtime'\"\n>  echo \"$newtime\" >\"$tmpdir/newtime\" || die \"Failed to write to '$tmpdir/newtime'\"\n>  \n> -# Bisecting must be performed from the top level directory (even with --no-checkout)\n> -(\n> -\ttoplevel_dir=$(git rev-parse --show-toplevel) || die \"Failed to find top level directory\"\n> -\tcd \"$toplevel_dir\" || die \"Failed to cd into top level directory '$toplevel_dir'\"\n>  \n> +(\n> +\t \n>  \tgit bisect start --no-checkout \"$newrev\" \"$oldrev\" || die \"Failed to start bisecting\"\n>  \n>  \tgit bisect run t/perf/bisect_run_script \"$test_script\" \"$test_number\" \"$tmpdir\"\n> \n> base-commit: 98cedd0233ee88e69711f79d1126b6bd772ff5bd\n> -- \n> gitgitgadget\n"},{"id":"393712","messageId":"1584887455-19369-1-git-send-email-sheikhhamza012@gmail.com","threadId":"53055","inReplyTo":"20200322104826.GB2224@szeder.dev","subject":"Re: [PATCH] bisect: remove root directory restriction for git bisect","fromName":"sheikh hamza","fromEmail":"sheikhhamza012@gmail.com","sentAt":"2020-03-22T14:30:55Z","receivedAt":"2020-03-22T14:31:09Z","isPatch":true,"sender":{"key":"sheikhhamza012@gmail.com","avatar":"https://gravatar.com/avatar/67e765e1aa9c192c25a00a31a51b83deb2afde34d497f0bf90867e71cd36c87b?d=mp&s=160"},"body":""},{"id":"393713","messageId":"1584887951-22737-1-git-send-email-sheikhhamza012@gmail.com","threadId":"53055","inReplyTo":"20200322104826.GB2224@szeder.dev","subject":"Re: [PATCH] bisect: remove root directory restriction for git bisect","fromName":"sheikh hamza","fromEmail":"sheikhhamza012@gmail.com","sentAt":"2020-03-22T14:39:11Z","receivedAt":"2020-03-22T14:39:22Z","isPatch":true,"sender":{"key":"sheikhhamza012@gmail.com","avatar":"https://gravatar.com/avatar/67e765e1aa9c192c25a00a31a51b83deb2afde34d497f0bf90867e71cd36c87b?d=mp&s=160"},"body":""},{"id":"393715","messageId":"e4cf161e-1f3a-8728-6c52-97651dc2d5fc@gmail.com","threadId":"53055","inReplyTo":"20200322104826.GB2224@szeder.dev","subject":"Re: [PATCH] bisect: remove root directory restriction for git bisect","fromName":"sheikh hamza","fromEmail":"sheikhhamza012@gmail.com","sentAt":"2020-03-22T14:58:53Z","receivedAt":"2020-03-22T14:59:06Z","isPatch":true,"sender":{"key":"sheikhhamza012@gmail.com","avatar":"https://gravatar.com/avatar/67e765e1aa9c192c25a00a31a51b83deb2afde34d497f0bf90867e71cd36c87b?d=mp&s=160"},"body":"i apologize for empty mails, i was configuring the mailer,\n\nby the issue i meant one of those mentioned on gigitgadget's\n\nfork, there this was mentioned as a good entry point project\n\nso thought of doing it as my GSoC microproject, do you think\n\nit makes a good microproject should i continue to work on it ?\n\n"},{"id":"393779","messageId":"nycvar.QRO.7.76.6.2003231658450.46@tvgsbejvaqbjf.bet","threadId":"53055","inReplyTo":"20200322104826.GB2224@szeder.dev","subject":"Re: [PATCH] bisect: remove root directory restriction for git bisect","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-03-23T16:02:17Z","receivedAt":"2020-03-23T16:02:21Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Gábor,\n\nOn Sun, 22 Mar 2020, SZEDER Gábor wrote:\n\n> On Sun, Mar 22, 2020 at 09:15:47AM +0000, Sheikh hamza via GitGitGadget wrote:\n> > From: sheikh hamza <sheikhhamza012@gmail.com>\n> >\n> > the git bisect\n> >     command should be able to run from inside any\n> >     subdirectory\n>\n> Why should 'git bisect' be able to run from inside any subdirectory\n> (of the working tree, I presume)?\n\nBecause other commands also allow the user to run in a subdirectory. For\nexample, `git rebase`, `git checkout`, `git cherry-pick`, etc\n\n> In particular, what happens, if someone starts 'git bisect' from within\n> 'subdir/', and 'git bisect' then checks out an old commit, where said\n> 'subdir/' didn't exist?  What happens, if the user runs 'git bisect run\n> ./script' from within 'subdir/', and that 'subdir/' doesn't exist in\n> that old commit?\n\nThe same that happens if that situation arises in `git rebase` or `git\ncheckout`: the directory is removed unless it is not empty (i.e. if there\nare untracked files in the directory, or submodules).\n\n> What happens, if 'subdir' does exists in that old commit, but it's a\n> file, not a directory?  What happens, if all this is on Windows?\n\nOn Windows, the directory is not deletable, of course, and the same thing\nhappens as if an untracked file is still in that directory: it is not\ndeleted.\n\n> >  git-bisect.sh            | 1 +\n> >  t/perf/bisect_regression | 6 ++----\n> >  2 files changed, 3 insertions(+), 4 deletions(-)\n\nThe most obvious problem with this patch is that it is not accompanied by\na regression test that documents and verifies the intended behavior.\n\nCiao,\nDscho\n"},{"id":"393781","messageId":"xmqqpnd359l6.fsf@gitster.c.googlers.com","threadId":"53055","inReplyTo":"20200322104826.GB2224@szeder.dev","subject":"Re: [PATCH] bisect: remove root directory restriction for git bisect","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-03-23T16:17:57Z","receivedAt":"2020-03-23T16:18:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> On Sun, Mar 22, 2020 at 09:15:47AM +0000, Sheikh hamza via GitGitGadget wrote:\n>> From: sheikh hamza <sheikhhamza012@gmail.com>\n>> \n>>     according to the open issue #486\n>\n> What issue #486?  Where?  The Git project doesn't use issues.\n>\n>> the git bisect\n>>     command should be able to run from inside any\n>>     subdirectory\n>\n> Why should 'git bisect' be able to run from inside any subdirectory\n> (of the working tree, I presume)?\n>\n> In particular, what happens, if someone starts 'git bisect' from\n> within 'subdir/', and 'git bisect' then checks out an old commit,\n> where said 'subdir/' didn't exist?  What happens, if the user runs\n> 'git bisect run ./script' from within 'subdir/', and that 'subdir/'\n> doesn't exist in that old commit?  What happens, if 'subdir' does\n> exists in that old commit, but it's a file, not a directory?  What\n> happens, if all this is on Windows?\n\nHmm, I am of two minds.  Most certainly, the bisection would break\nwhen the directory cannot be removed, and if it can be, then $pwd\nwould become in a weird state and the iteration with the bisect\nmachinery (be it interactive test before saying \"bisect good/bad\",\nor the command execution during \"bisect run\") would fail in a\nstrange and unpredictable ways.\n\nSo from that perspective, it does make sense to forbid running \"git\nbisect\" from a subdirectory, and we should probably do so on the\nsame principle for \"git checkout\", \"git pull\" and many other things.\n\nBut even then, it would not probably be foolproof.  Another process\nthat the end-user is not even aware of its execution (e.g. virus\nscanners?) may have a file open in the subdirectory on a filesystem\nthat does not allow directories to be removed while there is an open\nfile descriptor on a file it contains, and would cause the command\nto fail in a similar way.\n\nSo it probably is being too draconian to forbid these commands (not\njust \"git bisect\") from being run in a subdirectory for no good\nreason (i.e. being strict is not helping us much).  What would help\nis to make sure we fail in an understandable way (i.e. \"cannot\nremove directory /foo/bar/boz, so checkout of version v1.2.3 failed\"\nis clearly conveyed to the end user, which we may be already doing\nin which case that is wonderful).\n\n>> and in the same disscusion \"dscho\"\n>>     gave the directions and those directions lead me\n>>     the fix of adding SUBDIRECTORY_OK=Yes on L#34\n>>     before sourcing git-sh-setup that made it work as\n>>     in git-sh-setup there was a check on SUBDIRECTORY_OK\n>>     that prevents it to run in sub directories if it is not\n>>     set to \"ok\" as this file was also sourced in other commands\n>>     that are required to only run from root one of such scripts\n>>     is git-filter-branch\n>\n> Please don't indent the commit message and use punctuation to make it\n> more readable.\n\nThis is a good point.\n"}]}