merge: use annotated commits for recursion · nodegit/libgit2@76ade3a · GitHub
Skip to content

Commit 76ade3a

Browse files
ethomsonEdward Thomson
authored andcommitted
merge: use annotated commits for recursion
Use annotated commits to act as our virtual bases, instead of regular commits, to avoid polluting the odb with virtual base commits and trees. Instead, build an annotated commit with an index and pointers to the commits that it was merged from.
1 parent 7730fe8 commit 76ade3a

3 files changed

Lines changed: 122 additions & 68 deletions

File tree

‎src/annotated_commit.c‎

Lines changed: 18 additions & 8 deletions

‎src/annotated_commit.h‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,31 @@
77
#ifndef INCLUDE_annotated_commit_h__
88
#define INCLUDE_annotated_commit_h__
99

10+
#include "oidarray.h"
11+
1012
#include "git2/oid.h"
1113

12-
/** Internal structure for merge inputs */
14+
typedef enum {
15+
GIT_ANNOTATED_COMMIT_REAL = 1,
16+
GIT_ANNOTATED_COMMIT_VIRTUAL = 2,
17+
} git_annotated_commit_t;
18+
19+
/**
20+
* Internal structure for merge inputs. An annotated commit is generally
21+
* "real" and backed by an actual commit in the repository, but merge will
22+
* internally create "virtual" commits that are in-memory intermediate
23+
* commits backed by an index.
24+
*/
1325
struct git_annotated_commit {
26+
git_annotated_commit_t type;
27+
28+
/* real commit */
1429
git_commit *commit;
30+
git_tree *tree;
31+
32+
/* virtual commit structure */
33+
git_index *index;
34+
git_array_oid_t parents;
1535

1636
char *ref_name;
1737
char *remote_url;

‎src/merge.c‎

Lines changed: 83 additions & 59 deletions

0 commit comments

Comments
 (0)