commit b03c880f032f7cfc88a56c2ede174663d4357344 from: Stefan Sperling date: Tue May 21 11:47:20 2019 UTC fix handling of non-directories in change from previous commit commit - 941e9f741afacc0a0b0fc19b80c534c8917589fb commit + b03c880f032f7cfc88a56c2ede174663d4357344 blob - d0e5a2aa7f3136157c5f5d9036fcffa69949bcf1 blob + fb469f128940f28466812d8c09b2f1cc44c03bb6 --- tog/tog.c +++ tog/tog.c @@ -1421,7 +1421,7 @@ browse_commit_tree(struct tog_view **new_view, int beg struct got_tree_entry *te; struct tog_tree_view_state *s; struct tog_view *tree_view; - char *slash, *subpath; + char *slash, *subpath = NULL; const char *p; err = got_object_open_as_tree(&tree, repo, @@ -1441,9 +1441,6 @@ browse_commit_tree(struct tog_view **new_view, int beg s = &tree_view->state.tree; *new_view = tree_view; - - if (got_path_is_root_dir(path)) - return NULL; /* Walk the path and open corresponding tree objects. */ p = path; @@ -1462,12 +1459,18 @@ browse_commit_tree(struct tog_view **new_view, int beg s->selected_entry = te; break; } + s->selected++; } if (s->selected_entry == NULL) { err = got_error(GOT_ERR_NO_TREE_ENTRY); break; } + if (s->tree != s->root) + s->selected++; /* skip '..' */ + if (!S_ISDIR(s->selected_entry->mode)) + break; + slash = strchr(p, '/'); if (slash) subpath = strndup(path, slash - path);