@matheusbsbs / matheus-bagliano / commits / b57321f57b
Fork 0

git-clean: honor core.excludesfile

git-clean did not honor core.excludesfile configuration variable, although some other commands such as git-add and git-status did. Fix this inconsistency. Original report and patch from Shun'ichi Fuji. Rewritten by me and bugs and tests are mine. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Nov 14, 2007 at 01:54 UTC b57321f57b324320bdcf9f453ec4788da166f8f4
2 files changed +19 -1
git-clean.sh
+8 -1
@@ -75,15 +75,22 @@ esac
75
76 if [ -z "$ignored" ]; then
77 excl="--exclude-per-directory=.gitignore"
78 + excl_info= excludes_file=
79 if [ -f "$GIT_DIR/info/exclude" ]; then
80 excl_info="--exclude-from=$GIT_DIR/info/exclude"
81 fi
82 + if cfg_excl=$(git config core.excludesfile) && test -f "$cfg_excl"
83 + then
84 + excludes_file="--exclude-from=$cfg_excl"
85 + fi
86 if [ "$ignoredonly" ]; then
87 excl="$excl --ignored"
88 fi
89 fi
90
86 -git ls-files --others --directory $excl ${excl_info:+"$excl_info"} -- "$@" |
91 +git ls-files --others --directory \
92 + $excl ${excl_info:+"$excl_info"} ${excludes_file:+"$excludes_file"} \
93 + -- "$@" |
94 while read -r file; do
95 if [ -d "$file" -a ! -L "$file" ]; then
96 if [ -z "$cleandir" ]; then
t/t7300-clean.sh
+11
@@ -177,4 +177,15 @@ test_expect_success 'clean.requireForce and -f' '
177
178 '
179
180 +test_expect_success 'core.excludesfile' '
181 +
182 + echo excludes >excludes &&
183 + echo included >included &&
184 + git config core.excludesfile excludes &&
185 + output=$(git clean -n excludes included 2>&1) &&
186 + expr "$output" : ".*included" >/dev/null &&
187 + ! expr "$output" : ".*excludes" >/dev/null
188 +
189 +'
190 +
191 test_done