prefix ?= $(HOME)
bindir ?= $(prefix)/bin
datarootdir ?= $(prefix)/share
+sysconfdir ?= $(prefix)/etc
docdir ?= $(datarootdir)/doc
mandir ?= $(datarootdir)/man
# DESTDIR=
TARNAME = tig-$(RPM_VERSION)
endif
-override CFLAGS += '-DTIG_VERSION="$(VERSION)"'
+override CPPFLAGS += '-DTIG_VERSION="$(VERSION)"'
+override CPPFLAGS += '-DSYSCONFDIR="$(sysconfdir)"'
AUTORECONF ?= autoreconf
ASCIIDOC ?= asciidoc
-ASCIIDOC_FLAGS = -aversion=$(VERSION)
+ASCIIDOC_FLAGS = -aversion=$(VERSION) -asysconfdir=$(sysconfdir)
XMLTO ?= xmlto
DOCBOOK2PDF ?= docbook2pdf
mandir = @mandir@
docdir = @docdir@
datarootdir = @datarootdir@
+sysconfdir = @sysconfdir@
CC = @CC@
CFLAGS = @CFLAGS@
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
~~~~~~~~~~~~~~~~~~~~~
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).
'~/.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).
return OK;
}
-static int
-load_options(void)
+static void
+load_option_file(const char *path)
{
- char *home = getenv("HOME");
- char buf[SIZEOF_STR];
FILE *file;
+ /* It's ok that the file doesn't exist. */
+ file = fopen(path, "r");
+ if (!file)
+ return;
+
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);
return OK;
}