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

Re: Custom merge driver with no rename detection

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 15, 2016, 08:06 UTC
Message-ID
<alpine.DEB.2.20.1602150858340.2964@virtualbox>
In-Reply-To
<CALMa68ovz=VZYkCcUDvEn1d7=xJDx__71caqsPXUFASZ1phfdw@mail.gmail.com>
Hi Felipe,
On Sun, 14 Feb 2016, Felipe Gonçalves Assis wrote:
> Attached is a quick and dirty patch that emulates the effect by
> allowing greater than 100% rename thresholds to mean "no-renames".
It is really hard to comment on attached patches.
First comment: the commit message is awfully empty, and lacks a sign-off.
Show 5 quoted lines
>         /* user says num divided by scale and we say internally that
>          * is MAX_SCORE * num / scale.
>          */
> -       return (int)((num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale));
> +       return (int)(MAX_SCORE * num / scale);

Uh oh. I suspect this opens the door pretty wide for integer overflows. I could imagine that something like

	return (int)(num > scale ? MAX_SCORE + 1 : MAX_SCORE * num / scale);
would work better, but it still would need some careful consideration.
Show 11 quoted lines
>  static int diff_scoreopt_parse(const char *opt)
> diff --git a/diffcore-rename.c b/diffcore-rename.c
> index af1fe08..7cb5a3b 100644
> --- a/diffcore-rename.c
> +++ b/diffcore-rename.c
> @@ -497,7 +497,7 @@ void diffcore_rename(struct diff_options *options)
>                         register_rename_src(p);
>                 }
>         }
> -       if (rename_dst_nr == 0 || rename_src_nr == 0)
> +       if (rename_dst_nr == 0 || rename_src_nr == 0 || minimum_score > MAX_SCORE)
This line is too long now.

Ciao, Johannes

Previous: Junio C HamanoNext: Felipe Gonçalves Assis
Message 5 of 8 in “Custom merge driver with no rename detection”
  1. Felipe Gonçalves AssisFeb 14, 2016
  2. Junio C HamanoFeb 15, 2016
  3. Johannes SchindelinFeb 15, 2016
  4. Junio C HamanoFeb 15, 2016
  5. Johannes SchindelinFeb 15, 2016
  6. Felipe Gonçalves AssisFeb 15, 2016
  7. Junio C HamanoFeb 15, 2016
  8. Felipe Gonçalves AssisFeb 16, 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.