Code

Improve checkout error reporting
authorJonas Fonseca <fonseca@diku.dk>
Mon, 6 Oct 2008 20:09:42 +0000 (22:09 +0200)
committerJonas Fonseca <fonseca@diku.dk>
Mon, 6 Oct 2008 20:09:42 +0000 (22:09 +0200)
tig.c

diff --git a/tig.c b/tig.c
index 3850387c4b10829a571ecb9c5ae27841aeca6c8d..2fff94e61b666bed37f66a989a386a5d4b0b629c 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -4353,15 +4353,15 @@ status_update(struct view *view)
 }
 
 static bool
-status_checkout(struct status *status, enum line_type type, bool has_next)
+status_checkout(struct status *status, enum line_type type, bool has_none)
 {
        if (!status || type != LINE_STAT_UNSTAGED) {
-               if (has_next) {
-                       report("Nothing to checkout");
+               if (type == LINE_STAT_STAGED) {
+                       report("Cannot checkout staged files");
                } else if (type == LINE_STAT_UNTRACKED) {
                        report("Cannot checkout untracked files");
-               } else if (type == LINE_STAT_STAGED) {
-                       report("Cannot checkout staged files");
+               } else if (has_none) {
+                       report("Nothing to checkout");
                } else {
                        report("Cannot checkout multiple files");
                }
@@ -4682,7 +4682,8 @@ stage_request(struct view *view, enum request request, struct line *line)
                break;
 
        case REQ_STATUS_CHECKOUT:
-               if (!status_checkout(&stage_status, stage_line_type, FALSE))
+               if (!status_checkout(stage_status.status ? &stage_status : NULL,
+                                    stage_line_type, FALSE))
                        return REQ_NONE;
                break;