aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-25 11:07:47 -0700
committerJunio C Hamano <gitster@pobox.com>2014-03-25 11:07:48 -0700
commit46c0f913a49218a8a94d30c5a2df792a16aab827 (patch)
treeefc504f849bced5dd3c5b155ab5c4fce4fcbcf14 /builtin
parentd4c6e9fb6f0db328a40905a3555f8f41d37aaec5 (diff)
parent75df1f434f8cfdac1c8eeacae259ab375c01385b (diff)
downloadgit-46c0f913a49218a8a94d30c5a2df792a16aab827.tar.gz
git-46c0f913a49218a8a94d30c5a2df792a16aab827.tar.xz
Merge branch 'nd/commit-editor-cleanup'
"git commit --cleanup=<mode>" learned a new mode, scissors. * nd/commit-editor-cleanup: commit: add --cleanup=scissors wt-status.c: move cut-line print code out to wt_status_add_cut_line wt-status.c: make cut_line[] const to shrink .data section a bit
Diffstat (limited to 'builtin')
-rw-r--r--builtin/commit.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 3783bcadc..38f34e7cd 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -113,6 +113,7 @@ static char *sign_commit;
static enum {
CLEANUP_SPACE,
CLEANUP_NONE,
+ CLEANUP_SCISSORS,
CLEANUP_ALL
} cleanup_mode;
static const char *cleanup_arg;
@@ -755,7 +756,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
int ident_shown = 0;
int saved_color_setting;
char *ai_tmp, *ci_tmp;
- if (whence != FROM_COMMIT)
+ if (whence != FROM_COMMIT) {
+ if (cleanup_mode == CLEANUP_SCISSORS)
+ wt_status_add_cut_line(s->fp);
status_printf_ln(s, GIT_COLOR_NORMAL,
whence == FROM_MERGE
? _("\n"
@@ -771,6 +774,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
git_path(whence == FROM_MERGE
? "MERGE_HEAD"
: "CHERRY_PICK_HEAD"));
+ }
fprintf(s->fp, "\n");
if (cleanup_mode == CLEANUP_ALL)
@@ -778,6 +782,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
_("Please enter the commit message for your changes."
" Lines starting\nwith '%c' will be ignored, and an empty"
" message aborts the commit.\n"), comment_line_char);
+ else if (cleanup_mode == CLEANUP_SCISSORS && whence == FROM_COMMIT)
+ wt_status_add_cut_line(s->fp);
else /* CLEANUP_SPACE, that is. */
status_printf(s, GIT_COLOR_NORMAL,
_("Please enter the commit message for your changes."
@@ -1133,6 +1139,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
cleanup_mode = CLEANUP_SPACE;
else if (!strcmp(cleanup_arg, "strip"))
cleanup_mode = CLEANUP_ALL;
+ else if (!strcmp(cleanup_arg, "scissors"))
+ cleanup_mode = use_editor ? CLEANUP_SCISSORS : CLEANUP_SPACE;
else
die(_("Invalid cleanup mode %s"), cleanup_arg);
@@ -1605,8 +1613,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
die(_("could not read commit message: %s"), strerror(saved_errno));
}
- /* Truncate the message just before the diff, if any. */
- if (verbose)
+ if (verbose || /* Truncate the message just before the diff, if any. */
+ cleanup_mode == CLEANUP_SCISSORS)
wt_status_truncate_message_at_cut_line(&sb);
if (cleanup_mode != CLEANUP_NONE)