summaryrefslogtreecommitdiff
path: root/builtin/reset.c
diff options
context:
space:
mode:
authorNika Layzell <nika@thelayzells.com>2019-11-24 20:25:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-25 02:01:22 (GMT)
commit0a8e3036a304d99de24432d65a3d3920dd6e2e46 (patch)
tree86f62e83756ab1e1b94c49f2e6201b1b952ec8e9 /builtin/reset.c
parentd9f6f3b6195a0ca35642561e530798ad1469bd41 (diff)
downloadgit-0a8e3036a304d99de24432d65a3d3920dd6e2e46.zip
git-0a8e3036a304d99de24432d65a3d3920dd6e2e46.tar.gz
git-0a8e3036a304d99de24432d65a3d3920dd6e2e46.tar.bz2
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 'builtin/reset.c')
-rw-r--r--builtin/reset.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/reset.c b/builtin/reset.c
index fdd5721..5cbfb21 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);