From 8f2a69d8be49017f716c30ed2acf9a000d742f31 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Wed, 1 Oct 2008 17:39:52 +0200 Subject: [PATCH] Avoid refreshing views when checkout is canceled by user --- tig.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tig.c b/tig.c index 0360e17..e22d33d 100644 --- 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?"); } } -- 2.30.2