commit - 3bf198ba335fa30c8d16efb5c8e496200ac99c05
commit + 18430de34d84534127f98116e72ee39bb145f6fd
blob - 390bc183325517cc6ee710b64a1f0a8e0a3c86c2
blob + edd2b6d8e60f9b46f3cf146bc7660986c9d5ffda
--- tog/tog.c
+++ tog/tog.c
static const struct got_error *
draw_blame(WINDOW *window, FILE *f, const char *path,
- struct tog_blame_line *lines, int nlines, int *first_displayed_line,
- int *last_displayed_line, int *eof, int max_lines)
+ struct tog_blame_line *lines, int nlines, int blame_complete,
+ int *first_displayed_line, int *last_displayed_line,
+ int *eof, int max_lines)
{
const struct got_error *err;
int lineno = 0, nprinted = 0;
rewind(f);
werase(window);
- if (asprintf(&line, "annotation of %s (lines %d-%d of %d)", path,
- *first_displayed_line, *last_displayed_line, nlines) == -1)
+ if (asprintf(&line, "[%d-%d/%d] annotation of %s%s",
+ *first_displayed_line, *last_displayed_line, nlines,
+ path, blame_complete ? "" : " in progress...") == -1)
return got_error_from_errno();
err = format_line(&wline, &width, line, COLS);
free(line);
WINDOW *window;
int *first_displayed_line;
int *last_displayed_line;
- int *done;
+ int *quit;
};
static const struct got_error *
if (pthread_mutex_lock(a->mutex) != 0)
return got_error_from_errno();
- if (*a->done) { /* user has quit the blame view */
+ if (*a->quit) { /* user has quit the blame view */
err = got_error(GOT_ERR_ITER_COMPLETED);
goto done;
}
}
line->annotated = 1;
- err = draw_blame(a->window, a->f, a->path, a->lines, a->nlines,
+ err = draw_blame(a->window, a->f, a->path, a->lines, a->nlines, 0,
a->first_displayed_line, a->last_displayed_line, &eof, LINES);
done:
if (pthread_mutex_unlock(a->mutex) != 0)
struct got_object_id *commit_id;
struct got_repository *repo;
void *blame_cb_args;
+ int *complete;
};
static void *
blame_thread(void *arg)
{
- struct tog_blame_thread_args *a = arg;
- return (void *)got_blame_incremental(a->path, a->commit_id, a->repo,
- blame_cb, a->blame_cb_args);
+ const struct got_error *err;
+ struct tog_blame_thread_args *ta = arg;
+ struct tog_blame_cb_args *a = ta->blame_cb_args;
+ int eof;
+
+ err = got_blame_incremental(ta->path, ta->commit_id, ta->repo,
+ blame_cb, ta->blame_cb_args);
+ *ta->complete = 1;
+ if (err)
+ return (void *)err;
+
+ if (pthread_mutex_lock(a->mutex) != 0)
+ return (void *)got_error_from_errno();
+
+ err = draw_blame(a->window, a->f, a->path, a->lines, a->nlines, 1,
+ a->first_displayed_line, a->last_displayed_line, &eof, LINES);
+
+ if (pthread_mutex_unlock(a->mutex) != 0 && err == NULL)
+ err = got_error_from_errno();
+
+ return (void *)err;
}
static const struct got_error *
{
const struct got_error *err = NULL;
int ch, done = 0, first_displayed_line = 1, last_displayed_line = LINES;
- int eof, i;
+ int eof, i, blame_complete = 0;
struct got_object *obj = NULL;
struct got_blob_object *blob = NULL;
FILE *f = NULL;
blame_cb_args.window = tog_blame_view.window;
blame_cb_args.first_displayed_line = &first_displayed_line;
blame_cb_args.last_displayed_line = &last_displayed_line;
- blame_cb_args.done = &done;
+ blame_cb_args.quit = &done;
blame_thread_args.path = path;
blame_thread_args.commit_id = commit_id;
blame_thread_args.repo = repo;
blame_thread_args.blame_cb_args = &blame_cb_args;
+ blame_thread_args.complete = &blame_complete;
if (pthread_create(&thread, NULL, blame_thread,
&blame_thread_args) != 0) {
goto done;
}
err = draw_blame(tog_blame_view.window, f, path, lines, nlines,
- &first_displayed_line, &last_displayed_line, &eof, LINES);
+ blame_complete, &first_displayed_line, &last_displayed_line,
+ &eof, LINES);
if (pthread_mutex_unlock(&mutex) != 0) {
err = got_error_from_errno();
goto done;