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

[PATCH 2/2] read-tree: at least one tree-ish argument is required

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Dec 15, 2009, 08:43 UTC
Message-ID
<4B274C3A.4060808@viscovery.net>
In-Reply-To
<4B274BDE.8000504@viscovery.net>
From: Johannes Sixt <j6t@kdbg.org>

Previously, it was possible to run read-tree without any arguments, whereupon it purged the index!

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 Discovered by typing
   git ..daab02
 with help.autocorrect > 0 :-)
 -- Hannes
 builtin-read-tree.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 50413ca..31623b9 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -125,6 +125,9 @@ int cmd_read_tree(int argc, const char **argv,
 		stage = opts.merge = 1;
 	}

+	if (argc == 0)
+		usage_with_options(read_tree_usage, read_tree_options);
+
 	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
-- 
1.6.6.rc1.46.g1635
Previous: Johannes SixtNext: Johannes Sixt
Message 2 of 21 in “filter-branch: remove an unnecessary use of 'git read-tree'”
  1. 1/2 filter-branch: remove an unnecessary use of 'git read-tree'Johannes Sixt, Dec 15, 2009
  2. 2/2 read-tree: at least one tree-ish argument is requiredJohannes Sixt, Dec 15, 2009
  3. Johannes SixtDec 18, 2009
  4. Junio C HamanoDec 18, 2009
  5. Johannes SixtDec 18, 2009
  6. Sverre RabbelierDec 18, 2009
  7. Junio C HamanoDec 18, 2009
  8. Sverre RabbelierDec 18, 2009
  9. Junio C HamanoDec 18, 2009
  10. Sverre RabbelierDec 18, 2009
  11. Junio C HamanoDec 18, 2009
  12. Sverre RabbelierDec 18, 2009
  13. Johannes SixtDec 18, 2009
  14. Jakub NarebskiDec 18, 2009
  15. Junio C HamanoDec 18, 2009
  16. Nanako ShiraishiDec 19, 2009
  17. Junio C HamanoDec 19, 2009
  18. Junio C HamanoDec 19, 2009
  19. Johannes SchindelinDec 19, 2009
  20. Johannes SchindelinDec 15, 2009
  21. Junio C HamanoDec 16, 2009

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.