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

[PATCH] read-tree: abort if no trees are given

From
Jan Krüger <jk@jk.gs>
Date
Sep 10, 2010, 10:06 UTC
Message-ID
<20100910120604.50aa1e94@jk.gs>

Currently, read-tree silently accepts an invocation without any tree-ishs given and simply clobbers the index in that case. This contradicts the usage synopsis and it's also probably not what anyone would want to happen. So, instead, abort with a fatal error.

Signed-off-by: Jan Krüger <jk@jk.gs>
---
Someone in #git got confused by this.
 builtin/read-tree.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 9ad1e66..67eb08e 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -166,6 +166,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 			die("failed to unpack tree object %s", arg);
 		stage++;
 	}
+	if (nr_trees == 0)
+		die("no trees specified to read");
 	if (1 < opts.index_only + opts.update)
 		die("-u and -i at the same time makes no sense");
 	if ((opts.update||opts.index_only) && !opts.merge)
-- 
1.7.2.3.392.g02377.dirty
Next: Johannes Sixt
Message 1 of 5 in “read-tree: abort if no trees are given”
  1. read-tree: abort if no trees are givenJan Krüger, Sep 10, 2010
  2. Johannes SixtSep 10, 2010
  3. read-tree: deprecate syntax without tree-ish argsJan Krüger, Sep 10, 2010
  4. Sverre RabbelierSep 10, 2010
  5. Junio C HamanoSep 10, 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.