libgit2 / libgit2/libgit2sharp
BlameHunk line numbers are zero-based?
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Description
var x = 5; // just an example
var options = new BlameOptions {MinLine = x, MaxLine = x};
var hunks = repository.Blame(path, options);
var hunk = hunks.HunkForLine(x); // throws ArgumentOutOfRangeException: 'No hunk for that line'
It seems that though the line numbers in BlameOptions are one-based (according to the code comments), BlameHunkCollection.HunkForLine, BlameHunk.ContainsLine, BlameHunk.FinalStartLineNumber and BlameHunk.InitialStartLineNumber are all zero based.
Is this a bug, or intentional? If intentional, it would be good to add to the comments on all of these which base is to be expected. Thanks.
I can subtract one in the HunkForLine call to work around for now.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with BlameOptions, BlameHunkCollection.HunkForLine, BlameHunk.ContainsLine, and the FinalStartLineNumber and InitialStartLineNumber properties. Reproduce the shown call, compare the documented and observed indexing, and determine whether the APIs should be aligned or explicitly documented; done means the behavior is consistent or clearly specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, git
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100