Feature/show commit in main #77

Closed
wants to merge 12 commits into
from

Projects

None yet

3 participants

@esc
Contributor
esc commented Aug 15, 2012

I was missing the feature to show the (abbreviated) commit ID in the main view. The three commits in this branch implement this feature.

I have taken care to implement the feature, the settings including color for this feature, the possibility to toggle this feature and documentation for all of this.

By default the display is disabled, to not confuse regular users of Tig with a new default main view.

One question remains. I don't understand why need to use +1 when drawing the commit ID to get 7 shown characters if the value of opt_id_len is 7?

esc added some commits Aug 15, 2012
@esc esc implement showing commit ID in main view
Signed-off-by: Valentin Haenel <valentin.haenel@gmx.de>
17cbada
@esc esc implement toggle showing commit ID in main view
Signed-off-by: Valentin Haenel <valentin.haenel@gmx.de>
7d3385c
@esc esc document showing (and toggling) commit ID
Signed-off-by: Valentin Haenel <valentin.haenel@gmx.de>
0369849
@vivien vivien and 1 other commented on an outdated diff Aug 15, 2012
@@ -1517,6 +1522,12 @@ enum option_code {
if (!strcmp(argv[0], "wrap-lines"))
return parse_bool(&opt_wrap_lines, argv[2]);
+ if (!strcmp(argv[0], "show-id"))
+ return parse_bool(&opt_show_id, argv[2]);
+
+ if (!strcmp(argv[0], "id-len"))
+ return parse_int(&opt_id_len, argv[2], 1, 40);
@vivien
vivien Aug 15, 2012 Contributor

According to Git, the minimum abbrev size is 4 (see environment.c:17).

@vivien
vivien Aug 15, 2012 Contributor

Also, it would be smart to parse the core.abbrev git config option.

@jonas
jonas Aug 17, 2012 Owner

Yes, using core.abbrev would be nice.

@vivien
Contributor
vivien commented Aug 15, 2012

BTW, I would have squashed those 3 commits, and used "abbrev" instead of "id" to use Git terminology, but that's just me. Otherwise I tested it and it works fine!

@esc
Contributor
esc commented Aug 17, 2012

One thing i just noticed, is that searching for a partial commit ID using / does not work. Am not sure why this is the case...

@jonas
Owner
jonas commented Aug 17, 2012

@esc They are not searchable because they are not made searchable. See main_grep: https://github.com/jonas/tig/blob/master/tig.c#L7301

@esc
Contributor
esc commented Aug 17, 2012

Yeah, I just discovered that. Preparing a patch to make them search-able.

@jonas
jonas commented on tig.c in 17cbada Aug 17, 2012

There is an existing constant that I propose using here:

#define ID_COLS         8
@jonas
Owner
jonas commented Aug 17, 2012
One question remains. I don't understand why need to use +1 when drawing the commit ID to get 7 shown characters if the value of opt_id_len is 7?

@esc It is because the argument to draw_field is the number of (character) columns to stretch this field including a separator/padding character at the end.

esc added some commits Aug 17, 2012
@esc esc fix: minimum abbrev length is 4
Suggested-by: Vivien Didelot <vivien@didelot.org>
37a3155
@esc esc fix: use already defined ID_COLS as default
Suggested-by: Jonas Fonseca <jonas.fonseca@gmail.com>
8438a7e
@esc
Contributor
esc commented Aug 17, 2012

@jonas Thanks! In that case I'll remove the +1 so that the option id-len is consistent with author-width and filename-width. Also, I'll rename it to id-width for consistent naming.

esc added some commits Aug 17, 2012
@esc esc fix: don't add one to make display consistent
The option value specifies the length including the padding character. I
initially added one to mean: "if I specify an id-len of 7, I get 7 hex chars".
However it seems more sensible to make this option consistent with the others
to mean: "If i specify an id-len of 7, I get 6 hex chars plus a single
whitespace for padding."
287baa8
@esc esc rename opt_id_len -> opt_id_cols for consistency 48444cf
@esc esc rename id-len -> id-width for consistency 0e82095
@esc esc read core.abbrev, but prefer id-width
There are now two settings that can affect how long the commit ID in the main
view is: 'core.abbrev' and 'id-width'. The first is a core option, the second
is a tig specific one. In case tig finds the first setting it respects this. In
case the user wishes tig to use a different value, the second option is
provided as an oevrride.
edfc873
@esc esc document that 'core.abbrev' will be searched 311c0c3
@esc esc increment the value of 'core.abbrev' to match tig semantics dd58466
@jonas jonas added a commit that referenced this pull request Aug 18, 2012
@esc @jonas esc + [GH #77] Add options for displaying commit IDs in the main view
'show-id' will make the commit IDs visible, and 'id-width' configures
how many characters to show. The latter is also applied to the blame
view.

Reviewed-by: Vivien Didelot <vivien@didelot.org>
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
f6280b3
@jonas
Owner
jonas commented Aug 18, 2012

Thanks, I squash-merged this and made a couple of cosmetic changes, but the end result should be the same. Also, I ended up renaming the _cols/_COLS variables to _width/WIDTH and changing draw_field() to automatically add an extra character for the padding to simplify the handling of core.abbrev.

@jonas jonas closed this Aug 18, 2012
@esc
Contributor
esc commented Aug 18, 2012

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment