{"thread":{"id":"39770","subject":"[PATCH 00/12] Improve git-am test coverage","startedAt":"2015-07-02T18:16:28Z","lastAt":"2015-07-14T09:43:06Z","messageCount":26,"participants":["Paul Tan","Paolo Bonzini","Stefan Beller","Johannes Schindelin","Junio C Hamano","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":12},"messages":[{"id":"265421","messageId":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":null,"subject":"[PATCH 00/12] Improve git-am test coverage","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:28Z","receivedAt":"2015-07-02T18:16:28Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Increase test coverage of git-am.sh to help prevent regressions that could arise\nfrom the rewrite of git-am.sh to C. This patch series, along with\npt/am-foreign, improved test coverage as measured by kcov from 56.5%[1] to\n67.3%[2].\n\nNo tests for git-am's interactive mode, though, as test_terminal does not seem\nto attach a pseudo-tty to stdin(?), thus making git-am's \"test -t 0\" check fail.\n\nThis is part of my GSoC project to rewrite git-am.sh to a C builtin[3].\n\n[1] http://pyokagan.github.io/git/20150430132408-a75942b//kcov-merged/git-am.eb79278e.html\n[2] http://pyokagan.github.io/git/20150702173751-2fdae08//kcov-merged/git-am.eb79278e.html\n[3] https://gist.github.com/pyokagan/1b7b0d1f4dab6ba3cef1\n\n\nPaul Tan (12):\n  t4150: am.messageid really adds the message id\n  t4150: am fails if index is dirty\n  t4151: am --abort will keep dirty index intact\n  t4150: am refuses patches when paused\n  t4150: am --resolved fails if index has no changes\n  t4150: am --resolved fails if index has unmerged entries\n  t4150: am with applypatch-msg hook\n  t4150: am with pre-applypatch hook\n  t4150: am with post-applypatch hook\n  t4150: tests for am --[no-]scissors\n  t3418: non-interactive rebase --continue with rerere enabled\n  t3901: test git-am encoding conversion\n\n t/t3418-rebase-continue.sh |  19 ++++\n t/t3901-i18n-patch.sh      |  62 ++++++++++++\n t/t4150-am.sh              | 228 +++++++++++++++++++++++++++++++++++++++++++++\n t/t4151-am-abort.sh        |  15 +++\n 4 files changed, 324 insertions(+)\n\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265422","messageId":"1435861000-25278-2-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 01/12] t4150: am.messageid really adds the message id","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:29Z","receivedAt":"2015-07-02T18:16:29Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since a078f73 (git-am: add --message-id/--no-message-id, 2014-11-25),\nthe am.messageid setting determines whether the --message-id option is\nset by default.\n\nAdd a test for this.\n\nCc: Paolo Bonzini <pbonzini@redhat.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex b822a39..3f54bdf 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -563,6 +563,17 @@ test_expect_success 'am --message-id really adds the message id' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'am.messageid really adds the message id' '\n+\trm -fr .git/rebase-apply &&\n+\tgit checkout -f HEAD^ &&\n+\ttest_config am.messageid true &&\n+\tgit am patch1.eml &&\n+\ttest_path_is_missing .git/rebase-apply &&\n+\tgit cat-file commit HEAD | tail -n1 >actual &&\n+\tgrep Message-Id patch1.eml >expected &&\n+\ttest_cmp expected actual\n+'\n+\n test_expect_success 'am --message-id -s signs off after the message id' '\n \trm -fr .git/rebase-apply &&\n \tgit reset --hard &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265423","messageId":"1435861000-25278-3-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 02/12] t4150: am fails if index is dirty","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:30Z","receivedAt":"2015-07-02T18:16:30Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am\nwill ensure that the index is clean before applying the patch. This is\nto prevent changes unrelated to the patch from being committed.\n\nAdd a test for this check.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 3f54bdf..0a19136 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -154,6 +154,17 @@ test_expect_success 'am applies patch correctly' '\n \ttest \"$(git rev-parse second^)\" = \"$(git rev-parse HEAD^)\"\n '\n \n+test_expect_success 'am fails if index is dirty' '\n+\ttest_when_finished \"rm -fr dirtyfile\" &&\n+\trm -fr .git/rebase-apply &&\n+\tgit checkout -f first &&\n+\techo dirtyfile >dirtyfile &&\n+\tgit add dirtyfile &&\n+\ttest_must_fail git am patch1 &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\ttest_cmp_rev first HEAD\n+'\n+\n test_expect_success 'am applies patch e-mail not in a mbox' '\n \trm -fr .git/rebase-apply &&\n \tgit reset --hard &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265424","messageId":"1435861000-25278-4-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 03/12] t4151: am --abort will keep dirty index intact","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:31Z","receivedAt":"2015-07-02T18:16:31Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since 7b3b7e3 (am --abort: keep unrelated commits since the last failure\nand warn, 2010-12-21), git-am --abort will not touch the index if on the\nprevious invocation, git-am failed because the index is dirty. This is\nto ensure that the user's modifications to the index are not discarded.\n\nAdd a test for this.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4151-am-abort.sh | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)\n\ndiff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh\nindex 833e7b2..05bdc3e 100755\n--- a/t/t4151-am-abort.sh\n+++ b/t/t4151-am-abort.sh\n@@ -95,6 +95,21 @@ test_expect_success 'am --abort will keep the local commits intact' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'am --abort will keep dirty index intact' '\n+\tgit reset --hard initial &&\n+\techo dirtyfile >dirtyfile &&\n+\tcp dirtyfile dirtyfile.expected &&\n+\tgit add dirtyfile &&\n+\ttest_must_fail git am 0001-*.patch &&\n+\ttest_cmp_rev initial HEAD &&\n+\ttest_path_is_file dirtyfile &&\n+\ttest_cmp dirtyfile.expected dirtyfile &&\n+\tgit am --abort &&\n+\ttest_cmp_rev initial HEAD &&\n+\ttest_path_is_file dirtyfile &&\n+\ttest_cmp dirtyfile.expected dirtyfile\n+'\n+\n test_expect_success 'am -3 stops on conflict on unborn branch' '\n \tgit checkout -f --orphan orphan &&\n \tgit reset &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265425","messageId":"1435861000-25278-5-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 04/12] t4150: am refuses patches when paused","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:32Z","receivedAt":"2015-07-02T18:16:32Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since c95b138 (Fix git-am safety checks, 2006-09-15), when there is a\nsession in progress, git-am will check the command-line arguments and\nstandard input to ensure that the user does not pass it any patches.\n\nAdd a test for this.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 14 ++++++++++++++\n 1 file changed, 14 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 0a19136..e5506f5 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -396,6 +396,20 @@ test_expect_success 'am --abort removes a stray directory' '\n \ttest_path_is_missing .git/rebase-apply\n '\n \n+test_expect_success 'am refuses patches when paused' '\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout lorem2^^ &&\n+\n+\ttest_must_fail git am lorem-move.patch &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\ttest_cmp_rev lorem2^^ HEAD &&\n+\n+\ttest_must_fail git am <lorem-move.patch &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\ttest_cmp_rev lorem2^^ HEAD\n+'\n+\n test_expect_success 'am --resolved works' '\n \techo goodbye >expected &&\n \trm -fr .git/rebase-apply &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265426","messageId":"1435861000-25278-6-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 05/12] t4150: am --resolved fails if index has no changes","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:33Z","receivedAt":"2015-07-02T18:16:33Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since 6d28644 (git-am: do not allow empty commits by mistake.,\n2006-02-23), git-am --resolved will check to see if the index has any\nchanges to prevent the user from creating an empty commit by mistake.\n\nAdd a test for this.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex e5506f5..a2bcffe 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -424,6 +424,18 @@ test_expect_success 'am --resolved works' '\n \ttest_cmp expected another\n '\n \n+test_expect_success 'am --resolved fails if index has no changes' '\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout lorem2^^ &&\n+\ttest_must_fail git am lorem-move.patch &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\ttest_cmp_rev lorem2^^ HEAD &&\n+\ttest_must_fail git am --resolved &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\ttest_cmp_rev lorem2^^ HEAD\n+'\n+\n test_expect_success 'am takes patches from a Pine mailbox' '\n \trm -fr .git/rebase-apply &&\n \tgit reset --hard &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265427","messageId":"1435861000-25278-7-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 06/12] t4150: am --resolved fails if index has unmerged entries","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:34Z","receivedAt":"2015-07-02T18:16:34Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since c1d1128 (git-am --resolved: more usable error message.,\n2006-04-28), git-am --resolved will check to see if there are any\nunmerged entries, and will error out with a user-friendly error message\nif there are.\n\nAdd a test for this.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex a2bcffe..05494e9 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -436,6 +436,19 @@ test_expect_success 'am --resolved fails if index has no changes' '\n \ttest_cmp_rev lorem2^^ HEAD\n '\n \n+test_expect_success 'am --resolved fails if index has unmerged entries' '\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout second &&\n+\ttest_must_fail git am -3 lorem-move.patch &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\ttest_cmp_rev second HEAD &&\n+\ttest_must_fail git am --resolved >err &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\ttest_cmp_rev second HEAD &&\n+\ttest_i18ngrep \"still have unmerged paths\" err\n+'\n+\n test_expect_success 'am takes patches from a Pine mailbox' '\n \trm -fr .git/rebase-apply &&\n \tgit reset --hard &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265428","messageId":"1435861000-25278-8-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 07/12] t4150: am with applypatch-msg hook","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:35Z","receivedAt":"2015-07-02T18:16:35Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am\nwill invoke the applypatch-msg hooks just after extracting the patch\nmessage. If the applypatch-msg hook exits with a non-zero status, git-am\nabort before even applying the patch to the index.\n\nAdd tests for this hook.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 39 +++++++++++++++++++++++++++++++++++++++\n 1 file changed, 39 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 05494e9..24c1b42 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -198,6 +198,45 @@ test_expect_success 'am applies patch e-mail with preceding whitespace' '\n \ttest \"$(git rev-parse second^)\" = \"$(git rev-parse HEAD^)\"\n '\n \n+test_expect_success 'am with applypatch-msg hook' '\n+\ttest_when_finished \"rm -f .git/hooks/applypatch-msg\" &&\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout first &&\n+\tmkdir -p .git/hooks &&\n+\tcat >.git/hooks/applypatch-msg <<-\\EOF &&\n+\t#!/bin/sh\n+\tcat \"$1\" >actual-msg &&\n+\techo hook-message >\"$1\"\n+\tEOF\n+\tchmod +x .git/hooks/applypatch-msg &&\n+\tgit am patch1 &&\n+\ttest_path_is_missing .git/rebase-apply &&\n+\tgit diff --exit-code second &&\n+\techo hook-message >expected &&\n+\tgit log -1 --format=format:%B >actual &&\n+\ttest_cmp expected actual &&\n+\tgit log -1 --format=format:%B second >expected &&\n+\ttest_cmp expected actual-msg\n+'\n+\n+test_expect_success 'am with failing applypatch-msg hook' '\n+\ttest_when_finished \"rm -f .git/hooks/applypatch-msg\" &&\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout first &&\n+\tmkdir -p .git/hooks &&\n+\tcat >.git/hooks/applypatch-msg <<-\\EOF &&\n+\t#!/bin/sh\n+\texit 1\n+\tEOF\n+\tchmod +x .git/hooks/applypatch-msg &&\n+\ttest_must_fail git am patch1 &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\tgit diff --exit-code first &&\n+\ttest_cmp_rev first HEAD\n+'\n+\n test_expect_success 'setup: new author and committer' '\n \tGIT_AUTHOR_NAME=\"Another Thor\" &&\n \tGIT_AUTHOR_EMAIL=\"a.thor@example.com\" &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265429","messageId":"1435861000-25278-9-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 08/12] t4150: am with pre-applypatch hook","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:36Z","receivedAt":"2015-07-02T18:16:36Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07),\ngit-am.sg will invoke the pre-applypatch hook after applying the patch\nto the index, but before a commit is made. Should the hook exit with a\nnon-zero status, git am will exit.\n\nAdd tests for this hook.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 38 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 38 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 24c1b42..dd6fe81 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -237,6 +237,44 @@ test_expect_success 'am with failing applypatch-msg hook' '\n \ttest_cmp_rev first HEAD\n '\n \n+test_expect_success 'am with pre-applypatch hook' '\n+\ttest_when_finished \"rm -f .git/hooks/pre-applypatch\" &&\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout first &&\n+\tmkdir -p .git/hooks &&\n+\tcat >.git/hooks/pre-applypatch <<-\\EOF &&\n+\t#!/bin/sh\n+\tgit diff first >diff.actual\n+\texit 0\n+\tEOF\n+\tchmod +x .git/hooks/pre-applypatch &&\n+\tgit am patch1 &&\n+\ttest_path_is_missing .git/rebase-apply &&\n+\tgit diff --exit-code second &&\n+\ttest_cmp_rev second HEAD &&\n+\ttest_cmp_rev second^ HEAD^ &&\n+\tgit diff first..second >diff.expected &&\n+\ttest_cmp diff.expected diff.actual\n+'\n+\n+test_expect_success 'am with failing pre-applypatch hook' '\n+\ttest_when_finished \"rm -f .git/hooks/pre-applypatch\" &&\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout first &&\n+\tmkdir -p .git/hooks &&\n+\tcat >.git/hooks/pre-applypatch <<-\\EOF &&\n+\t#!/bin/sh\n+\texit 1\n+\tEOF\n+\tchmod +x .git/hooks/pre-applypatch &&\n+\ttest_must_fail git am patch1 &&\n+\ttest_path_is_dir .git/rebase-apply &&\n+\tgit diff --exit-code second &&\n+\ttest_cmp_rev first HEAD\n+'\n+\n test_expect_success 'setup: new author and committer' '\n \tGIT_AUTHOR_NAME=\"Another Thor\" &&\n \tGIT_AUTHOR_EMAIL=\"a.thor@example.com\" &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265430","messageId":"1435861000-25278-10-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 09/12] t4150: am with post-applypatch hook","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:37Z","receivedAt":"2015-07-02T18:16:37Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07),\ngit-am.sh will invoke the post-applypatch hook after the patch is\napplied and a commit is made. The exit code of the hook is ignored.\n\nAdd tests for this hook.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 42 ++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 42 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex dd6fe81..62b678c 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -275,6 +275,48 @@ test_expect_success 'am with failing pre-applypatch hook' '\n \ttest_cmp_rev first HEAD\n '\n \n+test_expect_success 'am with post-applypatch hook' '\n+\ttest_when_finished \"rm -f .git/hooks/post-applypatch\" &&\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout first &&\n+\tmkdir -p .git/hooks &&\n+\tcat >.git/hooks/post-applypatch <<-\\EOF &&\n+\t#!/bin/sh\n+\tgit rev-parse HEAD >head.actual\n+\tgit diff second >diff.actual\n+\texit 0\n+\tEOF\n+\tchmod +x .git/hooks/post-applypatch &&\n+\tgit am patch1 &&\n+\ttest_path_is_missing .git/rebase-apply &&\n+\ttest_cmp_rev second HEAD &&\n+\tgit rev-parse second >head.expected &&\n+\ttest_cmp head.expected head.actual &&\n+\tgit diff second >diff.expected &&\n+\ttest_cmp diff.expected diff.actual\n+'\n+\n+test_expect_success 'am with failing post-applypatch hook' '\n+\ttest_when_finished \"rm -f .git/hooks/post-applypatch\" &&\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout first &&\n+\tmkdir -p .git/hooks &&\n+\tcat >.git/hooks/post-applypatch <<-\\EOF &&\n+\t#!/bin/sh\n+\tgit rev-parse HEAD >head.actual\n+\texit 1\n+\tEOF\n+\tchmod +x .git/hooks/post-applypatch &&\n+\tgit am patch1 &&\n+\ttest_path_is_missing .git/rebase-apply &&\n+\tgit diff --exit-code second &&\n+\ttest_cmp_rev second HEAD &&\n+\tgit rev-parse second >head.expected &&\n+\ttest_cmp head.expected head.actual\n+'\n+\n test_expect_success 'setup: new author and committer' '\n \tGIT_AUTHOR_NAME=\"Another Thor\" &&\n \tGIT_AUTHOR_EMAIL=\"a.thor@example.com\" &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265431","messageId":"1435861000-25278-11-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 10/12] t4150: tests for am --[no-]scissors","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:38Z","receivedAt":"2015-07-02T18:16:38Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since 017678b (am/mailinfo: Disable scissors processing by default,\n2009-08-26), git-am supported the --[no-]scissors option, passing it to\ngit-mailinfo.\n\nAdd tests to ensure that git-am will pass the --scissors option to\ngit-mailinfo, and that --no-scissors will override the configuration\nsetting of mailinfo.scissors.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t4150-am.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 48 insertions(+)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 62b678c..94e7c18 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -67,6 +67,19 @@ test_expect_success 'setup: messages' '\n \n \tEOF\n \n+\tcat >scissors-msg <<-\\EOF &&\n+\tTest git-am with scissors line\n+\n+\tThis line should be included in the commit message.\n+\tEOF\n+\n+\tcat - scissors-msg >no-scissors-msg <<-\\EOF &&\n+\tThis line should not be included in the commit message with --scissors enabled.\n+\n+\t - - >8 - - remove everything above this line - - >8 - -\n+\n+\tEOF\n+\n \tsignoff=\"Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>\"\n '\n \n@@ -105,6 +118,20 @@ test_expect_success setup '\n \t\tgit format-patch --stdout first | sed -e \"1d\"\n \t} > patch1-ws.eml &&\n \n+\techo scissors-file >scissors-file &&\n+\tgit add scissors-file &&\n+\tgit commit -F scissors-msg &&\n+\tgit tag scissors &&\n+\tgit format-patch --stdout scissors^ >scissors-patch.eml &&\n+\tgit reset --hard HEAD^ &&\n+\n+\techo no-scissors-file >no-scissors-file &&\n+\tgit add no-scissors-file &&\n+\tgit commit -F no-scissors-msg &&\n+\tgit tag no-scissors &&\n+\tgit format-patch --stdout no-scissors^ >no-scissors-patch.eml &&\n+\tgit reset --hard HEAD^ &&\n+\n \tsed -n -e \"3,\\$p\" msg >file &&\n \tgit add file &&\n \ttest_tick &&\n@@ -317,6 +344,27 @@ test_expect_success 'am with failing post-applypatch hook' '\n \ttest_cmp head.expected head.actual\n '\n \n+test_expect_success 'am --scissors cuts the message at the scissors line' '\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout second &&\n+\tgit am --scissors scissors-patch.eml &&\n+\ttest_path_is_missing .git/rebase-apply &&\n+\tgit diff --exit-code scissors &&\n+\ttest_cmp_rev scissors HEAD\n+'\n+\n+test_expect_success 'am --no-scissors overrides mailinfo.scissors' '\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout second &&\n+\ttest_config mailinfo.scissors true &&\n+\tgit am --no-scissors no-scissors-patch.eml &&\n+\ttest_path_is_missing .git/rebase-apply &&\n+\tgit diff --exit-code no-scissors &&\n+\ttest_cmp_rev no-scissors HEAD\n+'\n+\n test_expect_success 'setup: new author and committer' '\n \tGIT_AUTHOR_NAME=\"Another Thor\" &&\n \tGIT_AUTHOR_EMAIL=\"a.thor@example.com\" &&\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265432","messageId":"1435861000-25278-12-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 11/12] t3418: non-interactive rebase --continue with rerere enabled","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:39Z","receivedAt":"2015-07-02T18:16:39Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since 8389b52 (git-rerere: reuse recorded resolve., 2006-01-28), git-am\nwill call git-rerere to re-use recorded merge conflict resolutions if\nany occur in a threeway merge.\n\nAdd a test to ensure that git-rerere is called by git-am (which handles\nthe non-interactive rebase).\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t3418-rebase-continue.sh | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 2680375..4428b90 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -40,6 +40,25 @@ test_expect_success 'non-interactive rebase --continue works with touched file'\n \tgit rebase --continue\n '\n \n+test_expect_success 'non-interactive rebase --continue with rerere enabled' '\n+\ttest_config rerere.enabled true &&\n+\ttest_when_finished \"test_might_fail git rebase --abort\" &&\n+\tgit reset --hard commit-new-file-F2-on-topic-branch &&\n+\tgit checkout master &&\n+\trm -fr .git/rebase-* &&\n+\n+\ttest_must_fail git rebase --onto master master topic &&\n+\techo \"Resolved\" >F2 &&\n+\tgit add F2 &&\n+\tcp F2 F2.expected &&\n+\tgit rebase --continue &&\n+\n+\tgit reset --hard commit-new-file-F2-on-topic-branch &&\n+\tgit checkout master &&\n+\ttest_must_fail git rebase --onto master master topic &&\n+\ttest_cmp F2.expected F2\n+'\n+\n test_expect_success 'rebase --continue can not be used with other options' '\n \ttest_must_fail git rebase -v --continue &&\n \ttest_must_fail git rebase --continue -v\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265433","messageId":"1435861000-25278-13-git-send-email-pyokagan@gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"[PATCH 12/12] t3901: test git-am encoding conversion","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-02T18:16:40Z","receivedAt":"2015-07-02T18:16:40Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am\nsupported the --utf8 and --no-utf8 options, and if set, would pass the\n-u flag and the -k flag respectively.\n\ngit mailinfo -u will re-code the commit log message and authorship info\nin the charset specified by i18n.commitencoding setting, while\ngit mailinfo -n will disable the re-coding.\n\nSince d84029b (--utf8 is now default for 'git-am', 2007-01-08), --utf8\nis set by default in git-am.\n\nAdd various encoding conversion tests to t3901 to test git-mailinfo's\nencoding conversion. In addition, add a test for --no-utf8 to check that\nno encoding conversion will occur if that option is set.\n\nCc: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\n t/t3901-i18n-patch.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 62 insertions(+)\n\ndiff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh\nindex 75cf3ff..b49bdb7 100755\n--- a/t/t3901-i18n-patch.sh\n+++ b/t/t3901-i18n-patch.sh\n@@ -251,4 +251,66 @@ test_expect_success 'rebase --merge (L/U)' '\n \tcheck_encoding 2 8859\n '\n \n+test_expect_success 'am (U/U)' '\n+\t# Apply UTF-8 patches with UTF-8 commitencoding\n+\tgit config i18n.commitencoding UTF-8 &&\n+\t. \"$TEST_DIRECTORY\"/t3901-utf8.txt &&\n+\n+\tgit reset --hard master &&\n+\tgit am out-u1 out-u2 &&\n+\n+\tcheck_encoding 2\n+'\n+\n+test_expect_success 'am (L/L)' '\n+\t# Apply ISO-8859-1 patches with ISO-8859-1 commitencoding\n+\tgit config i18n.commitencoding ISO8859-1 &&\n+\t. \"$TEST_DIRECTORY\"/t3901-8859-1.txt &&\n+\n+\tgit reset --hard master &&\n+\tgit am out-l1 out-l2 &&\n+\n+\tcheck_encoding 2 8859\n+'\n+\n+test_expect_success 'am (U/L)' '\n+\t# Apply ISO-8859-1 patches with UTF-8 commitencoding\n+\tgit config i18n.commitencoding UTF-8 &&\n+\t. \"$TEST_DIRECTORY\"/t3901-utf8.txt &&\n+\tgit reset --hard master &&\n+\n+\t# am specifies --utf8 by default.\n+\tgit am out-l1 out-l2 &&\n+\n+\tcheck_encoding 2\n+'\n+\n+test_expect_success 'am --no-utf8 (U/L)' '\n+\t# Apply ISO-8859-1 patches with UTF-8 commitencoding\n+\tgit config i18n.commitencoding UTF-8 &&\n+\t. \"$TEST_DIRECTORY\"/t3901-utf8.txt &&\n+\n+\tgit reset --hard master &&\n+\tgit am --no-utf8 out-l1 out-l2 2>err &&\n+\n+\t# commit-tree will warn that the commit message does not contain valid UTF-8\n+\t# as mailinfo did not convert it\n+\tgrep \"did not conform\" err &&\n+\n+\tcheck_encoding 2\n+'\n+\n+test_expect_success !MINGW 'am (L/U)' '\n+\t# Apply UTF-8 patches with ISO-8859-1 commitencoding\n+\tgit config i18n.commitencoding ISO8859-1 &&\n+\t. \"$TEST_DIRECTORY\"/t3901-8859-1.txt &&\n+\n+\tgit reset --hard master &&\n+\t# mailinfo will re-code the commit message to the charset specified by\n+\t# i18n.commitencoding\n+\tgit am out-u1 out-u2 &&\n+\n+\tcheck_encoding 2 8859\n+'\n+\n test_done\n-- \n2.5.0.rc1.81.gfe77482\n"},{"id":"265434","messageId":"559585BC.4060601@redhat.com","threadId":"39770","inReplyTo":"1435861000-25278-2-git-send-email-pyokagan@gmail.com","subject":"Re: [PATCH 01/12] t4150: am.messageid really adds the message id","fromName":"Paolo Bonzini","fromEmail":"pbonzini@redhat.com","sentAt":"2015-07-02T18:41:00Z","receivedAt":"2015-07-02T18:41:00Z","isPatch":true,"sender":{"key":"pbonzini@redhat.com","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"\n\nOn 02/07/2015 20:16, Paul Tan wrote:\n> Since a078f73 (git-am: add --message-id/--no-message-id, 2014-11-25),\n> the am.messageid setting determines whether the --message-id option is\n> set by default.\n> \n> Add a test for this.\n> \n> Cc: Paolo Bonzini <pbonzini@redhat.com>\n> Signed-off-by: Paul Tan <pyokagan@gmail.com>\n> ---\n>  t/t4150-am.sh | 11 +++++++++++\n>  1 file changed, 11 insertions(+)\n> \n> diff --git a/t/t4150-am.sh b/t/t4150-am.sh\n> index b822a39..3f54bdf 100755\n> --- a/t/t4150-am.sh\n> +++ b/t/t4150-am.sh\n> @@ -563,6 +563,17 @@ test_expect_success 'am --message-id really adds the message id' '\n>  \ttest_cmp expected actual\n>  '\n>  \n> +test_expect_success 'am.messageid really adds the message id' '\n> +\trm -fr .git/rebase-apply &&\n> +\tgit checkout -f HEAD^ &&\n> +\ttest_config am.messageid true &&\n> +\tgit am patch1.eml &&\n> +\ttest_path_is_missing .git/rebase-apply &&\n> +\tgit cat-file commit HEAD | tail -n1 >actual &&\n> +\tgrep Message-Id patch1.eml >expected &&\n> +\ttest_cmp expected actual\n> +'\n> +\n>  test_expect_success 'am --message-id -s signs off after the message id' '\n>  \trm -fr .git/rebase-apply &&\n>  \tgit reset --hard &&\n> \n\nReviewed-by: Paolo Bonzini <pbonzini@redhat.com>\n"},{"id":"265462","messageId":"CAGZ79kaisrdsguxrwMCr5TK9RQaGF-WgVE7d9_=s7GXELqYxXA@mail.gmail.com","threadId":"39770","inReplyTo":"1435861000-25278-1-git-send-email-pyokagan@gmail.com","subject":"Re: [PATCH 00/12] Improve git-am test coverage","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-07-03T16:24:13Z","receivedAt":"2015-07-03T16:24:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jul 2, 2015 at 11:16 AM, Paul Tan <pyokagan@gmail.com> wrote:\n> Increase test coverage of git-am.sh to help prevent regressions that could arise\n> from the rewrite of git-am.sh to C. This patch series, along with\n> pt/am-foreign, improved test coverage as measured by kcov from 56.5%[1] to\n> 67.3%[2].\n>\n> No tests for git-am's interactive mode, though, as test_terminal does not seem\n> to attach a pseudo-tty to stdin(?), thus making git-am's \"test -t 0\" check fail.\n>\n> This is part of my GSoC project to rewrite git-am.sh to a C builtin[3].\n\nThe whole series looks good to me.\n\n>\n> [1] http://pyokagan.github.io/git/20150430132408-a75942b//kcov-merged/git-am.eb79278e.html\n> [2] http://pyokagan.github.io/git/20150702173751-2fdae08//kcov-merged/git-am.eb79278e.html\n> [3] https://gist.github.com/pyokagan/1b7b0d1f4dab6ba3cef1\n>\n>\n> Paul Tan (12):\n>   t4150: am.messageid really adds the message id\n>   t4150: am fails if index is dirty\n>   t4151: am --abort will keep dirty index intact\n>   t4150: am refuses patches when paused\n>   t4150: am --resolved fails if index has no changes\n>   t4150: am --resolved fails if index has unmerged entries\n>   t4150: am with applypatch-msg hook\n>   t4150: am with pre-applypatch hook\n>   t4150: am with post-applypatch hook\n>   t4150: tests for am --[no-]scissors\n>   t3418: non-interactive rebase --continue with rerere enabled\n>   t3901: test git-am encoding conversion\n>\n>  t/t3418-rebase-continue.sh |  19 ++++\n>  t/t3901-i18n-patch.sh      |  62 ++++++++++++\n>  t/t4150-am.sh              | 228 +++++++++++++++++++++++++++++++++++++++++++++\n>  t/t4151-am-abort.sh        |  15 +++\n>  4 files changed, 324 insertions(+)\n>\n> --\n> 2.5.0.rc1.81.gfe77482\n>\n"},{"id":"265533","messageId":"eb790f13314192dcf4787c54d4cd3cfb@www.dscho.org","threadId":"39770","inReplyTo":"1435861000-25278-3-git-send-email-pyokagan@gmail.com","subject":"Re: [PATCH 02/12] t4150: am fails if index is dirty","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-07-05T15:38:25Z","receivedAt":"2015-07-05T15:38:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Paul,\n\nOn 2015-07-02 20:16, Paul Tan wrote:\n\n> diff --git a/t/t4150-am.sh b/t/t4150-am.sh\n> index 3f54bdf..0a19136 100755\n> --- a/t/t4150-am.sh\n> +++ b/t/t4150-am.sh\n> @@ -154,6 +154,17 @@ test_expect_success 'am applies patch correctly' '\n>  \ttest \"$(git rev-parse second^)\" = \"$(git rev-parse HEAD^)\"\n>  '\n>  \n> +test_expect_success 'am fails if index is dirty' '\n> +\ttest_when_finished \"rm -fr dirtyfile\" &&\n\nSeeing as you `git add` that file further down, how about `git rm -f dirtfile` here?\n\n> +\trm -fr .git/rebase-apply &&\n> +\tgit checkout -f first &&\n> +\techo dirtyfile >dirtyfile &&\n> +\tgit add dirtyfile &&\n> +\ttest_must_fail git am patch1 &&\n> +\ttest_path_is_dir .git/rebase-apply &&\n> +\ttest_cmp_rev first HEAD\n\nCiao,\nDscho\n"},{"id":"265534","messageId":"17f64cb49c820eb41d0fb58435c91c40@www.dscho.org","threadId":"39770","inReplyTo":"1435861000-25278-10-git-send-email-pyokagan@gmail.com","subject":"Re: [PATCH 09/12] t4150: am with post-applypatch hook","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-07-05T15:58:49Z","receivedAt":"2015-07-05T15:58:49Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Paul,\n\nOn 2015-07-02 20:16, Paul Tan wrote:\n\n> diff --git a/t/t4150-am.sh b/t/t4150-am.sh\n> index dd6fe81..62b678c 100755\n> --- a/t/t4150-am.sh\n> +++ b/t/t4150-am.sh\n> @@ -275,6 +275,48 @@ test_expect_success 'am with failing pre-applypatch hook' '\n>  \ttest_cmp_rev first HEAD\n>  '\n>  \n> +test_expect_success 'am with post-applypatch hook' '\n> +\ttest_when_finished \"rm -f .git/hooks/post-applypatch\" &&\n> +\trm -fr .git/rebase-apply &&\n> +\tgit reset --hard &&\n> +\tgit checkout first &&\n> +\tmkdir -p .git/hooks &&\n> +\tcat >.git/hooks/post-applypatch <<-\\EOF &&\n> +\t#!/bin/sh\n> +\tgit rev-parse HEAD >head.actual\n> +\tgit diff second >diff.actual\n> +\texit 0\n> +\tEOF\n> +\tchmod +x .git/hooks/post-applypatch &&\n> +\tgit am patch1 &&\n> +\ttest_path_is_missing .git/rebase-apply &&\n> +\ttest_cmp_rev second HEAD &&\n> +\tgit rev-parse second >head.expected &&\n> +\ttest_cmp head.expected head.actual &&\n> +\tgit diff second >diff.expected &&\n> +\ttest_cmp diff.expected diff.actual\n> +'\n> +\n> +test_expect_success 'am with failing post-applypatch hook' '\n> +\ttest_when_finished \"rm -f .git/hooks/post-applypatch\" &&\n> +\trm -fr .git/rebase-apply &&\n> +\tgit reset --hard &&\n> +\tgit checkout first &&\n> +\tmkdir -p .git/hooks &&\n> +\tcat >.git/hooks/post-applypatch <<-\\EOF &&\n> +\t#!/bin/sh\n> +\tgit rev-parse HEAD >head.actual\n> +\texit 1\n> +\tEOF\n> +\tchmod +x .git/hooks/post-applypatch &&\n> +\tgit am patch1 &&\n> +\ttest_path_is_missing .git/rebase-apply &&\n> +\tgit diff --exit-code second &&\n> +\ttest_cmp_rev second HEAD &&\n> +\tgit rev-parse second >head.expected &&\n> +\ttest_cmp head.expected head.actual\n> +'\n\nThese 2 tests as well as the previous patches look to me as if they could be refactored (the paradigm is the same: add a certain hook after resetting and then apply the patch, verify that the hook ran/failed)... do you think there is a chance for that?\n\nJust to make sure: I think the patch series looks good, and if it would be too cumbersome (or just not feasible) to simplify those test cases, I am totally fine with them as-are.\n\nCiao,\nDscho\n"},{"id":"265536","messageId":"341ac4ca31dabe768c106be1b11e8ea4@www.dscho.org","threadId":"39770","inReplyTo":"CAGZ79kaisrdsguxrwMCr5TK9RQaGF-WgVE7d9_=s7GXELqYxXA@mail.gmail.com","subject":"Re: [PATCH 00/12] Improve git-am test coverage","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-07-05T16:02:55Z","receivedAt":"2015-07-05T16:02:55Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn 2015-07-03 18:24, Stefan Beller wrote:\n> On Thu, Jul 2, 2015 at 11:16 AM, Paul Tan <pyokagan@gmail.com> wrote:\n>> Increase test coverage of git-am.sh to help prevent regressions that could arise\n>> from the rewrite of git-am.sh to C. This patch series, along with\n>> pt/am-foreign, improved test coverage as measured by kcov from 56.5%[1] to\n>> 67.3%[2].\n>>\n>> No tests for git-am's interactive mode, though, as test_terminal does not seem\n>> to attach a pseudo-tty to stdin(?), thus making git-am's \"test -t 0\" check fail.\n>>\n>> This is part of my GSoC project to rewrite git-am.sh to a C builtin[3].\n> \n> The whole series looks good to me.\n\nI concur (my two comments really are minor nit picks).\n\nThanks,\nDscho\n"},{"id":"265606","messageId":"xmqqoajp1916.fsf@gitster.dls.corp.google.com","threadId":"39770","inReplyTo":"559585BC.4060601@redhat.com","subject":"Re: [PATCH 01/12] t4150: am.messageid really adds the message id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-06T17:38:13Z","receivedAt":"2015-07-06T17:38:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks, both.\n"},{"id":"265608","messageId":"xmqqk2ud18nt.fsf@gitster.dls.corp.google.com","threadId":"39770","inReplyTo":"1435861000-25278-8-git-send-email-pyokagan@gmail.com","subject":"Re: [PATCH 07/12] t4150: am with applypatch-msg hook","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-06T17:46:14Z","receivedAt":"2015-07-06T17:46:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Tan <pyokagan@gmail.com> writes:\n\n> +test_expect_success 'am with applypatch-msg hook' '\n> +\ttest_when_finished \"rm -f .git/hooks/applypatch-msg\" &&\n> +\trm -fr .git/rebase-apply &&\n> +\tgit reset --hard &&\n> +\tgit checkout first &&\n> +\tmkdir -p .git/hooks &&\n> +\tcat >.git/hooks/applypatch-msg <<-\\EOF &&\n> +\t#!/bin/sh\n> +\tcat \"$1\" >actual-msg &&\n> +\techo hook-message >\"$1\"\n> +\tEOF\n> +\tchmod +x .git/hooks/applypatch-msg &&\n\nThis (and the other one below) looks like a good candidate for the\nwrite_script helper.\n\n> +\tgit am patch1 &&\n> +\ttest_path_is_missing .git/rebase-apply &&\n> +\tgit diff --exit-code second &&\n> +\techo hook-message >expected &&\n> +\tgit log -1 --format=format:%B >actual &&\n> +\ttest_cmp expected actual &&\n> +\tgit log -1 --format=format:%B second >expected &&\n> +\ttest_cmp expected actual-msg\n> +'\n> +\n> +test_expect_success 'am with failing applypatch-msg hook' '\n> +\ttest_when_finished \"rm -f .git/hooks/applypatch-msg\" &&\n> +\trm -fr .git/rebase-apply &&\n> +\tgit reset --hard &&\n> +\tgit checkout first &&\n> +\tmkdir -p .git/hooks &&\n> +\tcat >.git/hooks/applypatch-msg <<-\\EOF &&\n> +\t#!/bin/sh\n> +\texit 1\n> +\tEOF\n> +\tchmod +x .git/hooks/applypatch-msg &&\n> +\ttest_must_fail git am patch1 &&\n> +\ttest_path_is_dir .git/rebase-apply &&\n> +\tgit diff --exit-code first &&\n> +\ttest_cmp_rev first HEAD\n> +'\n> +\n>  test_expect_success 'setup: new author and committer' '\n>  \tGIT_AUTHOR_NAME=\"Another Thor\" &&\n>  \tGIT_AUTHOR_EMAIL=\"a.thor@example.com\" &&\n"},{"id":"265625","messageId":"xmqq8uatyq4d.fsf@gitster.dls.corp.google.com","threadId":"39770","inReplyTo":"341ac4ca31dabe768c106be1b11e8ea4@www.dscho.org","subject":"Re: [PATCH 00/12] Improve git-am test coverage","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-06T20:42:42Z","receivedAt":"2015-07-06T20:42:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n\n> On 2015-07-03 18:24, Stefan Beller wrote:\n>> On Thu, Jul 2, 2015 at 11:16 AM, Paul Tan <pyokagan@gmail.com> wrote:\n>>> Increase test coverage of git-am.sh to help prevent regressions\n>>> that could arise\n>>> from the rewrite of git-am.sh to C. This patch series, along with\n>>> pt/am-foreign, improved test coverage as measured by kcov from 56.5%[1] to\n>>> 67.3%[2].\n>>>\n>>> No tests for git-am's interactive mode, though, as test_terminal does not seem\n>>> to attach a pseudo-tty to stdin(?), thus making git-am's \"test -t\n>>> 0\" check fail.\n>>>\n>>> This is part of my GSoC project to rewrite git-am.sh to a C builtin[3].\n>> \n>> The whole series looks good to me.\n>\n> I concur (my two comments really are minor nit picks).\n>\n> Thanks,\n> Dscho\n\nYeah, looked more-or-less ready for 'next' to me, too.\n\nThanks, all.\n"},{"id":"265645","messageId":"CACRoPnSTNxR4+NLX_f6FaOJPLj4k9ESaLrdwjfxhSZCZYHUOSw@mail.gmail.com","threadId":"39770","inReplyTo":"eb790f13314192dcf4787c54d4cd3cfb@www.dscho.org","subject":"Re: [PATCH 02/12] t4150: am fails if index is dirty","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-07T06:35:59Z","receivedAt":"2015-07-07T06:35:59Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"On Sun, Jul 5, 2015 at 11:38 PM, Johannes Schindelin\n<johannes.schindelin@gmx.de> wrote:\n> On 2015-07-02 20:16, Paul Tan wrote:\n>\n>> diff --git a/t/t4150-am.sh b/t/t4150-am.sh\n>> index 3f54bdf..0a19136 100755\n>> --- a/t/t4150-am.sh\n>> +++ b/t/t4150-am.sh\n>> @@ -154,6 +154,17 @@ test_expect_success 'am applies patch correctly' '\n>>       test \"$(git rev-parse second^)\" = \"$(git rev-parse HEAD^)\"\n>>  '\n>>\n>> +test_expect_success 'am fails if index is dirty' '\n>> +     test_when_finished \"rm -fr dirtyfile\" &&\n>\n> Seeing as you `git add` that file further down, how about `git rm -f dirtfile` here?\n\nBut \"git rm -f\" would fail if the file is not in the index, no? (Which\ncould happen if the git-reset or git-checkout fails) Anyway, the\npurpose of the \"rm -f\" is to remove the dirtyfile, and not to clean up\nthe index (we would use git reset --hard for that).\n\n(But yeah, I see that Junio noticed correctly that it should not be a\nrm -fr, but a rm -f instead.)\n\nThanks,\nPaul\n"},{"id":"265648","messageId":"CACRoPnQ_bUtLuavFCdJGFAW08EY_LGV5Q=RR9Ey3jsoPk6-C3w@mail.gmail.com","threadId":"39770","inReplyTo":"17f64cb49c820eb41d0fb58435c91c40@www.dscho.org","subject":"Re: [PATCH 09/12] t4150: am with post-applypatch hook","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-07T06:47:19Z","receivedAt":"2015-07-07T06:47:19Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"On Sun, Jul 5, 2015 at 11:58 PM, Johannes Schindelin\n<johannes.schindelin@gmx.de> wrote:\n> On 2015-07-02 20:16, Paul Tan wrote:\n>\n>> diff --git a/t/t4150-am.sh b/t/t4150-am.sh\n>> index dd6fe81..62b678c 100755\n>> --- a/t/t4150-am.sh\n>> +++ b/t/t4150-am.sh\n>> @@ -275,6 +275,48 @@ test_expect_success 'am with failing pre-applypatch hook' '\n>>       test_cmp_rev first HEAD\n>>  '\n>>\n>> +test_expect_success 'am with post-applypatch hook' '\n>> +     test_when_finished \"rm -f .git/hooks/post-applypatch\" &&\n>> +     rm -fr .git/rebase-apply &&\n>> +     git reset --hard &&\n>> +     git checkout first &&\n>> +     mkdir -p .git/hooks &&\n>> +     cat >.git/hooks/post-applypatch <<-\\EOF &&\n>> +     #!/bin/sh\n>> +     git rev-parse HEAD >head.actual\n>> +     git diff second >diff.actual\n>> +     exit 0\n>> +     EOF\n>> +     chmod +x .git/hooks/post-applypatch &&\n>> +     git am patch1 &&\n>> +     test_path_is_missing .git/rebase-apply &&\n>> +     test_cmp_rev second HEAD &&\n>> +     git rev-parse second >head.expected &&\n>> +     test_cmp head.expected head.actual &&\n>> +     git diff second >diff.expected &&\n>> +     test_cmp diff.expected diff.actual\n>> +'\n>> +\n>> +test_expect_success 'am with failing post-applypatch hook' '\n>> +     test_when_finished \"rm -f .git/hooks/post-applypatch\" &&\n>> +     rm -fr .git/rebase-apply &&\n>> +     git reset --hard &&\n>> +     git checkout first &&\n>> +     mkdir -p .git/hooks &&\n>> +     cat >.git/hooks/post-applypatch <<-\\EOF &&\n>> +     #!/bin/sh\n>> +     git rev-parse HEAD >head.actual\n>> +     exit 1\n>> +     EOF\n>> +     chmod +x .git/hooks/post-applypatch &&\n>> +     git am patch1 &&\n>> +     test_path_is_missing .git/rebase-apply &&\n>> +     git diff --exit-code second &&\n>> +     test_cmp_rev second HEAD &&\n>> +     git rev-parse second >head.expected &&\n>> +     test_cmp head.expected head.actual\n>> +'\n>\n> These 2 tests as well as the previous patches look to me as if they could be refactored (the paradigm is the same: add a certain hook after resetting and then apply the patch, verify that the hook ran/failed)... do you think there is a chance for that?\n\nI had a look, but I think that while it is true that the overall\nsequence of each test is the same, the details differ enough that\nthere's no obvious way to refactor the tests sensibly. For example,\nthe contents of the hook scripts are not the same, as we need to check\nthat the hooks are run at the correct stage of git-am execution. And\nas such, the verification tests are also different as well.\n\nJunio did correctly point out though that we can shave off 2 lines if\nthe write_script helper is used (the shebang and the chmod).\n\nThanks,\nPaul\n"},{"id":"265655","messageId":"4babfe85175ee5b2e2da3afdfe3a30c2@www.dscho.org","threadId":"39770","inReplyTo":"CACRoPnQ_bUtLuavFCdJGFAW08EY_LGV5Q=RR9Ey3jsoPk6-C3w@mail.gmail.com","subject":"Re: [PATCH 09/12] t4150: am with post-applypatch hook","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-07-07T08:07:51Z","receivedAt":"2015-07-07T08:07:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Paul,\n\nOn 2015-07-07 08:47, Paul Tan wrote:\n> On Sun, Jul 5, 2015 at 11:58 PM, Johannes Schindelin\n> <johannes.schindelin@gmx.de> wrote:\n>> On 2015-07-02 20:16, Paul Tan wrote:\n>>\n>>> diff --git a/t/t4150-am.sh b/t/t4150-am.sh\n>>> index dd6fe81..62b678c 100755\n>>> --- a/t/t4150-am.sh\n>>> +++ b/t/t4150-am.sh\n>>> @@ -275,6 +275,48 @@ test_expect_success 'am with failing pre-applypatch hook' '\n>>>       test_cmp_rev first HEAD\n>>>  '\n>>>\n>>> +test_expect_success 'am with post-applypatch hook' '\n>>> +     test_when_finished \"rm -f .git/hooks/post-applypatch\" &&\n>>> +     rm -fr .git/rebase-apply &&\n>>> +     git reset --hard &&\n>>> +     git checkout first &&\n>>> +     mkdir -p .git/hooks &&\n>>> +     cat >.git/hooks/post-applypatch <<-\\EOF &&\n>>> +     #!/bin/sh\n>>> +     git rev-parse HEAD >head.actual\n>>> +     git diff second >diff.actual\n>>> +     exit 0\n>>> +     EOF\n>>> +     chmod +x .git/hooks/post-applypatch &&\n>>> +     git am patch1 &&\n>>> +     test_path_is_missing .git/rebase-apply &&\n>>> +     test_cmp_rev second HEAD &&\n>>> +     git rev-parse second >head.expected &&\n>>> +     test_cmp head.expected head.actual &&\n>>> +     git diff second >diff.expected &&\n>>> +     test_cmp diff.expected diff.actual\n>>> +'\n>>> +\n>>> +test_expect_success 'am with failing post-applypatch hook' '\n>>> +     test_when_finished \"rm -f .git/hooks/post-applypatch\" &&\n>>> +     rm -fr .git/rebase-apply &&\n>>> +     git reset --hard &&\n>>> +     git checkout first &&\n>>> +     mkdir -p .git/hooks &&\n>>> +     cat >.git/hooks/post-applypatch <<-\\EOF &&\n>>> +     #!/bin/sh\n>>> +     git rev-parse HEAD >head.actual\n>>> +     exit 1\n>>> +     EOF\n>>> +     chmod +x .git/hooks/post-applypatch &&\n>>> +     git am patch1 &&\n>>> +     test_path_is_missing .git/rebase-apply &&\n>>> +     git diff --exit-code second &&\n>>> +     test_cmp_rev second HEAD &&\n>>> +     git rev-parse second >head.expected &&\n>>> +     test_cmp head.expected head.actual\n>>> +'\n>>\n>> These 2 tests as well as the previous patches look to me as if they could be refactored (the paradigm is the same: add a certain hook after resetting and then apply the patch, verify that the hook ran/failed)... do you think there is a chance for that?\n> \n> I had a look, but I think that while it is true that the overall\n> sequence of each test is the same, the details differ enough that\n> there's no obvious way to refactor the tests sensibly. For example,\n> the contents of the hook scripts are not the same, as we need to check\n> that the hooks are run at the correct stage of git-am execution. And\n> as such, the verification tests are also different as well.\n\nYeah, makes sense. Thanks for the clarification!\n\nCiao,\nDscho\n"},{"id":"265876","messageId":"559D8BA0.5090701@kdbg.org","threadId":"39770","inReplyTo":"1435861000-25278-13-git-send-email-pyokagan@gmail.com","subject":"Re: [PATCH 12/12] t3901: test git-am encoding conversion","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-07-08T20:44:16Z","receivedAt":"2015-07-08T20:44:16Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 02.07.2015 um 20:16 schrieb Paul Tan:\n> Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am\n> supported the --utf8 and --no-utf8 options, and if set, would pass the\n> -u flag and the -k flag respectively.\n>\n> git mailinfo -u will re-code the commit log message and authorship info\n> in the charset specified by i18n.commitencoding setting, while\n> git mailinfo -n will disable the re-coding.\n>\n> Since d84029b (--utf8 is now default for 'git-am', 2007-01-08), --utf8\n> is set by default in git-am.\n>\n> Add various encoding conversion tests to t3901 to test git-mailinfo's\n> encoding conversion. In addition, add a test for --no-utf8 to check that\n> no encoding conversion will occur if that option is set.\n>\n> Cc: Junio C Hamano <gitster@pobox.com>\n> Signed-off-by: Paul Tan <pyokagan@gmail.com>\n> ---\n>   t/t3901-i18n-patch.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++\n>   1 file changed, 62 insertions(+)\n>\n> diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh\n> index 75cf3ff..b49bdb7 100755\n> --- a/t/t3901-i18n-patch.sh\n> +++ b/t/t3901-i18n-patch.sh\n> @@ -251,4 +251,66 @@ test_expect_success 'rebase --merge (L/U)' '\n>   \tcheck_encoding 2 8859\n>   '\n>\n> +test_expect_success 'am (U/U)' '\n> +\t# Apply UTF-8 patches with UTF-8 commitencoding\n> +\tgit config i18n.commitencoding UTF-8 &&\n> +\t. \"$TEST_DIRECTORY\"/t3901-utf8.txt &&\n> +\n> +\tgit reset --hard master &&\n> +\tgit am out-u1 out-u2 &&\n> +\n> +\tcheck_encoding 2\n> +'\n> +\n> +test_expect_success 'am (L/L)' '\n> +\t# Apply ISO-8859-1 patches with ISO-8859-1 commitencoding\n> +\tgit config i18n.commitencoding ISO8859-1 &&\n> +\t. \"$TEST_DIRECTORY\"/t3901-8859-1.txt &&\n> +\n> +\tgit reset --hard master &&\n> +\tgit am out-l1 out-l2 &&\n> +\n> +\tcheck_encoding 2 8859\n> +'\n\nThis test case must be protected by !MINGW, just like the last case \nbelow and other cases that are already in the file. See 32f4cb6cee for \ndetails.\n\n> +\n> +test_expect_success 'am (U/L)' '\n> +\t# Apply ISO-8859-1 patches with UTF-8 commitencoding\n> +\tgit config i18n.commitencoding UTF-8 &&\n> +\t. \"$TEST_DIRECTORY\"/t3901-utf8.txt &&\n> +\tgit reset --hard master &&\n> +\n> +\t# am specifies --utf8 by default.\n> +\tgit am out-l1 out-l2 &&\n> +\n> +\tcheck_encoding 2\n> +'\n> +\n> +test_expect_success 'am --no-utf8 (U/L)' '\n> +\t# Apply ISO-8859-1 patches with UTF-8 commitencoding\n> +\tgit config i18n.commitencoding UTF-8 &&\n> +\t. \"$TEST_DIRECTORY\"/t3901-utf8.txt &&\n> +\n> +\tgit reset --hard master &&\n> +\tgit am --no-utf8 out-l1 out-l2 2>err &&\n> +\n> +\t# commit-tree will warn that the commit message does not contain valid UTF-8\n> +\t# as mailinfo did not convert it\n> +\tgrep \"did not conform\" err &&\n> +\n> +\tcheck_encoding 2\n> +'\n> +\n> +test_expect_success !MINGW 'am (L/U)' '\n> +\t# Apply UTF-8 patches with ISO-8859-1 commitencoding\n> +\tgit config i18n.commitencoding ISO8859-1 &&\n> +\t. \"$TEST_DIRECTORY\"/t3901-8859-1.txt &&\n> +\n> +\tgit reset --hard master &&\n> +\t# mailinfo will re-code the commit message to the charset specified by\n> +\t# i18n.commitencoding\n> +\tgit am out-u1 out-u2 &&\n> +\n> +\tcheck_encoding 2 8859\n> +'\n> +\n>   test_done\n>\n\n-- Hannes\n"},{"id":"266110","messageId":"CACRoPnTZap1bn99kB37eJ3N61EprSa9oyXozRJ5qmN9JPTDVkw@mail.gmail.com","threadId":"39770","inReplyTo":"559D8BA0.5090701@kdbg.org","subject":"Re: [PATCH 12/12] t3901: test git-am encoding conversion","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-07-14T09:43:06Z","receivedAt":"2015-07-14T09:43:06Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"On Thu, Jul 9, 2015 at 4:44 AM, Johannes Sixt <j6t@kdbg.org> wrote:\n> Am 02.07.2015 um 20:16 schrieb Paul Tan:\n>> diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh\n>> index 75cf3ff..b49bdb7 100755\n>> --- a/t/t3901-i18n-patch.sh\n>> +++ b/t/t3901-i18n-patch.sh\n>> @@ -251,4 +251,66 @@ test_expect_success 'rebase --merge (L/U)' '\n>>         check_encoding 2 8859\n>>   '\n>>\n>> +test_expect_success 'am (U/U)' '\n>> +       # Apply UTF-8 patches with UTF-8 commitencoding\n>> +       git config i18n.commitencoding UTF-8 &&\n>> +       . \"$TEST_DIRECTORY\"/t3901-utf8.txt &&\n>> +\n>> +       git reset --hard master &&\n>> +       git am out-u1 out-u2 &&\n>> +\n>> +       check_encoding 2\n>> +'\n>> +\n>> +test_expect_success 'am (L/L)' '\n>> +       # Apply ISO-8859-1 patches with ISO-8859-1 commitencoding\n>> +       git config i18n.commitencoding ISO8859-1 &&\n>> +       . \"$TEST_DIRECTORY\"/t3901-8859-1.txt &&\n>> +\n>> +       git reset --hard master &&\n>> +       git am out-l1 out-l2 &&\n>> +\n>> +       check_encoding 2 8859\n>> +'\n>\n>\n> This test case must be protected by !MINGW, just like the last case below\n> and other cases that are already in the file. See 32f4cb6cee for details.\n\nAh, OK.\n\nThanks,\nPaul\n"}]}