-
-
Notifications
You must be signed in to change notification settings - Fork 404
Description
Currently the worktree implementation in pygit2 directly re-declares and uses the internal git_worktree
struct.
Lines 36 to 43 in 8d6940f
struct git_worktree { | |
char *name; | |
char *gitlink_path; | |
char *gitdir_path; | |
char *commondir_path; | |
char *parent_path; | |
int locked:1; | |
}; |
It would be nice if we could avoid using this unexposed libgit2 data structure for stability reasons.
For example, building pygit2 against the libgit2 master branch succeeds, however causes silent & dangerous incorrect behaviour due to the definition of git_worktree
in pygit2 no longer matching git_worktree
in libgit2 (a new field, worktree_path
, was added to git_worktree
).
Unfortunately, the fields which are currently exposed as the name
, path
, and git_path
properties on Worktree objects are not public at all in the libgit2 API. My current thoughts about how to handle this are the following:
- Change the
name
property to returngit_worktree_name(self->worktree)
no change in behaviour
- Change the
path
property to returngit_worktree_path(self->worktree)
breaking change -
git_worktree_path
returns the 'worktree_path' rather than the currentgitlink_path
.worktree_path
is currently ~$(basename $gitlink_path)
- this usually results in a.git
segment being removed from the end of the path. - Remove the
git_path
property, as it is not exposed in any way from libgit2.breaking change - property removal
This would make it fall more in line with the libgit2-exposed methods, which seems desirable. Alternatively, the required APIs could be added to libgit2 to maintain behaviour between releases.