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

Re: [PATCH v3 2/3] merge: Add merge.renames config setting

From
Ben Peart <peartben@gmail.com>
Date
Apr 27, 2018, 00:54 UTC
Message-ID
<7de8f144-8a37-e471-48e8-0b6f17a7bf29@gmail.com>
In-Reply-To
<CABPp-BE29rwZCDqFHH-nzrDub6MMdtoiorj0jv3K6B6cmfcaLA@mail.gmail.com>
On 4/26/2018 6:52 PM, Elijah Newren wrote:
Show 15 quoted lines
> On Thu, Apr 26, 2018 at 1:52 PM, Ben Peart <Ben.Peart@microsoft.com> wrote:
> 
>> +merge.renames::
>> +       Whether and how Git detects renames.  If set to "false",
>> +       rename detection is disabled. If set to "true", basic rename
>> +       detection is enabled.  If set to "copies" or "copy", Git will
>> +       detect copies, as well.  Defaults to the value of diff.renames.
>> +
> 
> We shouldn't allow users to force copy detection on for merges  The
> diff side of the code will detect them correctly but the code in
> merge-recursive will mishandle the copy pairs.  I think fixing it is
> somewhere between big can of worms and
> it's-a-configuration-that-doesn't-even-make-sense, but it's been a
> while since I thought about it.

Color me puzzled. :) The consensus was that the default value for merge.renames come from diff.renames. diff.renames supports copy detection which means that merge.renames will inherit that value. My assumption was that is what was intended so when I reimplemented it, I fully implemented it that way.

Are you now requesting to only use diff.renames as the default if the value is true or false but not if it is copy? What should happen if diff.renames is actually set to copy? Should merge silently change that to true, display a warning, error out, or something else? Do you have some other behavior for how to handle copy being inherited from diff.renames you'd like to see?

Can you write the documentation that clearly explains the exact behavior you want? That would kill two birds with one stone... :)

