fix logging /sys in tog while /sys symlink exists on disk
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
diff --git a/got/got.c b/got/got.c
index 398bd39..d390e0e 100644
--- a/got/got.c
+++ b/got/got.c
@@ -551,7 +551,7 @@ cmd_log(int argc, char *argv[])
goto done;
}
- error = got_repo_map_path(&in_repo_path, repo, path);
+ error = got_repo_map_path(&in_repo_path, repo, path, 1);
if (error != NULL)
goto done;
if (in_repo_path) {
@@ -749,7 +749,7 @@ cmd_blame(int argc, char *argv[])
if (error != NULL)
goto done;
- error = got_repo_map_path(&in_repo_path, repo, path);
+ error = got_repo_map_path(&in_repo_path, repo, path, 1);
if (error != NULL)
goto done;
@@ -905,7 +905,7 @@ cmd_tree(int argc, char *argv[])
if (error != NULL)
goto done;
- error = got_repo_map_path(&in_repo_path, repo, path);
+ error = got_repo_map_path(&in_repo_path, repo, path, 1);
if (error != NULL)
goto done;
diff --git a/include/got_repository.h b/include/got_repository.h
index 2fd4ddd..37f50bb 100644
--- a/include/got_repository.h
+++ b/include/got_repository.h
@@ -45,4 +45,4 @@ int got_repo_is_bare(struct got_repository *);
/* Attempt to map an arbitrary path to a path within the repository. */
const struct got_error *got_repo_map_path(char **, struct got_repository *,
- const char *);
+ const char *, int);
diff --git a/lib/repository.c b/lib/repository.c
index d45495d..d82e38e 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -433,13 +433,13 @@ got_repo_close(struct got_repository *repo)
const struct got_error *
got_repo_map_path(char **in_repo_path, struct got_repository *repo,
- const char *input_path)
+ const char *input_path, int check_disk)
{
const struct got_error *err = NULL;
char *repo_abspath = NULL, *cwd = NULL;
struct stat sb;
size_t repolen, cwdlen, len;
- char *canonpath, *path;
+ char *canonpath, *path = NULL;
*in_repo_path = NULL;
@@ -464,7 +464,9 @@ got_repo_map_path(char **in_repo_path, struct got_repository *repo,
/* TODO: Call "get in-repository path of work-tree node" API. */
- if (lstat(canonpath, &sb) != 0) {
+ if (!check_disk)
+ path = strdup(canonpath);
+ else if (lstat(canonpath, &sb) != 0) {
if (errno != ENOENT) {
err = got_error_from_errno();
goto done;
diff --git a/tog/tog.c b/tog/tog.c
index 220eb8c..c90730d 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -270,7 +270,7 @@ static const struct got_error *input_diff_view(struct tog_view **,
static const struct got_error* close_diff_view(struct tog_view *);
static const struct got_error *open_log_view(struct tog_view *,
- struct got_object_id *, struct got_repository *, const char *);
+ struct got_object_id *, struct got_repository *, const char *, int);
static const struct got_error * show_log_view(struct tog_view *);
static const struct got_error *input_log_view(struct tog_view **,
struct tog_view **, struct tog_view **, struct tog_view *, int);
@@ -1360,7 +1360,7 @@ close_log_view(struct tog_view *view)
static const struct got_error *
open_log_view(struct tog_view *view, struct got_object_id *start_id,
- struct got_repository *repo, const char *path)
+ struct got_repository *repo, const char *path, int check_disk)
{
const struct got_error *err = NULL;
struct tog_log_view_state *s = &view->state.log;
@@ -1368,7 +1368,7 @@ open_log_view(struct tog_view *view, struct got_object_id *start_id,
struct got_commit_graph *thread_graph = NULL;
int errcode;
- err = got_repo_map_path(&s->in_repo_path, repo, path);
+ err = got_repo_map_path(&s->in_repo_path, repo, path, check_disk);
if (err != NULL)
goto done;
@@ -1566,7 +1566,7 @@ input_log_view(struct tog_view **new_view, struct tog_view **dead_view,
if (lv == NULL)
return got_error_from_errno();
err = open_log_view(lv, s->start_id, s->repo,
- parent_path);
+ parent_path, 0);
if (err)
return err;;
if (view_is_parent_view(view))
@@ -1669,7 +1669,7 @@ cmd_log(int argc, char *argv[])
error = got_error_from_errno();
goto done;
}
- error = open_log_view(view, start_id, repo, path);
+ error = open_log_view(view, start_id, repo, path, 1);
if (error)
goto done;
error = view_loop(view);
@@ -2755,7 +2755,7 @@ cmd_blame(int argc, char *argv[])
if (error != NULL)
return error;
- error = got_repo_map_path(&in_repo_path, repo, path);
+ error = got_repo_map_path(&in_repo_path, repo, path, 1);
if (error != NULL)
goto done;
@@ -3048,7 +3048,7 @@ log_tree_entry(struct tog_view **new_view, int begin_x,
if (err)
return err;
- err = open_log_view(log_view, commit_id, repo, path);
+ err = open_log_view(log_view, commit_id, repo, path, 0);
if (err)
view_close(log_view);
else