File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,26 @@ func (oid *Oid) NCmp(oid2 *Oid, n uint) int {
96
96
return bytes .Compare (oid .bytes [:n ], oid2 .bytes [:n ])
97
97
}
98
98
99
+ func ShortenOids (ids []* Oid , minlen int ) (int , error ) {
100
+ shorten := C .git_oid_shorten_new (C .size_t (minlen ))
101
+ if shorten == nil {
102
+ panic ("Out of memory" )
103
+ }
104
+ defer C .git_oid_shorten_free (shorten )
105
+
106
+ var ret C.int
107
+ for _ , id := range ids {
108
+ buf := make ([]byte , 41 )
109
+ C .git_oid_fmt ((* C .char )(unsafe .Pointer (& buf [0 ])), id .toC ())
110
+ buf [40 ] = 0
111
+ ret = C .git_oid_shorten_add (shorten , (* C .char )(unsafe .Pointer (& buf [0 ])))
112
+ if ret < 0 {
113
+ return int (ret ), LastError ()
114
+ }
115
+ }
116
+ return int (ret ), nil
117
+ }
118
+
99
119
type GitError struct {
100
120
Message string
101
121
Code int
You can’t perform that action at this time.
0 commit comments