Actions
Bug #5167
closedgit-pbchk fails to detect parent branch
Start date:
2014-09-15
Due date:
% Done:
100%
Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:
External Bug:
Description
There is a bug in git-pbchk in that it attempts to pass whitespace to Popen() instead of using an array. Furthermore the splitting logic is busted.
Here's my solution, which uses the list form of submission to git() (thereby avoiding the busted format), and doing the split properly by using a scratch array to receive the split(), then checking the results.
--- /opt/onbld/bin/git-pbchk Mon Sep 15 11:13:27 2014 +++ /tank/garrett/illumos/usr/src/tools/scripts/git-pbchk.py Tue Jul 22 09:41:14 2014 @@ -122,8 +122,8 @@ if not branch: return None - p = git(["for-each-ref", "--format=%(refname:short) %(upstream:short)", - "refs/heads/"]) + p = git("for-each-ref --format=%(refname:short) %(upstream:short) " + + "refs/heads/") if not p: sys.stderr.write("Failed finding git parent branch\\n") @@ -130,9 +130,9 @@ sys.exit(err) for line in p: - arr = line.split() - if len(arr) > 1: - local, remote = arr[0], arr[1] + # Git 1.7 will leave a ' ' trailing any non-tracking branch + if ' ' in line and not line.endswith(' \\n'): + local, remote = line.split() if local == branch: return remote return 'origin/master'
Related issues
Updated by Garrett D'Amore over 8 years ago
Sorry, that was a "reverse" diff. Let's get it in the right direction:
garrett@proteus{27}> diff -u /tank/garrett/illumos/usr/src/tools/scripts/git-pbchk.py /opt/onbld/bin/git-pbchk --- /tank/garrett/illumos/usr/src/tools/scripts/git-pbchk.py Tue Jul 22 09:41:14 2014 +++ /opt/onbld/bin/git-pbchk Mon Sep 15 11:13:27 2014 @@ -122,8 +122,8 @@ if not branch: return None - p = git("for-each-ref --format=%(refname:short) %(upstream:short) " + - "refs/heads/") + p = git(["for-each-ref", "--format=%(refname:short) %(upstream:short)", + "refs/heads/"]) if not p: sys.stderr.write("Failed finding git parent branch\\n") @@ -130,9 +130,9 @@ sys.exit(err) for line in p: - # Git 1.7 will leave a ' ' trailing any non-tracking branch - if ' ' in line and not line.endswith(' \\n'): - local, remote = line.split() + arr = line.split() + if len(arr) > 1: + local, remote = arr[0], arr[1] if local == branch: return remote return 'origin/master'
Updated by Yuri Pankov almost 6 years ago
- Subject changed from git-pbchk fails when parent is not origin/master to git-pbchk fails to detect parent branch
- Status changed from New to In Progress
- Assignee set to Hans Rosenfeld
- % Done changed from 0 to 50
- Difficulty changed from Medium to Bite-size
- Tags deleted (
needs-triage)
hijacking the ticket to cherry-pick fix from illumos-nexenta.
Updated by Electric Monk almost 6 years ago
- Status changed from In Progress to Closed
- % Done changed from 50 to 100
git commit 28e2b3ad0b14867ee7f3383890f6658e6e9448a1
commit 28e2b3ad0b14867ee7f3383890f6658e6e9448a1 Author: Hans Rosenfeld <hans.rosenfeld@nexenta.com> Date: 2017-07-04T21:32:17.000Z 5167 git-pbchk fails to detect parent branch Reviewed by: Dan Fields <dan.fields@nexenta.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Robert Mustacchi <rm@joyent.com>
Updated by Yuri Pankov almost 6 years ago
- Has duplicate Bug #7128: git-pbchk fails to detect parent branch added
Actions