commit - decd3bd14e78423a5f4398c1706d6d6bc4d0d662
commit + ab089a2a3acbaa8f750cfa1eea773efea685191c
blob - 4c0093a42e49bc5234324cb313037cb515e857cb
blob + 1c84a1f621f5060040676c60f90137c47447cfd0
--- tog/tog.c
+++ tog/tog.c
};
static const struct got_error *
-draw_blame(WINDOW *window, FILE *f, const char *path,
+draw_blame(WINDOW *window, struct got_object_id *id, FILE *f, const char *path,
struct tog_blame_line *lines, int nlines, int blame_complete,
int selected_line, int *first_displayed_line, int *last_displayed_line,
int *eof, int max_lines)
int width, wlimit;
struct tog_blame_line *blame_line;
struct got_object_id *prev_id = NULL;
+ char *id_str;
+
+ err = got_object_id_str(&id_str, id);
+ if (err)
+ return err;
rewind(f);
werase(window);
- if (asprintf(&line, "[%d-%d/%d] annotation of %s%s",
- *first_displayed_line, *last_displayed_line, nlines,
- path, blame_complete ? "" : " in progress...") == -1)
+ if (asprintf(&line, "commit: %s", id_str) == -1) {
+ err = got_error_from_errno();
+ free(id_str);
+ return err;
+ }
+
+ err = format_line(&wline, &width, line, COLS);
+ free(line);
+ waddwstr(window, wline);
+ if (width < COLS)
+ waddch(window, '\n');
+
+ if (asprintf(&line, "[%d-%d/%d] %s%s",
+ *first_displayed_line, *last_displayed_line, nlines,
+ path, blame_complete ? "" : " annotating...") == -1) {
+ free(id_str);
return got_error_from_errno();
+ }
+ free(id_str);
err = format_line(&wline, &width, line, COLS);
free(line);
if (err)
waddch(window, '\n');
*eof = 0;
- while (nprinted < max_lines - 1) {
+ while (nprinted < max_lines - 2) {
line = parse_next_line(f, &len);
if (line == NULL) {
*eof = 1;
struct tog_blame_line *lines; /* one per line */
int nlines;
+ struct got_object_id *commit_id;
FILE *f;
const char *path;
WINDOW *window;
}
line->annotated = 1;
- err = draw_blame(a->window, a->f, a->path, a->lines, a->nlines, 0,
- *a->selected_line, a->first_displayed_line, a->last_displayed_line,
- &eof, LINES);
+ err = draw_blame(a->window, a->commit_id, a->f, a->path, a->lines,
+ a->nlines, 0, *a->selected_line, a->first_displayed_line,
+ a->last_displayed_line, &eof, LINES);
done:
if (pthread_mutex_unlock(a->mutex) != 0)
return got_error_from_errno();
struct tog_blame_thread_args {
const char *path;
- struct got_object_id *commit_id;
struct got_repository *repo;
void *blame_cb_args;
int *complete;
struct tog_blame_cb_args *a = ta->blame_cb_args;
int eof;
- err = got_blame_incremental(ta->path, ta->commit_id, ta->repo,
+ err = got_blame_incremental(ta->path, a->commit_id, ta->repo,
blame_cb, ta->blame_cb_args);
*ta->complete = 1;
if (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->selected_line, a->first_displayed_line, a->last_displayed_line,
+ err = draw_blame(a->window, a->commit_id, a->f, a->path, a->lines,
+ a->nlines, 1, *a->selected_line, a->first_displayed_line,
+ a->last_displayed_line,
&eof, LINES);
if (pthread_mutex_unlock(a->mutex) != 0 && err == NULL)
blame_cb_args.lines = lines;
blame_cb_args.nlines = nlines;
blame_cb_args.mutex = &mutex;
+ blame_cb_args.commit_id = commit_id;
blame_cb_args.f = f;
blame_cb_args.path = path;
blame_cb_args.window = tog_blame_view.window;
blame_cb_args.quit = &done;
blame_thread_args.path = path;
- blame_thread_args.commit_id = commit_id;
blame_thread_args.repo = blame_thread_repo;
blame_thread_args.blame_cb_args = &blame_cb_args;
blame_thread_args.complete = &blame_complete;
err = got_error_from_errno();
goto done;
}
- err = draw_blame(tog_blame_view.window, f, path, lines, nlines,
- blame_complete, selected_line, &first_displayed_line,
- &last_displayed_line, &eof, LINES);
+ err = draw_blame(tog_blame_view.window, commit_id, f, path,
+ lines, nlines, blame_complete, selected_line,
+ &first_displayed_line, &last_displayed_line, &eof, LINES);
if (pthread_mutex_unlock(&mutex) != 0) {
err = got_error_from_errno();
goto done;