legit
legit copied to clipboard
git sync fails badly, not goodly, when branch is unpublished
I am using legit version 1.2.0post0 installed from pip. When I have a branch that is unpublished, git sync fails badly:
lousyd $ git status
On branch 174-branchname
Your branch is up to date with 'origin/174-branchname'.
nothing to commit, working tree clean
lousyd $ git branches
172-some-other-branch (published)
* 174-branchname (unpublished)
179-another-branch (published)
lousyd $ git pull --all
Fetching origin
Your configuration specifies to merge with the ref 'refs/heads/174-branchname'
from the remote, but no such ref was fetched.
lousyd $ git sync
Pulling commits from the server.
Traceback (most recent call last):
File "/home/lousyd/.local/bin/legit", line 8, in <module>
sys.exit(cli())
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/legit/cli.py", line 167, in sync
status_log(scm.smart_pull, 'Pulling commits from the server.')
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/legit/utils.py", line 14, in status_log
log = func(*args, **kwargs)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/legit/scm.py", line 137, in smart_pull
self.smart_merge_enabled())
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/legit/scm.py", line 151, in smart_merge
['log', '--merges', '{}..{}'.format(branch, from_branch)])
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/legit/scm.py", line 60, in git_exec
result = self.repo.git.execute(command, **kwargs)
File "/home/lousyd/.local/share/virtualenvs/pip-fh2szxJc/lib/python3.6/site-packages/git/cmd.py", line 823, in execute
raise GitCommandError(command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git log --merges origin/174-branchname..174-branchname
stderr: 'fatal: ambiguous argument 'origin/174-branchname..174-branchname': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]''
ttwalto $ git publish 174-branchname
Publishing 174-branchname.
Branch '174-branchname' set up to track remote branch '174-branchname' from 'origin'.
ttwalto $ git sync
Pulling commits from the server.
Current branch 174-branchname is up to date.
Pushing commits to the server.
It would be helpful for sync to give a friendlier and more informative error, like:
Error: Branch 174-branchname is not published. Use a branch that is already published.