Skip to content

Commit 2b06b0a

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 902f235 commit 2b06b0a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

builtin-reset.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
291291
die("%s reset requires a work tree",
292292
reset_type_names[reset_type]);
293293

294+
if (reset_type == MIXED && is_bare_repository())
295+
die("%s reset is not allowed in a bare repository",
296+
reset_type_names[reset_type]);
297+
294298
/* Soft reset does not touch the index file nor the working tree
295299
* at all, but requires them in a good order. Other resets reset
296300
* the index file to the tree object we are switching to. */

0 commit comments

Comments
 (0)