FAQ Database Discussion Community


C# XML Diffing algorithm

c#,xml,diff
I have two XML, before and after the user has edited them. I need to check that user have only added new elements but have not deleted or changed old ones. Can anybody suggest to me a good algorithm to do that comparison? Ps: My XML has a very trivial...

How to style diff implementation for PHP with CSS

php,css,diff
http://code.stephenmorley.org/php/diff-implementation/#styling I am following above link to test code. I have put them together but in the browser but I am not seeing any nice color table just like author mentioned. I don't know how to include style code any idea on how to do that? index.php <?php // include...

Git diff partial file name

git,diff
Is there a way to specify a partial file name in order to save keystrokes? Instead of: git diff path/path/path/path/path/somefilename.js To something like: git diff *somefilename.js Or: git diff .somefilename.js ...

Sublime only opens in Sublimerge view

view,merge,diff,sublimetext3,restore
I have the plugin Sublimerge installed in Sublime Text 3. In order to compare two files Sublimerge opens a new window (but without any menu). That is fine since the original Sublime window is still there. Unfortunately the diff-window was the last one I closed and when I restart Sublime...

How do I move an unstaged file to untracked?

git,diff,track
Say this is what I'm looking at in git status: Changes not staged for commit: modified: Makefile.in Untracked files: ../node_modules/somepath/inverter_packet.js What I want to do is something like move Makefile.in from 'Changes not staged for commit' to 'Untracked files.' I know I can ignore changes with git update-index --assume-unchanged Makefile.in,...

How to store revision data in database?

c#,sql-server,version-control,diff
I have a column in a SQL Server database table of type xml. This column data has to be able to store all its previous revisions and some data on each revision. Since it could be massive files with very few changes it would be silly to store the entire...

Export a condensed file by file diff/patch between 2 git commits?

git,diff
I came across this code to export a patch from a specific location in a repository git log --author=jdoe oldbranch..newbranch -p -- path/to/subdirectory > myChangesInSubdirectory.patch It, of course, goes by commit rather than all scrunched together, because that's what a patch does. But I would like to be able to...

Remove files excluding files-list in file in shell - delete files from one directory that don't also exist in another

bash,file,shell,diff
I have file with files: ./aaa ./bbb ./c/ccc ./d/ddd I have another directory with the same files and some another ones. ./aaa ./bbb ./c/ccc ./d/ddd ./to-remove-1 ./c/to-rem-ove-2 I need to remove all files that are not in the first list. P.S. Actually the first list has been made by command...

Using Compare-Object in a script: where is my return value?

powershell,diff
I'm trying to write a powershell script which will do one thing if two text files are different, and another thing if the files are the same. In Unix, I can just do diff a.txt b.txt; if [ $? -eq 0 ]; then ..., but I'm having trouble programmatically determining...

Git: Differences since a commit

git,diff,git-diff
Given this output: c:\git\xxx>git log --oneline -n 5 b99c981 Merge remote-tracking branch 'origin/xxx-newfeature' into xxx-blah e53f30a [maven-release-plugin] prepare for next development iteration e40978b [maven-release-plugin] prepare release xxx-3.9.6 0639706 Modified Ant installion path 654ef47 [maven-release-plugin] prepare for next development iteration What are the GIT diff commands to see: What changed in...

using diff and -y limitation on number of characters displayed

bash,diff
I have these 2 files file1.txt: $ cat file1.txt I need to buy apples. I need to buy apples. I need to buy apples. I need to buy apples. I need to buy apples. I need to run the laundry. I need to wash the dog. I need to get...

How to default to side-by-side view in GitLab

diff,gitlab,git-diff
How can I make Side-by-side be the default diff for my GitLab installation or project or profile?

increase in one variable nested within another column in R + setting 0 as starting value

r,nested,diff
I'm trying to use the diff function to calculate the increase in a variable ("damage") in this dataset (df). I want to fill the column "damage_new" with this new variable. The values that you see now are the values I would like to have. df = data.frame(id=c(1,1,1,2,2), trial=c(1,3,4,1,2), damage=(1,NA,3,1,5)) df...

Why does git difftool use git diff instead?

