@matheusbsbs / matheus-bagliano / commits / 163d7b9b85
Fork 0

builtin-fmt-merge-msg: fix bugs in --file option

If --file's argument is missing, don't crash. If it cannot be opened, die with an error message. Signed-off-by: Junio C Hamano <junkio@cox.net>

Michael Coleman committed Feb 27, 2007 at 23:44 UTC 163d7b9b8536d206eda7eb0eccb0fc211812346f
1 file changed +3 -1
builtin-fmt-merge-msg.c
+3 -1
@@ -259,13 +259,15 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
259 else if (!strcmp(argv[1], "--no-summary"))
260 merge_summary = 0;
261 else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
262 - if (argc < 2)
262 + if (argc < 3)
263 die ("Which file?");
264 if (!strcmp(argv[2], "-"))
265 in = stdin;
266 else {
267 fclose(in);
268 in = fopen(argv[2], "r");
269 + if (!in)
270 + die("cannot open %s", argv[2]);
271 }
272 argc--; argv++;
273 } else