Re: [long] worktree setup cases

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Wednesday, October 20, 2010 - 2:00 pm

Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:


Ok.  I agree that a regular file .git that has "gitdir: ../there" in it
should be naming "there" directory next to the directory .git lives in.
It is insane for it to take $(cwd) into account.


Hmm, why is core.worktree separate from the second item?  In any case, the
three mechanisms to specify the working tree should only be in effect when
GIT_DIR/--git-dir is used, so the above are not orthogonal, and the total
count should be smaller than 32 cases.


All good questions to ask, except for the last one which I cannot quite
parse.


Ok.


How does it make sense to have GIT_WORK_TREE without GIT_DIR?  Without
GIT_DIR, we will run repository discovery, which means we will always go
up to find a .git dir, and the reason for doing that is because we want to
also work in a subdirectory of a working tree (the very original git never
worked from anywhere other than the root level of the working tree).  By
definition, the root of the working tree is the same as in cases 0/8.


If you set GIT_DIR, we do no discovery, so git will work only from the
root level of the working tree (or bare repository operation) if you do
not tell us where the working tree is.


Without discovery, we know where the root level of the working tree is,
and we know where the repository is, because you told us.  The answers to
questions 1-5, i.e. semantics observable by the end user, should be the
same as case 0/8 even though the internal codepath to achieve that,
i.e. question 0, may be different.


Shouldn't all of these 16 be the same, if the repository is bare?  What is
your definition of bareness?  core.bare?  In any case we should say "you
are using a bare repository, there is no working tree" and cwd shouldn't
change in these cases.  They are all bare and there is no working tree.

Alternatively, you could give precedence to core.worktree and friends, in
which case these can go to the other categories in your description,
ignoring core.bare settings.  For example, 31 explicitly specifies where
the .git directory and the working tree are, which would fall into the
same category as 3,6,7,11,14,15.

Either way is fine.


Ok.


As I said already, isn't this a nonsense combination you should error out?


Ok.


Ok.


This is operating out of bounds of the original design criteria; we
probably do not error out now, which is an original bug, but I understand
that you are trying to enhance this to reach into a submodule repository
and its working tree from its superproject.  As long as we can make such
an enhancement in a way that produces sensible and consistent output, that
kind of change would be fine.

I suspect that you would need to pass in "make the path relative to this"
using some means that do not exist in the current structure of the code.

Also I suspect that for the purpose of your enhancement, the first three
lines of this paragraph would not be true.  Think of a case where you are
at the superproject level and running a recursive grep into its submodule
at "nitfol", that has contents recorded at the path "xyzzy/frotz.txt".

If you keep cwd unchanged, the path appears at nitfol/xyzzy/frotz.txt in
the working tree from the end user's point of view, so you need to pass
"nitfol/" as a different kind of "prefix" that needs to be used to modify
the path recorded in the contents tracked by the submodule.  The grep
running in the submodule will read xyzzy/frotz.txt from the index (which
is how it notices which paths are of interest), use the "nitfol/" prefix
to turn it into a path in the working tree, read from that file and report
hits.  This is an example of an operation that clearly require a working
tree, and does not have to error out.

Alternatively, if you move cwd to the top of the working tree of the
submodule, you would still need to pass "nitfol/" prefix, but it needs to
be used only in the output phase.  The grep running in the submodule will
read xyzzy/frotz.txt from the index (which is how it notices which paths
are of interest), read from the file in the working tree (relative to cwd
which now is at the root level of the submodule), and use "nitfol/" as
output prefix when reporting.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[long] worktree setup cases, Nguyen Thai Ngoc Duy, (Wed Oct 20, 1:59 am)
Re: [long] worktree setup cases, Jonathan Nieder, (Wed Oct 20, 12:07 pm)
Re: [long] worktree setup cases, Jonathan Nieder, (Wed Oct 20, 12:18 pm)
Re: [long] worktree setup cases, Junio C Hamano, (Wed Oct 20, 2:00 pm)
Re: [long] worktree setup cases, Nguyen Thai Ngoc Duy, (Wed Oct 20, 6:46 pm)
Re: [long] worktree setup cases, Nguyen Thai Ngoc Duy, (Wed Oct 20, 7:23 pm)
Re: [long] worktree setup cases, Jonathan Nieder, (Wed Oct 20, 8:30 pm)
Re: [long] worktree setup cases, Nguyen Thai Ngoc Duy, (Thu Oct 21, 5:50 am)
Re: [long] worktree setup cases, Jonathan Nieder, (Thu Oct 21, 9:01 am)
Re: [long] worktree setup cases, Enrico Weigelt, (Thu Oct 21, 11:51 am)
Re: [long] worktree setup cases, Enrico Weigelt, (Thu Oct 21, 12:01 pm)
Re: [long] worktree setup cases, Junio C Hamano, (Thu Oct 21, 4:06 pm)
Re: [long] worktree setup cases, Nguyen Thai Ngoc Duy, (Thu Oct 21, 5:34 pm)
Re: [long] worktree setup cases, Enrico Weigelt, (Thu Oct 21, 10:00 pm)
.git file (Re: [long] worktree setup cases), Jonathan Nieder, (Thu Oct 21, 10:28 pm)
Re: [long] worktree setup cases, Nguyen Thai Ngoc Duy, (Thu Oct 21, 10:36 pm)
Re: [long] worktree setup cases, Nguyen Thai Ngoc Duy, (Sat Oct 23, 3:12 am)