summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2017-02-05 21:23:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-02-06 18:13:48 (GMT)
commitd81345ce09c121fb0d18dec5c2535ec8d2a67542 (patch)
treedfd66a63db19d383530453f73f23b38d60fdf116 /builtin
parent94d3997ecc09f36d17b9ad4b49c4709885e300f7 (diff)
downloadgit-d81345ce09c121fb0d18dec5c2535ec8d2a67542.zip
git-d81345ce09c121fb0d18dec5c2535ec8d2a67542.tar.gz
git-d81345ce09c121fb0d18dec5c2535ec8d2a67542.tar.bz2
difftool: fix bug when printing usage
"git difftool -h" reports an error: fatal: BUG: setup_git_env called without repository Defer repository setup so that the help option processing happens before the repository is initialized. Add tests to ensure that the basic usage works inside and outside of a repository. Signed-off-by: David Aguilar <davvid@gmail.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/difftool.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/difftool.c b/builtin/difftool.c
index b5e85ab..d13350c 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -647,10 +647,6 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
OPT_END()
};
- /* NEEDSWORK: once we no longer spawn anything, remove this */
- setenv(GIT_DIR_ENVIRONMENT, absolute_path(get_git_dir()), 1);
- setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(get_git_work_tree()), 1);
-
git_config(difftool_config, NULL);
symlinks = has_symlinks;
@@ -661,6 +657,10 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
if (tool_help)
return print_tool_help();
+ /* NEEDSWORK: once we no longer spawn anything, remove this */
+ setenv(GIT_DIR_ENVIRONMENT, absolute_path(get_git_dir()), 1);
+ setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(get_git_work_tree()), 1);
+
if (use_gui_tool && diff_gui_tool && *diff_gui_tool)
setenv("GIT_DIFF_TOOL", diff_gui_tool, 1);
else if (difftool_cmd) {