Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNika Layzell <nika@thelayzells.com>2019-11-24 23:25:49 +0300
committerJunio C Hamano <gitster@pobox.com>2019-11-25 05:01:22 +0300
commit0a8e3036a304d99de24432d65a3d3920dd6e2e46 (patch)
tree86f62e83756ab1e1b94c49f2e6201b1b952ec8e9 /t/t7105-reset-patch.sh
parentd9f6f3b6195a0ca35642561e530798ad1469bd41 (diff)
reset: parse rev as tree-ish in patch mode
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7105-reset-patch.sh')
-rwxr-xr-xt/t7105-reset-patch.sh21
1 files changed, 21 insertions, 0 deletions
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
+'
+
# 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