Skip to content

Commit 6cb97bc

Browse files
committed
remote: Update git_remote_update_tips to use RemoteUpdateFlags
1 parent cb8bbc6 commit 6cb97bc

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

examples/fetch.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#![deny(warnings)]
1616

1717
use clap::Parser;
18-
use git2::{AutotagOption, FetchOptions, RemoteCallbacks, Repository};
18+
use git2::{AutotagOption, FetchOptions, RemoteCallbacks, RemoteUpdateFlags, Repository};
1919
use std::io::{self, Write};
2020
use std::str;
2121

@@ -113,7 +113,12 @@ fn run(args: &Args) -> Result<(), git2::Error> {
113113
// commits. This may be needed even if there was no packfile to download,
114114
// which can happen e.g. when the branches have been changed but all the
115115
// needed objects are available locally.
116-
remote.update_tips(None, true, AutotagOption::Unspecified, None)?;
116+
remote.update_tips(
117+
None,
118+
RemoteUpdateFlags::UPDATE_FETCHHEAD,
119+
AutotagOption::Unspecified,
120+
None,
121+
)?;
117122

118123
Ok(())
119124
}

libgit2-sys/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ extern "C" {
23342334
pub fn git_remote_update_tips(
23352335
remote: *mut git_remote,
23362336
callbacks: *const git_remote_callbacks,
2337-
update_fetchead: c_int,
2337+
update_flags: c_uint,
23382338
download_tags: git_remote_autotag_option_t,
23392339
reflog_message: *const c_char,
23402340
) -> c_int;

src/remote.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::iter::FusedIterator;
33
use std::marker;
44
use std::mem;
55
use std::ops::Range;
6+
use std::os::raw::c_uint;
67
use std::ptr;
78
use std::slice;
89
use std::str;
@@ -11,7 +12,7 @@ use std::{ffi::CString, os::raw::c_char};
1112
use crate::string_array::StringArray;
1213
use crate::util::Binding;
1314
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};
1516

1617
/// A structure representing a [remote][1] of a git repository.
1718
///
@@ -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
));
@@ -778,7 +779,7 @@ impl RemoteRedirect {
778779

779780
#[cfg(test)]
780781
mod tests {
781-
use crate::{AutotagOption, PushOptions};
782+
use crate::{AutotagOption, PushOptions, RemoteUpdateFlags};
782783
use crate::{Direction, FetchOptions, Remote, RemoteCallbacks, Repository};
783784
use std::cell::Cell;
784785
use tempfile::TempDir;
@@ -867,10 +868,20 @@ mod tests {
867868
origin.fetch(&[] as &[&str], None, None).unwrap();
868869
origin.fetch(&[] as &[&str], None, Some("foo")).unwrap();
869870
origin
870-
.update_tips(None, true, AutotagOption::Unspecified, None)
871+
.update_tips(
872+
None,
873+
RemoteUpdateFlags::UPDATE_FETCHHEAD,
874+
AutotagOption::Unspecified,
875+
None,
876+
)
871877
.unwrap();
872878
origin
873-
.update_tips(None, true, AutotagOption::All, Some("foo"))
879+
.update_tips(
880+
None,
881+
RemoteUpdateFlags::UPDATE_FETCHHEAD,
882+
AutotagOption::All,
883+
Some("foo"),
884+
)
874885
.unwrap();
875886

876887
t!(repo.remote_add_fetch("origin", "foo"));

0 commit comments

Comments
 (0)