remove pointless cwd checking from got_repo_map_path()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
diff --git a/lib/repository.c b/lib/repository.c
index 694024d..158483e 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -657,15 +657,11 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
{
const struct got_error *err = NULL;
const char *repo_abspath = NULL;
- size_t repolen, cwdlen, len;
- char *cwd, *canonpath, *path = NULL;
+ size_t repolen, len;
+ char *canonpath, *path = NULL;
*in_repo_path = NULL;
- cwd = getcwd(NULL, 0);
- if (cwd == NULL)
- return got_error_from_errno("getcwd");
-
canonpath = strdup(input_path);
if (canonpath == NULL) {
err = got_error_from_errno("strdup");
@@ -684,7 +680,7 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
goto done;
}
} else {
- int is_repo_child = 0, is_cwd_child = 0;
+ int is_repo_child = 0;
path = realpath(canonpath, NULL);
if (path == NULL) {
@@ -705,13 +701,10 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
}
repolen = strlen(repo_abspath);
- cwdlen = strlen(cwd);
len = strlen(path);
if (len > repolen && strncmp(path, repo_abspath, repolen) == 0)
is_repo_child = 1;
- if (len > cwdlen && strncmp(path, cwd, cwdlen) == 0)
- is_cwd_child = 1;
if (strcmp(path, repo_abspath) == 0) {
free(path);
@@ -720,15 +713,6 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
err = got_error_from_errno("strdup");
goto done;
}
- } else if (is_repo_child && is_cwd_child) {
- char *child;
- /* Strip common prefix with repository path. */
- err = got_path_skip_common_ancestor(&child,
- repo_abspath, path);
- if (err)
- goto done;
- free(path);
- path = child;
} else if (is_repo_child) {
/* Matched an on-disk path inside repository. */
if (got_repo_is_bare(repo)) {
@@ -746,15 +730,6 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
free(path);
path = child;
}
- } else if (is_cwd_child) {
- char *child;
- /* Strip common prefix with cwd. */
- err = got_path_skip_common_ancestor(&child, cwd,
- path);
- if (err)
- goto done;
- free(path);
- path = child;
} else {
/*
* Matched unrelated on-disk path.
@@ -775,7 +750,6 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
}
done:
- free(cwd);
free(canonpath);
if (err)
free(path);