commit - f3000d9057e4537bca1386858f58aaf3e1b550c3
commit + 1134ebde7e9791e46cbbb9356aa0abf4617125da
blob - aeb5a6fad658605ce561bee956f82b7fd58cca3f
blob + f28f644c2ffd30e11a5646fd5f92ca54144e5829
--- tog/tog.c
+++ tog/tog.c
int *complete;
got_cancel_cb cancel_cb;
void *cancel_arg;
+ pthread_cond_t blame_complete;
};
struct tog_blame {
size_t linesz = 0;
*ch = -1;
-
- if (tog_io.wait_for_ui)
- goto done;
if (getline(&line, &linesz, script) == -1) {
if (feof(script)) {
goto done;
}
}
+
if (strncasecmp(line, "WAIT_FOR_UI", 11) == 0)
tog_io.wait_for_ui = 1;
else if (strncasecmp(line, "KEY_ENTER", 9) == 0)
"newterm: failed to initialise curses");
using_mock_io = 1;
+
done:
if (err)
tog_io_close();
if (view->gline > blame->nlines)
view->gline = blame->nlines;
+ if (tog_io.wait_for_ui) {
+ struct tog_blame_thread_args *bta = &s->blame.thread_args;
+ int rc;
+
+ rc = pthread_cond_wait(&bta->blame_complete, &tog_mutex);
+ if (rc)
+ return got_error_set_errno(rc, "pthread_cond_wait");
+ tog_io.wait_for_ui = 0;
+ }
+
if (asprintf(&line, "[%d/%d] %s%s", view->gline ? view->gline :
s->first_displayed_line - 1 + s->selected_line, blame->nlines,
s->blame_complete ? "" : "annotating... ", s->path) == -1) {
view_border(view);
- if (tog_io.wait_for_ui) {
- if (s->blame_complete)
- tog_io.wait_for_ui = 0;
- }
-
return NULL;
}
err = close_err;
ta->repo = NULL;
*ta->complete = 1;
+
+ if (tog_io.wait_for_ui) {
+ errcode = pthread_cond_signal(&ta->blame_complete);
+ if (errcode && err == NULL)
+ err = got_error_set_errno(errcode,
+ "pthread_cond_signal");
+ }
errcode = pthread_mutex_unlock(&tog_mutex);
if (errcode && err == NULL)
view->search_start = search_start_blame_view;
view->search_setup = search_setup_blame_view;
view->search_next = search_next_view_match;
+
+ if (using_mock_io) {
+ struct tog_blame_thread_args *bta = &s->blame.thread_args;
+ int rc;
+
+ rc = pthread_cond_init(&bta->blame_complete, NULL);
+ if (rc)
+ return got_error_set_errno(rc, "pthread_cond_init");
+ }
return run_blame(view);
}
blamed_commit = STAILQ_FIRST(&s->blamed_commits);
STAILQ_REMOVE_HEAD(&s->blamed_commits, entry);
got_object_qid_free(blamed_commit);
+ }
+
+ if (using_mock_io) {
+ struct tog_blame_thread_args *bta = &s->blame.thread_args;
+ int rc;
+
+ rc = pthread_cond_destroy(&bta->blame_complete);
+ if (rc && err == NULL)
+ err = got_error_set_errno(rc, "pthread_cond_destroy");
}
free(s->path);