I sometimes edit xml-like files, like plist
s or xib
s, and sometimes i get diffs like .
Instead of the diff starting with the <dict>
and ending with the </dict>
, it starts and ends +2 lines. This also happens sometimes with Objective-C code too. I would add a new case
in a switch
, and the diff will not start from case
down to break
, but it will again have an offset of one or two lines.
I understand that this happens because the previous and next lines are basically the same, but is there a way I can avoid this, fix this, or change its behavior in some way?
Thanks.
Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
The git diff command helps you see, compare, and understand changes in your project. You can use it in many different situations, e.g. to look at current changes in your working copy, past changes in commits, or even to compare branches.
Hashes and diffs If you then make changes, git will only need to store the changes (also called the diff), but it will also store the hash of the data.
When viewing a combined diff, if the two files you're comparing have a line that's different from what they were merged into, you will see the ++ to represent: one line that was added does not appear in either file1 or file2.
Try another diff algorithm. I had good results with the patience algorithm in cases like this.
Use for example:
git diff --patience
From the git-diff
manual:
--patience
Generate a diff using the "patience diff" algorithm.
--diff-algorithm={patience|minimal|histogram|myers}
Choose a diff algorithm. The variants are as follows:
default, myers
The basic greedy diff algorithm. Currently, this is the default.
minimal
Spend extra time to make sure the smallest possible diff is produced.
patience
Use "patience diff" algorithm when generating patches.
histogram
This algorithm extends the patience algorithm to "support low-occurrence common elements".
Related:
git diff --patience
for?If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With