Re: [PATCH v5 00/11] Avoid removing the current working directory, even if it becomes empty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/1/2021 1:40 AM, Elijah Newren via GitGitGadget wrote:
> Traditionally, if folks run git commands such as checkout or rebase from a
> subdirectory, that git command could remove their current working directory
> and result in subsequent git and non-git commands either getting confused or
> printing messages that confuse the user (e.g. "fatal: Unable to read current
> working directory: No such file or directory"). Many commands either
> silently avoid removing directories that are not empty (i.e. those that have
> untracked or modified files in them)[1], or show an error and abort,
> depending on which is more appropriate for the command in question. With
> this series, we augment the reasons to avoid removing directories to include
> not just has-untracked-or-modified-files, but also to avoid removing the
> original_cwd as well.

I did not clearly voice my approval of the core idea here, but I do like it.

I think this fits squarely into a category of "help the user not get stuck"
which Git has enough of those situations that we don't need this one. Even
expert users won't know for sure if a 'git checkout' will cause their current
directory to be removed, however unlikely.

In the Git project, we spend a lot of time in the root of our workdir, but
this is not the typical case for large projects. I remember spending most of
my time in a previous role working four levels deep in the directory hierarchy.


I read the previous two range-diffs and took another pass at this v5 and
didn't see anything worth commenting on. This version is good to go.

There is _also_ more work to do, as follow-ups. In particular, the thing
that I thought about was sparse-checkout and created this test which still
fails at the end of your series (as an addition to t1092)

test_expect_success 'remove cwd' '
	init_repos &&

	test_sparse_match git sparse-checkout set deep/deeper1/deepest &&
	for repo in sparse-checkout sparse-index
	do
		(
			cd $repo/deep/deeper1 &&
			test-tool getcwd >"$TRASH_DIRECTORY/expect" &&
			git sparse-checkout set &&

			test-tool getcwd >"$TRASH_DIRECTORY/actual" &&
			test_sparse_match git status --porcelain &&
			cd "$TRASH_DIRECTORY" &&
			test_cmp expect actual
		)
	done
'

Please do not let this test delay the advancement of this series. As we
find these kinds of issues, we can fix them one-by-one as needed.

Thanks,
-Stolee



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux