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>
Subject: [PATCH v2 0/1] reset: parse rev as tree-ish in patch mode
Date: Sun, 24 Nov 2019 20:25:48 +0000 [thread overview]
Message-ID: <pull.474.v2.git.1574627149.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.474.git.1574538937.gitgitgadget@gmail.com>
This allows passing a tree-ish git reset -p without specifying a pathspec.
Requiring a commit in this situation appears to be an oversight, and support
for a tree-ish is documented by git-reset's manpage. (
https://github.com/git/git/blob/d9f6f3b6195a0ca35642561e530798ad1469bd41/Documentation/git-reset.txt#L12
)
An alternative implementation of this change would move the if (patch_mode)
{ ... return; } check before the rev parsing logic, offloading validation of
the rev argument when in patch mode to the git-add--interactive logic. This
would be possible as the parsed oid is not passed to git-add--interactive. (
https://github.com/git/git/blob/d9f6f3b6195a0ca35642561e530798ad1469bd41/builtin/reset.c#L341-L346
)
Nika Layzell (1):
reset: parse rev as tree-ish in patch mode
builtin/reset.c | 2 +-
t/t7105-reset-patch.sh | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
base-commit: 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-474%2Fmystor%2Freset-interactive-treeish-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-474/mystor/reset-interactive-treeish-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/474
Range-diff vs v1:
1: 338c2777f7 ! 1: a608dc8368 reset: parse rev as tree-ish in patch mode
@@ -2,12 +2,22 @@
reset: parse rev as tree-ish in patch mode
- Relaxes the commit requirement for the rev argument when running
- git-reset in patch mode without pathspec.
+ Since 2f328c3d ("reset $sha1 $pathspec: require $sha1 only to be
+ treeish", 2013-01-14), we allowed "git reset $object -- $path" to reset
+ individual paths that match the pathspec to take the blob from a tree
+ object, not necessarily a commit, while the form to reset the tip of the
+ current branch to some other commit still must be given a commit.
- 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.
+ Like resetting with paths, "git reset --patch" does not update HEAD, and
+ need not require a commit. The path-filtered form, "git reset --patch
+ $object -- $pathspec", has accepted a tree-ish since 2f328c3d.
+
+ "git reset --patch" is documented as accepting a <tree-ish> since
+ bf44142f ("reset: update documentation to require only tree-ish with
+ paths", 2013-01-16). Documentation changes are not required.
+
+ Loosen the restriction that requires a commit for the unfiltered "git
+ reset --patch $object".
Signed-off-by: Nika Layzell <nika@thelayzells.com>
@@ -37,6 +47,20 @@
+ verify_saved_state bar &&
+ test_i18ngrep "Apply" output
+'
++
++test_expect_success PERL 'git reset -p HEAD^:dir/foo (blob fails)' '
++ set_and_save_state dir/foo work work &&
++ test_must_fail git reset -p HEAD^:dir/foo &&
++ verify_saved_state dir/foo &&
++ verify_saved_state bar
++'
++
++test_expect_success PERL 'git reset -p aaaaaaaa (unknown fails)' '
++ set_and_save_state dir/foo work work &&
++ test_must_fail git reset -p aaaaaaaa &&
++ verify_saved_state dir/foo &&
++ verify_saved_state bar
++'
+
# 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
--
gitgitgadget
next prev parent reply other threads:[~2019-11-24 20:25 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 ` [PATCH 1/1] " Nika Layzell via GitGitGadget
2019-11-24 5:54 ` Junio C Hamano
2019-11-24 18:31 ` Nika Layzell
2019-11-25 1:58 ` Junio C Hamano
2019-11-24 20:25 ` Nika Layzell via GitGitGadget [this message]
2019-11-24 20:25 ` [PATCH v2 " 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=pull.474.v2.git.1574627149.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).