@@ -3,6 +3,7 @@ use std::iter::FusedIterator;
33use std:: marker;
44use std:: mem;
55use std:: ops:: Range ;
6+ use std:: os:: raw:: c_uint;
67use std:: ptr;
78use std:: slice;
89use std:: str;
@@ -11,7 +12,7 @@ use std::{ffi::CString, os::raw::c_char};
1112use crate :: string_array:: StringArray ;
1213use crate :: util:: Binding ;
1314use 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 } ;
1516
1617/// A structure representing a [remote][1] of a git repository.
1718///
@@ -43,7 +44,7 @@ pub struct FetchOptions<'cb> {
4344 depth : i32 ,
4445 proxy : Option < ProxyOptions < ' cb > > ,
4546 prune : FetchPrune ,
46- update_fetchhead : bool ,
47+ update_flags : RemoteUpdateFlags ,
4748 download_tags : AutotagOption ,
4849 follow_redirects : RemoteRedirect ,
4950 custom_headers : Vec < CString > ,
@@ -320,7 +321,7 @@ impl<'repo> Remote<'repo> {
320321 pub fn update_tips (
321322 & mut self ,
322323 callbacks : Option < & mut RemoteCallbacks < ' _ > > ,
323- update_fetchhead : bool ,
324+ update_flags : RemoteUpdateFlags ,
324325 download_tags : AutotagOption ,
325326 msg : Option < & str > ,
326327 ) -> Result < ( ) , Error > {
@@ -330,7 +331,7 @@ impl<'repo> Remote<'repo> {
330331 try_call ! ( raw:: git_remote_update_tips(
331332 self . raw,
332333 cbs. as_ref( ) ,
333- update_fetchhead ,
334+ update_flags . bits ( ) as c_uint ,
334335 download_tags,
335336 msg
336337 ) ) ;
@@ -506,7 +507,7 @@ impl<'cb> FetchOptions<'cb> {
506507 callbacks : None ,
507508 proxy : None ,
508509 prune : FetchPrune :: Unspecified ,
509- update_fetchhead : true ,
510+ update_flags : RemoteUpdateFlags :: UPDATE_FETCHHEAD ,
510511 download_tags : AutotagOption :: Unspecified ,
511512 follow_redirects : RemoteRedirect :: Initial ,
512513 custom_headers : Vec :: new ( ) ,
@@ -537,7 +538,17 @@ impl<'cb> FetchOptions<'cb> {
537538 ///
538539 /// Defaults to `true`.
539540 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) ;
541552 self
542553 }
543554
@@ -602,7 +613,7 @@ impl<'cb> Binding for FetchOptions<'cb> {
602613 . map ( |m| m. raw ( ) )
603614 . unwrap_or_else ( || ProxyOptions :: new ( ) . raw ( ) ) ,
604615 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 ,
606617 download_tags : crate :: call:: convert ( & self . download_tags ) ,
607618 depth : self . depth ,
608619 follow_redirects : self . follow_redirects . raw ( ) ,
@@ -778,7 +789,7 @@ impl RemoteRedirect {
778789
779790#[ cfg( test) ]
780791mod tests {
781- use crate :: { AutotagOption , PushOptions } ;
792+ use crate :: { AutotagOption , PushOptions , RemoteUpdateFlags } ;
782793 use crate :: { Direction , FetchOptions , Remote , RemoteCallbacks , Repository } ;
783794 use std:: cell:: Cell ;
784795 use tempfile:: TempDir ;
@@ -867,10 +878,20 @@ mod tests {
867878 origin. fetch ( & [ ] as & [ & str ] , None , None ) . unwrap ( ) ;
868879 origin. fetch ( & [ ] as & [ & str ] , None , Some ( "foo" ) ) . unwrap ( ) ;
869880 origin
870- . update_tips ( None , true , AutotagOption :: Unspecified , None )
881+ . update_tips (
882+ None ,
883+ RemoteUpdateFlags :: UPDATE_FETCHHEAD ,
884+ AutotagOption :: Unspecified ,
885+ None ,
886+ )
871887 . unwrap ( ) ;
872888 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+ )
874895 . unwrap ( ) ;
875896
876897 t ! ( repo. remote_add_fetch( "origin" , "foo" ) ) ;
0 commit comments