mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-02 23:20:20 +00:00
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 <dirk@hohndel.org>
This commit is contained in:
parent
1be4435175
commit
6852c3b039
1 changed files with 5 additions and 3 deletions
|
@ -1070,12 +1070,14 @@ static int get_authorship(git_repository *repo, git_signature **authorp)
|
||||||
return git_signature_now(authorp, user.name, user.email);
|
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;
|
int nr = dive_table.nr;
|
||||||
struct dive *dive = get_dive(nr-1);
|
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;
|
dive_trip_t *trip = dive->divetrip;
|
||||||
const char *location = get_dive_location(dive) ? : "no location";
|
const char *location = get_dive_location(dive) ? : "no location";
|
||||||
struct divecomputer *dc = &dive->dc;
|
struct divecomputer *dc = &dive->dc;
|
||||||
|
@ -1153,7 +1155,7 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha
|
||||||
} else {
|
} else {
|
||||||
struct membuffer commit_msg = { 0 };
|
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))
|
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));
|
return report_error("Git commit create failed (%s)", strerror(errno));
|
||||||
free_buffer(&commit_msg);
|
free_buffer(&commit_msg);
|
||||||
|
|
Loading…
Reference in a new issue