Improved patch and nmudiff documenting the new option in mairixrc(5). -- Sean Whitton
diff -Nru mairix-0.23+git20131125/debian/changelog mairix-0.23+git20131125/debian/changelog --- mairix-0.23+git20131125/debian/changelog 2015-09-10 14:23:34.000000000 -0700 +++ mairix-0.23+git20131125/debian/changelog 2016-03-24 11:51:17.000000000 -0700 @@ -1,3 +1,12 @@ +mairix (0.23+git20131125-0.5) unstable; urgency=medium + + * Non-maintainer upload. + * Add Option-to-follow-symlinks-to-mboxes-in-rc-file.patch to allow the + user to restore mairix's old behaviour of following symlinks to + mboxes. Closes: #819127 + + -- Sean Whitton <spwhit...@spwhitton.name> Thu, 24 Mar 2016 11:51:15 -0700 + mairix (0.23+git20131125-0.4) unstable; urgency=medium * Non-maintainer upload. diff -Nru mairix-0.23+git20131125/debian/patches/Option-to-follow-symlinks-to-mboxes-in-rc-file.patch mairix-0.23+git20131125/debian/patches/Option-to-follow-symlinks-to-mboxes-in-rc-file.patch --- mairix-0.23+git20131125/debian/patches/Option-to-follow-symlinks-to-mboxes-in-rc-file.patch 1969-12-31 17:00:00.000000000 -0700 +++ mairix-0.23+git20131125/debian/patches/Option-to-follow-symlinks-to-mboxes-in-rc-file.patch 2016-03-24 11:49:25.000000000 -0700 @@ -0,0 +1,130 @@ +From: Sean Whitton <spwhit...@spwhitton.name> +Date: Wed, 23 Mar 2016 17:18:47 -0700 +Subject: Option to follow symlinks to mboxes in rc file +Forwarded: https://github.com/rc0/mairix/pull/20 + +Add .mairixrc option "follow_mbox_symlinks" which allows the user to +restore the behaviour disabled by commit 74ebca5. + +This is particularly useful for users of git-annex. It is possible to +work around mairix's symlink-skipping behaviour [1], but a simple +configuration file option to restore the old behaviour is much more +practical. + +This patch does not change the default behaviour of mairix for users who +do not explicitly include "follow_mbox_symlinks" in their .mairixrc. + +[1] https://joeyh.name/blog/entry/moving_my_email_archives_and_packages_to_git-annex/ +--- + mairix.c | 9 ++++++++- + mairix.h | 3 ++- + mairixrc.5 | 8 ++++++++ + mbox.c | 7 ++++--- + 4 files changed, 22 insertions(+), 5 deletions(-) + +diff --git a/mairix.c b/mairix.c +index 09f255b..2ef6a62 100644 +--- a/mairix.c ++++ b/mairix.c +@@ -51,6 +51,7 @@ static char *omit = NULL; + static char *database_path = NULL; + static enum folder_type output_folder_type = FT_MAILDIR; + static int skip_integrity_checks = 0; ++static int follow_mbox_symlinks = 0; + + enum filetype { + M_NONE, M_FILE, M_DIR, M_OTHER +@@ -249,6 +250,7 @@ static void parse_rc_file(char *name)/*{{{*/ + } + else if (!strncasecmp(p, "mh=", 3)) add_folders(&mh_folders, copy_value(p)); + else if (!strncasecmp(p, "mbox=", 5)) add_folders(&mboxen, copy_value(p)); ++ else if (!strncasecmp(p, "follow_mbox_symlinks", 20)) follow_mbox_symlinks = 1; + else if (!strncasecmp(p, "omit=", 5)) add_folders(&omit, copy_value(p)); + + else if (!strncasecmp(p, "mformat=", 8)) { +@@ -490,6 +492,7 @@ int main (int argc, char **argv)/*{{{*/ + int do_integrity_checks = 1; + int do_forced_unlock = 0; + int do_fast_index = 0; ++ int do_mbox_symlinks = 0; + + unsigned int forced_hash_key = CREATE_RANDOM_DATABASE_HASH; + +@@ -617,6 +620,10 @@ int main (int argc, char **argv)/*{{{*/ + do_integrity_checks = 0; + } + ++ if (follow_mbox_symlinks) { ++ do_mbox_symlinks = 1; ++ } ++ + if (!folder_base) { + fprintf(stderr, "No folder_base/MAIRIX_FOLDER_BASE set\n"); + exit(2); +@@ -746,7 +753,7 @@ int main (int argc, char **argv)/*{{{*/ + unlock_and_exit(2); + } + +- build_mbox_lists(db, folder_base, mboxen, omit_globs); ++ build_mbox_lists(db, folder_base, mboxen, omit_globs, do_mbox_symlinks); + + any_updates = update_database(db, msgs->paths, msgs->n, do_fast_index); + if (do_purge) { +diff --git a/mairix.h b/mairix.h +index 2480492..b05c1c6 100644 +--- a/mairix.h ++++ b/mairix.h +@@ -357,7 +357,8 @@ int cull_dead_messages(struct database *db, int do_integrity_checks); + + /* In mbox.c */ + void build_mbox_lists(struct database *db, const char *folder_base, +- const char *mboxen_paths, struct globber_array *omit_globs); ++ const char *mboxen_paths, struct globber_array *omit_globs, ++ int do_mbox_symlinks); + int add_mbox_messages(struct database *db); + void compute_checksum(const char *data, size_t len, checksum_t *csum); + void cull_dead_mboxen(struct database *db); +diff --git a/mairixrc.5 b/mairixrc.5 +index b25dead..9dc4ef5 100644 +--- a/mairixrc.5 ++++ b/mairixrc.5 +@@ -358,6 +358,14 @@ relative to the location of the + .I mairixrc + file or anything like that.) + ++.TP ++.BI follow_mbox_symlinks ++.br ++This takes no arguments. By default, mairix will skip symlinks to ++mboxes when indexing. If a line starting with ++.B follow_mbox_symlinks ++is present, mairix will follow them instead of skipping them. ++ + .SS Expansions + + The part of each line in '.mairixrc' following the equals sign can +diff --git a/mbox.c b/mbox.c +index ebbfa78..f8bed26 100644 +--- a/mbox.c ++++ b/mbox.c +@@ -743,7 +743,8 @@ void glob_and_expand_paths(const char *folder_base, + /*}}}*/ + + void build_mbox_lists(struct database *db, const char *folder_base, /*{{{*/ +- const char *mboxen_paths, struct globber_array *omit_globs) ++ const char *mboxen_paths, struct globber_array *omit_globs, ++ int do_mbox_symlinks) + { + char **raw_paths, **paths; + int n_raw_paths, i; +@@ -776,8 +777,8 @@ void build_mbox_lists(struct database *db, const char *folder_base, /*{{{*/ + if (lstat(path, &sb) < 0) { + /* can't stat */ + } else { +- if (S_ISLNK(sb.st_mode)) { +- /* Skip mbox if symlink */ ++ if (S_ISLNK(sb.st_mode) && !do_mbox_symlinks) { ++ /* Skip mbox if symlink and no follow_mbox_symlinks in mairixrc */ + if (verbose) { + printf("%s is a link - skipping\n", path); + } diff -Nru mairix-0.23+git20131125/debian/patches/series mairix-0.23+git20131125/debian/patches/series --- mairix-0.23+git20131125/debian/patches/series 2015-09-10 14:24:21.000000000 -0700 +++ mairix-0.23+git20131125/debian/patches/series 2016-03-24 11:49:41.000000000 -0700 @@ -1,3 +1,4 @@ #fix-test-suite.patch fix-search-with-equal-in-msgid.patch fix-256-char-limit-on-filenames.patch +Option-to-follow-symlinks-to-mboxes-in-rc-file.patch
From: Sean Whitton <spwhit...@spwhitton.name> Date: Wed, 23 Mar 2016 17:18:47 -0700 Subject: Option to follow symlinks to mboxes in rc file Forwarded: https://github.com/rc0/mairix/pull/20
Add .mairixrc option "follow_mbox_symlinks" which allows the user to restore the behaviour disabled by commit 74ebca5. This is particularly useful for users of git-annex. It is possible to work around mairix's symlink-skipping behaviour [1], but a simple configuration file option to restore the old behaviour is much more practical. This patch does not change the default behaviour of mairix for users who do not explicitly include "follow_mbox_symlinks" in their .mairixrc. [1] https://joeyh.name/blog/entry/moving_my_email_archives_and_packages_to_git-annex/ --- mairix.c | 9 ++++++++- mairix.h | 3 ++- mairixrc.5 | 8 ++++++++ mbox.c | 7 ++++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/mairix.c b/mairix.c index 09f255b..2ef6a62 100644 --- a/mairix.c +++ b/mairix.c @@ -51,6 +51,7 @@ static char *omit = NULL; static char *database_path = NULL; static enum folder_type output_folder_type = FT_MAILDIR; static int skip_integrity_checks = 0; +static int follow_mbox_symlinks = 0; enum filetype { M_NONE, M_FILE, M_DIR, M_OTHER @@ -249,6 +250,7 @@ static void parse_rc_file(char *name)/*{{{*/ } else if (!strncasecmp(p, "mh=", 3)) add_folders(&mh_folders, copy_value(p)); else if (!strncasecmp(p, "mbox=", 5)) add_folders(&mboxen, copy_value(p)); + else if (!strncasecmp(p, "follow_mbox_symlinks", 20)) follow_mbox_symlinks = 1; else if (!strncasecmp(p, "omit=", 5)) add_folders(&omit, copy_value(p)); else if (!strncasecmp(p, "mformat=", 8)) { @@ -490,6 +492,7 @@ int main (int argc, char **argv)/*{{{*/ int do_integrity_checks = 1; int do_forced_unlock = 0; int do_fast_index = 0; + int do_mbox_symlinks = 0; unsigned int forced_hash_key = CREATE_RANDOM_DATABASE_HASH; @@ -617,6 +620,10 @@ int main (int argc, char **argv)/*{{{*/ do_integrity_checks = 0; } + if (follow_mbox_symlinks) { + do_mbox_symlinks = 1; + } + if (!folder_base) { fprintf(stderr, "No folder_base/MAIRIX_FOLDER_BASE set\n"); exit(2); @@ -746,7 +753,7 @@ int main (int argc, char **argv)/*{{{*/ unlock_and_exit(2); } - build_mbox_lists(db, folder_base, mboxen, omit_globs); + build_mbox_lists(db, folder_base, mboxen, omit_globs, do_mbox_symlinks); any_updates = update_database(db, msgs->paths, msgs->n, do_fast_index); if (do_purge) { diff --git a/mairix.h b/mairix.h index 2480492..b05c1c6 100644 --- a/mairix.h +++ b/mairix.h @@ -357,7 +357,8 @@ int cull_dead_messages(struct database *db, int do_integrity_checks); /* In mbox.c */ void build_mbox_lists(struct database *db, const char *folder_base, - const char *mboxen_paths, struct globber_array *omit_globs); + const char *mboxen_paths, struct globber_array *omit_globs, + int do_mbox_symlinks); int add_mbox_messages(struct database *db); void compute_checksum(const char *data, size_t len, checksum_t *csum); void cull_dead_mboxen(struct database *db); diff --git a/mairixrc.5 b/mairixrc.5 index b25dead..9dc4ef5 100644 --- a/mairixrc.5 +++ b/mairixrc.5 @@ -358,6 +358,14 @@ relative to the location of the .I mairixrc file or anything like that.) +.TP +.BI follow_mbox_symlinks +.br +This takes no arguments. By default, mairix will skip symlinks to +mboxes when indexing. If a line starting with +.B follow_mbox_symlinks +is present, mairix will follow them instead of skipping them. + .SS Expansions The part of each line in '.mairixrc' following the equals sign can diff --git a/mbox.c b/mbox.c index ebbfa78..f8bed26 100644 --- a/mbox.c +++ b/mbox.c @@ -743,7 +743,8 @@ void glob_and_expand_paths(const char *folder_base, /*}}}*/ void build_mbox_lists(struct database *db, const char *folder_base, /*{{{*/ - const char *mboxen_paths, struct globber_array *omit_globs) + const char *mboxen_paths, struct globber_array *omit_globs, + int do_mbox_symlinks) { char **raw_paths, **paths; int n_raw_paths, i; @@ -776,8 +777,8 @@ void build_mbox_lists(struct database *db, const char *folder_base, /*{{{*/ if (lstat(path, &sb) < 0) { /* can't stat */ } else { - if (S_ISLNK(sb.st_mode)) { - /* Skip mbox if symlink */ + if (S_ISLNK(sb.st_mode) && !do_mbox_symlinks) { + /* Skip mbox if symlink and no follow_mbox_symlinks in mairixrc */ if (verbose) { printf("%s is a link - skipping\n", path); }
signature.asc
Description: PGP signature