The log command only seems to work when the dir is passed in as a string
See original GitHub issue@wmhilton first of all HUGE THANKS for this great library! It has been a joy working with it so far. Well, mostly, hence the issue 😉
I’m using Isomorphic GIT in a browser project created with Create React App, the TypeScript variant.
Somehow it seems like the log
command does not accept the documented parameter log({ dir: '.' })
, but instead it works when I do log('.')
.
I’ve created an example on StackBlitz to show how it behaves (make sure to open the console):
https://stackblitz.com/edit/isomorphic-git?file=GitService.tsx
Here in the file GitService.tsx
on line 74 you see the syntax as documented. However, this syntax yields and error: Error: Could not resolve reference "HEAD".
.
If I instead use the code on line 76 I do get back the expected git logs.
Am I doing something wrong here?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
The reason
log(dir)
seemed to work was because the clone was in the root directory. The code also worked if you didlog({})
. (Interestingly,log()
straight up fails because it has no argument to destruct. I guess since strings are objects,const { dir } = "foo"
doesn’t cause an error.)Both cases resulted in
join(undefined, '.git')
which ended up being.git
which worked. Whilejoin('/', '.git')
ended up being//.git
which didn’t work.And I know, I know, that’s an… incredibly stupid mistake on my part due in part to the arrogance of not using the builtin
path
library but using my ownjoin
function… but the browser version of thepath
library (path-browserify
) is different enough from thepath
library in Node.js that that was causing bugs in the past, so… there’s good reasons why I rolled my own (shudder) but I still feel shamed that such a simple bug slipped in. (You could argue it is a LightningFS bug rather than an isomorphic-git bug, since node’sfs
and BrowserFS understand “//.git” but I’m choosing to fix it in isomorphic-git.)I’m adding an intense test/regression suite for
join
so this silliness doesn’t happen again.Aha! I figured it out. There’s a bug in
isomorphic-git/utils/join
such that `join(‘/’, ‘.git’) == ‘//.git’. BrowserFS normalized that so it didn’t cause an error, but LightningFS is stricter about such foolishness… because I figured it’s better to catch and handle these bugs closer to the source. 😆 Serves me right, I wrote both of them.Thanks for fixing the URL! Sorry I didn’t get to it faster (adventures of moving across states!). I’ll have a fix soon.