-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
x/tools/go/vcs: FromDir fails to recognize git submodules #10322
Comments
I have a patch for this issue |
@dgsb, if you haven't seen it yet: https://golang.org/doc/contribute.html |
The changes have been posted on gerrit. I'm not sure if I shoud have received an email notification. |
Patch waiting for review https://go-review.googlesource.com/#/c/21430/ |
Is this really an issue? How should From https://godoc.org/golang.org/x/tools/go/vcs#FromDir:
The documentation doesn't make it explicit or clear, but I interpret that to mean that it will get the vcs that contains dir at the top-most level. So if you're inside a submodule directory of a git repo, it should still return the top level git repo, no? Can you link to the issue in |
No, I indeed I don't think it should, a subrepository is repository by itself. |
Can you provide more details about such a setup with a git repository that gathers other repositories as submodules? How can I reproduce it? What Like, what would $ tree -a .
.
├── Conception-go
│ ├── .git (directory)
│ ├── README.md
│ └── caret
├── vfsgen
│ ├── .git (directory)
│ ├── CONTRIBUTING.md
│ ├── README.md
│ ├── cmd
│ │ └── vfsgendev
│ │ ├── generate.go
│ │ ├── parse.go
│ │ ├── template.go
│ │ └── vfsgendev.go
│ ├── commentwriter.go
│ ├── doc.go
│ ├── generator.go
│ ├── generator_test.go
│ ├── options.go
│ ├── stringwriter.go
│ └── test
│ ├── doc.go
│ ├── test_gen.go
│ ├── test_test.go
│ └── test_vfsdata_test.go
└── webdavfs
├── .git (directory)
├── README.md
└── vfsutil
└── vfsutil.go |
Here the tree command which I have stripped down for readability .
├── .git
│ ├── modules
│ │ └── src
│ │ └── package_producer <-- The .git directory of the submodule
├── .gitmodules
└── src
├── package_consumer
│ └── main.go
└── package_producer
├── .git <-- FILE !
└── main.go At this point vendoring through godep into the package consumer will fail |
How can I reproduce one of these ".git file instead of .git directory" situations? What (plain git) commands can I run? Thanks. |
@rsc The magic search keyword is "gitdir" and you can read more about it in
For me, simply adding a submodule creates this situation (the submodule has a .git file that points to inside the enclosing repo's .git directory as described above). I'm using git 2.1.0 but I believe this is true for any recent-ish git.
|
@rsc for what it worth I posted a patch for this issue on golang gerrit several months ago. I'm not sure if it has been reviewed. At that time it solved my issue in my specific workflow. I don't remember if the patch was neat enough to be integrated in the main code base. |
@dgsb, yes, I got here because I was reviewing your CL (assuming that is CL 21430). |
OK, so the question is whether to bother making Git a special case or if we should just take ".vcs exists" for all the version control systems. I'd rather not special-case Git any more than we need to. We could just drop the && IsDir() from all the checks. The fix would need to be applied both here and in the cmd/go sources, if I understand correctly. |
While toying with a solution for #10010, I had to make special cases for Fossil, as the repository data is an SQLite3 database. While there aren't many systems that use a single file, I know at least two (Fossil and Monotone both use SQLite3), so the looser check may be more general across all VCS. That is if it doesn't obstruct the more popular systems. |
CL https://golang.org/cl/21430 mentions this issue. |
CL https://golang.org/cl/30948 mentions this issue. |
@rsc there is an st.IsDir() check in cmd/go/get.go as well at: https://github.com/golang/go/blob/master/src/cmd/go/get.go#L421 I didn't see it in the last CL, and it would pre-empt the vcs.go checks, I think. |
I am trying to understand the issue, the fix, and its implications better. I would like to be confident this is the right fix for
The original issue said:
After the change in CL 21430, Is a git submodule considered a "git repository"? A consequence that I noticed is that if you're using For example, if you do vcs, root, err := vcs.FromDir("/tmp/gopath/src/github.com/shazow/ssh-chat/vendor/github.com/alexcesaro/log", "/tmp/gopath/src") Before CL 21430, the value of Is that intended and expected behavior for Now that CL 30948 is about to apply the same change for |
Sometimes .git is a plain file; maybe others will follow. This CL matches CL 21430, made in x/tools/go/vcs. The change in the Swift test case makes the test case pass by changing the test to match current behavior, which I assume is better than the reverse. (The test only runs locally and without -short, so the builders are not seeing this particular failure.) For #10322. Change-Id: Iccd08819a01c5609a2880b9d8a99af936e20faff Reviewed-on: https://go-review.googlesource.com/30948 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
Sometimes .git is a plain file; maybe others will follow. Fixes golang/go#10322. Change-Id: Id57424998c207080c3ed5826b1e5e091fa26aad5 Reviewed-on: https://go-review.googlesource.com/21430 Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
I'm using
godep save
in a project that is imported as a git submodule. The command fails with the error:Digging deeper, I found that godep is using https://godoc.org/golang.org/x/tools/go/vcs#FromDir to determine if the current directory contains a git repo. This command does not correctly identify git submodules because the implementation searches for .git directory. Git submodules don't have a .git directory, just a .git file that contains a link to the parent repo.
The text was updated successfully, but these errors were encountered: