Fix updating of the blob ref and the blob view ref
authorJonas Fonseca <fonseca@diku.dk>
Tue, 12 Sep 2006 00:05:17 +0000 (02:05 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Tue, 12 Sep 2006 00:16:45 +0000 (02:16 +0200)
So now pressing 'f' on a tree link won't open a blank blob view. Also, the
blob reference shown in the title bar is always up to date.

tig.c

diff --git a/tig.c b/tig.c
index 66c5f76..6236bf3 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2601,28 +2601,24 @@ tree_enter(struct view *view, struct line *line)
 
        open_view(view, request, flags);
 
-       if (!VIEW(request)->pipe)
-               return TRUE;
-
-       /* For tree views insert the path to the parent as the first line. */
-       if (request == REQ_VIEW_BLOB) {
-               /* Mirror what is showed in the title bar. */
-               string_ncopy(ref_blob, data + STRING_SIZE("100644 blob "), 40);
-               string_copy(VIEW(REQ_VIEW_BLOB)->ref, ref_blob);
-               return TRUE;
-       }
-
        return TRUE;
 }
 
 static void
 tree_select(struct view *view, struct line *line)
 {
-       if (line->type == LINE_TREE_DIR || line->type == LINE_TREE_FILE) {
-               char *text = line->data;
+       char *text = line->data;
+
+       text += STRING_SIZE("100644 blob ");
+
+       if (line->type == LINE_TREE_FILE) {
+               string_ncopy(ref_blob, text, 40);
+               /* Also update the blob view's ref, since all there must always
+                * be in sync. */
+               string_copy(VIEW(REQ_VIEW_BLOB)->ref, ref_blob);
 
-               string_ncopy(view->ref, text + STRING_SIZE("100644 blob "), 40);
-               string_copy(ref_blob, view->ref);
+       } else if (line->type == LINE_TREE_DIR) {
+               string_ncopy(view->ref, text, 40);
        }
 }