@matheusbsbs / matheus-bagliano / commits / 5c21ac0e7c
Fork 0

Libified diff-index: backward compatibility fix.

"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>

Junio C Hamano committed Apr 22, 2006 at 03:58 UTC 5c21ac0e7c475c82039ab604ee9d7d8430889346
3 files changed +12 -6
diff-index.c
+2 -4
@@ -23,9 +23,7 @@ int main(int argc, const char **argv)
23 for (i = 1; i < argc; i++) {
24 const char *arg = argv[i];
25
26 - if (!strcmp(arg, "-m"))
27 - match_missing = 1;
28 - else if (!strcmp(arg, "--cached"))
26 + if (!strcmp(arg, "--cached"))
27 cached = 1;
28 else
29 usage(diff_cache_usage);
@@ -37,5 +35,5 @@ int main(int argc, const char **argv)
35 if (!rev.pending_objects || rev.pending_objects->next ||
36 rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
37 usage(diff_cache_usage);
40 - return run_diff_index(&rev, cached, match_missing);
38 + return run_diff_index(&rev, cached);
39 }
diff-lib.c
+9 -1
@@ -308,12 +308,20 @@ static void mark_merge_entries(void)
308 }
309 }
310
311 -int run_diff_index(struct rev_info *revs, int cached, int match_missing)
311 +int run_diff_index(struct rev_info *revs, int cached)
312 {
313 int ret;
314 struct object *ent;
315 struct tree *tree;
316 const char *tree_name;
317 + int match_missing = 0;
318 +
319 + /*
320 + * Backward compatibility wart - "diff-index -m" does
321 + * not mean "do not ignore merges", but totally different.
322 + */
323 + if (!revs->ignore_merges)
324 + match_missing = 1;
325
326 if (read_cache() < 0) {
327 perror("read_cache");
diff.h
+1 -1
@@ -171,6 +171,6 @@ extern const char *diff_unique_abbrev(const unsigned char *, int);
171
172 extern int run_diff_files(struct rev_info *revs, int silent_on_removed);
173
174 -extern int run_diff_index(struct rev_info *revs, int cached, int match_missing);
174 +extern int run_diff_index(struct rev_info *revs, int cached);
175
176 #endif /* DIFF_H */