aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2009-12-30 06:54:44 +0100
committerJunio C Hamano <gitster@pobox.com>2009-12-30 01:09:43 -0800
commit2b06b0a02f8d0aa01c8ff19b72c9292afd7a84fe (patch)
tree063e6ade320dd09677790b9d12824b5876dec08f
parent902f235378cb2b2f6dd5dd664b9630c95321f0ae (diff)
downloadgit-2b06b0a02f8d0aa01c8ff19b72c9292afd7a84fe.tar.gz
git-2b06b0a02f8d0aa01c8ff19b72c9292afd7a84fe.tar.xz
reset: improve mixed reset error message when in a bare repo
When running a "git reset --mixed" in a bare repository, the message displayed is something like: fatal: This operation must be run in a work tree fatal: Could not reset index file to revision 'HEAD^'. This message is a little bit misleading because a mixed reset is ok in a git directory, so it is not absolutely needed to run it in a work tree. So this patch improves upon the above by changing the message to: fatal: mixed reset is not allowed in a bare repository And if "git reset" is ever sped up by using unpack_tree() directly (instead of execing "git read-tree"), this patch will also make sure that a mixed reset is still disallowed in a bare repository. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-reset.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin-reset.c b/builtin-reset.c
index 11d1c6e4d..3180c2b58 100644
--- a/builtin-reset.c
+++ b/builtin-reset.c
@@ -291,6 +291,10 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
die("%s reset requires a work tree",
reset_type_names[reset_type]);
+ if (reset_type == MIXED && is_bare_repository())
+ die("%s reset is not allowed in a bare repository",
+ reset_type_names[reset_type]);
+
/* Soft reset does not touch the index file nor the working tree
* at all, but requires them in a good order. Other resets reset
* the index file to the tree object we are switching to. */