[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: diff files



On Thu, Oct 02, 2025 at 12:13:11PM +0100, mick.crane wrote:
> Please bear in mind I don't know what I'm doing.
> I only ever used diff once before.
> I was trying to get ChatGPT to post a patch file rather than the whole thing
> but it's been unsuccessful.
> Does anybody know how the system/syntax for diff files for Bookworm can be
> explained?
> At my end the patch partly worked and then bailed before 208c222,231
> Maybe it's something about code blocks in a browser.

I'd recommend using "diff -u" (i.e. the "unified format"), which these days
is the default in git land. It is safer (it usually carries some "context",
so makes it more difficult to apply the patch to the "wrong" file), and it
is far more readable.

> 
> 1a2,6
> > use Cwd qw(abs_path);
> > use File::Path qw(make_path);
> > use File::Basename;
> > my $script_dir = dirname(abs_path($0));
> 176a182,190
> > sub make_path_if_missing {
> >     my ($path) = @_;
> >     unless (-d $path) {
> >         make_path($path) or die "Failed to create path $path: $!";
> >     }
> > }
> 208c222,231
> 
> 
> 
> The first 3 lines or maybe 4 were added to the receiving file but seemed to
> bail at 208c222,231
> There was a ">" above that line that patch was moaning about because it
> wasn't followed by a space.

I don't see that ">" you refer to?

> I tried adding a space, tab or deleting it but no change.
> syntax like this
> +}
> +

This looks like the unified format, but to get it right, the stuff "around it"
has to fit, naturally.

While understanding (roughly) what a diff does (esp. if it is in unified format)
is fairly easy, editing it by hand to produce something consistent takes some
dedication. The Wikipedia [1], as usually, helps.

Cheers

[1] https://en.wikipedia.org/wiki/Diff
-- 
tomás

Attachment: signature.asc
Description: PGP signature


Reply to: