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

Re: [RFC/PATCH 01/18] Remove duplicate code

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 8, 2016, 23:34 UTC
Message-ID
<xmqqvb3ru13r.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1460098726-5958-2-git-send-email-newren@gmail.com>
Elijah Newren <newren@gmail.com> writes:
> Subject: Re: [RFC/PATCH 01/18] Remove duplicate code
Subject: [RFC/PATCH 01/18] merge-recursive: remove duplicate code
Show 6 quoted lines
> In commit 51931bf (merge-recursive: Improve handling of rename target vs.
> directory addition, 2011-08-11) I apparently added two lines of code that
> were immediately duplicated a few lines later.  No idea why, other than
> it seems pretty clear this was a mistake: there is no need to remove the
> same file twice; removing it once is sufficient...especially since the
> intervening line was working with a different file entirely.
Interesting.

I briefly wondered if the update_files() in the middle may be prevented by D/F conflict if you didn't remove the path beforehand, but path and new_path are both in the same directory, so that would not be the reason. Checking out 51931bf and running two tests (6022 and 6042) that were modified to protect the fix after applying this partial revert does not seem to break, either, so...

Reviewed-by: Junio C Hamano <gitster@pobox.com>
Show 19 quoted lines
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  merge-recursive.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/merge-recursive.c b/merge-recursive.c
> index b880ae5..d4292de 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -1773,8 +1773,6 @@ static int process_entry(struct merge_options *o,
>  			output(o, 1, _("CONFLICT (%s): There is a directory with name %s in %s. "
>  			       "Adding %s as %s"),
>  			       conf, path, other_branch, path, new_path);
> -			if (o->call_depth)
> -				remove_file_from_cache(path);
>  			update_file(o, 0, sha, mode, new_path);
>  			if (o->call_depth)
>  				remove_file_from_cache(path);
Previous: Elijah NewrenNext: Elijah Newren
Message 3 of 30 in “Add --index-only option to git merge”
  1. 00/18 Add --index-only option to git mergeElijah Newren, Apr 8, 2016
  2. 01/18 Remove duplicate codeElijah Newren, Apr 8, 2016
  3. Junio C HamanoApr 8, 2016
  4. 02/18 Avoid checking working copy when creating a virtual merge baseElijah Newren, Apr 8, 2016
  5. 03/18 Document weird bug in octopus merges via testcasesElijah Newren, Apr 8, 2016
  6. 04/18 merge-octopus: Abort if index not cleanElijah Newren, Apr 8, 2016
  7. Junio C HamanoApr 8, 2016
  8. 05/18 Add testcase for --index-only merges needing the recursive strategyElijah Newren, Apr 8, 2016
  9. Junio C HamanoApr 8, 2016
  10. Junio C HamanoApr 8, 2016
  11. 06/18 Add testcase for --index-only merges needing an ff updateElijah Newren, Apr 8, 2016
  12. 07/18 Add testcase for --index-only merges with the resolve strategyElijah Newren, Apr 8, 2016
  13. 08/18 Add testcase for --index-only merges with the octopus strategyElijah Newren, Apr 8, 2016
  14. 09/18 Add testcase for --index-only merges with the ours strategyElijah Newren, Apr 8, 2016
  15. 10/18 Add testcase for --index-only merges with the subtree strategyElijah Newren, Apr 8, 2016
  16. 11/18 merge: Add a new --index-only option, not yet implementedElijah Newren, Apr 8, 2016
  17. Junio C HamanoApr 8, 2016
  18. 12/18 Add --index-only support for recursive mergesElijah Newren, Apr 8, 2016
  19. 13/18 Add --index-only support with read_tree_trivial merges, kind ofElijah Newren, Apr 8, 2016
  20. 14/18 Add --index-only support for ff_only mergesElijah Newren, Apr 8, 2016
  21. 15/18 merge: Pass --index-only along to external merge strategy programsElijah Newren, Apr 8, 2016
  22. 16/18 git-merge-one-file.sh: support --index-only optionElijah Newren, Apr 8, 2016
  23. 17/18 git-merge-resolve.sh: support --index-only optionElijah Newren, Apr 8, 2016
  24. 18/18 git-merge-octopus.sh: support --index-only optionElijah Newren, Apr 8, 2016
  25. Michael J GruberApr 8, 2016
  26. Elijah NewrenApr 9, 2016
  27. Junio C HamanoApr 8, 2016
  28. Elijah NewrenApr 9, 2016
  29. Junio C HamanoApr 9, 2016
  30. Elijah NewrenApr 10, 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.