diff options
Diffstat (limited to 'builtin/mailsplit.c')
-rw-r--r-- | builtin/mailsplit.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c index 664400b..3af9ddb 100644 --- a/builtin/mailsplit.c +++ b/builtin/mailsplit.c @@ -4,8 +4,8 @@ * It just splits a mbox into a list of files: "0001" "0002" .. * so you can process them further from there. */ -#include "cache.h" #include "builtin.h" +#include "gettext.h" #include "string-list.h" #include "strbuf.h" @@ -75,9 +75,7 @@ static int split_one(FILE *mbox, const char *name, int allow_bare) fprintf(stderr, "corrupt mailbox\n"); exit(1); } - fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666); - if (fd < 0) - die_errno("cannot open output file '%s'", name); + fd = xopen(name, O_WRONLY | O_CREAT | O_EXCL, 0666); output = xfdopen(fd, "w"); /* Copy it out, while searching for a line that begins with @@ -122,7 +120,7 @@ static int populate_maildir_list(struct string_list *list, const char *path) for (sub = subs; *sub; ++sub) { free(name); name = xstrfmt("%s/%s", path, *sub); - if ((dir = opendir(name)) == NULL) { + if (!(dir = opendir(name))) { if (errno == ENOENT) continue; error_errno("cannot opendir %s", name); @@ -225,6 +223,9 @@ static int split_mbox(const char *file, const char *dir, int allow_bare, FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r"); int file_done = 0; + if (isatty(fileno(f))) + warning(_("reading patches from stdin/tty...")); + if (!f) { error_errno("cannot open mbox %s", file); goto out; @@ -276,6 +277,8 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix) const char **argp; static const char *stdin_only[] = { "-", NULL }; + BUG_ON_NON_EMPTY_PREFIX(prefix); + for (argp = argv+1; *argp; argp++) { const char *arg = *argp; |