#include "cache.h"
#include "config.h"
#include "diff.h"
+#include "diff-merges.h"
#include "commit.h"
#include "revision.h"
#include "builtin.h"
rev.abbrev = 0;
prefix = precompose_argv_prefix(argc, argv, prefix);
+ /*
+ * We need no diff for merges options, and we need to avoid conflict
+ * with our own meaning of "-m".
+ */
+ diff_merges_suppress_options_parsing();
+
argc = setup_revisions(argc, argv, &rev, NULL);
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
option |= DIFF_INDEX_CACHED;
else if (!strcmp(arg, "--merge-base"))
option |= DIFF_INDEX_MERGE_BASE;
+ else if (!strcmp(arg, "-m"))
+ rev.match_missing = 1;
else
usage(diff_cache_usage);
}
static void set_separate(struct rev_info *revs);
static diff_merges_setup_func_t set_to_default = set_separate;
+static int suppress_parsing;
static void suppress(struct rev_info *revs)
{
revs->first_parent_merges = 1;
}
-static void set_m(struct rev_info *revs)
-{
- /*
- * To "diff-index", "-m" means "match missing", and to the "log"
- * family of commands, it means "show default diff for merges". Set
- * both fields appropriately.
- */
- set_to_default(revs);
- revs->match_missing = 1;
-}
-
static void set_combined(struct rev_info *revs)
{
suppress(revs);
return 0;
}
+void diff_merges_suppress_options_parsing(void)
+{
+ suppress_parsing = 1;
+}
+
int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
{
int argcount = 1;
const char *optarg;
const char *arg = argv[0];
+ if (suppress_parsing)
+ return 0;
+
if (!strcmp(arg, "-m")) {
- set_m(revs);
+ set_to_default(revs);
} else if (!strcmp(arg, "-c")) {
set_combined(revs);
revs->combined_imply_patch = 1;
void diff_merges_setup_revs(struct rev_info *revs)
{
+ if (suppress_parsing)
+ return;
+
if (revs->combine_merges == 0)
revs->dense_combined_merges = 0;
if (revs->separate_merges == 0)
int diff_merges_config(const char *value);
+void diff_merges_suppress_options_parsing(void);
+
int diff_merges_parse_opts(struct rev_info *revs, const char **argv);
void diff_merges_suppress(struct rev_info *revs);