git-mailsplit: with maildirs not only process cur/, but also new/
When saving patches to a maildir with e.g. mutt, the files are put into the new/ subdirectory of the maildir, not cur/. This makes git-am state "Nothing to do.". This patch lets git-mailsplit additional check new/ after reading cur/. This was reported by Joey Hess through http://bugs.debian.org/447396 Signed-off-by: Gerrit Pape <pape@smarden.org> Acked-by: Jeff King <peff@peff.net> Acked-by: Alex Riesen <raa.lkml@gmail.com> Acked-by: Fernando J. Pereda <ferdy@gentoo.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
6d0618a820
commit
d50a4bc4e9
@ -101,20 +101,29 @@ static int populate_maildir_list(struct path_list *list, const char *path)
|
|||||||
{
|
{
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
|
char name[PATH_MAX];
|
||||||
|
char *subs[] = { "cur", "new", NULL };
|
||||||
|
char **sub;
|
||||||
|
|
||||||
if ((dir = opendir(path)) == NULL) {
|
for (sub = subs; *sub; ++sub) {
|
||||||
error("cannot opendir %s (%s)", path, strerror(errno));
|
snprintf(name, sizeof(name), "%s/%s", path, *sub);
|
||||||
return -1;
|
if ((dir = opendir(name)) == NULL) {
|
||||||
|
if (errno == ENOENT)
|
||||||
|
continue;
|
||||||
|
error("cannot opendir %s (%s)", name, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((dent = readdir(dir)) != NULL) {
|
||||||
|
if (dent->d_name[0] == '.')
|
||||||
|
continue;
|
||||||
|
snprintf(name, sizeof(name), "%s/%s", *sub, dent->d_name);
|
||||||
|
path_list_insert(name, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((dent = readdir(dir)) != NULL) {
|
|
||||||
if (dent->d_name[0] == '.')
|
|
||||||
continue;
|
|
||||||
path_list_insert(dent->d_name, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dir);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,19 +131,17 @@ static int split_maildir(const char *maildir, const char *dir,
|
|||||||
int nr_prec, int skip)
|
int nr_prec, int skip)
|
||||||
{
|
{
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
char curdir[PATH_MAX];
|
|
||||||
char name[PATH_MAX];
|
char name[PATH_MAX];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int i;
|
int i;
|
||||||
struct path_list list = {NULL, 0, 0, 1};
|
struct path_list list = {NULL, 0, 0, 1};
|
||||||
|
|
||||||
snprintf(curdir, sizeof(curdir), "%s/cur", maildir);
|
if (populate_maildir_list(&list, maildir) < 0)
|
||||||
if (populate_maildir_list(&list, curdir) < 0)
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for (i = 0; i < list.nr; i++) {
|
for (i = 0; i < list.nr; i++) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
snprintf(file, sizeof(file), "%s/%s", curdir, list.items[i].path);
|
snprintf(file, sizeof(file), "%s/%s", maildir, list.items[i].path);
|
||||||
f = fopen(file, "r");
|
f = fopen(file, "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
error("cannot open mail %s (%s)", file, strerror(errno));
|
error("cannot open mail %s (%s)", file, strerror(errno));
|
||||||
@ -152,10 +159,9 @@ static int split_maildir(const char *maildir, const char *dir,
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
path_list_clear(&list, 1);
|
|
||||||
|
|
||||||
ret = skip;
|
ret = skip;
|
||||||
out:
|
out:
|
||||||
|
path_list_clear(&list, 1);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user