Skip to content

Commit 2b0f5cb

Browse files
committed
Bump to 0.1.9
1 parent 9affb94 commit 2b0f5cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1323
-1239
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "git2"
4-
version = "0.1.8"
4+
version = "0.1.9"
55
authors = ["Alex Crichton <alex@alexcrichton.com>"]
66
license = "MIT/Apache-2.0"
77
readme = "README.md"

examples/add.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
3434
let repo = try!(Repository::open(&Path::new(".")));
3535
let mut index = try!(repo.index());
3636

37-
let cb = (&mut |&mut: path: &[u8], _matched_spec: &[u8]| -> int {
37+
let cb = (&mut |&mut: path: &[u8], _matched_spec: &[u8]| -> i32 {
3838
let path = Path::new(path);
3939
let status = repo.status_file(&path).unwrap();
4040

@@ -55,9 +55,9 @@ fn run(args: &Args) -> Result<(), git2::Error> {
5555
};
5656

5757
if args.flag_update {
58-
try!(index.update_all(args.arg_spec.as_slice(), cb));
58+
try!(index.update_all(args.arg_spec.iter(), cb));
5959
} else {
60-
try!(index.add_all(args.arg_spec.as_slice(), git2::ADD_DEFAULT, cb));
60+
try!(index.add_all(args.arg_spec.iter(), git2::ADD_DEFAULT, cb));
6161
}
6262

6363
try!(index.write());

examples/clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ struct Args {
3333

3434
struct State {
3535
progress: Option<Progress<'static>>,
36-
total: uint,
37-
current: uint,
36+
total: usize,
37+
current: usize,
3838
path: Path,
3939
newline: bool,
4040
}

examples/log.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![feature(macro_rules)]
16-
#![deny(warnings)]
1715
#![allow(unstable)]
1816

1917
extern crate "rustc-serialize" as rustc_serialize;
@@ -37,14 +35,14 @@ struct Args {
3735
flag_committer: Option<String>,
3836
flag_grep: Option<String>,
3937
flag_git_dir: Option<String>,
40-
flag_skip: Option<uint>,
41-
flag_max_count: Option<uint>,
38+
flag_skip: Option<usize>,
39+
flag_max_count: Option<usize>,
4240
flag_merges: bool,
4341
flag_no_merges: bool,
4442
flag_no_min_parents: bool,
4543
flag_no_max_parents: bool,
46-
flag_max_parents: Option<uint>,
47-
flag_min_parents: Option<uint>,
44+
flag_max_parents: Option<usize>,
45+
flag_min_parents: Option<usize>,
4846
flag_patch: bool,
4947
}
5048

@@ -221,12 +219,12 @@ fn match_with_parent(repo: &Repository, commit: &Commit, parent: &Commit,
221219
}
222220

223221
impl Args {
224-
fn min_parents(&self) -> uint {
222+
fn min_parents(&self) -> usize {
225223
if self.flag_no_min_parents { return 0 }
226224
self.flag_min_parents.unwrap_or(if self.flag_merges {2} else {0})
227225
}
228226

229-
fn max_parents(&self) -> Option<uint> {
227+
fn max_parents(&self) -> Option<usize> {
230228
if self.flag_no_max_parents { return None }
231229
self.flag_max_parents.or(if self.flag_no_merges {Some(1)} else {None})
232230
}

examples/ls-remote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1313
*/
1414

15-
#![deny(warnings)]
1615
#![allow(unstable)]
16+
#![deny(warnings)]
1717

1818
extern crate git2;
1919
extern crate docopt;

examples/rev-list.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* <http://creativecommons.org/publicdomain/zero/1.0/>.
1414
*/
1515

16-
#![feature(slicing_syntax)]
1716
#![deny(warnings)]
1817
#![allow(unstable)]
1918

examples/rev-parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
3232
let path = args.flag_git_dir.as_ref().map(Path::new).unwrap_or(Path::new("."));
3333
let repo = try!(Repository::open(&path));
3434

35-
let revspec = try!(repo.revparse(args.arg_spec.as_slice()));
35+
let revspec = try!(repo.revparse(&args.arg_spec[]));
3636

3737
if revspec.mode().contains(git2::REVPARSE_SINGLE) {
3838
println!("{}", revspec.from().unwrap().id());

libgit2-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "libgit2-sys"
4-
version = "0.1.5"
4+
version = "0.1.6"
55
authors = ["Alex Crichton <alex@alexcrichton.com>"]
66
links = "git2"
77
build = "build.rs"

libgit2-sys/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(unstable)]
2+
13
extern crate "pkg-config" as pkg_config;
24

35
use std::os;

libgit2-sys/lib.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![allow(non_camel_case_types, missing_copy_implementations)]
2+
#![allow(raw_pointer_derive)]
23

4+
#[allow(unstable)]
35
extern crate libc;
46
extern crate "libssh2-sys" as libssh2;
57
#[cfg(unix)] extern crate "openssl-sys" as openssl;
@@ -36,8 +38,8 @@ pub use git_diff_stats_format_t::*;
3638

3739
use libc::{c_int, c_char, c_uint, size_t, c_uchar, c_void, c_ushort};
3840

39-
pub const GIT_OID_RAWSZ: uint = 20;
40-
pub const GIT_OID_HEXSZ: uint = GIT_OID_RAWSZ * 2;
41+
pub const GIT_OID_RAWSZ: usize = 20;
42+
pub const GIT_OID_HEXSZ: usize = GIT_OID_RAWSZ * 2;
4143
pub const GIT_CLONE_OPTIONS_VERSION: c_uint = 1;
4244
pub const GIT_CHECKOUT_OPTIONS_VERSION: c_uint = 1;
4345
pub const GIT_REMOTE_CALLBACKS_VERSION: c_uint = 1;
@@ -77,19 +79,19 @@ pub struct git_revspec {
7779
}
7880

7981
#[repr(C)]
80-
#[derive(Show)]
8182
pub struct git_error {
8283
pub message: *mut c_char,
8384
pub klass: c_int,
8485
}
8586

8687
#[repr(C)]
87-
#[derive(Copy,Show)]
88+
#[derive(Copy)]
8889
pub struct git_oid {
8990
pub id: [u8; GIT_OID_RAWSZ],
9091
}
9192

9293
#[repr(C)]
94+
#[derive(Copy)]
9395
pub struct git_strarray {
9496
pub strings: *mut *mut c_char,
9597
pub count: size_t,
@@ -103,7 +105,7 @@ pub struct git_signature {
103105
}
104106

105107
#[repr(C)]
106-
#[derive(Copy)]
108+
#[derive(Copy, Clone, Eq, PartialEq)]
107109
pub struct git_time {
108110
pub time: git_time_t,
109111
pub offset: c_int,
@@ -118,7 +120,7 @@ pub const GIT_REVPARSE_RANGE: c_int = 1 << 1;
118120
pub const GIT_REVPARSE_MERGE_BASE: c_int = 1 << 2;
119121

120122
#[repr(C)]
121-
#[derive(PartialEq, Eq, Clone, Show, Copy)]
123+
#[derive(PartialEq, Eq, Clone, Copy)]
122124
pub enum git_error_code {
123125
GIT_OK = 0,
124126

@@ -465,7 +467,7 @@ pub enum git_ref_t {
465467
GIT_REF_INVALID = 0,
466468
GIT_REF_OID = 1,
467469
GIT_REF_SYMBOLIC = 2,
468-
GIT_REF_LISTALL = GIT_REF_OID as int | GIT_REF_SYMBOLIC as int,
470+
GIT_REF_LISTALL = GIT_REF_OID as isize | GIT_REF_SYMBOLIC as isize,
469471
}
470472

471473
#[repr(C)]
@@ -490,6 +492,7 @@ pub type git_treewalk_cb = extern fn(*const c_char, *const git_tree_entry,
490492
*mut c_void) -> c_int;
491493

492494
#[repr(C)]
495+
#[derive(Copy)]
493496
pub struct git_buf {
494497
pub ptr: *mut c_char,
495498
pub asize: size_t,
@@ -501,13 +504,14 @@ pub struct git_buf {
501504
pub enum git_branch_t {
502505
GIT_BRANCH_LOCAL = 1,
503506
GIT_BRANCH_REMOTE = 2,
504-
GIT_BRANCH_ALL = GIT_BRANCH_LOCAL as int | GIT_BRANCH_REMOTE as int,
507+
GIT_BRANCH_ALL = GIT_BRANCH_LOCAL as isize | GIT_BRANCH_REMOTE as isize,
505508
}
506509

507510
pub type git_index_matched_path_cb = extern fn(*const c_char, *const c_char,
508511
*mut c_void) -> c_int;
509512

510513
#[repr(C)]
514+
#[derive(Copy)]
511515
pub struct git_index_entry {
512516
pub ctime: git_index_time,
513517
pub mtime: git_index_time,
@@ -524,7 +528,7 @@ pub struct git_index_entry {
524528
}
525529

526530
#[repr(C)]
527-
#[derive(Copy)]
531+
#[derive(Copy, Clone, Eq, PartialEq)]
528532
pub struct git_index_time {
529533
pub seconds: git_time_t,
530534
pub nanoseconds: c_uint,

src/blob.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use std::marker;
22
use std::mem;
3-
use std::raw as stdraw;
3+
use std::slice;
44

55
use {raw, Oid};
6+
use util::Binding;
67

78
/// A structure to represent a git [blob][1]
89
///
@@ -13,25 +14,11 @@ pub struct Blob<'repo> {
1314
}
1415

1516
impl<'repo> Blob<'repo> {
16-
/// Create a new object from its raw component.
17-
///
18-
/// This method is unsafe as there is no guarantee that `raw` is a valid
19-
/// pointer.
20-
pub unsafe fn from_raw(raw: *mut raw::git_blob) -> Blob<'repo> {
21-
Blob {
22-
raw: raw,
23-
marker: marker::ContravariantLifetime,
24-
}
25-
}
26-
2717
/// Get the id (SHA1) of a repository blob
2818
pub fn id(&self) -> Oid {
29-
unsafe { Oid::from_raw(raw::git_blob_id(&*self.raw)) }
19+
unsafe { Binding::from_raw(raw::git_blob_id(&*self.raw)) }
3020
}
3121

32-
/// Get access to the underlying raw pointer.
33-
pub fn raw(&self) -> *mut raw::git_blob { self.raw }
34-
3522
/// Determine if the blob content is most certainly binary or not.
3623
pub fn is_binary(&self) -> bool {
3724
unsafe { raw::git_blob_is_binary(&*self.raw) == 1 }
@@ -40,14 +27,26 @@ impl<'repo> Blob<'repo> {
4027
/// Get the content of this blob.
4128
pub fn content(&self) -> &[u8] {
4229
unsafe {
43-
mem::transmute(stdraw::Slice {
44-
data: raw::git_blob_rawcontent(&*self.raw) as *const u8,
45-
len: raw::git_blob_rawsize(&*self.raw) as uint,
46-
})
30+
let data = raw::git_blob_rawcontent(&*self.raw) as *const u8;
31+
let len = raw::git_blob_rawsize(&*self.raw) as usize;
32+
slice::from_raw_buf(mem::copy_lifetime(self, &data), len)
33+
}
34+
}
35+
}
36+
37+
impl<'repo> Binding for Blob<'repo> {
38+
type Raw = *mut raw::git_blob;
39+
40+
unsafe fn from_raw(raw: *mut raw::git_blob) -> Blob<'repo> {
41+
Blob {
42+
raw: raw,
43+
marker: marker::ContravariantLifetime,
4744
}
4845
}
46+
fn raw(&self) -> *mut raw::git_blob { self.raw }
4947
}
5048

49+
5150
#[unsafe_destructor]
5251
impl<'repo> Drop for Blob<'repo> {
5352
fn drop(&mut self) {

src/branch.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::str;
44
use libc;
55

66
use {raw, Error, Reference, Signature, BranchType};
7+
use util::Binding;
78

89
/// A structure to represent a git [branch][1]
910
///
@@ -47,14 +48,14 @@ impl<'repo> Branch<'repo> {
4748
signature: Option<&Signature>,
4849
log_message: &str) -> Result<Branch<'repo>, Error> {
4950
let mut ret = 0 as *mut raw::git_reference;
51+
let new_branch_name = CString::from_slice(new_branch_name.as_bytes());
52+
let log_message = CString::from_slice(log_message.as_bytes());
5053
unsafe {
5154
try_call!(raw::git_branch_move(&mut ret, self.get().raw(),
52-
CString::from_slice(new_branch_name.as_bytes()),
53-
force,
54-
&*signature.map(|s| s.raw())
55-
.unwrap_or(0 as *mut _),
56-
CString::from_slice(log_message.as_bytes())));
57-
Ok(Branch::wrap(Reference::from_raw(ret)))
55+
new_branch_name, force,
56+
signature.map(|s| s.raw()),
57+
log_message));
58+
Ok(Branch::wrap(Binding::from_raw(ret)))
5859
}
5960
}
6061

@@ -80,7 +81,7 @@ impl<'repo> Branch<'repo> {
8081
let mut ret = 0 as *mut raw::git_reference;
8182
unsafe {
8283
try_call!(raw::git_branch_upstream(&mut ret, &*self.get().raw()));
83-
Ok(Branch::wrap(Reference::from_raw(ret)))
84+
Ok(Branch::wrap(Binding::from_raw(ret)))
8485
}
8586
}
8687

@@ -129,7 +130,7 @@ impl<'repo> Iterator for Branches<'repo> {
129130
raw::GIT_BRANCH_REMOTE => BranchType::Remote,
130131
raw::GIT_BRANCH_ALL => panic!("unexected branch type"),
131132
};
132-
Some((Branch::wrap(Reference::from_raw(ret)), typ))
133+
Some((Branch::wrap(Binding::from_raw(ret)), typ))
133134
}
134135
}
135136
}

0 commit comments

Comments
 (0)