Re: [PATCH 3/8] entry: support CE_WT_REMOVE flag in checkout_entry
On 12/10, Elijah Newren wrote:
Show 36 quoted lines
> On Sun, Dec 9, 2018 at 12:05 PM Thomas Gummerer <t.gummerer@gmail.com> wrote:
> >
> > 'checkout_entry()' currently only supports creating new entries in the
> > working tree, but not deleting them. Add the ability to remove
> > entries at the same time if the entry is marked with the CE_WT_REMOVE
> > flag.
> >
> > Currently this doesn't have any effect, as the CE_WT_REMOVE flag is
> > only used in unpack-tree, however we will make use of this in a
> > subsequent step in the series.
> >
> > Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
> > ---
> > entry.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/entry.c b/entry.c
> > index 3ec148ceee..cd1c6601b6 100644
> > --- a/entry.c
> > +++ b/entry.c
> > @@ -441,6 +441,13 @@ int checkout_entry(struct cache_entry *ce,
> > static struct strbuf path = STRBUF_INIT;
> > struct stat st;
> >
> > + if (ce->ce_flags & CE_WT_REMOVE) {
> > + if (topath)
> > + BUG("Can't remove entry to a path");
>
> Minor nit: This error message is kinda hard to parse, for someone not
> that familiar with all the *_entry functions, like myself. Maybe add
> a comment before this line:
> /* No content and thus no path to create, so we have no pathname
> to return */
> or reword the error slightly? Or maybe it's fine and I was just
> confused from lack of code familiarity, but I'll throw it out there
> since I stumbled on it a bit.I'll try to make it more clear in the new round, thanks!
Show 9 quoted lines
> > + unlink_entry(ce);
> > + return 0;
> > + }
> > +
> > if (topath)
> > return write_entry(ce, topath, state, 1);
> >
> > --
> > 2.20.0.405.gbc1bbc6f85