git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v8 4/8] notes: allow use of the "rewrite" terminology for merge strategies

From
Jacob Keller <jacob.e.keller@intel.com>
Date
Aug 17, 2015, 08:46 UTC
Message-ID
<1439801191-3026-5-git-send-email-jacob.e.keller@intel.com>
In-Reply-To
<1439801191-3026-1-git-send-email-jacob.e.keller@intel.com>
From: Jacob Keller <jacob.keller@gmail.com>

notes-merge.c already re-uses the same functions for the automatic merge strategies used by the rewrite functionality. Teach the -s/--strategy option how to interpret the equivalent rewrite terminology for consistency.

Add tests for the new synonyms.

Teaching rewrite how to understand merge terminology is left for a following patch.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
 Documentation/git-notes.txt         |  6 +++++
 notes-utils.c                       |  6 +++++
 t/t3309-notes-merge-auto-resolve.sh | 45 +++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)
diff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt
index 00c84be33ca9..5028e9355de5 100644
--- a/Documentation/git-notes.txt
+++ b/Documentation/git-notes.txt
@@ -250,13 +250,19 @@ When done, the user can either finalize the merge with
 "ours" automatically resolves conflicting notes in favor of the local
 version (i.e. the current notes ref).
 
+"ignore" is an alternative spelling for "ours".
+
 "theirs" automatically resolves notes conflicts in favor of the remote
 version (i.e. the given notes ref being merged into the current notes
 ref).
 
+"overwrite" is an alternative spelling for "theirs".
+
 "union" automatically resolves notes conflicts by concatenating the
 local and remote versions.
 
+"concatenate" is an alternative spelling for "union".
+
 "cat_sort_uniq" is similar to "union", but in addition to concatenating
 the local and remote versions, this strategy also sorts the resulting
 lines, and removes duplicate lines from the result. This is equivalent
diff --git a/notes-utils.c b/notes-utils.c
index 299e34bccc58..656b0ea152e2 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -60,10 +60,16 @@ int parse_notes_merge_strategy(const char *v, enum notes_merge_strategy *s)
 		*s = NOTES_MERGE_RESOLVE_MANUAL;
 	else if (!strcmp(v, "ours"))
 		*s = NOTES_MERGE_RESOLVE_OURS;
+	else if (!strcmp(v, "ignore"))
+		*s = NOTES_MERGE_RESOLVE_OURS;
 	else if (!strcmp(v, "theirs"))
 		*s = NOTES_MERGE_RESOLVE_THEIRS;
+	else if (!strcmp(v, "overwrite"))
+		*s = NOTES_MERGE_RESOLVE_THEIRS;
 	else if (!strcmp(v, "union"))
 		*s = NOTES_MERGE_RESOLVE_UNION;
+	else if (!strcmp(v, "concatenate"))
+		*s = NOTES_MERGE_RESOLVE_UNION;
 	else if (!strcmp(v, "cat_sort_uniq"))
 		*s = NOTES_MERGE_RESOLVE_CAT_SORT_UNIQ;
 	else
diff --git a/t/t3309-notes-merge-auto-resolve.sh b/t/t3309-notes-merge-auto-resolve.sh
index 461fd84755d7..909900672446 100755
--- a/t/t3309-notes-merge-auto-resolve.sh
+++ b/t/t3309-notes-merge-auto-resolve.sh
@@ -365,6 +365,17 @@ test_expect_success 'reset to pre-merge state (y)' '
 	verify_notes y y
 '
 
+test_expect_success 'merge z into y with "ignore" strategy => Non-conflicting 3-way merge' '
+	git notes merge --strategy=ignore z &&
+	verify_notes y ours
+'
+
+test_expect_success 'reset to pre-merge state (y)' '
+	git update-ref refs/notes/y refs/notes/y^1 &&
+	# Verify pre-merge state
+	verify_notes y y
+'
+
 cat <<EOF | sort >expect_notes_theirs
 9b4b2c61f0615412da3c10f98ff85b57c04ec765 $commit_sha15
 5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
@@ -432,6 +443,17 @@ test_expect_success 'reset to pre-merge state (y)' '
 	verify_notes y y
 '
 
+test_expect_success 'merge z into y with "overwrite" strategy => Non-conflicting 3-way merge' '
+	git notes merge --strategy=overwrite z &&
+	verify_notes y theirs
+'
+
+test_expect_success 'reset to pre-merge state (y)' '
+	git update-ref refs/notes/y refs/notes/y^1 &&
+	# Verify pre-merge state
+	verify_notes y y
+'
+
 cat <<EOF | sort >expect_notes_union
 7c4e546efd0fe939f876beb262ece02797880b54 $commit_sha15
 5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
@@ -505,6 +527,17 @@ test_expect_success 'reset to pre-merge state (y)' '
 	verify_notes y y
 '
 
+test_expect_success 'merge z into y with "concatenate" strategy => Non-conflicting 3-way merge' '
+	git notes merge --strategy=concatenate z &&
+	verify_notes y union
+'
+
+test_expect_success 'reset to pre-merge state (y)' '
+	git update-ref refs/notes/y refs/notes/y^1 &&
+	# Verify pre-merge state
+	verify_notes y y
+'
+
 cat <<EOF | sort >expect_notes_union2
 d682107b8bf7a7aea1e537a8d5cb6a12b60135f1 $commit_sha15
 5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
@@ -579,6 +612,18 @@ test_expect_success 'reset to pre-merge state (z)' '
 	verify_notes z z
 '
 
+test_expect_success 'merge y into z with "concatenate" strategy => Non-conflicting 3-way merge' '
+	git config core.notesRef refs/notes/z &&
+	git notes merge --strategy=concatenate y &&
+	verify_notes z union2
+'
+
+test_expect_success 'reset to pre-merge state (z)' '
+	git update-ref refs/notes/z refs/notes/z^1 &&
+	# Verify pre-merge state
+	verify_notes z z
+'
+
 cat <<EOF | sort >expect_notes_cat_sort_uniq
 6be90240b5f54594203e25d9f2f64b7567175aee $commit_sha15
 5de7ea7ad4f47e7ff91989fb82234634730f75df $commit_sha14
-- 
2.5.0.280.g4aaba03
Previous: Jacob KellerNext: Johan Herland
Message 5 of 14 in “implement notes.mergeStrategy option”
  1. 0/8 implement notes.mergeStrategy optionJacob Keller, Aug 17, 2015
  2. 1/8 notes: document cat_sort_uniq rewriteModeJacob Keller, Aug 17, 2015
  3. 2/8 notes: extract enum notes_merge_strategy to notes-utils.hJacob Keller, Aug 17, 2015
  4. 3/8 note: extract parse_notes_merge_strategy to notes-utilsJacob Keller, Aug 17, 2015
  5. 4/8 notes: allow use of the "rewrite" terminology for merge strategiesJacob Keller, Aug 17, 2015
  6. Johan HerlandAug 17, 2015
  7. Jacob KellerAug 17, 2015
  8. Junio C HamanoAug 17, 2015
  9. 5/8 notes: implement parse_combine_rewrite_fn using parse_notes_merge_strategyJacob Keller, Aug 17, 2015
  10. 6/8 notes: add tests for --commit/--abort/--strategy exclusivityJacob Keller, Aug 17, 2015
  11. 7/8 notes: add notes.mergeStrategy option to select default strategyJacob Keller, Aug 17, 2015
  12. 8/8 notes: teach git-notes about notes.<ref>.mergeStrategy optionJacob Keller, Aug 17, 2015
  13. Johan HerlandAug 17, 2015
  14. Jacob KellerAug 17, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.