PSA: including a diff in your git commit message can lead to it being applied to the code (github.com)
from CombatWombatEsq@lemmy.world to programming@programming.dev on 06 Feb 17:49
https://lemmy.world/post/42768887

#programming

threaded - newest

verstra@programming.dev on 06 Feb 18:06 next collapse

Context: this happens if you use patch(1) with patches generated by git format-patch. If you do, you should be using git am instead.

CombatWombatEsq@lemmy.world on 06 Feb 18:08 collapse

It happens when you use git-am as well, per the thread

verstra@programming.dev on 06 Feb 18:29 collapse

Ha. Lol. That’s bad

CombatWombatEsq@lemmy.world on 06 Feb 18:54 collapse

The final verdict being “it’s working as intended” is fully wild to me.

FizzyOrange@programming.dev on 06 Feb 18:42 next collapse

… if you have a super janky patch file workflow.

If you are using Git like normal people do this can’t happen.

hallettj@leminal.space on 06 Feb 18:52 collapse

The Linux kernel development workflow, the purpose for which git was invented, makes use of emailed patches docs.kernel.org/process/submitting-patches.html

Kissaki@programming.dev on 06 Feb 19:05 next collapse

… which arguably makes them not “normal people” (referring to the earlier comment).

Surely, most people use different, more integrated tooling.

FizzyOrange@programming.dev on 06 Feb 21:55 collapse

Yeah it’s mad. Tbh I don’t think GitHub PRs are the best workflow, but I absolutely know that git send-email is the worst. I tried to use it once to contribute to OpenSBI, which inexplicably also insists on it. Suffice it to say my patch was never merged…

ElBarto@piefed.social on 06 Feb 23:16 collapse

Why didn’t your patch get merged?

FizzyOrange@programming.dev on 07 Feb 10:02 collapse

They wanted me to make some changes and with the normal workflow that’s just git commit and git push. With git send-email I have no fucking idea and it got beyond the point where I had enough cared enough to fight the process.

Oinks@lemmy.blahaj.zone on 06 Feb 19:37 next collapse

Hooray to underspecified file formats.

From patch(1):

patch tries to skip any leading garbage, apply the diff, and then skip any trailing garbage. Thus you could feed an email message containing a diff listing to patch, and it should work.

From git-am(1):

The patch is expected to be inline, directly following the message. Any line that is of the form:

  • three-dashes and end-of-line, or
  • a line that begins with “diff -”, or
  • a line that begins with "Index: "

is taken as the beginning of a patch, and the commit log message is terminated before the first occurrence of such a line.

Ideally git-am should use a better file format, but I suppose the more realistic lesson now is to never have inline diffs in Commit messages.

Draconic_MEO@programming.dev on 07 Feb 10:10 collapse

Never had issues or challenges just sit back and let AI do all the coding