# [PATCH/RFC] feeding Maildir to git-am

2 messages from 2008-08-20 to 2008-08-20. Participants: Junio C Hamano, Jeff King.
Thread: https://gitlist.dev/t/15102

## Junio C Hamano, 2008-08-20 05:25

Subject: [PATCH/RFC] feeding Maildir to git-am
Message-ID: <7vbpzotfyy.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vbpzotfyy.fsf%40gitster.siamese.dyndns.org

```
I do not use Maildir myself but people who do not know how Maildir look
like (including myself) would be left wondering why there is even no error
message when giving a random directory full of format-patch output to am.

I am wondering if something like this would be helpful...

 builtin-mailsplit.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git i/builtin-mailsplit.c w/builtin-mailsplit.c
index 71f3b3b..829abbb 100644
--- i/builtin-mailsplit.c
+++ w/builtin-mailsplit.c
@@ -122,16 +122,17 @@ static int populate_maildir_list(struct string_list *list, const char *path)
 	char name[PATH_MAX];
 	char *subs[] = { "cur", "new", NULL };
 	char **sub;
+	int found = 0;
 
 	for (sub = subs; *sub; ++sub) {
 		snprintf(name, sizeof(name), "%s/%s", path, *sub);
 		if ((dir = opendir(name)) == NULL) {
 			if (errno == ENOENT)
 				continue;
-			error("cannot opendir %s (%s)", name, strerror(errno));
-			return -1;
+			return error("cannot opendir %s (%s)", name, strerror(errno));
 		}
 
+		found = 1;
 		while ((dent = readdir(dir)) != NULL) {
 			if (dent->d_name[0] == '.')
 				continue;
@@ -142,6 +143,8 @@ static int populate_maildir_list(struct string_list *list, const char *path)
 		closedir(dir);
 	}
 
+	if (!found)
+		return error("'%s' is not a Maildir (no 'cur' nor 'new' found)", path);
 	return 0;
 }
 

```

## Jeff King, 2008-08-20 13:03

Subject: Re: [PATCH/RFC] feeding Maildir to git-am
Message-ID: <20080820130342.GA6602@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20080820130342.GA6602%40coredump.intra.peff.net
In-Reply-To: <7vbpzotfyy.fsf@gitster.siamese.dyndns.org>

```
On Tue, Aug 19, 2008 at 10:25:57PM -0700, Junio C Hamano wrote:

> I do not use Maildir myself but people who do not know how Maildir look
> like (including myself) would be left wondering why there is even no error
> message when giving a random directory full of format-patch output to am.

I don't use maildirs with git, but I have worked with them in the past,
and I think your patch is definitely an improvement.

However, I wonder if we could go one step further and just DWYM: if a
directory has "cur" or "new", treat it like a maildir (IOW, look in
there for patches), but otherwise treat it like a directory of
format-patch output.

-Peff

```
