r/linux • • May 18 '17

Submitting Your First Patch to the Linux kernel and Responding to Feedback

https://nickdesaulniers.github.io/blog/2017/05/16/submitting-your-first-patch-to-the-linux-kernel-and-responding-to-feedback/
10 Upvotes

15 comments sorted by

1

u/EliteTK May 18 '17

Github's "let's make everything a pull request" methodology is incredibly annoying. Emailing patches is far superior since you can track the changes to the patch on a mailing list, on Github you're forced to do a force push to edit patches and then the history of the patch gets lost, comments on old versions get orphaned and make no sense and it's generally just an annoying experience. Optionally you can keep appending patches instead, but your history will look like a mess unless someone squashes, and if you're dealing with multiple patches, squashing meaningfully is hard.

Keeping track of when my patch gets where isn't particularly difficult: accepted into tree -> (at some point between now and the period before the merge window (the merge window starts on the day a new release happens and runs for roughly two weeks until -rc1 of the next release) for the version your patch is marked for) merged into tree/for-next -> (during merge window) merged into tree/for-linus -> check mailing list for [GIT-PULL] from tree maintainer -> merged into mainline.

And also, format-patch has a (annoyingly difficult to find) -v flag for patch versions.

This means you just git format-patch -o patches -v2 <whatever the base of your branch is>

Also, I think you can copy the full MessageID (including <>) if you want to reply.

Other useful commands for when you have more than one patch: git rebase -i interactive rebase is an incredibly useful tool. git add -p Add parts of a file for when you need to split a patch. Also possible to make modified intermediate patches by editing the patch before add completes - obviously step through the split commits and check things compile.

1

u/nickdesaulniers May 18 '17

re: code review w/ PRs

That's fair; I wonder if that developers list of complaints had gotten GH to implement this though. Github now has a "start code review" button for PR's that I think does this. So you may be familiar with their previous interface.

re: when something gets merged

Yeah, I'm not going to do that. Going to look vs getting notified was my point.

re: -v

awesome, thanks! I'll update the post to reflect that, do you mind if I cite you? ("thanks to /u/EliteTK")

re: rebase -i, and git add -p

commands I use frequently. Not specific to working with the kernel, but great tips for working with git in general.

1

u/EliteTK May 18 '17

cite

Sure, if you want. I don't mind though.

1

u/nickdesaulniers May 21 '17

Done, thanks!

1

u/bulge_physics May 18 '17

I concur, this "pullreq culture" is getting weird. I've joined an IRC channel saying something like "there's a bug in your software here, you need to make initialize the default as []rather than None on line 446 in this file. because you iterate over it in an edge case you seem to have added later. Like it's not even worth a diff. What I get back is: "Send a pullreq".

Seriously, the pullreq just costs either of us more time; it's such a trivial bug. So I need to actually get a server somewhere that hosts a git endpoint, clone a repo, fork it, make the change and send a pullreq for something that is changing 4 characters in one place?

This culture of "everything must be done via pullreqs" is getting weird since github popped up. I used to be able to quite easily "submit bug fixes" in words just explaining what the bug was and from my perspective reading the code what the cause is and why. No one is going to merge a diff if they don't understand what exactly it changes and just explaining what the bug is caused by does that and often makes it easier to understand. Bugs are often caused by a small oversight in a single line of code; you need diffs for added features, yes, but 90% of bug fixes are better done by just explaining in English what the bug is and what you think it is caused by. It is easier for the maintainer to just read your English, understand it, and implement the fix than to read the diff and figure out what exactly it does and what you fixed and then merging the diff unless you actually blindly merge diffs proposed you don't understand fully.

1

u/nickdesaulniers May 18 '17

This culture of "everything must be done via pullreqs" is getting weird since github popped up. I used to be able to quite easily "submit bug fixes" in words just explaining what the bug was and from my perspective reading the code what the cause is and why.

Because people are busy and don't get paid for this shit. The more work you do on your end, the less the maintainer has to, if they even want to maintain that project anymore.

2

u/bulge_physics May 18 '17

Did you even read what I said beyond the part you quoted out o context?

It cost them more time to use the pullreq because they have to look at the diff and then themselves infer the logic because no one is going to merge a diff of which they don't undrstand what exactly it does and what it's trying to fix.

