Skip to content

Commit

Permalink
Show annotated commits in main view
Browse files Browse the repository at this point in the history
Show annotated commits title in main-annotated color (the default
configuration in tigrc uses "default default bold" to follow the
same logic as tags). You can choose a different notes tree using
tig --notes=foo. To see all notes, use tig --notes=*.

Closes jonas#819
  • Loading branch information
koutcher committed May 27, 2019
1 parent 3b0f518 commit f8efe00
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 14 deletions.
8 changes: 4 additions & 4 deletions include/tig/git.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
#define GIT_DIFF_BLAME_NO_PARENT(encoding_arg, context_arg, space_arg, new_name) \
GIT_DIFF_INITIAL(encoding_arg, "", context_arg, space_arg, "/dev/null", new_name)

#define GIT_MAIN_LOG(encoding_arg, commit_order_arg, mainargs, diffargs, revargs, fileargs, pretty_arg) \
#define GIT_MAIN_LOG(encoding_arg, commit_order_arg, mainargs, diffargs, revargs, fileargs, show_notes_arg, pretty_arg) \
"git", "log", (encoding_arg), \
(commit_order_arg), (mainargs), (diffargs), (revargs), "--date=raw", "--parents", \
"--no-color", (pretty_arg), "--", (fileargs), NULL
"--no-color", (show_notes_arg), (pretty_arg), "--", (fileargs), NULL

#define GIT_MAIN_LOG_RAW(encoding_arg, commit_order_arg, mainargs, diffargs, revargs, fileargs) \
GIT_MAIN_LOG(encoding_arg, commit_order_arg, mainargs, diffargs, revargs, fileargs, \
#define GIT_MAIN_LOG_RAW(encoding_arg, commit_order_arg, mainargs, diffargs, revargs, fileargs, show_notes_arg) \
GIT_MAIN_LOG(encoding_arg, commit_order_arg, mainargs, diffargs, revargs, fileargs, show_notes_arg, \
"--pretty=raw")

#endif
Expand Down
1 change: 1 addition & 0 deletions include/tig/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct ref;
_(MAIN_TRACKED, ""), \
_(MAIN_REF, ""), \
_(MAIN_HEAD, ""), \
_(MAIN_ANNOTATED, ""), \
_(STAT_NONE, ""), \
_(STAT_STAGED, ""), \
_(STAT_UNSTAGED, ""), \
Expand Down
1 change: 1 addition & 0 deletions include/tig/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct commit {
const struct ident *author; /* Author of the commit. */
struct time time; /* Date from the author ident. */
struct graph_canvas graph; /* Ancestry chain graphics. */
bool annotated; /* Notes indicator. */
char title[1]; /* First line of the commit message. */
};

Expand Down
1 change: 1 addition & 0 deletions include/tig/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ struct view_column_data {
const char *status;
const char *text;
const struct box *box;
bool annotated;
};

#define view_column_bit(id) (1 << VIEW_COLUMN_##id)
Expand Down
7 changes: 4 additions & 3 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,15 @@ draw_graph(struct view *view, const struct graph *graph, const struct graph_canv
static bool
draw_commit_title(struct view *view, struct view_column *column,
const struct graph *graph, const struct graph_canvas *graph_canvas,
const struct ref *refs, const char *commit_title)
const struct ref *refs, const char *commit_title, bool annotated)
{
if (graph && graph_canvas && column->opt.commit_title.graph &&
draw_graph(view, graph, graph_canvas))
return true;
if (draw_refs(view, column, refs))
return true;
return draw_text_overflow(view, commit_title, LINE_DEFAULT,
return draw_text_overflow(view, commit_title,
annotated ? LINE_MAIN_ANNOTATED : LINE_DEFAULT,
column->opt.commit_title.overflow, 0);
}

Expand Down Expand Up @@ -510,7 +511,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno)

case VIEW_COLUMN_COMMIT_TITLE:
if (draw_commit_title(view, column, column_data.graph, column_data.graph_canvas,
column_data.refs, column_data.commit_title))
column_data.refs, column_data.commit_title, column_data.annotated))
return true;
continue;

Expand Down
12 changes: 9 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,12 @@ main_open(struct view *view, enum open_flags flags)
const char *pretty_custom_argv[] = {
GIT_MAIN_LOG(encoding_arg, commit_order_arg_with_graph(graph_display),
"%(mainargs)", "%(cmdlineargs)", "%(revargs)", "%(fileargs)",
log_custom_pretty_arg())
show_notes_arg(), log_custom_pretty_arg())
};
const char *pretty_raw_argv[] = {
GIT_MAIN_LOG_RAW(encoding_arg, commit_order_arg_with_graph(graph_display),
"%(mainargs)", "%(cmdlineargs)", "%(revargs)", "%(fileargs)")
"%(mainargs)", "%(cmdlineargs)", "%(revargs)", "%(fileargs)",
show_notes_arg())
};
struct main_state *state = view->private;
const char **main_argv = pretty_custom_argv;
Expand Down Expand Up @@ -360,6 +361,7 @@ main_get_column_data(struct view *view, const struct line *line, struct view_col
column_data->reflog = state->reflog[line->lineno - 1];

column_data->commit_title = commit->title;
column_data->annotated = commit->annotated;
if (state->with_graph) {
column_data->graph = state->graph;
column_data->graph_canvas = &commit->graph;
Expand Down Expand Up @@ -459,8 +461,12 @@ main_read(struct view *view, struct buffer *buf, bool force_stop)
parse_author_line(author, &commit->author, &commit->time);
if (state->with_graph)
graph->render_parents(graph, &commit->graph);
if (title)
if (title) {
char *notes = io_memchr(buf, title, 0);

commit->annotated = notes && *notes;
main_add_commit(view, LINE_MAIN_COMMIT, commit, title, false);
}
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ const char *
log_custom_pretty_arg(void)
{
return opt_mailmap
? "--pretty=format:commit %m %H %P%x00%aN <%aE> %ad%x00%s"
: "--pretty=format:commit %m %H %P%x00%an <%ae> %ad%x00%s";
? "--pretty=format:commit %m %H %P%x00%aN <%aE> %ad%x00%s%x00%N"
: "--pretty=format:commit %m %H %P%x00%an <%ae> %ad%x00%s%x00%N";
}

#define ENUM_ARG(enum_name, arg_string) ENUM_MAP_ENTRY(arg_string, enum_name)
Expand Down
2 changes: 1 addition & 1 deletion src/refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ refs_request(struct view *view, enum request request, struct line *line)
const char *all_references_argv[] = {
GIT_MAIN_LOG(encoding_arg, commit_order_arg(),
"%(mainargs)", "",
refs_is_all(reference) ? "--all" : ref->name, "",
refs_is_all(reference) ? "--all" : ref->name, "", "",
log_custom_pretty_arg())
};

Expand Down
2 changes: 1 addition & 1 deletion test/main/filter-args-test
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ git rev-parse --git-dir --is-inside-work-tree --show-cdup --show-prefix HEAD --s
EOF

assert_equals 'log.trace' <<EOF
git log --encoding=UTF-8 --topo-order --exclude=refs/remotes/origin/* --exclude=refs/heads/master --all --date=raw --parents --no-color --pretty=format:commit %m %H %P%x00%an <%ae> %ad%x00%s -- common tracer
git log --encoding=UTF-8 --topo-order --exclude=refs/remotes/origin/* --exclude=refs/heads/master --all --date=raw --parents --no-color --show-notes --pretty=format:commit %m %H %P%x00%an <%ae> %ad%x00%s%x00%N -- common tracer
EOF

assert_equals 'filtered.screen' <<EOF
Expand Down
1 change: 1 addition & 0 deletions tigrc
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ color main-replace cyan default
color main-tracked yellow default bold
color main-ref cyan default
color main-head cyan default bold
color main-annotated default default bold
color stat-none default default
color stat-staged magenta default
color stat-unstaged magenta default
Expand Down

0 comments on commit f8efe00

Please sign in to comment.