aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2023-03-10 16:57:53 +1100
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2023-03-10 15:04:23 -0500
commit4f90eab09937e78f27e63a01076af72f8d45e3f3 (patch)
tree00a3175fb65ecbba1449cb82167044ae51a4d240
parent3f473c7547792707abd093a2b7a131fdf8be8264 (diff)
downloadb4-4f90eab09937e78f27e63a01076af72f8d45e3f3.tar.gz
ty: Fix git-config regexp in get_branch_info()
The regexp used to get the branch configuration in get_branch_info() is subtly wrong. If there are multiple branches starting with the same prefix, the configuration for all of them will be returned, which can lead to the wrong branch info being used. eg. Running b4 -d ty, with extra logging of every line in get_config_from_git() shows: Running git --no-pager config -z --get-regexp branch\.foo\.* branch.foo.remote . branch.foo.merge refs/heads/foo-test branch.foo-test.remote . branch.foo-test.merge refs/heads/foo-base Although the regexp has two escaped dots, the 2nd one is seemingly consumed by the '*', leading to the regexp matching "foo" and "foo-test". This can be observed on the command line: $ git branch -t foo origin/master $ git branch -t foo-test origin/master $ git --no-pager config --get-regexp "branch\.foo\.*" branch.foo.remote . branch.foo.merge refs/heads/foo-test branch.foo-test.remote . branch.foo-test.merge refs/heads/foo-base The real problem is that we meant to pass a regexp of "branch\.foo\..*", so change the code to use that, which fixes the problem: $ git --no-pager config --get-regexp "branch\.foo\..*" branch.foo.remote origin branch.foo.merge refs/heads/master Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20230310055753.1609529-1-mpe@ellerman.id.au Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/ty.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/b4/ty.py b/b4/ty.py
index 4594116..863441e 100644
--- a/b4/ty.py
+++ b/b4/ty.py
@@ -627,7 +627,7 @@ def get_branch_info(gitdir, branch):
BRANCH_INFO = dict()
- remotecfg = b4.get_config_from_git('branch\\.%s\\.*' % branch)
+ remotecfg = b4.get_config_from_git('branch\\.%s\\..*' % branch)
if remotecfg is None or 'remote' not in remotecfg:
# Did not find a matching branch entry, so look at remotes
gitargs = ['remote', 'show']