summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
62c7d1a)
Introduced envvars TIGRC_USER and TIGRC_SYSTEM to control which config
file is used. The default user specific config file can be overridden
with TIGRC_USER. Before loading the user config file, tig now looks for
a system wide config file ($(sysconfdir)/tirgc by default). This can be
overridden with the environment variable TIGRC_SYSTEM.
Also corrected a small mistake in the Makefile. Instead of setting
CFLAGS for '-D...' compiler options, use CPPFLAGS.
[ The original code from Dominik was changed so that tig always reads
the system-wide configuration file. The documentation was improved
so the configured sysconfdir is used in the generated documentation.
-- jonas ]
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
prefix ?= $(HOME)
bindir ?= $(prefix)/bin
datarootdir ?= $(prefix)/share
prefix ?= $(HOME)
bindir ?= $(prefix)/bin
datarootdir ?= $(prefix)/share
+sysconfdir ?= $(prefix)/etc
docdir ?= $(datarootdir)/doc
mandir ?= $(datarootdir)/man
# DESTDIR=
docdir ?= $(datarootdir)/doc
mandir ?= $(datarootdir)/man
# DESTDIR=
TARNAME = tig-$(RPM_VERSION)
endif
TARNAME = tig-$(RPM_VERSION)
endif
-override CFLAGS += '-DTIG_VERSION="$(VERSION)"'
+override CPPFLAGS += '-DTIG_VERSION="$(VERSION)"'
+override CPPFLAGS += '-DSYSCONFDIR="$(sysconfdir)"'
AUTORECONF ?= autoreconf
ASCIIDOC ?= asciidoc
AUTORECONF ?= autoreconf
ASCIIDOC ?= asciidoc
-ASCIIDOC_FLAGS = -aversion=$(VERSION)
+ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir)
XMLTO ?= xmlto
DOCBOOK2PDF ?= docbook2pdf
XMLTO ?= xmlto
DOCBOOK2PDF ?= docbook2pdf
mandir = @mandir@
docdir = @docdir@
datarootdir = @datarootdir@
mandir = @mandir@
docdir = @docdir@
datarootdir = @datarootdir@
+sysconfdir = @sysconfdir@
CC = @CC@
CFLAGS = @CFLAGS@
CC = @CC@
CFLAGS = @CFLAGS@
Several options related to the interface with git can be configured via
environment options.
Several options related to the interface with git can be configured via
environment options.
+[[configuration-files]]
+Configuration Files
+~~~~~~~~~~~~~~~~~~~
+
+Upon startup, tig first reads the system wide configuration file
+(`{sysconfdir}/tigrc` by default) and then proceeds to read the user's
+configuration file (`~/.tigrc` by default). The paths to either of these files
+can be overridden through the following environment variables:
+
+TIGRC_USER::
+ Path of the user configuration file.
+
+TIGRC_SYSTEM::
+ Path of the system wide configuration file.
+
[[repo-refs]]
Repository References
~~~~~~~~~~~~~~~~~~~~~
[[repo-refs]]
Repository References
~~~~~~~~~~~~~~~~~~~~~
In addition to environment variables used by git (e.g. GIT_DIR), tig defines
the following:
In addition to environment variables used by git (e.g. GIT_DIR), tig defines
the following:
+TIGRC_USER::
+ Path of the user configuration file (defaults to `~/.tigrc`).
+
+TIGRC_SYSTEM::
+ Path of the system wide configuration file (defaults to
+ `{sysconfdir}/tigrc`).
+
TIG_LS_REMOTE::
Set command for retrieving all repository references. The command
should output data in the same format as git-ls-remote(1).
TIG_LS_REMOTE::
Set command for retrieving all repository references. The command
should output data in the same format as git-ls-remote(1).
'~/.tigrc'::
User configuration file. See gitlink:tigrc[5] for examples.
'~/.tigrc'::
User configuration file. See gitlink:tigrc[5] for examples.
+'{sysconfdir}/tigrc'::
+ System wide configuration file.
+
'$GIT_DIR/config'::
Repository config file. Read on start-up with the help of
git-config(1).
'$GIT_DIR/config'::
Repository config file. Read on start-up with the help of
git-config(1).
-static int
-load_options(void)
+static void
+load_option_file(const char *path)
- char *home = getenv("HOME");
- char buf[SIZEOF_STR];
+ /* It's ok that the file doesn't exist. */
+ file = fopen(path, "r");
+ if (!file)
+ return;
+
config_lineno = 0;
config_errors = FALSE;
config_lineno = 0;
config_errors = FALSE;
- add_builtin_run_requests();
+ if (read_properties(file, " \t", read_option) == ERR ||
+ config_errors == TRUE)
+ fprintf(stderr, "Errors while loading %s.\n", path);
+}
- if (!home || !string_format(buf, "%s/.tigrc", home))
- return ERR;
+static int
+load_options(void)
+{
+ char *home = getenv("HOME");
+ char *tigrc_user = getenv("TIGRC_USER");
+ char *tigrc_system = getenv("TIGRC_SYSTEM");
+ char buf[SIZEOF_STR];
- /* It's ok that the file doesn't exist. */
- file = fopen(buf, "r");
- if (!file)
- return OK;
+ add_builtin_run_requests();
- if (read_properties(file, " \t", read_option) == ERR ||
- config_errors == TRUE)
- fprintf(stderr, "Errors while loading %s.\n", buf);
+ if (!tigrc_system) {
+ if (!string_format(buf, "%s/tigrc", SYSCONFDIR))
+ return ERR;
+ tigrc_system = buf;
+ }
+ load_option_file(tigrc_system);
+
+ if (!tigrc_user) {
+ if (!home || !string_format(buf, "%s/.tigrc", home))
+ return ERR;
+ tigrc_user = buf;
+ }
+ load_option_file(tigrc_user);