From: "Nika Layzell via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Nika Layzell <nika@thelayzells.com>,
Junio C Hamano <gitster@pobox.com>,
Nika Layzell <nika@thelayzells.com>
Subject: [PATCH 1/1] reset: parse rev as tree-ish in patch mode
Date: Sat, 23 Nov 2019 19:55:36 +0000 [thread overview]
Message-ID: <338c2777f711ac21a30a7f890a8a11708e9a4fa6.1574538937.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.474.git.1574538937.gitgitgadget@gmail.com>
From: Nika Layzell <nika@thelayzells.com>
Relaxes the commit requirement for the rev argument when running
git-reset in patch mode without pathspec.
The revision argument to git-reset is parsed as either a commit or
tree-ish depending on mode. Previously, if no pathspec was provided,
the rev argument was parsed as a commit unconditionally.
Signed-off-by: Nika Layzell <nika@thelayzells.com>
---
builtin/reset.c | 2 +-
t/t7105-reset-patch.sh | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/builtin/reset.c b/builtin/reset.c
index fdd572168b..5cbfb21ec4 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -320,7 +320,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
if (unborn) {
/* reset on unborn branch: treat as reset to empty tree */
oidcpy(&oid, the_hash_algo->empty_tree);
- } else if (!pathspec.nr) {
+ } else if (!pathspec.nr && !patch_mode) {
struct commit *commit;
if (get_oid_committish(rev, &oid))
die(_("Failed to resolve '%s' as a valid revision."), rev);
diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh
index bd10a96727..2a6ecf515b 100755
--- a/t/t7105-reset-patch.sh
+++ b/t/t7105-reset-patch.sh
@@ -38,6 +38,13 @@ test_expect_success PERL 'git reset -p HEAD^' '
test_i18ngrep "Apply" output
'
+test_expect_success PERL 'git reset -p HEAD^^{tree}' '
+ test_write_lines n y | git reset -p HEAD^^{tree} >output &&
+ verify_state dir/foo work parent &&
+ verify_saved_state bar &&
+ test_i18ngrep "Apply" output
+'
+
# The idea in the rest is that bar sorts first, so we always say 'y'
# first and if the path limiter fails it'll apply to bar instead of
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
--
gitgitgadget
next prev parent reply other threads:[~2019-11-23 19:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-23 19:55 [PATCH 0/1] reset: parse rev as tree-ish in patch mode Nika Layzell via GitGitGadget
2019-11-23 19:55 ` Nika Layzell via GitGitGadget [this message]
2019-11-24 5:54 ` [PATCH 1/1] " Junio C Hamano
2019-11-24 18:31 ` Nika Layzell
2019-11-25 1:58 ` Junio C Hamano
2019-11-24 20:25 ` [PATCH v2 0/1] " Nika Layzell via GitGitGadget
2019-11-24 20:25 ` [PATCH v2 1/1] " Nika Layzell via GitGitGadget
2019-11-25 2:03 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=338c2777f711ac21a30a7f890a8a11708e9a4fa6.1574538937.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nika@thelayzells.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).