Merge branch 'vk/autoconf-gettext'
[gitweb.git] / builtin / commit.c
index 8277da84746dcaf87377409c50615e9b08ac3c01..bd4b180c43f51b73da04894f88754b843cd2d0d1 100644 (file)
@@ -235,7 +235,7 @@ static int commit_index_files(void)
  * and return the paths that match the given pattern in list.
  */
 static int list_paths(struct string_list *list, const char *with_tree,
-                     const char *prefix, const struct pathspec *pattern)
+                     const struct pathspec *pattern)
 {
        int i, ret;
        char *m;
@@ -264,7 +264,7 @@ static int list_paths(struct string_list *list, const char *with_tree,
                        item->util = item; /* better a valid pointer than a fake one */
        }
 
-       ret = report_path_error(m, pattern, prefix);
+       ret = report_path_error(m, pattern);
        free(m);
        return ret;
 }
@@ -454,7 +454,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
                        die(_("cannot do a partial commit during a cherry-pick."));
        }
 
-       if (list_paths(&partial, !current_head ? NULL : "HEAD", prefix, &pathspec))
+       if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec))
                exit(1);
 
        discard_cache();
@@ -668,6 +668,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
        const char *hook_arg2 = NULL;
        int clean_message_contents = (cleanup_mode != COMMIT_MSG_CLEANUP_NONE);
        int old_display_comment_prefix;
+       int merge_contains_scissors = 0;
 
        /* This checks and barfs if author is badly specified */
        determine_author_info(author_ident);
@@ -728,6 +729,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                        strbuf_addbuf(&sb, &message);
                hook_arg1 = "message";
        } else if (!stat(git_path_merge_msg(the_repository), &statbuf)) {
+               size_t merge_msg_start;
+
                /*
                 * prepend SQUASH_MSG here if it exists and a
                 * "merge --squash" was originally performed
@@ -738,8 +741,16 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                        hook_arg1 = "squash";
                } else
                        hook_arg1 = "merge";
+
+               merge_msg_start = sb.len;
                if (strbuf_read_file(&sb, git_path_merge_msg(the_repository), 0) < 0)
                        die_errno(_("could not read MERGE_MSG"));
+
+               if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
+                   wt_status_locate_end(sb.buf + merge_msg_start,
+                                        sb.len - merge_msg_start) <
+                               sb.len - merge_msg_start)
+                       merge_contains_scissors = 1;
        } else if (!stat(git_path_squash_msg(the_repository), &statbuf)) {
                if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0)
                        die_errno(_("could not read SQUASH_MSG"));
@@ -807,7 +818,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                struct ident_split ci, ai;
 
                if (whence != FROM_COMMIT) {
-                       if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)
+                       if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
+                               !merge_contains_scissors)
                                wt_status_add_cut_line(s->fp);
                        status_printf_ln(s, GIT_COLOR_NORMAL,
                            whence == FROM_MERGE
@@ -832,10 +844,10 @@ 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 == COMMIT_MSG_CLEANUP_SCISSORS &&
-                        whence == FROM_COMMIT)
-                       wt_status_add_cut_line(s->fp);
-               else /* COMMIT_MSG_CLEANUP_SPACE, that is. */
+               else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
+                       if (whence == FROM_COMMIT && !merge_contains_scissors)
+                               wt_status_add_cut_line(s->fp);
+               else /* COMMIT_MSG_CLEANUP_SPACE, that is. */
                        status_printf(s, GIT_COLOR_NORMAL,
                                _("Please enter the commit message for your changes."
                                  " Lines starting\n"
@@ -1177,7 +1189,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
        handle_untracked_files_arg(s);
 
        if (all && argc > 0)
-               die(_("Paths with -a does not make sense."));
+               die(_("paths '%s ...' with -a does not make sense"),
+                   argv[0]);
 
        if (status_format != STATUS_FORMAT_NONE)
                dry_run = 1;