aboutsummaryrefslogtreecommitdiff
path: root/builtin/reset.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-07-03 10:04:22 -0700
committerJunio C Hamano <gitster@pobox.com>2012-07-09 16:42:23 -0700
commit13243c2c7a758bb6510ba26d0372f384b5f422ce (patch)
treeed04f6f91f46ec6049d3255deb50d3f2a7054758 /builtin/reset.c
parent75f5ac04a2984fcf1e4d167047bfb63c5f385d44 (diff)
downloadgit-13243c2c7a758bb6510ba26d0372f384b5f422ce.tar.gz
git-13243c2c7a758bb6510ba26d0372f384b5f422ce.tar.xz
reset: the command takes committish
This is not strictly correct, in that resetting selected index entries from corresponding paths out of a given tree without moving HEAD is a valid operation, and in such case a tree-ish would suffice. But the existing code already requires a committish in the codepath, so let's be consistent with it for now. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/reset.c')
-rw-r--r--builtin/reset.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin/reset.c b/builtin/reset.c
index 8c2c1d52a..392fb6361 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -276,7 +276,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
* Otherwise, argv[i] could be either <rev> or <paths> and
* has to be unambiguous.
*/
- else if (!get_sha1(argv[i], sha1)) {
+ else if (!get_sha1_committish(argv[i], sha1)) {
/*
* Ok, argv[i] looks like a rev; it should not
* be a filename.
@@ -289,9 +289,15 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
}
}
- if (get_sha1(rev, sha1))
+ if (get_sha1_committish(rev, sha1))
die(_("Failed to resolve '%s' as a valid ref."), rev);
+ /*
+ * NOTE: As "git reset $treeish -- $path" should be usable on
+ * any tree-ish, this is not strictly correct. We are not
+ * moving the HEAD to any commit; we are merely resetting the
+ * entries in the index to that of a treeish.
+ */
commit = lookup_commit_reference(sha1);
if (!commit)
die(_("Could not parse object '%s'."), rev);