X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-commit.c;h=93ca49635731942c72cb52b27b1a6ba53becd1ca;hb=1689c5de8730ea334535337a341db3c7a21ad002;hp=2c33af276671ff0ba4bffee437a03e7fc2a7fae2;hpb=ce6e5ff435f325769dd28980cf3c8b1625f194f2;p=git.git diff --git a/builtin-commit.c b/builtin-commit.c index 2c33af276..93ca49635 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -320,7 +320,9 @@ static char *prepare_index(int argc, const char **argv, const char *prefix) die("unable to write new_index file"); fd = hold_lock_file_for_update(&false_lock, - git_path("next-index-%"PRIuMAX, (uintmax_t) getpid()), 1); + git_path("next-index-%"PRIuMAX, + (uintmax_t) getpid()), + LOCK_DIE_ON_ERROR); create_base_index(); add_remove_files(&partial); @@ -943,6 +945,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix) unsigned char commit_sha1[20]; struct ref_lock *ref_lock; struct commit_list *parents = NULL, **pptr = &parents; + struct stat statbuf; + int allow_fast_forward = 1; git_config(git_commit_config, NULL); @@ -989,13 +993,22 @@ int cmd_commit(int argc, const char **argv, const char *prefix) } fclose(fp); strbuf_release(&m); + if (!stat(git_path("MERGE_MODE"), &statbuf)) { + if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0) + die("could not read MERGE_MODE: %s", + strerror(errno)); + if (!strcmp(sb.buf, "no-ff")) + allow_fast_forward = 0; + } + if (allow_fast_forward) + parents = reduce_heads(parents); } else { reflog_msg = "commit"; pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next; } - parents = reduce_heads(parents); /* Finally, get the commit message */ + strbuf_reset(&sb); if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) { rollback_index_files(); die("could not read commit message"); @@ -1044,6 +1057,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) unlink(git_path("MERGE_HEAD")); unlink(git_path("MERGE_MSG")); + unlink(git_path("MERGE_MODE")); unlink(git_path("SQUASH_MSG")); if (commit_index_files())