summaryrefslogtreecommitdiff
path: root/notes-merge.h
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2010-11-09 22:49:46 +0100
committerJunio C Hamano <gitster@pobox.com>2010-11-17 13:21:30 -0800
commit75ef3f4a5cc69b21bc825ed0e739030d77a4f077 (patch)
tree0159ebbc0a52781b645de37059689c6e679176b2 /notes-merge.h
parent8ef313e1ec3b9b8ca47dce1fec632597aa34bedc (diff)
downloadgit-75ef3f4a5cc69b21bc825ed0e739030d77a4f077.tar.gz
git notes merge: Initial implementation handling trivial merges only
This initial implementation of 'git notes merge' only handles the trivial merge cases (i.e. where the merge is either a no-op, or a fast-forward). The patch includes testcases for these trivial merge cases. Future patches will extend the functionality of 'git notes merge'. This patch has been improved by the following contributions: - Stephen Boyd: Simplify argc logic - Stephen Boyd: Use test_commit - Ævar Arnfjörð Bjarmason: Don't use C99 comments. - Jonathan Nieder: Add constants for common verbosity values - Jonathan Nieder: Use trace_printf(...) instead of OUTPUT(o, 5, ...) - Jonathan Nieder: Remove extraneous show() function - Jonathan Nieder: Clarify handling of empty/missing notes ref in notes_merge() - Junio C Hamano: fixup minor style issues Thanks-to: Stephen Boyd <bebarino@gmail.com> Thanks-to: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Thanks-to: Jonathan Nieder <jrnieder@gmail.com> Thanks-to: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes-merge.h')
-rw-r--r--notes-merge.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/notes-merge.h b/notes-merge.h
new file mode 100644
index 0000000000..fd572ac35c
--- /dev/null
+++ b/notes-merge.h
@@ -0,0 +1,36 @@
+#ifndef NOTES_MERGE_H
+#define NOTES_MERGE_H
+
+enum notes_merge_verbosity {
+ NOTES_MERGE_VERBOSITY_DEFAULT = 2,
+ NOTES_MERGE_VERBOSITY_MAX = 5
+};
+
+struct notes_merge_options {
+ const char *local_ref;
+ const char *remote_ref;
+ int verbosity;
+};
+
+void init_notes_merge_options(struct notes_merge_options *o);
+
+/*
+ * Merge notes from o->remote_ref into o->local_ref
+ *
+ * The commits given by the two refs are merged, producing one of the following
+ * outcomes:
+ *
+ * 1. The merge trivially results in an existing commit (e.g. fast-forward or
+ * already-up-to-date). The SHA1 of the result is written into 'result_sha1'
+ * and 0 is returned.
+ * 2. The merge fails. result_sha1 is set to null_sha1, and non-zero returned.
+ *
+ * Both o->local_ref and o->remote_ref must be given (non-NULL), but either ref
+ * (although not both) may refer to a non-existing notes ref, in which case
+ * that notes ref is interpreted as an empty notes tree, and the merge
+ * trivially results in what the other ref points to.
+ */
+int notes_merge(struct notes_merge_options *o,
+ unsigned char *result_sha1);
+
+#endif