path: root/notes-merge.c
diff options
authorJohan Herland <>2010-11-14 23:57:17 (GMT)
committerJunio C Hamano <>2010-11-17 21:22:53 (GMT)
commita6a09095a08339afc8468d053ff978ed4662a1d5 (patch)
tree915beb0e1f4fbe5fe5932b8188a1ac983c7ed786 /notes-merge.c
parent6cfd6a9dea889707fa207ee2003010c3b56b2131 (diff)
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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'notes-merge.c')
1 files changed, 7 insertions, 0 deletions
diff --git a/notes-merge.c b/notes-merge.c
index 459b1c2..71c4d45 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -453,6 +453,13 @@ static int merge_one_change(struct notes_merge_options *o,
die("failed to concatenate notes "
return 0;
+ OUTPUT(o, 2, "Concatenating unique lines in local and remote "
+ "notes for %s", sha1_to_hex(p->obj));
+ if (add_note(t, p->obj, p->remote, combine_notes_cat_sort_uniq))
+ die("failed to concatenate notes "
+ "(combine_notes_cat_sort_uniq)");
+ return 0;
die("Unknown strategy (%i).", o->strategy);