git,diff,config,vimdiff,meld
I want git diff to be a quick command line solution to see the difference between two files, and then I want git difftool to launch meld for a more graphical view of the file differences. Currently, git diff does exactly what I want it to, however when I run...

How can I do “svn diff” side-by-side in emacs.

emacs,diff,side-by-side
M-x vc-diff is cool. But not enough for me. Is it possible to diff side-by-side in emacs like GUI diff tools ? (kdiff3, meld)

View diff between two git revisions in VS2013

git,visual-studio,visual-studio-2013,diff
When using git for source control in VS2013, is there any way to show a diff between two arbitrary versions of a source file in the integrated editor (either with built in functionality or a free extension/plugin)? So far I only found out how to display the changes made since...

The most efficient way to do the differences between the columns in SAS

sas,diff
I have a SAS data set like below. I want to use the first column values as a minuend, which is column 2 - column 1, column 3 - column 1, column 4 - column 1... Which is the most efficient way to do this diff in SAS? Using array...

diff with file names prefixing each line

shell,diff
How can I diff two (or more) files, displaying the file name at the beginning of each line? That is, instead of this: --- file1.c +++ file2.c @@ -1 +1 @@ -int main() { +int main(void) { I would prefer something like this: file1.c:- int main() { file2.c:+ int main(void)...

Inconsistent result of SVN diff command

svn,diff
Problem: the svn diff command seems to be inconsistent when executing on a whole repository, compared with the execution on a single file. An example: consider the r542208 commit of the Apache Tomcat source code. svn log -v -r r542208 http://svn.apache.org/repos/asf/ Result: ------------------------------------------------------------------------ r542208 | fhanik | 2007-05-28 13:39:15 +0200...

Comparing baseline differences including file contents

diff,clearcase,baseline
I know that I can use the diffbl command to compare two baselines. But how can I also ask the command to print out the diffs of all the files that were different? Is this even possible or do I need to write a script or something? Any pointers?...

Git diff of a branch, excluding commits in other branch

git,diff
To do code review, I often make a git difftool hash_of_parent_of_first_commit_in_branch last_commit_in_branch of a feature branch. The feature_branch was created from its source (let's call it master branch) and work was done on it. But in the middle of this time, the master branch received some commits, and these commits...

diff command label format

linux,bash,scripting,diff
is it possible to get header or label on two diff file using diff or sdiff command or any other tool. following just example, we have a script which comparing 100s of file so it is good to know which one we are comparing.. currently: # diff -y --suppress-common-lines /tmp/file1...

How to use DateTime diff : PHP

php,datetime,diff
I am using the DateTime diff function in a function, for this I need to work out the amount of seconds between a set of dates. I have this function: public function CanBet($bettilltime, $bettilldate, $betsettime, $betsetdate, $amount) { $can_bet = true; $bettilltime = new DateTime(date("H:i:s", strtotime($bettilltime))); $bettilldate = new DateTime(date("Y-m-d",...

Differentiate function without Symbolic Math Toolbox

matlab,diff,symbolic-math
If I want to differentiate a function, I would do the following: syms x f(x) = sin(x^2); df = diff(f) ,but that requires the use of the Symbolic Math Toolbox (for the syms function). Is there a workaround (an alternative) to this method without the use of the Symbolic Toolbox?...

Side-by-side diff (-y) : how to hide the reverse-video ^M (at end-of-line)?

linux,text,diff,gnu,eol
Problem I'm diffing files side-by-side (-y) on a GNU/Linux system: $ diff -y file1 file2 but each end-of-line results in spurious ^M in reverse video... one for the left line and one for the right line. Here's the version of diff I'm using: diff (GNU diffutils) 3.3 EDIT: I forgot...

Git > diffs filtered, show only certain changed classes/files

git,filter,grep,diff,git-log
I have 2 versions of a software (i.e. tag 4.1 and tag 4.2). Now I want to filter out in which java classes of version 4.1 there were fixed bugs. If I enter git diff r4.1 r4.2 --name-only > patch.csv I get a list of all changed classes from version...

Diff command in bash

bash,diff
Every time i run the following bash command, i get an error: Here's the code: sort -b ./tests/out/$scenario > $studentFile sort -b ./tests/out/$scenario > $profFile $(diff $studentFile $profFile) if [ $? -eq 0 ] then echo "Files are equal!" else echo "Files are different!" fi Here's the error: ./test.sh: 2c2:...

How to test if two files are identical via mocha

node.js,file,diff,mocha
I have written a node.js script which scans a very large legacy code base and applies a set of changes. The changes can be quite complex because this affects certain storage mechanisms and associated size definitions. I've written tests that all the calculations and reporting is correct by using mocha,...

How to diff ansible vault changes?

git,diff,ansible,ansible-vault
I'd like to see the actual git commit changes in the ansible vault file. Is there an easy way how to achieve this?...

R function for time difference calculation

r,diff
I have this function for calculating difference of consecutive date/times in seconds. It is working fine, but I would like to understand why I need the first line: padded.diff <- function(x) c(0L, diff(x)) df2=within(df, { date <- strptime(Last.Modified.Date, format="%d.%m.%Y %H:%M:%S") date.diff <- padded.diff(as.numeric(date)) }) Why does it give me an...

How to reconstruct diff data with leading NAs using diffinv in R?

r,matrix,diff,cumsum
I have a large data matrix (“trial.matrix”) similar to the one below. [,1] [,2] [1,] 3 NA [2,] 5 NA [3,] 7 NA [4,] 9 10 [5,] 11 12 [6,] 13 14 My problem requires that I shuffle some rows of the difference version of this matrix and then reconstruct...

What does a red text-background mean in GitHub comparison view?

github,diff
I created a pull request and was browsing through, the differences are shown with light red/green line-brackgrounds, but some text is bolded with a red text background... Update: Image changed to show file with some highlighted comments and some not. What does this mean?...

How does Github generate small branch diffs?

git,github,diff
Let's say I work on a project in the following order: Fork master to branch named BRANCH-A Merge BRANCH-B to master Merge BRANCH-C to master Do some work on BRANCH-A and submit a pull request Now, if I checkout BRANCH-A locally and run git diff master, the diff will include...

Python - Compare 2 files and output differences

python,file,compare,output,diff
I'm aiming to write a script that will compare each line within a file, and based upon this comparison, create a new file containing the lines of text which aren't in the second file. For example; **File 1:** Bob:20 Dan:50 Brad:34 Emma:32 Anne:43 **File 2:** Dan:50 Emma:32 Anne:43 The new...

Scala - finding first position in which two Seq differ

scala,diff,sequence,seq
Scala comes with the nice corresponds method: val a = scala.io.Source.fromFile("fileA").getLines().toSeq() val b = scala.io.Source.fromFile("fileB").getLines().toSeq() val areEqual = a.corresponds(b){_.equals(_)} if(areEqual) ... And I quite like the brevity of that. Is there a similar method already defined that will also report to me the first position in which the two sequences...

diff: Only compare files and ignore subdirectories

linux,bash,shell,command-line,diff
I'm trying to compare two directories, each with some files and a subdirectory. Is there any way to run diff on these two folders, but not run it on the subdirectory? I've tried using diff -x'*/' foo bar, as well as a couple variants with backslashes to escape them, but...

Interactively merge files tracked with git and untracked local files

git,command-line,merge,diff,interactive
I use a couple of software packages (like gitlab) that you install by cloning from their git repo. They typically come with some config.example (under version control), which you copy to your own config file (not under version control or even ignored in .gitignore) and adapt to your needs. When...

How can I make `git diff` as fine-grained as StackExchange diff?

diff,git-diff
Is there a diff tool which can highlight single character edits as such, and not just show the old and new version of the whole line (i.e. the kind of diff StackExchange shows you for edits to a post)? I'd prefer one I could use on the Linux command line...

PHP DateTime diff

php,datetime,diff,days
This may be a complete noob question but here goes: I have the following code that compares two dates for absence management. Where I expect the answer to return as 2 (the difference between start and end date) I get 1. $start_time = new DateTime("2015-01-01 00:00:00"); $end_time = new DateTime("2015-01-02...