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

Re: [PATCH] Avoid rename/add conflict when contents are identical

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 13, 2010, 01:18 UTC
Message-ID
<7vd3tnmht0.fsf@alter.siamese.dyndns.org>
In-Reply-To
<5C4EA6C5B30E6B45A9164CB3A26A0D326F79D9AA04@azsmsx503.amr.corp.intel.com>
"Schalk, Ken" <ken.schalk@intel.com> writes:
Show 23 quoted lines
> diff --git a/merge-recursive.c b/merge-recursive.c
> index fb6aa4a..57c7a85 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -955,6 +955,18 @@ static int process_renames(struct merge_options *o,
>                                                         ren1->pair->two : NULL,
>                                                         branch1 == o->branch1 ?
>                                                         NULL : ren1->pair->two, 1);
> +                       } else if ((dst_other.mode == ren1->pair->two->mode) &&
> +                                  sha_eq(dst_other.sha1, ren1->pair->two->sha1)) {
> +                               /* Added file on the other side
> +                                  identical to the file being
> +                                  renamed: clean merge */
> +                               update_file(o, 1, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
> +                               if (!o->call_depth)
> +                                       update_stages(ren1_dst, NULL,
> +                                                       branch1 == o->branch1 ?
> +                                                       ren1->pair->two : NULL,
> +                                                       branch1 == o->branch1 ?
> +                                                       NULL : ren1->pair->two, 1);
>                         } else if (!sha_eq(dst_other.sha1, null_sha1)) {
>                                 const char *new_path;
>                                 clean_merge = 0;

The logic seems to be clear enough. Could you write a test script instead of description in the commit log message, so that future changes to the codebase won't break this improvement?

Thanks.
Previous: Ævar Arnfjörð BjarmasonNext: Schalk, Ken
Message 3 of 8 in “Avoid rename/add conflict when contents are identical”
  1. Avoid rename/add conflict when contents are identicalSchalk, Ken, Aug 9, 2010
  2. Ævar Arnfjörð BjarmasonAug 9, 2010
  3. Junio C HamanoAug 13, 2010
  4. Schalk, KenAug 27, 2010
  5. Ævar Arnfjörð BjarmasonAug 28, 2010
  6. Schalk, KenAug 31, 2010
  7. Schalk, KenSep 1, 2010
  8. Junio C HamanoSep 3, 2010

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.