Skip to content

Commit

Permalink
[Fix #1600] Fix Git submodule command on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
shivjm committed Jul 15, 2022
1 parent 00fce5a commit 95c514a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Fix version extraction logic.
* [1654](https://github.com/bbatsov/projectile/issues/1654) Fix consecutive duplicates appearing in command history
* [#1755](https://github.com/bbatsov/projectile/issues/1755) Cache failure to find project root
* [#1600](https://github.com/bbatsov/projectile/issues/1600): Fix error finding project files with Git submodules on Windows.

### Changes

Expand Down
22 changes: 21 additions & 1 deletion projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,17 @@ Set to nil to disable listing submodules contents."
:group 'projectile
:type 'string)

(make-obsolete-variable 'projectile-git-submodule-command "Configure `projectile-git-submodule-command-function' instead." "2.6.0")

(defcustom projectile-git-submodule-command-function 'projectile--get-git-sub-projects-command
"Function generate command to list submodules of a given git repository.
Set to nil to disable listing submodules contents.

This has to be a function to generate the command with the correct quotes."
:group 'projectile
:type 'function
:package-version '(projectile . "2.6.0"))

(defcustom projectile-git-ignored-command "git ls-files -zcoi --exclude-standard"
"Command used by projectile to get the ignored files in a git project."
:group 'projectile
Expand Down Expand Up @@ -1385,9 +1396,18 @@ Fallback to a generic command when not in a VCS-controlled project."
Currently that's supported just for Git (sub-projects being Git
sub-modules there)."
(pcase vcs
('git projectile-git-submodule-command)
('git (and projectile-git-submodule-command-function (funcall projectile-git-submodule-command-function)))
(_ "")))

(defun projectile--get-git-sub-projects-command ()
"Get the sub-projects command for Git.
Defined as a function in order to generate the properly-quoted command at
runtime."
(format "git submodule --quiet foreach %s | tr %s %s"
(shell-quote-argument "echo $displaypath")
(shell-quote-argument "\\n")
(shell-quote-argument "\\0")))

(defun projectile-get-ext-ignored-command (vcs)
"Determine which external command to invoke based on the project's VCS."
(pcase vcs
Expand Down

0 comments on commit 95c514a

Please sign in to comment.