Code

Avoid refreshing views when checkout is canceled by user
authorJonas Fonseca <fonseca@diku.dk>
Wed, 1 Oct 2008 15:39:52 +0000 (17:39 +0200)
committerJonas Fonseca <fonseca@diku.dk>
Wed, 1 Oct 2008 15:39:52 +0000 (17:39 +0200)
tig.c

diff --git a/tig.c b/tig.c
index 0360e173457a455d4d266b46ee338ac19e4fefba..e22d33de5205e10cbb4bc41b05a4e7a3f4c0ef20 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2536,12 +2536,15 @@ open_view(struct view *prev, enum request request, enum open_flags flags)
                update_view_title(view);
 }
 
-static void
+static bool
 run_confirm(const char *cmd, const char *prompt)
 {
-       if (prompt_yesno(prompt)) {
+       bool confirmation = prompt_yesno(prompt);
+
+       if (confirmation)
                system(cmd);
-       }
+
+       return confirmation;
 }
 
 static void
@@ -4368,12 +4371,11 @@ status_checkout(struct status *status, enum line_type type, bool has_next)
                char cmd[SIZEOF_STR];
                char file_sq[SIZEOF_STR];
 
-               if (sq_quote(file_sq, 0, status->old.name) < sizeof(file_sq) &&
-                   string_format(cmd, "git checkout %s%s", opt_cdup, file_sq)) {
-                       run_confirm(cmd, "Are you sure you want to overwrite any changes?");
-               }
+               if (sq_quote(file_sq, 0, status->old.name) >= sizeof(file_sq) ||
+                   !string_format(cmd, "git checkout %s%s", opt_cdup, file_sq))
+                       return FALSE;
 
-               return TRUE;
+               return run_confirm(cmd, "Are you sure you want to overwrite any changes?");
        }
 }