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

Method stash

pygit2/repository.py:1240–1311  ·  view source on GitHub ↗

Save changes to the working directory to the stash. Returns: The Oid of the stash merge commit (Oid). Parameters: stasher : Signature The identity of the person doing the stashing. message : str An optional description of stashed s

(
        self,
        stasher: Signature,
        message: str | None = None,
        keep_index: bool = False,
        include_untracked: bool = False,
        include_ignored: bool = False,
        keep_all: bool = False,
        paths: list[str] | None = None,
    )

Source from the content-addressed store, hash-verified

1238 # Stash
1239 #
1240 def stash(
1241 self,
1242 stasher: Signature,
1243 message: str | None = None,
1244 keep_index: bool = False,
1245 include_untracked: bool = False,
1246 include_ignored: bool = False,
1247 keep_all: bool = False,
1248 paths: list[str] | None = None,
1249 ) -> Oid:
1250 """
1251 Save changes to the working directory to the stash.
1252
1253 Returns: The Oid of the stash merge commit (Oid).
1254
1255 Parameters:
1256
1257 stasher : Signature
1258 The identity of the person doing the stashing.
1259
1260 message : str
1261 An optional description of stashed state.
1262
1263 keep_index : bool
1264 Leave changes already added to the index in the working directory.
1265
1266 include_untracked : bool
1267 Also stash untracked files.
1268
1269 include_ignored : bool
1270 Also stash ignored files.
1271
1272 keep_all : bool
1273 All changes in the index and working directory are left intact.
1274
1275 paths : list[str]
1276 An optional list of paths that control which files are stashed.
1277
1278 Example::
1279
1280 >>> repo = pygit2.Repository('.')
1281 >>> repo.stash(repo.default_signature, 'WIP: stashing')
1282 """
1283
1284 opts = ffi.new('git_stash_save_options *')
1285 C.git_stash_save_options_init(opts, C.GIT_STASH_SAVE_OPTIONS_VERSION)
1286
1287 flags = 0
1288 flags |= keep_index * C.GIT_STASH_KEEP_INDEX
1289 flags |= keep_all * C.GIT_STASH_KEEP_ALL
1290 flags |= include_untracked * C.GIT_STASH_INCLUDE_UNTRACKED
1291 flags |= include_ignored * C.GIT_STASH_INCLUDE_IGNORED
1292 opts.flags = flags
1293
1294 stasher_cptr = ffi.new('git_signature **')
1295 ffi.buffer(stasher_cptr)[:] = stasher._pointer[:]
1296 opts.stasher = stasher_cptr[0]
1297

Callers 5

test_stashFunction · 0.80
stash_pathspecsFunction · 0.80

Calls 3

to_bytesFunction · 0.85
StrArrayClass · 0.85
check_errorFunction · 0.85

Tested by 5

test_stashFunction · 0.64
stash_pathspecsFunction · 0.64