Commit Diff


commit - 20a2ad1cd21c17764d7586038148381fb41adcb9
commit + 74cfe85e3941b6738539031e8c2cf8e59db13eab
blob - a99744c546674ba7c12f31a138da72c698c6902d
blob + a0db9b1a7f0df182ae32cc5af74379a2ad21c6d8
--- tog/tog.c
+++ tog/tog.c
@@ -2439,30 +2439,34 @@ input_log_view(struct tog_view **new_view, struct tog_
 			*new_view = tree_view;
 		break;
 	case KEY_BACKSPACE:
-		if (strcmp(s->in_repo_path, "/") == 0)
+		if (got_path_cmp(s->in_repo_path, "/",
+		    strlen(s->in_repo_path), 1) == 0)
 			break;
-		parent_path = dirname(s->in_repo_path);
-		if (parent_path && strcmp(parent_path, ".") != 0) {
-			err = stop_log_thread(s);
-			if (err)
-				return err;
-			lv = view_open(view->nlines, view->ncols,
-			    view->begin_y, view->begin_x, TOG_VIEW_LOG);
-			if (lv == NULL)
-				return got_error_from_errno(
-				    "view_open");
-			err = open_log_view(lv, s->start_id, s->refs,
-			    s->repo, s->head_ref_name, parent_path,
-			    s->log_branches);
-			if (err)
-				return err;;
-			if (view_is_parent_view(view))
-				*new_view = lv;
-			else {
-				view_set_child(view->parent, lv);
-				*focus_view = lv;
-			}
-			return NULL;
+		err = got_path_dirname(&parent_path, s->in_repo_path);
+		if (err)
+			return err;
+		err = stop_log_thread(s);
+		if (err) {
+			free(parent_path);
+			return err;
+		}
+		lv = view_open(view->nlines, view->ncols,
+		    view->begin_y, view->begin_x, TOG_VIEW_LOG);
+		if (lv == NULL) {
+			free(parent_path);
+			return got_error_from_errno("view_open");
+		}
+		err = open_log_view(lv, s->start_id, s->refs,
+		    s->repo, s->head_ref_name, parent_path,
+		    s->log_branches);
+		free(parent_path);
+		if (err)
+			return err;;
+		if (view_is_parent_view(view))
+			*new_view = lv;
+		else {
+			view_set_child(view->parent, lv);
+			*focus_view = lv;
 		}
 		break;
 	case CTRL('l'):