Commit f5375317cb16274ce182ea5d99dd913de9b07390

Stefan Sperling 2020-10-20T21:09:01

use got_path_dirname() in install_blob() to avoid const dirname(3) ok naddy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/lib/worktree.c b/lib/worktree.c
index 397a788..5e02cc8 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1475,10 +1475,12 @@ install_blob(struct got_worktree *worktree, const char *ondisk_path,
 	    GOT_DEFAULT_FILE_MODE);
 	if (fd == -1) {
 		if (errno == ENOENT) {
-			char *parent = dirname(path);
-			if (parent == NULL)
-				return got_error_from_errno2("dirname", path);
+			char *parent;
+			err = got_path_dirname(&parent, path);
+			if (err)
+				return err;
 			err = add_dir_on_disk(worktree, parent);
+			free(parent);
 			if (err)
 				return err;
 			fd = open(ondisk_path,