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

2017-03-07 Thread Junio C Hamano
Stefan Beller writes: > On Tue, Mar 7, 2017 at 10:44 AM, Junio C Hamano 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, >

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

2017-03-07 Thread Stefan Beller
On Tue, Mar 7, 2017 at 10:44 AM, Junio C Hamano 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,

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

2017-03-07 Thread Junio C Hamano
Stefan Beller writes: > +const char *get_superproject_working_tree() const char *get_superproject_working_tree(void) The same for the *.h file declaration. > +{ > + struct child_process cp = CHILD_PROCESS_INIT; > + struct strbuf sb = STRBUF_INIT; > + > + if (!superproject_exists())

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

2017-03-06 Thread Junio C Hamano
Junio C Hamano 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 bas

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

2017-03-06 Thread Junio C Hamano
Junio C Hamano writes: >> +dirname = relative_path(xgetcwd(), one_up, &sb); > > So, the idea is we start at the root level of the current project's > working tree, and we go up one level, then we know the last component > of the path our submodule is bound at in the superproject. > >> +pr

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

2017-03-06 Thread Junio C Hamano
Stefan Beller writes: > diff --git a/submodule.c b/submodule.c > index 3b98766a6b..a63aef2c6b 100644 > --- a/submodule.c > +++ b/submodule.c > @@ -1514,3 +1514,90 @@ void absorb_git_dir_into_superproject(const char > *prefix, > strbuf_release(&sb); > } > } Please have a com

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

2017-03-06 Thread Stefan Beller
Signed-off-by: Stefan Beller --- Marking this as RFC as documentation and tests are missing. builtin/rev-parse.c | 7 + submodule.c | 87 + submodule.h | 8 + 3 files changed, 102 insertions(+) diff --git a/builtin/r