repos: git: Strip of heads/ prefix when checking out branches
If a remote branch is referenced as refs/heads/<branch>, also drop the heads/ from the local branch name to have a consistent naming. This wasn't noticed so far because the primary use case of refs/ is addressing symbolic refs in upstream, and the related test case (test_refspec_absolute) was papering over another hidden kas issues while using refs/heads/. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
a317a0e957
commit
420bf399b3
@ -443,7 +443,9 @@ class GitRepo(RepoImpl):
|
||||
def checkout_cmd(self, desired_ref, is_branch):
|
||||
cmd = ['git', 'checkout', '-q', self.remove_ref_prefix(desired_ref)]
|
||||
if is_branch:
|
||||
cmd.extend(['-B', self.remove_ref_prefix(self.refspec)])
|
||||
branch = self.remove_ref_prefix(self.refspec)
|
||||
branch = branch[branch.startswith('heads/') and len('heads/'):]
|
||||
cmd.extend(['-B', branch])
|
||||
if get_context().force_checkout:
|
||||
cmd.append('--force')
|
||||
return cmd
|
||||
|
Loading…
Reference in New Issue
Block a user