File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -2059,6 +2059,16 @@ extern "C" {
2059
2059
pub fn git_refspec_src_matches ( spec : * const git_refspec , refname : * const c_char ) -> c_int ;
2060
2060
pub fn git_refspec_force ( spec : * const git_refspec ) -> c_int ;
2061
2061
pub fn git_refspec_string ( spec : * const git_refspec ) -> * const c_char ;
2062
+ pub fn git_refspec_transform (
2063
+ out : * mut git_buf ,
2064
+ spec : * const git_refspec ,
2065
+ name : * const c_char ,
2066
+ ) -> c_int ;
2067
+ pub fn git_refspec_rtransform (
2068
+ out : * mut git_buf ,
2069
+ spec : * const git_refspec ,
2070
+ name : * const c_char ,
2071
+ ) -> c_int ;
2062
2072
2063
2073
// strarray
2064
2074
pub fn git_strarray_free ( array : * mut git_strarray ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use std::marker;
3
3
use std:: str;
4
4
5
5
use crate :: util:: Binding ;
6
- use crate :: { raw, Direction } ;
6
+ use crate :: { raw, Buf , Direction , Error } ;
7
7
8
8
/// A structure to represent a git [refspec][1].
9
9
///
@@ -77,6 +77,34 @@ impl<'remote> Refspec<'remote> {
77
77
pub fn bytes ( & self ) -> & [ u8 ] {
78
78
unsafe { crate :: opt_bytes ( self , raw:: git_refspec_string ( self . raw ) ) . unwrap ( ) }
79
79
}
80
+
81
+ /// Transform a reference to its target following the refspec's rules
82
+ pub fn transform ( & self , name : & str ) -> Result < Buf , Error > {
83
+ let name = CString :: new ( name) . unwrap ( ) ;
84
+ unsafe {
85
+ let buf = Buf :: new ( ) ;
86
+ try_call ! ( raw:: git_refspec_transform(
87
+ buf. raw( ) ,
88
+ self . raw,
89
+ name. as_ptr( )
90
+ ) ) ;
91
+ Ok ( buf)
92
+ }
93
+ }
94
+
95
+ /// Transform a target reference to its source reference following the refspec's rules
96
+ pub fn rtransform ( & self , name : & str ) -> Result < Buf , Error > {
97
+ let name = CString :: new ( name) . unwrap ( ) ;
98
+ unsafe {
99
+ let buf = Buf :: new ( ) ;
100
+ try_call ! ( raw:: git_refspec_rtransform(
101
+ buf. raw( ) ,
102
+ self . raw,
103
+ name. as_ptr( )
104
+ ) ) ;
105
+ Ok ( buf)
106
+ }
107
+ }
80
108
}
81
109
82
110
impl < ' remote > Binding for Refspec < ' remote > {
You can’t perform that action at this time.
0 commit comments