Re: [RFC PATCH] rev-parse: add --show-superproject-working-tree
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 7, 2017, 22:49 UTC
- Message-ID
- <xmqq7f4066t9.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAGZ79kYMZk3sNNjWgp9acQG6z5Q5CnsJi+n7Bvr3EkfbSHasMA@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 16 quoted lines
> On Tue, Mar 7, 2017 at 10:44 AM, Junio C Hamano <gitster@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.
Show 5 quoted lines
>> - ask "ls-{tree,files} --full-name HEAD dir" to get "160000"
>> and "sub/dir".
>
> "ls-files --stage --full-name" to get
> 160000 ... dir/subYeah, 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.