summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 62c7d1a)
raw | patch | inline | side by side (parent: 62c7d1a)
author | Dominik Vogt <dvogt@ffm.tc.iot.dtag.de> | |
Thu, 27 Dec 2007 10:11:28 +0000 (11:11 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 16 Mar 2008 21:18:07 +0000 (22:18 +0100) |
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>
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>
Makefile | patch | blob | history | |
config.make.in | patch | blob | history | |
manual.txt | patch | blob | history | |
tig.1.txt | patch | blob | history | |
tig.c | patch | blob | history |
diff --git a/Makefile b/Makefile
index 6cc4e424e6ef84a3e4c716a25be18cb6db6d86a8..c2d6b608ef376c77c1ca5da112bf0b466df76e53 100644 (file)
--- a/Makefile
+++ b/Makefile
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
diff --git a/config.make.in b/config.make.in
index 3af2ea941390118c54255b6fd104208461840dcb..3962050d2bc906b09dd732975a91a4a38b8e4a70 100644 (file)
--- a/config.make.in
+++ b/config.make.in
mandir = @mandir@
docdir = @docdir@
datarootdir = @datarootdir@
+sysconfdir = @sysconfdir@
CC = @CC@
CFLAGS = @CFLAGS@
diff --git a/manual.txt b/manual.txt
index 1bafd1b05ccf1e1ec60cde48334134da7df272dc..efdb0799fa800ccc27204f4b816c749856cf7ae9 100644 (file)
--- a/manual.txt
+++ b/manual.txt
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
~~~~~~~~~~~~~~~~~~~~~
diff --git a/tig.1.txt b/tig.1.txt
index 30508ea50a6973e70b6b628bc3262f69fdab3f7c..7b1c779ebfc2becea792ca0772d51509edd5ce98 100644 (file)
--- a/tig.1.txt
+++ b/tig.1.txt
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).
index c6146909a5bbf306cf93612b41b244762237cafd..c44409e8c85bd88bcda3522ea0c618a71d5878e0 100644 (file)
--- a/tig.c
+++ b/tig.c
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;
}