Skip to content

git expects boolean value to be lower case #578

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

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(refs): handle quoted branch names
Fixes #550
  • Loading branch information
Byron authored and barry-scott committed Feb 2, 2017
commit d803684b5217a0825aa8cd1309efe8ef24c7af30
8 changes: 7 additions & 1 deletion git/refs/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
__all__ = ["HEAD", "Head"]


def strip_quotes(string):
if string.startswith('"') and string.endswith('"'):
return string[1:-1]
return string


class HEAD(SymbolicReference):

"""Special case of a Symbolic Reference as it represents the repository's
Expand Down Expand Up @@ -152,7 +158,7 @@ def tracking_branch(self):
from .remote import RemoteReference
reader = self.config_reader()
if reader.has_option(self.k_config_remote) and reader.has_option(self.k_config_remote_ref):
ref = Head(self.repo, Head.to_full_path(reader.get_value(self.k_config_remote_ref)))
ref = Head(self.repo, Head.to_full_path(strip_quotes(reader.get_value(self.k_config_remote_ref))))
remote_refpath = RemoteReference.to_full_path(join_path(reader.get_value(self.k_config_remote), ref.name))
return RemoteReference(self.repo, remote_refpath)
# END handle have tracking branch
Expand Down
12 changes: 12 additions & 0 deletions git/test/test_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ def test_heads(self, rwrepo):
assert head.tracking_branch() == remote_ref
head.set_tracking_branch(None)
assert head.tracking_branch() is None


special_name = 'feature#123'
special_name_remote_ref = SymbolicReference.create(rwrepo, 'refs/remotes/origin/%s' % special_name)
gp_tracking_branch = rwrepo.create_head('gp_tracking#123')
special_name_remote_ref = rwrepo.remotes[0].refs[special_name] # get correct type
gp_tracking_branch.set_tracking_branch(special_name_remote_ref)
assert gp_tracking_branch.tracking_branch().path == special_name_remote_ref.path

git_tracking_branch = rwrepo.create_head('git_tracking#123')
rwrepo.git.branch('-u', special_name_remote_ref.name, git_tracking_branch.name)
assert git_tracking_branch.tracking_branch().name == special_name_remote_ref.name
# END for each head

# verify REFLOG gets altered
Expand Down