2023-02-24 00:09:20 +00:00
|
|
|
#include "git-compat-util.h"
|
2020-12-21 15:19:33 +00:00
|
|
|
#include "diff-merges.h"
|
|
|
|
|
2023-02-24 00:09:30 +00:00
|
|
|
#include "gettext.h"
|
2020-12-21 15:19:33 +00:00
|
|
|
#include "revision.h"
|
|
|
|
|
2021-04-13 11:41:14 +00:00
|
|
|
typedef void (*diff_merges_setup_func_t)(struct rev_info *);
|
|
|
|
static void set_separate(struct rev_info *revs);
|
|
|
|
|
|
|
|
static diff_merges_setup_func_t set_to_default = set_separate;
|
2021-09-01 16:52:20 +00:00
|
|
|
static int suppress_m_parsing;
|
2021-04-13 11:41:14 +00:00
|
|
|
|
2020-12-21 15:19:38 +00:00
|
|
|
static void suppress(struct rev_info *revs)
|
|
|
|
{
|
2020-12-21 15:19:46 +00:00
|
|
|
revs->separate_merges = 0;
|
2020-12-21 15:19:38 +00:00
|
|
|
revs->first_parent_merges = 0;
|
|
|
|
revs->combine_merges = 0;
|
|
|
|
revs->dense_combined_merges = 0;
|
2020-12-21 15:19:50 +00:00
|
|
|
revs->combined_all_paths = 0;
|
2021-05-20 21:47:02 +00:00
|
|
|
revs->merges_imply_patch = 0;
|
2020-12-21 15:19:53 +00:00
|
|
|
revs->merges_need_diff = 0;
|
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>
2022-02-02 02:37:28 +00:00
|
|
|
revs->remerge_diff = 0;
|
2020-12-21 15:19:38 +00:00
|
|
|
}
|
|
|
|
|
2022-09-14 19:31:01 +00:00
|
|
|
static void common_setup(struct rev_info *revs)
|
2020-12-21 15:19:49 +00:00
|
|
|
{
|
|
|
|
suppress(revs);
|
2022-09-14 19:31:01 +00:00
|
|
|
revs->merges_need_diff = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_none(struct rev_info *revs)
|
|
|
|
{
|
|
|
|
suppress(revs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_separate(struct rev_info *revs)
|
|
|
|
{
|
|
|
|
common_setup(revs);
|
2020-12-21 15:19:49 +00:00
|
|
|
revs->separate_merges = 1;
|
2022-02-02 02:37:37 +00:00
|
|
|
revs->simplify_history = 0;
|
2020-12-21 15:19:49 +00:00
|
|
|
}
|
|
|
|
|
2020-12-21 15:19:51 +00:00
|
|
|
static void set_first_parent(struct rev_info *revs)
|
|
|
|
{
|
|
|
|
set_separate(revs);
|
|
|
|
revs->first_parent_merges = 1;
|
|
|
|
}
|
|
|
|
|
2020-12-21 15:19:49 +00:00
|
|
|
static void set_combined(struct rev_info *revs)
|
|
|
|
{
|
2022-09-14 19:31:01 +00:00
|
|
|
common_setup(revs);
|
2020-12-21 15:19:49 +00:00
|
|
|
revs->combine_merges = 1;
|
|
|
|
revs->dense_combined_merges = 0;
|
|
|
|
}
|
|
|
|
|
2020-12-21 15:19:39 +00:00
|
|
|
static void set_dense_combined(struct rev_info *revs)
|
|
|
|
{
|
2022-09-14 19:31:01 +00:00
|
|
|
common_setup(revs);
|
2020-12-21 15:19:39 +00:00
|
|
|
revs->combine_merges = 1;
|
|
|
|
revs->dense_combined_merges = 1;
|
|
|
|
}
|
|
|
|
|
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>
2022-02-02 02:37:28 +00:00
|
|
|
static void set_remerge_diff(struct rev_info *revs)
|
|
|
|
{
|
2022-09-14 19:31:01 +00:00
|
|
|
common_setup(revs);
|
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>
2022-02-02 02:37:28 +00:00
|
|
|
revs->remerge_diff = 1;
|
2022-02-02 02:37:37 +00:00
|
|
|
revs->simplify_history = 0;
|
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>
2022-02-02 02:37:28 +00:00
|
|
|
}
|
|
|
|
|
2021-04-13 11:41:15 +00:00
|
|
|
static diff_merges_setup_func_t func_by_opt(const char *optarg)
|
2020-12-21 15:19:49 +00:00
|
|
|
{
|
2021-04-13 11:41:15 +00:00
|
|
|
if (!strcmp(optarg, "off") || !strcmp(optarg, "none"))
|
2022-09-14 19:31:01 +00:00
|
|
|
return set_none;
|
2020-12-21 15:19:55 +00:00
|
|
|
if (!strcmp(optarg, "1") || !strcmp(optarg, "first-parent"))
|
2021-04-13 11:41:15 +00:00
|
|
|
return set_first_parent;
|
2022-09-14 19:31:00 +00:00
|
|
|
if (!strcmp(optarg, "separate"))
|
2021-04-13 11:41:15 +00:00
|
|
|
return set_separate;
|
2022-09-14 19:31:00 +00:00
|
|
|
if (!strcmp(optarg, "c") || !strcmp(optarg, "combined"))
|
2021-04-13 11:41:15 +00:00
|
|
|
return set_combined;
|
2022-09-14 19:31:00 +00:00
|
|
|
if (!strcmp(optarg, "cc") || !strcmp(optarg, "dense-combined"))
|
2021-04-13 11:41:15 +00:00
|
|
|
return set_dense_combined;
|
2022-09-14 19:31:00 +00:00
|
|
|
if (!strcmp(optarg, "r") || !strcmp(optarg, "remerge"))
|
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>
2022-02-02 02:37:28 +00:00
|
|
|
return set_remerge_diff;
|
2022-09-14 19:31:00 +00:00
|
|
|
if (!strcmp(optarg, "m") || !strcmp(optarg, "on"))
|
2021-04-13 11:41:15 +00:00
|
|
|
return set_to_default;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_diff_merges(struct rev_info *revs, const char *optarg)
|
|
|
|
{
|
|
|
|
diff_merges_setup_func_t func = func_by_opt(optarg);
|
|
|
|
|
|
|
|
if (!func)
|
2022-01-31 22:07:47 +00:00
|
|
|
die(_("invalid value for '%s': '%s'"), "--diff-merges", optarg);
|
2020-12-21 15:19:53 +00:00
|
|
|
|
2021-04-13 11:41:15 +00:00
|
|
|
func(revs);
|
2020-12-21 15:19:49 +00:00
|
|
|
}
|
2020-12-21 15:19:39 +00:00
|
|
|
|
2020-12-21 15:19:37 +00:00
|
|
|
/*
|
|
|
|
* Public functions. They are in the order they are called.
|
|
|
|
*/
|
|
|
|
|
2021-04-13 11:41:17 +00:00
|
|
|
int diff_merges_config(const char *value)
|
|
|
|
{
|
|
|
|
diff_merges_setup_func_t func = func_by_opt(value);
|
|
|
|
|
|
|
|
if (!func)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
set_to_default = func;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-09-01 16:52:20 +00:00
|
|
|
void diff_merges_suppress_m_parsing(void)
|
2021-05-20 21:46:59 +00:00
|
|
|
{
|
2021-09-01 16:52:20 +00:00
|
|
|
suppress_m_parsing = 1;
|
2021-05-20 21:46:59 +00:00
|
|
|
}
|
|
|
|
|
2020-12-21 15:19:34 +00:00
|
|
|
int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
|
2020-12-21 15:19:33 +00:00
|
|
|
{
|
|
|
|
int argcount = 1;
|
|
|
|
const char *optarg;
|
|
|
|
const char *arg = argv[0];
|
|
|
|
|
2021-09-01 16:52:20 +00:00
|
|
|
if (!suppress_m_parsing && !strcmp(arg, "-m")) {
|
2021-05-20 21:46:59 +00:00
|
|
|
set_to_default(revs);
|
2022-09-14 19:31:01 +00:00
|
|
|
revs->merges_need_diff = 0;
|
2020-12-21 15:19:52 +00:00
|
|
|
} else if (!strcmp(arg, "-c")) {
|
2020-12-21 15:19:49 +00:00
|
|
|
set_combined(revs);
|
2021-05-20 21:47:02 +00:00
|
|
|
revs->merges_imply_patch = 1;
|
2020-12-21 15:19:52 +00:00
|
|
|
} else if (!strcmp(arg, "--cc")) {
|
2020-12-21 15:19:39 +00:00
|
|
|
set_dense_combined(revs);
|
2021-05-20 21:47:02 +00:00
|
|
|
revs->merges_imply_patch = 1;
|
2023-10-09 16:05:34 +00:00
|
|
|
} else if (!strcmp(arg, "--dd")) {
|
|
|
|
set_first_parent(revs);
|
|
|
|
revs->merges_imply_patch = 1;
|
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>
2022-02-02 02:37:28 +00:00
|
|
|
} else if (!strcmp(arg, "--remerge-diff")) {
|
|
|
|
set_remerge_diff(revs);
|
|
|
|
revs->merges_imply_patch = 1;
|
2020-12-21 15:19:52 +00:00
|
|
|
} else if (!strcmp(arg, "--no-diff-merges")) {
|
2022-09-14 19:31:01 +00:00
|
|
|
set_none(revs);
|
2020-12-21 15:19:52 +00:00
|
|
|
} else if (!strcmp(arg, "--combined-all-paths")) {
|
2020-12-21 15:19:33 +00:00
|
|
|
revs->combined_all_paths = 1;
|
2020-12-21 15:19:52 +00:00
|
|
|
} else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
|
2020-12-21 15:19:49 +00:00
|
|
|
set_diff_merges(revs, optarg);
|
2020-12-21 15:19:52 +00:00
|
|
|
} else
|
2020-12-21 15:19:46 +00:00
|
|
|
return 0;
|
2020-12-21 15:19:33 +00:00
|
|
|
|
2020-12-21 15:19:46 +00:00
|
|
|
revs->explicit_diff_merges = 1;
|
2020-12-21 15:19:33 +00:00
|
|
|
return argcount;
|
|
|
|
}
|
|
|
|
|
2020-12-21 15:19:38 +00:00
|
|
|
void diff_merges_suppress(struct rev_info *revs)
|
|
|
|
{
|
2022-09-14 19:31:01 +00:00
|
|
|
set_none(revs);
|
2020-12-21 15:19:38 +00:00
|
|
|
}
|
|
|
|
|
2020-12-21 15:19:36 +00:00
|
|
|
void diff_merges_default_to_first_parent(struct rev_info *revs)
|
2020-12-21 15:19:33 +00:00
|
|
|
{
|
2020-12-21 15:19:46 +00:00
|
|
|
if (!revs->explicit_diff_merges)
|
|
|
|
revs->separate_merges = 1;
|
|
|
|
if (revs->separate_merges)
|
2020-12-21 15:19:40 +00:00
|
|
|
revs->first_parent_merges = 1;
|
2020-12-21 15:19:33 +00:00
|
|
|
}
|
|
|
|
|
2020-12-21 15:19:34 +00:00
|
|
|
void diff_merges_default_to_dense_combined(struct rev_info *revs)
|
2020-12-21 15:19:33 +00:00
|
|
|
{
|
2020-12-21 15:19:46 +00:00
|
|
|
if (!revs->explicit_diff_merges)
|
|
|
|
set_dense_combined(revs);
|
2020-12-21 15:19:33 +00:00
|
|
|
}
|
2020-12-21 15:19:37 +00:00
|
|
|
|
2020-12-21 15:19:39 +00:00
|
|
|
void diff_merges_set_dense_combined_if_unset(struct rev_info *revs)
|
|
|
|
{
|
|
|
|
if (!revs->combine_merges)
|
|
|
|
set_dense_combined(revs);
|
|
|
|
}
|
|
|
|
|
2020-12-21 15:19:37 +00:00
|
|
|
void diff_merges_setup_revs(struct rev_info *revs)
|
|
|
|
{
|
2020-12-21 15:19:46 +00:00
|
|
|
if (revs->combine_merges == 0)
|
|
|
|
revs->dense_combined_merges = 0;
|
|
|
|
if (revs->separate_merges == 0)
|
|
|
|
revs->first_parent_merges = 0;
|
2020-12-21 15:19:37 +00:00
|
|
|
if (revs->combined_all_paths && !revs->combine_merges)
|
|
|
|
die("--combined-all-paths makes no sense without -c or --cc");
|
2021-05-20 21:47:02 +00:00
|
|
|
if (revs->merges_imply_patch)
|
2020-12-21 15:19:42 +00:00
|
|
|
revs->diff = 1;
|
2021-05-20 21:47:02 +00:00
|
|
|
if (revs->merges_imply_patch || revs->merges_need_diff) {
|
2020-12-21 15:19:41 +00:00
|
|
|
if (!revs->diffopt.output_format)
|
|
|
|
revs->diffopt.output_format = DIFF_FORMAT_PATCH;
|
|
|
|
}
|
2020-12-21 15:19:37 +00:00
|
|
|
}
|