{"thread":{"id":"52323","subject":"[PATCH 0/1] reset: parse rev as tree-ish in patch mode","startedAt":"2019-11-23T19:55:41Z","lastAt":"2019-11-25T02:04:17Z","messageCount":8,"participants":["Nika Layzell via GitGitGadget","Junio C Hamano","Nika Layzell"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"386910","messageId":"pull.474.git.1574538937.gitgitgadget@gmail.com","threadId":"52323","inReplyTo":null,"subject":"[PATCH 0/1] reset: parse rev as tree-ish in patch mode","fromName":"Nika Layzell via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-11-23T19:55:35Z","receivedAt":"2019-11-23T19:55:41Z","isPatch":true,"sender":{"key":"nika@thelayzells.com","avatar":"https://avatars.githubusercontent.com/u/1261662?v=4"},"body":"This allows passing a tree-ish git reset -p without specifying a pathspec.\nRequiring a commit in this situation appears to be an oversight, and support\nfor a tree-ish is documented by git-reset's manpage. (\nhttps://github.com/git/git/blob/d9f6f3b6195a0ca35642561e530798ad1469bd41/Documentation/git-reset.txt#L12\n)\n\nAn alternative implementation of this change would move the if (patch_mode)\n{ ... return; } check before the rev parsing logic, offloading validation of\nthe rev argument when in patch mode to the git-add--interactive logic. This\nwould be possible as the parsed oid is not passed to git-add--interactive. (\nhttps://github.com/git/git/blob/d9f6f3b6195a0ca35642561e530798ad1469bd41/builtin/reset.c#L341-L346\n)\n\nNika Layzell (1):\n  reset: parse rev as tree-ish in patch mode\n\n builtin/reset.c        | 2 +-\n t/t7105-reset-patch.sh | 7 +++++++\n 2 files changed, 8 insertions(+), 1 deletion(-)\n\n\nbase-commit: 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-474%2Fmystor%2Freset-interactive-treeish-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-474/mystor/reset-interactive-treeish-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/474\n-- \ngitgitgadget\n"},{"id":"386911","messageId":"338c2777f711ac21a30a7f890a8a11708e9a4fa6.1574538937.git.gitgitgadget@gmail.com","threadId":"52323","inReplyTo":"pull.474.git.1574538937.gitgitgadget@gmail.com","subject":"[PATCH 1/1] reset: parse rev as tree-ish in patch mode","fromName":"Nika Layzell via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-11-23T19:55:36Z","receivedAt":"2019-11-23T19:55:42Z","isPatch":true,"sender":{"key":"nika@thelayzells.com","avatar":"https://avatars.githubusercontent.com/u/1261662?v=4"},"body":"From: Nika Layzell <nika@thelayzells.com>\n\nRelaxes the commit requirement for the rev argument when running\ngit-reset in patch mode without pathspec.\n\nThe revision argument to git-reset is parsed as either a commit or\ntree-ish depending on mode. Previously, if no pathspec was provided,\nthe rev argument was parsed as a commit unconditionally.\n\nSigned-off-by: Nika Layzell <nika@thelayzells.com>\n---\n builtin/reset.c        | 2 +-\n t/t7105-reset-patch.sh | 7 +++++++\n 2 files changed, 8 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex fdd572168b..5cbfb21ec4 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -320,7 +320,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \tif (unborn) {\n \t\t/* reset on unborn branch: treat as reset to empty tree */\n \t\toidcpy(&oid, the_hash_algo->empty_tree);\n-\t} else if (!pathspec.nr) {\n+\t} else if (!pathspec.nr && !patch_mode) {\n \t\tstruct commit *commit;\n \t\tif (get_oid_committish(rev, &oid))\n \t\t\tdie(_(\"Failed to resolve '%s' as a valid revision.\"), rev);\ndiff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh\nindex bd10a96727..2a6ecf515b 100755\n--- a/t/t7105-reset-patch.sh\n+++ b/t/t7105-reset-patch.sh\n@@ -38,6 +38,13 @@ test_expect_success PERL 'git reset -p HEAD^' '\n \ttest_i18ngrep \"Apply\" output\n '\n \n+test_expect_success PERL 'git reset -p HEAD^^{tree}' '\n+\ttest_write_lines n y | git reset -p HEAD^^{tree} >output &&\n+\tverify_state dir/foo work parent &&\n+\tverify_saved_state bar &&\n+\ttest_i18ngrep \"Apply\" output\n+'\n+\n # The idea in the rest is that bar sorts first, so we always say 'y'\n # first and if the path limiter fails it'll apply to bar instead of\n # dir/foo.  There's always an extra 'n' to reject edits to dir/foo in\n-- \ngitgitgadget\n"},{"id":"386930","messageId":"xmqq4kyt250e.fsf@gitster-ct.c.googlers.com","threadId":"52323","inReplyTo":"338c2777f711ac21a30a7f890a8a11708e9a4fa6.1574538937.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] reset: parse rev as tree-ish in patch mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-24T05:54:41Z","receivedAt":"2019-11-24T05:54:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Nika Layzell via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Nika Layzell <nika@thelayzells.com>\n>\n> Relaxes the commit requirement for the rev argument when running\n> git-reset in patch mode without pathspec.\n>\n> The revision argument to git-reset is parsed as either a commit or\n> tree-ish depending on mode. Previously, if no pathspec was provided,\n> the rev argument was parsed as a commit unconditionally.\n\nSwap the order of two paragraphs, i.e. explain what happens and what\nyou perceive as a problem in the current system in the present tense\n(and do not say \"Previously\" if you are talking about the state of\nthe system without your change), and then propose what to change in\nthe imperative mood as if you are giving an order to the codebase to\n\"be like so\".  Perhaps like this.\n\n    Since 2f328c3d (\"reset $sha1 $pathspec: require $sha1 only to be\n    treeish\", 2013-01-14), we allowed \"git reset $object -- $path\"\n    to reset individual paths that match the pathspec to take the\n    blob from a tree object, not necessarily a commit, while the\n    form to reset the tip of the current branch to some other commit\n    still must be given a commit.\n\n    Sometimes, however, being able to give a tree object to \"git\n    reset -p $obj\" when using the patch mode is useful FOR SUCH AND\n    SUCH REASONS.\n\n    Loosen the condition that requires a commit object to take a\n    tree object under the patch mode.\n\n>\n> Signed-off-by: Nika Layzell <nika@thelayzells.com>\n> ---\n>  builtin/reset.c        | 2 +-\n>  t/t7105-reset-patch.sh | 7 +++++++\n>  2 files changed, 8 insertions(+), 1 deletion(-)\n>\n> diff --git a/builtin/reset.c b/builtin/reset.c\n> index fdd572168b..5cbfb21ec4 100644\n> --- a/builtin/reset.c\n> +++ b/builtin/reset.c\n> @@ -320,7 +320,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n>  \tif (unborn) {\n>  \t\t/* reset on unborn branch: treat as reset to empty tree */\n>  \t\toidcpy(&oid, the_hash_algo->empty_tree);\n> -\t} else if (!pathspec.nr) {\n> +\t} else if (!pathspec.nr && !patch_mode) {\n>  \t\tstruct commit *commit;\n>  \t\tif (get_oid_committish(rev, &oid))\n>  \t\t\tdie(_(\"Failed to resolve '%s' as a valid revision.\"), rev);\n\nI notice that under the patch mode after this part of the code, we\ndo not even use the oid computed in these pieces of code at all.\nPresumably, run_add_interactive() function would also be sanity\nchecking the incoming \"rev\" and giving an appropriate error message\nwhen it is not of expected type.\n\nWhich means that perhaps a cleaner fix may be\n\n-\tif (unborn) {\n+\tif (patch_mode) {\n+\t\t/* do not compute or check &oid we will not use */\n+\t\t;\n+\t} else if (unborn) {\n\t\t...\n\nright?\n\n> diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh\n> index bd10a96727..2a6ecf515b 100755\n> --- a/t/t7105-reset-patch.sh\n> +++ b/t/t7105-reset-patch.sh\n> @@ -38,6 +38,13 @@ test_expect_success PERL 'git reset -p HEAD^' '\n>  \ttest_i18ngrep \"Apply\" output\n>  '\n>  \n> +test_expect_success PERL 'git reset -p HEAD^^{tree}' '\n> +\ttest_write_lines n y | git reset -p HEAD^^{tree} >output &&\n> +\tverify_state dir/foo work parent &&\n> +\tverify_saved_state bar &&\n> +\ttest_i18ngrep \"Apply\" output\n> +'\n\nThis only tests a positive (i.e. \"see what my change now allows you\nto do\") without checking a negative (i.e. \"I started allowing a\ntree, but I didn't inadvertently started allowing a blob or an\nobject that does not exist\"), which is an anti-pattern.  Please have\nanother test to ensure that the parser fails when it should, too.\n\nThanks.\n"},{"id":"386949","messageId":"CACwGqKgPYMEHhfOnAEuCA3sNiuV0Wk_JQwU+c=vF7Wkhf=V9iQ@mail.gmail.com","threadId":"52323","inReplyTo":"xmqq4kyt250e.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 1/1] reset: parse rev as tree-ish in patch mode","fromName":"Nika Layzell","fromEmail":"nika@thelayzells.com","sentAt":"2019-11-24T18:31:06Z","receivedAt":"2019-11-24T18:32:27Z","isPatch":true,"sender":{"key":"nika@thelayzells.com","avatar":"https://avatars.githubusercontent.com/u/1261662?v=4"},"body":"On Sun, Nov 24, 2019 at 12:54 AM Junio C Hamano <gitster@pobox.com> wrote:\n> I notice that under the patch mode after this part of the code, we\n> do not even use the oid computed in these pieces of code at all.\n> Presumably, run_add_interactive() function would also be sanity\n> checking the incoming \"rev\" and giving an appropriate error message\n> when it is not of expected type.\n>\n> Which means that perhaps a cleaner fix may be\n>\n> -       if (unborn) {\n> +       if (patch_mode) {\n> +               /* do not compute or check &oid we will not use */\n> +               ;\n> +       } else if (unborn) {\n>                 ...\n>\n> right?\n\nI tried to make this change, however it has unfortunate side-effects. The\n\"git-add--interactive\" script does produce an error if it is not of the\nexpected type, but it exits with a successful \"0\" status.\n\n$ $(git --exec-path)/git-add--interactive --patch=reset HEAD~:README.md --\nerror: Bad tree object HEAD~:README.md\nNo changes.\n$ echo $?\n0\n\nGiven that the add--interactive script is undergoing a C rewrite, I am\ninclined to continue validating the argument in reset.c to avoid changes to\nthe perl script.\n\n> This only tests a positive (i.e. \"see what my change now allows you\n> to do\") without checking a negative (i.e. \"I started allowing a\n> tree, but I didn't inadvertently started allowing a blob or an\n> object that does not exist\"), which is an anti-pattern.  Please have\n> another test to ensure that the parser fails when it should, too.\n\nI have added negative tests for the next version of the patch.\n\nThanks,\nNika\n\nPS. Apologies for the duplicate email. I accidentally sent a non-plain-text\nversion previously which was rejected from the mailing list.\n"},{"id":"386951","messageId":"pull.474.v2.git.1574627149.gitgitgadget@gmail.com","threadId":"52323","inReplyTo":"pull.474.git.1574538937.gitgitgadget@gmail.com","subject":"[PATCH v2 0/1] reset: parse rev as tree-ish in patch mode","fromName":"Nika Layzell via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-11-24T20:25:48Z","receivedAt":"2019-11-24T20:25:54Z","isPatch":true,"sender":{"key":"nika@thelayzells.com","avatar":"https://avatars.githubusercontent.com/u/1261662?v=4"},"body":"This allows passing a tree-ish git reset -p without specifying a pathspec.\nRequiring a commit in this situation appears to be an oversight, and support\nfor a tree-ish is documented by git-reset's manpage. (\nhttps://github.com/git/git/blob/d9f6f3b6195a0ca35642561e530798ad1469bd41/Documentation/git-reset.txt#L12\n)\n\nAn alternative implementation of this change would move the if (patch_mode)\n{ ... return; } check before the rev parsing logic, offloading validation of\nthe rev argument when in patch mode to the git-add--interactive logic. This\nwould be possible as the parsed oid is not passed to git-add--interactive. (\nhttps://github.com/git/git/blob/d9f6f3b6195a0ca35642561e530798ad1469bd41/builtin/reset.c#L341-L346\n)\n\nNika Layzell (1):\n  reset: parse rev as tree-ish in patch mode\n\n builtin/reset.c        |  2 +-\n t/t7105-reset-patch.sh | 21 +++++++++++++++++++++\n 2 files changed, 22 insertions(+), 1 deletion(-)\n\n\nbase-commit: 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-474%2Fmystor%2Freset-interactive-treeish-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-474/mystor/reset-interactive-treeish-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/474\n\nRange-diff vs v1:\n\n 1:  338c2777f7 ! 1:  a608dc8368 reset: parse rev as tree-ish in patch mode\n     @@ -2,12 +2,22 @@\n      \n          reset: parse rev as tree-ish in patch mode\n      \n     -    Relaxes the commit requirement for the rev argument when running\n     -    git-reset in patch mode without pathspec.\n     +    Since 2f328c3d (\"reset $sha1 $pathspec: require $sha1 only to be\n     +    treeish\", 2013-01-14), we allowed \"git reset $object -- $path\" to reset\n     +    individual paths that match the pathspec to take the blob from a tree\n     +    object, not necessarily a commit, while the form to reset the tip of the\n     +    current branch to some other commit still must be given a commit.\n      \n     -    The revision argument to git-reset is parsed as either a commit or\n     -    tree-ish depending on mode. Previously, if no pathspec was provided,\n     -    the rev argument was parsed as a commit unconditionally.\n     +    Like resetting with paths, \"git reset --patch\" does not update HEAD, and\n     +    need not require a commit. The path-filtered form, \"git reset --patch\n     +    $object -- $pathspec\", has accepted a tree-ish since 2f328c3d.\n     +\n     +    \"git reset --patch\" is documented as accepting a <tree-ish> since\n     +    bf44142f (\"reset: update documentation to require only tree-ish with\n     +    paths\", 2013-01-16). Documentation changes are not required.\n     +\n     +    Loosen the restriction that requires a commit for the unfiltered \"git\n     +    reset --patch $object\".\n      \n          Signed-off-by: Nika Layzell <nika@thelayzells.com>\n      \n     @@ -37,6 +47,20 @@\n      +\tverify_saved_state bar &&\n      +\ttest_i18ngrep \"Apply\" output\n      +'\n     ++\n     ++test_expect_success PERL 'git reset -p HEAD^:dir/foo (blob fails)' '\n     ++\tset_and_save_state dir/foo work work &&\n     ++\ttest_must_fail git reset -p HEAD^:dir/foo &&\n     ++\tverify_saved_state dir/foo &&\n     ++\tverify_saved_state bar\n     ++'\n     ++\n     ++test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' '\n     ++\tset_and_save_state dir/foo work work &&\n     ++\ttest_must_fail git reset -p aaaaaaaa &&\n     ++\tverify_saved_state dir/foo &&\n     ++\tverify_saved_state bar\n     ++'\n      +\n       # The idea in the rest is that bar sorts first, so we always say 'y'\n       # first and if the path limiter fails it'll apply to bar instead of\n\n-- \ngitgitgadget\n"},{"id":"386952","messageId":"a608dc8368c6fc738393dac46618f12e25d40eaf.1574627149.git.gitgitgadget@gmail.com","threadId":"52323","inReplyTo":"pull.474.v2.git.1574627149.gitgitgadget@gmail.com","subject":"[PATCH v2 1/1] reset: parse rev as tree-ish in patch mode","fromName":"Nika Layzell via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-11-24T20:25:49Z","receivedAt":"2019-11-24T20:25:54Z","isPatch":true,"sender":{"key":"nika@thelayzells.com","avatar":"https://avatars.githubusercontent.com/u/1261662?v=4"},"body":"From: Nika Layzell <nika@thelayzells.com>\n\nSince 2f328c3d (\"reset $sha1 $pathspec: require $sha1 only to be\ntreeish\", 2013-01-14), we allowed \"git reset $object -- $path\" to reset\nindividual paths that match the pathspec to take the blob from a tree\nobject, not necessarily a commit, while the form to reset the tip of the\ncurrent branch to some other commit still must be given a commit.\n\nLike resetting with paths, \"git reset --patch\" does not update HEAD, and\nneed not require a commit. The path-filtered form, \"git reset --patch\n$object -- $pathspec\", has accepted a tree-ish since 2f328c3d.\n\n\"git reset --patch\" is documented as accepting a <tree-ish> since\nbf44142f (\"reset: update documentation to require only tree-ish with\npaths\", 2013-01-16). Documentation changes are not required.\n\nLoosen the restriction that requires a commit for the unfiltered \"git\nreset --patch $object\".\n\nSigned-off-by: Nika Layzell <nika@thelayzells.com>\n---\n builtin/reset.c        |  2 +-\n t/t7105-reset-patch.sh | 21 +++++++++++++++++++++\n 2 files changed, 22 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex fdd572168b..5cbfb21ec4 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -320,7 +320,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \tif (unborn) {\n \t\t/* reset on unborn branch: treat as reset to empty tree */\n \t\toidcpy(&oid, the_hash_algo->empty_tree);\n-\t} else if (!pathspec.nr) {\n+\t} else if (!pathspec.nr && !patch_mode) {\n \t\tstruct commit *commit;\n \t\tif (get_oid_committish(rev, &oid))\n \t\t\tdie(_(\"Failed to resolve '%s' as a valid revision.\"), rev);\ndiff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh\nindex bd10a96727..fc2a6cf5c7 100755\n--- a/t/t7105-reset-patch.sh\n+++ b/t/t7105-reset-patch.sh\n@@ -38,6 +38,27 @@ test_expect_success PERL 'git reset -p HEAD^' '\n \ttest_i18ngrep \"Apply\" output\n '\n \n+test_expect_success PERL 'git reset -p HEAD^^{tree}' '\n+\ttest_write_lines n y | git reset -p HEAD^^{tree} >output &&\n+\tverify_state dir/foo work parent &&\n+\tverify_saved_state bar &&\n+\ttest_i18ngrep \"Apply\" output\n+'\n+\n+test_expect_success PERL 'git reset -p HEAD^:dir/foo (blob fails)' '\n+\tset_and_save_state dir/foo work work &&\n+\ttest_must_fail git reset -p HEAD^:dir/foo &&\n+\tverify_saved_state dir/foo &&\n+\tverify_saved_state bar\n+'\n+\n+test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' '\n+\tset_and_save_state dir/foo work work &&\n+\ttest_must_fail git reset -p aaaaaaaa &&\n+\tverify_saved_state dir/foo &&\n+\tverify_saved_state bar\n+'\n+\n # The idea in the rest is that bar sorts first, so we always say 'y'\n # first and if the path limiter fails it'll apply to bar instead of\n # dir/foo.  There's always an extra 'n' to reject edits to dir/foo in\n-- \ngitgitgadget\n"},{"id":"386961","messageId":"xmqqblt0zpgk.fsf@gitster-ct.c.googlers.com","threadId":"52323","inReplyTo":"CACwGqKgPYMEHhfOnAEuCA3sNiuV0Wk_JQwU+c=vF7Wkhf=V9iQ@mail.gmail.com","subject":"Re: [PATCH 1/1] reset: parse rev as tree-ish in patch mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-25T01:58:51Z","receivedAt":"2019-11-25T02:02:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nika Layzell <nika@thelayzells.com> writes:\n\n>> Which means that perhaps a cleaner fix may be\n>>\n>> -       if (unborn) {\n>> +       if (patch_mode) {\n>> +               /* do not compute or check &oid we will not use */\n>> +               ;\n>> +       } else if (unborn) {\n>>                 ...\n>>\n>> right?\n>\n> I tried to make this change, however it has unfortunate side-effects. The\n> \"git-add--interactive\" script does produce an error if it is not of the\n> expected type, but it exits with a successful \"0\" status.\n\nThanks for being diligent.  I love it when I see contributors do not\nbelieve blindly what I suggest out of hunch and instead verify it\nthemselves.\n\n> Given that the add--interactive script is undergoing a C rewrite, I am\n> inclined to continue validating the argument in reset.c to avoid changes to\n> the perl script.\n\nThanks.  That is a very reasonable decision.\n"},{"id":"386963","messageId":"xmqq7e3ozp97.fsf@gitster-ct.c.googlers.com","threadId":"52323","inReplyTo":"a608dc8368c6fc738393dac46618f12e25d40eaf.1574627149.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 1/1] reset: parse rev as tree-ish in patch mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-25T02:03:16Z","receivedAt":"2019-11-25T02:04:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Nika Layzell via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Nika Layzell <nika@thelayzells.com>\n>\n> Since 2f328c3d (\"reset $sha1 $pathspec: require $sha1 only to be\n> treeish\", 2013-01-14), we allowed \"git reset $object -- $path\" to reset\n> individual paths that match the pathspec to take the blob from a tree\n> object, not necessarily a commit, while the form to reset the tip of the\n> current branch to some other commit still must be given a commit.\n>\n> Like resetting with paths, \"git reset --patch\" does not update HEAD, and\n> need not require a commit. The path-filtered form, \"git reset --patch\n> $object -- $pathspec\", has accepted a tree-ish since 2f328c3d.\n>\n> \"git reset --patch\" is documented as accepting a <tree-ish> since\n> bf44142f (\"reset: update documentation to require only tree-ish with\n> paths\", 2013-01-16). Documentation changes are not required.\n>\n> Loosen the restriction that requires a commit for the unfiltered \"git\n> reset --patch $object\".\n>\n> Signed-off-by: Nika Layzell <nika@thelayzells.com>\n> ---\n\nNicely explained.\n\n> diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh\n> index bd10a96727..fc2a6cf5c7 100755\n> --- a/t/t7105-reset-patch.sh\n> +++ b/t/t7105-reset-patch.sh\n> @@ -38,6 +38,27 @@ test_expect_success PERL 'git reset -p HEAD^' '\n>  \ttest_i18ngrep \"Apply\" output\n>  '\n>  \n> +test_expect_success PERL 'git reset -p HEAD^^{tree}' '\n> +\ttest_write_lines n y | git reset -p HEAD^^{tree} >output &&\n> +\tverify_state dir/foo work parent &&\n> +\tverify_saved_state bar &&\n> +\ttest_i18ngrep \"Apply\" output\n> +'\n> +\n> +test_expect_success PERL 'git reset -p HEAD^:dir/foo (blob fails)' '\n> +\tset_and_save_state dir/foo work work &&\n> +\ttest_must_fail git reset -p HEAD^:dir/foo &&\n> +\tverify_saved_state dir/foo &&\n> +\tverify_saved_state bar\n> +'\n> +\n> +test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' '\n> +\tset_and_save_state dir/foo work work &&\n> +\ttest_must_fail git reset -p aaaaaaaa &&\n> +\tverify_saved_state dir/foo &&\n> +\tverify_saved_state bar\n> +'\n\nThanks, will queue.\n"}]}