MCPcopy Create free account
hub / github.com/libgit2/pygit2 / Repository_add_worktree

Function Repository_add_worktree

src/repository.c:2121–2148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2119 "Create a new worktree for this repository. If ref is specified, no new \
2120 branch will be created and the provided ref will be checked out instead.");
2121PyObject *
2122Repository_add_worktree(Repository *self, PyObject *args)
2123{
2124 char *c_name;
2125 PyBytesObject *py_path = NULL;
2126 char *c_path = NULL;
2127 Reference *py_reference = NULL;
2128 git_worktree *wt;
2129 git_worktree_add_options add_opts = GIT_WORKTREE_ADD_OPTIONS_INIT;
2130
2131 int err;
2132
2133 if (!PyArg_ParseTuple(args, "sO&|O!", &c_name, PyUnicode_FSConverter, &py_path, &ReferenceType, &py_reference))
2134 return NULL;
2135
2136 if (py_path != NULL)
2137 c_path = PyBytes_AS_STRING(py_path);
2138
2139 if(py_reference != NULL)
2140 add_opts.ref = py_reference->reference;
2141
2142 err = git_worktree_add(&wt, self->repo, c_name, c_path, &add_opts);
2143 Py_XDECREF(py_path);
2144 if (err < 0)
2145 return Error_set(err);
2146
2147 return wrap_worktree(self, wt);
2148}
2149
2150PyDoc_STRVAR(Repository_lookup_worktree__doc__,
2151 "lookup_worktree(name: str) -> Worktree\n"

Callers

nothing calls this directly

Calls 2

Error_setFunction · 0.85
wrap_worktreeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…