git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/1] reset: parse rev as tree-ish in patch mode

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 25, 2019, 02:03 UTC
Message-ID
<xmqq7e3ozp97.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<a608dc8368c6fc738393dac46618f12e25d40eaf.1574627149.git.gitgitgadget@gmail.com>
"Nika Layzell via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 21 quoted lines
> From: Nika Layzell <nika@thelayzells.com>
>
> 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.
>
> 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>
> ---
Nicely explained.
Show 28 quoted lines
> diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh
> index bd10a96727..fc2a6cf5c7 100755
> --- a/t/t7105-reset-patch.sh
> +++ b/t/t7105-reset-patch.sh
> @@ -38,6 +38,27 @@ 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
> +'
> +
> +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
> +'
Thanks, will queue.
Previous: Nika Layzell via GitGitGadget
Message 8 of 8 in “reset: parse rev as tree-ish in patch mode”
  1. 0/1 reset: parse rev as tree-ish in patch modeNika Layzell via GitGitGadget, Nov 23, 2019
  2. 1/1 reset: parse rev as tree-ish in patch modeNika Layzell via GitGitGadget, Nov 23, 2019
  3. Junio C HamanoNov 24, 2019
  4. Nika LayzellNov 24, 2019
  5. Junio C HamanoNov 25, 2019
  6. 0/1 reset: parse rev as tree-ish in patch modeNika Layzell via GitGitGadget, Nov 24, 2019
  7. 1/1 reset: parse rev as tree-ish in patch modeNika Layzell via GitGitGadget, Nov 24, 2019
  8. Junio C HamanoNov 25, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.