diff options
Diffstat (limited to 'builtin/reset.c')
-rw-r--r-- | builtin/reset.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/builtin/reset.c b/builtin/reset.c index 4b018d2..1d62ff6 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -16,10 +16,8 @@ #include "hash.h" #include "hex.h" #include "lockfile.h" -#include "tag.h" #include "object.h" #include "pretty.h" -#include "run-command.h" #include "refs.h" #include "diff.h" #include "diffcore.h" @@ -33,7 +31,6 @@ #include "setup.h" #include "sparse-index.h" #include "submodule.h" -#include "submodule-config.h" #include "trace.h" #include "trace2.h" #include "dir.h" @@ -119,6 +116,10 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t if (reset_type == MIXED || reset_type == HARD) { tree = parse_tree_indirect(oid); + if (!tree) { + error(_("unable to read tree (%s)"), oid_to_hex(oid)); + goto out; + } prime_cache_tree(the_repository, the_repository->index, tree); } @@ -284,7 +285,9 @@ static void parse_args(struct pathspec *pathspec, verify_filename(prefix, argv[0], 1); } } - *rev_ret = rev; + + /* treat '@' as a shortcut for 'HEAD' */ + *rev_ret = !strcmp("@", rev) ? "HEAD" : rev; parse_pathspec(pathspec, 0, PATHSPEC_PREFER_FULL | |