aboutsummaryrefslogtreecommitdiffstats
path: root/subversion/libsvn_fs_fs/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/libsvn_fs_fs/tree.c')
-rw-r--r--subversion/libsvn_fs_fs/tree.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/subversion/libsvn_fs_fs/tree.c b/subversion/libsvn_fs_fs/tree.c
index 76209f368bf9..764052b3fa89 100644
--- a/subversion/libsvn_fs_fs/tree.c
+++ b/subversion/libsvn_fs_fs/tree.c
@@ -920,6 +920,25 @@ try_match_last_node(dag_node_t **node_p,
return SVN_NO_ERROR;
}
+/* Helper for open_path() that constructs and returns an appropriate
+ SVN_ERR_FS_NOT_DIRECTORY error. */
+static svn_error_t *
+err_not_directory(svn_fs_root_t *root,
+ const char *path,
+ apr_pool_t *scratch_pool)
+{
+ const char *msg;
+
+ msg = root->is_txn_root
+ ? apr_psprintf(scratch_pool,
+ _("Failure opening '%s' in transaction '%s'"),
+ path, root->txn)
+ : apr_psprintf(scratch_pool,
+ _("Failure opening '%s' in revision %ld"),
+ path, root->rev);
+
+ return svn_error_quick_wrap(SVN_FS__ERR_NOT_DIRECTORY(root->fs, path), msg);
+}
/* Open the node identified by PATH in ROOT, allocating in POOL. Set
*PARENT_PATH_P to a path from the node up to ROOT. The resulting
@@ -1016,12 +1035,26 @@ open_path(parent_path_t **parent_path_p,
SVN_ERR(dag_node_cache_get(&here, root, directory, pool));
/* Did the shortcut work? */
- if (here)
+ if (here && svn_fs_fs__dag_node_kind(here) == svn_node_dir)
{
apr_size_t dirname_len = strlen(directory);
path_so_far->len = dirname_len;
rest = path + dirname_len + 1;
}
+ else if (here)
+ {
+ /* The parent node is not a directory. We are looking for some
+ sub-path, so that sub-path will not exist. That will be o.k.
+ if we are just here to check for the path's existence, but
+ should result in an error otherwise. */
+ if (flags & open_path_allow_null)
+ {
+ *parent_path_p = NULL;
+ return SVN_NO_ERROR;
+ }
+ else
+ return svn_error_trace(err_not_directory(root, directory, pool));
+ }
}
}
@@ -1144,8 +1177,6 @@ open_path(parent_path_t **parent_path_p,
/* The path isn't finished yet; we'd better be in a directory. */
if (svn_fs_fs__dag_node_kind(child) != svn_node_dir)
{
- const char *msg;
-
/* Since this is not a directory and we are looking for some
sub-path, that sub-path will not exist. That will be o.k.,
if we are just here to check for the path's existence. */
@@ -1156,14 +1187,8 @@ open_path(parent_path_t **parent_path_p,
}
/* It's really a problem ... */
- msg = root->is_txn_root
- ? apr_psprintf(iterpool,
- _("Failure opening '%s' in transaction '%s'"),
- path, root->txn)
- : apr_psprintf(iterpool,
- _("Failure opening '%s' in revision %ld"),
- path, root->rev);
- SVN_ERR_W(SVN_FS__ERR_NOT_DIRECTORY(fs, path_so_far->data), msg);
+ return svn_error_trace(
+ err_not_directory(root, path_so_far->data, iterpool));
}
rest = next;
@@ -4619,7 +4644,7 @@ make_txn_root(svn_fs_root_t **root_p,
svn_fs_fs__dag_deserialize,
APR_HASH_KEY_STRING,
32, 20, FALSE,
- apr_pstrcat(pool, txn, ":TXN",
+ apr_pstrcat(pool, root->txn, ":TXN",
SVN_VA_NULL),
root->pool));