Stefan Beller <sbel...@google.com> writes:

> On Tue, Mar 7, 2017 at 10:44 AM, Junio C Hamano <gits...@pobox.com> wrote:
>
>> So perhaps your superproject_exists() helper can be eliminated
>
> That is what I had originally, but I assumed a strict helper function
> for "existence of the superproject" would be interesting in the future,
> e.g. for get_superproject_git_dir, or on its own. There was an attempt
> to have the shell prompt indicate if you are in a submodule,
> which would not need to know the worktree or git dir of the
> superproject, but only its existence.
>
>> instead coded in get_superproject_working_tree() in place to do:
>>
>>         - xgetcwd() to get "/local/repo/super/sub/dir".
>
> Did you mean .../super/dir/sub ?

I meant "/local/repo/super/sub/dir".  I am using this case to
illustrate: the root of the superproject is at /local/repo/super,
its submodule we are interested in is at sub/dir, and the function
is working inside the submodule--after the repository discovery
moves the cwd, xgetcwd() would give the root of the working tree of
the submodule, which is at "/local/repo/super/sub/dir".

And that would give us "dir" by taking that as relative to its "../"

>>         - relative_path() to get "dir".
>
> ok.

indeed.

>>         - ask "ls-{tree,files} --full-name HEAD dir" to get "160000"
>>           and "sub/dir".
>
> "ls-files --stage --full-name" to get
> 160000 ... dir/sub

Yeah, also when usihng ls-files you obviously do not give HEAD but
you do give "dir" as the pathspec.  And you get "sub/dir" as the
result.

Reply via email to