git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v6 1/4] reset: improve mixed reset error message when in a bare repo

From
Christian Couder <chriscool@tuxfamily.org>
Date
Dec 30, 2009, 05:54 UTC
Message-ID
<20091230055448.4475.94394.chriscool@tuxfamily.org>
In-Reply-To
<20091230055008.4475.95755.chriscool@tuxfamily.org>

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>
---
 builtin-reset.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/builtin-reset.c b/builtin-reset.c
index 11d1c6e..3180c2b 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. */
-- 
1.6.6.rc2.5.g49666
Previous: Christian CouderNext: Christian Couder
Message 2 of 14 in “"git reset --merge" related improvements”
  1. 0/4 "git reset --merge" related improvementsChristian Couder, Dec 30, 2009
  2. 1/4 reset: improve mixed reset error message when in a bare repoChristian Couder, Dec 30, 2009
  3. 2/4 Documentation: reset: add some tables to describe the different optionsChristian Couder, Dec 30, 2009
  4. Junio C HamanoJan 1, 2010
  5. Christian CouderJan 2, 2010
  6. 3/4 reset: add a few tests for "git reset --merge"Christian Couder, Dec 30, 2009
  7. Junio C HamanoJan 1, 2010
  8. Christian CouderJan 2, 2010
  9. 4/4 reset: use "unpack_trees()" directly instead of "git read-tree"Christian Couder, Dec 30, 2009
  10. Junio C HamanoJan 1, 2010
  11. Junio C HamanoJan 1, 2010
  12. Christian CouderJan 2, 2010
  13. Linus TorvaldsJan 1, 2010
  14. Junio C HamanoJan 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.