unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/2] new: Skip ignored broken symlinks
Date: Sun, 25 Nov 2012 00:25:45 -0500	[thread overview]
Message-ID: <1353821145-29182-3-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1353821145-29182-1-git-send-email-amdragon@mit.edu>

We now test for user ignore patterns before attempting to determine if
a directory entry is itself a directory.  As a result, we no longer
abort for broken symlinks if the user has explicitly ignored them.

This fixes the test added in the previous patch.  It also slightly
changes the debug output checked by another test of ignores.
---
 notmuch-new.c |   26 +++++++++++++++-----------
 test/new      |    6 +++++-
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 56c4a6f..718a538 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -350,6 +350,18 @@ add_files (notmuch_database_t *notmuch,
 
 	entry = fs_entries[i];
 
+	/* Ignore any files/directories the user has configured to
+	 * ignore.  We do this before dirent_type both for performance
+	 * and because we don't care if dirent_type fails on entries
+	 * that are explicitly ignored.
+	 */
+	if (_entry_in_ignore_list (entry->d_name, state)) {
+	    if (state->debug)
+		printf ("(D) add_files_recursive, pass 1: explicitly ignoring %s/%s\n",
+			path, entry->d_name);
+	    continue;
+	}
+
 	/* We only want to descend into directories (and symlinks to
 	 * directories). */
 	entry_type = dirent_type (path, entry);
@@ -364,22 +376,14 @@ add_files (notmuch_database_t *notmuch,
 	}
 
 	/* Ignore special directories to avoid infinite recursion.
-	 * Also ignore the .notmuch directory, any "tmp" directory
-	 * that appears within a maildir and files/directories
-	 * the user has configured to be ignored.
+	 * Also ignore the .notmuch directory and any "tmp" directory
+	 * that appears within a maildir.
 	 */
 	if (strcmp (entry->d_name, ".") == 0 ||
 	    strcmp (entry->d_name, "..") == 0 ||
 	    (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
-	    strcmp (entry->d_name, ".notmuch") == 0 ||
-	    _entry_in_ignore_list (entry->d_name, state))
-	{
-	    if (_entry_in_ignore_list (entry->d_name, state) && state->debug)
-		printf ("(D) add_files_recursive, pass 1: explicitly ignoring %s/%s\n",
-			path,
-			entry->d_name);
+	    strcmp (entry->d_name, ".notmuch") == 0)
 	    continue;
-	}
 
 	next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
 	status = add_files (notmuch, next, state);
diff --git a/test/new b/test/new
index 59892a7..8a76e34 100755
--- a/test/new
+++ b/test/new
@@ -192,7 +192,12 @@ touch "${MAIL_DIR}"/{one,one/two,one/two/three}/ignored_file
 output=$(NOTMUCH_NEW --debug 2>&1 | sort)
 test_expect_equal "$output" \
 "(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/.git
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/ignored_file
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/ignored_file
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/ignored_file
 (D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/three/.git
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/three/ignored_file
 (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/.git
 (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file
 (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/ignored_file
@@ -204,7 +209,6 @@ No new mail."
 
 
 test_begin_subtest "Don't stop for ignored broken symlinks"
-test_subtest_known_broken
 notmuch config set new.ignore .git ignored_file .ignored_hidden_file broken_link
 ln -s i_do_not_exist "${MAIL_DIR}"/broken_link
 output=$(NOTMUCH_NEW 2>&1)
-- 
1.7.10.4

  parent reply	other threads:[~2012-11-25  5:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-25  5:25 [PATCH 0/2] Ignore ignored broken symlinks Austin Clements
2012-11-25  5:25 ` [PATCH 1/2] test: Add a test for skipping " Austin Clements
2012-11-25  5:25 ` Austin Clements [this message]
2012-11-25 10:19 ` [PATCH 0/2] Ignore " Tomi Ollila
2012-11-25 11:46   ` Mark Walters
2012-11-27  2:23 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353821145-29182-3-git-send-email-amdragon@mit.edu \
    --to=amdragon@mit.edu \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

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 read-only IMAP folder(s) and NNTP newsgroup(s).