summaryrefslogtreecommitdiff
path: root/commit-graph.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2018-04-10 12:56:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-11 01:43:02 (GMT)
commit7547b95b4fbb8591726b1d9381c176cc27fc6aea (patch)
tree0de2b763a40f4c07eee2ddbf40fd50eaf82dc996 /commit-graph.c
parent3d5df01b5e42416a59e857135e932bbdd8cc3ba0 (diff)
downloadgit-7547b95b4fbb8591726b1d9381c176cc27fc6aea.zip
git-7547b95b4fbb8591726b1d9381c176cc27fc6aea.tar.gz
git-7547b95b4fbb8591726b1d9381c176cc27fc6aea.tar.bz2
commit-graph: implement "--append" option
Teach git-commit-graph to add all commits from the existing commit-graph file to the file about to be written. This should be used when adding new commits without performing garbage collection. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/commit-graph.c b/commit-graph.c
index a59d1e3..3ff8c84 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -553,7 +553,8 @@ void write_commit_graph(const char *obj_dir,
const char **pack_indexes,
int nr_packs,
const char **commit_hex,
- int nr_commits)
+ int nr_commits,
+ int append)
{
struct packed_oid_list oids;
struct packed_commit_list commits;
@@ -571,10 +572,24 @@ void write_commit_graph(const char *obj_dir,
oids.nr = 0;
oids.alloc = approximate_object_count() / 4;
+ if (append) {
+ prepare_commit_graph_one(obj_dir);
+ if (commit_graph)
+ oids.alloc += commit_graph->num_commits;
+ }
+
if (oids.alloc < 1024)
oids.alloc = 1024;
ALLOC_ARRAY(oids.list, oids.alloc);
+ if (append && commit_graph) {
+ for (i = 0; i < commit_graph->num_commits; i++) {
+ const unsigned char *hash = commit_graph->chunk_oid_lookup +
+ commit_graph->hash_len * i;
+ hashcpy(oids.list[oids.nr++].hash, hash);
+ }
+ }
+
if (pack_indexes) {
struct strbuf packname = STRBUF_INIT;
int dirlen;