* [PATCH] commit -c/-C/--amend: take over authorship and restamp time with --claim @ 2009-10-31 3:08 Erick Mattos 2009-10-31 21:24 ` Junio C Hamano 0 siblings, 1 reply; 13+ messages in thread From: Erick Mattos @ 2009-10-31 3:08 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Erick Mattos When we use one of the options above we are normally trying to do mainly two things: one is using the source as a template and second is to recreate a commit with corrections. When they are used, the authorship and timestamp recorded in the newly created commit is always taken from the original commit. And they should not when we are using it as a template. The new --claim option is meant to solve this need by regenerating the timestamp and setting as new author the committer or the one specified on --author option. Signed-off-by: Erick Mattos <erick.mattos@gmail.com> --- Documentation/git-commit.txt | 10 +++++++--- builtin-commit.c | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 0578a40..96248ab 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>] [--claim] [--allow-empty] [--no-verify] [-e] [--author=<author>] [--cleanup=<mode>] [--] [[-i | -o ]<file>...] @@ -61,14 +61,18 @@ OPTIONS -C <commit>:: --reuse-message=<commit>:: Take an existing commit object, and reuse the log message - and the authorship information (including the timestamp) - when creating the commit. + and the authorship information when creating the commit. -c <commit>:: --reedit-message=<commit>:: Like '-C', but with '-c' the editor is invoked, so that the user can further edit the commit message. +--claim:: + When used with -C/-c/--amend options the committer takes over + the cloned commit authorship and renew the timestamp thus using + only the commit message from the source. + -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 c395cbf..33922df 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, claim; 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, "claim", &claim, "take over cloned commit authorship and renew timestamp"), 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 && !claim) { const char *a, *lb, *rb, *eol; a = strstr(use_message_buffer, "\nauthor "); -- 1.6.5.2.102.g0a733 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: take over authorship and restamp time with --claim 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 0 siblings, 1 reply; 13+ messages in thread From: Junio C Hamano @ 2009-10-31 21:24 UTC (permalink / raw) To: Erick Mattos; +Cc: git Erick Mattos <erick.mattos@gmail.com> writes: > The new --claim option is meant to solve this need by regenerating the > timestamp and setting as new author the committer or the one specified > on --author option. I'll leave discussion on the option name to others. > +--claim:: > + When used with -C/-c/--amend options the committer takes over > + the cloned commit authorship and renew the timestamp thus using > + only the commit message from the source. "The cloned commit" is a bit misleading; in the mind of users --amend does not clone but rewrite, as the old commit usually only belongs to a reflog and not any other branch. I'd rewrite it this way, perhaps. 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. We also would need a test to protect this new feature from getting broken by future updates. Thanks. ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2] commit -c/-C/--amend: take over authorship and restamp time with --claim 2009-10-31 21:24 ` Junio C Hamano @ 2009-11-01 18:19 ` Erick Mattos 2009-11-01 18:45 ` [PATCH] commit -c/-C/--amend: acquire " Erick Mattos 0 siblings, 1 reply; 13+ messages in thread From: Erick Mattos @ 2009-11-01 18:19 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Erick Mattos When we use one of the options above we are normally trying to do mainly two things: one is using the source as a template and second is to recreate a commit with corrections. When they are used, the authorship and timestamp recorded in the newly created commit is always taken from the original commit. And they should not when we are using it as a template. The new --claim option is meant to solve this need by regenerating the timestamp and setting as new author the committer or the one specified on --author option. Signed-off-by: Erick Mattos <erick.mattos@gmail.com> --- Documentation/git-commit.txt | 11 ++++- builtin-commit.c | 7 ++- t/t7509-commit.sh | 87 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 6 deletions(-) create mode 100755 t/t7509-commit.sh diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 0578a40..27b774e 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>] [--claim] [--allow-empty] [--no-verify] [-e] [--author=<author>] [--cleanup=<mode>] [--] [[-i | -o ]<file>...] @@ -61,14 +61,19 @@ OPTIONS -C <commit>:: --reuse-message=<commit>:: Take an existing commit object, and reuse the log message - and the authorship information (including the timestamp) - when creating the commit. + and the authorship information when creating the commit. -c <commit>:: --reedit-message=<commit>:: Like '-C', but with '-c' the editor is invoked, so that the user can further edit the commit message. +--claim:: + 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. Therefore this option + sets the use of the message only from the original commit. + -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 c395cbf..33922df 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, claim; 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, "claim", &claim, "take over cloned commit authorship and renew timestamp"), 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 && !claim) { const char *a, *lb, *rb, *eol; a = strstr(use_message_buffer, "\nauthor "); diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh new file mode 100755 index 0000000..62fb00f --- /dev/null +++ b/t/t7509-commit.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# +# Copyright (c) 2009 Erick Mattos +# + +test_description='git commit + +Tests for --claim option on a commit.' + +. ./test-lib.sh + +TEST_FILE="$PWD"/foo + +test_expect_success '-C option should be working' ' + echo "Initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && + sleep 1 && + echo "Test 1" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -C HEAD && + git cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 && + git cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 && + cmp commit_1 commit_2 +' + +test_expect_success '-C option with --claim is working properly' ' + sleep 1 && + echo "Test 2" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -C HEAD^ --claim && + git cat-file -p HEAD^ | grep '^author' > commit_1 && + git cat-file -p HEAD | grep '^author' > commit_2 && + test_must_fail cmp commit_1 commit_2 +' + +test_expect_success '-c option should be working' ' + echo "Initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && + sleep 1 && + echo "Test 3" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -c HEAD <<EOF + "Changed" + EOF && + git cat-file -p HEAD^ | grep '^author' > commit_1 && + git cat-file -p HEAD | grep '^author' > commit_2 && + cmp commit_1 commit_2 +' + +test_expect_success '-c option with --claim is working properly' ' + sleep 1 && + echo "Test 4" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -c HEAD^ --claim <<EOF + "Changed again" + EOF && + git cat-file -p HEAD^ | grep '^author' > commit_1 && + git cat-file -p HEAD | grep '^author' > commit_2 && + test_must_fail cmp commit_1 commit_2 +' + +test_expect_success '--amend option should be working' ' + echo "Initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && + echo "Test 5" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "--amend test" && + git cat-file -p HEAD | grep '^author' > commit_1 && + sleep 1 && + git commit -m "Changed" --amend && + git cat-file -p HEAD | grep '^author' > commit_2 && + cmp commit_1 commit_2 +' + +test_expect_success '--amend option with --claim is working properly' ' + sleep 1 && + echo "Test 6" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Changed again" --amend --claim && + git cat-file -p HEAD | grep '^author' > commit_1 && + test_must_fail cmp commit_1 commit_2 +' + +test_done -- 1.6.5.GIT ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 2009-11-01 18:19 ` [PATCH v2] " Erick Mattos @ 2009-11-01 18:45 ` Erick Mattos 2009-11-01 20:02 ` Junio C Hamano 0 siblings, 1 reply; 13+ messages in thread From: Erick Mattos @ 2009-11-01 18:45 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Erick Mattos When we use one of the options above we are normally trying to do mainly two things: one is using the source as a template and second is to recreate a commit with corrections. When they are used, the authorship and timestamp recorded in the newly created commit is always taken from the original commit. And they should not when we are using it as a template. The new --claim option is meant to solve this need by regenerating the timestamp and setting as new author the committer or the one specified on --author option. Signed-off-by: Erick Mattos <erick.mattos@gmail.com> --- Documentation/git-commit.txt | 11 ++++- builtin-commit.c | 7 ++- t/t7509-commit.sh | 87 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 6 deletions(-) create mode 100755 t/t7509-commit.sh diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 0578a40..01eeb3e 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>] [--claim] [--allow-empty] [--no-verify] [-e] [--author=<author>] [--cleanup=<mode>] [--] [[-i | -o ]<file>...] @@ -61,14 +61,19 @@ OPTIONS -C <commit>:: --reuse-message=<commit>:: Take an existing commit object, and reuse the log message - and the authorship information (including the timestamp) - when creating the commit. + and the authorship information when creating the commit. -c <commit>:: --reedit-message=<commit>:: Like '-C', but with '-c' the editor is invoked, so that the user can further edit the commit message. +--claim:: + 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. Therefore this option + sets the use of only the message from the original commit. + -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 c395cbf..919e3fe 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, claim; 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, "claim", &claim, "acquire authorship and restamp time of resulting commit"), 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 && !claim) { const char *a, *lb, *rb, *eol; a = strstr(use_message_buffer, "\nauthor "); diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh new file mode 100755 index 0000000..62fb00f --- /dev/null +++ b/t/t7509-commit.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# +# Copyright (c) 2009 Erick Mattos +# + +test_description='git commit + +Tests for --claim option on a commit.' + +. ./test-lib.sh + +TEST_FILE="$PWD"/foo + +test_expect_success '-C option should be working' ' + echo "Initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && + sleep 1 && + echo "Test 1" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -C HEAD && + git cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 && + git cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 && + cmp commit_1 commit_2 +' + +test_expect_success '-C option with --claim is working properly' ' + sleep 1 && + echo "Test 2" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -C HEAD^ --claim && + git cat-file -p HEAD^ | grep '^author' > commit_1 && + git cat-file -p HEAD | grep '^author' > commit_2 && + test_must_fail cmp commit_1 commit_2 +' + +test_expect_success '-c option should be working' ' + echo "Initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && + sleep 1 && + echo "Test 3" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -c HEAD <<EOF + "Changed" + EOF && + git cat-file -p HEAD^ | grep '^author' > commit_1 && + git cat-file -p HEAD | grep '^author' > commit_2 && + cmp commit_1 commit_2 +' + +test_expect_success '-c option with --claim is working properly' ' + sleep 1 && + echo "Test 4" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -c HEAD^ --claim <<EOF + "Changed again" + EOF && + git cat-file -p HEAD^ | grep '^author' > commit_1 && + git cat-file -p HEAD | grep '^author' > commit_2 && + test_must_fail cmp commit_1 commit_2 +' + +test_expect_success '--amend option should be working' ' + echo "Initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && + echo "Test 5" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "--amend test" && + git cat-file -p HEAD | grep '^author' > commit_1 && + sleep 1 && + git commit -m "Changed" --amend && + git cat-file -p HEAD | grep '^author' > commit_2 && + cmp commit_1 commit_2 +' + +test_expect_success '--amend option with --claim is working properly' ' + sleep 1 && + echo "Test 6" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Changed again" --amend --claim && + git cat-file -p HEAD | grep '^author' > commit_1 && + test_must_fail cmp commit_1 commit_2 +' + +test_done -- 1.6.5.GIT ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 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-01 23:14 ` Erick Mattos 0 siblings, 2 replies; 13+ messages in thread From: Junio C Hamano @ 2009-11-01 20:02 UTC (permalink / raw) To: Erick Mattos; +Cc: git Erick Mattos <erick.mattos@gmail.com> writes: > The new --claim option is meant to solve this need by regenerating the > timestamp and setting as new author the committer or the one specified > on --author option. Thanks. I don't think "claim" is a good name for this option. It makes me go "huh, I do not get it. What are you claiming? Claiming that this is the correct fix?" Renaming it to "claim-authorship" may avoid that confusion, but it is too long. How about naming this option "mine"? > @@ -61,14 +61,19 @@ OPTIONS > -C <commit>:: > --reuse-message=<commit>:: > Take an existing commit object, and reuse the log message > - and the authorship information (including the timestamp) > - when creating the commit. > + and the authorship information when creating the commit. I don't think this is a good change. When you use the new option, the author name, email and timestamp are ignored, and when you don't, they are all used. To new users who are taught to first set user.name and user.email via configuration variables, the phrase "authorship information" would mean <name, email> pair, and the explanation in the parentheses helps to avoid a misunderstanding that these two are the only things that are copied. I would suggest you keep the original text. > +--claim:: > + 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. Therefore this option > + sets the use of only the message from the original commit. I don't understand/parse the last sentence; I don't think it is necessary, either. > diff --git a/builtin-commit.c b/builtin-commit.c > index c395cbf..919e3fe 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, claim; Even if you name the command option "claim" in order to keep it short, I think it is a bad idea to name the variable "claim", because it doesn't say _what_ you are claiming and is confusing. Naming it claim_authorship would be better. > + OPT_BOOLEAN(0, "claim", &claim, "acquire authorship and restamp time of resulting commit"), It is unclear from where it is "acquire"-ing, nor what "restamp" means. Here are my attempts to come up with better wording: "ignore author and timestamp of the original commit (used with -C/-c/--amend)" "the commit is authored by me now (used with -C/-c/--amend)" The latter will work well if the option is renamed to "--mine". What should happen when the user uses --claim without -C/-c/--amend? % git commit --claim Should you detect an error? Does your code do so? Do you have a test that catches this error? What should happen when the user uses --author and --claim at the same time? % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD Should you detect an error? Does your code do so? Do you have a test that catches this error? > diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh > new file mode 100755 > index 0000000..62fb00f > --- /dev/null > +++ b/t/t7509-commit.sh > @@ -0,0 +1,87 @@ > +#!/bin/sh > +# > +# Copyright (c) 2009 Erick Mattos > +# > + > +test_description='git commit > + > +Tests for --claim option on a commit.' > + > +. ./test-lib.sh > + > +TEST_FILE="$PWD"/foo Why does this have to be given as a full path, not just "foo"? > +test_expect_success '-C option should be working' ' Every test is about "should be working", so you are wasting 16 letters or so without giving any useful information. Say something like "-C without --claim uses the author from the old commit" here. > + echo "Initial" > "$TEST_FILE" && > + git add "$TEST_FILE" && > + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && > + sleep 1 && If you use "test_tick", you don't have to slow the test down. You use "test_tick" before you commit to increment the time. Look at t6036 for an example. > + echo "Test 1" >> "$TEST_FILE" && > + git add "$TEST_FILE" && > + git commit -C HEAD && > + git cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 && > + git cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 && > + cmp commit_1 commit_2 > +' Use "test_cmp" instead, so that errors can be seen easily when somebody breaks this new feature. > +test_expect_success '-C option with --claim is working properly' ' Again, "working properly" is a meaningless thing to say because that is what all tests check. "-C with --claim makes me the author" would be better. > + sleep 1 && > + echo "Test 2" >> "$TEST_FILE" && > + git add "$TEST_FILE" && > + git commit -C HEAD^ --claim && > + git cat-file -p HEAD^ | grep '^author' > commit_1 && > + git cat-file -p HEAD | grep '^author' > commit_2 && > + test_must_fail cmp commit_1 commit_2 This test shouldn't be happy with any random author information that happens to be different from the original. The purpose of --claim option is to take the authorship, make it mine (or whoever is specified with GIT_AUTHOR_NAME or user.name or uid-to-gecos), so the last cmp (again, it should use test_cmp) should make sure that the author is 'A U Thor', not just being different from "Frigate" or whatever. It should check email and timestamp as well, of course. > +' > + > +test_expect_success '-c option should be working' ' > + echo "Initial" > "$TEST_FILE" && > + git add "$TEST_FILE" && > + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && > + sleep 1 && > + echo "Test 3" >> "$TEST_FILE" && > + git add "$TEST_FILE" && > + git commit -c HEAD <<EOF > + "Changed" > + EOF && What editor is reading this "Changed"? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 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-01 23:14 ` Erick Mattos 1 sibling, 1 reply; 13+ messages in thread From: Erick Mattos @ 2009-11-01 20:57 UTC (permalink / raw) To: Junio C Hamano; +Cc: git 2009/11/1 Junio C Hamano <gitster@pobox.com>: > Erick Mattos <erick.mattos@gmail.com> writes: > >> The new --claim option is meant to solve this need by regenerating the >> timestamp and setting as new author the committer or the one specified >> on --author option. > > Thanks. > > I don't think "claim" is a good name for this option. It makes me go > "huh, I do not get it. What are you claiming? Claiming that this is the > correct fix?" > > Renaming it to "claim-authorship" may avoid that confusion, but it is too > long. > > How about naming this option "mine"? Makes sense: "mine" then. I felt you haven't like the name. >> @@ -61,14 +61,19 @@ OPTIONS >> -C <commit>:: >> --reuse-message=<commit>:: >> Take an existing commit object, and reuse the log message >> - and the authorship information (including the timestamp) >> - when creating the commit. >> + and the authorship information when creating the commit. > > I don't think this is a good change. > > When you use the new option, the author name, email and timestamp are > ignored, and when you don't, they are all used. > > To new users who are taught to first set user.name and user.email via > configuration variables, the phrase "authorship information" would mean > <name, email> pair, and the explanation in the parentheses helps to avoid > a misunderstanding that these two are the only things that are copied. > > I would suggest you keep the original text. I think it is pointless but if you say so. >> +--claim:: >> + 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. Therefore this option >> + sets the use of only the message from the original commit. > > I don't understand/parse the last sentence; I don't think it is necessary, > either. Just trying to clarify. I think people that would be searching for renewing timestamp as I was would find it easier to identify the correct option. >> diff --git a/builtin-commit.c b/builtin-commit.c >> index c395cbf..919e3fe 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, claim; > > Even if you name the command option "claim" in order to keep it short, I > think it is a bad idea to name the variable "claim", because it doesn't > say _what_ you are claiming and is confusing. Naming it claim_authorship > would be better. Changed to mine. >> + OPT_BOOLEAN(0, "claim", &claim, "acquire authorship and restamp time of resulting commit"), > > It is unclear from where it is "acquire"-ing, nor what "restamp" means. > > Here are my attempts to come up with better wording: > > "ignore author and timestamp of the original commit (used with -C/-c/--amend)" > "the commit is authored by me now (used with -C/-c/--amend)" What about "take new timestamp and make me new author (with -C/-c/--amend)"? > The latter will work well if the option is renamed to "--mine". > > What should happen when the user uses --claim without -C/-c/--amend? > > % git commit --claim > > Should you detect an error? Does your code do so? Do you have a test > that catches this error? You say it. In the first patch of mine I was testing for --(new|old)-timestamp. Now I thought it was unnecessary because the normal behavior is documented and by comparison with other options which does not test combinations extensively. But it is just code to add if you want... > What should happen when the user uses --author and --claim at the same time? > > % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD > > Should you detect an error? Does your code do so? Do you have a test > that catches this error? It works as intended. Both together. >> diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh >> new file mode 100755 >> index 0000000..62fb00f >> --- /dev/null >> +++ b/t/t7509-commit.sh >> @@ -0,0 +1,87 @@ >> +#!/bin/sh >> +# >> +# Copyright (c) 2009 Erick Mattos >> +# >> + >> +test_description='git commit >> + >> +Tests for --claim option on a commit.' >> + >> +. ./test-lib.sh >> + >> +TEST_FILE="$PWD"/foo > > Why does this have to be given as a full path, not just "foo"? Templating from other scripts. Ask them... :-) >> +test_expect_success '-C option should be working' ' > > Every test is about "should be working", so you are wasting 16 letters or > so without giving any useful information. > > Say something like "-C without --claim uses the author from the old commit" here. > >> + echo "Initial" > "$TEST_FILE" && >> + git add "$TEST_FILE" && >> + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && >> + sleep 1 && > > If you use "test_tick", you don't have to slow the test down. You use > "test_tick" before you commit to increment the time. Look at t6036 for an > example. Easy change. >> + echo "Test 1" >> "$TEST_FILE" && >> + git add "$TEST_FILE" && >> + git commit -C HEAD && >> + git cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 && >> + git cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 && >> + cmp commit_1 commit_2 >> +' > > Use "test_cmp" instead, so that errors can be seen easily when somebody > breaks this new feature. Easy change. >> +test_expect_success '-C option with --claim is working properly' ' > > Again, "working properly" is a meaningless thing to say because that is > what all tests check. "-C with --claim makes me the author" would be > better. > >> + sleep 1 && >> + echo "Test 2" >> "$TEST_FILE" && >> + git add "$TEST_FILE" && >> + git commit -C HEAD^ --claim && >> + git cat-file -p HEAD^ | grep '^author' > commit_1 && >> + git cat-file -p HEAD | grep '^author' > commit_2 && >> + test_must_fail cmp commit_1 commit_2 > > This test shouldn't be happy with any random author information that > happens to be different from the original. The purpose of --claim option > is to take the authorship, make it mine (or whoever is specified with > GIT_AUTHOR_NAME or user.name or uid-to-gecos), so the last cmp (again, it > should use test_cmp) should make sure that the author is 'A U Thor', not > just being different from "Frigate" or whatever. It should check email > and timestamp as well, of course. Good point but the text imho is a little unnecessary because the change could only be to user.name, user.email, ... But if want that it will be an easy change too. >> +' >> + >> +test_expect_success '-c option should be working' ' >> + echo "Initial" > "$TEST_FILE" && >> + git add "$TEST_FILE" && >> + git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && >> + sleep 1 && >> + echo "Test 3" >> "$TEST_FILE" && >> + git add "$TEST_FILE" && >> + git commit -c HEAD <<EOF >> + "Changed" >> + EOF && > > What editor is reading this "Changed"? > Nobody cares... Just a text to change the file. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 2009-11-01 20:57 ` Erick Mattos @ 2009-11-02 0:47 ` Junio C Hamano 2009-11-02 0:54 ` Erick Mattos 0 siblings, 1 reply; 13+ messages in thread From: Junio C Hamano @ 2009-11-02 0:47 UTC (permalink / raw) To: Erick Mattos; +Cc: git Erick Mattos <erick.mattos@gmail.com> writes: >> % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD >> >> Should you detect an error? Does your code do so? Do you have a test >> that catches this error? > > It works as intended. Both together. That does not make any sense. If you are saying this is yours and it is his at the same time, there can be no sane way to work "as intended", no?. >>> + git commit -c HEAD <<EOF >>> + "Changed" >>> + EOF && >> >> What editor is reading this "Changed"? > > Nobody cares... Just a text to change the file. I actually care. Who uses that Changed string, and where does it end up with? At the end of the log message? At the beginning? What "file"? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 2009-11-02 0:47 ` Junio C Hamano @ 2009-11-02 0:54 ` Erick Mattos 2009-11-02 2:58 ` Junio C Hamano 0 siblings, 1 reply; 13+ messages in thread From: Erick Mattos @ 2009-11-02 0:54 UTC (permalink / raw) To: Junio C Hamano; +Cc: git 2009/11/1 Junio C Hamano <gitster@pobox.com>: > Erick Mattos <erick.mattos@gmail.com> writes: > >>> % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD >>> >>> Should you detect an error? Does your code do so? Do you have a test >>> that catches this error? >> >> It works as intended. Both together. > > That does not make any sense. If you are saying this is yours and it is > his at the same time, there can be no sane way to work "as intended", no?. I am adding a new option not changing the option --author already in git. So it does work together. >>>> + git commit -c HEAD <<EOF >>>> + "Changed" >>>> + EOF && >>> >>> What editor is reading this "Changed"? >> >> Nobody cares... Just a text to change the file. > > I actually care. Who uses that Changed string, and where does it end up > with? At the end of the log message? At the beginning? What "file"? > I didn't get it. -c option does not accept -m option and starts an editor to change the message. The text "Changed is just a forced message. I can not use an editor in interactive mode in a script... What I am losing here?? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 2009-11-02 0:54 ` Erick Mattos @ 2009-11-02 2:58 ` Junio C Hamano 2009-11-02 3:07 ` Junio C Hamano 0 siblings, 1 reply; 13+ messages in thread From: Junio C Hamano @ 2009-11-02 2:58 UTC (permalink / raw) To: Erick Mattos; +Cc: git Erick Mattos <erick.mattos@gmail.com> writes: > 2009/11/1 Junio C Hamano <gitster@pobox.com>: >> Erick Mattos <erick.mattos@gmail.com> writes: >> >>>> % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD >>>> >>>> Should you detect an error? Does your code do so? Do you have a test >>>> that catches this error? >>> >>> It works as intended. Both together. >> >> That does not make any sense. If you are saying this is yours and it is >> his at the same time, there can be no sane way to work "as intended", no?. > > I am adding a new option not changing the option --author already in > git. So it does work together. Somebody who says "this commit is mine, and its author is this other person" is not making any sense. The resulting commit can either have that person (i.e. the committer) as the author, which is what the "claim" option means, or it can have the person named with --author as the author, but both cannot be true at the same time. When you introduce a new option, sometimes it cannot sanely be used with an existing option. In such a case, two options (the new one and the existing one) are called mutually exclusive. And you add some code to catch an user error to use them together. >>>>> + git commit -c HEAD <<EOF >>>>> + "Changed" >>>>> + EOF && >>>> >>>> What editor is reading this "Changed"? >>> >>> Nobody cares... Just a text to change the file. >> >> I actually care. Who uses that Changed string, and where does it end up >> with? At the end of the log message? At the beginning? What "file"? > > I didn't get it. -c option does not accept -m option and starts an > editor to change the message. The text "Changed is just a forced > message. I can not use an editor in interactive mode in a script... How are the existing tests that try "commit -c" do this? I do not think there is any here-text redirect into "git commit". It is sometimes easier to show by example than by giving nudging words that only show direction, so here is a suggested rewrite on top of your patch. I am not very happy with the option name "mine" either, but at least I think this gets the semantics right. Documentation/git-commit.txt | 10 ++-- Makefile | 1 + builtin-commit.c | 9 ++- t/t7509-commit.sh | 144 +++++++++++++++++++++++------------------- 4 files changed, 92 insertions(+), 72 deletions(-) diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 01eeb3e..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>] [--claim] + [(-c | -C) <commit>] [-F <file> | -m <msg>] [--mine] [--allow-empty] [--no-verify] [-e] [--author=<author>] [--cleanup=<mode>] [--] [[-i | -o ]<file>...] @@ -61,18 +61,18 @@ OPTIONS -C <commit>:: --reuse-message=<commit>:: Take an existing commit object, and reuse the log message - and the authorship information when creating the commit. + and the authorship information (including the timestamp) + when creating the commit. -c <commit>:: --reedit-message=<commit>:: Like '-C', but with '-c' the editor is invoked, so that the user can further edit the commit message. ---claim:: +--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. Therefore this option - sets the use of only the message from the original commit. + This also renews the author timestamp. -F <file>:: --file=<file>:: diff --git a/Makefile b/Makefile index 15ea32d..a9108b3 100644 --- a/Makefile +++ b/Makefile @@ -1944,3 +1944,4 @@ coverage-report: grep '^function.*called 0 ' *.c.gcov \ | sed -e 's/\([^:]*\)\.gcov: *function \([^ ]*\) called.*/\1: \2/' \ | tee coverage-untested-functions + diff --git a/builtin-commit.c b/builtin-commit.c index 1aeafa6..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, claim; +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 @@ -93,7 +93,7 @@ static struct option builtin_commit_options[] = { 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', "reuse-message", &use_message, "COMMIT", "reuse message from specified commit"), - OPT_BOOLEAN(0, "claim", &claim, "acquire authorship and restamp time of resulting 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"), @@ -382,7 +382,7 @@ static void determine_author_info(void) email = getenv("GIT_AUTHOR_EMAIL"); date = getenv("GIT_AUTHOR_DATE"); - if (use_message && !claim) { + if (use_message && !renew_authorship) { const char *a, *lb, *rb, *eol; a = strstr(use_message_buffer, "\nauthor "); @@ -748,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 index 6d9eb26..ec13cea 100755 --- a/t/t7509-commit.sh +++ b/t/t7509-commit.sh @@ -3,85 +3,101 @@ # Copyright (c) 2009 Erick Mattos # -test_description='git commit - -Tests for --claim option on a commit.' +test_description='git commit --mine' . ./test-lib.sh -TEST_FILE="$PWD"/foo +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 should be working' ' - echo "Initial" > "$TEST_FILE" && - git add "$TEST_FILE" && +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\> && - sleep 1 && - echo "Test 1" >> "$TEST_FILE" && - git add "$TEST_FILE" && - git commit -C HEAD && - git cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 && - git cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 && - cmp commit_1 commit_2 + 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 with --claim is working properly' ' - sleep 1 && - echo "Test 2" >> "$TEST_FILE" && - git add "$TEST_FILE" && - git commit -C HEAD^ --claim && - git cat-file -p HEAD^ | grep '^author' > commit_1 && - git cat-file -p HEAD | grep '^author' > commit_2 && - test_must_fail cmp commit_1 commit_2 +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 should be working' ' - echo "Initial" > "$TEST_FILE" && - git add "$TEST_FILE" && - git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && - sleep 1 && - echo "Test 3" >> "$TEST_FILE" && - git add "$TEST_FILE" && - git commit -c HEAD <<EOF - "Changed" - EOF && - git cat-file -p HEAD^ | grep '^author' > commit_1 && - git cat-file -p HEAD | grep '^author' > commit_2 && - cmp commit_1 commit_2 +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 '-c option with --claim is working properly' ' - sleep 1 && - echo "Test 4" >> "$TEST_FILE" && - git add "$TEST_FILE" && - git commit -c HEAD^ --claim <<EOF - "Changed again" - EOF && - git cat-file -p HEAD^ | grep '^author' > commit_1 && - git cat-file -p HEAD | grep '^author' > commit_2 && - test_must_fail cmp commit_1 commit_2 +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 '--amend option should be working' ' - echo "Initial" > "$TEST_FILE" && - git add "$TEST_FILE" && - git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> && - echo "Test 5" >> "$TEST_FILE" && - git add "$TEST_FILE" && - git commit -m "--amend test" && - git cat-file -p HEAD | grep '^author' > commit_1 && - sleep 1 && - git commit -m "Changed" --amend && - git cat-file -p HEAD | grep '^author' > commit_2 && - cmp commit_1 commit_2 +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 '--amend option with --claim is working properly' ' - sleep 1 && - echo "Test 6" >> "$TEST_FILE" && - git add "$TEST_FILE" && - git commit -m "Changed again" --amend --claim && - git cat-file -p HEAD | grep '^author' > commit_1 && - test_must_fail cmp commit_1 commit_2 +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 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 2009-11-02 2:58 ` Junio C Hamano @ 2009-11-02 3:07 ` Junio C Hamano 2009-11-03 16:39 ` Erick Mattos 0 siblings, 1 reply; 13+ messages in thread From: Junio C Hamano @ 2009-11-02 3:07 UTC (permalink / raw) To: Erick Mattos; +Cc: git 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 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 2009-11-02 3:07 ` Junio C Hamano @ 2009-11-03 16:39 ` Erick Mattos 0 siblings, 0 replies; 13+ messages in thread From: Erick Mattos @ 2009-11-03 16:39 UTC (permalink / raw) To: Junio C Hamano; +Cc: git 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 > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim 2009-11-01 20:02 ` Junio C Hamano 2009-11-01 20:57 ` Erick Mattos @ 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 1 sibling, 1 reply; 13+ messages in thread From: Erick Mattos @ 2009-11-01 23:14 UTC (permalink / raw) To: Junio C Hamano; +Cc: git 2009/11/1 Junio C Hamano <gitster@pobox.com>: > Erick Mattos <erick.mattos@gmail.com> writes: > >> + OPT_BOOLEAN(0, "claim", &claim, "acquire authorship and restamp time of resulting commit"), > > It is unclear from where it is "acquire"-ing, nor what "restamp" means. > > Here are my attempts to come up with better wording: > > "ignore author and timestamp of the original commit (used with -C/-c/--amend)" > "the commit is authored by me now (used with -C/-c/--amend)" Two new suggestions: "reset authorship and timestamp to you (-C-c/--amend)" # On this case "you" can be changed to "commiter" but the text is going to be bigger # and wrap. "make me new author with new timestamp (-C-c/--amend)" I am just waiting for your answers to this e-mail and to the previous one so I can send you another patch. Regards ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] commit -c/-C/--amend: reset timestamp and authorship to committer with --mine 2009-11-01 23:14 ` Erick Mattos @ 2009-11-02 0:44 ` Erick Mattos 0 siblings, 0 replies; 13+ messages in thread From: Erick Mattos @ 2009-11-02 0:44 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Erick Mattos When we use one of the options above we are normally trying to do mainly two things: one is using the source as a template and second is to recreate a commit with corrections. When they are used, the authorship and timestamp recorded in the newly created commit is always taken from the original commit. And they should not when we are using it as a template. The new --mine option is meant to solve this need by regenerating the timestamp and setting as new author the committer or the one specified on --author option. Signed-off-by: Erick Mattos <erick.mattos@gmail.com> --- Documentation/git-commit.txt | 8 +++- builtin-commit.c | 9 +++- t/t7509-commit.sh | 98 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 4 deletions(-) create mode 100755 t/t7509-commit.sh diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 0578a40..eae5bf4 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,12 @@ 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. Therefore this option + sets the use of only the message from the original commit. + -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 c395cbf..17a6794 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, mine; 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", &mine, "reset timestamp and authorship to committer"), 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 && !mine) { const char *a, *lb, *rb, *eol; a = strstr(use_message_buffer, "\nauthor "); @@ -778,6 +779,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 && mine) + die("Option --mine is used only with -C/-c/--amend."); if (use_message) { unsigned char sha1[20]; static char utf8[] = "UTF-8"; diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh new file mode 100755 index 0000000..514de6a --- /dev/null +++ b/t/t7509-commit.sh @@ -0,0 +1,98 @@ +#!/bin/sh +# +# Copyright (c) 2009 Erick Mattos +# + +test_description='git commit + +Tests for --mine option on a commit.' + +. ./test-lib.sh + +TEST_FILE=foo + +test_expect_success '-C without --mine uses the author from the old commit' ' + echo "initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author "Frigate <flying@over.world>" && + test_tick && + echo "Test 1" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -C HEAD && + git cat-file -p HEAD^ | sed -e "/^parent/d" -e "/^tree/d" \ + -e "/^committer/d" > commit_1 && + git cat-file -p HEAD | sed -e "/^parent/d" -e "/^tree/d" \ + -e "/^committer/d" > commit_2 && + test_cmp commit_1 commit_2 +' + +test_expect_success '-C with --mine makes me the author' ' + test_tick && + echo "Test 2" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -C HEAD^ --mine && + git cat-file -p HEAD^ | grep "^author" > commit_1 && + git cat-file -p HEAD | grep "^author" > commit_2 && + test "$(cat commit_1 | sed "s/.*> //")" !=\ + "$(cat commit_2 | sed "s/.*> //")" && + test "$(cat commit_2 | sed -e "s/author //" -e "s/>.*/>/")" =\ + "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" +' + +test_expect_success '-c without --mine uses the author from the old commit' ' + echo "Initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author "Frigate <flying@over.world>" && + test_tick && + echo "Test 3" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -c HEAD <<EOF + "Changed" + EOF && + git cat-file -p HEAD^ | grep "^author" > commit_1 && + git cat-file -p HEAD | grep "^author" > commit_2 && + test_cmp commit_1 commit_2 +' + +test_expect_success '-c with --mine makes me the author' ' + test_tick && + echo "Test 4" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -c HEAD^ --mine <<EOF + "Changed again" + EOF && + git cat-file -p HEAD^ | grep "^author" > commit_1 && + git cat-file -p HEAD | grep "^author" > commit_2 && + test "$(cat commit_1 | sed "s/.*> //")" !=\ + "$(cat commit_2 | sed "s/.*> //")" && + test "$(cat commit_2 | sed -e "s/author //" -e "s/>.*/>/")" =\ + "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" +' + +test_expect_success '--amend without --mine uses the author from the old commit' ' + echo "Initial" > "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Initial Commit" --author "Frigate <flying@over.world>" && + echo "Test 5" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "--amend test" && + git cat-file -p HEAD | grep "^author" > commit_1 && + test_tick && + git commit -m "Changed" --amend && + git cat-file -p HEAD | grep "^author" > commit_2 && + test_cmp commit_1 commit_2 +' + +test_expect_success '--amend with --mine makes me the author' ' + test_tick && + echo "Test 6" >> "$TEST_FILE" && + git add "$TEST_FILE" && + git commit -m "Changed again" --amend --mine && + git cat-file -p HEAD | grep "^author" > commit_1 && + test "$(cat commit_1 | sed "s/.*> //")" !=\ + "$(cat commit_2 | sed "s/.*> //")" && + test "$(cat commit_2 | sed -e "s/author //" -e "s/>.*/>/")" =\ + "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" +' + +test_done -- 1.6.5.2.102.gdbd78.dirty ^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2009-11-03 16:40 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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).