git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] merge-recursive: add ability to turn off directory rename detection

From
Elijah Newren <newren@gmail.com>
Date
Aug 29, 2018, 23:00 UTC
Message-ID
<CABPp-BHFrk026R5VZLGwVvRYq_d82GTFqAyAeyTD=iQX4df2Bw@mail.gmail.com>
In-Reply-To
<nycvar.QRO.7.76.6.1808291452070.71@tvgsbejvaqbjf.bet>

On Wed, Aug 29, 2018 at 5:54 AM Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 40 quoted lines
>
> Hi Elijah,
>
> On Wed, 29 Aug 2018, Elijah Newren wrote:
>
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> >  merge-recursive.c | 18 +++++++++++++-----
> >  merge-recursive.h |  1 +
> >  2 files changed, 14 insertions(+), 5 deletions(-)
> >
> > diff --git a/merge-recursive.c b/merge-recursive.c
> > index f110e1c5ec..bf3cb03d3a 100644
> > --- a/merge-recursive.c
> > +++ b/merge-recursive.c
> > @@ -2843,12 +2843,19 @@ static int handle_renames(struct merge_options *o,
> >       head_pairs = get_diffpairs(o, common, head);
> >       merge_pairs = get_diffpairs(o, common, merge);
> >
> > -     dir_re_head = get_directory_renames(head_pairs, head);
> > -     dir_re_merge = get_directory_renames(merge_pairs, merge);
> > +     if (o->detect_directory_renames) {
> > +             dir_re_head = get_directory_renames(head_pairs, head);
> > +             dir_re_merge = get_directory_renames(merge_pairs, merge);
> >
> > -     handle_directory_level_conflicts(o,
> > -                                      dir_re_head, head,
> > -                                      dir_re_merge, merge);
> > +             handle_directory_level_conflicts(o,
> > +                                              dir_re_head, head,
> > +                                              dir_re_merge, merge);
> > +     } else {
> > +             dir_re_head  = xmalloc(sizeof(*dir_re_head));
> > +             dir_re_merge = xmalloc(sizeof(*dir_re_merge));
>
> This is not a suggestion to change anything, but a genuine question out of
> curiosity: would it make sense to put the `dir_re_head` and `dir_re_merge`
> structures into `struct merge_options` to avoid these extra `malloc()`s?
> Or would that cause issues with the recursive nature of the recursive
> merge?

That would work to avoid the extra `malloc()`s, and be inline with the current usage of merge_options. However, I'm not sure I like the current usage of merge_options. That struct is supposed to be public API, but it's got a lot of private internal-only use stuff (and putting dir_re_head and dir_re_merge there would add more). I'm tempted to go the other way and eject some of the other internal-only stuff from merge_options (or wrap it inside an opaque struct merge_options_internal* internal field, or something like that).

Previous: Johannes SchindelinNext: Elijah Newren
Message 15 of 20 in “A rebase regression in Git 2.18.0”
  1. Nikolay KasyanovAug 28, 2018
  2. Ævar Arnfjörð BjarmasonAug 28, 2018
  3. Johannes SchindelinAug 28, 2018
  4. Nikolay KasyanovAug 28, 2018
  5. Elijah NewrenAug 28, 2018
  6. Junio C HamanoAug 28, 2018
  7. 0/3 Turn off directory rename detection in am -3Elijah Newren, Aug 29, 2018
  8. 1/3 t3401: add another directory rename testcase for rebase and amElijah Newren, Aug 29, 2018
  9. Junio C HamanoAug 29, 2018
  10. Elijah NewrenAug 29, 2018
  11. Junio C HamanoAug 30, 2018
  12. Elijah NewrenAug 30, 2018
  13. 2/3 merge-recursive: add ability to turn off directory rename detectionElijah Newren, Aug 29, 2018
  14. Johannes SchindelinAug 29, 2018
  15. Elijah NewrenAug 29, 2018
  16. 3/3 am: avoid directory rename detection when calling recursive merge machineryElijah Newren, Aug 29, 2018
  17. Johannes SchindelinAug 29, 2018
  18. Elijah NewrenAug 30, 2018
  19. Johannes SchindelinAug 31, 2018
  20. Elijah NewrenAug 31, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.