Skip to content

Commit c8ad9d0

Browse files
rscharfegitster
authored andcommitted
read-cache: let verify_path() reject trailing dir separators again
6e77352 (sparse-index: convert from full to sparse, 2021-03-30) made verify_path() accept trailing directory separators for directories, which is necessary for sparse directory entries. This clemency causes "git stash" to stumble over sub-repositories, though, and there may be more unintended side-effects. Avoid them by restoring the old verify_path() behavior and accepting trailing directory separators only in places that are supposed to handle sparse directory entries. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2a1ae64 commit c8ad9d0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

read-cache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ static enum verify_path_result verify_path_internal(const char *, unsigned);
854854

855855
int verify_path(const char *path, unsigned mode)
856856
{
857-
return verify_path_internal(path, mode) != PATH_INVALID;
857+
return verify_path_internal(path, mode) == PATH_OK;
858858
}
859859

860860
struct cache_entry *make_cache_entry(struct index_state *istate,
@@ -867,7 +867,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,
867867
struct cache_entry *ce, *ret;
868868
int len;
869869

870-
if (!verify_path(path, mode)) {
870+
if (verify_path_internal(path, mode) == PATH_INVALID) {
871871
error(_("invalid path '%s'"), path);
872872
return NULL;
873873
}
@@ -1356,7 +1356,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
13561356

13571357
if (!ok_to_add)
13581358
return -1;
1359-
if (!verify_path(ce->name, ce->ce_mode))
1359+
if (verify_path_internal(ce->name, ce->ce_mode) == PATH_INVALID)
13601360
return error(_("invalid path '%s'"), ce->name);
13611361

13621362
if (!skip_df_check &&

t/t3905-stash-include-untracked.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ test_expect_success 'stash show --include-untracked errors on duplicate files' '
405405
test_i18ngrep "worktree and untracked commit have duplicate entries: tracked" err
406406
'
407407

408-
test_expect_failure 'stash -u ignores sub-repository' '
408+
test_expect_success 'stash -u ignores sub-repository' '
409409
test_when_finished "rm -rf sub-repo" &&
410410
git init sub-repo &&
411411
git stash -u

0 commit comments

Comments
 (0)