History

feat: `fetch::Arguments::is_empty()` to help decide if arguments should be sent at all. (#450)

Furthermore, the `Debug` trait was added.

Sebastian Thiel committed 4 years ago

Commit 0bcb2fd1 parent 0b6ed602 files · +9 −1Browse files

Unified · Split

2 files
  1. git-protocol/src/fetch/arguments/mod.rs +8 −0
  2. git-protocol/src/fetch/refs/mod.rs +1 −1
git-protocol/src/fetch/arguments/mod.rs+8−0
@@ -3,6 +3,7 @@ use std::fmt; · 2 unmodified lines
3use bstr::{BStr, BString, ByteVec};3use bstr::{BStr, BString, ByteVec};
4 4
5/// The arguments passed to a server command.5/// The arguments passed to a server command.
6#[derive(Debug)]
6pub struct Arguments {7pub struct Arguments {
7 /// The active features/capabilities of the fetch invocation8 /// The active features/capabilities of the fetch invocation
8 #[cfg(any(feature = "async-client", feature = "blocking-client"))]9 #[cfg(any(feature = "async-client", feature = "blocking-client"))]
@@ -24,6 +25,13 @@ pub struct Arguments { · 15 unmodified lines
24}25}
25 26
26impl Arguments {27impl Arguments {
28 /// Return true if there is no argument at all.
29 ///
30 /// This can happen if callers assure that they won't add 'wants' if their 'have' is the same, i.e. if the remote has nothing
31 /// new for them.
32 pub fn is_empty(&self) -> bool {
33 self.args.is_empty()
34 }
27 /// Return true if ref filters is supported.35 /// Return true if ref filters is supported.
28 pub fn can_use_filter(&self) -> bool {36 pub fn can_use_filter(&self) -> bool {
29 self.filter37 self.filter
git-protocol/src/fetch/refs/mod.rs+1−1
@@ -50,7 +50,7 @@ pub mod parse { · 49 unmodified lines
50pub enum Ref {50pub enum Ref {
51 /// A ref pointing to a `tag` object, which in turns points to an `object`, usually a commit51 /// A ref pointing to a `tag` object, which in turns points to an `object`, usually a commit
52 Peeled {52 Peeled {
53 /// The name at which the ref is located, like `refs/heads/main`.53 /// The name at which the ref is located, like `refs/tags/1.0`.
54 full_ref_name: BString,54 full_ref_name: BString,
55 /// The hash of the tag the ref points to.55 /// The hash of the tag the ref points to.
56 tag: git_hash::ObjectId,56 tag: git_hash::ObjectId,