From 6852c3b039e5fb5b2f0330cb097f43af4f7f1ea2 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 26 Oct 2017 18:37:57 +0200 Subject: [PATCH] git save: create a better commit message for initial commit When we create an empty repo we should simply state that in the commit message. Signed-off-by: Dirk Hohndel --- core/save-git.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/save-git.c b/core/save-git.c index 436335a51..5ff67ddea 100644 --- a/core/save-git.c +++ b/core/save-git.c @@ -1070,12 +1070,14 @@ static int get_authorship(git_repository *repo, git_signature **authorp) return git_signature_now(authorp, user.name, user.email); } -static void create_commit_message(struct membuffer *msg) +static void create_commit_message(struct membuffer *msg, bool create_empty) { int nr = dive_table.nr; struct dive *dive = get_dive(nr-1); - if (dive) { + if (create_empty) { + put_string(msg, "Initial commit to create empty repo.\n\n"); + } else if (dive) { dive_trip_t *trip = dive->divetrip; const char *location = get_dive_location(dive) ? : "no location"; struct divecomputer *dc = &dive->dc; @@ -1153,7 +1155,7 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha } else { struct membuffer commit_msg = { 0 }; - create_commit_message(&commit_msg); + create_commit_message(&commit_msg, create_empty); if (git_commit_create_v(&commit_id, repo, NULL, author, author, NULL, mb_cstring(&commit_msg), tree, parent != NULL, parent)) return report_error("Git commit create failed (%s)", strerror(errno)); free_buffer(&commit_msg);