Showing the changes to git-protocol/src (2 of 8 files). Show all
Unified · Split
| @@ -64,22 +64,22 @@ impl Arguments { · 63 unmodified lines | |||
| 64 | /// Add the given `id` pointing to a commit to the 'want' list. | 64 | /// Add the given `id` pointing to a commit to the 'want' list. |
| 65 | /// | 65 | /// |
| 66 | /// As such it should be included in the server response as it's not present on the client. | 66 | /// 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>) { |
| 68 | match self.features_for_first_want.take() { | 68 | match self.features_for_first_want.take() { |
| 69 | Some(features) => self.prefixed("want ", format!("{} {}", id, features.join(" "))), | 69 | Some(features) => self.prefixed("want ", format!("{} {}", id.as_ref(), features.join(" "))), |
| 70 | None => self.prefixed("want ", id), | 70 | None => self.prefixed("want ", id.as_ref()), |
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| 73 | /// Add the given `id` pointing to a commit to the 'have' list. | 73 | /// Add the given `id` pointing to a commit to the 'have' list. |
| 74 | /// | 74 | /// |
| 75 | /// As such it should _not_ be included in the server response as it's already present on the client. | 75 | /// 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<'_>) { | 76 | pub fn have(&mut self, id: impl AsRef<git_hash::oid>) { |
| 77 | self.haves.push(format!("have {}", id).into()); | 77 | self.haves.push(format!("have {}", id.as_ref()).into()); |
| 78 | } | 78 | } |
| 79 | /// Add the given `id` pointing to a commit to the 'shallow' list. | 79 | /// 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>) { |
| 81 | assert!(self.shallow, "'shallow' feature required for 'shallow <id>'"); | 81 | assert!(self.shallow, "'shallow' feature required for 'shallow <id>'"); |
| 82 | self.prefixed("shallow ", id); | 82 | self.prefixed("shallow ", id.as_ref()); |
| 83 | } | 83 | } |
| 84 | /// Deepen the commit history by `depth` amount of commits. | 84 | /// Deepen the commit history by `depth` amount of commits. |
| 85 | pub fn deepen(&mut self, depth: usize) { | 85 | pub fn deepen(&mut self, depth: usize) { |
| @@ -81,8 +81,8 @@ mod v1 { · 80 unmodified lines | |||
| 81 | let mut t = transport(&mut out, true); | 81 | let mut t = transport(&mut out, true); |
| 82 | let mut arguments = arguments_v1(["feature-a", "feature-b"].iter().cloned()); | 82 | let mut arguments = arguments_v1(["feature-a", "feature-b"].iter().cloned()); |
| 83 | 83 | ||
| 84 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed()); | 84 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907")); |
| 85 | arguments.want(id("ff333369de1221f9bfbbe03a3a13e9a09bc1ffff").to_borrowed()); | 85 | arguments.want(id("ff333369de1221f9bfbbe03a3a13e9a09bc1ffff")); |
| 86 | arguments.send(&mut t, true).expect("sending to buffer to work"); | 86 | arguments.send(&mut t, true).expect("sending to buffer to work"); |
| 87 | assert_eq!( | 87 | assert_eq!( |
| 88 | out.as_bstr(), | 88 | out.as_bstr(), |
| @@ -101,14 +101,14 @@ mod v1 { · 12 unmodified lines | |||
| 101 | let mut arguments = arguments_v1(["feature-a", "shallow", "deepen-since", "deepen-not"].iter().copied()); | 101 | let mut arguments = arguments_v1(["feature-a", "shallow", "deepen-since", "deepen-not"].iter().copied()); |
| 102 | 102 | ||
| 103 | arguments.deepen(1); | 103 | arguments.deepen(1); |
| 104 | arguments.shallow(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c9ff").to_borrowed()); | 104 | arguments.shallow(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c9ff")); |
| 105 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed()); | 105 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907")); |
| 106 | arguments.deepen_since(12345); | 106 | arguments.deepen_since(12345); |
| 107 | arguments.deepen_not("refs/heads/main".into()); | 107 | arguments.deepen_not("refs/heads/main".into()); |
| 108 | arguments.have(id("0000000000000000000000000000000000000000").to_borrowed()); | 108 | arguments.have(id("0000000000000000000000000000000000000000")); |
| 109 | arguments.send(&mut t, false).expect("sending to buffer to work"); | 109 | arguments.send(&mut t, false).expect("sending to buffer to work"); |
| 110 | 110 | ||
| 111 | arguments.have(id("1111111111111111111111111111111111111111").to_borrowed()); | 111 | arguments.have(id("1111111111111111111111111111111111111111")); |
| 112 | arguments.send(&mut t, true).expect("sending to buffer to work"); | 112 | arguments.send(&mut t, true).expect("sending to buffer to work"); |
| 113 | assert_eq!( | 113 | assert_eq!( |
| 114 | out.as_bstr(), | 114 | out.as_bstr(), |
| @@ -137,11 +137,11 @@ mod v1 { · 22 unmodified lines | |||
| 137 | let mut arguments = arguments_v1(["feature-a", "shallow"].iter().copied()); | 137 | let mut arguments = arguments_v1(["feature-a", "shallow"].iter().copied()); |
| 138 | 138 | ||
| 139 | arguments.deepen(1); | 139 | arguments.deepen(1); |
| 140 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed()); | 140 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907")); |
| 141 | arguments.have(id("0000000000000000000000000000000000000000").to_borrowed()); | 141 | arguments.have(id("0000000000000000000000000000000000000000")); |
| 142 | arguments.send(&mut t, false).expect("sending to buffer to work"); | 142 | arguments.send(&mut t, false).expect("sending to buffer to work"); |
| 143 | 143 | ||
| 144 | arguments.have(id("1111111111111111111111111111111111111111").to_borrowed()); | 144 | arguments.have(id("1111111111111111111111111111111111111111")); |
| 145 | arguments.send(&mut t, true).expect("sending to buffer to work"); | 145 | arguments.send(&mut t, true).expect("sending to buffer to work"); |
| 146 | assert_eq!( | 146 | assert_eq!( |
| 147 | out.as_bstr(), | 147 | out.as_bstr(), |
| @@ -168,8 +168,8 @@ mod v2 { · 20 unmodified lines | |||
| 168 | 168 | ||
| 169 | arguments.deepen(1); | 169 | arguments.deepen(1); |
| 170 | arguments.deepen_relative(); | 170 | arguments.deepen_relative(); |
| 171 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed()); | 171 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907")); |
| 172 | arguments.want(id("ff333369de1221f9bfbbe03a3a13e9a09bc1ffff").to_borrowed()); | 172 | arguments.want(id("ff333369de1221f9bfbbe03a3a13e9a09bc1ffff")); |
| 173 | arguments.send(&mut t, true).expect("sending to buffer to work"); | 173 | arguments.send(&mut t, true).expect("sending to buffer to work"); |
| 174 | assert_eq!( | 174 | assert_eq!( |
| 175 | out.as_bstr(), | 175 | out.as_bstr(), |
| @@ -196,13 +196,13 @@ mod v2 { · 20 unmodified lines | |||
| 196 | 196 | ||
| 197 | arguments.deepen(1); | 197 | arguments.deepen(1); |
| 198 | arguments.deepen_since(12345); | 198 | arguments.deepen_since(12345); |
| 199 | arguments.shallow(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c9ff").to_borrowed()); | 199 | arguments.shallow(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c9ff")); |
| 200 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907").to_borrowed()); | 200 | arguments.want(id("7b333369de1221f9bfbbe03a3a13e9a09bc1c907")); |
| 201 | arguments.deepen_not("refs/heads/main".into()); | 201 | arguments.deepen_not("refs/heads/main".into()); |
| 202 | arguments.have(id("0000000000000000000000000000000000000000").to_borrowed()); | 202 | arguments.have(id("0000000000000000000000000000000000000000")); |
| 203 | arguments.send(&mut t, false).expect("sending to buffer to work"); | 203 | arguments.send(&mut t, false).expect("sending to buffer to work"); |
| 204 | 204 | ||
| 205 | arguments.have(id("1111111111111111111111111111111111111111").to_borrowed()); | 205 | arguments.have(id("1111111111111111111111111111111111111111")); |
| 206 | arguments.send(&mut t, true).expect("sending to buffer to work"); | 206 | arguments.send(&mut t, true).expect("sending to buffer to work"); |
| 207 | assert_eq!( | 207 | assert_eq!( |
| 208 | out.as_bstr(), | 208 | out.as_bstr(), |