Skip to content

Avoid initializing nested Git repository#2285

Open
senekor wants to merge 1 commit intorust-lang:mainfrom
senekor:senekor/kvtomxvosvvx
Open

Avoid initializing nested Git repository#2285
senekor wants to merge 1 commit intorust-lang:mainfrom
senekor:senekor/kvtomxvosvvx

Conversation

@senekor
Copy link
Contributor

@senekor senekor commented Sep 10, 2025

Previously a Git repository was initialized if a Cargo workspace was detected. However, it's also possible for users to initialize rustlings in an existing Git repository that doesn't contain a Cargo workspace. In that case, it's still undesirable to initialize a nested Git repository for rustlings. We therefore call Git directly to determine if rustlings is being initialized in an existing Git repository.

@mo8it
Copy link
Contributor

mo8it commented Feb 26, 2026

I would prefer checking the current directory and every other parent directory for the existence of a .git or .jj directory instead of calling git. What do you think?

@senekor
Copy link
Contributor Author

senekor commented Feb 26, 2026

That seems good, yes. Jujutsu colocates repos by default these days, so I think looking for .git should be sufficient.

@mo8it
Copy link
Contributor

mo8it commented Feb 26, 2026

Sometimes, I deactivate the colocation. But yeah, if you do so, then you know what you are doing.

Can you please implement that instead of this PR? :)

@senekor senekor force-pushed the senekor/kvtomxvosvvx branch from 7187ad6 to 3f49c95 Compare February 26, 2026 16:15
@senekor
Copy link
Contributor Author

senekor commented Feb 26, 2026

Done. I checked for .jj anyway, since it shouldn't be expensive.

Previously a Git repository was initialized if a Cargo workspace was
detected. However, it's also possible for users to initialize rustlings
in an existing Git repository that doesn't contain a Cargo workspace. In
that case, it's still undesirable to initialize a nested Git repository
for rustlings. We therefore search all ancestors of the current working
directory for `.git` or `.jj` directories to determine if rustlings is
being initialized in an existing Git repository.
@senekor senekor force-pushed the senekor/kvtomxvosvvx branch from 3f49c95 to 17ff889 Compare February 26, 2026 16:57
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