Skip to content

Commit 4b342f1

Browse files
authored
Use id column for commit id only (#1056)
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 aee8eb1 commit 4b342f1

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
@@ -364,8 +364,6 @@ main_get_column_data(struct view *view, const struct line *line, struct view_col
364364
column_data->author = commit->author;
365365
column_data->date = &commit->time;
366366
column_data->id = commit->id;
367-
if (state->reflogs)
368-
column_data->reflog = state->reflog[line->lineno - 1];
369367

370368
column_data->commit_title = commit->title;
371369
if (state->with_graph) {
@@ -587,9 +585,16 @@ main_select(struct view *view, struct line *line)
587585
string_ncopy(view->ref, commit->title, strlen(commit->title));
588586
status_stage_info(view->env->status, line->type, NULL);
589587
} else {
588+
struct main_state *state = view->private;
590589
const struct ref *ref = main_get_commit_refs(line, commit);
591590

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

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)