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

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: No-op histedit scripts
To:
Christian Weisgerber <naddy@mips.inka.de>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 15 Jul 2023 13:25:11 +1000

Download raw body.

Thread
Christian Weisgerber <naddy@mips.inka.de> wrote:
> Stefan Sperling:
> 
> > Has your work on this been successfully unblocked by the EEXIST error fix?
> 
> Yes, it has!
> 
> I guess we want to use a stock phrase in the man page to indicate
> that the commit/import/tag and histedit operations are only executed
> if the log msg/histedit script files have been written from the
> invoked editor.  I may not have found the best phrasing yet.

I think you've stated the caveat well; it's clear and concise. I like it!
Using the same verb and noun as in the preceding sentence makes it
simple to understand the abort condition.

ok for me

> diff refs/heads/main refs/heads/histedit
> commit - 1494a06e4ce25cf1beafa90b6b1f98bdebf9e7e2
> commit + d9e93be4ebec9dd8fd002bbee5c6269b212bc70a
> blob - ea3b833f1bc15d5ea3e276e75da0a16f1e29702c
> blob + f10f7d4f259e94b489487e17f41eb5dee33b95df
> --- got/got.1
> +++ got/got.1
> @@ -127,6 +127,7 @@ opens a temporary file in an editor where a log messag
>  option,
>  .Cm got import
>  opens a temporary file in an editor where a log message can be written.
> +If the temporary file is not written to, the import operation is aborted.
>  .It Fl r Ar repository-path
>  Use the repository at the specified path.
>  If not specified, assume the repository is located at or above the current
> @@ -1347,6 +1348,7 @@ opens a temporary file in an editor where a tag messag
>  option,
>  .Cm got tag
>  opens a temporary file in an editor where a tag message can be written.
> +If the temporary file is not written to, the tag operation is aborted.
>  .It Fl r Ar repository-path
>  Use the repository at the specified path.
>  If not specified, assume the repository is located at or above the current
> @@ -1708,6 +1710,7 @@ options are used together.
>  and
>  .Fl N
>  options are used together.
> +If the temporary file is not written to, the commit operation is aborted.
>  .Pp
>  Show the status of each affected file, using the following status codes:
>  .Bl -column YXZ description
> @@ -2522,6 +2525,7 @@ options.
>  or
>  .Fl m
>  options.
> +If the script file is not written to, the histedit operation is aborted.
>  .Pp
>  The format of the histedit script is line-based.
>  Each line in the script begins with a command name, followed by
> blob - e21a92523011eaf67089838f68f9e98950704b11
> blob + 2a5d0bd5f3e513f26cad87624b5c5ebbb8eaef14
> --- got/got.c
> +++ got/got.c
> @@ -11969,6 +11969,8 @@ histedit_run_editor(struct got_histedit_list *histedit
>      struct got_repository *repo)
>  {
>  	const struct got_error *err = NULL;
> +	struct stat st, st2;
> +	struct timespec timeout;
>  	char *editor;
>  	FILE *f = NULL;
>  
> @@ -11976,11 +11978,32 @@ histedit_run_editor(struct got_histedit_list *histedit
>  	if (err)
>  		return err;
>  
> +	if (stat(path, &st) == -1) {
> +		err = got_error_from_errno2("stat", path);
> +		goto done;
> +	}
> +
>  	if (spawn_editor(editor, path) == -1) {
>  		err = got_error_from_errno("failed spawning editor");
>  		goto done;
>  	}
>  
> +	timeout.tv_sec = 0;
> +	timeout.tv_nsec = 1;
> +	nanosleep(&timeout,  NULL);
> +
> +	if (stat(path, &st2) == -1) {
> +		err = got_error_from_errno2("stat", path);
> +		goto done;
> +	}
> +
> +	if (st.st_size == st2.st_size &&
> +	    timespeccmp(&st.st_mtim, &st2.st_mtim, ==)) {
> +		err = got_error_msg(GOT_ERR_EMPTY_HISTEDIT,
> +                    "no changes made to histedit script, aborting");
> +		goto done;
> +	}
> +
>  	f = fopen(path, "re");
>  	if (f == NULL) {
>  		err = got_error_from_errno("fopen");


-- 
Mark Jamsek <https://bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68