Commit Diff


commit - ce0de6b686eb6239b2454cde401d6fb38a999dee
commit + 0f63689de68526464ea93d1dc72ca49f138cdf39
blob - 555a850583f3257be7587dc15a2b4e9c5891b0e2
blob + 934b269244bf1905ef3050cd37b7a189852bc2c1
--- lib/worktree.c
+++ lib/worktree.c
@@ -2353,15 +2353,13 @@ match_ct_parent_path(int *match, struct commitable *ct
 	*match = 0;
 
 	if (strchr(ct->path, '/') == NULL) {
-		ct_parent_path = strdup("/");
-		if (ct_parent_path == NULL)
-			return got_error_from_errno();
-	} else {
-		err = got_path_dirname(&ct_parent_path, ct->path);
-		if (err)
-			return err;
+		*match = got_path_is_root_dir(path);
+		return NULL;
 	}
 
+	err = got_path_dirname(&ct_parent_path, ct->path);
+	if (err)
+		return err;
 	*match = (strcmp(path, ct_parent_path) == 0);
 	free(ct_parent_path);
 	return err;