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
33 use bstr::{BStr, BString, ByteVec};
44
55 /// The arguments passed to a server command.
6+#[derive(Debug)]
67 pub struct Arguments {
78 /// The active features/capabilities of the fetch invocation
89 #[cfg(any(feature = "async-client", feature = "blocking-client"))]
@@ -24,6 +25,13 @@ pub struct Arguments { · 15 unmodified lines
2425 }
2526
2627 impl 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+ }
2735 /// Return true if ref filters is supported.
2836 pub fn can_use_filter(&self) -> bool {
2937 self.filter
git-protocol/src/fetch/refs/mod.rs+1−1
@@ -50,7 +50,7 @@ pub mod parse { · 49 unmodified lines
5050 pub enum Ref {
5151 /// A ref pointing to a `tag` object, which in turns points to an `object`, usually a commit
5252 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`.
5454 full_ref_name: BString,
5555 /// The hash of the tag the ref points to.
5656 tag: git_hash::ObjectId,