Re: [PATCH 3/2] ls-files: only recurse on active submodules
- From
Jacob Keller <jacob.keller@gmail.com>
- Date
- Apr 13, 2017, 19:30 UTC
- Message-ID
- <CA+P7+xq7VUAT3pLahj72YUnF3zDm2u-ZBFu6TxWRYcJCc0c=Ew@mail.gmail.com>
- In-Reply-To
- <CAGZ79kaRTrgHMnP6mA3V2rDHzf8iOidqLTpp2aXmi6x+6YeZxw@mail.gmail.com>
On Thu, Apr 13, 2017 at 12:25 PM, Stefan Beller <sbeller@google.com> wrote:
Show 35 quoted lines
> On Thu, Apr 13, 2017 at 12:12 PM, Jacob Keller <jacob.keller@gmail.com> wrote: >> On Thu, Apr 13, 2017 at 12:05 PM, Stefan Beller <sbeller@google.com> wrote: >>> On Thu, Apr 13, 2017 at 11:57 AM, Brandon Williams <bmwill@google.com> wrote: >>>> Add in a check to see if a submodule is active before attempting to >>>> recurse. This prevents 'ls-files' from trying to operate on a submodule >>>> which may not exist in the working directory. >>> >>> What would currently happen on recursing into non-active submodules? >>> Can we have a test for this? >>> >>> Thanks, >>> Stefan >> >> We should be able to test for this. Is it possible that we can recurse >> into a submodule as long as we have the clone in .git/modules/<name> >> even if we don't have it checked out currently? > > Conceptually that should be possible, e.g. > > git ls-files --recurse-submodules <ancient ref> > > where the ancient ref contained submodules that are not present any more. > In that case we would need to do > > struct strbuf sb = STRBUF_INIT; > struct child_process = CHILD_PROCESS_INIT; > struct submodule *sub = submodule_from_path( \ > <path as recorded in ancient tree>, <ancient ref>) > strbuf_git_path(&sb, "modules/%s", sub->name); > > argv_array_pushl(&cp.args, "git", "ls-files", "--recurse", ...); > cp.dir = sb.buf; > run_command(&cp); > > Stefan
This is probably the right flow to use then.
Thanks, Jake