diff

Git diff --stat explanation

青春壹個敷衍的年華 提交于 2019-11-26 20:18:46
问题 Git's pull output has been explained here fairly well. In spite of this I'm still unsure exactly what the text graph relates to. For example: git diff --stat master HEAD^ Outputs (truncated): Site/index.php | 118 ++-- While the number of lines modified is clearly displayed as 118, the text graph is a little harder to interpret. Could this relate to the ratio of added and removed lines? 回答1: Yes it's the ratio of added and removed lines. See also: man diffstat 回答2: git diff --numstat "@{1 day

Show both staged & working tree in git diff?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 19:56:30
问题 If I run git diff I see the changes in my working tree, and if I run git diff --staged (alternatively --cached ) then I see the changes that are staged (w/ git add ) but is there a way with git diff to see all in one go? 回答1: Is there a way with git diff to see all in one go? There is, with Git 2.4.0+ (April 2015). See commit 4055500 from Michael J Gruber mjg: commit / status : show the index-worktree diff with -v -v (or -vv ) git commit and git status in long format show the diff between

An efficient way to get the difference between two arrays of objects?

那年仲夏 提交于 2019-11-26 19:53:22
问题 I have two arrays of objects: var a = [ {'id': 20}, {'id': 15}, {'id': 10}, {'id': 17}, {'id': 23} ]; var b = [ {'id': 90}, {'id': 15}, {'id': 17}, {'id': 23} ]; I'd like to get objects which are in a, but not in b. Results from this example would be: {'id': 20} and {'id': 10} . Because the arrays could be large, I need an efficient way to do this. 回答1: // Make hashtable of ids in B var bIds = {} b.forEach(function(obj){ bIds[obj.id] = obj; }); // Return all elements in A, unless in B return

Bash: using the result of a diff in a if statement

时间秒杀一切 提交于 2019-11-26 19:44:09
问题 I am writing a simple Bash script to detect when a folder has been modified. It is something very close to: ls -lR $dir > a ls -lR $dir > b DIFF=$(diff a b) if [ $DIFF -ne 0 ] then echo "The directory was modified" Unfortunately, the if statement prints an error: [: -ne: unary operator expected I am not sure what is wrong with my script, would anyone please be able to help me? Thank you very much! Jary 回答1: ls -lR $dir > a ls -lR $dir > b DIFF=$(diff a b) if [ "$DIFF" != "" ] then echo "The

How to read .rej files, i.e

拈花ヽ惹草 提交于 2019-11-26 19:43:49
问题 I'm having trouble applying a patch to my source tree, and it's not the usual -p stripping problem. patch is able to find the file to patch. Specifically, my question is how to read / interpret the .rej files patch creates when it fails on a few hunks. Most discussions of patch / diff I have seen don't include this. 回答1: A simple example: $ echo -e "line 1\nline 2\nline 3" > a $ sed -e 's/2/b/' <a >b $ sed -e 's/2/c/' <a >c $ diff a b > ab.diff $ patch c < ab.diff $ cat c.rej ***************

Are there any free Xml Diff/Merge tools available? [closed]

ε祈祈猫儿з 提交于 2019-11-26 19:39:37
I have several config files in my .net applications which I would like to merge application settings elements etc. I was about to begin doing it manually as I usually do, however thought there must be an XML diff GUI tool available somewhere. The tool would be able to go to the element level to compare and display the differences etc. However Google gave no substantive free tool results and no hints for anything of value. Is such a tool available? That is very useful? For free? Thanks in advance. :) Edit: Here is a bit of clarification of the functionality that would turn my error-prone,

Text difference algorithm

我的未来我决定 提交于 2019-11-26 19:30:43
I need an algorithm that can compare two text files and highlight their difference and ( even better!) can compute their difference in a meaningful way (like two similar files should have a similarity score higher than two dissimilar files, with the word "similar" defined in the normal terms). It sounds easy to implement, but it's not. The implementation can be in c# or python. Thanks. In Python, there is difflib , as also others have suggested. difflib offers the SequenceMatcher class, which can be used to give you a similarity ratio. Example function: def text_compare(text1, text2, isjunk

Can I use git diff on untracked files?

回眸只為那壹抹淺笑 提交于 2019-11-26 19:26:10
Is it possible to ask git diff to include untracked files in its diff output? Or is my best bet to git add the new files I've created and the existing files I have edited, and use git diff --cached ? araqnid With recent git versions you can git add -N the file (or --intent-to-add ), which adds a zero-length blob to the index at that location. The upshot is that your "untracked" file now becomes a modification to add all the content to this zero-length file, and that shows up in the "git diff" output. git diff echo "this is a new file" > new.txt git diff git add -N new.txt git diff diff --git a

use Winmerge inside of Git to file diff

跟風遠走 提交于 2019-11-26 19:19:29
Is there a way to use Winmerge inside of git to do Diffs? VonC Update June 2015, 6 years later: As detailed in " git mergetool winmerge ", a simple git config diff.tool winmerge will be enough. Git 2.5+ (Q2, 2015) is now aware of Winmerge as a diff or merge tool! Original answer (2009-2012) (msysgit, 1.6.5, DOS session) The first part (using winmerge) is described in " How do I view ‘git diff’ output with visual diff program? " C:\myGitRepo>git config --replace --global diff.tool winmerge C:\myGitRepo>git config --replace --global difftool.winmerge.cmd "winmerge.sh \"$LOCAL\" \"$REMOTE\"" C:

Mercurial - all files that changed in a changeset?

谁都会走 提交于 2019-11-26 19:14:17
问题 How can you determine all the files that changed in a given changeset? I'm not looking for a diff in this case, just a list of add/remove/modifications. hg log -vprX does a list of diffs but I just want the files. 回答1: If you want to list only files that have changed then you should be using "status command" The following will list the changes to files in revision REV hg status --change REV 回答2: Just remove p from your hg log -vpr will show the list of files. -p means show patch. You can also