diff

git status shows changed files but git diff doesn't

走远了吗. 提交于 2019-11-27 19:46:36
问题 I've had a look at all similar questions however I've double checked and something strange is definitely happening. On one server (Solaris with git 1.8.1) I cloned the git repository then copied the .git folder into my existing live files. This worked perfectly, I could run git status then git diff [filename] to check any files that were different. On another server (Solaris with git 1.7.6) I'm doing exactly the same however git diff [filename] shows nothing, even if the contents of the file

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

删除回忆录丶 提交于 2019-11-27 19:30:50
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. // 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 a.filter(function(obj){ return !(obj.id in bIds); }); very minor addendum: If the lists are very large and

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

最后都变了- 提交于 2019-11-27 19:14:41
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 ls -lR $dir > a ls -lR $dir > b DIFF=$(diff a b) if [ "$DIFF" != "" ] then echo "The directory was modified" fi Paul Tomblin if ! diff -q a b &>/dev/null; then >&2 echo "different" fi tangens

Comparing image in url to image in filesystem in python

心不动则不痛 提交于 2019-11-27 18:54:17
Is there a quick and easy way to do such comparison? I've found few image compare questions from stackoverflow but none of those actually proved answer for this question. I have images files in my filesystem and a script that fetches images from urls. I want to check if the image in url is already the same that is on disk. Normally I would load the image in disk and url to a PIL object and use following function I found: def equal(im1, im2): return ImageChops.difference(im1, im2).getbbox() is None but this doesn't work if you have a image saved to disk with PIL as it gets compressed even if

XML Diff and Merge

我怕爱的太早我们不能终老 提交于 2019-11-27 18:25:30
I think i have a rather unique problem to solve. Well, i cant find enough information using Google. So here it goes, I work on a Java EE SOA application which stores XML documents as XML using Oracle XML DB. Whenever the XML changes, i increment the version and throw the previous version into a different table. The requirement now is, I should store the differences between 2 versions as XML, instead of the whole XML document. Is there any Java library which can do XML comparison? (XMLUnit, ... ?) Is there a standard XML Schema for capturing XML differences? What transformation technology can i

Diffing between two entire directories/projects in hg or git?

会有一股神秘感。 提交于 2019-11-27 18:06:36
I inherited a project originally stored in CVS with all the revisions. I made quite a few edits, and I'm trying to compare all the changes I made in the original directory, in regards to new files added versus the old ones. Is there some sort of utility for hg/git where I can do a tree diff, or something of that nature? So that say, there's a mark between newly added files, deleted files, am I asking for too much? git diff does exactly that. but it only works for git projects. hg diff , svn diff pretty every version control system can diff directory trees To simply create a diff patch in git's

Ignore *all* whitespace changes with git-diff between commits

陌路散爱 提交于 2019-11-27 17:56:48
I'm going through a codebase and fixing whitespace oddities and generally correcting indentation and such things, and I want to make sure I haven't inadvertently made any other changes, so I'm doing git diff -w to display differences in all changed files while ignoring whitespace differences. The problem is that this is not actually ignoring all whitespace differences—at least what I consider to be merely whitespace differences. For instance, in the following output from git diff -w , -"Links": -{ - - "Thermal": - -{ - + "Links": { + "Thermal": { you can see that I've only removed superfluous

PHP's DateTime::Diff gets it wrong?

百般思念 提交于 2019-11-27 17:53:04
问题 DateTime::Diff should calculate a proper interval and take into account Daylight Savings Time (DST) and leap years. Although apparently it isn't so. Code of horror: $d1 = new DateTime("2011-10-30 01:05:00", new DateTimeZone("Europe/Stockholm")); $d2 = new DateTime("2011-10-30 03:05:00", new DateTimeZone("Europe/Stockholm")); echo $d1->getOffset() / (60 * 60); Prints '2'! Keep in mind thus that UTC time = 1h - 2h = 23:05:00 the day before. echo $d2->getOffset() / (60 * 60); Prints '1'. DST

Using jq or alternative command line tools to compare JSON files

我们两清 提交于 2019-11-27 17:48:16
Are there any command line utilities that can be used to find if two JSON files are identical with invariance to within-dictionary-key and within-list-element ordering? Could this be done with jq or some other equivalent tool? Examples: These two JSON files are identical A : { "People": ["John", "Bryan"], "City": "Boston", "State": "MA" } B : { "People": ["Bryan", "John"], "State": "MA", "City": "Boston" } but these two JSON files are different: A : { "People": ["John", "Bryan", "Carla"], "City": "Boston", "State": "MA" } C : { "People": ["Bryan", "John"], "State": "MA", "City": "Boston" }

Mercurial - all files that changed in a changeset?

谁都会走 提交于 2019-11-27 17:46:18
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. 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 Just remove p from your hg log -vpr will show the list of files. -p means show patch. You can also use a template to format the output to your taste. I know the question is for a single changeset, but if you'd