-
Notifications
You must be signed in to change notification settings - Fork 280
Fixes a bug that occurs when attempting to created nested subdirs #161
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
Conversation
Great PR. Thanks. Only problem is I'm not sure there is a problem. I can run:
in the git-subrepo directory itself and it works fine. Should we prevent init-ing subrepos inside subrepos? I'm not sure. |
The reason it works is because the 'subrepo/ext/bashplus' branch doesn't exist yet in your local repo. If you run 'git subrepo branch ext/bashplus', pull or push with processed commits, or run 'git subrepo init ext/bashplus' for the first time, the branch will then exist, which will block 'git subrepo init ext/bashplus/test'. It took me a while to realize this myself while I was trying to trace the issue. Try running 'git subrepo branch ext/bashplus', then run 'git subrepo init ext/bashplus/test' and you will see the problem. Thanks |
Thanks for the explanation. BTW, I like working with existing public repos to The thing is, that with your patch I can't init ext/bashplus/test and I think There are still a few open issues around subsubrepos. I'd like to get those I'll add a test to protect my use case above and then you can adjust your patch |
I see, that makes sense. It is rather restrictive to not allow any subrepos you are using to not have subrepos of their own. Perhaps we should move this discussion to an issue? In the meantime, I will send you a separate pull with just the commit that catches and resets after a failed git branch. |
@stsquared99 see https://gist.github.com/2b1c142254fdf83a114b git-subrepo already has a sub-subrepo, as you can see. The thing is that the status command can't see them yet (unless you specify them explicitly). See #132. If you could work on that one too, I'd appreciate it. Else I will eventually... |
Also #82 is the nested subrepo issue. Regarding the dir vs file thing, I think just issuing a message to do a |
Ah, I think that clarified things for me now, thanks. I'll take a look at those issues and play around with nested subrepos some more. |
Fixes a bug that occurs when trying to create a subrepo inside of another subrepo.
Steps to reproduce:
$ find | grep -v '.git'
.
./foo
./foo/bar
./foo/bar/Bar
./foo/Foo
$ git subrepo init foo
Subrepo created from 'foo' (with no remote).
$ git branch
subrepo/foo
$ git subrepo init foo/bar
git-subrepo: Command failed: 'git branch subrepo/foo/bar'.
$ find | grep -v '.git'
.
./Bar
'git branch subrepo/foo/bar' fails because '.git/refs/heads/subrepo/foo' already exists as a file instead of a directory. Furthermore, when git branch fails, there is no catch, so the HEAD is stuck in the subdirectory-filter.
This PR properly handles the failed 'git branch' command, and prevents a subdir from being created inside of another subdir entirely.
Hopefully the test I wrote is in accordance with your standards.
Thanks