make tog's show_log_view() accept a pre-defined view
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
diff --git a/tog/tog.c b/tog/tog.c
index cf32a40..df1b81b 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -93,7 +93,8 @@ static const struct got_error *
show_diff_view(struct tog_view *, struct got_object *, struct got_object *,
struct got_repository *);
static const struct got_error *
-show_log_view(struct got_object_id *, struct got_repository *, const char *);
+show_log_view(struct tog_view *, struct got_object_id *,
+ struct got_repository *, const char *);
static const struct got_error *
show_blame_view(const char *, struct got_object_id *, struct got_repository *);
static const struct got_error *
@@ -763,8 +764,8 @@ browse_commit(struct commit_queue_entry *entry, struct got_repository *repo)
}
static const struct got_error *
-show_log_view(struct got_object_id *start_id, struct got_repository *repo,
- const char *path)
+show_log_view(struct tog_view *view, struct got_object_id *start_id,
+ struct got_repository *repo, const char *path)
{
const struct got_error *err = NULL;
struct got_object_id *head_id = NULL;
@@ -775,7 +776,6 @@ show_log_view(struct got_object_id *start_id, struct got_repository *repo,
struct commit_queue_entry *last_displayed_entry = NULL;
struct commit_queue_entry *selected_entry = NULL;
char *in_repo_path = NULL;
- struct tog_view *view = NULL;
err = got_repo_map_path(&in_repo_path, repo, path);
if (err != NULL)
@@ -799,13 +799,6 @@ show_log_view(struct got_object_id *start_id, struct got_repository *repo,
if (err)
goto done;
- view = open_view(0, 0, 0, 0);
- if (view == NULL) {
- err = got_error_from_errno();
- goto done;
- }
- show_panel(view->panel);
-
/*
* Open the initial batch of commits, sorted in commit graph order.
* We keep all commits open throughout the lifetime of the log view
@@ -820,6 +813,8 @@ show_log_view(struct got_object_id *start_id, struct got_repository *repo,
err = NULL;
}
+ show_panel(view->panel);
+
first_displayed_entry = TAILQ_FIRST(&commits.head);
selected_entry = first_displayed_entry;
while (!done) {
@@ -916,8 +911,6 @@ show_log_view(struct got_object_id *start_id, struct got_repository *repo,
}
}
done:
- if (view)
- close_view(view);
free(head_id);
if (graph)
got_commit_graph_close(graph);
@@ -935,6 +928,7 @@ cmd_log(int argc, char *argv[])
char *path = NULL, *repo_path = NULL, *cwd = NULL;
char *start_commit = NULL;
int ch;
+ struct tog_view *view;
#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc tty", NULL) == -1)
@@ -1003,7 +997,13 @@ cmd_log(int argc, char *argv[])
if (error != NULL)
goto done;
- error = show_log_view(start_id, repo, path);
+ view = open_view(0, 0, 0, 0);
+ if (view == NULL) {
+ error = got_error_from_errno();
+ goto done;
+ }
+ error = show_log_view(view, start_id, repo, path);
+ close_view(view);
done:
free(repo_path);
free(cwd);
@@ -2212,8 +2212,9 @@ blame_tree_entry(struct got_tree_entry *te, struct tog_parent_trees *parents,
}
static const struct got_error *
-log_tree_entry(struct got_tree_entry *te, struct tog_parent_trees *parents,
- struct got_object_id *commit_id, struct got_repository *repo)
+log_tree_entry(struct tog_view *view, struct got_tree_entry *te,
+ struct tog_parent_trees *parents, struct got_object_id *commit_id,
+ struct got_repository *repo)
{
const struct got_error *err = NULL;
char *path;
@@ -2222,7 +2223,7 @@ log_tree_entry(struct got_tree_entry *te, struct tog_parent_trees *parents,
if (err)
return err;
- err = show_log_view(commit_id, repo, path);
+ err = show_log_view(view, commit_id, repo, path);
free(path);
return err;
}
@@ -2294,8 +2295,16 @@ show_tree_view(struct got_tree_object *root, struct got_object_id *commit_id,
break;
case 'l':
if (selected_entry) {
- err = log_tree_entry(selected_entry,
- &parents, commit_id, repo);
+ struct tog_view *log_view;
+ log_view = open_view(0, 0, 0, 0);
+ if (log_view == NULL) {
+ err = got_error_from_errno();
+ goto done;
+ }
+ err = log_tree_entry(log_view,
+ selected_entry, &parents,
+ commit_id, repo);
+ close_view(log_view);
if (err)
goto done;
}