]> git.ipfire.org Git - thirdparty/git.git/commitdiff
read-cache: let verify_path() reject trailing dir separators again
authorRené Scharfe <l.s.r@web.de>
Thu, 7 Oct 2021 20:31:58 +0000 (22:31 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Oct 2021 00:52:26 +0000 (17:52 -0700)
6e773527b6 (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 <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c
t/t3905-stash-include-untracked.sh

index c823580fb0799b51a55644ac37227d4c3fbb8452..42d804f9623f0a86322df2b21cd8c976bfb4f985 100644 (file)
@@ -854,7 +854,7 @@ static enum verify_path_result verify_path_internal(const char *, unsigned);
 
 int verify_path(const char *path, unsigned mode)
 {
-       return verify_path_internal(path, mode) != PATH_INVALID;
+       return verify_path_internal(path, mode) == PATH_OK;
 }
 
 struct cache_entry *make_cache_entry(struct index_state *istate,
@@ -867,7 +867,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,
        struct cache_entry *ce, *ret;
        int len;
 
-       if (!verify_path(path, mode)) {
+       if (verify_path_internal(path, mode) == PATH_INVALID) {
                error(_("invalid path '%s'"), path);
                return NULL;
        }
@@ -1356,7 +1356,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
 
        if (!ok_to_add)
                return -1;
-       if (!verify_path(ce->name, ce->ce_mode))
+       if (verify_path_internal(ce->name, ce->ce_mode) == PATH_INVALID)
                return error(_("invalid path '%s'"), ce->name);
 
        if (!skip_df_check &&
index f213c7327e06f35617fe2762930332cd9f2d59bf..c59bcffabbba2690ba81bcec31e7b3c38a978cb5 100755 (executable)
@@ -405,7 +405,7 @@ test_expect_success 'stash show --include-untracked errors on duplicate files' '
        test_i18ngrep "worktree and untracked commit have duplicate entries: tracked" err
 '
 
-test_expect_failure 'stash -u ignores sub-repository' '
+test_expect_success 'stash -u ignores sub-repository' '
        test_when_finished "rm -rf sub-repo" &&
        git init sub-repo &&
        git stash -u