MCPcopy Create free account
hub / github.com/libgit2/git2go / Save

Method Save

stash.go:47–72  ·  view source on GitHub ↗

Save saves the local modifications to a new stash. Stasher is the identity of the person performing the stashing. Message is the optional description along with the stashed state. Flags control the stashing process and are given as bitwise OR.

(
	stasher *Signature, message string, flags StashFlag)

Source from the content-addressed store, hash-verified

45// Message is the optional description along with the stashed state.
46// Flags control the stashing process and are given as bitwise OR.
47func (c *StashCollection) Save(
48 stasher *Signature, message string, flags StashFlag) (*Oid, error) {
49
50 oid := new(Oid)
51
52 stasherC, err := stasher.toC()
53 if err != nil {
54 return nil, err
55 }
56 defer C.git_signature_free(stasherC)
57
58 messageC := C.CString(message)
59 defer C.free(unsafe.Pointer(messageC))
60
61 runtime.LockOSThread()
62 defer runtime.UnlockOSThread()
63
64 ret := C.git_stash_save(
65 oid.toC(), c.repo.ptr,
66 stasherC, messageC, C.uint32_t(flags))
67 runtime.KeepAlive(c)
68 if ret < 0 {
69 return nil, MakeGitError(ret)
70 }
71 return oid, nil
72}
73
74// StashApplyFlag are flags that affect the stash apply operation.
75type StashApplyFlag int

Callers 1

TestStashFunction · 0.80

Calls 3

MakeGitErrorFunction · 0.85
freeMethod · 0.80
toCMethod · 0.45

Tested by 1

TestStashFunction · 0.64