summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-01-18 21:49:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-18 21:49:53 (GMT)
commitec27a940134e940a68228401e54f89d610858a26 (patch)
tree20201a138630a1d06a78cc54d07c4443656d8af1
parent4744d03a47d668e0e2ea45a637fd16d782e035b9 (diff)
parent957da7580255f30ce8f1224531e795a9bace3d52 (diff)
downloadgit-ec27a940134e940a68228401e54f89d610858a26.zip
git-ec27a940134e940a68228401e54f89d610858a26.tar.gz
git-ec27a940134e940a68228401e54f89d610858a26.tar.bz2
Merge branch 'jn/stripspace-wo-repository'
"git stripspace" should be usable outside a git repository, but under the "-s" or "-c" mode, it didn't. * jn/stripspace-wo-repository: stripspace: allow -s/-c outside git repository
-rw-r--r--builtin/stripspace.c3
-rwxr-xr-xt/t0030-stripspace.sh12
2 files changed, 11 insertions, 4 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);
}
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
index 5ce47e8..0c24a0f 100755
--- a/t/t0030-stripspace.sh
+++ b/t/t0030-stripspace.sh
@@ -430,9 +430,15 @@ test_expect_success '-c with changed comment char' '
test_expect_success '-c with comment char defined in .git/config' '
test_config core.commentchar = &&
printf "= foo\n" >expect &&
- printf "foo" | (
- mkdir sub && cd sub && git stripspace -c
- ) >actual &&
+ rm -fr sub &&
+ mkdir sub &&
+ printf "foo" | git -C sub stripspace -c >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '-c outside git repository' '
+ printf "# foo\n" >expect &&
+ printf "foo" | nongit git stripspace -c >actual &&
test_cmp expect actual
'