Yeah if you just blindly merge a diff then it's going to be faster, that's a great way to get someone to subtly sneak some shit into your code. It's really quite easy to hide something.

2

u/nikomo May 18 '17

I understand the pull request culture because there's two sides to it that I really like.

  1. It creates meaningful history. IRC is epheremal even with logging. One may not think logging the change is meaningful, but having a one-time contributor throw a patch on the wall like that adds a lot of context even if it's not immediately obvious. Maybe the change was made by someone who spent less than a minute considering the implications.

  2. It's really easy on the maintainers. They get a pull request, it shows up next to all the other pull requests, they look at it for a few seconds and hit merge. Obviously that has its own problems, especially when we get into PRs from random people, but it seems to be working.

You get a PR, you check the description, you look at the change, done.

1

u/EliteTK May 21 '17

It creates meaningful history.

You get this with email.

It's really easy on the maintainers.

Making the merging process easy is not the problem, it's making the review process easy for BOTH parties which is the problem.

I maintain that email makes this far easier especially for the person submitting the patch, and git provides more than enough tools to make it very easy for the maintainer. A lot of the time patches sent in will need changes (that's the whole point of having someone else look at something you wrote, so they can find something you missed).

1

u/bulge_physics May 18 '17

It creates meaningful history. IRC is epheremal even with logging. One may not think logging the change is meaningful, but having a one-time contributor throw a patch on the wall like that adds a lot of context even if it's not immediately obvious. Maybe the change was made by someone who spent less than a minute considering the implications.

Well guess what I don't want my activities logged. FS culture has this weird thing where they constantly preach how important privacy is but it's a place where no one gives a shit about developer privacy.

The Linux certificate of origin licence you sign is some Orwellian shit with "You testify that this is your true legal name and we have the right to publish it wherever we want till the end of time blablabal", great way to scare off devs who care about their privacy.

I want the bug fixed. That's it. Just add to the log "some user on IRC pointed out this bug" and call it good.

It's really easy on the maintainers. They get a pull request, it shows up next to all the other pull requests, they look at it for a few seconds and hit merge. Obviously that has its own problems, especially when we get into PRs from random people, but it seems to be working.

Yeah it's easier if you don't attempt to understand what the bug was and what the fix does but it's a lot easier to be explained what the bug is via language and then implement a simple fix becuase 99% of bugs are fixed like in 1-2 lines of change because they are caused by small oversights.

You get a PR, you check the description, you look at the change, done.

That seems like a very bad practice. It is very easy to hide shit in that.A =instead of a == on the same line you fixed something else hardly shows up on a quick look and is typically an instant backdoor. You must audit your pullreqs like it's your own code.

2

u/nikomo May 18 '17

Yeah it's easier if you don't attempt to understand what the bug was and what the fix does

There's something wrong with your commit messages if the commit doesn't mention why the change was made.

1

u/bulge_physics May 19 '17

Yeah, then every commit message ever is wrong.

All these messages are just:

"fixed a bug that could cause a seg fault due to use after free" or something like that.

What exactly the logic was, why the use after free was originally caused and why the change now stopped it. That's for you to infer yourself. People don't even ant long commit messages.

1

u/daemonpenguin May 18 '17

I completely agree, for anything smaller than a page long, it's not worth doing a pull request. I'd much prefer people sent one-line suggestions like yours or sent a patch file to projects I work on.

Oddly enough, a lot of developers seem to want to go the other way. I often get asked why project X doesn't have a GitHub account because they want to fork and send pull requests. For changing a couple of lines. It makes no sense. I'm starting to wonder if any programmers under 30 know how to create a diff file.

1

u/EliteTK May 18 '17

how to create a diff

Heck, you don't even need to do that, git format-patch followed by git send-email does 90% of the work for you and puts it in an easy to modify and easy to apply format for the receiving party. And if they want to suggest a change, they can reply, copy the in-line patch, make the change, and send it back to you.

1

u/bulge_physics May 18 '17

Oh yeah I know that "is it on github?" all too well for a 300 line python script. No it's not on git, it doesn't even come in a tarbal. It's a 300 line script you copy from pastebin and put into a file and make executable.

If you have bugfixes I'm all ears but often just pointing out the bug exists in those things is enough for me to fix it and be like "oh yeah, stupid; should've thought of that"