Defect #31120
closedGarbage lines in the output of 'git branch' break git adapter
0%
Description
I found that adding an if condition around line 84-89 solves the issue.
change:
branch_rev = line.match('\s*(\*?)\s*(.*?)\s*([0-9a-f]{40}).*$')
bran = GitBranch.new(branch_rev[2])
bran.revision = branch_rev[3]
bran.scmid = branch_rev[3]
bran.is_default = ( branch_rev[1] == '*' )
@branches << bran
To:
if branch_rev = line.match('\s*(\*?)\s*(.*?)\s*([0-9a-f]{40}).*$')
bran = GitBranch.new(branch_rev[2])
bran.revision = branch_rev[3]
bran.scmid = branch_rev[3]
bran.is_default = ( branch_rev[1] == '*' )
@branches << bran
end
Files
Updated by Chad Petersen almost 6 years ago
The file is {redmineroot}\lib\redmine\scm\adapters\git_adapter.rb
Updated by Go MAEDA almost 6 years ago
- File 31120.patch 31120.patch added
I have generated a patch file from Chad Petersen's post.
Updated by Go MAEDA almost 6 years ago
- Status changed from New to Needs feedback
The fixed code looks correct but I was not able to reproduce the situation that 'git branch --no-color --verbose --no-abbrev' outputs a single branch using two or more lines even if the commit log consists of multiple lines.
Could you tell me the operations to make a repository that causes the problem?
Updated by Chad Petersen almost 6 years ago
It's a bit of an odd setup. This particular team is using TFS as its source control. So in order to pull it across to git, I'm using the git-TFS integration found here: https://github.com/git-tfs/git-tfs. This appends git commit messages with a new line including the TFS commit so you can trace them back.
Updated by Go MAEDA almost 6 years ago
- Tracker changed from Patch to Defect
- Subject changed from Git commit with multi-line comment on a project with more than one branch breaking parser. to Git commit with multi-line comment on a project with more than one branch breaking parser
- Status changed from Needs feedback to New
- Target version set to 3.4.11
Chad Petersen wrote:
It's a bit of an odd setup. This particular team is using TFS as its source control. So in order to pull it across to git, I'm using the git-TFS integration found here: https://github.com/git-tfs/git-tfs. This appends git commit messages with a new line including the TFS commit so you can trace them back.
I understand. Thank you for clarifying.
I cannot reproduce the problem because I don't use TFS, but the code after line 86 ('bran = GitBranch...
') must not be executed if branch_rev
is nil. I am setting the target version to 3.4.11.
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index e0c5d4763..0733cbc40 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -84,6 +84,7 @@ module Redmine
git_cmd(cmd_args) do |io|
io.each_line do |line|
branch_rev = line.match('\s*(\*?)\s*(.*?)\s*([0-9a-f]{40}).*$')
+ next unless branch_rev
bran = GitBranch.new(branch_rev[2])
bran.revision = branch_rev[3]
bran.scmid = branch_rev[3]
Updated by Go MAEDA almost 6 years ago
- Subject changed from Git commit with multi-line comment on a project with more than one branch breaking parser to Multi-line commit message breaks git adapter when parsing branches
Updated by Go MAEDA almost 6 years ago
- Subject changed from Multi-line commit message breaks git adapter when parsing branches to Garbage lines in the output of 'git branch' break git adapter
- Status changed from New to Resolved
- Assignee set to Go MAEDA
- Resolution set to Fixed
Fixed in r18046. Thank you for your contribution.