@matheusbsbs / matheus-bagliano / commits / a429d2dd76
Fork 0

read-tree: convert unhelpful usage()'s to helpful die()'s

Printing the usage message when encountering bad option combinations is not very helpful. Instead, die with a message which tells the user exactly what combination is invalid. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Jun 25, 2009 at 22:14 UTC a429d2dd76c81cb52fb17463821a457e541637ce
1 file changed +3 -3
builtin-read-tree.c
+3 -3
@@ -145,9 +145,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
145 continue;
146 }
147
148 - /* using -u and -i at the same time makes no sense */
148 if (1 < opts.index_only + opts.update)
150 - usage(read_tree_usage);
149 + die("-u and -i at the same time makes no sense");
150
151 if (get_sha1(arg, sha1))
152 die("Not a valid object name %s", arg);
@@ -156,7 +155,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
155 stage++;
156 }
157 if ((opts.update||opts.index_only) && !opts.merge)
159 - usage(read_tree_usage);
158 + die("%s is meaningless without -m, --reset, or --prefix",
159 + opts.update ? "-u" : "-i");
160 if ((opts.dir && !opts.update))
161 die("--exclude-per-directory is meaningless unless -u");
162 if (opts.merge && !opts.index_only)