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

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

 



On Tue, Mar 7, 2017 at 10:44 AM, Junio C Hamano <gitster@xxxxxxxxx> 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 ?

If not and we run this command from a directory inside the
submodule, the usual prefix mechanics should go to the
root of the submodule, such that the ".." will be just enough
to break out of that submodule repo.

The interesting part is in the superproject, to see if we are
in a directory (and where the root of the superproject is).

>         - relative_path() to get "dir".

ok.

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

"ls-files --stage --full-name" to get
160000 ... dir/sub

>
>         - subtract "sub/dir" from the tail of the "/local/repo/super/sub/dir"
>           you got from xgetcwd() earlier.

makes sense.

>
>         - return the result.
>
> with a failure/unmet expectations (like not finding 160000) from any
> step returning an error, or something like that.

That seems better as we only need to spawn one process.

(This could also mean I am bad at reading our own man pages)

Thanks,
Stefan



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