New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format catenated unified diffs #399
Comments
You're missing the header lines like:
or similar. |
Any updates on this? Can we close this issue? |
I sort of understand how to construct the first line, but what about the other two lines? Is there some utility function that can produce that header? |
Well the middle one is optional; the third is just the git SHAs that the diff is between, and the file mode, which d-s-f will strip (and not meaningfully use) so you could put whatever, probably just best to keep it real-ish so you don't rely too much on exactly how the parsing happens to work today (i.e. this is not minimal, the content of the third line doesn't seem to matter today):
|
Thanks for the help! Here is how I fixed my script following your advice: for path in paths:
file_a = os.path.join(dir_a, path)
with open(file_a) as fd:
sa = fd.read().splitlines(keepends=True)
file_b = os.path.join(dir_b, path)
with open(file_b) as fd:
sb = fd.read().splitlines(keepends=True)
lines = unified_diff(
sa,
sb,
fromfile=file_a,
tofile=file_b
)
try:
first_line = next(lines)
sys.stdout.writelines([
'diff --git a/{} b/{}\n'.format(file_a, file_b),
'index dead..beef 100644\n',
first_line
])
sys.stdout.writelines(lines)
except StopIteration:
pass @scottchiefbaker Feel free to close this issue. |
What is the proper way to catenate unified diffs? When I use the following python loop
then pipe it to
diff-so-fancy
, the first--- file_a
+++ file_b
header is correctly formatted, but the others are formatted as diff lines-- file_a
++ file_b
(removing the first-
/+
symbol) and the line annotations always refer to the first file.The text was updated successfully, but these errors were encountered: