Skip to content

Commit 9b5a630

Browse files
committed
gptel-context: Handle possibly nil git-cache argument
1 parent e2ca876 commit 9b5a630

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

gptel-context.el

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,22 @@ Fall back to nil (allowing all files) if Git command fails."
310310
(let ((git-unignored (gptel-context--get-git-unignored git-root)))
311311
(not (member rel-path git-unignored))))))
312312

313-
(defun gptel-context--message-git-skipped (path git-cache)
313+
(defun gptel-context--message-git-skipped (path &optional git-cache)
314314
"Message that PATH is skipped due to gitignore rules.
315315
Optional GIT-CACHE is a cons of git-root directory and non-ignored
316316
files list."
317-
(let* ((git-root (car-safe git-cache))
318-
(type (if (file-directory-p path) "directory" "file"))
317+
(let* ((type (if (file-directory-p path) "directory" "file"))
319318
(skipped-common (format "git-ignored %s" type))
320319
(skipped (if (string= type "directory")
321320
(concat "files from " skipped-common)
322321
skipped-common))
323-
(rel-path (file-relative-name path git-root))
324-
(repo (file-name-nondirectory (directory-file-name git-root)))
325-
(var (symbol-name 'gptel-context-exclude-git-ignored)))
326-
(message "Skipping %s `%s' in repo (%s). To include git-ignored files, unset `%s'."
327-
skipped rel-path repo var)))
322+
(var (symbol-name 'gptel-context-exclude-git-ignored))
323+
(reminder (format "To include git-ignored files, unset `%s'." var)))
324+
(if-let* ((git-root (car-safe git-cache))
325+
(rel-path (file-relative-name path git-root))
326+
(repo (file-name-nondirectory (directory-file-name git-root))))
327+
(message "Skipping %s `%s' in repo (%s). %s" skipped rel-path repo reminder)
328+
(message "Skipping %s `%s'. %s" skipped path reminder))))
328329

329330
(defun gptel-context-remove (&optional context)
330331
"Remove the CONTEXT overlay from the contexts list.

0 commit comments

Comments
 (0)