{"thread":{"id":"21441","subject":"[PATCH] commit -c/-C/--amend: take over authorship and restamp time with --claim","startedAt":"2009-10-31T03:08:00Z","lastAt":"2009-11-03T16:39:05Z","messageCount":13,"participants":["Erick Mattos","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"126507","messageId":"1256958480-6775-1-git-send-email-erick.mattos@gmail.com","threadId":"21441","inReplyTo":null,"subject":"[PATCH] commit -c/-C/--amend: take over authorship and restamp time with --claim","fromName":"Erick Mattos","fromEmail":"erick.mattos@gmail.com","sentAt":"2009-10-31T03:08:00Z","receivedAt":"2009-10-31T03:08:00Z","isPatch":true,"sender":{"key":"erick.mattos@gmail.com","avatar":"https://avatars.githubusercontent.com/u/134001?v=4"},"body":"When we use one of the options above we are normally trying to do mainly\ntwo things: one is using the source as a template and second is to\nrecreate a commit with corrections.\n\nWhen they are used, the authorship and timestamp recorded in the newly\ncreated commit is always taken from the original commit.  And they\nshould not when we are using it as a template.\n\nThe new --claim option is meant to solve this need by regenerating the\ntimestamp and setting as new author the committer or the one specified\non --author option.\n\nSigned-off-by: Erick Mattos <erick.mattos@gmail.com>\n---\n Documentation/git-commit.txt |   10 +++++++---\n builtin-commit.c             |    7 ++++---\n 2 files changed, 11 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 0578a40..96248ab 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n-\t   [(-c | -C) <commit>] [-F <file> | -m <msg>]\n+\t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--claim]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n \t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n \n@@ -61,14 +61,18 @@ OPTIONS\n -C <commit>::\n --reuse-message=<commit>::\n \tTake an existing commit object, and reuse the log message\n-\tand the authorship information (including the timestamp)\n-\twhen creating the commit.\n+\tand the authorship information when creating the commit.\n \n -c <commit>::\n --reedit-message=<commit>::\n \tLike '-C', but with '-c' the editor is invoked, so that\n \tthe user can further edit the commit message.\n \n+--claim::\n+\tWhen used with -C/-c/--amend options the committer takes over\n+\tthe cloned commit authorship and renew the timestamp thus using\n+\tonly the commit message from the source.\n+\n -F <file>::\n --file=<file>::\n \tTake the commit message from the given file.  Use '-' to\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex c395cbf..33922df 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -51,7 +51,7 @@ static const char *template_file;\n static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n-static int quiet, verbose, no_verify, allow_empty, dry_run;\n+static int quiet, verbose, no_verify, allow_empty, dry_run, claim;\n static char *untracked_files_arg;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -91,8 +91,9 @@ static struct option builtin_commit_options[] = {\n \tOPT_FILENAME('F', \"file\", &logfile, \"read log from file\"),\n \tOPT_STRING(0, \"author\", &force_author, \"AUTHOR\", \"override author for commit\"),\n \tOPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n-\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit \"),\n+\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit\"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n+\tOPT_BOOLEAN(0, \"claim\", &claim, \"take over cloned commit authorship and renew timestamp\"),\n \tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n \tOPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n@@ -381,7 +382,7 @@ static void determine_author_info(void)\n \temail = getenv(\"GIT_AUTHOR_EMAIL\");\n \tdate = getenv(\"GIT_AUTHOR_DATE\");\n \n-\tif (use_message) {\n+\tif (use_message && !claim) {\n \t\tconst char *a, *lb, *rb, *eol;\n \n \t\ta = strstr(use_message_buffer, \"\\nauthor \");\n-- \n1.6.5.2.102.g0a733\n"},{"id":"126538","messageId":"7v7hub5kam.fsf@alter.siamese.dyndns.org","threadId":"21441","inReplyTo":"1256958480-6775-1-git-send-email-erick.mattos@gmail.com","subject":"Re: [PATCH] commit -c/-C/--amend: take over authorship and restamp time with --claim","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-31T21:24:17Z","receivedAt":"2009-10-31T21:24:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Erick Mattos <erick.mattos@gmail.com> writes:\n\n> The new --claim option is meant to solve this need by regenerating the\n> timestamp and setting as new author the committer or the one specified\n> on --author option.\n\nI'll leave discussion on the option name to others.\n\n> +--claim::\n> +\tWhen used with -C/-c/--amend options the committer takes over\n> +\tthe cloned commit authorship and renew the timestamp thus using\n> +\tonly the commit message from the source.\n\n\"The cloned commit\" is a bit misleading; in the mind of users --amend does\nnot clone but rewrite, as the old commit usually only belongs to a reflog\nand not any other branch.  I'd rewrite it this way, perhaps.\n\n\tWhen used with -C/-c/--amend options, declare that the authorship\n\tof the resulting commit now belongs of the committer.  This also\n\trenews the author timestamp.\n\nWe also would need a test to protect this new feature from getting broken\nby future updates.\n\nThanks.\n"},{"id":"126551","messageId":"1257099580-7365-1-git-send-email-erick.mattos@gmail.com","threadId":"21441","inReplyTo":"7v7hub5kam.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] commit -c/-C/--amend: take over authorship and restamp time with --claim","fromName":"Erick Mattos","fromEmail":"erick.mattos@gmail.com","sentAt":"2009-11-01T18:19:40Z","receivedAt":"2009-11-01T18:19:40Z","isPatch":true,"sender":{"key":"erick.mattos@gmail.com","avatar":"https://avatars.githubusercontent.com/u/134001?v=4"},"body":"When we use one of the options above we are normally trying to do mainly\ntwo things: one is using the source as a template and second is to\nrecreate a commit with corrections.\n\nWhen they are used, the authorship and timestamp recorded in the newly\ncreated commit is always taken from the original commit.  And they\nshould not when we are using it as a template.\n\nThe new --claim option is meant to solve this need by regenerating the\ntimestamp and setting as new author the committer or the one specified\non --author option.\n\nSigned-off-by: Erick Mattos <erick.mattos@gmail.com>\n---\n Documentation/git-commit.txt |   11 ++++-\n builtin-commit.c             |    7 ++-\n t/t7509-commit.sh            |   87 ++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 99 insertions(+), 6 deletions(-)\n create mode 100755 t/t7509-commit.sh\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 0578a40..27b774e 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n-\t   [(-c | -C) <commit>] [-F <file> | -m <msg>]\n+\t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--claim]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n \t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n \n@@ -61,14 +61,19 @@ OPTIONS\n -C <commit>::\n --reuse-message=<commit>::\n \tTake an existing commit object, and reuse the log message\n-\tand the authorship information (including the timestamp)\n-\twhen creating the commit.\n+\tand the authorship information when creating the commit.\n \n -c <commit>::\n --reedit-message=<commit>::\n \tLike '-C', but with '-c' the editor is invoked, so that\n \tthe user can further edit the commit message.\n \n+--claim::\n+\tWhen used with -C/-c/--amend options, declare that the\n+\tauthorship of the resulting commit now belongs of the committer.\n+\tThis also renews the author timestamp.  Therefore this option\n+\tsets the use of the message only from the original commit.\n+\n -F <file>::\n --file=<file>::\n \tTake the commit message from the given file.  Use '-' to\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex c395cbf..33922df 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -51,7 +51,7 @@ static const char *template_file;\n static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n-static int quiet, verbose, no_verify, allow_empty, dry_run;\n+static int quiet, verbose, no_verify, allow_empty, dry_run, claim;\n static char *untracked_files_arg;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -91,8 +91,9 @@ static struct option builtin_commit_options[] = {\n \tOPT_FILENAME('F', \"file\", &logfile, \"read log from file\"),\n \tOPT_STRING(0, \"author\", &force_author, \"AUTHOR\", \"override author for commit\"),\n \tOPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n-\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit \"),\n+\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit\"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n+\tOPT_BOOLEAN(0, \"claim\", &claim, \"take over cloned commit authorship and renew timestamp\"),\n \tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n \tOPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n@@ -381,7 +382,7 @@ static void determine_author_info(void)\n \temail = getenv(\"GIT_AUTHOR_EMAIL\");\n \tdate = getenv(\"GIT_AUTHOR_DATE\");\n \n-\tif (use_message) {\n+\tif (use_message && !claim) {\n \t\tconst char *a, *lb, *rb, *eol;\n \n \t\ta = strstr(use_message_buffer, \"\\nauthor \");\ndiff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\nnew file mode 100755\nindex 0000000..62fb00f\n--- /dev/null\n+++ b/t/t7509-commit.sh\n@@ -0,0 +1,87 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 Erick Mattos\n+#\n+\n+test_description='git commit\n+\n+Tests for --claim option on a commit.'\n+\n+. ./test-lib.sh\n+\n+TEST_FILE=\"$PWD\"/foo\n+\n+test_expect_success '-C option should be working' '\n+\techo \"Initial\" > \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> && \n+\tsleep 1 && \n+\techo \"Test 1\" >> \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -C HEAD && \n+\tgit cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 && \n+\tgit cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 && \n+\tcmp commit_1 commit_2\n+'\n+\n+test_expect_success '-C option with --claim is working properly' '\n+\tsleep 1 &&\n+\techo \"Test 2\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -C HEAD^ --claim &&\n+\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n+\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n+\ttest_must_fail cmp commit_1 commit_2\n+'\n+\n+test_expect_success '-c option should be working' '\n+\techo \"Initial\" > \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> && \n+\tsleep 1 && \n+\techo \"Test 3\" >> \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -c HEAD <<EOF\n+\t\"Changed\" \n+\tEOF && \n+\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n+\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n+\tcmp commit_1 commit_2\n+'\n+\n+test_expect_success '-c option with --claim is working properly' '\n+\tsleep 1 &&\n+\techo \"Test 4\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -c HEAD^ --claim <<EOF\n+\t\"Changed again\" \n+\tEOF && \n+\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n+\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n+\ttest_must_fail cmp commit_1 commit_2\n+'\n+\n+test_expect_success '--amend option should be working' '\n+\techo \"Initial\" > \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> && \n+\techo \"Test 5\" >> \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -m \"--amend test\" && \n+\tgit cat-file -p HEAD | grep '^author' > commit_1 &&\n+\tsleep 1 && \n+\tgit commit -m \"Changed\" --amend && \n+\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n+\tcmp commit_1 commit_2\n+'\n+\n+test_expect_success '--amend option with --claim is working properly' '\n+\tsleep 1 &&\n+\techo \"Test 6\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -m \"Changed again\" --amend --claim && \n+\tgit cat-file -p HEAD | grep '^author' > commit_1 &&\n+\ttest_must_fail cmp commit_1 commit_2\n+'\n+\n+test_done\n-- \n1.6.5.GIT\n"},{"id":"126552","messageId":"1257101127-8196-1-git-send-email-erick.mattos@gmail.com","threadId":"21441","inReplyTo":"1257099580-7365-1-git-send-email-erick.mattos@gmail.com","subject":"[PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Erick Mattos","fromEmail":"erick.mattos@gmail.com","sentAt":"2009-11-01T18:45:27Z","receivedAt":"2009-11-01T18:45:27Z","isPatch":true,"sender":{"key":"erick.mattos@gmail.com","avatar":"https://avatars.githubusercontent.com/u/134001?v=4"},"body":"When we use one of the options above we are normally trying to do mainly\ntwo things: one is using the source as a template and second is to\nrecreate a commit with corrections.\n\nWhen they are used, the authorship and timestamp recorded in the newly\ncreated commit is always taken from the original commit.  And they\nshould not when we are using it as a template.\n\nThe new --claim option is meant to solve this need by regenerating the\ntimestamp and setting as new author the committer or the one specified\non --author option.\n\nSigned-off-by: Erick Mattos <erick.mattos@gmail.com>\n---\n Documentation/git-commit.txt |   11 ++++-\n builtin-commit.c             |    7 ++-\n t/t7509-commit.sh            |   87 ++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 99 insertions(+), 6 deletions(-)\n create mode 100755 t/t7509-commit.sh\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 0578a40..01eeb3e 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n-\t   [(-c | -C) <commit>] [-F <file> | -m <msg>]\n+\t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--claim]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n \t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n \n@@ -61,14 +61,19 @@ OPTIONS\n -C <commit>::\n --reuse-message=<commit>::\n \tTake an existing commit object, and reuse the log message\n-\tand the authorship information (including the timestamp)\n-\twhen creating the commit.\n+\tand the authorship information when creating the commit.\n \n -c <commit>::\n --reedit-message=<commit>::\n \tLike '-C', but with '-c' the editor is invoked, so that\n \tthe user can further edit the commit message.\n \n+--claim::\n+\tWhen used with -C/-c/--amend options, declare that the\n+\tauthorship of the resulting commit now belongs of the committer.\n+\tThis also renews the author timestamp.  Therefore this option\n+\tsets the use of only the message from the original commit.\n+\n -F <file>::\n --file=<file>::\n \tTake the commit message from the given file.  Use '-' to\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex c395cbf..919e3fe 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -51,7 +51,7 @@ static const char *template_file;\n static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n-static int quiet, verbose, no_verify, allow_empty, dry_run;\n+static int quiet, verbose, no_verify, allow_empty, dry_run, claim;\n static char *untracked_files_arg;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -91,8 +91,9 @@ static struct option builtin_commit_options[] = {\n \tOPT_FILENAME('F', \"file\", &logfile, \"read log from file\"),\n \tOPT_STRING(0, \"author\", &force_author, \"AUTHOR\", \"override author for commit\"),\n \tOPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n-\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit \"),\n+\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit\"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n+\tOPT_BOOLEAN(0, \"claim\", &claim, \"acquire authorship and restamp time of resulting commit\"),\n \tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n \tOPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n@@ -381,7 +382,7 @@ static void determine_author_info(void)\n \temail = getenv(\"GIT_AUTHOR_EMAIL\");\n \tdate = getenv(\"GIT_AUTHOR_DATE\");\n \n-\tif (use_message) {\n+\tif (use_message && !claim) {\n \t\tconst char *a, *lb, *rb, *eol;\n \n \t\ta = strstr(use_message_buffer, \"\\nauthor \");\ndiff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\nnew file mode 100755\nindex 0000000..62fb00f\n--- /dev/null\n+++ b/t/t7509-commit.sh\n@@ -0,0 +1,87 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 Erick Mattos\n+#\n+\n+test_description='git commit\n+\n+Tests for --claim option on a commit.'\n+\n+. ./test-lib.sh\n+\n+TEST_FILE=\"$PWD\"/foo\n+\n+test_expect_success '-C option should be working' '\n+\techo \"Initial\" > \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> && \n+\tsleep 1 && \n+\techo \"Test 1\" >> \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -C HEAD && \n+\tgit cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 && \n+\tgit cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 && \n+\tcmp commit_1 commit_2\n+'\n+\n+test_expect_success '-C option with --claim is working properly' '\n+\tsleep 1 &&\n+\techo \"Test 2\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -C HEAD^ --claim &&\n+\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n+\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n+\ttest_must_fail cmp commit_1 commit_2\n+'\n+\n+test_expect_success '-c option should be working' '\n+\techo \"Initial\" > \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> && \n+\tsleep 1 && \n+\techo \"Test 3\" >> \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -c HEAD <<EOF\n+\t\"Changed\" \n+\tEOF && \n+\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n+\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n+\tcmp commit_1 commit_2\n+'\n+\n+test_expect_success '-c option with --claim is working properly' '\n+\tsleep 1 &&\n+\techo \"Test 4\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -c HEAD^ --claim <<EOF\n+\t\"Changed again\" \n+\tEOF && \n+\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n+\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n+\ttest_must_fail cmp commit_1 commit_2\n+'\n+\n+test_expect_success '--amend option should be working' '\n+\techo \"Initial\" > \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> && \n+\techo \"Test 5\" >> \"$TEST_FILE\" && \n+\tgit add \"$TEST_FILE\" && \n+\tgit commit -m \"--amend test\" && \n+\tgit cat-file -p HEAD | grep '^author' > commit_1 &&\n+\tsleep 1 && \n+\tgit commit -m \"Changed\" --amend && \n+\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n+\tcmp commit_1 commit_2\n+'\n+\n+test_expect_success '--amend option with --claim is working properly' '\n+\tsleep 1 &&\n+\techo \"Test 6\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -m \"Changed again\" --amend --claim && \n+\tgit cat-file -p HEAD | grep '^author' > commit_1 &&\n+\ttest_must_fail cmp commit_1 commit_2\n+'\n+\n+test_done\n-- \n1.6.5.GIT\n"},{"id":"126554","messageId":"7vr5sixbd1.fsf@alter.siamese.dyndns.org","threadId":"21441","inReplyTo":"1257101127-8196-1-git-send-email-erick.mattos@gmail.com","subject":"Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-01T20:02:02Z","receivedAt":"2009-11-01T20:02:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Erick Mattos <erick.mattos@gmail.com> writes:\n\n> The new --claim option is meant to solve this need by regenerating the\n> timestamp and setting as new author the committer or the one specified\n> on --author option.\n\nThanks.\n\nI don't think \"claim\" is a good name for this option.  It makes me go\n\"huh, I do not get it.  What are you claiming?  Claiming that this is the\ncorrect fix?\"\n\nRenaming it to \"claim-authorship\" may avoid that confusion, but it is too\nlong.\n\nHow about naming this option \"mine\"?\n\n> @@ -61,14 +61,19 @@ OPTIONS\n>  -C <commit>::\n>  --reuse-message=<commit>::\n>  \tTake an existing commit object, and reuse the log message\n> -\tand the authorship information (including the timestamp)\n> -\twhen creating the commit.\n> +\tand the authorship information when creating the commit.\n\nI don't think this is a good change.\n\nWhen you use the new option, the author name, email and timestamp are\nignored, and when you don't, they are all used.\n\nTo new users who are taught to first set user.name and user.email via\nconfiguration variables, the phrase \"authorship information\" would mean\n<name, email> pair, and the explanation in the parentheses helps to avoid\na misunderstanding that these two are the only things that are copied.\n\nI would suggest you keep the original text.\n\n> +--claim::\n> +\tWhen used with -C/-c/--amend options, declare that the\n> +\tauthorship of the resulting commit now belongs of the committer.\n> +\tThis also renews the author timestamp.  Therefore this option\n> +\tsets the use of only the message from the original commit.\n\nI don't understand/parse the last sentence; I don't think it is necessary,\neither.\n\n> diff --git a/builtin-commit.c b/builtin-commit.c\n> index c395cbf..919e3fe 100644\n> --- a/builtin-commit.c\n> +++ b/builtin-commit.c\n> @@ -51,7 +51,7 @@ static const char *template_file;\n>  static char *edit_message, *use_message;\n>  static char *author_name, *author_email, *author_date;\n>  static int all, edit_flag, also, interactive, only, amend, signoff;\n> -static int quiet, verbose, no_verify, allow_empty, dry_run;\n> +static int quiet, verbose, no_verify, allow_empty, dry_run, claim;\n\nEven if you name the command option \"claim\" in order to keep it short, I\nthink it is a bad idea to name the variable \"claim\", because it doesn't\nsay _what_ you are claiming and is confusing.  Naming it claim_authorship\nwould be better.\n\n> +\tOPT_BOOLEAN(0, \"claim\", &claim, \"acquire authorship and restamp time of resulting commit\"),\n\nIt is unclear from where it is \"acquire\"-ing, nor what \"restamp\" means.\n\nHere are my attempts to come up with better wording:\n\n    \"ignore author and timestamp of the original commit (used with -C/-c/--amend)\"\n    \"the commit is authored by me now (used with -C/-c/--amend)\"\n\nThe latter will work well if the option is renamed to \"--mine\".\n\nWhat should happen when the user uses --claim without -C/-c/--amend?\n\n    % git commit --claim\n\nShould you detect an error?  Does your code do so?  Do you have a test\nthat catches this error?\n\nWhat should happen when the user uses --author and --claim at the same time?\n\n    % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD\n\nShould you detect an error?  Does your code do so?  Do you have a test\nthat catches this error?\n\n> diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\n> new file mode 100755\n> index 0000000..62fb00f\n> --- /dev/null\n> +++ b/t/t7509-commit.sh\n> @@ -0,0 +1,87 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2009 Erick Mattos\n> +#\n> +\n> +test_description='git commit\n> +\n> +Tests for --claim option on a commit.'\n> +\n> +. ./test-lib.sh\n> +\n> +TEST_FILE=\"$PWD\"/foo\n\nWhy does this have to be given as a full path, not just \"foo\"?\n\n> +test_expect_success '-C option should be working' '\n\nEvery test is about \"should be working\", so you are wasting 16 letters or\nso without giving any useful information.\n\nSay something like \"-C without --claim uses the author from the old commit\" here.\n\n> +\techo \"Initial\" > \"$TEST_FILE\" && \n> +\tgit add \"$TEST_FILE\" && \n> +\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> && \n> +\tsleep 1 && \n\nIf you use \"test_tick\", you don't have to slow the test down. You use\n\"test_tick\" before you commit to increment the time. Look at t6036 for an\nexample.\n\n> +\techo \"Test 1\" >> \"$TEST_FILE\" && \n> +\tgit add \"$TEST_FILE\" && \n> +\tgit commit -C HEAD && \n> +\tgit cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 && \n> +\tgit cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 && \n> +\tcmp commit_1 commit_2\n> +'\n\nUse \"test_cmp\" instead, so that errors can be seen easily when somebody\nbreaks this new feature.\n\n> +test_expect_success '-C option with --claim is working properly' '\n\nAgain, \"working properly\" is a meaningless thing to say because that is\nwhat all tests check. \"-C with --claim makes me the author\" would be\nbetter.\n\n> +\tsleep 1 &&\n> +\techo \"Test 2\" >> \"$TEST_FILE\" &&\n> +\tgit add \"$TEST_FILE\" &&\n> +\tgit commit -C HEAD^ --claim &&\n> +\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n> +\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n> +\ttest_must_fail cmp commit_1 commit_2\n\nThis test shouldn't be happy with any random author information that\nhappens to be different from the original. The purpose of --claim option\nis to take the authorship, make it mine (or whoever is specified with\nGIT_AUTHOR_NAME or user.name or uid-to-gecos), so the last cmp (again, it\nshould use test_cmp) should make sure that the author is 'A U Thor', not\njust being different from \"Frigate\" or whatever.  It should check email\nand timestamp as well, of course.\n\n> +'\n> +\n> +test_expect_success '-c option should be working' '\n> +\techo \"Initial\" > \"$TEST_FILE\" && \n> +\tgit add \"$TEST_FILE\" && \n> +\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> && \n> +\tsleep 1 && \n> +\techo \"Test 3\" >> \"$TEST_FILE\" && \n> +\tgit add \"$TEST_FILE\" && \n> +\tgit commit -c HEAD <<EOF\n> +\t\"Changed\" \n> +\tEOF && \n\nWhat editor is reading this \"Changed\"?\n"},{"id":"126558","messageId":"55bacdd30911011257m22ee85f2wc5d51865f7f2aadd@mail.gmail.com","threadId":"21441","inReplyTo":"7vr5sixbd1.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Erick Mattos","fromEmail":"erick.mattos@gmail.com","sentAt":"2009-11-01T20:57:37Z","receivedAt":"2009-11-01T20:57:37Z","isPatch":true,"sender":{"key":"erick.mattos@gmail.com","avatar":"https://avatars.githubusercontent.com/u/134001?v=4"},"body":"2009/11/1 Junio C Hamano <gitster@pobox.com>:\n> Erick Mattos <erick.mattos@gmail.com> writes:\n>\n>> The new --claim option is meant to solve this need by regenerating the\n>> timestamp and setting as new author the committer or the one specified\n>> on --author option.\n>\n> Thanks.\n>\n> I don't think \"claim\" is a good name for this option.  It makes me go\n> \"huh, I do not get it.  What are you claiming?  Claiming that this is the\n> correct fix?\"\n>\n> Renaming it to \"claim-authorship\" may avoid that confusion, but it is too\n> long.\n>\n> How about naming this option \"mine\"?\n\nMakes sense: \"mine\" then.  I felt you haven't like the name.\n\n>> @@ -61,14 +61,19 @@ OPTIONS\n>>  -C <commit>::\n>>  --reuse-message=<commit>::\n>>       Take an existing commit object, and reuse the log message\n>> -     and the authorship information (including the timestamp)\n>> -     when creating the commit.\n>> +     and the authorship information when creating the commit.\n>\n> I don't think this is a good change.\n>\n> When you use the new option, the author name, email and timestamp are\n> ignored, and when you don't, they are all used.\n>\n> To new users who are taught to first set user.name and user.email via\n> configuration variables, the phrase \"authorship information\" would mean\n> <name, email> pair, and the explanation in the parentheses helps to avoid\n> a misunderstanding that these two are the only things that are copied.\n>\n> I would suggest you keep the original text.\n\nI think it is pointless but if you say so.\n\n>> +--claim::\n>> +     When used with -C/-c/--amend options, declare that the\n>> +     authorship of the resulting commit now belongs of the committer.\n>> +     This also renews the author timestamp.  Therefore this option\n>> +     sets the use of only the message from the original commit.\n>\n> I don't understand/parse the last sentence; I don't think it is necessary,\n> either.\n\nJust trying to clarify.  I think people that would be searching for\nrenewing timestamp as I was would find it easier to identify the\ncorrect option.\n\n>> diff --git a/builtin-commit.c b/builtin-commit.c\n>> index c395cbf..919e3fe 100644\n>> --- a/builtin-commit.c\n>> +++ b/builtin-commit.c\n>> @@ -51,7 +51,7 @@ static const char *template_file;\n>>  static char *edit_message, *use_message;\n>>  static char *author_name, *author_email, *author_date;\n>>  static int all, edit_flag, also, interactive, only, amend, signoff;\n>> -static int quiet, verbose, no_verify, allow_empty, dry_run;\n>> +static int quiet, verbose, no_verify, allow_empty, dry_run, claim;\n>\n> Even if you name the command option \"claim\" in order to keep it short, I\n> think it is a bad idea to name the variable \"claim\", because it doesn't\n> say _what_ you are claiming and is confusing.  Naming it claim_authorship\n> would be better.\n\nChanged to mine.\n\n>> +     OPT_BOOLEAN(0, \"claim\", &claim, \"acquire authorship and restamp time of resulting commit\"),\n>\n> It is unclear from where it is \"acquire\"-ing, nor what \"restamp\" means.\n>\n> Here are my attempts to come up with better wording:\n>\n>    \"ignore author and timestamp of the original commit (used with -C/-c/--amend)\"\n>    \"the commit is authored by me now (used with -C/-c/--amend)\"\n\nWhat about \"take new timestamp and make me new author (with -C/-c/--amend)\"?\n\n> The latter will work well if the option is renamed to \"--mine\".\n>\n> What should happen when the user uses --claim without -C/-c/--amend?\n>\n>    % git commit --claim\n>\n> Should you detect an error?  Does your code do so?  Do you have a test\n> that catches this error?\n\nYou say it.  In the first patch of mine I was testing for\n--(new|old)-timestamp.  Now I thought it was unnecessary because the\nnormal behavior is documented and by comparison with other options\nwhich does not test combinations extensively.  But it is just code to\nadd if you want...\n\n> What should happen when the user uses --author and --claim at the same time?\n>\n>    % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD\n>\n> Should you detect an error?  Does your code do so?  Do you have a test\n> that catches this error?\n\nIt works as intended.  Both together.\n\n>> diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\n>> new file mode 100755\n>> index 0000000..62fb00f\n>> --- /dev/null\n>> +++ b/t/t7509-commit.sh\n>> @@ -0,0 +1,87 @@\n>> +#!/bin/sh\n>> +#\n>> +# Copyright (c) 2009 Erick Mattos\n>> +#\n>> +\n>> +test_description='git commit\n>> +\n>> +Tests for --claim option on a commit.'\n>> +\n>> +. ./test-lib.sh\n>> +\n>> +TEST_FILE=\"$PWD\"/foo\n>\n> Why does this have to be given as a full path, not just \"foo\"?\n\nTemplating from other scripts.  Ask them...   :-)\n\n>> +test_expect_success '-C option should be working' '\n>\n> Every test is about \"should be working\", so you are wasting 16 letters or\n> so without giving any useful information.\n>\n> Say something like \"-C without --claim uses the author from the old commit\" here.\n>\n>> +     echo \"Initial\" > \"$TEST_FILE\" &&\n>> +     git add \"$TEST_FILE\" &&\n>> +     git commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> &&\n>> +     sleep 1 &&\n>\n> If you use \"test_tick\", you don't have to slow the test down. You use\n> \"test_tick\" before you commit to increment the time. Look at t6036 for an\n> example.\n\nEasy change.\n\n>> +     echo \"Test 1\" >> \"$TEST_FILE\" &&\n>> +     git add \"$TEST_FILE\" &&\n>> +     git commit -C HEAD &&\n>> +     git cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 &&\n>> +     git cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 &&\n>> +     cmp commit_1 commit_2\n>> +'\n>\n> Use \"test_cmp\" instead, so that errors can be seen easily when somebody\n> breaks this new feature.\n\nEasy change.\n\n>> +test_expect_success '-C option with --claim is working properly' '\n>\n> Again, \"working properly\" is a meaningless thing to say because that is\n> what all tests check. \"-C with --claim makes me the author\" would be\n> better.\n>\n>> +     sleep 1 &&\n>> +     echo \"Test 2\" >> \"$TEST_FILE\" &&\n>> +     git add \"$TEST_FILE\" &&\n>> +     git commit -C HEAD^ --claim &&\n>> +     git cat-file -p HEAD^ | grep '^author' > commit_1 &&\n>> +     git cat-file -p HEAD | grep '^author' > commit_2 &&\n>> +     test_must_fail cmp commit_1 commit_2\n>\n> This test shouldn't be happy with any random author information that\n> happens to be different from the original. The purpose of --claim option\n> is to take the authorship, make it mine (or whoever is specified with\n> GIT_AUTHOR_NAME or user.name or uid-to-gecos), so the last cmp (again, it\n> should use test_cmp) should make sure that the author is 'A U Thor', not\n> just being different from \"Frigate\" or whatever.  It should check email\n> and timestamp as well, of course.\n\nGood point but the text imho is a little unnecessary because the\nchange could only be to user.name, user.email, ...\nBut if want that it will be an easy change too.\n\n>> +'\n>> +\n>> +test_expect_success '-c option should be working' '\n>> +     echo \"Initial\" > \"$TEST_FILE\" &&\n>> +     git add \"$TEST_FILE\" &&\n>> +     git commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> &&\n>> +     sleep 1 &&\n>> +     echo \"Test 3\" >> \"$TEST_FILE\" &&\n>> +     git add \"$TEST_FILE\" &&\n>> +     git commit -c HEAD <<EOF\n>> +     \"Changed\"\n>> +     EOF &&\n>\n> What editor is reading this \"Changed\"?\n>\n\nNobody cares...  Just a text to change the file.\n"},{"id":"126562","messageId":"55bacdd30911011514r1be6e09fobe2751588ed5166e@mail.gmail.com","threadId":"21441","inReplyTo":"7vr5sixbd1.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Erick Mattos","fromEmail":"erick.mattos@gmail.com","sentAt":"2009-11-01T23:14:56Z","receivedAt":"2009-11-01T23:14:56Z","isPatch":true,"sender":{"key":"erick.mattos@gmail.com","avatar":"https://avatars.githubusercontent.com/u/134001?v=4"},"body":"2009/11/1 Junio C Hamano <gitster@pobox.com>:\n> Erick Mattos <erick.mattos@gmail.com> writes:\n>\n>> +     OPT_BOOLEAN(0, \"claim\", &claim, \"acquire authorship and restamp time of resulting commit\"),\n>\n> It is unclear from where it is \"acquire\"-ing, nor what \"restamp\" means.\n>\n> Here are my attempts to come up with better wording:\n>\n>    \"ignore author and timestamp of the original commit (used with -C/-c/--amend)\"\n>    \"the commit is authored by me now (used with -C/-c/--amend)\"\n\nTwo new suggestions:\n\n\"reset authorship and timestamp to you (-C-c/--amend)\"\n        # On this case \"you\" can be changed to \"commiter\" but the text\nis going to be bigger\n        # and wrap.\n\n\"make me new author with new timestamp (-C-c/--amend)\"\n\nI am just waiting for your answers to this e-mail and to the previous\none so I can send you another patch.\n\nRegards\n"},{"id":"126565","messageId":"1257122660-21350-1-git-send-email-erick.mattos@gmail.com","threadId":"21441","inReplyTo":"55bacdd30911011514r1be6e09fobe2751588ed5166e@mail.gmail.com","subject":"[PATCH] commit -c/-C/--amend: reset timestamp and authorship to committer with --mine","fromName":"Erick Mattos","fromEmail":"erick.mattos@gmail.com","sentAt":"2009-11-02T00:44:20Z","receivedAt":"2009-11-02T00:44:20Z","isPatch":true,"sender":{"key":"erick.mattos@gmail.com","avatar":"https://avatars.githubusercontent.com/u/134001?v=4"},"body":"When we use one of the options above we are normally trying to do mainly\ntwo things: one is using the source as a template and second is to\nrecreate a commit with corrections.\n\nWhen they are used, the authorship and timestamp recorded in the newly\ncreated commit is always taken from the original commit.  And they\nshould not when we are using it as a template.\n\nThe new --mine option is meant to solve this need by regenerating the\ntimestamp and setting as new author the committer or the one specified\non --author option.\n\nSigned-off-by: Erick Mattos <erick.mattos@gmail.com>\n---\n Documentation/git-commit.txt |    8 +++-\n builtin-commit.c             |    9 +++-\n t/t7509-commit.sh            |   98 ++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 111 insertions(+), 4 deletions(-)\n create mode 100755 t/t7509-commit.sh\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 0578a40..eae5bf4 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n-\t   [(-c | -C) <commit>] [-F <file> | -m <msg>]\n+\t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--mine]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n \t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n \n@@ -69,6 +69,12 @@ OPTIONS\n \tLike '-C', but with '-c' the editor is invoked, so that\n \tthe user can further edit the commit message.\n \n+--mine::\n+\tWhen used with -C/-c/--amend options, declare that the\n+\tauthorship of the resulting commit now belongs of the committer.\n+\tThis also renews the author timestamp.  Therefore this option\n+\tsets the use of only the message from the original commit.\n+\n -F <file>::\n --file=<file>::\n \tTake the commit message from the given file.  Use '-' to\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex c395cbf..17a6794 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -51,7 +51,7 @@ static const char *template_file;\n static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n-static int quiet, verbose, no_verify, allow_empty, dry_run;\n+static int quiet, verbose, no_verify, allow_empty, dry_run, mine;\n static char *untracked_files_arg;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -91,8 +91,9 @@ static struct option builtin_commit_options[] = {\n \tOPT_FILENAME('F', \"file\", &logfile, \"read log from file\"),\n \tOPT_STRING(0, \"author\", &force_author, \"AUTHOR\", \"override author for commit\"),\n \tOPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n-\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit \"),\n+\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit\"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n+\tOPT_BOOLEAN(0, \"mine\", &mine, \"reset timestamp and authorship to committer\"),\n \tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n \tOPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n@@ -381,7 +382,7 @@ static void determine_author_info(void)\n \temail = getenv(\"GIT_AUTHOR_EMAIL\");\n \tdate = getenv(\"GIT_AUTHOR_DATE\");\n \n-\tif (use_message) {\n+\tif (use_message && !mine) {\n \t\tconst char *a, *lb, *rb, *eol;\n \n \t\ta = strstr(use_message_buffer, \"\\nauthor \");\n@@ -778,6 +779,8 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \t\tuse_message = edit_message;\n \tif (amend && !use_message)\n \t\tuse_message = \"HEAD\";\n+\tif (!use_message && mine)\n+\t\tdie(\"Option --mine is used only with -C/-c/--amend.\");\n \tif (use_message) {\n \t\tunsigned char sha1[20];\n \t\tstatic char utf8[] = \"UTF-8\";\ndiff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\nnew file mode 100755\nindex 0000000..514de6a\n--- /dev/null\n+++ b/t/t7509-commit.sh\n@@ -0,0 +1,98 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 Erick Mattos\n+#\n+\n+test_description='git commit\n+\n+Tests for --mine option on a commit.'\n+\n+. ./test-lib.sh\n+\n+TEST_FILE=foo\n+\n+test_expect_success '-C without --mine uses the author from the old commit' '\n+\techo \"initial\" > \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -m \"Initial Commit\" --author \"Frigate <flying@over.world>\" &&\n+\ttest_tick &&\n+\techo \"Test 1\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -C HEAD &&\n+\tgit cat-file -p HEAD^ | sed -e \"/^parent/d\" -e \"/^tree/d\" \\\n+\t\t-e \"/^committer/d\" > commit_1 &&\n+\tgit cat-file -p HEAD | sed -e \"/^parent/d\" -e \"/^tree/d\" \\\n+\t\t-e \"/^committer/d\" > commit_2 &&\n+\ttest_cmp commit_1 commit_2\n+'\n+\n+test_expect_success '-C with --mine makes me the author' '\n+\ttest_tick &&\n+\techo \"Test 2\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -C HEAD^ --mine &&\n+\tgit cat-file -p HEAD^ | grep \"^author\" > commit_1 &&\n+\tgit cat-file -p HEAD | grep \"^author\" > commit_2 &&\n+\ttest \"$(cat commit_1 | sed \"s/.*> //\")\" !=\\\n+\t\t\"$(cat commit_2 | sed \"s/.*> //\")\" &&\n+\ttest \"$(cat commit_2 | sed -e \"s/author //\" -e \"s/>.*/>/\")\" =\\\n+\t\t\"$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\"\n+'\n+\n+test_expect_success '-c without --mine uses the author from the old commit' '\n+\techo \"Initial\" > \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -m \"Initial Commit\" --author \"Frigate <flying@over.world>\" &&\n+\ttest_tick &&\n+\techo \"Test 3\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -c HEAD <<EOF\n+\t\"Changed\" \n+\tEOF &&\n+\tgit cat-file -p HEAD^ | grep \"^author\" > commit_1 &&\n+\tgit cat-file -p HEAD | grep \"^author\" > commit_2 &&\n+\ttest_cmp commit_1 commit_2\n+'\n+\n+test_expect_success '-c with --mine makes me the author' '\n+\ttest_tick &&\n+\techo \"Test 4\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -c HEAD^ --mine <<EOF\n+\t\"Changed again\" \n+\tEOF &&\n+\tgit cat-file -p HEAD^ | grep \"^author\" > commit_1 &&\n+\tgit cat-file -p HEAD | grep \"^author\" > commit_2 &&\n+\ttest \"$(cat commit_1 | sed \"s/.*> //\")\" !=\\\n+\t\t\"$(cat commit_2 | sed \"s/.*> //\")\" &&\n+\ttest \"$(cat commit_2 | sed -e \"s/author //\" -e \"s/>.*/>/\")\" =\\\n+\t\t\"$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\"\n+'\n+\n+test_expect_success '--amend without --mine uses the author from the old commit' '\n+\techo \"Initial\" > \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -m \"Initial Commit\" --author \"Frigate <flying@over.world>\" &&\n+\techo \"Test 5\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -m \"--amend test\" &&\n+\tgit cat-file -p HEAD | grep \"^author\" > commit_1 &&\n+\ttest_tick &&\n+\tgit commit -m \"Changed\" --amend &&\n+\tgit cat-file -p HEAD | grep \"^author\" > commit_2 &&\n+\ttest_cmp commit_1 commit_2\n+'\n+\n+test_expect_success '--amend with --mine makes me the author' '\n+\ttest_tick &&\n+\techo \"Test 6\" >> \"$TEST_FILE\" &&\n+\tgit add \"$TEST_FILE\" &&\n+\tgit commit -m \"Changed again\" --amend --mine &&\n+\tgit cat-file -p HEAD | grep \"^author\" > commit_1 &&\n+\ttest \"$(cat commit_1 | sed \"s/.*> //\")\" !=\\\n+\t\t\"$(cat commit_2 | sed \"s/.*> //\")\" &&\n+\ttest \"$(cat commit_2 | sed -e \"s/author //\" -e \"s/>.*/>/\")\" =\\\n+\t\t\"$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>\"\n+'\n+\n+test_done\n-- \n1.6.5.2.102.gdbd78.dirty\n"},{"id":"126566","messageId":"7vbpjlycqc.fsf@alter.siamese.dyndns.org","threadId":"21441","inReplyTo":"55bacdd30911011257m22ee85f2wc5d51865f7f2aadd@mail.gmail.com","subject":"Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-02T00:47:07Z","receivedAt":"2009-11-02T00:47:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Erick Mattos <erick.mattos@gmail.com> writes:\n\n>>    % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD\n>>\n>> Should you detect an error?  Does your code do so?  Do you have a test\n>> that catches this error?\n>\n> It works as intended.  Both together.\n\nThat does not make any sense.  If you are saying this is yours and it is\nhis at the same time, there can be no sane way to work \"as intended\", no?.\n\n>>> +     git commit -c HEAD <<EOF\n>>> +     \"Changed\"\n>>> +     EOF &&\n>>\n>> What editor is reading this \"Changed\"?\n>\n> Nobody cares...  Just a text to change the file.\n\nI actually care.  Who uses that Changed string, and where does it end up\nwith?  At the end of the log message?  At the beginning?  What \"file\"?\n"},{"id":"126567","messageId":"55bacdd30911011654k22eb6b13r28897bf71fc5e11b@mail.gmail.com","threadId":"21441","inReplyTo":"7vbpjlycqc.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Erick Mattos","fromEmail":"erick.mattos@gmail.com","sentAt":"2009-11-02T00:54:34Z","receivedAt":"2009-11-02T00:54:34Z","isPatch":true,"sender":{"key":"erick.mattos@gmail.com","avatar":"https://avatars.githubusercontent.com/u/134001?v=4"},"body":"2009/11/1 Junio C Hamano <gitster@pobox.com>:\n> Erick Mattos <erick.mattos@gmail.com> writes:\n>\n>>>    % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD\n>>>\n>>> Should you detect an error?  Does your code do so?  Do you have a test\n>>> that catches this error?\n>>\n>> It works as intended.  Both together.\n>\n> That does not make any sense.  If you are saying this is yours and it is\n> his at the same time, there can be no sane way to work \"as intended\", no?.\n\nI am adding a new option not changing the option --author already in\ngit.  So it does work together.\n\n>>>> +     git commit -c HEAD <<EOF\n>>>> +     \"Changed\"\n>>>> +     EOF &&\n>>>\n>>> What editor is reading this \"Changed\"?\n>>\n>> Nobody cares...  Just a text to change the file.\n>\n> I actually care.  Who uses that Changed string, and where does it end up\n> with?  At the end of the log message?  At the beginning?  What \"file\"?\n>\n\nI didn't get it.  -c option does not accept -m option and starts an\neditor to change the message.  The text \"Changed is just a forced\nmessage.  I can not use an editor in interactive mode in a script...\nWhat I am losing here??\n"},{"id":"126571","messageId":"7v1vkhy6n4.fsf@alter.siamese.dyndns.org","threadId":"21441","inReplyTo":"55bacdd30911011654k22eb6b13r28897bf71fc5e11b@mail.gmail.com","subject":"Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-02T02:58:39Z","receivedAt":"2009-11-02T02:58:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Erick Mattos <erick.mattos@gmail.com> writes:\n\n> 2009/11/1 Junio C Hamano <gitster@pobox.com>:\n>> Erick Mattos <erick.mattos@gmail.com> writes:\n>>\n>>>>    % git commit --claim --author='Erick Mattos <eric@mattos>' -C HEAD\n>>>>\n>>>> Should you detect an error?  Does your code do so?  Do you have a test\n>>>> that catches this error?\n>>>\n>>> It works as intended.  Both together.\n>>\n>> That does not make any sense.  If you are saying this is yours and it is\n>> his at the same time, there can be no sane way to work \"as intended\", no?.\n>\n> I am adding a new option not changing the option --author already in\n> git.  So it does work together.\n\nSomebody who says \"this commit is mine, and its author is this other\nperson\" is not making any sense.  The resulting commit can either have\nthat person (i.e. the committer) as the author, which is what the \"claim\"\noption means, or it can have the person named with --author as the author,\nbut both cannot be true at the same time.\n\nWhen you introduce a new option, sometimes it cannot sanely be used with\nan existing option.  In such a case, two options (the new one and the\nexisting one) are called mutually exclusive.  And you add some code to\ncatch an user error to use them together.\n\n>>>>> +     git commit -c HEAD <<EOF\n>>>>> +     \"Changed\"\n>>>>> +     EOF &&\n>>>>\n>>>> What editor is reading this \"Changed\"?\n>>>\n>>> Nobody cares...  Just a text to change the file.\n>>\n>> I actually care.  Who uses that Changed string, and where does it end up\n>> with?  At the end of the log message?  At the beginning?  What \"file\"?\n>\n> I didn't get it.  -c option does not accept -m option and starts an\n> editor to change the message.  The text \"Changed is just a forced\n> message.  I can not use an editor in interactive mode in a script...\n\nHow are the existing tests that try \"commit -c\" do this?  I do not think\nthere is any here-text redirect into \"git commit\".\n\nIt is sometimes easier to show by example than by giving nudging words\nthat only show direction, so here is a suggested rewrite on top of your\npatch.  I am not very happy with the option name \"mine\" either, but at\nleast I think this gets the semantics right.\n\n Documentation/git-commit.txt |   10 ++--\n Makefile                     |    1 +\n builtin-commit.c             |    9 ++-\n t/t7509-commit.sh            |  144 +++++++++++++++++++++++-------------------\n 4 files changed, 92 insertions(+), 72 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 01eeb3e..7832720 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n-\t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--claim]\n+\t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--mine]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n \t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n \n@@ -61,18 +61,18 @@ OPTIONS\n -C <commit>::\n --reuse-message=<commit>::\n \tTake an existing commit object, and reuse the log message\n-\tand the authorship information when creating the commit.\n+\tand the authorship information (including the timestamp)\n+\twhen creating the commit.\n \n -c <commit>::\n --reedit-message=<commit>::\n \tLike '-C', but with '-c' the editor is invoked, so that\n \tthe user can further edit the commit message.\n \n---claim::\n+--mine::\n \tWhen used with -C/-c/--amend options, declare that the\n \tauthorship of the resulting commit now belongs of the committer.\n-\tThis also renews the author timestamp.  Therefore this option\n-\tsets the use of only the message from the original commit.\n+\tThis also renews the author timestamp.\n \n -F <file>::\n --file=<file>::\ndiff --git a/Makefile b/Makefile\nindex 15ea32d..a9108b3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1944,3 +1944,4 @@ coverage-report:\n \tgrep '^function.*called 0 ' *.c.gcov \\\n \t\t| sed -e 's/\\([^:]*\\)\\.gcov: *function \\([^ ]*\\) called.*/\\1: \\2/' \\\n \t\t| tee coverage-untested-functions\n+\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 1aeafa6..aa42989 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -51,7 +51,7 @@ static const char *template_file;\n static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n-static int quiet, verbose, no_verify, allow_empty, dry_run, claim;\n+static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n static char *untracked_files_arg;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -93,7 +93,7 @@ static struct option builtin_commit_options[] = {\n \tOPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n \tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit\"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n-\tOPT_BOOLEAN(0, \"claim\", &claim, \"acquire authorship and restamp time of resulting commit\"),\n+\tOPT_BOOLEAN(0, \"mine\", &renew_authorship, \"the commit is authored by me now (used with -C-c/--amend)\"),\n \tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n \tOPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n@@ -382,7 +382,7 @@ static void determine_author_info(void)\n \temail = getenv(\"GIT_AUTHOR_EMAIL\");\n \tdate = getenv(\"GIT_AUTHOR_DATE\");\n \n-\tif (use_message && !claim) {\n+\tif (use_message && !renew_authorship) {\n \t\tconst char *a, *lb, *rb, *eol;\n \n \t\ta = strstr(use_message_buffer, \"\\nauthor \");\n@@ -748,6 +748,9 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (force_author && !strchr(force_author, '>'))\n \t\tforce_author = find_author_by_nickname(force_author);\n \n+\tif (force_author && renew_authorship)\n+\t\tdie(\"Using both --mine and --author does not make sense\");\n+\n \tif (logfile || message.len || use_message)\n \t\tuse_editor = 0;\n \tif (edit_flag)\ndiff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\nindex 6d9eb26..ec13cea 100755\n--- a/t/t7509-commit.sh\n+++ b/t/t7509-commit.sh\n@@ -3,85 +3,101 @@\n # Copyright (c) 2009 Erick Mattos\n #\n \n-test_description='git commit\n-\n-Tests for --claim option on a commit.'\n+test_description='git commit --mine'\n \n . ./test-lib.sh\n \n-TEST_FILE=\"$PWD\"/foo\n+author_header () {\n+\tgit cat-file commit \"$1\" |\n+\tsed -n -e '/^$/q' -e '/^author /p'\n+}\n+\n+message_body () {\n+\tgit cat-file commit \"$1\" |\n+\tsed -e '1,/^$/d'\n+}\n \n-test_expect_success '-C option should be working' '\n-\techo \"Initial\" > \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n+test_expect_success '-C option copies authorship and message' '\n+\techo \"Initial\" >foo &&\n+\tgit add foo &&\n+\ttest_tick &&\n \tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> &&\n-\tsleep 1 &&\n-\techo \"Test 1\" >> \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n-\tgit commit -C HEAD &&\n-\tgit cat-file -p HEAD^ | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_1 &&\n-\tgit cat-file -p HEAD | sed -e '/^parent/d' -e '/^tree/d' -e '/^committer/d' > commit_2 &&\n-\tcmp commit_1 commit_2\n+\tgit tag Initial &&\n+\techo \"Test 1\" >>foo &&\n+\ttest_tick &&\n+\tgit commit -a -C Initial &&\n+\tauthor_header Initial >expect &&\n+\tauthor_header HEAD >actual &&\n+\ttest_cmp expect actual\n '\n \n-test_expect_success '-C option with --claim is working properly' '\n-\tsleep 1 &&\n-\techo \"Test 2\" >> \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n-\tgit commit -C HEAD^ --claim &&\n-\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n-\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n-\ttest_must_fail cmp commit_1 commit_2\n+test_expect_success '-C option copies only the message with --mine' '\n+\techo \"Test 2\" >>foo &&\n+\ttest_tick &&\n+\tgit commit -a -C Initial --mine &&\n+\techo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n+\tauthor_header HEAD >actual\n+\ttest_cmp expect actual &&\n+\n+\tmessage_body Initial >expect &&\n+\tmessage_body HEAD >actual &&\n+\ttest_cmp expect actual\n '\n \n-test_expect_success '-c option should be working' '\n-\techo \"Initial\" > \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n-\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> &&\n-\tsleep 1 &&\n-\techo \"Test 3\" >> \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n-\tgit commit -c HEAD <<EOF\n-\t\"Changed\"\n-\tEOF &&\n-\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n-\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n-\tcmp commit_1 commit_2\n+test_expect_success '-c option copies authorship and message' '\n+\techo \"Test 3\" >>foo &&\n+\ttest_tick &&\n+\tEDITOR=: VISUAL=: git commit -a -c Initial &&\n+\tauthor_header Initial >expect &&\n+\tauthor_header HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '-c option copies only the message with --mine' '\n+\techo \"Test 4\" >>foo &&\n+\ttest_tick &&\n+\tEDITOR=: VISUAL=: git commit -a -c Initial --mine &&\n+\techo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n+\tauthor_header HEAD >actual &&\n+\ttest_cmp expect actual &&\n+\n+\tmessage_body Initial >expect &&\n+\tmessage_body HEAD >actual &&\n+\ttest_cmp expect actual\n '\n \n-test_expect_success '-c option with --claim is working properly' '\n-\tsleep 1 &&\n-\techo \"Test 4\" >> \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n-\tgit commit -c HEAD^ --claim <<EOF\n-\t\"Changed again\"\n-\tEOF &&\n-\tgit cat-file -p HEAD^ | grep '^author' > commit_1 &&\n-\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n-\ttest_must_fail cmp commit_1 commit_2\n+test_expect_success '--amend option copies authorship' '\n+\tgit checkout Initial &&\n+\techo \"Test 5\" >>foo &&\n+\ttest_tick &&\n+\tgit commit -a --amend -m \"amend test\" &&\n+\tauthor_header Initial >expect &&\n+\tauthor_header HEAD >actual &&\n+\n+\techo \"amend test\" >expect &&\n+\tmessage_body HEAD >actual &&\n+\ttest_cmp expect actual\n '\n \n-test_expect_success '--amend option should be working' '\n-\techo \"Initial\" > \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n-\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> &&\n-\techo \"Test 5\" >> \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n-\tgit commit -m \"--amend test\" &&\n-\tgit cat-file -p HEAD | grep '^author' > commit_1 &&\n-\tsleep 1 &&\n-\tgit commit -m \"Changed\" --amend &&\n-\tgit cat-file -p HEAD | grep '^author' > commit_2 &&\n-\tcmp commit_1 commit_2\n+test_expect_success '--mine makes the commit ours even with --amend option' '\n+\tgit checkout Initial &&\n+\techo \"Test 6\" >>foo &&\n+\ttest_tick &&\n+\tgit commit -a --mine -m \"Changed again\" --amend &&\n+\techo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n+\tauthor_header HEAD >actual &&\n+\ttest_cmp expect actual &&\n+\n+\techo \"Changed again\" >expect &&\n+\tmessage_body HEAD >actual &&\n+\ttest_cmp expect actual\n '\n \n-test_expect_success '--amend option with --claim is working properly' '\n-\tsleep 1 &&\n-\techo \"Test 6\" >> \"$TEST_FILE\" &&\n-\tgit add \"$TEST_FILE\" &&\n-\tgit commit -m \"Changed again\" --amend --claim &&\n-\tgit cat-file -p HEAD | grep '^author' > commit_1 &&\n-\ttest_must_fail cmp commit_1 commit_2\n+test_expect_success '--mine and --author are mutually exclusive' '\n+\tgit checkout Initial &&\n+\techo \"Test 7\" >>foo &&\n+\ttest_tick &&\n+\ttest_must_fail git commit -a --mine --author=\"Xyzzy <frotz@nitfol.xz>\"\n '\n \n test_done\n"},{"id":"126572","messageId":"7vskcxwro7.fsf@alter.siamese.dyndns.org","threadId":"21441","inReplyTo":"7v1vkhy6n4.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-02T03:07:20Z","receivedAt":"2009-11-02T03:07:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The last one was probably harder to read since it was an interdiff.  Here\nis what I am considering to queue.\n\nNo, I didn't use --mine option when I ran \"commit --amend\" to record this\none ;-)\n\n-- >8 --\nFrom: Erick Mattos <erick.mattos@gmail.com>\nDate: Sun, 1 Nov 2009 16:45:27 -0200\nSubject: [PATCH] git commit --mine: ignore authorship information taken from -c/-C/--amend\n\nWhen we use -c, -C, or --amend, we are trying one of two things: using the\nsource as a template or modifying a commit with corrections.\n\nWhen these options are are used, the authorship and timestamp recorded in\nthe newly created commit is always taken from the original commit.  This\nis inconvenient when you want to just borrow the commit log message, or\nyour change is so significant that you should take over the authorship\n(with the blame for bugs you introduced).\n\nSigned-off-by: Erick Mattos <erick.mattos@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-commit.txt |    7 +++-\n builtin-commit.c             |   10 +++-\n t/t7509-commit.sh            |  103 ++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 116 insertions(+), 4 deletions(-)\n create mode 100755 t/t7509-commit.sh\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 0578a40..7832720 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n-\t   [(-c | -C) <commit>] [-F <file> | -m <msg>]\n+\t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--mine]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n \t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n \n@@ -69,6 +69,11 @@ OPTIONS\n \tLike '-C', but with '-c' the editor is invoked, so that\n \tthe user can further edit the commit message.\n \n+--mine::\n+\tWhen used with -C/-c/--amend options, declare that the\n+\tauthorship of the resulting commit now belongs of the committer.\n+\tThis also renews the author timestamp.\n+\n -F <file>::\n --file=<file>::\n \tTake the commit message from the given file.  Use '-' to\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex beddf01..aa42989 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -51,7 +51,7 @@ static const char *template_file;\n static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n-static int quiet, verbose, no_verify, allow_empty, dry_run;\n+static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n static char *untracked_files_arg;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -91,8 +91,9 @@ static struct option builtin_commit_options[] = {\n \tOPT_FILENAME('F', \"file\", &logfile, \"read log from file\"),\n \tOPT_STRING(0, \"author\", &force_author, \"AUTHOR\", \"override author for commit\"),\n \tOPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n-\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit \"),\n+\tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit\"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n+\tOPT_BOOLEAN(0, \"mine\", &renew_authorship, \"the commit is authored by me now (used with -C-c/--amend)\"),\n \tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n \tOPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n@@ -381,7 +382,7 @@ static void determine_author_info(void)\n \temail = getenv(\"GIT_AUTHOR_EMAIL\");\n \tdate = getenv(\"GIT_AUTHOR_DATE\");\n \n-\tif (use_message) {\n+\tif (use_message && !renew_authorship) {\n \t\tconst char *a, *lb, *rb, *eol;\n \n \t\ta = strstr(use_message_buffer, \"\\nauthor \");\n@@ -747,6 +748,9 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (force_author && !strchr(force_author, '>'))\n \t\tforce_author = find_author_by_nickname(force_author);\n \n+\tif (force_author && renew_authorship)\n+\t\tdie(\"Using both --mine and --author does not make sense\");\n+\n \tif (logfile || message.len || use_message)\n \t\tuse_editor = 0;\n \tif (edit_flag)\ndiff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\nnew file mode 100755\nindex 0000000..ec13cea\n--- /dev/null\n+++ b/t/t7509-commit.sh\n@@ -0,0 +1,103 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 Erick Mattos\n+#\n+\n+test_description='git commit --mine'\n+\n+. ./test-lib.sh\n+\n+author_header () {\n+\tgit cat-file commit \"$1\" |\n+\tsed -n -e '/^$/q' -e '/^author /p'\n+}\n+\n+message_body () {\n+\tgit cat-file commit \"$1\" |\n+\tsed -e '1,/^$/d'\n+}\n+\n+test_expect_success '-C option copies authorship and message' '\n+\techo \"Initial\" >foo &&\n+\tgit add foo &&\n+\ttest_tick &&\n+\tgit commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> &&\n+\tgit tag Initial &&\n+\techo \"Test 1\" >>foo &&\n+\ttest_tick &&\n+\tgit commit -a -C Initial &&\n+\tauthor_header Initial >expect &&\n+\tauthor_header HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '-C option copies only the message with --mine' '\n+\techo \"Test 2\" >>foo &&\n+\ttest_tick &&\n+\tgit commit -a -C Initial --mine &&\n+\techo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n+\tauthor_header HEAD >actual\n+\ttest_cmp expect actual &&\n+\n+\tmessage_body Initial >expect &&\n+\tmessage_body HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '-c option copies authorship and message' '\n+\techo \"Test 3\" >>foo &&\n+\ttest_tick &&\n+\tEDITOR=: VISUAL=: git commit -a -c Initial &&\n+\tauthor_header Initial >expect &&\n+\tauthor_header HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '-c option copies only the message with --mine' '\n+\techo \"Test 4\" >>foo &&\n+\ttest_tick &&\n+\tEDITOR=: VISUAL=: git commit -a -c Initial --mine &&\n+\techo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n+\tauthor_header HEAD >actual &&\n+\ttest_cmp expect actual &&\n+\n+\tmessage_body Initial >expect &&\n+\tmessage_body HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '--amend option copies authorship' '\n+\tgit checkout Initial &&\n+\techo \"Test 5\" >>foo &&\n+\ttest_tick &&\n+\tgit commit -a --amend -m \"amend test\" &&\n+\tauthor_header Initial >expect &&\n+\tauthor_header HEAD >actual &&\n+\n+\techo \"amend test\" >expect &&\n+\tmessage_body HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '--mine makes the commit ours even with --amend option' '\n+\tgit checkout Initial &&\n+\techo \"Test 6\" >>foo &&\n+\ttest_tick &&\n+\tgit commit -a --mine -m \"Changed again\" --amend &&\n+\techo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n+\tauthor_header HEAD >actual &&\n+\ttest_cmp expect actual &&\n+\n+\techo \"Changed again\" >expect &&\n+\tmessage_body HEAD >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success '--mine and --author are mutually exclusive' '\n+\tgit checkout Initial &&\n+\techo \"Test 7\" >>foo &&\n+\ttest_tick &&\n+\ttest_must_fail git commit -a --mine --author=\"Xyzzy <frotz@nitfol.xz>\"\n+'\n+\n+test_done\n-- \n1.6.5.2.246.gc99575\n"},{"id":"126657","messageId":"55bacdd30911030839v724924bm7a49a08172ed7573@mail.gmail.com","threadId":"21441","inReplyTo":"7vskcxwro7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] commit -c/-C/--amend: acquire authorship and restamp time with --claim","fromName":"Erick Mattos","fromEmail":"erick.mattos@gmail.com","sentAt":"2009-11-03T16:39:05Z","receivedAt":"2009-11-03T16:39:05Z","isPatch":true,"sender":{"key":"erick.mattos@gmail.com","avatar":"https://avatars.githubusercontent.com/u/134001?v=4"},"body":"I am gonna check all this information but you probably missed the last\npatch I sent: http://marc.info/?l=git&m=125712272606721&w=2\nCould you please check this one... while I am checking this e-mail.\n\nRegards\n\n2009/11/2 Junio C Hamano <gitster@pobox.com>:\n> The last one was probably harder to read since it was an interdiff.  Here\n> is what I am considering to queue.\n>\n> No, I didn't use --mine option when I ran \"commit --amend\" to record this\n> one ;-)\n>\n> -- >8 --\n> From: Erick Mattos <erick.mattos@gmail.com>\n> Date: Sun, 1 Nov 2009 16:45:27 -0200\n> Subject: [PATCH] git commit --mine: ignore authorship information taken from -c/-C/--amend\n>\n> When we use -c, -C, or --amend, we are trying one of two things: using the\n> source as a template or modifying a commit with corrections.\n>\n> When these options are are used, the authorship and timestamp recorded in\n> the newly created commit is always taken from the original commit.  This\n> is inconvenient when you want to just borrow the commit log message, or\n> your change is so significant that you should take over the authorship\n> (with the blame for bugs you introduced).\n>\n> Signed-off-by: Erick Mattos <erick.mattos@gmail.com>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  Documentation/git-commit.txt |    7 +++-\n>  builtin-commit.c             |   10 +++-\n>  t/t7509-commit.sh            |  103 ++++++++++++++++++++++++++++++++++++++++++\n>  3 files changed, 116 insertions(+), 4 deletions(-)\n>  create mode 100755 t/t7509-commit.sh\n>\n> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\n> index 0578a40..7832720 100644\n> --- a/Documentation/git-commit.txt\n> +++ b/Documentation/git-commit.txt\n> @@ -9,7 +9,7 @@ SYNOPSIS\n>  --------\n>  [verse]\n>  'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n> -          [(-c | -C) <commit>] [-F <file> | -m <msg>]\n> +          [(-c | -C) <commit>] [-F <file> | -m <msg>] [--mine]\n>           [--allow-empty] [--no-verify] [-e] [--author=<author>]\n>           [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n>\n> @@ -69,6 +69,11 @@ OPTIONS\n>        Like '-C', but with '-c' the editor is invoked, so that\n>        the user can further edit the commit message.\n>\n> +--mine::\n> +       When used with -C/-c/--amend options, declare that the\n> +       authorship of the resulting commit now belongs of the committer.\n> +       This also renews the author timestamp.\n> +\n>  -F <file>::\n>  --file=<file>::\n>        Take the commit message from the given file.  Use '-' to\n> diff --git a/builtin-commit.c b/builtin-commit.c\n> index beddf01..aa42989 100644\n> --- a/builtin-commit.c\n> +++ b/builtin-commit.c\n> @@ -51,7 +51,7 @@ static const char *template_file;\n>  static char *edit_message, *use_message;\n>  static char *author_name, *author_email, *author_date;\n>  static int all, edit_flag, also, interactive, only, amend, signoff;\n> -static int quiet, verbose, no_verify, allow_empty, dry_run;\n> +static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n>  static char *untracked_files_arg;\n>  /*\n>  * The default commit message cleanup mode will remove the lines\n> @@ -91,8 +91,9 @@ static struct option builtin_commit_options[] = {\n>        OPT_FILENAME('F', \"file\", &logfile, \"read log from file\"),\n>        OPT_STRING(0, \"author\", &force_author, \"AUTHOR\", \"override author for commit\"),\n>        OPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n> -       OPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit \"),\n> +       OPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit\"),\n>        OPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n> +       OPT_BOOLEAN(0, \"mine\", &renew_authorship, \"the commit is authored by me now (used with -C-c/--amend)\"),\n>        OPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n>        OPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n>        OPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n> @@ -381,7 +382,7 @@ static void determine_author_info(void)\n>        email = getenv(\"GIT_AUTHOR_EMAIL\");\n>        date = getenv(\"GIT_AUTHOR_DATE\");\n>\n> -       if (use_message) {\n> +       if (use_message && !renew_authorship) {\n>                const char *a, *lb, *rb, *eol;\n>\n>                a = strstr(use_message_buffer, \"\\nauthor \");\n> @@ -747,6 +748,9 @@ static int parse_and_validate_options(int argc, const char *argv[],\n>        if (force_author && !strchr(force_author, '>'))\n>                force_author = find_author_by_nickname(force_author);\n>\n> +       if (force_author && renew_authorship)\n> +               die(\"Using both --mine and --author does not make sense\");\n> +\n>        if (logfile || message.len || use_message)\n>                use_editor = 0;\n>        if (edit_flag)\n> diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\n> new file mode 100755\n> index 0000000..ec13cea\n> --- /dev/null\n> +++ b/t/t7509-commit.sh\n> @@ -0,0 +1,103 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2009 Erick Mattos\n> +#\n> +\n> +test_description='git commit --mine'\n> +\n> +. ./test-lib.sh\n> +\n> +author_header () {\n> +       git cat-file commit \"$1\" |\n> +       sed -n -e '/^$/q' -e '/^author /p'\n> +}\n> +\n> +message_body () {\n> +       git cat-file commit \"$1\" |\n> +       sed -e '1,/^$/d'\n> +}\n> +\n> +test_expect_success '-C option copies authorship and message' '\n> +       echo \"Initial\" >foo &&\n> +       git add foo &&\n> +       test_tick &&\n> +       git commit -m \"Initial Commit\" --author Frigate\\ \\<flying@over.world\\> &&\n> +       git tag Initial &&\n> +       echo \"Test 1\" >>foo &&\n> +       test_tick &&\n> +       git commit -a -C Initial &&\n> +       author_header Initial >expect &&\n> +       author_header HEAD >actual &&\n> +       test_cmp expect actual\n> +'\n> +\n> +test_expect_success '-C option copies only the message with --mine' '\n> +       echo \"Test 2\" >>foo &&\n> +       test_tick &&\n> +       git commit -a -C Initial --mine &&\n> +       echo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n> +       author_header HEAD >actual\n> +       test_cmp expect actual &&\n> +\n> +       message_body Initial >expect &&\n> +       message_body HEAD >actual &&\n> +       test_cmp expect actual\n> +'\n> +\n> +test_expect_success '-c option copies authorship and message' '\n> +       echo \"Test 3\" >>foo &&\n> +       test_tick &&\n> +       EDITOR=: VISUAL=: git commit -a -c Initial &&\n> +       author_header Initial >expect &&\n> +       author_header HEAD >actual &&\n> +       test_cmp expect actual\n> +'\n> +\n> +test_expect_success '-c option copies only the message with --mine' '\n> +       echo \"Test 4\" >>foo &&\n> +       test_tick &&\n> +       EDITOR=: VISUAL=: git commit -a -c Initial --mine &&\n> +       echo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n> +       author_header HEAD >actual &&\n> +       test_cmp expect actual &&\n> +\n> +       message_body Initial >expect &&\n> +       message_body HEAD >actual &&\n> +       test_cmp expect actual\n> +'\n> +\n> +test_expect_success '--amend option copies authorship' '\n> +       git checkout Initial &&\n> +       echo \"Test 5\" >>foo &&\n> +       test_tick &&\n> +       git commit -a --amend -m \"amend test\" &&\n> +       author_header Initial >expect &&\n> +       author_header HEAD >actual &&\n> +\n> +       echo \"amend test\" >expect &&\n> +       message_body HEAD >actual &&\n> +       test_cmp expect actual\n> +'\n> +\n> +test_expect_success '--mine makes the commit ours even with --amend option' '\n> +       git checkout Initial &&\n> +       echo \"Test 6\" >>foo &&\n> +       test_tick &&\n> +       git commit -a --mine -m \"Changed again\" --amend &&\n> +       echo \"author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE\" >expect &&\n> +       author_header HEAD >actual &&\n> +       test_cmp expect actual &&\n> +\n> +       echo \"Changed again\" >expect &&\n> +       message_body HEAD >actual &&\n> +       test_cmp expect actual\n> +'\n> +\n> +test_expect_success '--mine and --author are mutually exclusive' '\n> +       git checkout Initial &&\n> +       echo \"Test 7\" >>foo &&\n> +       test_tick &&\n> +       test_must_fail git commit -a --mine --author=\"Xyzzy <frotz@nitfol.xz>\"\n> +'\n> +\n> +test_done\n> --\n> 1.6.5.2.246.gc99575\n>\n>\n"}]}