Skip to content

Commit

Permalink
Update to rust master
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Mar 7, 2015
1 parent 216d762 commit 43d1b11
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 27 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ version = "0.2"
docopt = "=0.6.40"
rustc-serialize = "0.3"
time = "0.1"
tempdir = "0.3"
4 changes: 2 additions & 2 deletions examples/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

#![deny(warnings)]
#![feature(old_io, std_misc, core, old_path)]
#![feature(old_io, std_misc, core, path)]

extern crate git2;
extern crate docopt;
Expand Down Expand Up @@ -43,7 +43,7 @@ struct Args {
enum Format { Long, Short, Porcelain }

fn run(args: &Args) -> Result<(), Error> {
let path = args.flag_git_dir.as_ref().map(Path::new).unwrap_or(Path::new("."));
let path = args.flag_git_dir.clone().unwrap_or(".".to_string());
let repo = try!(Repository::open(&path));
if repo.is_bare() {
return Err(Error::from_str("cannot report status on bare repository"))
Expand Down
14 changes: 5 additions & 9 deletions libgit2-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(path, io, exit_status, core, old_io, fs)]
#![feature(path, io)]

extern crate "pkg-config" as pkg_config;

Expand All @@ -24,7 +24,7 @@ fn main() {

if target.contains("i686") {
cflags.push_str(" -m32");
} else if target.as_slice().contains("x86_64") {
} else if target.contains("x86_64") {
cflags.push_str(" -m64");
}
if !target.contains("i686") {
Expand All @@ -41,7 +41,7 @@ fn main() {
if mingw {
cmd.arg("-G").arg("Unix Makefiles");
}
let profile = match env::var("PROFILE").unwrap().as_slice() {
let profile = match &env::var("PROFILE").unwrap()[..] {
"bench" | "release" => "Release",
_ => "Debug",
};
Expand Down Expand Up @@ -96,7 +96,7 @@ fn run(cmd: &mut Command, program: &str) {
}

fn register_dep(dep: &str) {
match env::var(format!("DEP_{}_ROOT", dep).as_slice()) {
match env::var(&format!("DEP_{}_ROOT", dep)) {
Ok(s) => {
append("CMAKE_PREFIX_PATH", PathBuf::new(&s));
append("PKG_CONFIG_PATH", Path::new(&s).join("lib/pkgconfig"));
Expand All @@ -113,9 +113,5 @@ fn append(var: &str, val: PathBuf) {
}

fn fail(s: &str) -> ! {
use std::old_io;
println!("{}", s);
env::set_exit_status(1);
old_io::stdio::set_stderr(Box::new(old_io::util::NullWriter));
panic!()
panic!("\n{}\n\nbuild script failed, must exit now", s)
}
3 changes: 2 additions & 1 deletion src/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ impl<'repo> Drop for Blob<'repo> {
#[cfg(test)]
mod tests {
use std::io::prelude::*;
use std::fs::{File, TempDir};
use std::fs::File;
use tempdir::TempDir;
use Repository;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ extern fn progress_cb(path: *const c_char,

#[cfg(test)]
mod tests {
use std::fs::{self, TempDir};
use std::fs;
use std::path::Path;
use tempdir::TempDir;
use super::RepoBuilder;
use Repository;

Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ impl<'cfg> Drop for ConfigEntries<'cfg> {

#[cfg(test)]
mod tests {
use std::fs::{File, TempDir};
use std::fs::File;
use tempdir::TempDir;

use Config;

Expand Down
5 changes: 3 additions & 2 deletions src/cred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ impl CredentialHelper {
#[cfg(test)]
mod test {
use std::env;
use std::fs::{self, File, TempDir};
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::Path;
use tempdir::TempDir;

use {Cred, Config, CredentialHelper, ConfigLevel};

Expand Down Expand Up @@ -445,7 +446,7 @@ echo username=c
#[cfg(unix)]
fn chmod(path: &Path) {
use std::os::unix::prelude::*;
let mut perms = path.metadata().unwrap().permissions();
let mut perms = fs::metadata(path).unwrap().permissions();
perms.set_mode(0o755);
fs::set_permissions(path, perms).unwrap();
}
Expand Down
9 changes: 5 additions & 4 deletions src/index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ffi::{CStr, OsString, OsStr};
use std::ffi::{CStr, OsString};
use std::iter::{Range, IntoIterator};
use std::path::Path;

Expand Down Expand Up @@ -110,8 +110,8 @@ impl Index {
// Git apparently expects '/' to be separators for paths
let mut posix_path = OsString::new();
for (i, comp) in path.components().enumerate() {
if i != 0 { posix_path.push_os_str(OsStr::from_str("/")); }
posix_path.push_os_str(comp.as_os_str());
if i != 0 { posix_path.push("/"); }
posix_path.push(comp.as_os_str());
}
let posix_path = try!(posix_path.into_c_string());
unsafe {
Expand Down Expand Up @@ -468,8 +468,9 @@ impl Binding for IndexEntry {

#[cfg(test)]
mod tests {
use std::fs::{self, File, TempDir};
use std::fs::{self, File};
use std::path::Path;
use tempdir::TempDir;

use {Index, Repository, ResetType};

Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@
//! itself.

#![doc(html_root_url = "http://alexcrichton.com/git2-rs")]
#![feature(unsafe_destructor, std_misc, core, path, os)]
#![feature(unsafe_destructor, std_misc, core, path)]
#![feature(io)]
#![deny(missing_docs)]
#![cfg_attr(test, deny(warnings))]
#![cfg_attr(test, feature(fs, tempdir))]
#![cfg_attr(test, feature(fs))]

extern crate libc;
extern crate url;
extern crate "libgit2-sys" as raw;
#[macro_use] extern crate bitflags;
#[cfg(test)] extern crate tempdir;

use std::ffi::{CStr, CString};
use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion src/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'a> Drop for Push<'a> {

#[cfg(test)]
mod tests {
use std::fs::TempDir;
use tempdir::TempDir;
use Repository;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl<'remote> RemoteHead<'remote> {
#[cfg(test)]
mod tests {
use std::cell::Cell;
use std::fs::TempDir;
use tempdir::TempDir;
use {Repository, Remote, RemoteCallbacks, Direction};

#[test]
Expand Down
3 changes: 2 additions & 1 deletion src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,8 @@ impl RepositoryInitOptions {

#[cfg(test)]
mod tests {
use std::fs::{self, TempDir};
use std::fs;
use tempdir::TempDir;
use {Repository, ObjectType, ResetType};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/submodule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ impl<'repo> Drop for Submodule<'repo> {

#[cfg(test)]
mod tests {
use std::fs::TempDir;
use std::path::Path;
use tempdir::TempDir;

use Repository;

Expand Down
2 changes: 1 addition & 1 deletion src/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::{Path, PathBuf};
use std::fs::TempDir;
use std::io;
use tempdir::TempDir;
use url::Url;

use Repository;
Expand Down

0 comments on commit 43d1b11

Please sign in to comment.