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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]