You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first time I tried committing, it ran the hooks but there were errors. The second time I tried committing, I get the following output:
Unable to setup environment for pre-commit hook run:
STDOUT:
STDERR:error: path/to/submodule: is a directory - add files inside instead
fatal: Unable to process path path/to/submodule
Cannot save the current worktree state
If I run git status everything looks as I would expect.
Whoops, I wasn't recreating the error conditions properly. After forcing AuthorName to fail and attempting to commit again, I see the same error with both v0.23.0 and the latest master.
Seems like the following sequence triggers the error:
$ git rm path/to/submodule
rm 'path/to/submodule'
$ git stash save --keep-index
Saved working directory and index state WIP on test-submodule-delete: bc0bb4a Add submodule
HEAD is now at bc0bb4a Add submodule
$ git reset --hard
HEAD is now at bc0bb4a Add submodule
$ git stash pop --index
Removing path/to/submodule
On branch test-submodule-delete
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: .gitmodules
deleted: path/to/submodule
Dropped refs/stash@{0} (43e3071fc1068177c4dadb96d106a35092145b7e)
$ git stash save --keep-index
error: path/to/submodule: is a directory - add files inside instead
fatal: Unable to process path path/to/submodule
Cannot save the current worktree state
This is the exact sequence that plays out when a pre-commit hook fails, and then runs again. The problem is that git reset --hard restores the path/to/submodule directory, but not its contents, and git stash save doesn't know what to do with the empty directory.
To sum up, submodules are terrible and no one should ever use them. But I guess this still needs a fix, eh?
I believe I've come up with a workaround for this in 5916e2c and 59fa73b. It's definitely more invasive than I would like, so if there are other ideas please suggest them. I'm leaving this open until some tests are written.
It turns out we're running against some differences in behavior between git 1.8 and 2.3 (at least those are the versions I jump between when developing on CentOS versus Mac OS X).
I've added a test in 25f9e62 with some explanation of the difference in behavior.
However, I've realized that the separate tests added in 5916e2c fail on git 1.8, since .gitmodules seems to be treated differently between those two versions (haven't looked into this deeply yet).
We'd probably want to explicitly test a number of releases. Much of enterprise Linux such as RHEL 6 is still on 1.7, and the relatively new RHEL 7 is on 1.8.
I'm guessing the largest audience of Overcommit will be Mac users, which means we'll see a wide-range of versions given the ease with which you can install git via homebrew and the relative infrequency with which most developers update it (it's usually a one-time thought when they're setting up a new machine and is never touched after that).
I'm not sure how much of a pain this will turn out to be in practice, but it seems like supporting the latest patch level of all minor versions 1.7 or newer is probably something a low-level tool like Overcommit needs to do. What do you think?
Sounds good to me. We just need to find apt repositories for each minor release since 1.7, or else compile from source, which we probably want to avoid.
This is going to create a huge build matrix, though. 6 supported Ruby versions and 7 supported Git versions gives us 42 builds overall.
Started testing all patch-level releases of Git from 1.8.3.1 onward, seems this was first fixed in 1.8.5. Possibly related to this entry in the release notes.
Edit: Specifically, this was fixed in this commit, which is included in all releases since 1.8.5.
I believe I've addressed this issue in 56f7339...6223ce2. I've also introduced a magic constant GIT_VERSION that we can use to hopefully make special cases like this easier to deal with in the future.
Feel free to comment inline on the commits.
I believe this wraps up any blockers for the 0.24.0 release. I'll be playing around with master for the next day and hopefully cut a release (barring any other issues discovered).
Activity
jawshooah commentedon Apr 8, 2015
Are you using Overcommit v0.23.0, or the latest master? This may have been fixed in #158, as I can't reproduce the error locally.
lencioni commentedon Apr 8, 2015
I'm using v0.23.0.
jawshooah commentedon Apr 8, 2015
Whoops, I wasn't recreating the error conditions properly. After forcing
AuthorNameto fail and attempting to commit again, I see the same error with both v0.23.0 and the latest master.Seems like the following sequence triggers the error:
This is the exact sequence that plays out when a pre-commit hook fails, and then runs again. The problem is that
git reset --hardrestores thepath/to/submoduledirectory, but not its contents, andgit stash savedoesn't know what to do with the empty directory.To sum up, submodules are terrible and no one should ever use them. But I guess this still needs a fix, eh?
jawshooah commentedon Apr 8, 2015
More generally, this error can be reproduced with the following commands:
sds commentedon Apr 9, 2015
I believe I've come up with a workaround for this in 5916e2c and 59fa73b. It's definitely more invasive than I would like, so if there are other ideas please suggest them. I'm leaving this open until some tests are written.
sds commentedon Apr 9, 2015
It turns out we're running against some differences in behavior between git 1.8 and 2.3 (at least those are the versions I jump between when developing on CentOS versus Mac OS X).
I've added a test in 25f9e62 with some explanation of the difference in behavior.
However, I've realized that the separate tests added in 5916e2c fail on git 1.8, since
.gitmodulesseems to be treated differently between those two versions (haven't looked into this deeply yet).jawshooah commentedon Apr 9, 2015
Would it be sufficient to test only against 1.8 and the latest release (currently 2.3.5)? If so, we could add something like this to
.travis.yml:sds commentedon Apr 10, 2015
We'd probably want to explicitly test a number of releases. Much of enterprise Linux such as RHEL 6 is still on 1.7, and the relatively new RHEL 7 is on 1.8.
I'm guessing the largest audience of Overcommit will be Mac users, which means we'll see a wide-range of versions given the ease with which you can install
gitviahomebrewand the relative infrequency with which most developers update it (it's usually a one-time thought when they're setting up a new machine and is never touched after that).I'm not sure how much of a pain this will turn out to be in practice, but it seems like supporting the latest patch level of all minor versions 1.7 or newer is probably something a low-level tool like Overcommit needs to do. What do you think?
jawshooah commentedon Apr 10, 2015
Sounds good to me. We just need to find apt repositories for each minor release since 1.7, or else compile from source, which we probably want to avoid.
This is going to create a huge build matrix, though. 6 supported Ruby versions and 7 supported Git versions gives us 42 builds overall.
jawshooah commentedon Apr 10, 2015
Strange, all tests seem to be passing with both git 1.8.5 and 2.3.5: https://travis-ci.org/jawshooah/overcommit/builds/57886049
sds commentedon Apr 10, 2015
I can confirm
git_repo_spec.rbfails on git 1.8.3.1.sds commentedon Apr 10, 2015
So much for testing only minor versions? :P (I think we're fine with the policy as defined—I just need to dig into what's going on here)
jawshooah commentedon Apr 10, 2015
Started testing all patch-level releases of Git from 1.8.3.1 onward, seems this was first fixed in 1.8.5. Possibly related to this entry in the release notes.
Edit: Specifically, this was fixed in this commit, which is included in all releases since 1.8.5.
sds commentedon Apr 10, 2015
I believe I've addressed this issue in 56f7339...6223ce2. I've also introduced a magic constant
GIT_VERSIONthat we can use to hopefully make special cases like this easier to deal with in the future.Feel free to comment inline on the commits.
I believe this wraps up any blockers for the 0.24.0 release. I'll be playing around with
masterfor the next day and hopefully cut a release (barring any other issues discovered).Support hook side effects without stashing repository changes (#939)