diff

Algorithm: optimal way to rearrange a list from one order to another?

无人久伴 提交于 2019-12-18 12:35:28
问题 EDIT: I'm not sure that my original question is clear enough. I need an algorithm that will compute the minimal sequence of moves to rearrange an array from one order to another. It is known that both arrays will contain the same elements (no duplicates) and have the same length. For example: reorder( ['d', 'a', 'c', 'b', 'e'], ['a', 'b', 'c', 'd', 'e'] ) should return something like: [ {move:'d', after:'b'}, {move:'c', after:'b'} ] which indicates that I should first move the element 'd' to

C# Diff Algorithm for Text [closed]

為{幸葍}努か 提交于 2019-12-18 11:30:00
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I'm looking for a diff algorithm that will produce results like SO's edit revisions page. I've more or less just started looking and I'm not opposed to doing it myself but I don't need to reinvent the wheel. I'll be using C# 4.0. I'll basically have two strings, and old one and a

ignoring changes matching a string in git diff

末鹿安然 提交于 2019-12-18 10:50:29
问题 I've made a single simple change to a large number of files that are version controlled in git and I'd like to be able to check that no other changes are slipping into this large commit. The changes are all of the form - "main()", + OOMPH_CURRENT_FUNCTION, where "main()" could be the name of any function. I want to generate a diff of all changes that are not of this form. The -G and -S options to git diff are tantalisingly close--they find changes that DO match a string or regexp. Is there a

How to ignore line endings when comparing files?

依然范特西╮ 提交于 2019-12-18 10:36:00
问题 I am comparing two text files and I get the following result diff file1 file2 | grep 12345678 > 12345678 < 12345678 As you can see the same string exists in both files, and both files were sorted with sort . The line endings must be getting in the way here (windows vs unix). Is there a way to get diff to ignore line endings on unix? 回答1: Use the --strip-trailing-cr option: diff --strip-trailing-cr file1 file2 the option causes diff to strip the trailing carriage return character before

How to count differences between two files on linux?

房东的猫 提交于 2019-12-18 10:26:23
问题 I need to work with large files and must find differences between two. And I don't need the different bits, but the number of differences. To find the number of different rows I come up with diff --suppress-common-lines --speed-large-files -y File1 File2 | wc -l And it works, but is there a better way to do it? And how to count the exact number of differences (with standard tools like bash, diff, awk, sed some old version of perl)? 回答1: diff -U 0 file1 file2 | grep -v ^@ | wc -l That minus 2

How to get diff working like git-diff?

删除回忆录丶 提交于 2019-12-18 09:55:28
问题 I like the output formatting of git diff . The color and the + / - representation of changes between lines is easier to read than GNU diff. I can run git diff using --no-index flag outside of a git repo and it works fine. However, it appears to be missing the --exclude option for excluding files or subdirectories from a recursive diff . Is there a way to get the best of both worlds? (color options and + / - format of git diff and --exclude option of GNU diff). I've experimented with colordiff

Is there a safe way to run a diff on two zip compressed files?

我是研究僧i 提交于 2019-12-18 03:54:48
问题 Seems this would not be a deterministic thing, or is there a way to do this reliably? 回答1: If you're using gzip, you can do something like this: # diff <(zcat file1.gz) <(zcat file2.gz) 回答2: Reliable: unzip both, diff. I have no idea if that answer's good enough for your use, but it works. 回答3: In general, you cannot avoid decompressing and then comparing. Different compressors will result in different DEFLATEd byte streams, which when INFLATEd result in the same original text. You cannot

Is there a safe way to run a diff on two zip compressed files?

岁酱吖の 提交于 2019-12-18 03:54:25
问题 Seems this would not be a deterministic thing, or is there a way to do this reliably? 回答1: If you're using gzip, you can do something like this: # diff <(zcat file1.gz) <(zcat file2.gz) 回答2: Reliable: unzip both, diff. I have no idea if that answer's good enough for your use, but it works. 回答3: In general, you cannot avoid decompressing and then comparing. Different compressors will result in different DEFLATEd byte streams, which when INFLATEd result in the same original text. You cannot

Can gitk show the diff of merges by default?

▼魔方 西西 提交于 2019-12-18 03:32:57
问题 Currently for merges without conflicts gitk shows no diffs. Is it possible to have the diffs resulting from a merge (which are indeed there, e.g. git diff HEAD~1 after the merge shows these diffs) shown by defautl, e.g. using a command line switch? Or why does gitk by default not show them? 回答1: By default gitk does the same thing as the --cc option to git diff and compresses the merge to only show diff chunks that don't come directly from one or other parent. This is usually more helpful as

Git: Compare All Local Commits to Remote Repo Version

让人想犯罪 __ 提交于 2019-12-18 01:29:07
问题 I'm somewhat new to Git and what I'm trying to do seems like it should be possible. Basically I've been working off of clone of a repo and have made quite a few local commits. Is there a way to see the diff of the 'sum' of all my changes and the original repo version? I would assume this would be possible because Git will essentially do this when I do a push . Here is an example of what I'm trying to do: in gitk I will see something like this: * - [mybranch] Added '42' to end of answers.txt