gitslave
gitslave copied to clipboard
Unable to attach a repo that does not have a branch with the same name as the parent
If you try to attach a repo that does not have a branch that shares a name with the parent repo, gits fails as in the example below.
[kj4ips ~/vcs/test2]1312% git ls-remote ssh://REDACTED/REDACTED.git | grep heads
71..REDACTEDREDACTEDREDACTEDREDACTED..ef refs/heads/development
60..REDACTEDREDACTEDREDACTEDREDACTED..ad refs/heads/production
27..REDACTEDREDACTEDREDACTEDREDACTED..ee refs/heads/qa
ab..REDACTEDREDACTEDREDACTEDREDACTED..cc refs/heads/sandbox
a4..REDACTEDREDACTEDREDACTEDREDACTED..b5 refs/heads/uat
[kj4ips ~/vcs/test2]1313% mkdir puppet
[kj4ips ~/vcs/test2]1314% gits -n attach ssh://REDACTED/REDACTED.git puppet/test
Cloning into 'puppet/test'...
remote: Counting objects: 1124, done.
remote: Compressing objects: 100% (1003/1003), done.
remote: Total 1124 (delta 657), reused 141 (delta 75)
Receiving objects: 100% (1124/1124), 146.15 KiB | 1.85 MiB/s, done.
Resolving deltas: 100% (657/657), done.
[master 4REDACTa] gits adding "ssh://REDACTED/REDACTED.git" "puppet/test"
2 files changed, 2 insertions(+)
Switching "puppet/test" to branch "master"
fatal: invalid reference: master
Branch inconsistency, branch master does not exist
This is more of a logical thing, some off the top thoughts:
- add a flag to tell gits to skip the post-clone checkout, so the remote's HEAD is used
- add a mechanism to specify the specific branch desired.
If you try to attach a repo that does not have a branch that shares a name with the parent repo, gits fails as in the example below.
Are you sure that it fails functionally, not just final exit code? It might not have, allowing you to create/checkout the correct branch for all attached repositories. "However, you should be scared" -- see comments from the basic tutorial:
- http://gitslave.sourceforge.net/tutorial-basic.html
...
gits attach ../plugin1 plugin1
...
# Switching "plugin1" to branch "master"
# fatal: invalid reference: master
# Branch inconsistency, branch master does not exist
## Don't worry about the scary "fatal" and "Branch inconsistency"
## errors, and the ominous warning. This is all because the upstream
## repository is empty since we just created it and have not put
## anything in it yet. However, you should be scared if you
## see these messages under any other circumstance. ...
...
This is more of a logical thing, some off the top thoughts:
Intuitively this feels like expected behavior. One of the main features of gitslave is to keep the checked out branches across attached repositories in sync.
- add a flag to tell gits to skip the post-clone checkout, so the remote's HEAD is used
This could be an option, but not a feature I personally long for. Feel free to implement and submit a pull request.
- add a mechanism to specify the specific branch desired.
If you have control of the repository, consider creating the relevant branch before attaching. You can of course also gits checkout -b <known existing branch in soon-to-be-attached-repository> before attaching.
If you don't have full control over the new repository, consider reading the gitslave documentation on the original homepage (or in the web/ directory). You might start with this quoted paragraph start, a bit more than halfway down the page. You'll find some suggestions in the bullet list, but they all seem more cumbersome than ensuring that all repositories (assuming full control) have the same set of branches.
Your setup may need special care and feeding if one or more of the repositories is a third party repository.
- http://gitslave.sourceforge.net/