-
Notifications
You must be signed in to change notification settings - Fork 873
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
Diff Context Lines (--unified=...) #423
Conversation
I agree. How about making the |
I'd forgotten about that thread - good call. Will see how far I can get on this tonight. |
* ContextLines * InterhunkLines Closes libgit2#423
Here's a start, but I'm not sure how to approach testing. The only test where we actually inspect a full diff is |
@@ -479,7 +488,7 @@ public void ComparingTwoNullTreesReturnsAnEmptyTreeChanges() | |||
{ | |||
using (var repo = new Repository(StandardTestRepoPath)) | |||
{ | |||
TreeChanges changes = repo.Diff.Compare(null, null, null); | |||
TreeChanges changes = repo.Diff.Compare(default(Tree), default(Tree)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Much more readable!
@dahlbyk @nulltoken f7fa450 is a proposal to ease testing of patches. I believe that most of the times when reading tests related to patches, you don't care about having the exact content of the patch near the code (and if you want it, you can just open the corresponding .patch file in the |
{ | ||
using (var repo = new Repository(StandardTestRepoPath)) | ||
{ | ||
Tree rootCommitTree = repo.Lookup<Commit>("f8d44d7").Tree; | ||
Tree commitTreeWithUpdatedFile = repo.Lookup<Commit>("ec9e401").Tree; | ||
|
||
TreeChanges changes = repo.Diff.Compare(rootCommitTree, commitTreeWithUpdatedFile); | ||
TreeChanges changes = repo.Diff.Compare(rootCommitTree, commitTreeWithUpdatedFile, | ||
compareOptions: new CompareOptions { ContextLines = (short)contextLines }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not force the consumer to pass in a short
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Great idea, @yorah! I rearranged f7fa450 a bit under the assumption that over time we'll collect more "expected" output:
|
😍 @dahlbyk Could you please rebase this so it can be merged? |
👍 |
* ContextLines * InterhunkLines Closes libgit2#423
@dahlbyk 💖 Could you please update your answer on SO to add a piece of code demonstrating your newest addition? |
Done! |
:Thanks! |
http://stackoverflow.com/questions/16402124/equivalent-to-git-diff-unified-0-with-libgit2sharp
Currently 3 lines of context is hard-coded:
libgit2sharp/LibGit2Sharp/Diff.cs
Line 27 in 6a2d99e