From d213ae3bb9c727dda1b48aac0f058ae5201d2a72 Mon Sep 17 00:00:00 2001
From: Yorhel <git@yorhel.nl>
Date: Fri, 6 Jan 2017 18:45:02 +0100
Subject: [PATCH] Minor improvements to chdir on browsing

- Don't do the chdir when working on an imported file; To keep with the
  spirit that ncdu doesn't attempt to correlate the imported fs with the
  actual fs.
- Call path_chdir() instead of chdir(), the former can handle infinitely
  long paths. (And, more pragmatically, doesn't generate a warning with
  -Wunused-result enabled).

(That said, path_chdir() is fairly inefficient and could use some
improvements)
---
 src/dirlist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/dirlist.c b/src/dirlist.c
index 8765503..b26ba84 100644
--- a/src/dirlist.c
+++ b/src/dirlist.c
@@ -191,7 +191,8 @@ void dirlist_open(struct dir *d) {
 
   /* not necessary for any ncdu functionality,
    * but enables screen/tmux to work out our cwd */
-  chdir(getpath(dirlist_par));
+  if(!dir_import_active)
+    path_chdir(getpath(dirlist_par));
 
   /* set the head of the list */
   head_real = head = d == NULL ? NULL : d->sub;
-- 
GitLab