Skip to content

Commit e76bce6

Browse files
committed
refactor(git2): replace all deprecated constants
1 parent 9b99406 commit e76bce6

File tree

11 files changed

+34
-34
lines changed

11 files changed

+34
-34
lines changed

src/blob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'repo> BlobWriter<'repo> {
9696
// After commit we already doesn't need cleanup on drop
9797
self.need_cleanup = false;
9898
let mut raw = raw::git_oid {
99-
id: [0; raw::GIT_OID_RAWSZ],
99+
id: [0; raw::GIT_OID_MAX_SIZE],
100100
};
101101
unsafe {
102102
try_call!(raw::git_blob_create_fromstream_commit(&mut raw, self.raw));

src/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ impl TreeUpdateBuilder {
724724
self.updates.push(raw::git_tree_update {
725725
action: raw::GIT_TREE_UPDATE_REMOVE,
726726
id: raw::git_oid {
727-
id: [0; raw::GIT_OID_RAWSZ],
727+
id: [0; raw::GIT_OID_MAX_SIZE],
728728
},
729729
filemode: raw::GIT_FILEMODE_UNREADABLE,
730730
path: path_ptr,
@@ -755,7 +755,7 @@ impl TreeUpdateBuilder {
755755
/// The baseline tree must exist in the specified repository.
756756
pub fn create_updated(&mut self, repo: &Repository, baseline: &Tree<'_>) -> Result<Oid, Error> {
757757
let mut ret = raw::git_oid {
758-
id: [0; raw::GIT_OID_RAWSZ],
758+
id: [0; raw::GIT_OID_MAX_SIZE],
759759
};
760760
unsafe {
761761
try_call!(raw::git_tree_create_updated(

src/commit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl<'repo> Commit<'repo> {
261261
tree: Option<&Tree<'repo>>,
262262
) -> Result<Oid, Error> {
263263
let mut raw = raw::git_oid {
264-
id: [0; raw::GIT_OID_RAWSZ],
264+
id: [0; raw::GIT_OID_MAX_SIZE],
265265
};
266266
let update_ref = crate::opt_cstr(update_ref)?;
267267
let encoding = crate::opt_cstr(message_encoding)?;

src/diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<'repo> Diff<'repo> {
290290
/// Create a patch ID from a diff.
291291
pub fn patchid(&self, opts: Option<&mut DiffPatchidOptions>) -> Result<Oid, Error> {
292292
let mut raw = raw::git_oid {
293-
id: [0; raw::GIT_OID_RAWSZ],
293+
id: [0; raw::GIT_OID_MAX_SIZE],
294294
};
295295
unsafe {
296296
try_call!(raw::git_diff_patchid(

src/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ impl Index {
617617
/// The index must not contain any file in conflict.
618618
pub fn write_tree(&mut self) -> Result<Oid, Error> {
619619
let mut raw = raw::git_oid {
620-
id: [0; raw::GIT_OID_RAWSZ],
620+
id: [0; raw::GIT_OID_MAX_SIZE],
621621
};
622622
unsafe {
623623
try_call!(raw::git_index_write_tree(&mut raw, self.raw));
@@ -631,7 +631,7 @@ impl Index {
631631
/// can be chosen.
632632
pub fn write_tree_to(&mut self, repo: &Repository) -> Result<Oid, Error> {
633633
let mut raw = raw::git_oid {
634-
id: [0; raw::GIT_OID_RAWSZ],
634+
id: [0; raw::GIT_OID_MAX_SIZE],
635635
};
636636
unsafe {
637637
try_call!(raw::git_index_write_tree_to(&mut raw, self.raw, repo.raw()));

src/note.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<'repo> Iterator for Notes<'repo> {
9393
type Item = Result<(Oid, Oid), Error>;
9494
fn next(&mut self) -> Option<Result<(Oid, Oid), Error>> {
9595
let mut note_id = raw::git_oid {
96-
id: [0; raw::GIT_OID_RAWSZ],
96+
id: [0; raw::GIT_OID_MAX_SIZE],
9797
};
9898
let mut annotated_id = note_id;
9999
unsafe {

src/odb.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'repo> Odb<'repo> {
145145
pub fn write(&self, kind: ObjectType, data: &[u8]) -> Result<Oid, Error> {
146146
unsafe {
147147
let mut out = raw::git_oid {
148-
id: [0; raw::GIT_OID_RAWSZ],
148+
id: [0; raw::GIT_OID_MAX_SIZE],
149149
};
150150
try_call!(raw::git_odb_write(
151151
&mut out,
@@ -195,7 +195,7 @@ impl<'repo> Odb<'repo> {
195195
pub fn exists_prefix(&self, short_oid: Oid, len: usize) -> Result<Oid, Error> {
196196
unsafe {
197197
let mut out = raw::git_oid {
198-
id: [0; raw::GIT_OID_RAWSZ],
198+
id: [0; raw::GIT_OID_MAX_SIZE],
199199
};
200200
try_call!(raw::git_odb_exists_prefix(
201201
&mut out,
@@ -389,7 +389,7 @@ impl<'repo> OdbWriter<'repo> {
389389
/// Attempting write after finishing will be ignored.
390390
pub fn finalize(&mut self) -> Result<Oid, Error> {
391391
let mut raw = raw::git_oid {
392-
id: [0; raw::GIT_OID_RAWSZ],
392+
id: [0; raw::GIT_OID_MAX_SIZE],
393393
};
394394
unsafe {
395395
try_call!(raw::git_odb_stream_finalize_write(&mut raw, self.raw));

src/oid.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Oid {
2525
pub fn from_str(s: &str) -> Result<Oid, Error> {
2626
crate::init();
2727
let mut raw = raw::git_oid {
28-
id: [0; raw::GIT_OID_RAWSZ],
28+
id: [0; raw::GIT_OID_MAX_SIZE],
2929
};
3030
unsafe {
3131
try_call!(raw::git_oid_fromstrn(
@@ -43,9 +43,9 @@ impl Oid {
4343
pub fn from_bytes(bytes: &[u8]) -> Result<Oid, Error> {
4444
crate::init();
4545
let mut raw = raw::git_oid {
46-
id: [0; raw::GIT_OID_RAWSZ],
46+
id: [0; raw::GIT_OID_MAX_SIZE],
4747
};
48-
if bytes.len() != raw::GIT_OID_RAWSZ {
48+
if bytes.len() != raw::GIT_OID_MAX_SIZE {
4949
Err(Error::from_str("raw byte array must be 20 bytes"))
5050
} else {
5151
unsafe {
@@ -58,7 +58,7 @@ impl Oid {
5858
/// Creates an all zero Oid structure.
5959
pub fn zero() -> Oid {
6060
let out = raw::git_oid {
61-
id: [0; raw::GIT_OID_RAWSZ],
61+
id: [0; raw::GIT_OID_MAX_SIZE],
6262
};
6363
Oid { raw: out }
6464
}
@@ -70,7 +70,7 @@ impl Oid {
7070
crate::init();
7171

7272
let mut out = raw::git_oid {
73-
id: [0; raw::GIT_OID_RAWSZ],
73+
id: [0; raw::GIT_OID_MAX_SIZE],
7474
};
7575
unsafe {
7676
try_call!(raw::git_odb_hash(
@@ -94,7 +94,7 @@ impl Oid {
9494
let rpath = path.as_ref().into_c_string()?;
9595

9696
let mut out = raw::git_oid {
97-
id: [0; raw::GIT_OID_RAWSZ],
97+
id: [0; raw::GIT_OID_MAX_SIZE],
9898
};
9999
unsafe {
100100
try_call!(raw::git_odb_hashfile(&mut out, rpath, kind.raw()));
@@ -134,7 +134,7 @@ impl fmt::Debug for Oid {
134134
impl fmt::Display for Oid {
135135
/// Hex-encode this Oid into a formatter.
136136
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
137-
let mut dst = [0u8; raw::GIT_OID_HEXSZ + 1];
137+
let mut dst = [0u8; raw::GIT_OID_MAX_HEXSIZE + 1];
138138
unsafe {
139139
raw::git_oid_tostr(
140140
dst.as_mut_ptr() as *mut libc::c_char,

src/repo.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ impl Repository {
11331133
/// the blob.
11341134
pub fn blob(&self, data: &[u8]) -> Result<Oid, Error> {
11351135
let mut raw = raw::git_oid {
1136-
id: [0; raw::GIT_OID_RAWSZ],
1136+
id: [0; raw::GIT_OID_MAX_SIZE],
11371137
};
11381138
unsafe {
11391139
let ptr = data.as_ptr() as *const c_void;
@@ -1157,7 +1157,7 @@ impl Repository {
11571157
// Normal file path OK (does not need Windows conversion).
11581158
let path = path.into_c_string()?;
11591159
let mut raw = raw::git_oid {
1160-
id: [0; raw::GIT_OID_RAWSZ],
1160+
id: [0; raw::GIT_OID_MAX_SIZE],
11611161
};
11621162
unsafe {
11631163
try_call!(raw::git_blob_create_fromdisk(&mut raw, self.raw(), path));
@@ -1310,7 +1310,7 @@ impl Repository {
13101310
.collect::<Vec<_>>();
13111311
let message = CString::new(message)?;
13121312
let mut raw = raw::git_oid {
1313-
id: [0; raw::GIT_OID_RAWSZ],
1313+
id: [0; raw::GIT_OID_MAX_SIZE],
13141314
};
13151315
unsafe {
13161316
try_call!(raw::git_commit_create(
@@ -1384,7 +1384,7 @@ impl Repository {
13841384
let signature = CString::new(signature)?;
13851385
let signature_field = crate::opt_cstr(signature_field)?;
13861386
let mut raw = raw::git_oid {
1387-
id: [0; raw::GIT_OID_RAWSZ],
1387+
id: [0; raw::GIT_OID_MAX_SIZE],
13881388
};
13891389
unsafe {
13901390
try_call!(raw::git_commit_create_with_signature(
@@ -1683,7 +1683,7 @@ impl Repository {
16831683
pub fn refname_to_id(&self, name: &str) -> Result<Oid, Error> {
16841684
let name = CString::new(name)?;
16851685
let mut ret = raw::git_oid {
1686-
id: [0; raw::GIT_OID_RAWSZ],
1686+
id: [0; raw::GIT_OID_MAX_SIZE],
16871687
};
16881688
unsafe {
16891689
try_call!(raw::git_reference_name_to_id(&mut ret, self.raw(), name));
@@ -1911,7 +1911,7 @@ impl Repository {
19111911
let name = CString::new(name)?;
19121912
let message = CString::new(message)?;
19131913
let mut raw = raw::git_oid {
1914-
id: [0; raw::GIT_OID_RAWSZ],
1914+
id: [0; raw::GIT_OID_MAX_SIZE],
19151915
};
19161916
unsafe {
19171917
try_call!(raw::git_tag_create(
@@ -1944,7 +1944,7 @@ impl Repository {
19441944
let name = CString::new(name)?;
19451945
let message = CString::new(message)?;
19461946
let mut raw_oid = raw::git_oid {
1947-
id: [0; raw::GIT_OID_RAWSZ],
1947+
id: [0; raw::GIT_OID_MAX_SIZE],
19481948
};
19491949
unsafe {
19501950
try_call!(raw::git_tag_annotation_create(
@@ -1972,7 +1972,7 @@ impl Repository {
19721972
) -> Result<Oid, Error> {
19731973
let name = CString::new(name)?;
19741974
let mut raw = raw::git_oid {
1975-
id: [0; raw::GIT_OID_RAWSZ],
1975+
id: [0; raw::GIT_OID_MAX_SIZE],
19761976
};
19771977
unsafe {
19781978
try_call!(raw::git_tag_create_lightweight(
@@ -2348,7 +2348,7 @@ impl Repository {
23482348
let notes_ref = crate::opt_cstr(notes_ref)?;
23492349
let note = CString::new(note)?;
23502350
let mut ret = raw::git_oid {
2351-
id: [0; raw::GIT_OID_RAWSZ],
2351+
id: [0; raw::GIT_OID_MAX_SIZE],
23522352
};
23532353
unsafe {
23542354
try_call!(raw::git_note_create(
@@ -2464,7 +2464,7 @@ impl Repository {
24642464
/// Find a merge base between two commits
24652465
pub fn merge_base(&self, one: Oid, two: Oid) -> Result<Oid, Error> {
24662466
let mut raw = raw::git_oid {
2467-
id: [0; raw::GIT_OID_RAWSZ],
2467+
id: [0; raw::GIT_OID_MAX_SIZE],
24682468
};
24692469
unsafe {
24702470
try_call!(raw::git_merge_base(
@@ -2512,7 +2512,7 @@ impl Repository {
25122512
/// given commits, use [`Self::merge_base_octopus`].
25132513
pub fn merge_base_many(&self, oids: &[Oid]) -> Result<Oid, Error> {
25142514
let mut raw = raw::git_oid {
2515-
id: [0; raw::GIT_OID_RAWSZ],
2515+
id: [0; raw::GIT_OID_MAX_SIZE],
25162516
};
25172517

25182518
unsafe {
@@ -2529,7 +2529,7 @@ impl Repository {
25292529
/// Find a common merge base between all given a list of commits
25302530
pub fn merge_base_octopus(&self, oids: &[Oid]) -> Result<Oid, Error> {
25312531
let mut raw = raw::git_oid {
2532-
id: [0; raw::GIT_OID_RAWSZ],
2532+
id: [0; raw::GIT_OID_MAX_SIZE],
25332533
};
25342534

25352535
unsafe {
@@ -2974,7 +2974,7 @@ impl Repository {
29742974
) -> Result<Oid, Error> {
29752975
unsafe {
29762976
let mut raw_oid = raw::git_oid {
2977-
id: [0; raw::GIT_OID_RAWSZ],
2977+
id: [0; raw::GIT_OID_MAX_SIZE],
29782978
};
29792979
let message = crate::opt_cstr(message)?;
29802980
let flags = flags.unwrap_or_else(StashFlags::empty);
@@ -2996,7 +2996,7 @@ impl Repository {
29962996
) -> Result<Oid, Error> {
29972997
unsafe {
29982998
let mut raw_oid = raw::git_oid {
2999-
id: [0; raw::GIT_OID_RAWSZ],
2999+
id: [0; raw::GIT_OID_MAX_SIZE],
30003000
};
30013001
let opts = opts.map(|opts| opts.raw());
30023002
try_call!(raw::git_stash_save_with_opts(

src/revwalk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<'repo> Iterator for Revwalk<'repo> {
239239
type Item = Result<Oid, Error>;
240240
fn next(&mut self) -> Option<Result<Oid, Error>> {
241241
let mut out: raw::git_oid = raw::git_oid {
242-
id: [0; raw::GIT_OID_RAWSZ],
242+
id: [0; raw::GIT_OID_MAX_SIZE],
243243
};
244244
unsafe {
245245
try_call_iter!(raw::git_revwalk_next(&mut out, self.raw()));

0 commit comments

Comments
 (0)