summaryrefslogtreecommitdiff
path: root/builtin/stripspace.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2018-12-17 16:59:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-12-26 23:41:47 (GMT)
commit957da7580255f30ce8f1224531e795a9bace3d52 (patch)
treee4762cdf76e36222cafafe15470216f8e0172b95 /builtin/stripspace.c
parent0d0ac3826a3bbb9247e39e12623bbcfdd722f24c (diff)
downloadgit-957da7580255f30ce8f1224531e795a9bace3d52.zip
git-957da7580255f30ce8f1224531e795a9bace3d52.tar.gz
git-957da7580255f30ce8f1224531e795a9bace3d52.tar.bz2
stripspace: allow -s/-c outside git repository
v2.11.0-rc3~3^2~1 (stripspace: respect repository config, 2016-11-21) improved stripspace --strip-comments / --comentlines by teaching them to read repository config, but it went a little too far: when running stripspace outside any repository, the result is $ git stripspace --strip-comments <test-input fatal: not a git repository (or any parent up to mount point /tmp) That makes experimenting with the stripspace command unnecessarily fussy. Fix it by discovering the git directory gently, as intended all along. Reported-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/stripspace.c')
-rw-r--r--builtin/stripspace.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/stripspace.c b/builtin/stripspace.c
index bdf0328..be33eb8 100644
--- a/builtin/stripspace.c
+++ b/builtin/stripspace.c
@@ -30,6 +30,7 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
{
struct strbuf buf = STRBUF_INIT;
enum stripspace_mode mode = STRIP_DEFAULT;
+ int nongit;
const struct option options[] = {
OPT_CMDMODE('s', "strip-comments", &mode,
@@ -46,7 +47,7 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
usage_with_options(stripspace_usage, options);
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
- setup_git_directory_gently(NULL);
+ setup_git_directory_gently(&nongit);
git_config(git_default_config, NULL);
}