isomorphic-git / isomorphic-git

A pure JavaScript implementation of git for node and browsers!
https://isomorphic-git.org
MIT License
7.51k stars 380 forks source link

`git.init()` with `gitdir` set behaves differently to `git init --separate-git-dir=foo` #1916

Open AtkinsSJ opened 6 months ago

AtkinsSJ commented 6 months ago

I'm developing a browser-based git client using isomorphic-git, and noticed a couple of differences here against the official git client:

For the second one, it's possible that isomorphic-git just doesn't handle git init in an existing repo at all, but I'm not far enough with my client to know if that's the case. :sweat_smile:

Neither of these is a big issue (because who even uses a different git dir?) but I thought it was worth reporting anyway. 🙂

I'm using isomorphic-git in the browser, bundled using rollup.

hhourani27 commented 4 months ago

Isomorphic-git's init({gitdir:<path to gitdir>}) doesn't quite behave as Canonical Git git init --separate-git-dir=<path to gitdir> . Canonical Git, creates a .git file with a link to <gitdir>. While isomorphic-git just directly creates <gitdir>, and you have to pass it for each subsequent command.

I'm curious what's your use case for supporting --separate-git-dir ?

AtkinsSJ commented 4 months ago

I'm curious what's your use case for supporting --separate-git-dir ?

The use case is roughly "copy canonical git's command line and functionality". You can find the app here: https://github.com/HeyPuter/puter/tree/main/packages/git It's part of a whole cloud OS, and the idea is someone could use it from Puter's terminal just like they would on any other OS.

jcubic commented 4 months ago

@hhourani27 I think that git.init({gitdir}) is creating a new git bare repo, not changing the git directory. It's by design.