Skip to content

Commit

Permalink
Libified diff-index: backward compatibility fix.
Browse files Browse the repository at this point in the history
"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>
  • Loading branch information
Junio C Hamano committed Apr 22, 2006
1 parent e09ad6e commit 5c21ac0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 2 additions & 4 deletions diff-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
10 changes: 9 additions & 1 deletion diff-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,6 @@ extern const char *diff_unique_abbrev(const unsigned char *, int);

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 */

0 comments on commit 5c21ac0

Please sign in to comment.