Re: [PATCH 31/31] ls-files: use repository object
- From
- Brandon Williams <bmwill@google.com>
- Date
- Jun 5, 2017, 17:46 UTC
- Message-ID
- <20170605174632.GB40426@google.com>
- In-Reply-To
- <CAGZ79kY4iLWuCrPVA6mo6BbgwoF_-wyP_=ju5Fs0+n8cTifb=Q@mail.gmail.com>
On 06/01, Stefan Beller wrote:
Show 28 quoted lines
> On Wed, May 31, 2017 at 2:44 PM, Brandon Williams <bmwill@google.com> wrote:
> > Convert ls-files to use a repository struct and recurse submodules
> > inprocess.
> >
> > Signed-off-by: Brandon Williams <bmwill@google.com>
>
>
> > +static void show_submodule(const struct repo *superproject,
> > + struct dir_struct *dir, const char *path)
> > {
> > + struct repo submodule;
> > + char *gitdir = mkpathdup("%s/%s", superproject->worktree, path);
> > + repo_init(&submodule, gitdir);
> > +
> > + repo_read_index(&submodule);
> > + repo_read_gitmodules(&submodule);
> > +
> > + if (superproject->submodule_prefix)
> > + submodule.submodule_prefix = xstrfmt("%s%s/", superproject->submodule_prefix, path);
> > + else
> > + submodule.submodule_prefix = xstrfmt("%s/", path);
> > + show_files(&submodule, dir);
> > +
> > + repo_clear(&submodule);
> > + free(gitdir);
> > }
>
> I like how it seems easy now to do work in another repository. :)It really does make working with another repo easy! No more compiling argv options and spawning child processes :D
Show 5 quoted lines
>
> > - { "ls-files", cmd_ls_files, RUN_SETUP | SUPPORT_SUPER_PREFIX },
> > + { "ls-files", cmd_ls_files, RUN_SETUP },
>
> With this step, we can get rid of SUPPORT_SUPER_PREFIX eventually.Yes Ideally most of the little hacks I introduced when originally teaching ls-files and grep to recurse could be removed.
Show 6 quoted lines
> > I do not have comments on the patches in the middle, but they > cleared up some of the questions that I asked in the early patches. > > Thanks, > Stefan
-- Brandon Williams