Skip to content

Commit 8373b8b

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 9e67e01 commit 8373b8b

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) {
@@ -593,9 +591,16 @@ main_select(struct view *view, struct line *line)
593591
string_ncopy(view->ref, commit->title, strlen(commit->title));
594592
status_stage_info(view->env->status, line->type, NULL);
595593
} else {
594+
struct main_state *state = view->private;
596595
const struct ref *ref = main_get_commit_refs(line, commit);
597596

598-
string_copy_rev(view->ref, commit->id);
597+
if (state->reflogs) {
598+
assert(state->reflogs >= line->lineno);
599+
string_ncopy(view->ref, state->reflog[line->lineno - 1],
600+
strlen(state->reflog[line->lineno - 1]));
601+
} else {
602+
string_copy_rev(view->ref, commit->id);
603+
}
599604
if (ref)
600605
ref_update_env(view->env, ref, true);
601606
}

src/view.c

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

889889
case VIEW_COLUMN_ID:
890-
if (column_data1->reflog && column_data2->reflog)
891-
return apply_comparator(strcmp, column_data1->reflog, column_data2->reflog);
892890
return apply_comparator(strcmp, column_data1->id, column_data2->id);
893891

894892
case VIEW_COLUMN_FILE_NAME:
@@ -1048,7 +1046,7 @@ view_column_text(struct view *view, struct view_column_data *column_data,
10481046

10491047
case VIEW_COLUMN_ID:
10501048
if (column->opt.id.display)
1051-
text = column_data->reflog ? column_data->reflog : column_data->id;
1049+
text = column_data->id;
10521050
break;
10531051

10541052
case VIEW_COLUMN_LINE_NUMBER:
@@ -1486,7 +1484,7 @@ view_column_info_update(struct view *view, struct line *line)
14861484
width = column->opt.id.width;
14871485
if (!width)
14881486
width = opt_id_width;
1489-
if (!column_data.reflog && !width)
1487+
if (!width)
14901488
width = 7;
14911489
break;
14921490

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)