;; expanded and not left for the shell command
;; to interpret.
(localdir (file-name-unquote (file-local-name (expand-file-name dir))))
- (command (format "%s -H %s %s -type f %s -print0"
+ (dfn (directory-file-name localdir))
+ (command (format "%s -H . %s -type f %s -print0"
find-program
- (shell-quote-argument
- (directory-file-name localdir)) ; Bug#48471
- (xref--find-ignores-arguments ignores localdir)
+ (xref--find-ignores-arguments ignores "./")
(if files
(concat (shell-quote-argument "(")
" " find-name-arg " "
(unless (zerop status)
(error "File listing failed: %s" (buffer-string))))))))
(project--remote-file-names
- (sort (split-string output "\0" t)
- #'string<))))
+ (mapcar (lambda (s) (concat dfn (substring s 1)))
+ (sort (split-string output "\0" t)
+ #'string<)))))
(defun project--remote-file-names (local-files)
"Return LOCAL-FILES as if they were on the system of `default-directory'.
;; do that reliably enough, without creating false negatives?
(command (xref--rgrep-command (xref--regexp-to-extended regexp)
files
- (directory-file-name
- (file-name-unquote
- (file-local-name (expand-file-name dir))))
+ "."
ignores))
- (def default-directory)
+ (local-dir (directory-file-name
+ (file-name-unquote
+ (file-local-name (expand-file-name dir)))))
(buf (get-buffer-create " *xref-grep*"))
(`(,grep-re ,file-group ,line-group . ,_) (car grep-regexp-alist))
(status nil)
(hits nil))
(with-current-buffer buf
(erase-buffer)
- (setq default-directory def)
+ (setq default-directory dir)
(setq status
(process-file-shell-command command nil t))
(goto-char (point-min))
(user-error "Search failed with status %d: %s" status (buffer-string)))
(while (re-search-forward grep-re nil t)
(push (list (string-to-number (match-string line-group))
- (match-string file-group)
+ (concat local-dir (substring (match-string file-group) 1))
(buffer-substring-no-properties (point) (line-end-position)))
hits)))
(xref--convert-hits (nreverse hits) regexp)))
(cl-assert (not (string-match-p "\\`~" dir)))
(if (not ignores)
""
+ ;; TODO: All in-tree callers are passing in just "." or "./".
+ ;; We can simplify.
+ ;; And, if we ever end up deleting xref-matches-in-directory, move
+ ;; this function to the project package.
+ (setq dir (file-name-as-directory dir))
(concat
(shell-quote-argument "(")
" -path "
collect (file-relative-name file dir))))
(should (equal relative-files '("some-file"))))))
+(ert-deftest project-ignores-bug-50240 ()
+ "Check that `project-files' does not ignore all files.
+When `project-ignores' includes a name matching project dir."
+ (skip-unless (executable-find find-program))
+ (project-tests--with-temporary-directory dir
+ (make-empty-file (expand-file-name "some-file" dir))
+ (let* ((project (make-project-tests--trivial
+ :root (file-name-as-directory dir)
+ :ignores (list (file-name-nondirectory
+ (directory-file-name dir)))))
+ (files (project-files project)))
+ (should (equal files
+ (list
+ (expand-file-name "some-file" dir)))))))
+
;;; project-tests.el ends here
(should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 0 locs))))
(should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 1 locs))))))
+(ert-deftest xref-matches-in-directory-filters-with-ignores ()
+ (let ((locs (xref-matches-in-directory "bar" "*" xref-tests--data-dir
+ '("./file1.*"))))
+ (should (= 1 (length locs)))
+ (should (string-match-p "file2\\.txt\\'" (xref-location-group
+ (xref-item-location
+ (nth 0 locs)))))))
+
(ert-deftest xref-matches-in-directory-finds-two-matches-on-the-same-line ()
(let ((locs (xref-tests--locations-in-data-dir "foo")))
(should (= 2 (length locs)))