fix handling of non-directories in change from previous commit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/tog/tog.c b/tog/tog.c
index d0e5a2a..fb469f1 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1421,7 +1421,7 @@ browse_commit_tree(struct tog_view **new_view, int begin_x,
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,
@@ -1442,9 +1442,6 @@ browse_commit_tree(struct tog_view **new_view, int begin_x,
*new_view = tree_view;
- if (got_path_is_root_dir(path))
- return NULL;
-
/* Walk the path and open corresponding tree objects. */
p = path;
while (*p) {
@@ -1462,11 +1459,17 @@ browse_commit_tree(struct tog_view **new_view, int begin_x,
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)