Skip to content

Add Local Repository rejects paths starting with ~ #22651

Closed as not planned
Closed as not planned

Description

@francisrath

The problem

Add Local Repository rejects paths beginning with ~. Entering ~/src/my-repo gives "This directory does not appear to be a Git repository" and offers to create one there, even though the repository exists and adding it by its absolute path works fine.

The dialog does know how to expand ~ — it just does it too late. addRepository validates the raw path first and only expands afterwards:

const { path } = this.state
const isValidPath = await this.validatePath(path)   // raw path, still contains ~

if (!isValidPath) {
  this.pathTextBoxRef.current?.focus()
  return                                            // never gets any further
}

const resolvedPath = this.resolvedPath(path)        // untildify happens here
const repositories = await dispatcher.addRepositories([resolvedPath])

validatePath calls getRepositoryType, which starts with a directoryExists check, and a literal ~/… never exists as far as the filesystem is concerned, so the result is always missing and the early return means the expansion is never reached.

Release version

3.6.3

Operating system

macOS 26.5.2 (arm64)

Steps to reproduce the behavior

  1. File → Add Local Repository.
  2. Enter the path to an existing repository using ~, e.g. ~/src/my-repo.
  3. Click Add Repository.
  4. The not-a-Git-repository warning appears and nothing is added.
  5. Replace ~ with the full home directory path and click Add Repository again — it works.

Log files

No response

Screenshots

No response

Additional context

Validating the resolved path rather than the raw one would fix it — resolvedPath already handles both the tilde and making the path absolute.

Worth noting this interacts with #22648: after the tilde path fails, correcting it to an absolute path leaves the warning on screen, because the warning only re-evaluates on submit. That combination is quite confusing to run into — the warning ends up displayed alongside a path that's perfectly valid.

Happy to open a PR for this one if you'd like it.

Activity

  1. desktop-triage commented on Aug 4, 2026

    @desktop-triage

    This is a duplicate of #5410, which tracks the same bug: tilde (~) paths entered in the Add Local Repository dialog are not expanded before validation, causing the "not a Git repository" error. Your report adds useful detail (exact code location, version, and the interaction with #22648), so please consider adding a comment to #5410 with those findings.

    Generated by Issue Triage (skills-driven) for #22651 · sonnet46 15.1 AIC · ⌖ 4 AIC · ⊞ 5.7K · ◷

  2. francisrath commented on Aug 4, 2026

    @francisrath
    ContributorAuthor

    Duplicate of #5410, which reports the same thing from 2018. I've added the current code analysis over there, so closing this in favour of it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions