summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-07-29 20:10:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-29 20:43:57 (GMT)
commit6fae74b418da05a80897487805c833fd0b253df3 (patch)
tree5e8167bcf4b3a876bcb615ee1ba36b0ef95ca84d /revision.c
parenteed5332a13ef15391039e5e953462201978058ec (diff)
downloadgit-6fae74b418da05a80897487805c833fd0b253df3.zip
git-6fae74b418da05a80897487805c833fd0b253df3.tar.gz
git-6fae74b418da05a80897487805c833fd0b253df3.tar.bz2
revision: add "--no-diff-merges" option to counteract "-m"
The "-m" option sets revs->ignore_merges to "0", but there's no way to undo it. This probably isn't something anybody overly cares about, since "1" is already the default, but it will serve as an escape hatch when we flip the default for ignore_merges to "0" in more situations. We'll also add a few extra niceties: - initialize the value to "-1" to indicate "not set", and then resolve it to the normal 0/1 bool in setup_revisions(). This lets any tweak functions, as well as setup_revisions() itself, avoid clobbering the user's preference (which until now they couldn't actually express). - since we now have --no-diff-merges, let's add the matching --diff-merges, which is just a synonym for "-m". Then we don't even need to document --no-diff-merges separately; it countermands the long form of "-m" in the usual way. The new test shows that this behaves just the same as the current behavior without "-m". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/revision.c b/revision.c
index 6aa7f4f..669bc85 100644
--- a/revision.c
+++ b/revision.c
@@ -1795,7 +1795,7 @@ void repo_init_revisions(struct repository *r,
revs->repo = r;
revs->abbrev = DEFAULT_ABBREV;
- revs->ignore_merges = 1;
+ revs->ignore_merges = -1;
revs->simplify_history = 1;
revs->pruning.repo = r;
revs->pruning.flags.recursive = 1;
@@ -2323,8 +2323,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->diff = 1;
revs->diffopt.flags.recursive = 1;
revs->diffopt.flags.tree_in_recursive = 1;
- } else if (!strcmp(arg, "-m")) {
+ } else if (!strcmp(arg, "-m") || !strcmp(arg, "--diff-merges")) {
revs->ignore_merges = 0;
+ } else if (!strcmp(arg, "--no-diff-merges")) {
+ revs->ignore_merges = 1;
} else if (!strcmp(arg, "-c")) {
revs->diff = 1;
revs->dense_combined_merges = 0;
@@ -2834,8 +2836,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
copy_pathspec(&revs->diffopt.pathspec,
&revs->prune_data);
}
- if (revs->combine_merges)
+ if (revs->combine_merges && revs->ignore_merges < 0)
revs->ignore_merges = 0;
+ if (revs->ignore_merges < 0)
+ revs->ignore_merges = 1;
if (revs->combined_all_paths && !revs->combine_merges)
die("--combined-all-paths makes no sense without -c or --cc");