Skip to content

Commit

Permalink
Merge pull request #1354 from dscho/phase-out-show-ignored-directory-…
Browse files Browse the repository at this point in the history
…gracefully

Phase out `--show-ignored-directory` gracefully
  • Loading branch information
dscho committed Oct 12, 2018
2 parents 3fc0ecc + e74d1fb commit 681e1d5
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 0 deletions.
11 changes: 11 additions & 0 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
static int no_renames = -1;
static const char *rename_score_arg = (const char *)-1;
static int no_lock_index = 0;
static int show_ignored_directory = 0;
static struct wt_status s;
int fd;
struct object_id oid;
Expand Down Expand Up @@ -1332,6 +1333,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)
{ OPTION_CALLBACK, 'M', "find-renames", &rename_score_arg,
N_("n"), N_("detect renames, optionally set similarity index"),
PARSE_OPT_OPTARG, opt_parse_rename_score },
OPT_BOOL(0, "show-ignored-directory", &show_ignored_directory,
N_("(DEPRECATED: use --ignore=matching instead) Only "
"show directories that match an ignore pattern "
"name.")),
OPT_BOOL(0, "no-lock-index", &no_lock_index,
N_("(DEPRECATED: use `git --no-optional-locks status` "
"instead) Do not lock the index")),
Expand All @@ -1354,6 +1359,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)
setenv(GIT_OPTIONAL_LOCKS_ENVIRONMENT, "false", 1);
}

if (show_ignored_directory) {
warning("--show-ignored-directory was deprecated, use "
"--ignored=matching instead");
ignored_arg = "matching";
}

handle_untracked_files_arg(&s);
handle_ignored_arg(&s);

Expand Down
151 changes: 151 additions & 0 deletions t/t7522-status-show-ignored-directory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/bin/sh
#
#

test_description='git status collapse ignored'

. ./test-lib.sh


cat >.gitignore <<\EOF
*.ign
ignored_dir/
!*.unignore
EOF

# commit initial ignore file
test_expect_success 'setup initial commit and ignore file' '
git add . &&
test_tick &&
git commit -m "Initial commit"
'

cat >expect <<\EOF
? err
? expect
? output
! dir/ignored/ignored_1.ign
! dir/ignored/ignored_2.ign
! ignored/ignored_1.ign
! ignored/ignored_2.ign
EOF

# Test status behavior on folder with ignored files
test_expect_success 'setup folder with ignored files' '
mkdir -p ignored dir/ignored &&
touch ignored/ignored_1.ign ignored/ignored_2.ign \
dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign
'

test_expect_success 'Verify behavior of status on folders with ignored files' '
test_when_finished "git clean -fdx" &&
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output 2>err &&
test_i18ncmp expect output &&
grep "deprecated.*use --ignored=matching instead" err
'

# Test status bahavior on folder with tracked and ignored files
cat >expect <<\EOF
? expect
? output
! dir/tracked_ignored/ignored_1.ign
! dir/tracked_ignored/ignored_2.ign
! tracked_ignored/ignored_1.ign
! tracked_ignored/ignored_2.ign
EOF

test_expect_success 'setup folder with tracked & ignored files' '
mkdir -p tracked_ignored dir/tracked_ignored &&
touch tracked_ignored/tracked_1 tracked_ignored/tracked_2 \
tracked_ignored/ignored_1.ign tracked_ignored/ignored_2.ign \
dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 \
dir/tracked_ignored/ignored_1.ign dir/tracked_ignored/ignored_2.ign &&
git add tracked_ignored/tracked_1 tracked_ignored/tracked_2 \
dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 &&
test_tick &&
git commit -m "commit tracked files"
'

test_expect_success 'Verify status on folder with tracked & ignored files' '
test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output &&
test_i18ncmp expect output
'


# Test status behavior on folder with untracked and ignored files
cat >expect <<\EOF
? dir/untracked_ignored/untracked_1
? dir/untracked_ignored/untracked_2
? expect
? output
? untracked_ignored/untracked_1
? untracked_ignored/untracked_2
! dir/untracked_ignored/ignored_1.ign
! dir/untracked_ignored/ignored_2.ign
! untracked_ignored/ignored_1.ign
! untracked_ignored/ignored_2.ign
EOF

test_expect_success 'setup folder with tracked & ignored files' '
mkdir -p untracked_ignored dir/untracked_ignored &&
touch untracked_ignored/untracked_1 untracked_ignored/untracked_2 \
untracked_ignored/ignored_1.ign untracked_ignored/ignored_2.ign \
dir/untracked_ignored/untracked_1 dir/untracked_ignored/untracked_2 \
dir/untracked_ignored/ignored_1.ign dir/untracked_ignored/ignored_2.ign
'

test_expect_success 'Verify status on folder with tracked & ignored files' '
test_when_finished "git clean -fdx" &&
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output &&
test_i18ncmp expect output
'

# Test status behavior on ignored folder
cat >expect <<\EOF
? expect
? output
! ignored_dir/
EOF

test_expect_success 'setup folder with tracked & ignored files' '
mkdir ignored_dir &&
touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign
'

test_expect_success 'Verify status on folder with tracked & ignored files' '
test_when_finished "git clean -fdx" &&
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output &&
test_i18ncmp expect output
'

# Test status behavior on ignored folder with tracked file
cat >expect <<\EOF
? expect
? output
! ignored_dir/ignored_1
! ignored_dir/ignored_1.ign
! ignored_dir/ignored_2
! ignored_dir/ignored_2.ign
EOF

test_expect_success 'setup folder with tracked & ignored files' '
mkdir ignored_dir &&
touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign \
ignored_dir/tracked &&
git add -f ignored_dir/tracked &&
test_tick &&
git commit -m "Force add file in ignored directory"
'

test_expect_success 'Verify status on folder with tracked & ignored files' '
test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output &&
test_i18ncmp expect output
'

test_done

0 comments on commit 681e1d5

Please sign in to comment.