"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got patch: delete binary files too
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 31 Dec 2022 16:18:00 +0100

Download raw body.

Thread
On Sat, Dec 31, 2022 at 04:05:26PM +0100, Omar Polo wrote:
> diff and cvs diff looks similar but they don't provide the filename in
> a way that's easy to extract so they're left out.  Here's an example
> for reference:
> 
> 	% diff -u bin/got /dev/null
> 	Binary files bin/got and /dev/null differ

The name could be extracted here. But you don't want to handle this
since it lacks a 'file + /dev/null' or 'delete file mode' header?

Isn't 'Binary files ... and /dev/null differ' enough to detect this
case? A destination of /dev/null imlies file deletion.
 
> The idea then is to parse the "file + /dev/null" or "deleted file
> mode" lines and extract the filename from the "Binary files foo and
> /dev/null differ."  There's no problem with ambiguous spaces since we
> can treat "Binary files " as prefix and the " and /dev/null differ"
> string as suffix and strip them, what remains is the filename.
> 
> (the patch file format has further restrictions on the bytes allowed
> on the filenames, for e.g. newlines and tabs are not permitted
> anyway.)
> 
> ok?

Sure. The above note regarding regular diff is just a question,
not an objection to the approach taken here. ok stsp@

> +static const struct got_error *
> +binaryfilename(const char *at, char **name)
> +{
> +	const char *trail = " and /dev/null differ\n";

I would call this variable 'tail' or 'trailer', not 'trail' (which
means "path" or "track" one can follow, e.g. while going on a hike).