Simplify history if --no-merges is set, even if no pathspec is given. Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxxxxxxxxxx> --- Hi! If I merge in a branch with -s ours, plain git log will still show commits from this branch: $git checkout b $git merge -s ours a $ git log --pretty=oneline 185166cad796945c52769033f16a4c1c9cd02f08 Merge branch 'a' into b 4ee339d9c905dcc39e208fd476a5ca1163d2f8b3 commit for branch b a2c872723eb585665c5e092059cc97115e63e80f commit for branch a 0b4a099bd90c2ffcd21273afd59a0ee7d182a084 initial commit If I limit the log to a path (any path), git log simplifies the commit history: $git log --pretty=oneline -- . 4ee339d9c905dcc39e208fd476a5ca1163d2f8b3 commit for branch b 0b4a099bd90c2ffcd21273afd59a0ee7d182a084 initial commit Which is better IMO, because the a branch is actually ignored. But, is this behaviour documented? I actually discovered this trick looking at the source: setup_revisions does /* First, search for "--" */ seen_dashdash = 0; for (i = 1; i < argc; i++) { const char *arg = argv[i]; if (strcmp(arg, "--")) continue; argv[i] = NULL; argc = i; revs->prune_data = get_pathspec(revs->prefix, argv + i + 1); seen_dashdash = 1; break; } so prune_data seems to be set if there's a path spec; and then if (revs->prune_data) { diff_tree_setup_paths(revs->prune_data, &revs->pruning); /* Can't prune commits with rename following: the paths change.. */ if (!revs->diffopt.follow_renames) revs->prune_fn = try_to_simplify_commit; if (!revs->full_diff) diff_tree_setup_paths(revs->prune_data, &revs->diffopt); } so try_to_simplify_commit is only called if there is prune_data, Further, man git-rev-list says --full-history:: Show also parts of history irrelevant to current state of a given path. This turns off history simplification, which removed merges which didn't change anything at all at some child. It will still actually simplify away merges that didn't change anything at all into either child. which makes it seem like the default should be to do history simplification, but what actually happens is that the default is not to do simplification unless you give a path, in which case the default is to do simplification, and --full-history changes this: $git-rev-list HEAD 185166cad796945c52769033f16a4c1c9cd02f08 4ee339d9c905dcc39e208fd476a5ca1163d2f8b3 a2c872723eb585665c5e092059cc97115e63e80f 0b4a099bd90c2ffcd21273afd59a0ee7d182a084 So it didn't hide branch a. Wouldn't it make sense to make the simplified form a default, or enable it if --no-merges is set, or add a flag to enable history simplification, or at least document this better? The following patch implements the second option. Comments? I would also really like to see, by default: $ git log --pretty=oneline 185166cad796945c52769033f16a4c1c9cd02f08 Merge branch 'a' into b 4ee339d9c905dcc39e208fd476a5ca1163d2f8b3 commit for branch b 0b4a099bd90c2ffcd21273afd59a0ee7d182a084 initial commit Opinions? diff --git a/revision.c b/revision.c index 51fff0e..746eb9f 100644 --- a/revision.c +++ b/revision.c @@ -1262,7 +1262,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch revs->prune_fn = try_to_simplify_commit; if (!revs->full_diff) diff_tree_setup_paths(revs->prune_data, &revs->diffopt); - } + } else if (revs->no_merges) /* Simplification can hide merge commits */ + revs->prune_fn = try_to_simplify_commit; + if (revs->combine_merges) { revs->ignore_merges = 0; if (revs->dense_combined_merges && !revs->diffopt.output_format) -- MST - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html