[PATCH 1/2] submodule--helper, module_clone: always operate on absolute paths

2016-03-31 Thread Stefan Beller
When giving relative paths to `relative_path` to compute a relative path from one directory to another, this may fail in `relative_path`. Make sure both arguments to `relative_path` are always absolute. Signed-off-by: Stefan Beller --- builtin/submodule--helper.c | 28 ++-

Re: [PATCH 1/2] submodule--helper, module_clone: always operate on absolute paths

2016-04-01 Thread Junio C Hamano
Stefan Beller writes: > + char *sm_gitdir_rel, *p, *path = NULL; > + const char *sm_gitdir; > struct strbuf rel_path = STRBUF_INIT; > struct strbuf sb = STRBUF_INIT; > > @@ -198,7 +199,14 @@ static int module_clone(int argc, const char **argv, > const char *prefix) >

Re: [PATCH 1/2] submodule--helper, module_clone: always operate on absolute paths

2016-04-01 Thread Junio C Hamano
Junio C Hamano writes: > By the way, this line is the last use of sm_gitdir_rel before it > gets freed. I wonder > > sm_gitdir = absolute_path(sb.buf); > > would be sufficient. We can lose the variable, and free() on it at > the end of this function, and an extra allocation if we can do s

Re: [PATCH 1/2] submodule--helper, module_clone: always operate on absolute paths

2016-04-01 Thread Eric Sunshine
On Fri, Apr 1, 2016 at 3:30 PM, Junio C Hamano wrote: > Subject: [PATCH] submodule--helper: do not borrow absolute_path() result for > too long > > absolute_path() is designed to allow its callers to take a brief > peek of the result (typically, to be fed to functions like > strbuf_add() and rela

Re: [PATCH 1/2] submodule--helper, module_clone: always operate on absolute paths

2016-04-01 Thread Junio C Hamano
Junio C Hamano writes: > From: Junio C Hamano > Date: Fri, 1 Apr 2016 12:23:16 -0700 > Subject: [PATCH] submodule--helper: do not borrow absolute_path() result for > too long > > absolute_path() is designed to allow its callers to take a brief > peek of the result (typically, to be fed to funct