summaryrefslogtreecommitdiff
path: root/diff-merges.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2022-02-02 02:37:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-02-02 18:02:27 (GMT)
commitdb757e8b8d5527c195c461a04ec35d141ddea48e (patch)
treea7f6eff8d025937db3e7344eee1e500ac9cb377b /diff-merges.c
parent504683162642c0db86c844ea37cad339f928ea9c (diff)
downloadgit-db757e8b8d5527c195c461a04ec35d141ddea48e.zip
git-db757e8b8d5527c195c461a04ec35d141ddea48e.tar.gz
git-db757e8b8d5527c195c461a04ec35d141ddea48e.tar.bz2
show, log: provide a --remerge-diff capability
When this option is specified, we remerge all (two parent) merge commits and diff the actual merge commit to the automatically created version, in order to show how users removed conflict markers, resolved the different conflict versions, and potentially added new changes outside of conflict regions in order to resolve semantic merge problems (or, possibly, just to hide other random changes). This capability works by creating a temporary object directory and marking it as the primary object store. This makes it so that any blobs or trees created during the automatic merge are easily removable afterwards by just deleting all objects from the temporary object directory. There are a few ways that this implementation is suboptimal: * `log --remerge-diff` becomes slow, because the temporary object directory can fill with many loose objects while running * the log output can be muddied with misplaced "warning: cannot merge binary files" messages, since ll-merge.c unconditionally writes those messages to stderr while running instead of allowing callers to manage them. * important conflict and warning messages are simply dropped; thus for conflicts like modify/delete or rename/rename or file/directory which are not representable with content conflict markers, there may be no way for a user of --remerge-diff to know that there had been a conflict which was resolved (and which possibly motivated other changes in the merge commit). * when fixing the previous issue, note that some unimportant conflict and warning messages might start being included. We should instead make sure these remain dropped. Subsequent commits will address these issues. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-merges.c')
-rw-r--r--diff-merges.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/diff-merges.c b/diff-merges.c
index 5060ccd..0af4b3f 100644
--- a/diff-merges.c
+++ b/diff-merges.c
@@ -17,6 +17,7 @@ static void suppress(struct rev_info *revs)
revs->combined_all_paths = 0;
revs->merges_imply_patch = 0;
revs->merges_need_diff = 0;
+ revs->remerge_diff = 0;
}
static void set_separate(struct rev_info *revs)
@@ -45,6 +46,12 @@ static void set_dense_combined(struct rev_info *revs)
revs->dense_combined_merges = 1;
}
+static void set_remerge_diff(struct rev_info *revs)
+{
+ suppress(revs);
+ revs->remerge_diff = 1;
+}
+
static diff_merges_setup_func_t func_by_opt(const char *optarg)
{
if (!strcmp(optarg, "off") || !strcmp(optarg, "none"))
@@ -57,6 +64,8 @@ static diff_merges_setup_func_t func_by_opt(const char *optarg)
return set_combined;
else if (!strcmp(optarg, "cc") || !strcmp(optarg, "dense-combined"))
return set_dense_combined;
+ else if (!strcmp(optarg, "r") || !strcmp(optarg, "remerge"))
+ return set_remerge_diff;
else if (!strcmp(optarg, "m") || !strcmp(optarg, "on"))
return set_to_default;
return NULL;
@@ -110,6 +119,9 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
} else if (!strcmp(arg, "--cc")) {
set_dense_combined(revs);
revs->merges_imply_patch = 1;
+ } else if (!strcmp(arg, "--remerge-diff")) {
+ set_remerge_diff(revs);
+ revs->merges_imply_patch = 1;
} else if (!strcmp(arg, "--no-diff-merges")) {
suppress(revs);
} else if (!strcmp(arg, "--combined-all-paths")) {