diff

Ignore newlines with diff

巧了我就是萌 提交于 2019-12-04 18:40:12
问题 I'd like to ignore newlines when I compare c source files. For example I want following two codes are reported they are same. // codeA int main(int argc, char *argv[]) { // codeB int main(int argc, char *argv[]) { I already have tried following options but could not get the result. diff -b codeA codeB diff -w codeA codeB 回答1: You can pretty print both files using, for example, GNU Indent, http://www.gnu.org/software/indent/ , and then compare them with diff. 回答2: There is a tool called "word

How to print the 2 full objects instead of show diff on a python unit test error?

守給你的承諾、 提交于 2019-12-04 18:13:40
For example, if I run this test: import unittest class TestAssertEqual(unittest.TestCase): def testString(self): self.maxDiff = None a = u'looooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggloooooooo\nooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnngggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg' b = u

Copy only difference (kdiff, winmerge, any diff like tool)

…衆ロ難τιáo~ 提交于 2019-12-04 18:13:14
问题 Is there possibility of copy ONLY difference of two files? Like in winmerge, but, I can't find this option Just like on this screen- i want to copy only 'yellow part' . Of course I can do that manually, but in big file it's not too funny :-) 回答1: WinMerge has a built-in and simple way to generate such "diff only" files, that they called "patches". Click on "Tool", then on "Generate Patch...", and enter where you want to store the result: You will obtain (for your example) the file 4,8c4,8 <

Algorithm: Find all common substrings between two strings where order is preserved

ⅰ亾dé卋堺 提交于 2019-12-04 18:12:08
Would like to discuss algorithms, no code. Problem: Let S and T be two sequences of elements. Find the common subsequences between them where the order of the elements is preserved . It should have O(n + m) running time where n is the length of S, and m is the length of T. I would also like to make the assumption that for the most part the two sequences will be similar. An optimal solution?: After some research, one solution that appears to be optimal is to first build a generalised suffix tree for the two sequences. Then find the longest common substring and consider this subsequence to be

Differences between the staged and unstaged versions of the same file, using difftool [duplicate]

岁酱吖の 提交于 2019-12-04 18:09:54
问题 This question already has answers here : Show both staged & working tree in git diff? (3 answers) Closed 2 years ago . Is there a way of viewing the differences between the staged and unstaged versions of the same file? For example: Changes to be committed: modified: conf/application.conf Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: conf/application.conf This

How to tell binary from text files in linux

删除回忆录丶 提交于 2019-12-04 17:36:31
问题 The linux file command does a very good job in recognising file types and gives very fine-grained results. The diff tool is able to tell binary files from text files, producing a different output. Is there a way to tell binary files form text files? All I want is a yes/no answer whether a given file is binary. Because it's difficult to define binary, let's say I want to know if diff will attempt a text-based comparison. To clarify the question: I do not care if it's ASCII text or XML as long

Diffing Binary Files In Python

放肆的年华 提交于 2019-12-04 17:04:10
I've got two binary files. They look something like this, but the data is more random: File A: FF FF FF FF 00 00 00 00 FF FF 44 43 42 41 FF FF ... File B: 41 42 43 44 00 00 00 00 44 43 42 41 40 39 38 37 ... What I'd like is to call something like: >>> someDiffLib.diff(file_a_data, file_b_data) And receive something like: [Match(pos=4, length=4)] Indicating that in both files the bytes at position 4 are the same for 4 bytes. The sequence 44 43 42 41 would not match because they're not in the same positions in each file. Is there a library that will do the diff for me? Or should I just write the

How do you make Git ignore spaces and tabs?

纵然是瞬间 提交于 2019-12-04 16:55:59
问题 I have a small scripting project that consists of five different source files in one directory called "Droid XX-XX-XX". Each time I created a new backup copy of the source directory, I put the date in the X's. So there are about 15 different versions from different dates. I want to add each of these to my bare new Git repository starting from the earliest. However I have run into several problems. One problem is that some of the files use tabs for indentation, while others use spaces -- but

How to ignore some differences in diff command?

瘦欲@ 提交于 2019-12-04 15:13:05
问题 diff has an option -I regexp , which ignores changes that just insert or delete lines that match the given regexp. I need an analogue of this for the case, when changes are between two lines (rather then insert or delete lines). For instance, I want to ignore all differences like between "abXd" and "abYd" , for given X and Y . It seems diff has not such kind of ability. Is there any suitable alternative for diff ? 回答1: You could filter the two files through sed to eliminate the lines you don

How to use an external diff tool for Git in Visual Studio 2013?

送分小仙女□ 提交于 2019-12-04 14:13:03
问题 I've found this post that explains how you can have Visual Studio 2013 use the built-in diff tool when comparing files in Git, but I'm having the opposite problem. Right now when I right-click on a file in the Git Commit Details window and choose Compare With Previous... VS performs the diff in the default Visual Studio 2013 compare tool, but I want it to use an external diff tool, specifically TortoiseMerge.exe. I have it specified in my C:\Users\[My Name]\.gitconfig and it works properly