Show 33 quoted lines
> 
>> diff --git a/merge-recursive.h b/merge-recursive.h
>> index 80d69d1401..0c5f7eff98 100644
>> --- a/merge-recursive.h
>> +++ b/merge-recursive.h
>> @@ -17,7 +17,8 @@ struct merge_options {
>>          unsigned renormalize : 1;
>>          long xdl_opts;
>>          int verbosity;
>> -       int detect_rename;
>> +       int diff_detect_rename;
>> +       int merge_detect_rename;
>>          int diff_rename_limit;
>>          int merge_rename_limit;
>>          int rename_score;
>> @@ -28,6 +29,11 @@ struct merge_options {
>>          struct hashmap current_file_dir_set;
>>          struct string_list df_conflict_file_set;
>>   };
>> +inline int merge_detect_rename(struct merge_options *o)
>> +{
>> +       return o->merge_detect_rename >= 0 ? o->merge_detect_rename :
>> +               o->diff_detect_rename >= 0 ? o->diff_detect_rename : 1;
>> +}
> 
> Why did you split o->detect_rename into two fields?  You then
> recombine them in merge_detect_rename(), and after initial setup only
> ever access them through that function.  Having two fields worries me
> that people will accidentally introduce bugs by using one of them
> instead of the merge_detect_rename() function.  Is there a reason you
> decided against having the initial setup just set a single value and
> then use it directly?
> 

The setup of this value is split into 3 places that may or may not all get called. The initial values, the values that come from the config settings and then any values passed on the command line.

Because the merge value can now inherit from the diff value, you only know the final value after you have received all possible inputs. That makes it necessary to be a calculated value.

If you look at diff_rename_limit/merge_rename_limit, detect_rename follow the same pattern for the same reasons. It turns out detect_rename was a little more complex because it is used in 3 different locations (vs just one) which is why I wrapped the inheritance logic into the helper function merge_detect_rename().

Previous: Elijah NewrenNext: Junio C Hamano
Message 43 of 65 in “add additional config settings for merge”
  1. 0/2 add additional config settings for mergeBen Peart, Apr 20, 2018
  2. 1/2 merge: Add merge.renames config settingBen Peart, Apr 20, 2018
  3. Elijah NewrenApr 20, 2018
  4. Elijah NewrenApr 20, 2018
  5. Ben PeartApr 23, 2018
  6. Ben PeartApr 20, 2018
  7. Elijah NewrenApr 20, 2018
  8. Junio C HamanoApr 21, 2018
  9. Ben PeartApr 23, 2018
  10. Junio C HamanoApr 23, 2018
  11. Johannes SchindelinApr 24, 2018
  12. Elijah NewrenApr 24, 2018
  13. Johannes SchindelinApr 25, 2018
  14. Eckhard MaaßApr 22, 2018
  15. Ben PeartApr 23, 2018
  16. Eckhard MaaßApr 23, 2018
  17. Ben PeartApr 24, 2018
  18. Ben PeartApr 23, 2018
  19. 2/2 merge: Add merge.aggressive config settingBen Peart, Apr 20, 2018
  20. Elijah NewrenApr 20, 2018
  21. Ben PeartApr 24, 2018
  22. Elijah NewrenApr 24, 2018
  23. Junio C HamanoApr 24, 2018
  24. Ben PeartApr 25, 2018
  25. Elijah NewrenApr 20, 2018
  26. Ben PeartApr 20, 2018
  27. 0/2 add additional config settings for mergeBen Peart, Apr 24, 2018
  28. 1/2 merge: Add merge.renames config settingBen Peart, Apr 24, 2018
  29. Elijah NewrenApr 24, 2018
  30. Elijah NewrenApr 24, 2018
  31. Ben PeartApr 24, 2018
  32. Elijah NewrenApr 25, 2018
  33. 2/2 merge: Add merge.aggressive config settingBen Peart, Apr 24, 2018
  34. Junio C HamanoApr 25, 2018
  35. Ben PeartApr 25, 2018
  36. Junio C HamanoApr 26, 2018
  37. 0/3 add merge.renames config settingBen Peart, Apr 26, 2018
  38. 1/3 merge: update documentation for {merge,diff}.renameLimitBen Peart, Apr 26, 2018
  39. Elijah NewrenApr 26, 2018
  40. Jonathan TanApr 26, 2018
  41. 2/3 merge: Add merge.renames config settingBen Peart, Apr 26, 2018
  42. Elijah NewrenApr 26, 2018
  43. Ben PeartApr 27, 2018
  44. Junio C HamanoApr 27, 2018
  45. Elijah NewrenApr 27, 2018
  46. Johannes SchindelinApr 27, 2018
  47. Elijah NewrenApr 27, 2018
  48. Eckhard MaaßApr 27, 2018
  49. Elijah NewrenApr 27, 2018
  50. Eckhard MaaßApr 30, 2018
  51. Elijah NewrenApr 30, 2018
  52. Elijah NewrenApr 27, 2018
  53. Elijah Newren, Apr 27, 2018
  54. Ben PeartApr 30, 2018
  55. Elijah NewrenApr 30, 2018
  56. Ben PeartMay 2, 2018
  57. 3/3 merge: pass aggressive when rename detection is turned offBen Peart, Apr 26, 2018
  58. Elijah NewrenApr 26, 2018
  59. Elijah NewrenApr 26, 2018
  60. 0/3 add additional config settings for mergeBen Peart, May 2, 2018
  61. 1/3 merge: update documentation for {merge,diff}.renameLimitBen Peart, May 2, 2018
  62. 2/3 merge: Add merge.renames config settingBen Peart, May 2, 2018
  63. Junio C HamanoMay 4, 2018
  64. 3/3 merge: pass aggressive when rename detection is turned offBen Peart, May 2, 2018
  65. Elijah NewrenMay 2, 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.