git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erick Mattos <erick.mattos@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time  with --claim
Date: Tue, 3 Nov 2009 14:39:05 -0200	[thread overview]
Message-ID: <55bacdd30911030839v724924bm7a49a08172ed7573@mail.gmail.com> (raw)
In-Reply-To: <7vskcxwro7.fsf@alter.siamese.dyndns.org>

I am gonna check all this information but you probably missed the last
patch I sent: http://marc.info/?l=git&m=125712272606721&w=2
Could you please check this one... while I am checking this e-mail.

Regards

2009/11/2 Junio C Hamano <gitster@pobox.com>:
> The last one was probably harder to read since it was an interdiff.  Here
> is what I am considering to queue.
>
> No, I didn't use --mine option when I ran "commit --amend" to record this
> one ;-)
>
> -- >8 --
> From: Erick Mattos <erick.mattos@gmail.com>
> Date: Sun, 1 Nov 2009 16:45:27 -0200
> Subject: [PATCH] git commit --mine: ignore authorship information taken from -c/-C/--amend
>
> When we use -c, -C, or --amend, we are trying one of two things: using the
> source as a template or modifying a commit with corrections.
>
> When these options are are used, the authorship and timestamp recorded in
> the newly created commit is always taken from the original commit.  This
> is inconvenient when you want to just borrow the commit log message, or
> your change is so significant that you should take over the authorship
> (with the blame for bugs you introduced).
>
> Signed-off-by: Erick Mattos <erick.mattos@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  Documentation/git-commit.txt |    7 +++-
>  builtin-commit.c             |   10 +++-
>  t/t7509-commit.sh            |  103 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 116 insertions(+), 4 deletions(-)
>  create mode 100755 t/t7509-commit.sh
>
> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
> index 0578a40..7832720 100644
> --- a/Documentation/git-commit.txt
> +++ b/Documentation/git-commit.txt
> @@ -9,7 +9,7 @@ SYNOPSIS
>  --------
>  [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>] [--mine]
>           [--allow-empty] [--no-verify] [-e] [--author=<author>]
>           [--cleanup=<mode>] [--] [[-i | -o ]<file>...]
>
> @@ -69,6 +69,11 @@ OPTIONS
>        Like '-C', but with '-c' the editor is invoked, so that
>        the user can further edit the commit message.
>
> +--mine::
> +       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
> diff --git a/builtin-commit.c b/builtin-commit.c
> index beddf01..aa42989 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
> @@ -91,8 +91,9 @@ static struct option builtin_commit_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, "mine", &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 @@ 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 +748,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 --mine and --author does not make sense");
> +
>        if (logfile || message.len || use_message)
>                use_editor = 0;
>        if (edit_flag)
> diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh
> new file mode 100755
> index 0000000..ec13cea
> --- /dev/null
> +++ b/t/t7509-commit.sh
> @@ -0,0 +1,103 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2009 Erick Mattos
> +#
> +
> +test_description='git commit --mine'
> +
> +. ./test-lib.sh
> +
> +author_header () {
> +       git cat-file commit "$1" |
> +       sed -n -e '/^$/q' -e '/^author /p'
> +}
> +
> +message_body () {
> +       git cat-file commit "$1" |
> +       sed -e '1,/^$/d'
> +}
> +
> +test_expect_success '-C option copies authorship and message' '
> +       echo "Initial" >foo &&
> +       git add foo &&
> +       test_tick &&
> +       git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> &&
> +       git tag Initial &&
> +       echo "Test 1" >>foo &&
> +       test_tick &&
> +       git commit -a -C Initial &&
> +       author_header Initial >expect &&
> +       author_header HEAD >actual &&
> +       test_cmp expect actual
> +'
> +
> +test_expect_success '-C option copies only the message with --mine' '
> +       echo "Test 2" >>foo &&
> +       test_tick &&
> +       git commit -a -C Initial --mine &&
> +       echo "author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
> +       author_header HEAD >actual
> +       test_cmp expect actual &&
> +
> +       message_body Initial >expect &&
> +       message_body HEAD >actual &&
> +       test_cmp expect actual
> +'
> +
> +test_expect_success '-c option copies authorship and message' '
> +       echo "Test 3" >>foo &&
> +       test_tick &&
> +       EDITOR=: VISUAL=: git commit -a -c Initial &&
> +       author_header Initial >expect &&
> +       author_header HEAD >actual &&
> +       test_cmp expect actual
> +'
> +
> +test_expect_success '-c option copies only the message with --mine' '
> +       echo "Test 4" >>foo &&
> +       test_tick &&
> +       EDITOR=: VISUAL=: git commit -a -c Initial --mine &&
> +       echo "author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
> +       author_header HEAD >actual &&
> +       test_cmp expect actual &&
> +
> +       message_body Initial >expect &&
> +       message_body HEAD >actual &&
> +       test_cmp expect actual
> +'
> +
> +test_expect_success '--amend option copies authorship' '
> +       git checkout Initial &&
> +       echo "Test 5" >>foo &&
> +       test_tick &&
> +       git commit -a --amend -m "amend test" &&
> +       author_header Initial >expect &&
> +       author_header HEAD >actual &&
> +
> +       echo "amend test" >expect &&
> +       message_body HEAD >actual &&
> +       test_cmp expect actual
> +'
> +
> +test_expect_success '--mine makes the commit ours even with --amend option' '
> +       git checkout Initial &&
> +       echo "Test 6" >>foo &&
> +       test_tick &&
> +       git commit -a --mine -m "Changed again" --amend &&
> +       echo "author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
> +       author_header HEAD >actual &&
> +       test_cmp expect actual &&
> +
> +       echo "Changed again" >expect &&
> +       message_body HEAD >actual &&
> +       test_cmp expect actual
> +'
> +
> +test_expect_success '--mine and --author are mutually exclusive' '
> +       git checkout Initial &&
> +       echo "Test 7" >>foo &&
> +       test_tick &&
> +       test_must_fail git commit -a --mine --author="Xyzzy <frotz@nitfol.xz>"
> +'
> +
> +test_done
> --
> 1.6.5.2.246.gc99575
>
>

  reply	other threads:[~2009-11-03 16:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-31  3:08 [PATCH] commit -c/-C/--amend: take over authorship and restamp time with --claim Erick Mattos
2009-10-31 21:24 ` Junio C Hamano
2009-11-01 18:19   ` [PATCH v2] " Erick Mattos
2009-11-01 18:45     ` [PATCH] commit -c/-C/--amend: acquire " Erick Mattos
2009-11-01 20:02       ` Junio C Hamano
2009-11-01 20:57         ` Erick Mattos
2009-11-02  0:47           ` Junio C Hamano
2009-11-02  0:54             ` Erick Mattos
2009-11-02  2:58               ` Junio C Hamano
2009-11-02  3:07                 ` Junio C Hamano
2009-11-03 16:39                   ` Erick Mattos [this message]
2009-11-01 23:14         ` Erick Mattos
2009-11-02  0:44           ` [PATCH] commit -c/-C/--amend: reset timestamp and authorship to committer with --mine Erick Mattos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55bacdd30911030839v724924bm7a49a08172ed7573@mail.gmail.com \
    --to=erick.mattos@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).