Commit Diff


commit - 5541355f708ebb0d883dc03a3a2a29563a6df2c9
commit + bccae03fdbe2f0902e2447972ef9f63ffef57c3c
blob - 4c1cec0823d60146457085b972328049ac986934
blob + aedab60cfd015c8f0ee324f24c2eaaabdb75d665
--- cvg/cvg.1
+++ cvg/cvg.1
@@ -124,6 +124,7 @@ Without the
 option,
 .Cm got import
 opens a temporary file in an editor where a log message can be written.
+Quitting the editor without saving the file will abort the import operation.
 .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
@@ -1153,6 +1154,7 @@ or the
 and
 .Fl N
 options are used together.
+Quitting the editor without saving the file will abort the commit operation.
 .Pp
 Show the status of each affected file, using the following status codes:
 .Bl -column YXZ description
blob - ea3b833f1bc15d5ea3e276e75da0a16f1e29702c
blob + 19956b285901018b3d037f8f9a305d91091998ff
--- got/got.1
+++ got/got.1
@@ -127,6 +127,7 @@ Without the
 option,
 .Cm got import
 opens a temporary file in an editor where a log message can be written.
+Quitting the editor without saving the file will abort the import operation.
 .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 @@ Without the
 option,
 .Cm got tag
 opens a temporary file in an editor where a tag message can be written.
+Quitting the editor without saving the file will abort the tag operation.
 .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 @@ or the
 and
 .Fl N
 options are used together.
+Quitting the editor without saving the file will abort the commit operation.
 .Pp
 Show the status of each affected file, using the following status codes:
 .Bl -column YXZ description
@@ -2522,6 +2525,7 @@ command line, or generated with the
 or
 .Fl m
 options.
+Quitting the editor without saving the file will abort the histedit operation.
 .Pp
 The format of the histedit script is line-based.
 Each line in the script begins with a command name, followed by
blob - 664cbec303c1a130e85585f761c60b75c6db216a
blob + 4b372f0a31d36f58a9d7949e4f3329bc417a803c
--- got/got.c
+++ got/got.c
@@ -11968,6 +11968,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;
 
@@ -11975,11 +11977,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");