News for hackers. Stuff that matters.
Re:A 35-year-old bug in Patch found in efforts to restore 29... by jtchang on Monday August 17, 2020 @12:24PM (#24188713)
On a related note I've found finding information on the patch command to be a bit harder than normal. Without digging into the code I was trying to figure out why some people name things in the first two lines with an ending of .old. Some common search queries really have a hard time bringing this up. One link I found was here but didn't really go into much depth:

https://stackoverflow.com/questions/987372/what-is-the-forma...

Re:A 35-year-old bug in Patch found in efforts to restore 29... by pwg on Monday August 17, 2020 @02:28PM (#24190213)
If I'm understanding you correctly you are wondering why some filenames are named .old in the header of patch files.

If so, then that is likely an easy answer. No one creates patch files by hand, they are created by diff (or similar tools).

And diff, at least the Unix variant, is used to compare two files and produce an output that will change the first of the two into the second of the two (i.e., it outputs the 'differences' between the two files, hence the utility's name 'diff').

Well, to have two files, one of the files has to be given a different name. So if one is editing a single file, and is not using some kind of source control system that tracks changes, it is common to first do:

    cp file_to_be_edited file_to_be_edited.old
Then, edit "file_to_be_edited".

Then produce a patch by doing:

    diff -u file_to_be_edited.old file_to_be_edited > file_to_be_edited.diff
And since diff puts the filenames of the two files it compares into the header lines of the output unified diff format, you get a file named
.old showing up in the output patch file.
Re:A 35-year-old bug in Patch found in efforts to restore 29... by inopinatus on Monday August 17, 2020 @08:41PM (#24194070)
Well I just want to stop you right there and say that I have sinned and written diffs by hand, and what’s more they were for a sendmail.cf, and if this conjures visions of a cantankerous sandal-wearing Unix admin then so be it
Re:A 35-year-old bug in Patch found in efforts to restore 29... by rascul on Monday August 17, 2020 @09:23PM (#24194355)
I just got flashbacks. My night is now ruined.
Re:A 35-year-old bug in Patch found in efforts to restore 29... by asveikau on Monday August 17, 2020 @04:47PM (#24191859)
If you want to make a patch, you need a starting file and an end point. So you take a pristine tree and call it "foo.orig" or "foo.old" and then run diff -ur foo.old foo

Maybe younger developers don't know this experience because usually their patches are generated by git diff and the like. But before that stuff was as common as today, you would need to copy the old files off somewhere to generate a patch. At that point you need to name it something.

Re:A 35-year-old bug in Patch found in efforts to restore 29... by erichurkman on Monday August 17, 2020 @05:36PM (#24192467)
And for some projects, you might not have the disk space for a full 'clean' tree, so you copy just the 2 or 3 files you're editing into `file.old`. And when you're constructing the patch, you hand craft the order in which files are shown to make sure the code lines up to the narrative that accompanies the patch.