Skip to content

Commit 93e557c

Browse files
committed
Use id column for commit id only
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
1 parent 683b0cf commit 93e557c

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

NEWS.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Bug fixes:
1717
- Fix wrapping of lines with multibyte characters. (#988)
1818
- Improve highlighting of search with $ regex. (#1000)
1919
- Update tracking branch when refreshing status view. (#1015)
20+
- Use id column for commit id only. (#1025)
2021

2122
tig-2.5.1
2223
---------

include/tig/view.h

-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ struct view_column_data {
195195
const unsigned long *line_number;
196196
const mode_t *mode;
197197
const struct ref *ref;
198-
const char *reflog;
199198
const struct ref *refs;
200199
const char *status;
201200
const char *text;

src/draw.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno)
495495
continue;
496496

497497
case VIEW_COLUMN_ID:
498-
if (draw_id(view, column, column_data.reflog ? column_data.reflog : column_data.id))
498+
if (draw_id(view, column, column_data.id))
499499
return true;
500500
continue;
501501

src/main.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,6 @@ main_get_column_data(struct view *view, const struct line *line, struct view_col
362362
column_data->author = commit->author;
363363
column_data->date = &commit->time;
364364
column_data->id = commit->id;
365-
if (state->reflogs)
366-
column_data->reflog = state->reflog[line->lineno - 1];
367365

368366
column_data->commit_title = commit->title;
369367
if (state->with_graph) {
@@ -585,9 +583,16 @@ main_select(struct view *view, struct line *line)
585583
string_ncopy(view->ref, commit->title, strlen(commit->title));
586584
status_stage_info(view->env->status, line->type, NULL);
587585
} else {
586+
struct main_state *state = view->private;
588587
const struct ref *ref = main_get_commit_refs(line, commit);
589588

590-
string_copy_rev(view->ref, commit->id);
589+
if (state->reflogs) {
590+
assert(state->reflogs >= line->lineno);
591+
string_ncopy(view->ref, state->reflog[line->lineno - 1],
592+
strlen(state->reflog[line->lineno - 1]));
593+
} else {
594+
string_copy_rev(view->ref, commit->id);
595+
}
591596
if (ref)
592597
ref_update_env(view->env, ref, true);
593598
}

src/view.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,6 @@ compare_view_column(enum view_column_type column, bool use_file_mode,
893893
return apply_comparator(timecmp, column_data1->date, column_data2->date);
894894

895895
case VIEW_COLUMN_ID:
896-
if (column_data1->reflog && column_data2->reflog)
897-
return apply_comparator(strcmp, column_data1->reflog, column_data2->reflog);
898896
return apply_comparator(strcmp, column_data1->id, column_data2->id);
899897

900898
case VIEW_COLUMN_FILE_NAME:
@@ -1054,7 +1052,7 @@ view_column_text(struct view *view, struct view_column_data *column_data,
10541052

10551053
case VIEW_COLUMN_ID:
10561054
if (column->opt.id.display)
1057-
text = column_data->reflog ? column_data->reflog : column_data->id;
1055+
text = column_data->id;
10581056
break;
10591057

10601058
case VIEW_COLUMN_LINE_NUMBER:
@@ -1492,7 +1490,7 @@ view_column_info_update(struct view *view, struct line *line)
14921490
width = column->opt.id.width;
14931491
if (!width)
14941492
width = opt_id_width;
1495-
if (!column_data.reflog && !width)
1493+
if (!width)
14961494
width = 7;
14971495
break;
14981496

test/reflog/default-test

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ in_work_dir create_repo_from_tgz "$base_dir/files/refs-repo.tgz"
2121
test_tig reflog
2222

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

0 commit comments

Comments
 (0)