Re: [PATCH 03/19] Ensure index matches head before invoking merge machinery, round N

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Elijah,

On Thu, 25 Jul 2019, Elijah Newren wrote:

> On Thu, Jul 25, 2019 at 12:41 PM Johannes Schindelin
> <Johannes.Schindelin@xxxxxx> wrote:
> >
> > On Thu, 25 Jul 2019, Elijah Newren wrote:
> >
> > > diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
> > > index 5b910e351e..a4bfd8fc51 100644
> > > --- a/builtin/merge-recursive.c
> > > +++ b/builtin/merge-recursive.c
> > > @@ -1,3 +1,4 @@
> > > +#include "cache.h"
> > >  #include "builtin.h"
> > >  #include "commit.h"
> > >  #include "tag.h"
> > > @@ -63,6 +64,9 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
> > >       if (argc - i != 3) /* "--" "<head>" "<remote>" */
> > >               die(_("not handling anything other than two heads merge."));
> > >
> > > +     if (repo_read_index_unmerged(the_repository))
> > > +             die_resolve_conflict("merge");
> >
> > For a moment I was unsure whether `_unmerged()` is the right thing to do
> > here, as it specifically allows to read the index even when there are
> > conflict stages. But I guess it does not matter too much here. I
> > probably would have opted for `repo_read_index()` instead, though.
>
> The names repo_read_index() and repo_read_index_unmerged() actually
> seem slightly misleading to me; they seem to do the opposite of what
> you'd think they do.
>
> repo_read_index() reads in an index and allows unmerged entries and
> returns istate->cache_nr.
>
> repo_read_index_unmerged() calls repo_read_index(), then checks to see
> if any of the entries are unmerged and returns whether or not any
> unmerged entries were found.
>
> So, the way to disallow conflict stages isn't to use
> repo_read_index(), but to use repo_read_index_unmerged(), as I did.
> Counter-intuitive, I know.

Whoa. No wonder I get it wrong all the time.

Thanks for educating me,
Dscho




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux