From: Junio C Hamano Date: Mon, 30 Nov 2009 22:43:26 +0000 (-0800) Subject: Merge branch 'em/commit-claim' X-Git-Tag: v1.6.6-rc1~13 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c142465c07b7857ebb4816fe95c3d212aa825bcc?hp=-c Merge branch 'em/commit-claim' --- c142465c07b7857ebb4816fe95c3d212aa825bcc diff --combined Documentation/git-commit.txt index 3ea80c820f,f89db9a0ff..d227cec9ba --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@@ -9,7 -9,7 +9,7 @@@ SYNOPSI -------- [verse] 'git commit' [-a | --interactive] [-s] [-v] [-u] [--amend] [--dry-run] - [(-c | -C) ] [-F | -m ] + [(-c | -C) ] [-F | -m ] [--reset-author] [--allow-empty] [--no-verify] [-e] [--author=] [--cleanup=] [--] [[-i | -o ]...] @@@ -69,6 -69,11 +69,11 @@@ OPTION Like '-C', but with '-c' the editor is invoked, so that the user can further edit the commit message. + --reset-author:: + When used with -C/-c/--amend options, declare that the + authorship of the resulting commit now belongs of the committer. + This also renews the author timestamp. + -F :: --file=:: Take the commit message from the given file. Use '-' to @@@ -323,7 -328,7 +328,7 @@@ ENVIRONMENT AND CONFIGURATION VARIABLE The editor used to edit the commit log message will be chosen from the GIT_EDITOR environment variable, the core.editor configuration variable, the VISUAL environment variable, or the EDITOR environment variable (in that -order). +order). See linkgit:git-var[1] for details. HOOKS ----- diff --combined builtin-commit.c index 09d28405ec,764f4fdaac..e93a647c59 --- a/builtin-commit.c +++ b/builtin-commit.c @@@ -51,7 -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 @@@ -91,8 -91,9 +91,9 @@@ static struct option builtin_commit_opt 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"), @@@ -381,7 -382,7 +382,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 "); @@@ -530,7 -531,7 +531,7 @@@ static int prepare_to_commit(const cha for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--) ; /* do nothing */ if (prefixcmp(sb.buf + i, sob.buf)) { - if (!ends_rfc2822_footer(&sb)) + if (!i || !ends_rfc2822_footer(&sb)) strbuf_addch(&sb, '\n'); strbuf_addbuf(&sb, &sob); } @@@ -747,6 -748,9 +748,9 @@@ static int parse_and_validate_options(i 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 -784,8 +784,8 @@@ 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"; @@@ -999,7 -1005,7 +1005,7 @@@ static int git_commit_config(const cha 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); }