Skip to content
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

Fixup GetAllBranchesWhichContainGivenCommit #10836

Merged
merged 2 commits into from Mar 27, 2023

Conversation

mstv
Copy link
Member

@mstv mstv commented Mar 26, 2023

Fixes #10819

Proposed changes

  • correctly split git output, i.e. only at line ends
  • remove first two columns only if in expected format "* ", "+ " or " "

Screenshots

n/a

Test methodology

  • extended existing testcase

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@mstv mstv self-assigned this Mar 26, 2023
@@ -3141,12 +3141,12 @@ public IReadOnlyList<string> GetAllBranchesWhichContainGivenCommit(ObjectId obje
return Array.Empty<string>();
}

var result = exec.StandardOutput.Split(new[] { '\r', '\n', '*', '+' }, StringSplitOptions.RemoveEmptyEntries);
string[] result = exec.StandardOutput.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add a comment explaining what information git may provide and what transformation we do.
IIRC, * denotes the current branch, but I can't remember what + may be used for...

Copy link
Member

@gerhardol gerhardol Mar 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RussKie that would be a link to Git documentation
Documentation is poor, does not statate that the line starts with two chars before branch
So something should be added below (this line is fine).

https://git-scm.com/docs/git-branch#_description

+ is used for linked work trees, similar to *

@@ -3141,12 +3141,12 @@ public IReadOnlyList<string> GetAllBranchesWhichContainGivenCommit(ObjectId obje
return Array.Empty<string>();
}

var result = exec.StandardOutput.Split(new[] { '\r', '\n', '*', '+' }, StringSplitOptions.RemoveEmptyEntries);
string[] result = exec.StandardOutput.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
Copy link
Member

@gerhardol gerhardol Mar 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RussKie that would be a link to Git documentation
Documentation is poor, does not statate that the line starts with two chars before branch
So something should be added below (this line is fine).

https://git-scm.com/docs/git-branch#_description

+ is used for linked work trees, similar to *

GitCommands/Git/GitModule.cs Outdated Show resolved Hide resolved
@mstv mstv merged commit 0430677 into gitextensions:master Mar 27, 2023
1 of 2 checks passed
@mstv mstv deleted the fix/i10819_contained_in_branches branch March 27, 2023 19:43
@ghost ghost added this to the vNext milestone Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CommitInfo: "Contained in branches" splits branch name at '+' character
3 participants