commit - 5e70831eb7375e5fea42a487fb5df1e7640ea982
commit + f6d88e1a0cac5d10deaafff839c36f2a9860dd8c
blob - c0b4a22f88ac66488a7663be09009008dd5b3cd0
blob + f8c67ee6313435224cec826561679a4f712b822e
--- lib/worktree.c
+++ lib/worktree.c
goto done;
}
- path = strdup(resolved +
- strlen(got_worktree_get_root_path(worktree)) + 1 /* skip '/' */);
- if (path == NULL) {
- err = got_error_from_errno("strdup");
- goto done;
+ if (strlen(resolved) > strlen(got_worktree_get_root_path(worktree))) {
+ err = got_path_skip_common_ancestor(&path,
+ got_worktree_get_root_path(worktree), resolved);
+ if (err)
+ goto done;
+ } else {
+ path = strdup("");
+ if (path == NULL) {
+ err = got_error_from_errno("strdup");
+ goto done;
+ }
}
/* XXX status walk can't deal with trailing slash! */