diff --git a/builtin-log.c b/builtin-log.c
index fc5e47606c65962a7a1c1ab37a77f21f185a3bd5..fedb0137bc5e3ba50ecb90ce560ce9ce9290d8df 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
static int get_patch_id(struct commit *commit, struct diff_options *options,
unsigned char *sha1)
{
- diff_tree_sha1(commit->parents->item->object.sha1, commit->object.sha1,
- "", options);
+ if (commit->parents)
+ diff_tree_sha1(commit->parents->item->object.sha1,
+ commit->object.sha1, "", options);
+ else
+ diff_root_tree_sha1(commit->object.sha1, "", options);
diffcore_std(options);
return diff_flush_patch_id(options, sha1);
}