Move the current line to the first entry in the tree view
[tig] / tig.c
diff --git a/tig.c b/tig.c
index e78c26c..bd86899 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -1684,7 +1684,7 @@ search_view(struct view *view, enum request request, const char *search)
                char buf[SIZEOF_STR] = "unknown error";
 
                regerror(regex_err, &view->regex, buf, sizeof(buf));
-               report("Search failed: %s", buf);;
+               report("Search failed: %s", buf);
                return;
        }
 
@@ -2452,6 +2452,7 @@ tree_read(struct view *view, char *text)
        char buf[SIZEOF_STR];
        unsigned long pos;
        enum line_type type;
+       bool first_read = view->lines == 0;
 
        if (textlen <= SIZEOF_TREE_ATTR)
                return FALSE;
@@ -2459,8 +2460,7 @@ tree_read(struct view *view, char *text)
        type = text[STRING_SIZE("100644 ")] == 't'
             ? LINE_TREE_DIR : LINE_TREE_FILE;
 
-       /* The first time around ... */
-       if (!view->lines) {
+       if (first_read) {
                /* Add path info line */
                if (snprintf(buf, sizeof(buf), "Directory path /%s", opt_path) < sizeof(buf) &&
                    realloc_lines(view, view->line_size + 1) &&
@@ -2518,6 +2518,10 @@ tree_read(struct view *view, char *text)
        if (!pager_read(view, text))
                return FALSE;
 
+       /* Move the current line to the first tree entry. */
+       if (first_read)
+               view->lineno++;
+
        view->line[view->lines - 1].type = type;
        return TRUE;
 }
@@ -3416,7 +3420,7 @@ main(int argc, char *argv[])
 
        if (*opt_codeset && strcmp(opt_codeset, opt_encoding)) {
                opt_iconv = iconv_open(opt_codeset, opt_encoding);
-               if (opt_iconv == (iconv_t) -1)
+               if (opt_iconv == ICONV_NONE)
                        die("Failed to initialize character set conversion");
        }