Skip to content

feat: make VCS marker detection order configurable#1984

Open
stribb wants to merge 1 commit intobbatsov:masterfrom
stribb:vcs-markers
Open

feat: make VCS marker detection order configurable#1984
stribb wants to merge 1 commit intobbatsov:masterfrom
stribb:vcs-markers

Conversation

@stribb
Copy link
Copy Markdown

@stribb stribb commented Feb 20, 2026

Motivation

projectile-project-vcs checks VCS markers in a fixed order — .git
before .jj — so a colocated jj+git repo is always detected as git.

This is a common situation rather than an edge case: jj's most popular
backend is git. When you run jj git init in an existing repo, or
clone with jj git clone, you get a directory that contains both a
.jj/ folder and a .git/ folder. Users of jj-on-git who want
projectile to treat such repos as jj projects have no recourse short of
advising projectile-project-vcs.

Changes

Add projectile-vcs-markers — an ordered alist of (marker . vcs-symbol)
pairs — and rewrite projectile-project-vcs to iterate it for both the
root check and the dominating-file walk, replacing the hardcoded cond.

The default order is unchanged from the current behaviour, so this is
backwards-compatible for all existing users.

Usage

To prefer jj over git in colocated repos:

(setq projectile-vcs-markers
      (cons '(".jj" . jj)
            (assoc-delete-all ".jj" projectile-vcs-markers)))

Tests

Four new Buttercup specs in projectile-test.el covering:

  • single .git repo → git
  • single .jj repo → jj
  • colocated .git+.jj with default order → git
  • colocated .git+.jj with custom order (jj first) → jj

@bbatsov
Copy link
Copy Markdown
Owner

bbatsov commented Mar 10, 2026

I think that's a good change. Just rebase it on top of master and we're good to go.

You might also mention your usecases and the configuration somewhere in the user docs.

Add `projectile-vcs-markers` defcustom — an ordered alist of
(MARKER . VCS-SYMBOL) pairs.  `projectile-project-vcs` now iterates
this list for both the root check and dominating-file walk, replacing
the hardcoded cond.  Default order is unchanged.

Users can now prioritise e.g. jj over git for colocated repos:

  (push '(".jj" . jj) projectile-vcs-markers)
@stribb
Copy link
Copy Markdown
Author

stribb commented Apr 13, 2026

Rebased onto master and added docs. Ready for merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants