Skip to content

Commit

Permalink
Use id column for commit id only
Browse files Browse the repository at this point in the history
That way, you can better figure out identical references when browsing
the reflog view. Show the reflog name in the title window instead. In
the stash view, the id column also shows the commit id instead of the
reference.

Closes #1025
  • Loading branch information
koutcher committed Dec 13, 2020
1 parent e0fc1f4 commit 710f905
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Bug fixes:

- Fix wrapping of lines with multibyte characters. (#988)
- Improve highlighting of search with $ regex. (#1000)
- Use id column for commit id only. (#1025)

tig-2.5.1
---------
Expand Down
1 change: 0 additions & 1 deletion include/tig/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ struct view_column_data {
const unsigned long *line_number;
const mode_t *mode;
const struct ref *ref;
const char *reflog;
const struct ref *refs;
const char *status;
const char *text;
Expand Down
2 changes: 1 addition & 1 deletion src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno)
continue;

case VIEW_COLUMN_ID:
if (draw_id(view, column, column_data.reflog ? column_data.reflog : column_data.id))
if (draw_id(view, column, column_data.id))
return true;
continue;

Expand Down
11 changes: 8 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,6 @@ main_get_column_data(struct view *view, const struct line *line, struct view_col
column_data->author = commit->author;
column_data->date = &commit->time;
column_data->id = commit->id;
if (state->reflogs)
column_data->reflog = state->reflog[line->lineno - 1];

column_data->commit_title = commit->title;
if (state->with_graph) {
Expand Down Expand Up @@ -593,9 +591,16 @@ main_select(struct view *view, struct line *line)
string_ncopy(view->ref, commit->title, strlen(commit->title));
status_stage_info(view->env->status, line->type, NULL);
} else {
struct main_state *state = view->private;
const struct ref *ref = main_get_commit_refs(line, commit);

string_copy_rev(view->ref, commit->id);
if (state->reflogs) {
assert(state->reflogs >= line->lineno);
string_ncopy(view->ref, state->reflog[line->lineno - 1],
strlen(state->reflog[line->lineno - 1]));
} else {
string_copy_rev(view->ref, commit->id);
}
if (ref)
ref_update_env(view->env, ref, true);
}
Expand Down
6 changes: 2 additions & 4 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,6 @@ compare_view_column(enum view_column_type column, bool use_file_mode,
return apply_comparator(timecmp, column_data1->date, column_data2->date);

case VIEW_COLUMN_ID:
if (column_data1->reflog && column_data2->reflog)
return apply_comparator(strcmp, column_data1->reflog, column_data2->reflog);
return apply_comparator(strcmp, column_data1->id, column_data2->id);

case VIEW_COLUMN_FILE_NAME:
Expand Down Expand Up @@ -1048,7 +1046,7 @@ view_column_text(struct view *view, struct view_column_data *column_data,

case VIEW_COLUMN_ID:
if (column->opt.id.display)
text = column_data->reflog ? column_data->reflog : column_data->id;
text = column_data->id;
break;

case VIEW_COLUMN_LINE_NUMBER:
Expand Down Expand Up @@ -1484,7 +1482,7 @@ view_column_info_update(struct view *view, struct line *line)
width = column->opt.id.width;
if (!width)
width = opt_id_width;
if (!column_data.reflog && !width)
if (!width)
width = 7;
break;

Expand Down
10 changes: 5 additions & 5 deletions test/reflog/default-test
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ in_work_dir create_repo_from_tgz "$base_dir/files/refs-repo.tgz"
test_tig reflog

assert_equals 'reflog-default.screen' <<EOF
HEAD@{0} [r1.1.2] [r1.1.x] <v1.1> checkout: moving from r1.0 to r1.1.2
HEAD@{1} [r1.0] <v1.0> checkout: moving from master to r1.0
HEAD@{2} [master] {origin/master} {max-power/master} {origin/HEAD} reset: moving
HEAD@{3} [master] {origin/master} {max-power/master} {origin/HEAD} clone: from /
b45b570 [r1.1.2] [r1.1.x] <v1.1> checkout: moving from r1.0 to r1.1.2
957f2b3 [r1.0] <v1.0> checkout: moving from master to r1.0
5cb3412 [master] {origin/master} {max-power/master} {origin/HEAD} reset: moving
5cb3412 [master] {origin/master} {max-power/master} {origin/HEAD} clone: from /o
[reflog] b45b5704c34dbd4c5fd89d58d45238ad136ae166 - reference 1 of 4 100%
[reflog] HEAD@{0} - reference 1 of 4 100%
2009-12-26 01:11 +0000 作者 * [r1.1.2] [r1.1.x] <v1.1> Commit 8
2009-12-17 12:49 +0000 René Lévesque * [r1.0] <v1.0> Commit 8 B
2009-12-09 00:27 +0000 A. U. Thor * Commit 8 A
Expand Down

0 comments on commit 710f905

Please sign in to comment.