@matheusbsbs / matheus-bagliano / commits / 86af2caa5a
Fork 0

builtin-replace: use "usage_msg_opt" to give better error messages

Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Feb 2, 2009 at 06:13 UTC 86af2caa5ac322b1ebda8b4f0aceb9dfafe3e5ba
1 file changed +12 -6
builtin-replace.c
+12 -6
@@ -124,30 +124,36 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
124 argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
125
126 if (list && delete)
127 - usage_with_options(git_replace_usage, options);
127 + usage_msg_opt("-l and -d cannot be used together",
128 + git_replace_usage, options);
129
130 if (force && (list || delete))
130 - usage_with_options(git_replace_usage, options);
131 + usage_msg_opt("-f cannot be used with -d or -l",
132 + git_replace_usage, options);
133
134 /* Delete refs */
135 if (delete) {
136 if (argc < 1)
135 - usage_with_options(git_replace_usage, options);
137 + usage_msg_opt("-d needs at least one argument",
138 + git_replace_usage, options);
139 return for_each_replace_name(argv, delete_replace_ref);
140 }
141
142 /* Replace object */
143 if (!list && argc) {
144 if (argc != 2)
142 - usage_with_options(git_replace_usage, options);
145 + usage_msg_opt("bad number of arguments",
146 + git_replace_usage, options);
147 return replace_object(argv[0], argv[1], force);
148 }
149
150 /* List refs, even if "list" is not set */
151 if (argc > 1)
148 - usage_with_options(git_replace_usage, options);
152 + usage_msg_opt("only one pattern can be given with -l",
153 + git_replace_usage, options);
154 if (force)
150 - usage_with_options(git_replace_usage, options);
155 + usage_msg_opt("-f needs some arguments",
156 + git_replace_usage, options);
157
158 return list_replace_refs(argv[0]);
159 }