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
This commit is contained in:
commit
ec27a94013
@ -30,6 +30,7 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
|
|||||||
{
|
{
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
enum stripspace_mode mode = STRIP_DEFAULT;
|
enum stripspace_mode mode = STRIP_DEFAULT;
|
||||||
|
int nongit;
|
||||||
|
|
||||||
const struct option options[] = {
|
const struct option options[] = {
|
||||||
OPT_CMDMODE('s', "strip-comments", &mode,
|
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);
|
usage_with_options(stripspace_usage, options);
|
||||||
|
|
||||||
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
|
if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
|
||||||
setup_git_directory_gently(NULL);
|
setup_git_directory_gently(&nongit);
|
||||||
git_config(git_default_config, NULL);
|
git_config(git_default_config, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,9 +430,15 @@ test_expect_success '-c with changed comment char' '
|
|||||||
test_expect_success '-c with comment char defined in .git/config' '
|
test_expect_success '-c with comment char defined in .git/config' '
|
||||||
test_config core.commentchar = &&
|
test_config core.commentchar = &&
|
||||||
printf "= foo\n" >expect &&
|
printf "= foo\n" >expect &&
|
||||||
printf "foo" | (
|
rm -fr sub &&
|
||||||
mkdir sub && cd sub && git stripspace -c
|
mkdir sub &&
|
||||||
) >actual &&
|
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
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user