@@ -3,6 +3,7 @@ use std::iter::FusedIterator;
3
3
use std:: marker;
4
4
use std:: mem;
5
5
use std:: ops:: Range ;
6
+ use std:: os:: raw:: c_uint;
6
7
use std:: ptr;
7
8
use std:: slice;
8
9
use std:: str;
@@ -11,7 +12,7 @@ use std::{ffi::CString, os::raw::c_char};
11
12
use crate :: string_array:: StringArray ;
12
13
use crate :: util:: Binding ;
13
14
use crate :: { call, raw, Buf , Direction , Error , FetchPrune , Oid , ProxyOptions , Refspec } ;
14
- use crate :: { AutotagOption , Progress , RemoteCallbacks , Repository } ;
15
+ use crate :: { AutotagOption , Progress , RemoteCallbacks , RemoteUpdateFlags , Repository } ;
15
16
16
17
/// A structure representing a [remote][1] of a git repository.
17
18
///
@@ -43,7 +44,7 @@ pub struct FetchOptions<'cb> {
43
44
depth : i32 ,
44
45
proxy : Option < ProxyOptions < ' cb > > ,
45
46
prune : FetchPrune ,
46
- update_fetchhead : bool ,
47
+ update_flags : RemoteUpdateFlags ,
47
48
download_tags : AutotagOption ,
48
49
follow_redirects : RemoteRedirect ,
49
50
custom_headers : Vec < CString > ,
@@ -320,7 +321,7 @@ impl<'repo> Remote<'repo> {
320
321
pub fn update_tips (
321
322
& mut self ,
322
323
callbacks : Option < & mut RemoteCallbacks < ' _ > > ,
323
- update_fetchhead : bool ,
324
+ update_flags : RemoteUpdateFlags ,
324
325
download_tags : AutotagOption ,
325
326
msg : Option < & str > ,
326
327
) -> Result < ( ) , Error > {
@@ -330,7 +331,7 @@ impl<'repo> Remote<'repo> {
330
331
try_call ! ( raw:: git_remote_update_tips(
331
332
self . raw,
332
333
cbs. as_ref( ) ,
333
- update_fetchhead ,
334
+ update_flags . bits ( ) as c_uint ,
334
335
download_tags,
335
336
msg
336
337
) ) ;
@@ -506,7 +507,7 @@ impl<'cb> FetchOptions<'cb> {
506
507
callbacks : None ,
507
508
proxy : None ,
508
509
prune : FetchPrune :: Unspecified ,
509
- update_fetchhead : true ,
510
+ update_flags : RemoteUpdateFlags :: UPDATE_FETCHHEAD ,
510
511
download_tags : AutotagOption :: Unspecified ,
511
512
follow_redirects : RemoteRedirect :: Initial ,
512
513
custom_headers : Vec :: new ( ) ,
@@ -537,7 +538,17 @@ impl<'cb> FetchOptions<'cb> {
537
538
///
538
539
/// Defaults to `true`.
539
540
pub fn update_fetchhead ( & mut self , update : bool ) -> & mut Self {
540
- self . update_fetchhead = update;
541
+ self . update_flags
542
+ . set ( RemoteUpdateFlags :: UPDATE_FETCHHEAD , update) ;
543
+ self
544
+ }
545
+
546
+ /// Set whether to report unchanged tips in the update_tips callback.
547
+ ///
548
+ /// Defaults to `false`.
549
+ pub fn report_unchanged ( & mut self , update : bool ) -> & mut Self {
550
+ self . update_flags
551
+ . set ( RemoteUpdateFlags :: REPORT_UNCHANGED , update) ;
541
552
self
542
553
}
543
554
@@ -602,7 +613,7 @@ impl<'cb> Binding for FetchOptions<'cb> {
602
613
. map ( |m| m. raw ( ) )
603
614
. unwrap_or_else ( || ProxyOptions :: new ( ) . raw ( ) ) ,
604
615
prune : crate :: call:: convert ( & self . prune ) ,
605
- update_fetchhead : crate :: call :: convert ( & self . update_fetchhead ) ,
616
+ update_flags : self . update_flags . bits ( ) as c_uint ,
606
617
download_tags : crate :: call:: convert ( & self . download_tags ) ,
607
618
depth : self . depth ,
608
619
follow_redirects : self . follow_redirects . raw ( ) ,
@@ -778,7 +789,7 @@ impl RemoteRedirect {
778
789
779
790
#[ cfg( test) ]
780
791
mod tests {
781
- use crate :: { AutotagOption , PushOptions } ;
792
+ use crate :: { AutotagOption , PushOptions , RemoteUpdateFlags } ;
782
793
use crate :: { Direction , FetchOptions , Remote , RemoteCallbacks , Repository } ;
783
794
use std:: cell:: Cell ;
784
795
use tempfile:: TempDir ;
@@ -867,10 +878,20 @@ mod tests {
867
878
origin. fetch ( & [ ] as & [ & str ] , None , None ) . unwrap ( ) ;
868
879
origin. fetch ( & [ ] as & [ & str ] , None , Some ( "foo" ) ) . unwrap ( ) ;
869
880
origin
870
- . update_tips ( None , true , AutotagOption :: Unspecified , None )
881
+ . update_tips (
882
+ None ,
883
+ RemoteUpdateFlags :: UPDATE_FETCHHEAD ,
884
+ AutotagOption :: Unspecified ,
885
+ None ,
886
+ )
871
887
. unwrap ( ) ;
872
888
origin
873
- . update_tips ( None , true , AutotagOption :: All , Some ( "foo" ) )
889
+ . update_tips (
890
+ None ,
891
+ RemoteUpdateFlags :: UPDATE_FETCHHEAD ,
892
+ AutotagOption :: All ,
893
+ Some ( "foo" ) ,
894
+ )
874
895
. unwrap ( ) ;
875
896
876
897
t ! ( repo. remote_add_fetch( "origin" , "foo" ) ) ;
0 commit comments