diff options
author | Johan Herland <johan@herland.net> | 2010-11-15 00:57:17 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-11-17 13:22:53 -0800 |
commit | a6a09095a08339afc8468d053ff978ed4662a1d5 (patch) | |
tree | 915beb0e1f4fbe5fe5932b8188a1ac983c7ed786 /builtin | |
parent | git notes merge: --commit should fail if underlying notes ref has moved (diff) | |
download | tgif-a6a09095a08339afc8468d053ff978ed4662a1d5.tar.xz |
git notes merge: Add another auto-resolving strategy: "cat_sort_uniq"
This new strategy is similar to "concatenate", but in addition to
concatenating the two note candidates, this strategy sorts the resulting
lines, and removes duplicate lines from the result. This is equivalent to
applying the "cat | sort | uniq" shell pipeline to the two note candidates.
This strategy is useful if the notes follow a line-based format where one
wants to avoid duplicate lines in the merge result.
Note that if either of the note candidates contain duplicate lines _prior_
to the merge, these will also be removed by this merge strategy.
The patch also contains tests and documentation for the new strategy.
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/notes.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/notes.c b/builtin/notes.c index 710a89da28..455046e88a 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -324,6 +324,8 @@ combine_notes_fn parse_combine_notes_fn(const char *v) return combine_notes_ignore; else if (!strcasecmp(v, "concatenate")) return combine_notes_concatenate; + else if (!strcasecmp(v, "cat_sort_uniq")) + return combine_notes_cat_sort_uniq; else return NULL; } @@ -846,8 +848,8 @@ static int merge(int argc, const char **argv, const char *prefix) OPT__VERBOSITY(&verbosity), OPT_GROUP("Merge options"), OPT_STRING('s', "strategy", &strategy, "strategy", - "resolve notes conflicts using the given " - "strategy (manual/ours/theirs/union)"), + "resolve notes conflicts using the given strategy " + "(manual/ours/theirs/union/cat_sort_uniq)"), OPT_GROUP("Committing unmerged notes"), { OPTION_BOOLEAN, 0, "commit", &do_commit, NULL, "finalize notes merge by committing unmerged notes", @@ -899,6 +901,8 @@ static int merge(int argc, const char **argv, const char *prefix) o.strategy = NOTES_MERGE_RESOLVE_THEIRS; else if (!strcmp(strategy, "union")) o.strategy = NOTES_MERGE_RESOLVE_UNION; + else if (!strcmp(strategy, "cat_sort_uniq")) + o.strategy = NOTES_MERGE_RESOLVE_CAT_SORT_UNIQ; else { error("Unknown -s/--strategy: %s", strategy); usage_with_options(git_notes_merge_usage, options); |