History

git-protocol uses `oid` type (#63)

Sebastian Thiel committed 5 years ago

Commit 3930a6f1 parent 658c8968 files · +29 −29Browse files

Showing the changes to git-protocol/src (2 of 8 files). Show all

Unified · Split

2 files
  1. git-protocol/src/fetch/arguments.rs +7 −7
  2. git-protocol/src/fetch/tests/arguments.rs +15 −15
git-protocol/src/fetch/arguments.rs+7−7
@@ -64,22 +64,22 @@ impl Arguments { · 63 unmodified lines
6464 /// Add the given `id` pointing to a commit to the 'want' list.
6565 ///
6666 /// As such it should be included in the server response as it's not present on the client.
67− pub fn want(&mut self, id: git_hash::borrowed::Id<'_>) {
67+ pub fn want(&mut self, id: impl AsRef<git_hash::oid>) {
6868 match self.features_for_first_want.take() {
69− Some(features) => self.prefixed("want ", format!("{} {}", id, features.join(" "))),
70− None => self.prefixed("want ", id),
69+ Some(features) => self.prefixed("want ", format!("{} {}", id.as_ref(), features.join(" "))),
70+ None => self.prefixed("want ", id.as_ref()),
7171 }
7272 }
7373 /// Add the given `id` pointing to a commit to the 'have' list.
7474 ///
7575 /// As such it should _not_ be included in the server response as it's already present on the client.
76− pub fn have(&mut self, id: git_hash::borrowed::Id<'_>) {
77− self.haves.push(format!("have {}", id).into());
76+ pub fn have(&mut self, id: impl AsRef<git_hash::oid>) {
77+ self.haves.push(format!("have {}", id.as_ref()).into());
7878 }
7979 /// Add the given `id` pointing to a commit to the 'shallow' list.
80− pub fn shallow(&mut self, id: git_hash::borrowed::Id<'_>) {
80+ pub fn shallow(&mut self, id: impl AsRef<git_hash::oid>) {
8181 assert!(self.shallow, "'shallow' feature required for 'shallow <id>'");
82− self.prefixed("shallow ", id);
82+ self.prefixed("shallow ", id.as_ref());
8383 }
8484 /// Deepen the commit history by `depth` amount of commits.
8585 pub fn deepen(&mut self, depth: usize) {
git-protocol/src/fetch/tests/arguments.rs+15−15
@@ -81,8 +81,8 @@ mod v1 { · 80 unmodified lines
8181 let mut t = transport(&mut out, true);
8282 let mut arguments = arguments_v1(["feature-a", "feature-b"].iter().cloned());
8383
84− arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed());
85− arguments.want(id("ff333369de1221f9bfbbe03a3a13e9a09bc1ffff").to_borrowed());
84+ arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907"));
85+ arguments.want(id("ff333369de1221f9bfbbe03a3a13e9a09bc1ffff"));
8686 arguments.send(&mut t, true).expect("sending to buffer to work");
8787 assert_eq!(
8888 out.as_bstr(),
@@ -101,14 +101,14 @@ mod v1 { · 12 unmodified lines
101101 let mut arguments = arguments_v1(["feature-a", "shallow", "deepen-since", "deepen-not"].iter().copied());
102102
103103 arguments.deepen(1);
104− arguments.shallow(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c9ff").to_borrowed());
105− arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed());
104+ arguments.shallow(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c9ff"));
105+ arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907"));
106106 arguments.deepen_since(12345);
107107 arguments.deepen_not("refs/heads/main".into());
108− arguments.have(id("0000000000000000000000000000000000000000").to_borrowed());
108+ arguments.have(id("0000000000000000000000000000000000000000"));
109109 arguments.send(&mut t, false).expect("sending to buffer to work");
110110
111− arguments.have(id("1111111111111111111111111111111111111111").to_borrowed());
111+ arguments.have(id("1111111111111111111111111111111111111111"));
112112 arguments.send(&mut t, true).expect("sending to buffer to work");
113113 assert_eq!(
114114 out.as_bstr(),
@@ -137,11 +137,11 @@ mod v1 { · 22 unmodified lines
137137 let mut arguments = arguments_v1(["feature-a", "shallow"].iter().copied());
138138
139139 arguments.deepen(1);
140− arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed());
141− arguments.have(id("0000000000000000000000000000000000000000").to_borrowed());
140+ arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907"));
141+ arguments.have(id("0000000000000000000000000000000000000000"));
142142 arguments.send(&mut t, false).expect("sending to buffer to work");
143143
144− arguments.have(id("1111111111111111111111111111111111111111").to_borrowed());
144+ arguments.have(id("1111111111111111111111111111111111111111"));
145145 arguments.send(&mut t, true).expect("sending to buffer to work");
146146 assert_eq!(
147147 out.as_bstr(),
@@ -168,8 +168,8 @@ mod v2 { · 20 unmodified lines
168168
169169 arguments.deepen(1);
170170 arguments.deepen_relative();
171− arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed());
172− arguments.want(id("ff333369de1221f9bfbbe03a3a13e9a09bc1ffff").to_borrowed());
171+ arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907"));
172+ arguments.want(id("ff333369de1221f9bfbbe03a3a13e9a09bc1ffff"));
173173 arguments.send(&mut t, true).expect("sending to buffer to work");
174174 assert_eq!(
175175 out.as_bstr(),
@@ -196,13 +196,13 @@ mod v2 { · 20 unmodified lines
196196
197197 arguments.deepen(1);
198198 arguments.deepen_since(12345);
199− arguments.shallow(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c9ff").to_borrowed());
200− arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed());
199+ arguments.shallow(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c9ff"));
200+ arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907"));
201201 arguments.deepen_not("refs/heads/main".into());
202− arguments.have(id("0000000000000000000000000000000000000000").to_borrowed());
202+ arguments.have(id("0000000000000000000000000000000000000000"));
203203 arguments.send(&mut t, false).expect("sending to buffer to work");
204204
205− arguments.have(id("1111111111111111111111111111111111111111").to_borrowed());
205+ arguments.have(id("1111111111111111111111111111111111111111"));
206206 arguments.send(&mut t, true).expect("sending to buffer to work");
207207 assert_eq!(
208208 out.as_bstr(),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t