Re: [PATCH 04/11] merge-ort: implement compare_pairs() and collect_renames()
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Dec 11, 2020, 03:00 UTC
- Message-ID
- <8d744966-2344-1dbc-f2a2-7411be3bfc8b@gmail.com>
- In-Reply-To
- <207bb9a837cb855721daa88caaad80e37cb40ffe.1607542887.git.gitgitgadget@gmail.com>
On 12/9/2020 2:41 PM, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail.com>
Perhaps worth pointing out comparison to score_compare()
Show 21 quoted lines
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
> merge-ort.c | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/merge-ort.c b/merge-ort.c
> index 1ff637e57af..3cdf8124b85 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> @@ -625,7 +625,13 @@ static int process_renames(struct merge_options *opt,
>
> static int compare_pairs(const void *a_, const void *b_)
> {
> - die("Not yet implemented.");
> + const struct diff_filepair *a = *((const struct diff_filepair **)a_);
> + const struct diff_filepair *b = *((const struct diff_filepair **)b_);
> +
> + int cmp = strcmp(a->one->path, b->one->path);
> + if (cmp)
> + return cmp;
> + return a->score - b->score;Hm. I wasn't sure what would happen when subtracting these "unsigned short" scores, but I see that score_compare() does the same. Any potential for an existing, hidden bug here?
Thanks, -Stolee