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

[PATCH] Libified diff-index: backward compatibility fix.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 22, 2006, 11:04 UTC
Message-ID
<7vbqutkh1i.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7v64l1lxwj.fsf@assigned-by-dhcp.cox.net>

"diff-index -m" does not mean "do not ignore merges", but means "pretend missing files match the index".

The previous round tried to address this, but failed because setup_revisions() ate "-m" flag before the caller had a chance to intervene.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 diff-index.c |    6 ++----
 diff-lib.c   |   10 +++++++++-
 diff.h       |    2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/diff-index.c b/diff-index.c
index 4a243b3..8694012 100644
--- a/diff-index.c
+++ b/diff-index.c
@@ -23,9 +23,7 @@ int main(int argc, const char **argv)
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];
 			
-		if (!strcmp(arg, "-m"))
-			match_missing = 1; 
-		else if (!strcmp(arg, "--cached"))
+		if (!strcmp(arg, "--cached"))
 			cached = 1;
 		else
 			usage(diff_cache_usage);
@@ -37,5 +35,5 @@ int main(int argc, const char **argv)
 	if (!rev.pending_objects || rev.pending_objects->next ||
 	    rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
 		usage(diff_cache_usage);
-	return run_diff_index(&rev, cached, match_missing);
+	return run_diff_index(&rev, cached);
 }
diff --git a/diff-lib.c b/diff-lib.c
index 63da3b5..2183b41 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -308,12 +308,20 @@ static void mark_merge_entries(void)
 	}
 }
 
-int run_diff_index(struct rev_info *revs, int cached, int match_missing)
+int run_diff_index(struct rev_info *revs, int cached)
 {
 	int ret;
 	struct object *ent;
 	struct tree *tree;
 	const char *tree_name;
+	int match_missing = 0;
+
+	/* 
+	 * Backward compatibility wart - "diff-index -m" does
+	 * not mean "do not ignore merges", but totally different.
+	 */
+	if (!revs->ignore_merges)
+		match_missing = 1;
 
 	if (read_cache() < 0) {
 		perror("read_cache");
diff --git a/diff.h b/diff.h
index 837d449..7150b90 100644
--- a/diff.h
+++ b/diff.h
@@ -171,6 +171,6 @@ extern const char *diff_unique_abbrev(co
 
 extern int run_diff_files(struct rev_info *revs, int silent_on_removed);
 
-extern int run_diff_index(struct rev_info *revs, int cached, int match_missing);
+extern int run_diff_index(struct rev_info *revs, int cached);
 
 #endif /* DIFF_H */
-- 
1.3.0.g0bc6
Previous: Junio C Hamano
Message 2 of 2 in “Libify diff-index.”
  1. Libify diff-index.Junio C Hamano, Apr 22, 2006
  2. Libified diff-index: backward compatibility fix.Junio C Hamano, Apr 22, 2006

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.