Skip to content
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

nixpkgs manual: how to make a patch file with git #31778

Merged
merged 1 commit into from Nov 18, 2017

Conversation

chris-martin
Copy link
Contributor

This addresses #31684.

@orivej
Copy link
Contributor

orivej commented Nov 17, 2017

The text is good, but the placement is not quite right. 3.4. Phases is a reference section, it should not contain tutorials, but it may link to one. 13.5. Patches and 14.1. Making patches are closer to the right place.

@chris-martin
Copy link
Contributor Author

Section 14.1 doesn't seem relevant to this; I'll move it to 13.5.

@orivej
Copy link
Contributor

orivej commented Nov 17, 2017

I have not though about the best placement, I hope you'll chose right, but it seems appropriate for this to be a second level, not a third level section. Extending chapter 2 without creating a subsection also seems fine, because that chapter is a tutorial on adding packages, and this sometimes requires patching.

@chris-martin
Copy link
Contributor Author

Updated. I moved it into chapter 13 because I think it fits well alongside the discussion of when to commit patch files versus using fetchpatch, and I updated the text slightly to tie those concepts together.

I don't believe that Patches section really belongs under the "coding conventions" chapter, but I think that's a different conversation.

Copy link
Contributor

@orivej orivej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, 13.4. Fetching Sources and 13.5. Patches hardly are Coding conventions. I think this is ready to be merged.

@jtojnar
Copy link
Contributor

jtojnar commented Nov 17, 2017

Would it make sense to use filterdiff --strip=0 --clean like fetchpatch does?

@orivej
Copy link
Contributor

orivej commented Nov 17, 2017

The only effect of filterdiff on git diff output seems to be the stripping of the first two lines:

diff --git a/a b/a
index e69de29..6178079 100644

Personally I've never bothered to remove them, and I'd prefer to keep the instructions simple.

@chris-martin
Copy link
Contributor Author

I'd be happy to change

git diff > nixpkgs/pkgs/the/package/0001-changes.patch

to

nix-shell --pure --packages git patchutils --run "git diff | filterdiff --strip=0 --clean > nixpkgs/pkgs/the/package/0001-changes.patch"

Not including extraneous information in the nixpkgs repo seems very desirable to me. The command is harder to understand, but in exchange you get a patch file that's easier to understand, so seems like a worthwhile tradeoff.

@grahamc grahamc merged commit 9ce33dd into NixOS:master Nov 18, 2017
@grahamc
Copy link
Member

grahamc commented Nov 18, 2017

I think the instructions as-is are great, and the extra complexity of filterdiff isn't worth the benefits for this use case. Whereas, fetchpatch uses filterdiff to keep stable patch contents (shasum) when upstreams sometimes change bits of metadata (which are filtered.)

@chris-martin chris-martin deleted the pr/patch branch November 18, 2017 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants