GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add support for git diff --indent-heuristic option by jcansdale · Pull Request #1652 · libgit2/libgit2sharp

Conversation

@jcansdale

@jcansdale jcansdale commented Dec 19, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What this PR does

  • Add IndentHeuristic option to CompareOptions (it's a bool)
  • Add test to check that --indent-heuristic makes a difference
  • Add test for when --indent-heuristic won't make a difference

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jcansdale added 4 commits December 19, 2018 18:00
@jcansdale
Add IndentHeuristic option to CompareOptions
e34ae5b
@jcansdale
Test for IndentHeuristic Diff option
6a6f134
This test is based on example from:
https://github.com/git/git/blob/433860f3d0beb0c6f205290bd16cda413148f098/t/t4061-diff-indent.sh#L17
@jcansdale
Take account of CompareOptions.IndentHeuristic
98be00a
When this flag is set, enable the GIT_DIFF_INDENT_HEURISTIC option.
@jcansdale
Test for when IndentHeuristic makes no difference
e063680
When compared files don't contain spaces, the --indent-heuristic option
won't make a difference.
Therzok
Therzok reviewed Dec 19, 2018
View reviewed changes
Comment thread LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs
ContentChanges changes0 = repo.Diff.Compare(oldBlob, newBlob, noIndentHeuristicOption);
ContentChanges changes1 = repo.Diff.Compare(oldBlob, newBlob, indentHeuristicOption);

Assert.NotEqual(changes0.Patch, changes1.Patch);

@Therzok Therzok Dec 19, 2018

Copy link
Copy Markdown
Member

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.

Can we validate that changes0 is a superset of changes1?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Therzok Therzok Dec 19, 2018

Copy link
Copy Markdown
Member

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.

Or validate the results of the patch strings?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jcansdale jcansdale Dec 19, 2018

Copy link
Copy Markdown
Contributor Author

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.

I was wondering about what exactly to validate in this case. The main thing I wanted to validate was that the flag was making its way to indent heuristic code. By checking when we expect the flag to make a difference and when we don't expect it to make a difference, I hope that is pretty much covered.

I've added a sanity check in 2f583cb to make sure that the same lines are being added or removed. I'm trusting the algorithm to add or remove them in the correct order. 🙂

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jcansdale
Check the same lines have been added or removed
2f583cb
The --indent-heuristic option should create patches that add or remove
the same lines, but potentially in a different order.
@jcansdale jcansdale mentioned this pull request Dec 20, 2018
Update to use modern version of LibGit2Sharp and use indent heuristic when diffing github/VisualStudio#2142
Merged
3 tasks done
@ethomson
ethomson merged commit ac599f4 into libgit2:master Dec 25, 2018
@jcansdale
jcansdale deleted the fixes/git-diff-indent-heuristic branch January 7, 2019 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@Therzok Therzok Therzok left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@jcansdale @Therzok @ethomson
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.