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

From:
Mike Larkin <mlarkin@nested.page>
Subject:
Re: improve 'tog diff' patch file names in /tmp
To:
gameoftrees@openbsd.org
Date:
Fri, 29 Aug 2025 09:22:03 -0700

Download raw body.

Thread
On Fri, Aug 29, 2025 at 01:38:02PM +0200, Stefan Sperling wrote:
> Make 'tog diff' show the repository name in names of patches written
> to /tmp. This makes selecting a patch in /tmp a tiny bit easier while
> dealing with multiple projects in parallel.
>
> ok?
>

ran into this myself the other day. welcome change.

>
> M  tog/tog.c  |  9+  2-
>
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> commit - a906b277aa501d5897960b8e9f4466450d91dcac
> commit + 87514a0663e524cab02f7be984992879b4bffcd9
> blob - 0ccc6a0f788f55d0c7f1bd60778f977402cfd4d8
> blob + 44b2d7f8b746631a2dcc8691478e5b582881c5e3
> --- tog/tog.c
> +++ tog/tog.c
> @@ -7003,6 +7003,7 @@ diff_write_patch(struct tog_view *view)
>  	FILE				*f = NULL;
>  	char				 buf[BUFSIZ], pathbase[PATH_MAX];
>  	char				*idstr1, *idstr2 = NULL, *path = NULL;
> +	char				*repo_name = NULL;
>  	size_t				 r;
>  	off_t				 pos;
>  	int				 rc;
> @@ -7035,8 +7036,13 @@ diff_write_patch(struct tog_view *view)
>  	if (err != NULL)
>  		goto done;
>
> -	rc = snprintf(pathbase, sizeof(pathbase), "%s/tog-%.8s-%.8s",
> -	    GOT_TMPDIR_STR, idstr1 != NULL ? idstr1 : "empty", idstr2);
> +	err = got_path_basename(&repo_name, got_repo_get_path(s->repo));
> +	if (err)
> +		goto done;
> +
> +	rc = snprintf(pathbase, sizeof(pathbase), "%s/tog-%s-%.8s-%.8s",
> +	    GOT_TMPDIR_STR, repo_name,
> +	    idstr1 != NULL ? idstr1 : "empty", idstr2);
>  	if (rc < 0 || (size_t)rc >= sizeof(pathbase)) {
>  		err = got_error(rc < 0 ? GOT_ERR_IO : GOT_ERR_NO_SPACE);
>  		goto done;
> @@ -7080,6 +7086,7 @@ done:
>  	free(path);
>  	free(idstr1);
>  	free(idstr2);
> +	free(repo_name);
>  	return err;
>  }
>
>