Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-10-07 05:32:58 +0300
committerJunio C Hamano <gitster@pobox.com>2019-10-07 05:32:58 +0300
commit80693e3f09ab80cfe4a5a83467e765626ad0b15a (patch)
tree1100110f21941cbe7510a43d41c8121d59761030 /commit-graph.c
parentae203ba414f7e0b83f8b07255898a6cff3b5c07e (diff)
parent806278dead57766bf000af62dcb8892ee3a24956 (diff)
Merge branch 'tb/commit-graph-harden'
The code to parse and use the commit-graph file has been made more robust against corrupted input. * tb/commit-graph-harden: commit-graph.c: handle corrupt/missing trees commit-graph.c: handle commit parsing errors t/t5318: introduce failing 'git commit-graph write' tests
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/commit-graph.c b/commit-graph.c
index c3ba79fe4e..6ae2009a96 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -846,12 +846,19 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
while (list < last) {
struct commit_list *parent;
+ struct object_id *tree;
int edge_value;
uint32_t packedDate[2];
display_progress(ctx->progress, ++ctx->progress_cnt);
- parse_commit_no_graph(*list);
- hashwrite(f, get_commit_tree_oid(*list)->hash, hash_len);
+ if (parse_commit_no_graph(*list))
+ die(_("unable to parse commit %s"),
+ oid_to_hex(&(*list)->object.oid));
+ tree = get_commit_tree_oid(*list);
+ if (!tree)
+ die(_("unable to get tree for %s"),
+ oid_to_hex(&(*list)->object.oid));
+ hashwrite(f, tree->hash, hash_len);
parent = (*list)->parents;