summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 21afe1d)
raw | patch | inline | side by side (parent: 21afe1d)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 9 Mar 2011 23:15:49 +0000 (18:15 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 9 Mar 2011 23:38:33 +0000 (18:38 -0500) |
NEWS | patch | blob | history | |
tig.1.txt | patch | blob | history | |
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
index bdbd0a4e710b25204eac543e55aa693b1fbc3076..6091738f29cdf2c42670af958e1b5c42d034141e 100644 (file)
--- a/NEWS
+++ b/NEWS
master
------
+Improvements:
+
+ - (GH-6) Make blame configurable via extra options passed from the command
+ line and blame-options setting from ~/.tigrc. For example:
+
+ set blame-options = -C -C -C
+
Bug fixes:
- Expand %(directory) to . for the root directory. (GH-3)
diff --git a/tig.1.txt b/tig.1.txt
index 3e2ffdf59721072b5e7856da0532387bb2d5bd5b..490a0a247008663da6e0fc021150f09255e634ff 100644 (file)
--- a/tig.1.txt
+++ b/tig.1.txt
[verse]
tig [options] [revisions] [--] [paths]
tig show [options] [revisions] [--] [paths]
-tig blame [rev] path
+tig blame [options] [rev] path
tig status
tig < [git command output]
command.
show::
- Open diff view using the given git show options.
+ Open diff view using the given git-show(1) options.
blame::
- Show given file annotated or blamed by commits.
+ Show given file annotated by commits.
+ Takes zero or more git-blame(1) options.
Optionally limited from given revision.
status::
index 9250cd7013e7c26b8187ce09c2ead6233bc61f87..f022f17a974b2424f32e6c729a191f6672ac2792 100644 (file)
--- a/tig.c
+++ b/tig.c
static const char **opt_diff_argv = NULL;
static const char **opt_rev_argv = NULL;
static const char **opt_file_argv = NULL;
+static const char **opt_blame_argv = NULL;
#define is_initial_commit() (!get_ref_head())
#define is_head_commit(rev) (!strcmp((rev), "HEAD") || (get_ref_head() && !strcmp(rev, get_ref_head()->id)))
OPT_ERR_(NO_OPTION_VALUE, "No option value"), \
OPT_ERR_(NO_VALUE_ASSIGNED, "No value assigned"), \
OPT_ERR_(OBSOLETE_REQUEST_NAME, "Obsolete request name"), \
+ OPT_ERR_(OUT_OF_MEMORY, "Out of memory"), \
OPT_ERR_(TOO_MANY_OPTION_ARGUMENTS, "Too many option arguments"), \
OPT_ERR_(UNKNOWN_ATTRIBUTE, "Unknown attribute"), \
OPT_ERR_(UNKNOWN_COLOR, "Unknown color"), \
}
}
+static enum option_code
+parse_args(const char ***args, const char *argv[])
+{
+ if (!argv_copy(args, argv))
+ return OPT_ERR_OUT_OF_MEMORY;
+ return OPT_OK;
+}
+
/* Wants: name = value */
static enum option_code
option_set_command(int argc, const char *argv[])
{
+ if (argc < 3)
+ return OPT_ERR_WRONG_NUMBER_OF_ARGUMENTS;
+
+ if (!opt_blame_argv && !strcmp(argv[0], "blame-options"))
+ return parse_args(&opt_blame_argv, argv + 2);
+
if (argc != 3)
return OPT_ERR_WRONG_NUMBER_OF_ARGUMENTS;
@@ -2383,6 +2399,11 @@ format_argv(const char ***dst_argv, const char *src_argv[], bool replace, bool f
break;
continue;
+ } else if (!strcmp(arg, "%(blameargs)")) {
+ if (!argv_append_array(dst_argv, opt_blame_argv))
+ break;
+ continue;
+
} else if (!strcmp(arg, "%(revargs)") ||
(first && !strcmp(arg, "%(commit)"))) {
if (!argv_append_array(dst_argv, opt_rev_argv))
{
if (!line) {
const char *blame_argv[] = {
- "git", "blame", "--incremental",
+ "git", "blame", "%(blameargs)", "--incremental",
*opt_ref ? opt_ref : "--incremental", "--", opt_file, NULL
};
"\n"
"Usage: tig [options] [revs] [--] [paths]\n"
" or: tig show [options] [revs] [--] [paths]\n"
-" or: tig blame [rev] path\n"
+" or: tig blame [options] [rev] [--] path\n"
" or: tig status\n"
" or: tig < [git command output]\n"
"\n"
return REQ_VIEW_STATUS;
} else if (!strcmp(subcommand, "blame")) {
- if (argc <= 2 || argc > 4)
+ filter_rev_parse(&opt_file_argv, "--no-revs", "--no-flags", argv + 2);
+ filter_rev_parse(&opt_blame_argv, "--no-revs", "--flags", argv + 2);
+ filter_rev_parse(&opt_rev_argv, "--symbolic", "--revs-only", argv + 2);
+
+ if (!opt_file_argv || opt_file_argv[1] || (opt_rev_argv && opt_rev_argv[1]))
die("invalid number of options to blame\n\n%s", usage);
- i = 2;
- if (argc == 4) {
- string_ncopy(opt_ref, argv[i], strlen(argv[i]));
- i++;
+ if (opt_rev_argv) {
+ string_ncopy(opt_ref, opt_rev_argv[0], strlen(opt_rev_argv[0]));
}
- string_ncopy(opt_file, argv[i], strlen(argv[i]));
+ string_ncopy(opt_file, opt_file_argv[0], strlen(opt_file_argv[0]));
return REQ_VIEW_BLAME;
} else if (!strcmp(subcommand, "show")) {
diff --git a/tigrc.5.txt b/tigrc.5.txt
index 649a47ae7d04a495c523c5ee32028d054f2a1c8c..1464492c17fc4ca293f09811c7e387ea99b1ad04 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
set line-number-interval = 5 # Interval between line numbers
set commit-encoding = "UTF-8" # Commit encoding
set horizontal-scroll = 33% # Scroll 33% of the view width
+set blame-options = -C -C -C # Blame lines from other files
--------------------------------------------------------------------------
Or in the git configuration files:
Width of the author column. When set to 5 or below, the author name
will be abbreviated to the author's initials.
+'blame-options' (string)::
+
+ A space separated string of extra blame options. Can be used for
+ telling git-blame(1) how to detect the origin of lines. The value
+ is ignored when tig is started in blame mode and given blame options
+ on the command line.
+
'commit-encoding' (string)::
The encoding used for commits. The default is UTF-8. Note this option