Merge branch 'em/commit-claim'
authorJunio C Hamano <gitster@pobox.com>
Mon, 30 Nov 2009 22:43:26 +0000 (14:43 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Nov 2009 22:43:26 +0000 (14:43 -0800)
1  2 
Documentation/git-commit.txt
builtin-commit.c
index 3ea80c820fb404d7b00436f9820fe8701f056ebf,f89db9a0ff37bffa06f485be7d25a5f5bfe9a50f..d227cec9ba566caa098c36e8c91b19a8a27fcae5
@@@ -9,7 -9,7 +9,7 @@@ SYNOPSI
  --------
  [verse]
  'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
-          [(-c | -C) <commit>] [-F <file> | -m <msg>]
+          [(-c | -C) <commit>] [-F <file> | -m <msg>] [--reset-author]
           [--allow-empty] [--no-verify] [-e] [--author=<author>]
           [--cleanup=<mode>] [--] [[-i | -o ]<file>...]
  
@@@ -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>::
  --file=<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 09d28405ecde6112b799a423775e961ccdfd0789,764f4fdaac76642718ebbbf2371a29050860b168..e93a647c59f1f52a4b0eb92b6c84fd9cec0aad6a
@@@ -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)
                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);
  }