From: Junio C Hamano Date: Mon, 8 Aug 2016 21:21:38 +0000 (-0700) Subject: Merge branch 'pb/commit-editmsg-path' into maint X-Git-Tag: v2.9.3~36 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a220e2bbbfb325fee6c1ffb1dcdf415bfcd59ae5?ds=inline;hp=-c Merge branch 'pb/commit-editmsg-path' into maint Code clean-up. * pb/commit-editmsg-path: builtin/commit.c: memoize git-path for COMMIT_EDITMSG --- a220e2bbbfb325fee6c1ffb1dcdf415bfcd59ae5 diff --combined builtin/commit.c index 37702f3561,18c890e567..1f6dbcd0d0 --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -92,8 -92,9 +92,9 @@@ N_("If you wish to skip this commit, us "Then \"git cherry-pick --continue\" will resume cherry-picking\n" "the remaining commits.\n"); + static GIT_PATH_FUNC(git_path_commit_editmsg, "COMMIT_EDITMSG") + static const char *use_message_buffer; - static const char commit_editmsg[] = "COMMIT_EDITMSG"; static struct lock_file index_lock; /* real index */ static struct lock_file false_lock; /* used only for partial commits */ static enum { @@@ -386,7 -387,7 +387,7 @@@ static const char *prepare_index(int ar */ if (all || (also && pathspec.nr)) { hold_locked_index(&index_lock, 1); - add_files_to_cache(also ? prefix : NULL, &pathspec, 0); + add_files_to_cache(also ? prefix : NULL, &pathspec, 0, 0); refresh_cache_or_die(refresh_flags); update_main_cache_tree(WRITE_TREE_SILENT); if (write_locked_index(&the_index, &index_lock, CLOSE_LOCK)) @@@ -714,7 -715,7 +715,7 @@@ static int prepare_to_commit(const cha char *buffer; buffer = strstr(use_message_buffer, "\n\n"); if (buffer) - strbuf_addstr(&sb, buffer + 2); + strbuf_addstr(&sb, skip_blank_lines(buffer + 2)); hook_arg1 = "commit"; hook_arg2 = use_message; } else if (fixup_message) { @@@ -772,9 -773,9 +773,9 @@@ hook_arg2 = ""; } - s->fp = fopen_for_writing(git_path(commit_editmsg)); + s->fp = fopen_for_writing(git_path_commit_editmsg()); if (s->fp == NULL) - die_errno(_("could not open '%s'"), git_path(commit_editmsg)); + die_errno(_("could not open '%s'"), git_path_commit_editmsg()); /* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */ old_display_comment_prefix = s->display_comment_prefix; @@@ -951,7 -952,7 +952,7 @@@ } if (run_commit_hook(use_editor, index_file, "prepare-commit-msg", - git_path(commit_editmsg), hook_arg1, hook_arg2, NULL)) + git_path_commit_editmsg(), hook_arg1, hook_arg2, NULL)) return 0; if (use_editor) { @@@ -959,7 -960,7 +960,7 @@@ const char *env[2] = { NULL }; env[0] = index; snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file); - if (launch_editor(git_path(commit_editmsg), NULL, env)) { + if (launch_editor(git_path_commit_editmsg(), NULL, env)) { fprintf(stderr, _("Please supply the message using either -m or -F option.\n")); exit(1); @@@ -967,7 -968,7 +968,7 @@@ } if (!no_verify && - run_commit_hook(use_editor, index_file, "commit-msg", git_path(commit_editmsg), NULL)) { + run_commit_hook(use_editor, index_file, "commit-msg", git_path_commit_editmsg(), NULL)) { return 0; } @@@ -1738,7 -1739,7 +1739,7 @@@ int cmd_commit(int argc, const char **a /* Finally, get the commit message */ strbuf_reset(&sb); - if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) { + if (strbuf_read_file(&sb, git_path_commit_editmsg(), 0) < 0) { int saved_errno = errno; rollback_index_files(); die(_("could not read commit message: %s"), strerror(saved_errno));