[Pkg-libvirt-commits] [libguestfs] 213/266: fish: edit: return 1 for unchanged file

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:42:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit c9b6c8dac1bc0fd7ece202d2d7acccb8279d053e
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Thu Aug 28 10:45:28 2014 +0200

    fish: edit: return 1 for unchanged file
    
    Change the return value of edit_file_editor to 1, in case the editor did
    not change the (temporary) file.
---
 fish/edit.c      | 2 +-
 fish/file-edit.c | 2 +-
 fish/file-edit.h | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fish/edit.c b/fish/edit.c
index 0170daf..f43ef3b 100644
--- a/fish/edit.c
+++ b/fish/edit.c
@@ -60,5 +60,5 @@ run_edit (const char *cmd, size_t argc, char *argv[])
 
   r = edit_file_editor (g, remotefilename, editor, NULL);
 
-  return r;
+  return r == -1 ? -1 : 0;
 }
diff --git a/fish/file-edit.c b/fish/file-edit.c
index 8efa452..3a9dd2d 100644
--- a/fish/file-edit.c
+++ b/fish/file-edit.c
@@ -101,7 +101,7 @@ edit_file_editor (guestfs_h *g, const char *filename, const char *editor,
   /* Changed? */
   if (oldstat.st_ctime == newstat.st_ctime &&
       oldstat.st_size == newstat.st_size)
-    return 0;
+    return 1;
 
   /* Upload to a new file in the same directory, so if it fails we
    * don't end up with a partially written file.  Give the new file
diff --git a/fish/file-edit.h b/fish/file-edit.h
index 6622b3a..1d401c6 100644
--- a/fish/file-edit.h
+++ b/fish/file-edit.h
@@ -26,7 +26,8 @@
  * If 'backup_extension' is not null, then a copy of 'filename' is saved
  * with 'backup_extension' appended to its file name.
  *
- * Returns -1 for failure, 0 otherwise.
+ * Returns -1 for failure, 0 on success, 1 if the editor did not change
+ * the file (e.g. the user closed the editor without saving).
  */
 extern int edit_file_editor (guestfs_h *g, const char *filename,
                              const char *editor, const char *backup_extension);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list