Skip to content

Commit e90cc07

Browse files
joshtriplettgitster
authored andcommitted
commit: unify logic to avoid multiple scissors lines when merging
prepare_to_commit has some logic to figure out whether merge already added a scissors line, and therefore it shouldn't add another. Now that wt_status_add_cut_line has built-in state for whether it has already added a previous line, just set that state instead, and then remove that condition from subsequent calls to wt_status_add_cut_line. Signed-off-by: Josh Triplett <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 688a0a7 commit e90cc07

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

builtin/commit.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,6 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
737737
const char *hook_arg2 = NULL;
738738
int clean_message_contents = (cleanup_mode != COMMIT_MSG_CLEANUP_NONE);
739739
int old_display_comment_prefix;
740-
int merge_contains_scissors = 0;
741740
int invoked_hook;
742741

743742
/* This checks and barfs if author is badly specified */
@@ -841,7 +840,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
841840
wt_status_locate_end(sb.buf + merge_msg_start,
842841
sb.len - merge_msg_start) <
843842
sb.len - merge_msg_start)
844-
merge_contains_scissors = 1;
843+
s->added_cut_line = 1;
845844
} else if (!stat(git_path_squash_msg(the_repository), &statbuf)) {
846845
if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)
847846
die_errno(_("could not read SQUASH_MSG"));
@@ -924,8 +923,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
924923
" yourself if you want to.\n"
925924
"An empty message aborts the commit.\n");
926925
if (whence != FROM_COMMIT) {
927-
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
928-
!merge_contains_scissors)
926+
if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)
929927
wt_status_add_cut_line(s);
930928
status_printf_ln(
931929
s, GIT_COLOR_NORMAL,
@@ -946,7 +944,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
946944
if (cleanup_mode == COMMIT_MSG_CLEANUP_ALL)
947945
status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_all, comment_line_char);
948946
else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
949-
if (whence == FROM_COMMIT && !merge_contains_scissors)
947+
if (whence == FROM_COMMIT)
950948
wt_status_add_cut_line(s);
951949
} else /* COMMIT_MSG_CLEANUP_SPACE, that is. */
952950
status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_space, comment_line_char);

0 commit comments

Comments
 (0)