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

[PATCH] diff: make -M -C mean the same as -C -M

From
Mike Hommey <mh@glandium.org>
Date
Jan 23, 2015, 02:07 UTC
Message-ID
<1421978835-9921-1-git-send-email-mh@glandium.org>

While -C implies -M, it is quite common to see both on example command lines here and there. The unintuitive thing is that if -M appears after -C, then copy detection is turned off because of how the command line arguments are handled.

Change this so that when both -C and -M appear, whatever their order, copy detection is on.

Signed-off-by: Mike Hommey <mh@glandium.org>
---

Interestingly, I even found mentions of -C -M in this order for benchmarks, on this very list (see 6555655.XSJ9EnW4BY@mako).

 diff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/diff.c b/diff.c
index d1bd534..9081fd8 100644
--- a/diff.c
+++ b/diff.c
@@ -3670,7 +3670,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 		 !strcmp(arg, "--find-renames")) {
 		if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
 			return error("invalid argument to -M: %s", arg+2);
-		options->detect_rename = DIFF_DETECT_RENAME;
+		if (options->detect_rename != DIFF_DETECT_COPY)
+			options->detect_rename = DIFF_DETECT_RENAME;
 	}
 	else if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
 		options->irreversible_delete = 1;
-- 
2.2.2.2.g806f5e2.dirty
Next: Junio C Hamano
Message 1 of 4 in “diff: make -M -C mean the same as -C -M”
  1. diff: make -M -C mean the same as -C -MMike Hommey, Jan 23, 2015
  2. Junio C HamanoJan 23, 2015
  3. Mike HommeyJan 23, 2015
  4. Junio C HamanoJan 23, 2015

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.