Skip to content

Start making the library build with alpha compiler #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#![deny(warnings)]
#![allow(unstable)]

extern crate git2;
extern crate docopt;
Expand Down
1 change: 1 addition & 0 deletions examples/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#![deny(warnings)]
#![allow(unstable)]

extern crate git2;
extern crate docopt;
Expand Down
1 change: 1 addition & 0 deletions examples/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#![deny(warnings)]
#![allow(unstable)]

extern crate git2;
extern crate docopt;
Expand Down
1 change: 1 addition & 0 deletions examples/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#![deny(warnings)]
#![allow(unstable)]

extern crate git2;
extern crate docopt;
Expand Down
1 change: 1 addition & 0 deletions examples/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#![feature(macro_rules)]
#![deny(warnings)]
#![allow(unstable)]

extern crate "rustc-serialize" as rustc_serialize;
extern crate docopt;
Expand Down
1 change: 1 addition & 0 deletions examples/ls-remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#![deny(warnings)]
#![allow(unstable)]

extern crate git2;
extern crate docopt;
Expand Down
3 changes: 2 additions & 1 deletion examples/rev-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#![feature(slicing_syntax)]
#![deny(warnings)]
#![allow(unstable)]

extern crate git2;
extern crate docopt;
Expand Down Expand Up @@ -48,7 +49,7 @@ fn run(args: &Args) -> Result<(), git2::Error> {
let mut specs = args.flag_not.iter().map(|s| (s, true))
.chain(args.arg_spec.iter().map(|s| (s, false)))
.map(|(spec, hide)| {
if spec.starts_with("^") {(spec[1..], !hide)} else {(spec[], hide)}
if spec.starts_with("^") {(&spec[1..], !hide)} else {(&spec[], hide)}
});
for (spec, hide) in specs {
let id = if spec.contains("..") {
Expand Down
1 change: 1 addition & 0 deletions examples/rev-parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#![deny(warnings)]
#![allow(unstable)]

extern crate git2;
extern crate docopt;
Expand Down
1 change: 1 addition & 0 deletions examples/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#![deny(warnings)]
#![allow(unstable)]

extern crate git2;
extern crate docopt;
Expand Down
4 changes: 2 additions & 2 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(globs, phase)]
#![allow(non_camel_case_types, missing_copy_implementations)]

extern crate libc;
Expand Down Expand Up @@ -78,13 +77,14 @@ pub struct git_revspec {
}

#[repr(C)]
#[derive(Show)]
pub struct git_error {
pub message: *mut c_char,
pub klass: c_int,
}

#[repr(C)]
#[derive(Copy)]
#[derive(Copy,Show)]
pub struct git_oid {
pub id: [u8; GIT_OID_RAWSZ],
}
Expand Down
2 changes: 1 addition & 1 deletion src/blob.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::kinds::marker;
use std::marker;
use std::mem;
use std::raw as stdraw;

Expand Down
10 changes: 5 additions & 5 deletions src/branch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::c_str::ToCStr;
use std::kinds::marker;
use std::ffi::CString;
use std::marker;
use std::str;
use libc;

Expand Down Expand Up @@ -49,11 +49,11 @@ impl<'repo> Branch<'repo> {
let mut ret = 0 as *mut raw::git_reference;
unsafe {
try_call!(raw::git_branch_move(&mut ret, self.get().raw(),
new_branch_name.to_c_str(),
CString::from_slice(new_branch_name.as_bytes()),
force,
&*signature.map(|s| s.raw())
.unwrap_or(0 as *mut _),
log_message.to_c_str()));
CString::from_slice(log_message.as_bytes())));
Ok(Branch::wrap(Reference::from_raw(ret)))
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ impl<'repo> Branch<'repo> {
/// provided is the name of the branch to set as upstream.
pub fn set_upstream(&mut self,
upstream_name: Option<&str>) -> Result<(), Error> {
let upstream_name = upstream_name.map(|s| s.to_c_str());
let upstream_name = upstream_name.map(|s| CString::from_slice(s.as_bytes()));
unsafe {
try_call!(raw::git_branch_set_upstream(self.get().raw(),
upstream_name));
Expand Down
24 changes: 12 additions & 12 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Builder-pattern objects for configuration various git operations.

use std::c_str::{CString, ToCStr};
use std::ffi::{CString, c_str_to_bytes};
use std::io;
use std::mem;
use libc::{c_char, size_t, c_void, c_uint, c_int};
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'cb> RepoBuilder<'cb> {
///
/// If not specified, the remote's default branch will be used.
pub fn branch(&mut self, branch: &str) -> &mut RepoBuilder<'cb> {
self.branch = Some(branch.to_c_str());
self.branch = Some(CString::from_slice(branch.as_bytes()));
self
}

Expand Down Expand Up @@ -154,8 +154,8 @@ impl<'cb> RepoBuilder<'cb> {

let mut raw = 0 as *mut raw::git_repository;
unsafe {
try_call!(raw::git_clone(&mut raw, url.to_c_str(),
into.to_c_str(), &opts));
try_call!(raw::git_clone(&mut raw, CString::from_slice(url.as_bytes()),
CString::from_slice(into.as_vec()), &opts));
Ok(Repository::from_raw(raw))
}
}
Expand Down Expand Up @@ -342,34 +342,34 @@ impl<'cb> CheckoutBuilder<'cb> {
///
/// If no paths are specified, then all files are checked out. Otherwise
/// only these specified paths are checked out.
pub fn path<T: ToCStr>(&mut self, path: T) -> &mut CheckoutBuilder<'cb> {
let path = path.to_c_str();
pub fn path<T: Str>(&mut self, path: T) -> &mut CheckoutBuilder<'cb> {
let path = CString::from_slice(path.as_slice().as_bytes());
self.path_ptrs.push(path.as_ptr());
self.paths.push(path);
self
}

/// Set the directory to check out to
pub fn target_dir(&mut self, dst: Path) -> &mut CheckoutBuilder<'cb> {
self.target_dir = Some(dst.to_c_str());
self.target_dir = Some(CString::from_slice(dst.as_vec()));
self
}

/// The name of the common ancestor side of conflicts
pub fn ancestor_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> {
self.ancestor_label = Some(label.to_c_str());
self.ancestor_label = Some(CString::from_slice(label.as_bytes()));
self
}

/// The name of the common our side of conflicts
pub fn our_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> {
self.our_label = Some(label.to_c_str());
self.our_label = Some(CString::from_slice(label.as_bytes()));
self
}

/// The name of the common their side of conflicts
pub fn their_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> {
self.their_label = Some(label.to_c_str());
self.their_label = Some(CString::from_slice(label.as_bytes()));
self
}

Expand Down Expand Up @@ -430,9 +430,9 @@ extern fn progress_cb(path: *const c_char,
Some(ref mut c) => c,
None => return,
};
let path = CString::new(path, false);
let path = CString::from_slice(c_str_to_bytes(&path));
panic::wrap(|| {
callback(path.as_bytes_no_nul(), completed as uint, total as uint);
callback(path.as_bytes(), completed as uint, total as uint);
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/call.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![macro_escape]
#![macro_use]
use libc;

use Error;
Expand Down Expand Up @@ -41,7 +41,7 @@ fn last_error() -> Error {
}

mod impls {
use std::c_str::CString;
use std::ffi::CString;
use libc;

use {raw, ConfigLevel, ResetType, ObjectType, BranchType, Direction};
Expand Down
10 changes: 5 additions & 5 deletions src/commit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::c_str::ToCStr;
use std::ffi::CString;
use std::iter::Range;
use std::kinds::marker;
use std::marker;
use std::str;
use libc;

Expand Down Expand Up @@ -206,11 +206,11 @@ impl<'repo> Commit<'repo> {
unsafe {
try_call!(raw::git_commit_amend(&mut raw,
&*self.raw(),
update_ref.map(|s| s.to_c_str()),
update_ref.map(|s| CString::from_slice(s.as_bytes())),
author.map(|s| &*s.raw()),
committer.map(|s| &*s.raw()),
message_encoding.map(|s| s.to_c_str()),
message.map(|s| s.to_c_str()),
message_encoding.map(|s| CString::from_slice(s.as_bytes())),
message.map(|s| CString::from_slice(s.as_bytes())),
tree.map(|t| &*t.raw())));
Ok(Oid::from_raw(&raw))
}
Expand Down
32 changes: 16 additions & 16 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::c_str::ToCStr;
use std::kinds::marker;
use std::ffi::CString;
use std::marker;
use std::str;
use libc;

Expand Down Expand Up @@ -44,7 +44,7 @@ impl Config {
::init();
let mut raw = 0 as *mut raw::git_config;
unsafe {
try_call!(raw::git_config_open_ondisk(&mut raw, path.to_c_str()));
try_call!(raw::git_config_open_ondisk(&mut raw, CString::from_slice(path.as_vec())));
Ok(Config::from_raw(raw))
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ impl Config {
pub fn add_file(&mut self, path: &Path, level: ConfigLevel,
force: bool) -> Result<(), Error> {
unsafe {
try_call!(raw::git_config_add_file_ondisk(self.raw, path.to_c_str(),
try_call!(raw::git_config_add_file_ondisk(self.raw, CString::from_slice(path.as_vec()),
level, force));
Ok(())
}
Expand All @@ -134,7 +134,7 @@ impl Config {
/// (usually the local one).
pub fn remove(&mut self, name: &str) -> Result<(), Error> {
unsafe {
try_call!(raw::git_config_delete_entry(self.raw, name.to_c_str()));
try_call!(raw::git_config_delete_entry(self.raw, CString::from_slice(name.as_bytes())));
Ok(())
}
}
Expand All @@ -148,7 +148,7 @@ impl Config {
let mut out = 0 as libc::c_int;
unsafe {
try_call!(raw::git_config_get_bool(&mut out, &*self.raw,
name.to_c_str()));
CString::from_slice(name.as_bytes())));
}
Ok(if out == 0 {false} else {true})
}
Expand All @@ -162,7 +162,7 @@ impl Config {
let mut out = 0i32;
unsafe {
try_call!(raw::git_config_get_int32(&mut out, &*self.raw,
name.to_c_str()));
CString::from_slice(name.as_bytes())));
}
Ok(out)
}
Expand All @@ -176,7 +176,7 @@ impl Config {
let mut out = 0i64;
unsafe {
try_call!(raw::git_config_get_int64(&mut out, &*self.raw,
name.to_c_str()));
CString::from_slice(name.as_bytes())));
}
Ok(out)
}
Expand All @@ -196,7 +196,7 @@ impl Config {
let mut ret = 0 as *const libc::c_char;
unsafe {
try_call!(raw::git_config_get_string(&mut ret, &*self.raw,
name.to_c_str()));
CString::from_slice(name.as_bytes())));
Ok(::opt_bytes(self, ret).unwrap())
}
}
Expand All @@ -206,7 +206,7 @@ impl Config {
let mut ret = 0 as *const raw::git_config_entry;
unsafe {
try_call!(raw::git_config_get_entry(&mut ret, &*self.raw,
name.to_c_str()));
CString::from_slice(name.as_bytes())));
Ok(ConfigEntry::from_raw(ret))
}
}
Expand Down Expand Up @@ -234,7 +234,7 @@ impl Config {
Some(s) => {
try_call!(raw::git_config_iterator_glob_new(&mut ret,
&*self.raw,
s.to_c_str()));
CString::from_slice(s.as_bytes())));
}
None => {
try_call!(raw::git_config_iterator_new(&mut ret, &*self.raw));
Expand Down Expand Up @@ -274,7 +274,7 @@ impl Config {
/// highest level (usually the local one).
pub fn set_bool(&mut self, name: &str, value: bool) -> Result<(), Error> {
unsafe {
try_call!(raw::git_config_set_bool(self.raw, name.to_c_str(),
try_call!(raw::git_config_set_bool(self.raw, CString::from_slice(name.as_bytes()),
value));
}
Ok(())
Expand All @@ -284,7 +284,7 @@ impl Config {
/// highest level (usually the local one).
pub fn set_i32(&mut self, name: &str, value: i32) -> Result<(), Error> {
unsafe {
try_call!(raw::git_config_set_int32(self.raw, name.to_c_str(),
try_call!(raw::git_config_set_int32(self.raw, CString::from_slice(name.as_bytes()),
value));
}
Ok(())
Expand All @@ -294,7 +294,7 @@ impl Config {
/// highest level (usually the local one).
pub fn set_i64(&mut self, name: &str, value: i64) -> Result<(), Error> {
unsafe {
try_call!(raw::git_config_set_int64(self.raw, name.to_c_str(),
try_call!(raw::git_config_set_int64(self.raw, CString::from_slice(name.as_bytes()),
value));
}
Ok(())
Expand All @@ -304,8 +304,8 @@ impl Config {
/// highest level (usually the local one).
pub fn set_str(&mut self, name: &str, value: &str) -> Result<(), Error> {
unsafe {
try_call!(raw::git_config_set_string(self.raw, name.to_c_str(),
value.to_c_str()));
try_call!(raw::git_config_set_string(self.raw, CString::from_slice(name.as_bytes()),
CString::from_slice(value.as_bytes())));
}
Ok(())
}
Expand Down
Loading