Questions tagged [unified-diff]

20 questions
20
votes
2 answers

How to print the comparison of two multiline strings in unified diff format?

Do you know any library that will help doing that? I would write a function that prints the differences between two multiline strings in the unified diff format. Something like that: def print_differences(string1, string2): """ Prints the…
Andrea Francia
  • 8,807
  • 14
  • 53
  • 70
18
votes
2 answers

From a kdiff3 file comparison, can I generate a diff in unified diff format?

I have a kdiff3 comparison in Windows, and I would like to save the comparison as a text file in unified diff format. I realize this is kind of a strange question. Usually, people already have the text diff in hand, and want to see it graphically…
JXG
  • 6,953
  • 7
  • 29
  • 60
5
votes
3 answers

Can't apply unified diff patch on Solaris

For example, if I have two files: file1: This is file 1 and file2: This is file 2 and create patch with the following command: diff -u file1 file2 > files.patch result is: --- file1 Fri Aug 13 17:53:28 2010 +++ file2 Fri Aug 13…
Shcheklein
  • 5,090
  • 7
  • 37
  • 48
4
votes
0 answers

How to find exactly why patch failed?

I have a unified diff patch which patch rejects. A visual inspection of the diff file and the original code finds the code contains all text expected by the diff file in the correct location. I have tried --ignore-whitespace and -F3 for good measure…
xuinkrbin.
  • 895
  • 1
  • 6
  • 15
3
votes
1 answer

Why does unified_diff method from the difflib library in Python leave out some characters?

I am trying to check for differences between lines. This is my code: from difflib import unified_diff s1 = ['a', 'b', 'c', 'd', 'e', 'f'] s2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'i', 'k', 'l', 'm', 'n'] for line in unified_diff(s1, s2): print…
Shivani
  • 65
  • 9
3
votes
1 answer

Why is GNU patch failing for this diff?

G'day, Edit: Just thought I'd mention that this somewhat long question is now fixed thanks to Adam Goode's answer below if you're just skimming while passing through. I've been given a patch to add to Apache 2.2.14 and one unified diff is not…
Rob Wells
  • 34,617
  • 13
  • 76
  • 144
2
votes
1 answer

Create unified diff text for diff2html in browser

Is there a library that produces unified diff from two strings that diff2html can use? I've tried difflib but the output does not seem to fit the requirements that diff2html needs. I need a .js library I can import in the webpage to produce diffs…
2
votes
1 answer

How to append filename to a unified diff label

I am writing a bash script that needs to display a diff between a remote file and my local copy. I am doing this through a command: filepath=/home/user/test.txt ssh $REMOTE_USER cat $filepath | diff -bu --label="remote" --label="local" -…
Bill Baker
  • 33
  • 4
2
votes
1 answer

tf diff /recursive /format:unified - how to not include folder names in output

I want to generate the diff between two versions in TFS as a unified diff file. I do tf diff $/TFSPATH/PROJECT/FOLDER /recursive /version:C12345~C12346 /format:unified The generated output contains all the differences in files as I want to, but it…
Ben Schwehn
  • 4,429
  • 1
  • 25
  • 44
2
votes
1 answer

How to configure unified diff context via git-config?

How can I configure via git-config the unified context so that I don't have to always provide the -U or --unified option with a value?
bitcycle
  • 7,094
  • 13
  • 64
  • 116
2
votes
1 answer

How to create patch file between two revisions in TortoiseSVN?

I'm using TortoiseSVN 1.7 and want to create patch file between two revisions. I've searched, but these threads How do I create a patch from diff between revisions using TortoiseSVN? Creating a patch between two revisions do not work for me, as Show…
onmyway133
  • 38,911
  • 23
  • 231
  • 237
1
vote
1 answer

How do I identify & list unique hunks in a git commit?

I have a commit with a large number (hundreds) of similar hunks, and I'd like to list each unique hunk in the commit in order to compare them. I wrote the following GNU awk script, which writes each hunk to a unique file…
tavnab
  • 2,226
  • 15
  • 24
1
vote
0 answers

Is there a way to display the index in the list using difflib.unified_diff?

I would like to compare text files and see what sorts of changes were made. Not only would I like to see the changes, but I would like to see where these words can be found in the new list. This is the sample code in the documentation: >>> s1 =…
Shivani
  • 65
  • 9
1
vote
1 answer

Reverse diff -u in python

I need to write a module in python that gets the output of a unix diff -u command and one of the files that were used to create that ouput and in return output the second file. The diff -u returns a diff file in a unified format Could anyone…
Giora Guttsait
  • 1,157
  • 11
  • 25
0
votes
1 answer

How to parse git diff -U output using unidiff parser

I need hunks (lines added and deleted) with context so I used git diff -u to obtain a diff. I can do line.is_added to to obtain lines_added but those line will not include lines of context. How do I parse this diff to get lines_added and lines…
H-S
  • 1
  • 3
1
2