Commit Diff


commit - 5a6c61ae36e76ef40d6bac927cc3adea2fa54079
commit + ee27b57e0fcb14468a5b8a9cd8414b475267cddb
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 - 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");