Skip to content

Commit

Permalink
builtin-fmt-merge-msg: fix bugs in --file option
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Coleman authored and Junio C Hamano committed Feb 28, 2007
1 parent a91d49c commit 163d7b9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtin-fmt-merge-msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
else if (!strcmp(argv[1], "--no-summary"))
merge_summary = 0;
else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
if (argc < 2)
if (argc < 3)
die ("Which file?");
if (!strcmp(argv[2], "-"))
in = stdin;
else {
fclose(in);
in = fopen(argv[2], "r");
if (!in)
die("cannot open %s", argv[2]);
}
argc--; argv++;
} else
Expand Down

0 comments on commit 163d7b9

Please sign in to comment.