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

Re: [PATCH 3/5] merge-recursive: test rename threshold option

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Feb 21, 2016, 20:45 UTC
Message-ID
<CAPig+cQ5h4hjOwO6-xXii6QQP0J8B_bHYUwWniR6HdQN2dB_1A@mail.gmail.com>
In-Reply-To
<CALMa68qhCBJ5MnT7i6UT989OKKzzOF_bTqo38thSPMwq0mbj6g@mail.gmail.com>

On Sun, Feb 21, 2016 at 1:55 PM, Felipe Gonçalves Assis <felipeg.assis@gmail.com> wrote:

Show 16 quoted lines
> On 21 February 2016 at 14:52, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Sun, Feb 21, 2016 at 10:09 AM, Felipe Gonçalves Assis
>> <felipeg.assis@gmail.com> wrote:
>>> +test_expect_success 'rename threshold is truncated' '
>>> +       git read-tree --reset -u HEAD &&
>>> +       test_must_fail git merge-recursive --rename-threshold=200% HEAD^ -- HEAD master &&
>>> +       check_find_renames_100
>>> +'
>>
>> Is this truncation documented behavior or is it just a detail of the
>> current implementation. (Genuine question; I haven't checked the
>> documentation or source.) If just an implementation detail, then it
>> might not be desirable to formalize it via a test.
>
> Not documented. I will remove this. If you prefer to have it
> documented and the test added back later, I can do that.

Looking at the code itself and its history, this seems to be a deliberate decision, so the test may be appropriate, however, I defer to Junio's judgment.

Show 17 quoted lines
>>> +test_expect_success 'last wins in --rename-threshold=<m> --rename-threshold=<n>' '
>>> +       git read-tree --reset -u HEAD &&
>>> +       test_must_fail git merge-recursive --rename-threshold=25 --rename-threshold=75 HEAD^ -- HEAD master &&
>>> +       check_find_renames_75
>>> +'
>>
>> Would it make sense to add tests checking that invalid
>> --rename-threshold= arguments, such as negative and non-numbers,
>> correctly error out?
>
> I guess so. Can I ask you for a suggestion on how to check this?
>
> Given that merges here usually fail anyway because of the conflicts,
> what is the best way of checking the effect of an argument rejection?
> 1. Check that the merge fails but the index is not changed
> 2. Check for a specific exit code
> 3. Use another setup so that the merges succeed

The last option would be most straightforward, however, looking at diff.c:parse_rename_score(), I see that it never actually errors out (by returning -1), so you may not (presently) be able to test these cases. It seems (presently) that merge-recursive.c:parse_merge_opt() can only catch a usage error if nothing follows the '='.

Previous: Felipe Gonçalves AssisNext: Junio C Hamano
Message 9 of 16 in “Tests and fixes for merge-recursive rename options”
  1. 0/5 Tests and fixes for merge-recursive rename optionsFelipe Gonçalves Assis, Feb 21, 2016
  2. 1/5 merge-recursive: find-renames resets thresholdFelipe Gonçalves Assis, Feb 21, 2016
  3. Eric SunshineFeb 21, 2016
  4. 2/5 merge-strategies.txt: fix typoFelipe Gonçalves Assis, Feb 21, 2016
  5. Eric SunshineFeb 21, 2016
  6. 3/5 merge-recursive: test rename threshold optionFelipe Gonçalves Assis, Feb 21, 2016
  7. Eric SunshineFeb 21, 2016
  8. Felipe Gonçalves AssisFeb 21, 2016
  9. Eric SunshineFeb 21, 2016
  10. Junio C HamanoFeb 21, 2016
  11. 4/5 merge-recursive: test option to disable renamesFelipe Gonçalves Assis, Feb 21, 2016
  12. Eric SunshineFeb 21, 2016
  13. 5/5 merge-recursive: test more consistent interfaceFelipe Gonçalves Assis, Feb 21, 2016
  14. Eric SunshineFeb 21, 2016
  15. Felipe Gonçalves AssisFeb 21, 2016
  16. Eric SunshineFeb 21, 2016

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.