Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] cocogitto fails with multiple git working trees #312

Open
andreabedini opened this issue Aug 23, 2023 · 0 comments
Open

[BUG] cocogitto fails with multiple git working trees #312

andreabedini opened this issue Aug 23, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@andreabedini
Copy link

Thanks for this project, I have just started using it so I hope I am not just holding it wrong :)

Describe the bug

Adding a commit to one of my repositories, I was presented with misterious message:

~/work/cardano-haskell-packages-pr-441 pr/441* ⇡
❮ cog commit refactor "chap metadata is system-independent" flake
Error: Not a directory (os error 20)

Investigating further, I noticed that cog seems to be looking for .git/COMMIT_EDITMSG

❯ strace cog commit refactor "chap metadata is system-independent" flake >> /dev/null
...
newfstatat(AT_FDCWD, "/home/andrea/work/cardano-haskell-packages/.git/worktrees/cardano-haskell-packages-pr-441/", {st_mode=S_IFDIR|0755, st_size=122, ...}, AT_SYMLINK_NOFOLLOW) = 0
statx(AT_FDCWD, "/home/andrea/work/cardano-haskell-packages-pr-441/cog.toml", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7fff0e5934f0) = -1 ENOENT (No such file or directory)
statx(AT_FDCWD, "/home/andrea/work/cardano-haskell-packages-pr-441/.git/hooks/pre-commit", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7fff0e5941e0) = -1 ENOTDIR (Not a directory)
openat(AT_FDCWD, "/home/andrea/work/cardano-haskell-packages-pr-441/.git/COMMIT_EDITMSG", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = -1 ENOTDIR (Not a directory)
write(2, "Error: ", 7Error: )                  = 7
write(2, "Not a directory", 15Not a directory)         = 15

This .git is indeed not a directory because I am using multiple git working trees:

~/work/cardano-haskell-packages-pr-441 pr/441* ⇡
❯ git worktree list
/home/andrea/work/cardano-haskell-packages         a36b3a63 [main]
/home/andrea/work/cardano-haskell-packages-pr-441  8bad3070 [pr/441]

~/work/cardano-haskell-packages-pr-441 pr/441* ⇡
❯ cat .git
gitdir: /home/andrea/work/cardano-haskell-packages/.git/worktrees/cardano-haskell-packages-pr-441

The interesting thing is that cogitto seems to (partially) understand this because, at the top of the strace above, you can see it's accessing cardano-haskell-packages/.git/worktrees/cardano-haskell-packages-pr-441/ which only exists in presence of multile working trees.

To Reproduce

This seems to work:

mkdir cocogitto && cd cocogitto
git init && touch README.md && git add README.md && git commit -m "Initial commit"
git worktree add ../cocogitto-other && cd ../cocogitto-other
touch NEW_FILE.md && git add NEW_FILE.md && cog commit test

Expected behavior

The commit succeeds as it would normally do.

Additional context

None ☺️

@andreabedini andreabedini added the bug Something isn't working label Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants