summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b1fc02d)
raw | patch | inline | side by side (parent: b1fc02d)
author | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 9 Feb 2009 00:55:40 +0000 (01:55 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 9 Feb 2009 01:11:07 +0000 (02:11 +0100) |
If this option is found set up GIT_DIR and GIT_WORK_TREE. Also, pass
the known git directory path to git ls-remote.
Requested-by: bill lam
the known git directory path to git ls-remote.
Requested-by: bill lam
NEWS | patch | blob | history | |
tig.c | patch | blob | history |
index d96ef779289ec1e7ed02a389c5a2a833d8fc5be6..ea3296c79b29f8bb5ba34146811a1422aac3f674 100644 (file)
--- a/NEWS
+++ b/NEWS
code in git's bash completion script.
- Colors for 256-capable terminals can be specified as colorN.
- Entering a number in the prompt will jump to that line number.
+ - Handle core.worktree by setting GIT_DIR and GIT_WORK_TREE.
Bug fixes:
index 9537208ccb62199aa6ee4fe20b0aefec498ca3b1..613a734fb71519ffa991e74097e65fc29c55893a 100644 (file)
--- a/tig.c
+++ b/tig.c
load_refs(void)
{
static const char *ls_remote_argv[SIZEOF_ARG] = {
- "git", "ls-remote", ".", NULL
+ "git", "ls-remote", opt_git_dir, NULL
};
static bool init = FALSE;
@@ -6710,6 +6710,30 @@ set_repo_config_option(char *name, char *value, int (*cmd)(int, const char **))
warn("Option 'tig.%s': %s", name, config_msg);
}
+static void
+set_work_tree(const char *value)
+{
+ char cwd[SIZEOF_STR];
+
+ if (!getcwd(cwd, sizeof(cwd)))
+ die("Failed to get cwd path: %s", strerror(errno));
+ if (chdir(opt_git_dir) < 0)
+ die("Failed to chdir(%s): %s", strerror(errno));
+ if (!getcwd(opt_git_dir, sizeof(opt_git_dir)))
+ die("Failed to get git path: %s", strerror(errno));
+ if (chdir(cwd) < 0)
+ die("Failed to chdir(%s): %s", cwd, strerror(errno));
+ if (chdir(value) < 0)
+ die("Failed to chdir(%s): %s", value, strerror(errno));
+ if (!getcwd(cwd, sizeof(cwd)))
+ die("Failed to get cwd path: %s", strerror(errno));
+ if (setenv("GIT_WORK_TREE", cwd, TRUE) < 0)
+ die("Failed to set GIT_WORK_TREE to '%s'", cwd);
+ if (setenv("GIT_DIR", opt_git_dir, TRUE) < 0)
+ die("Failed to set GIT_DIR to '%s'", opt_git_dir);
+ opt_is_inside_work_tree = TRUE;
+}
+
static int
read_repo_config_option(char *name, size_t namelen, char *value, size_t valuelen)
{
@@ -6719,6 +6743,9 @@ read_repo_config_option(char *name, size_t namelen, char *value, size_t valuelen
else if (!strcmp(name, "core.editor"))
string_ncopy(opt_editor, value, valuelen);
+ else if (!strcmp(name, "core.worktree"))
+ set_work_tree(value);
+
else if (!prefixcmp(name, "tig.color."))
set_repo_config_option(name + 10, value, option_color_command);