Commit 69960a46af3e7b725e6698e08dc508d7baf38831

Stefan Sperling 2019-05-07T20:38:42

don't try to get dirname of a basename

diff --git a/lib/worktree.c b/lib/worktree.c
index 3354651..d78d997 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2239,9 +2239,15 @@ collect_commitables(void *arg, unsigned char status, const char *path,
 	    status != GOT_STATUS_DELETE)
 		return NULL;
 
-	err = got_path_dirname(&parent_path, path);
-	if (err)
-		return err;
+	if (strchr(path, '/') == NULL) {
+		parent_path = strdup("/");
+		if (parent_path == NULL)
+			return got_error_from_errno();
+	} else {
+		err = got_path_dirname(&parent_path, path);
+		if (err)
+			return err;
+	}
 
 	ct = malloc(sizeof(*ct));
 	if (ct == NULL) {