Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit ef94636

Browse files
committed
Merge branch 'as/check-ignore'
"git check-ignore ." segfaulted, as a function it calls deep in its callchain took a string in the <ptr, length> form but did not stop when given an empty string. * as/check-ignore: name-hash: allow hashing an empty string t0008: document test_expect_success_multi
2 parents a2b109f + c19387e commit ef94636

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

builtin/check-ignore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static int check_ignore(const char *prefix, const char **pathspec)
8989
? strlen(prefix) : 0, path);
9090
full_path = check_path_for_gitlink(full_path);
9191
die_if_path_beyond_symlink(full_path, prefix);
92-
if (!seen[i] && path[0]) {
92+
if (!seen[i]) {
9393
exclude = last_exclude_matching_path(&check, full_path,
9494
-1, &dtype);
9595
if (exclude) {

name-hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ static unsigned int hash_name(const char *name, int namelen)
2424
{
2525
unsigned int hash = 0x123;
2626

27-
do {
27+
while (namelen--) {
2828
unsigned char c = *name++;
2929
c = icase_hash(c);
3030
hash = hash*101 + c;
31-
} while (--namelen);
31+
}
3232
return hash;
3333
}
3434

t/t0008-ignores.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ test_check_ignore () {
7575
stderr_empty_on_success "$expect_code"
7676
}
7777

78+
# Runs the same code with 3 different levels of output verbosity,
79+
# expecting success each time. Takes advantage of the fact that
80+
# check-ignore --verbose output is the same as normal output except
81+
# for the extra first column.
82+
#
83+
# Arguments:
84+
# - (optional) prereqs for this test, e.g. 'SYMLINKS'
85+
# - test name
86+
# - output to expect from -v / --verbose mode
87+
# - code to run (should invoke test_check_ignore)
7888
test_expect_success_multi () {
7989
prereq=
8090
if test $# -eq 4
@@ -128,6 +138,7 @@ test_expect_success 'setup' '
128138
cat <<-\EOF >.gitignore &&
129139
one
130140
ignored-*
141+
top-level-dir/
131142
EOF
132143
for dir in . a
133144
do
@@ -167,6 +178,10 @@ test_expect_success 'setup' '
167178
#
168179
# test invalid inputs
169180

181+
test_expect_success_multi '. corner-case' '' '
182+
test_check_ignore . 1
183+
'
184+
170185
test_expect_success_multi 'empty command line' '' '
171186
test_check_ignore "" 128 &&
172187
stderr_contains "fatal: no path specified"

0 commit comments

Comments
 (0)