{"thread":{"id":"25211","subject":"[PATCHv4 4/4] t7500: add tests of commit --squash","startedAt":"2010-09-23T17:14:32Z","lastAt":"2010-09-23T20:39:31Z","messageCount":9,"participants":["Pat Notz","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"151373","messageId":"1285262076-20134-1-git-send-email-patnotz@gmail.com","threadId":"25211","inReplyTo":null,"subject":"[PATCHv4 0/4] Add commit message options for rebase --autosquash","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2010-09-23T17:14:32Z","receivedAt":"2010-09-23T17:14:32Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"This patch series adds new command line options to git-commit to make\nit easy to specify messages for commits correctly formatted for use\nwit 'rebase -i --autosquash'.\n\nThe 2nd iteration addressed concerns raised earlier:\nhttp://thread.gmane.org/gmane.comp.version-control.git/156369 .  Most\nnotably, --squash=COMMIT now works with -m/-c/-C/-F and uses the\neditor when appropriate.\n\nThe 3rd iteration added documentation links from --squash and --fixup\nto git-rebase(1) and updated the tests to conform to established style\n(editor script moved into t7500/ directory).\n\nThis 4th iteration adds missing '&&' to a couple of lines in the tests. \n\nPat Notz (4):\n  commit: --fixup option for use with rebase --autosquash\n  t7500: add tests of commit --fixup\n  commit: --squash option for use with rebase --autosquash\n  t7500: add tests of commit --squash\n\n Documentation/git-commit.txt |   21 +++++++++--\n builtin/commit.c             |   58 +++++++++++++++++++++++++++---\n t/t7500-commit.sh            |   80 ++++++++++++++++++++++++++++++++++++++++++\n t/t7500/edit-content         |    4 ++\n 4 files changed, 154 insertions(+), 9 deletions(-)\n create mode 100755 t/t7500/edit-content\n\n-- \n1.7.3\n"},{"id":"151372","messageId":"1285262076-20134-2-git-send-email-patnotz@gmail.com","threadId":"25211","inReplyTo":"1285262076-20134-1-git-send-email-patnotz@gmail.com","subject":"[PATCHv4 1/4] commit: --fixup option for use with rebase --autosquash","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2010-09-23T17:14:33Z","receivedAt":"2010-09-23T17:14:33Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"This option makes it convenient to construct commit messages for use\nwith 'rebase --autosquash'.  The resulting commit message will be\n\"fixup! ...\" where \"...\" is the subject line of the specified commit\nmessage.\n\nExample usage:\n  $ git commit --fixup HEAD~2\n\nSigned-off-by: Pat Notz <patnotz@gmail.com>\n---\n Documentation/git-commit.txt |   14 ++++++++++----\n builtin/commit.c             |   23 +++++++++++++++++++----\n 2 files changed, 29 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 42fb1f5..f4a2b8c 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -9,10 +9,10 @@ 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>] [--reset-author]\n-\t   [--allow-empty] [--allow-empty-message] [--no-verify] [-e] [--author=<author>]\n-\t   [--date=<date>] [--cleanup=<mode>] [--status | --no-status] [--]\n-\t   [[-i | -o ]<file>...]\n+\t   [(-c | -C | --fixup) <commit>] [-F <file> | -m <msg>]\n+\t   [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify]\n+\t   [-e] [--author=<author>] [--date=<date>] [--cleanup=<mode>]\n+\t   [--status | --no-status] [--] [[-i | -o ]<file>...]\n \n DESCRIPTION\n -----------\n@@ -70,6 +70,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+--fixup=<commit>::\n+\tConstruct a commit message for use with `rebase --autosquash`.\n+\tThe commit message will be the subject line from the specified\n+\tcommit with a prefix of \"fixup! \".  See linkgit:git-rebase[1]\n+\tfor details.\n+\n --reset-author::\n \tWhen used with -C/-c/--amend options, declare that the\n \tauthorship of the resulting commit now belongs of the committer.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 66fdd22..0901616 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -69,6 +69,7 @@ static enum {\n static const char *logfile, *force_author;\n static const char *template_file;\n static char *edit_message, *use_message;\n+static char *fixup_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, renew_authorship;\n@@ -124,6 +125,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_STRING(0, \"fixup\", &fixup_message, \"COMMIT\", \"use autosquash formatted message to fixup specified commit\"),\n \tOPT_BOOLEAN(0, \"reset-author\", &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@@ -586,6 +588,17 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\tstrbuf_add(&sb, buffer + 2, strlen(buffer + 2));\n \t\thook_arg1 = \"commit\";\n \t\thook_arg2 = use_message;\n+\t} else if (fixup_message) {\n+\t\tunsigned char sha1[20];\n+\t\tstruct commit *commit;\n+\t\tstruct pretty_print_context ctx = {0};\n+\t\tif (get_sha1(fixup_message, sha1))\n+\t\t\tdie(\"could not lookup commit %s\", fixup_message);\n+\t\tcommit = lookup_commit_reference(sha1);\n+\t\tif (!commit || parse_commit(commit))\n+\t\t\tdie(\"could not parse commit %s\", fixup_message);\n+\t\tformat_commit_message(commit, \"fixup! %s\\n\\n\", &sb, &ctx);\n+\t\thook_arg1 = \"message\";\n \t} else if (!stat(git_path(\"MERGE_MSG\"), &statbuf)) {\n \t\tif (strbuf_read_file(&sb, git_path(\"MERGE_MSG\"), 0) < 0)\n \t\t\tdie_errno(\"could not read MERGE_MSG\");\n@@ -863,7 +876,7 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (force_author && renew_authorship)\n \t\tdie(\"Using both --reset-author and --author does not make sense\");\n \n-\tif (logfile || message.len || use_message)\n+\tif (logfile || message.len || use_message || fixup_message)\n \t\tuse_editor = 0;\n \tif (edit_flag)\n \t\tuse_editor = 1;\n@@ -883,15 +896,17 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \t\tf++;\n \tif (edit_message)\n \t\tf++;\n+\tif (fixup_message)\n+\t\tf++;\n \tif (logfile)\n \t\tf++;\n \tif (f > 1)\n-\t\tdie(\"Only one of -c/-C/-F can be used.\");\n+\t\tdie(\"Only one of -c/-C/-F/--fixup can be used.\");\n \tif (message.len && f > 0)\n-\t\tdie(\"Option -m cannot be combined with -c/-C/-F.\");\n+\t\tdie(\"Option -m cannot be combined with -c/-C/-F/--fixup.\");\n \tif (edit_message)\n \t\tuse_message = edit_message;\n-\tif (amend && !use_message)\n+\tif (amend && !use_message && !fixup_message)\n \t\tuse_message = \"HEAD\";\n \tif (!use_message && renew_authorship)\n \t\tdie(\"--reset-author can be used only with -C, -c or --amend.\");\n-- \n1.7.3\n"},{"id":"151371","messageId":"1285262076-20134-3-git-send-email-patnotz@gmail.com","threadId":"25211","inReplyTo":"1285262076-20134-1-git-send-email-patnotz@gmail.com","subject":"[PATCHv4 2/4] t7500: add tests of commit --fixup","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2010-09-23T17:14:34Z","receivedAt":"2010-09-23T17:14:34Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"Signed-off-by: Pat Notz <patnotz@gmail.com>\n---\n t/t7500-commit.sh |   33 +++++++++++++++++++++++++++++++++\n 1 files changed, 33 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\nindex aa9c577..db82264 100755\n--- a/t/t7500-commit.sh\n+++ b/t/t7500-commit.sh\n@@ -215,4 +215,37 @@ test_expect_success 'Commit a message with --allow-empty-message' '\n \tcommit_msg_is \"hello there\"\n '\n \n+commit_for_rebase_autosquash_setup() {\n+\techo \"first content for testing commit messages for rebase --autosquash\" >>foo &&\n+\tgit add foo &&\n+\tcat >log <<EOF &&\n+target message subject line\n+\n+target message body line 1\n+target message body line 2\n+EOF\n+\tgit commit -F log &&\n+\techo \"second content for testing commit messages for rebase --autosquash\" >>foo &&\n+\tgit add foo &&\n+\tgit commit -m \"intermediate commit\" &&\n+\techo \"third content for testing commit messages for rebase --autosquash\" >>foo &&\n+\tgit add foo\n+}\n+\n+test_expect_success 'commit --fixup provides correct one-line commit message' '\n+\tcommit_for_rebase_autosquash_setup &&\n+\tgit commit --fixup HEAD~1 &&\n+\tcommit_msg_is \"fixup! target message subject line\"\n+'\n+\n+test_expect_success 'invalid message options when using --fixup' '\n+\techo changes >>foo &&\n+\techo \"message\" >log &&\n+\tgit add foo &&\n+\ttest_must_fail git commit --fixup HEAD~1 --C HEAD~2 &&\n+\ttest_must_fail git commit --fixup HEAD~1 --c HEAD~2 &&\n+\ttest_must_fail git commit --fixup HEAD~1 -m \"cmdline message\" &&\n+\ttest_must_fail git commit --fixup HEAD~1 -F log\n+'\n+\n test_done\n-- \n1.7.3\n"},{"id":"151374","messageId":"1285262076-20134-4-git-send-email-patnotz@gmail.com","threadId":"25211","inReplyTo":"1285262076-20134-1-git-send-email-patnotz@gmail.com","subject":"[PATCHv4 3/4] commit: --squash option for use with rebase --autosquash","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2010-09-23T17:14:35Z","receivedAt":"2010-09-23T17:14:35Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"This option makes it convenient to construct commit messages for use\nwith 'rebase --autosquash'.  The resulting commit message will be\n\"squash! ...\" where \"...\" is the subject line of the specified commit\nmessage.  This option can be used with other commit message options\nsuch as -m, -c, -C and -F.\n\nIf an editor is invoked (as with -c or -eF or no message options) the\ncommit message is seeded with the correctly formatted subject line.\n\nExample usage:\n  $ git commit --squash HEAD~2\n  $ git commit --squash HEAD~2 -m \"clever comment\"\n  $ git commit --squash HEAD~2 -F msgfile\n  $ git commit --squash HEAD~2 -C deadbeef\n\nSigned-off-by: Pat Notz <patnotz@gmail.com>\n---\n Documentation/git-commit.txt |    9 ++++++++-\n builtin/commit.c             |   37 +++++++++++++++++++++++++++++++++++--\n 2 files changed, 43 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex f4a2b8c..6e4c220 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 | --fixup) <commit>] [-F <file> | -m <msg>]\n+\t   [(-c | -C | --fixup | --squash) <commit>] [-F <file> | -m <msg>]\n \t   [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify]\n \t   [-e] [--author=<author>] [--date=<date>] [--cleanup=<mode>]\n \t   [--status | --no-status] [--] [[-i | -o ]<file>...]\n@@ -76,6 +76,13 @@ OPTIONS\n \tcommit with a prefix of \"fixup! \".  See linkgit:git-rebase[1]\n \tfor details.\n \n+--squash=<commit>::\n+\tConstruct a commit message for use with `rebase --autosquash`.\n+\tThe commit message subject line is taken from the specified\n+\tcommit with a prefix of \"squash! \".  Can be used with additional\n+\tcommit message options (`-m`/`-c`/`-C`/`-F`). See\n+\tlinkgit:git-rebase[1] for details.\n+\n --reset-author::\n \tWhen used with -C/-c/--amend options, declare that the\n \tauthorship of the resulting commit now belongs of the committer.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 0901616..d28b2ff 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -69,7 +69,7 @@ static enum {\n static const char *logfile, *force_author;\n static const char *template_file;\n static char *edit_message, *use_message;\n-static char *fixup_message;\n+static char *fixup_message, *squash_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, renew_authorship;\n@@ -126,6 +126,7 @@ static struct option builtin_commit_options[] = {\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_STRING(0, \"fixup\", &fixup_message, \"COMMIT\", \"use autosquash formatted message to fixup specified commit\"),\n+\tOPT_STRING(0, \"squash\", &squash_message, \"COMMIT\", \"use autosquash formatted message to squash specified commit\"),\n \tOPT_BOOLEAN(0, \"reset-author\", &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@@ -567,6 +568,27 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \tif (!no_verify && run_hook(index_file, \"pre-commit\", NULL))\n \t\treturn 0;\n \n+\tif (squash_message) {\n+\t\t/*\n+\t\t * Insert the proper subject line before other commit\n+\t\t * message options add their content.\n+\t\t */\n+\t\tunsigned char sha1[20];\n+\t\tstruct commit *commit;\n+\t\tstruct pretty_print_context ctx = {0};\n+\n+\t\tif (get_sha1(squash_message, sha1))\n+\t\t\tdie(\"could not lookup commit %s\", squash_message);\n+\t\tcommit = lookup_commit_reference(sha1);\n+\t\tif (!commit || parse_commit(commit))\n+\t\t\tdie(\"could not parse commit %s\", squash_message);\n+\n+\t\tif(use_message && strcmp(use_message, squash_message) == 0)\n+\t\t\tstrbuf_addstr(&sb,\"squash! \");\n+\t\telse\n+\t\t\tformat_commit_message(commit, \"squash! %s\\n\\n\", &sb, &ctx);\n+\t}\n+\n \tif (message.len) {\n \t\tstrbuf_addbuf(&sb, &message);\n \t\thook_arg1 = \"message\";\n@@ -620,6 +642,16 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \telse if (in_merge)\n \t\thook_arg1 = \"merge\";\n \n+\tif (squash_message) {\n+\t\t/*\n+\t\t * If squash_commit was used for the commit subject,\n+\t\t * then we're possibly hijacking other commit log options.\n+\t\t * Reset the hook args to tell the real story.\n+\t\t */\n+\t\thook_arg1 = \"message\";\n+\t\thook_arg2 = \"\";\n+\t}\n+\n \tfp = fopen(git_path(commit_editmsg), \"w\");\n \tif (fp == NULL)\n \t\tdie_errno(\"could not open '%s'\", git_path(commit_editmsg));\n@@ -891,7 +923,8 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \t\tdie(\"You have nothing to amend.\");\n \tif (amend && in_merge)\n \t\tdie(\"You are in the middle of a merge -- cannot amend.\");\n-\n+\tif (fixup_message && squash_message)\n+\t\tdie(\"Options --squash and --fixup cannot be used together\");\n \tif (use_message)\n \t\tf++;\n \tif (edit_message)\n-- \n1.7.3\n"},{"id":"151370","messageId":"1285262076-20134-5-git-send-email-patnotz@gmail.com","threadId":"25211","inReplyTo":"1285262076-20134-1-git-send-email-patnotz@gmail.com","subject":"[PATCHv4 4/4] t7500: add tests of commit --squash","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2010-09-23T17:14:36Z","receivedAt":"2010-09-23T17:14:36Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"Signed-off-by: Pat Notz <patnotz@gmail.com>\n---\n t/t7500-commit.sh    |   47 +++++++++++++++++++++++++++++++++++++++++++++++\n t/t7500/edit-content |    4 ++++\n 2 files changed, 51 insertions(+), 0 deletions(-)\n create mode 100755 t/t7500/edit-content\n\ndiff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\nindex db82264..2fd72be 100755\n--- a/t/t7500-commit.sh\n+++ b/t/t7500-commit.sh\n@@ -238,10 +238,57 @@ test_expect_success 'commit --fixup provides correct one-line commit message' '\n \tcommit_msg_is \"fixup! target message subject line\"\n '\n \n+test_expect_success 'commit --squash works with -F' '\n+\tcommit_for_rebase_autosquash_setup &&\n+\techo \"log message from file\" >msgfile &&\n+\tgit commit --squash HEAD~1 -F msgfile  &&\n+\tcommit_msg_is \"squash! target message subject linelog message from file\"\n+'\n+\n+test_expect_success 'commit --squash works with -m' '\n+\tcommit_for_rebase_autosquash_setup &&\n+\tgit commit --squash HEAD~1 -m \"foo bar\\nbaz\" &&\n+\tcommit_msg_is \"squash! target message subject linefoo bar\\nbaz\"\n+'\n+\n+test_expect_success 'commit --squash works with -C' '\n+\tcommit_for_rebase_autosquash_setup &&\n+\tgit commit --squash HEAD~1 -C HEAD &&\n+\tcommit_msg_is \"squash! target message subject lineintermediate commit\"\n+'\n+\n+test_expect_success 'commit --squash works with -c' '\n+\tcommit_for_rebase_autosquash_setup &&\n+\ttest_set_editor \"$TEST_DIRECTORY\"/t7500/edit-content &&\n+\tgit commit --squash HEAD~1 -c HEAD &&\n+\tcommit_msg_is \"squash! target message subject lineedited commit\"\n+'\n+\n+test_expect_success 'commit --squash works with -C for same commit' '\n+\tcommit_for_rebase_autosquash_setup &&\n+\tgit commit --squash HEAD -C HEAD &&\n+\tcommit_msg_is \"squash! intermediate commit\"\n+'\n+\n+test_expect_success 'commit --squash works with -c for same commit' '\n+\tcommit_for_rebase_autosquash_setup &&\n+\ttest_set_editor \"$TEST_DIRECTORY\"/t7500/edit-content &&\n+\tgit commit --squash HEAD -c HEAD &&\n+\tcommit_msg_is \"squash! edited commit\"\n+'\n+\n+test_expect_success 'commit --squash works with editor' '\n+\tcommit_for_rebase_autosquash_setup &&\n+\ttest_set_editor \"$TEST_DIRECTORY\"/t7500/add-content &&\n+\tgit commit --squash HEAD~1 &&\n+\tcommit_msg_is \"squash! target message subject linecommit message\"\n+'\n+\n test_expect_success 'invalid message options when using --fixup' '\n \techo changes >>foo &&\n \techo \"message\" >log &&\n \tgit add foo &&\n+\ttest_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&\n \ttest_must_fail git commit --fixup HEAD~1 --C HEAD~2 &&\n \ttest_must_fail git commit --fixup HEAD~1 --c HEAD~2 &&\n \ttest_must_fail git commit --fixup HEAD~1 -m \"cmdline message\" &&\ndiff --git a/t/t7500/edit-content b/t/t7500/edit-content\nnew file mode 100755\nindex 0000000..08db9fd\n--- /dev/null\n+++ b/t/t7500/edit-content\n@@ -0,0 +1,4 @@\n+#!/bin/sh\n+sed -e \"s/intermediate/edited/g\" <\"$1\" >\"$1-\"\n+mv \"$1-\" \"$1\"\n+exit 0\n-- \n1.7.3\n"},{"id":"151378","messageId":"7vzkv8qru6.fsf@alter.siamese.dyndns.org","threadId":"25211","inReplyTo":"1285262076-20134-3-git-send-email-patnotz@gmail.com","subject":"Re: [PATCHv4 2/4] t7500: add tests of commit --fixup","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-23T17:42:41Z","receivedAt":"2010-09-23T17:42:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Pat Notz\" <patnotz@gmail.com> writes:\n\n> Signed-off-by: Pat Notz <patnotz@gmail.com>\n> ---\n>  t/t7500-commit.sh |   33 +++++++++++++++++++++++++++++++++\n>  1 files changed, 33 insertions(+), 0 deletions(-)\n>\n> diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\n> index aa9c577..db82264 100755\n> --- a/t/t7500-commit.sh\n> +++ b/t/t7500-commit.sh\n> @@ -215,4 +215,37 @@ test_expect_success 'Commit a message with --allow-empty-message' '\n>  \tcommit_msg_is \"hello there\"\n>  '\n>  \n> +commit_for_rebase_autosquash_setup() {\n\nA SP after \"_setup\", i.e. \"..._setup () {\".\n\n> +\techo \"first content for testing commit messages for rebase --autosquash\" >>foo &&\n\nDid you really need this long line here?\n\n> +\tgit add foo &&\n> +\tcat >log <<EOF &&\n> +target message subject line\n> +\n> +target message body line 1\n> +target message body line 2\n> +EOF\n> +\tgit commit -F log &&\n> +\techo \"second content for testing commit messages for rebase --autosquash\" >>foo &&\n> +\tgit add foo &&\n> +\tgit commit -m \"intermediate commit\" &&\n> +\techo \"third content for testing commit messages for rebase --autosquash\" >>foo &&\n> +\tgit add foo\n> +}\n> +\n> +test_expect_success 'commit --fixup provides correct one-line commit message' '\n> +\tcommit_for_rebase_autosquash_setup &&\n> +\tgit commit --fixup HEAD~1 &&\n> +\tcommit_msg_is \"fixup! target message subject line\"\n> +'\n\nWhat should be the right output when \"target message subject line\" has\nsome metacharacters, i.e. \".\" (regexp) or \"?\" (glob)?\n\nDon't we also want to make sure that \"rebase --autosquash\" correctly groks\nthe history you prepared in this test?\n\n> +test_expect_success 'invalid message options when using --fixup' '\n> +\techo changes >>foo &&\n> +\techo \"message\" >log &&\n> +\tgit add foo &&\n> +\ttest_must_fail git commit --fixup HEAD~1 --C HEAD~2 &&\n> +\ttest_must_fail git commit --fixup HEAD~1 --c HEAD~2 &&\n\nDouble dashes before \"C\" and \"c\" look fishy.  Don't.\n\n> +\ttest_must_fail git commit --fixup HEAD~1 -m \"cmdline message\" &&\n> +\ttest_must_fail git commit --fixup HEAD~1 -F log\n> +'\n> +\n>  test_done\n> -- \n> 1.7.3\n"},{"id":"151381","messageId":"7vsk10qr7p.fsf@alter.siamese.dyndns.org","threadId":"25211","inReplyTo":"1285262076-20134-2-git-send-email-patnotz@gmail.com","subject":"Re: [PATCHv4 1/4] commit: --fixup option for use with rebase --autosquash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-23T17:56:10Z","receivedAt":"2010-09-23T17:56:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Pat Notz\" <patnotz@gmail.com> writes:\n\n> +\t} else if (fixup_message) {\n> +\t\tunsigned char sha1[20];\n> +\t\tstruct commit *commit;\n> +\t\tstruct pretty_print_context ctx = {0};\n> +\t\tif (get_sha1(fixup_message, sha1))\n> +\t\t\tdie(\"could not lookup commit %s\", fixup_message);\n> +\t\tcommit = lookup_commit_reference(sha1);\n> +\t\tif (!commit || parse_commit(commit))\n> +\t\t\tdie(\"could not parse commit %s\", fixup_message);\n> +\t\tformat_commit_message(commit, \"fixup! %s\\n\\n\", &sb, &ctx);\n> +\t\thook_arg1 = \"message\";\n\n\nI notice that the above is a half-copy-and-paste from \"if (use_message)\"\ncodepath that handles -c/-C.  A few issues to think about (i.e. not\ncomplaints; I haven't thought about them myself):\n\n (1) Is it worth refactoring the original instead of copying;\n\n (2) What happens/should happen when the original commit is encoded\n     differently from the current commit encoding?  -c/-C codepath takes\n     pains to re-encode.  Should we do so somewhere in this codepath, too?\n\n (3) If the answer to (2) is \"Yes\", notice that format_commit_message()\n     does not re-encode the commit log message (\"log\" output codepath uses\n     pretty.c::pretty_print_commit(), which reencodes for log output\n     encoding).  Maybe we need an option to tell format_commit_message()\n     to do so?\n\nThe last is not exactly an issue this patch alone should address, but I\nthought I'd better mention it anyway.\n\nMy knee-jerk answers to the above are:\n\n (1) The first handful of lines in this new \"if (fixup_message)\" codeblock\n     up to \"die\" might want to use a helper function shared with the\n     existing \"if (use_message)\" codepath;\n\n (2) We probably want to re-encode to the log output encoding the string\n     we receive from format_commit_message() in this codepath.\n\n (3) No need yet.\n"},{"id":"151384","messageId":"AANLkTikUonhDU-_mq+ON2nRvHEnJszR5jW7siyeXDFLn@mail.gmail.com","threadId":"25211","inReplyTo":"7vsk10qr7p.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv4 1/4] commit: --fixup option for use with rebase --autosquash","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2010-09-23T18:27:46Z","receivedAt":"2010-09-23T18:27:46Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"On Thu, Sep 23, 2010 at 11:56 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Pat Notz\" <patnotz@gmail.com> writes:\n>\n>> +     } else if (fixup_message) {\n>> +             unsigned char sha1[20];\n>> +             struct commit *commit;\n>> +             struct pretty_print_context ctx = {0};\n>> +             if (get_sha1(fixup_message, sha1))\n>> +                     die(\"could not lookup commit %s\", fixup_message);\n>> +             commit = lookup_commit_reference(sha1);\n>> +             if (!commit || parse_commit(commit))\n>> +                     die(\"could not parse commit %s\", fixup_message);\n>> +             format_commit_message(commit, \"fixup! %s\\n\\n\", &sb, &ctx);\n>> +             hook_arg1 = \"message\";\n>\n>\n> I notice that the above is a half-copy-and-paste from \"if (use_message)\"\n> codepath that handles -c/-C.  A few issues to think about (i.e. not\n> complaints; I haven't thought about them myself):\n>\n>  (1) Is it worth refactoring the original instead of copying;\n>\n>  (2) What happens/should happen when the original commit is encoded\n>     differently from the current commit encoding?  -c/-C codepath takes\n>     pains to re-encode.  Should we do so somewhere in this codepath, too?\n>\n\nYes, this was the concern I expressed in the v1 series patch.  I'm\ngetting more comfortable with the code so I'll look into re-encoding\nappropriately.\n\n>  (3) If the answer to (2) is \"Yes\", notice that format_commit_message()\n>     does not re-encode the commit log message (\"log\" output codepath uses\n>     pretty.c::pretty_print_commit(), which reencodes for log output\n>     encoding).  Maybe we need an option to tell format_commit_message()\n>     to do so?\n>\n> The last is not exactly an issue this patch alone should address, but I\n> thought I'd better mention it anyway.\n>\n> My knee-jerk answers to the above are:\n>\n>  (1) The first handful of lines in this new \"if (fixup_message)\" codeblock\n>     up to \"die\" might want to use a helper function shared with the\n>     existing \"if (use_message)\" codepath;\n\nAgreed.  I'll factor out the duplication.\n\n>\n>  (2) We probably want to re-encode to the log output encoding the string\n>     we receive from format_commit_message() in this codepath.\n\nWill do.\n\n>\n>  (3) No need yet.\n>\n"},{"id":"151396","messageId":"7vocboqjng.fsf@alter.siamese.dyndns.org","threadId":"25211","inReplyTo":"1285262076-20134-4-git-send-email-patnotz@gmail.com","subject":"Re: [PATCHv4 3/4] commit: --squash option for use with rebase --autosquash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-23T20:39:31Z","receivedAt":"2010-09-23T20:39:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Pat Notz\" <patnotz@gmail.com> writes:\n\n> +\t\tif(use_message && strcmp(use_message, squash_message) == 0)\n\n\t\"if (use_message && !strcmp(..., ...))\"\n\nOtherwise this patch looks sane to me.\n"}]}