Merge branch 'js/gitweb-path-info-unquote'
[gitweb.git] / builtin / commit.c
index b15e3119d672e753a5196f7ee7767f26c48af182..20cef95d600aeb15b716793beb5fb2534cc2b682 100644 (file)
@@ -89,7 +89,6 @@ static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
 static int no_post_rewrite, allow_empty_message;
 static char *untracked_files_arg, *force_date, *ignore_submodule_arg;
 static char *sign_commit;
-static unsigned int colopts;
 
 /*
  * The default commit message cleanup mode will remove the lines
@@ -185,6 +184,9 @@ static int list_paths(struct string_list *list, const char *with_tree,
        int i;
        char *m;
 
+       if (!pattern)
+               return 0;
+
        for (i = 0; pattern[i]; i++)
                ;
        m = xcalloc(1, i);
@@ -346,7 +348,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
         * and create commit from the_index.
         * We still need to refresh the index here.
         */
-       if (!pathspec || !*pathspec) {
+       if (!only && (!pathspec || !*pathspec)) {
                fd = hold_locked_index(&index_lock, 1);
                refresh_cache_or_die(refresh_flags);
                if (active_cache_changed) {
@@ -527,8 +529,7 @@ static void determine_author_info(struct strbuf *author_ident)
 
        if (force_date)
                date = force_date;
-       strbuf_addstr(author_ident, fmt_ident(name, email, date,
-                                             IDENT_ERROR_ON_NO_NAME));
+       strbuf_addstr(author_ident, fmt_ident(name, email, date, IDENT_STRICT));
        if (!split_ident_line(&author, author_ident->buf, author_ident->len)) {
                export_one("GIT_AUTHOR_NAME", author.name_begin, author.name_end, 0);
                export_one("GIT_AUTHOR_EMAIL", author.mail_begin, author.mail_end, 0);
@@ -642,7 +643,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                hook_arg1 = "message";
        } else if (use_message) {
                buffer = strstr(use_message_buffer, "\n\n");
-               if (!buffer || buffer[2] == '\0')
+               if (!use_editor && (!buffer || buffer[2] == '\0'))
                        die(_("commit has empty message"));
                strbuf_add(&sb, buffer + 2, strlen(buffer + 2));
                hook_arg1 = "commit";
@@ -724,7 +725,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
        strbuf_release(&sb);
 
        /* This checks if committer ident is explicitly given */
-       strbuf_addstr(&committer_ident, git_committer_info(0));
+       strbuf_addstr(&committer_ident, git_committer_info(IDENT_STRICT));
        if (use_editor && include_status) {
                char *ai_tmp, *ci_tmp;
                if (whence != FROM_COMMIT)
@@ -1121,7 +1122,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
        struct wt_status *s = cb;
 
        if (!prefixcmp(k, "column."))
-               return git_column_config(k, v, "status", &colopts);
+               return git_column_config(k, v, "status", &s->colopts);
        if (!strcmp(k, "status.submodulesummary")) {
                int is_bool;
                s->submodule_summary = git_config_bool_or_int(k, v, &is_bool);
@@ -1187,7 +1188,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
                { OPTION_STRING, 0, "ignore-submodules", &ignore_submodule_arg, "when",
                  "ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)",
                  PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
-               OPT_COLUMN(0, "column", &colopts, "list untracked files in columns"),
+               OPT_COLUMN(0, "column", &s.colopts, "list untracked files in columns"),
                OPT_END(),
        };
 
@@ -1201,8 +1202,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        argc = parse_options(argc, argv, prefix,
                             builtin_status_options,
                             builtin_status_usage, 0);
-       finalize_colopts(&colopts, -1);
-       s.colopts = colopts;
+       finalize_colopts(&s.colopts, -1);
 
        if (s.null_termination && status_format == STATUS_FORMAT_LONG)
                status_format = STATUS_FORMAT_PORCELAIN;
@@ -1439,6 +1439,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        wt_status_prepare(&s);
        git_config(git_commit_config, &s);
        determine_whence(&s);
+       s.colopts = 0;
 
        if (get_sha1("HEAD", sha1))
                current_head = NULL;