Skip to content

Commit 728c573

Browse files
committed
Merge branch 'ex/deprecate-empty-pathspec-as-match-all'
The final step to make an empty string as a pathspec element illegal. We started this by first deprecating and warning a pathspec that has such an element in 2.11 (Nov 2016). Hopefully we can merge this down to the 'master' by the end of the year? A deprecation warning period that is about 1 year does not sound too bad. * ex/deprecate-empty-pathspec-as-match-all: pathspec: die on empty strings as pathspec t0027: do not use an empty string as a pathspec element
2 parents e4db47e + 9e4e8a6 commit 728c573

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

pathspec.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ void parse_pathspec(struct pathspec *pathspec,
532532
{
533533
struct pathspec_item *item;
534534
const char *entry = argv ? *argv : NULL;
535-
int i, n, prefixlen, warn_empty_string, nr_exclude = 0;
535+
int i, n, prefixlen, nr_exclude = 0;
536536

537537
memset(pathspec, 0, sizeof(*pathspec));
538538

@@ -565,13 +565,10 @@ void parse_pathspec(struct pathspec *pathspec,
565565
}
566566

567567
n = 0;
568-
warn_empty_string = 1;
569568
while (argv[n]) {
570-
if (*argv[n] == '\0' && warn_empty_string) {
571-
warning(_("empty strings as pathspecs will be made invalid in upcoming releases. "
572-
"please use . instead if you meant to match all paths"));
573-
warn_empty_string = 0;
574-
}
569+
if (*argv[n] == '\0')
570+
die("empty string is not a valid pathspec. "
571+
"please use . instead if you meant to match all paths");
575572
n++;
576573
}
577574

t/t0027-auto-crlf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ test_expect_success 'setup master' '
315315
echo >.gitattributes &&
316316
git checkout -b master &&
317317
git add .gitattributes &&
318-
git commit -m "add .gitattributes" "" &&
318+
git commit -m "add .gitattributes" . &&
319319
printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\nLINETHREE" >LF &&
320320
printf "\$Id: 0000000000000000000000000000000000000000 \$\r\nLINEONE\r\nLINETWO\r\nLINETHREE" >CRLF &&
321321
printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\r\nLINETWO\nLINETHREE" >CRLF_mix_LF &&

t/t3600-rm.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,8 @@ test_expect_success 'rm files with two different errors' '
858858
test_i18ncmp expect actual
859859
'
860860

861-
test_expect_success 'rm empty string should invoke warning' '
862-
git rm -rf "" 2>output &&
863-
test_i18ngrep "warning: empty strings" output
861+
test_expect_success 'rm empty string should fail' '
862+
test_must_fail git rm -rf ""
864863
'
865864

866865
test_done

t/t3700-add.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,8 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
331331
test_i18ncmp expect.err actual.err
332332
'
333333

334-
test_expect_success 'git add empty string should invoke warning' '
335-
git add "" 2>output &&
336-
test_i18ngrep "warning: empty strings" output
334+
test_expect_success 'git add empty string should fail' '
335+
test_must_fail git add ""
337336
'
338337

339338
test_expect_success 'git add --chmod=[+-]x stages correctly' '

0 commit comments

Comments
 (0)