]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Move create_notes_commit() from notes-merge.c into notes-utils.c
authorJohan Herland <johan@herland.net>
Wed, 12 Jun 2013 00:13:01 +0000 (02:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Jun 2013 17:38:13 +0000 (10:38 -0700)
create_notes_commit() is needed by both the notes-merge code, and by
commit_notes() in notes-utils. Since it is generally useful, and not
bound to the notes-merge machinery, we move it from (the more specific)
notes-merge to (the more general) notes-utils.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes-merge.c
notes-merge.h
notes-utils.c
notes-utils.h

index 0f67bd3f9605aa7a3c98b88b4ae4aae037ace3d7..ab1885707403e06fe058ece2e0455e25e194224c 100644 (file)
@@ -9,6 +9,7 @@
 #include "notes.h"
 #include "notes-merge.h"
 #include "strbuf.h"
+#include "notes-utils.h"
 
 struct notes_merge_pair {
        unsigned char obj[20], base[20], local[20], remote[20];
@@ -530,32 +531,6 @@ static int merge_from_diffs(struct notes_merge_options *o,
        return conflicts ? -1 : 1;
 }
 
-void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
-                        const struct strbuf *msg, unsigned char *result_sha1)
-{
-       unsigned char tree_sha1[20];
-
-       assert(t->initialized);
-
-       if (write_notes_tree(t, tree_sha1))
-               die("Failed to write notes tree to database");
-
-       if (!parents) {
-               /* Deduce parent commit from t->ref */
-               unsigned char parent_sha1[20];
-               if (!read_ref(t->ref, parent_sha1)) {
-                       struct commit *parent = lookup_commit(parent_sha1);
-                       if (!parent || parse_commit(parent))
-                               die("Failed to find/parse commit %s", t->ref);
-                       commit_list_insert(parent, &parents);
-               }
-               /* else: t->ref points to nothing, assume root/orphan commit */
-       }
-
-       if (commit_tree(msg, tree_sha1, parents, result_sha1, NULL, NULL))
-               die("Failed to commit notes tree to database");
-}
-
 int notes_merge(struct notes_merge_options *o,
                struct notes_tree *local_tree,
                unsigned char *result_sha1)
index 0c11b173a1e38ddeb702e022ebdd571ed2ad12f3..1d01f6aacf54b27a498d6071b5ec80fee5c35a47 100644 (file)
@@ -25,20 +25,6 @@ struct notes_merge_options {
 
 void init_notes_merge_options(struct notes_merge_options *o);
 
-/*
- * Create new notes commit from the given notes tree
- *
- * Properties of the created commit:
- * - tree: the result of converting t to a tree object with write_notes_tree().
- * - parents: the given parents OR (if NULL) the commit referenced by t->ref.
- * - author/committer: the default determined by commmit_tree().
- * - commit message: msg
- *
- * The resulting commit SHA1 is stored in result_sha1.
- */
-void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
-                        const struct strbuf *msg, unsigned char *result_sha1);
-
 /*
  * Merge notes from o->remote_ref into o->local_ref
  *
index 5c9c976b80e01319bca05efcddf98685ec11f632..9107c379d905042807638c728ddeb52679c98e2a 100644 (file)
@@ -2,7 +2,32 @@
 #include "commit.h"
 #include "refs.h"
 #include "notes-utils.h"
-#include "notes-merge.h" /* for create_notes_commit() */
+
+void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
+                        const struct strbuf *msg, unsigned char *result_sha1)
+{
+       unsigned char tree_sha1[20];
+
+       assert(t->initialized);
+
+       if (write_notes_tree(t, tree_sha1))
+               die("Failed to write notes tree to database");
+
+       if (!parents) {
+               /* Deduce parent commit from t->ref */
+               unsigned char parent_sha1[20];
+               if (!read_ref(t->ref, parent_sha1)) {
+                       struct commit *parent = lookup_commit(parent_sha1);
+                       if (!parent || parse_commit(parent))
+                               die("Failed to find/parse commit %s", t->ref);
+                       commit_list_insert(parent, &parents);
+               }
+               /* else: t->ref points to nothing, assume root/orphan commit */
+       }
+
+       if (commit_tree(msg, tree_sha1, parents, result_sha1, NULL, NULL))
+               die("Failed to commit notes tree to database");
+}
 
 void commit_notes(struct notes_tree *t, const char *msg)
 {
index 0661e99909403e76ccdaa46504b12fd7614b2c76..b4cb1bfb4332a7e370071ac6699a9cf48e4da44c 100644 (file)
@@ -3,6 +3,20 @@
 
 #include "notes.h"
 
+/*
+ * Create new notes commit from the given notes tree
+ *
+ * Properties of the created commit:
+ * - tree: the result of converting t to a tree object with write_notes_tree().
+ * - parents: the given parents OR (if NULL) the commit referenced by t->ref.
+ * - author/committer: the default determined by commmit_tree().
+ * - commit message: msg
+ *
+ * The resulting commit SHA1 is stored in result_sha1.
+ */
+void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
+                        const struct strbuf *msg, unsigned char *result_sha1);
+
 void commit_notes(struct notes_tree *t, const char *msg);
 
 struct notes_rewrite_cfg {