Code

Use check_blame_commit when handling REQ_ENTER
authorJonas Fonseca <fonseca@diku.dk>
Sun, 8 Feb 2009 19:36:28 +0000 (20:36 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Sun, 8 Feb 2009 19:36:28 +0000 (20:36 +0100)
tig.c

diff --git a/tig.c b/tig.c
index 13c167d3c49f772d12dcd680eda2658c8d5181bb..62645334d9e6dcdc86ed108583e4e1ce4269e473 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -4405,11 +4405,11 @@ blame_draw(struct view *view, struct line *line, unsigned int lineno)
 }
 
 static bool
-check_blame_commit(struct blame *blame)
+check_blame_commit(struct blame *blame, bool check_null_id)
 {
        if (!blame->commit)
                report("Commit data not loaded yet");
-       else if (!strcmp(blame->commit->id, NULL_ID))
+       else if (check_null_id && !strcmp(blame->commit->id, NULL_ID))
                report("No commit exist for the selected line");
        else
                return TRUE;
@@ -4460,7 +4460,7 @@ blame_request(struct view *view, enum request request, struct line *line)
 
        switch (request) {
        case REQ_VIEW_BLAME:
-               if (check_blame_commit(blame)) {
+               if (check_blame_commit(blame, TRUE)) {
                        string_copy(opt_ref, blame->commit->id);
                        string_copy(opt_file, blame->commit->filename);
                        if (blame->lineno)
@@ -4470,7 +4470,7 @@ blame_request(struct view *view, enum request request, struct line *line)
                break;
 
        case REQ_PARENT:
-               if (check_blame_commit(blame) &&
+               if (check_blame_commit(blame, TRUE) &&
                    select_commit_parent(blame->commit->id, opt_ref,
                                         blame->commit->filename)) {
                        string_copy(opt_file, blame->commit->filename);
@@ -4480,10 +4480,8 @@ blame_request(struct view *view, enum request request, struct line *line)
                break;
 
        case REQ_ENTER:
-               if (!blame->commit) {
-                       report("No commit loaded yet");
+               if (!check_blame_commit(blame, FALSE))
                        break;
-               }
 
                if (view_is_displayed(VIEW(REQ_VIEW_DIFF)) &&
                    !strcmp(blame->commit->id, VIEW(REQ_VIEW_DIFF)->ref))