Re: [RFC PATCH] rev-parse: add --show-superproject-working-tree

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

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

>>  - If our submodule is bound at path sub/dir in the superproject,
>>    the relative-path thing above would get "dir" and this ls-tree
>>    ends up asking what is at "dir", but the question you really want
>>    to ask is what is at "sub/dir", isn't it?
>
> IOW, the basic ontline of the idea may be OK, but I think you would
> want to do something along this line:
>
>     - chdir to .. from the root of your submodule working tree;
>     - in that .. directory, ask what prefix it is (you'd get
>       "sub/dir", or "not a git" if you are not a submodule);
>     - in that .. directory, ask ls-files what sub/dir is;
>     - if it is 160000, you're happy.

Nah, that wouldn't be necessary and would not work.  --prefix would
be "sub" in that case, and you'd need to concatenate the "dir" that
is the basename of the path to the submodule to get "sub/dir".  

Besides, output from "ls-files" by default is relative to cwd, so if
you did ls-files or ls-tree HEAD in "sub/", you'll find where you
came from as "dir", not "sub/dir", so the original code happens to
work even from a subdirectory of a superproject, but the reason why
it works is a bit subtle.  Perhaps it deserves in-code comment to
explain it.





[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]