X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-commit.c;h=33aa593c21b70cd29a54e7b8151d78e092cfad3a;hb=8fb5d44a47dd3657c8be0de5dcf220935b04e98e;hp=d525b894ec1211476707acb06bdebe25d5828dbb;hpb=376f39fbea0dfb31402abda878a7b0018f6a6161;p=git.git diff --git a/builtin-commit.c b/builtin-commit.c index d525b894e..33aa593c2 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -51,7 +51,7 @@ static const char *template_file; static char *edit_message, *use_message; static char *author_name, *author_email, *author_date; static int all, edit_flag, also, interactive, only, amend, signoff; -static int quiet, verbose, no_verify, allow_empty, dry_run; +static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship; static char *untracked_files_arg; /* * The default commit message cleanup mode will remove the lines @@ -86,16 +86,19 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset) static struct option builtin_commit_options[] = { OPT__QUIET(&quiet), OPT__VERBOSE(&verbose), - OPT_GROUP("Commit message options"), + OPT_GROUP("Commit message options"), OPT_FILENAME('F', "file", &logfile, "read log from file"), OPT_STRING(0, "author", &force_author, "AUTHOR", "override author for commit"), OPT_CALLBACK('m', "message", &message, "MESSAGE", "specify commit message", opt_parse_m), - OPT_STRING('c', "reedit-message", &edit_message, "COMMIT", "reuse and edit message from specified commit "), + OPT_STRING('c', "reedit-message", &edit_message, "COMMIT", "reuse and edit message from specified commit"), OPT_STRING('C', "reuse-message", &use_message, "COMMIT", "reuse message from specified commit"), + OPT_BOOLEAN(0, "reset-author", &renew_authorship, "the commit is authored by me now (used with -C-c/--amend)"), OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"), OPT_FILENAME('t', "template", &template_file, "use specified template file"), OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"), + OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"), + /* end commit message options */ OPT_GROUP("Commit contents options"), OPT_BOOLEAN('a', "all", &all, "commit all changed files"), @@ -107,7 +110,7 @@ static struct option builtin_commit_options[] = { OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"), { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" }, OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"), - OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"), + /* end commit contents options */ OPT_END() }; @@ -381,7 +384,7 @@ static void determine_author_info(void) email = getenv("GIT_AUTHOR_EMAIL"); date = getenv("GIT_AUTHOR_DATE"); - if (use_message) { + if (use_message && !renew_authorship) { const char *a, *lb, *rb, *eol; a = strstr(use_message_buffer, "\nauthor "); @@ -747,6 +750,9 @@ static int parse_and_validate_options(int argc, const char *argv[], if (force_author && !strchr(force_author, '>')) force_author = find_author_by_nickname(force_author); + if (force_author && renew_authorship) + die("Using both --reset-author and --author does not make sense"); + if (logfile || message.len || use_message) use_editor = 0; if (edit_flag) @@ -780,6 +786,8 @@ static int parse_and_validate_options(int argc, const char *argv[], use_message = edit_message; if (amend && !use_message) use_message = "HEAD"; + if (!use_message && renew_authorship) + die("--reset-author can be used only with -C, -c or --amend."); if (use_message) { unsigned char sha1[20]; static char utf8[] = "UTF-8"; @@ -884,7 +892,7 @@ static int parse_status_slot(const char *var, int offset) return WT_STATUS_NOBRANCH; if (!strcasecmp(var+offset, "unmerged")) return WT_STATUS_UNMERGED; - die("bad config variable '%s'", var); + return -1; } static int git_status_config(const char *k, const char *v, void *cb) @@ -904,6 +912,8 @@ static int git_status_config(const char *k, const char *v, void *cb) } if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) { int slot = parse_status_slot(k, 13); + if (slot < 0) + return 0; if (!v) return config_error_nonbool(k); color_parse(v, k, s->color_palette[slot]); @@ -999,7 +1009,7 @@ static int git_commit_config(const char *k, const char *v, void *cb) struct wt_status *s = cb; if (!strcmp(k, "commit.template")) - return git_config_string(&template_file, k, v); + return git_config_pathname(&template_file, k, v); return git_status_config(k, v, s); }