git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] feeding Maildir to git-am
@ 2008-08-20  5:25 Junio C Hamano
  2008-08-20 13:03 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Junio C Hamano @ 2008-08-20  5:25 UTC (permalink / raw)
  To: git

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;
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH/RFC] feeding Maildir to git-am
  2008-08-20  5:25 [PATCH/RFC] feeding Maildir to git-am Junio C Hamano
@ 2008-08-20 13:03 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2008-08-20 13:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-20 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-20  5:25 [PATCH/RFC] feeding Maildir to git-am Junio C Hamano
2008-08-20 13:03 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).