Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use id column for commit id only #1056

Merged
merged 1 commit into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Bug fixes:
- Fix wrapping of lines with multibyte characters. (#988)
- Improve highlighting of search with $ regex. (#1000)
- Update tracking branch when refreshing status view. (#1015)
- 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 @@ -364,8 +364,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 @@ -587,9 +585,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]));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This will show the reflog ID in the title bar.

} 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 @@ -893,8 +893,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 @@ -1054,7 +1052,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 @@ -1492,7 +1490,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] {max-power/master} {origin/HEAD} {origin/master} reset: moving
HEAD@{3} [master] {max-power/master} {origin/HEAD} {origin/master} 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] {max-power/master} {origin/HEAD} {origin/master} reset: moving
5cb3412 [master] {max-power/master} {origin/HEAD} {origin/master} 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