Merge branch 'nl/reset-patch-takes-a-tree'
"git reset --patch $object" without any pathspec should allow a tree object to be given, but incorrectly required a committish, which has been corrected. * nl/reset-patch-takes-a-tree: reset: parse rev as tree-ish in patch mode
This commit is contained in:
commit
6b3cb32f43
@ -320,7 +320,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
|||||||
if (unborn) {
|
if (unborn) {
|
||||||
/* reset on unborn branch: treat as reset to empty tree */
|
/* reset on unborn branch: treat as reset to empty tree */
|
||||||
oidcpy(&oid, the_hash_algo->empty_tree);
|
oidcpy(&oid, the_hash_algo->empty_tree);
|
||||||
} else if (!pathspec.nr) {
|
} else if (!pathspec.nr && !patch_mode) {
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
if (get_oid_committish(rev, &oid))
|
if (get_oid_committish(rev, &oid))
|
||||||
die(_("Failed to resolve '%s' as a valid revision."), rev);
|
die(_("Failed to resolve '%s' as a valid revision."), rev);
|
||||||
|
@ -38,6 +38,27 @@ test_expect_success PERL 'git reset -p HEAD^' '
|
|||||||
test_i18ngrep "Apply" output
|
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'
|
# 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
|
# 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
|
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
|
||||||
|
Loading…
Reference in New Issue
Block a user