Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to current Rust, which is more or less 0.4.

- Regenerated bindings, after getting bindgen to compile.

- Fixed a bunch of syntax and type errors.

- Fixed a couple hacks that 0.4 makes unnecessary.

- Added `pub` all over the goddamn place.
  • Loading branch information...
commit 83abc9fe6c1df74e047a027d1b52055a9a0b6418 1 parent 5dff830
@eevee authored
View
2  README.md
@@ -11,7 +11,7 @@ hood.
`tcup` depends on:
-* The [Rust](http://www.rust-lang.org/) compiler (0.3 only)
+* The [Rust](http://www.rust-lang.org/) compiler (0.4+)
* Some arbitrarily recent build of [libgit2](https://github.com/libgit2/libgit2)
`tcup` consists of two parts: Rust bindings for `libgit2`, and the `tcup`
View
815 git2/c.rs
@@ -1,178 +1,190 @@
/* automatically generated by rust-bindgen */
-import libc::*;
-import libc::types::common::c99::*;
+use libc::*;
+use libc::types::common::c99::*;
-type git_strarray = {
- strings: **c_char,
- count: size_t,
-};
-type git_error = {
- message: *c_char,
- klass: c_int,
-};
+struct git_strarray {
+ strings: **c_schar,
+ count: size_t
+}
+
+type Enum_unnamed1 = c_int;
+const GIT_OK: c_int = 0;
+const GIT_ERROR: c_int = -1;
+const GIT_ENOTFOUND: c_int = -3;
+const GIT_EEXISTS: c_int = -4;
+const GIT_EAMBIGUOUS: c_int = -5;
+const GIT_EBUFS: c_int = -6;
+const GIT_PASSTHROUGH: c_int = -30;
+const GIT_REVWALKOVER: c_int = -31;
+struct git_error {
+ message: *c_schar,
+ klass: c_int
+}
+
type git_error_t = c_uint;
-const GITERR_NOMEMORY: u32 = 0_u32;
-const GITERR_OS: u32 = 1_u32;
-const GITERR_INVALID: u32 = 2_u32;
-const GITERR_REFERENCE: u32 = 3_u32;
-const GITERR_ZLIB: u32 = 4_u32;
-const GITERR_REPOSITORY: u32 = 5_u32;
-const GITERR_CONFIG: u32 = 6_u32;
-const GITERR_REGEX: u32 = 7_u32;
-const GITERR_ODB: u32 = 8_u32;
-const GITERR_INDEX: u32 = 9_u32;
-const GITERR_OBJECT: u32 = 10_u32;
-const GITERR_NET: u32 = 11_u32;
-const GITERR_TAG: u32 = 12_u32;
-const GITERR_TREE: u32 = 13_u32;
-const GITERR_INDEXER: u32 = 14_u32;
+const GITERR_NOMEMORY: c_uint = 0;
+const GITERR_OS: c_uint = 1;
+const GITERR_INVALID: c_uint = 2;
+const GITERR_REFERENCE: c_uint = 3;
+const GITERR_ZLIB: c_uint = 4;
+const GITERR_REPOSITORY: c_uint = 5;
+const GITERR_CONFIG: c_uint = 6;
+const GITERR_REGEX: c_uint = 7;
+const GITERR_ODB: c_uint = 8;
+const GITERR_INDEX: c_uint = 9;
+const GITERR_OBJECT: c_uint = 10;
+const GITERR_NET: c_uint = 11;
+const GITERR_TAG: c_uint = 12;
+const GITERR_TREE: c_uint = 13;
+const GITERR_INDEXER: c_uint = 14;
+
type git_off_t = int64_t;
type git_time_t = int64_t;
-
type git_otype = c_int;
-const GIT_OBJ_ANY: i32 = -2_i32;
-const GIT_OBJ_BAD: i32 = -1_i32;
-const GIT_OBJ__EXT1: i32 = 0_i32;
-const GIT_OBJ_COMMIT: i32 = 1_i32;
-const GIT_OBJ_TREE: i32 = 2_i32;
-const GIT_OBJ_BLOB: i32 = 3_i32;
-const GIT_OBJ_TAG: i32 = 4_i32;
-const GIT_OBJ__EXT2: i32 = 5_i32;
-const GIT_OBJ_OFS_DELTA: i32 = 6_i32;
-const GIT_OBJ_REF_DELTA: i32 = 7_i32;
+const GIT_OBJ_ANY: c_int = -2;
+const GIT_OBJ_BAD: c_int = -1;
+const GIT_OBJ__EXT1: c_int = 0;
+const GIT_OBJ_COMMIT: c_int = 1;
+const GIT_OBJ_TREE: c_int = 2;
+const GIT_OBJ_BLOB: c_int = 3;
+const GIT_OBJ_TAG: c_int = 4;
+const GIT_OBJ__EXT2: c_int = 5;
+const GIT_OBJ_OFS_DELTA: c_int = 6;
+const GIT_OBJ_REF_DELTA: c_int = 7;
-type struct_git_odb = c_void;
-type git_odb = struct_git_odb;
+type Struct_git_odb = c_void;
-type git_odb_backend = struct_git_odb_backend;
+type git_odb = Struct_git_odb;
-type struct_git_odb_object = c_void;
+type git_odb_backend = Struct_git_odb_backend;
-type git_odb_object = struct_git_odb_object;
+type Struct_git_odb_object = c_void;
-type git_odb_stream = struct_git_odb_stream;
+type git_odb_object = Struct_git_odb_object;
-type struct_git_repository = c_void;
+type git_odb_stream = Struct_git_odb_stream;
-type git_repository = struct_git_repository;
+type Struct_git_repository = c_void;
-type struct_git_object = c_void;
+type git_repository = Struct_git_repository;
-type git_object = struct_git_object;
+type Struct_git_object = c_void;
-type struct_git_revwalk = c_void;
+type git_object = Struct_git_object;
-type git_revwalk = struct_git_revwalk;
+type Struct_git_revwalk = c_void;
-type struct_git_tag = c_void;
+type git_revwalk = Struct_git_revwalk;
-type git_tag = struct_git_tag;
+type Struct_git_tag = c_void;
-type struct_git_blob = c_void;
+type git_tag = Struct_git_tag;
-type git_blob = struct_git_blob;
+type Struct_git_blob = c_void;
-type struct_git_commit = c_void;
+type git_blob = Struct_git_blob;
-type git_commit = struct_git_commit;
+type Struct_git_commit = c_void;
-type struct_git_tree_entry = c_void;
+type git_commit = Struct_git_commit;
-type git_tree_entry = struct_git_tree_entry;
+type Struct_git_tree_entry = c_void;
-type struct_git_tree = c_void;
+type git_tree_entry = Struct_git_tree_entry;
-type git_tree = struct_git_tree;
+type Struct_git_tree = c_void;
-type struct_git_treebuilder = c_void;
+type git_tree = Struct_git_tree;
-type git_treebuilder = struct_git_treebuilder;
+type Struct_git_treebuilder = c_void;
-type struct_git_index = c_void;
+type git_treebuilder = Struct_git_treebuilder;
-type git_index = struct_git_index;
+type Struct_git_index = c_void;
-type struct_git_config = c_void;
+type git_index = Struct_git_index;
-type git_config = struct_git_config;
+type Struct_git_config = c_void;
-type git_config_file = struct_git_config_file;
+type git_config = Struct_git_config;
-type struct_git_reflog_entry = c_void;
+type git_config_file = Struct_git_config_file;
-type git_reflog_entry = struct_git_reflog_entry;
+type Struct_git_reflog_entry = c_void;
-type struct_git_reflog = c_void;
+type git_reflog_entry = Struct_git_reflog_entry;
-type git_reflog = struct_git_reflog;
+type Struct_git_reflog = c_void;
-type struct_git_note = c_void;
+type git_reflog = Struct_git_reflog;
-type git_note = struct_git_note;
+type Struct_git_note = c_void;
-type struct_git_time = {
- time: git_time_t,
- offset: c_int,
-};
+type git_note = Struct_git_note;
-type git_time = struct_git_time;
+struct Struct_git_time {
+ time: git_time_t,
+ offset: c_int
+}
-type struct_git_signature = {
- name: *c_char,
- email: *c_char,
- when: git_time,
-};
+type git_time = Struct_git_time;
-type git_signature = struct_git_signature;
+struct Struct_git_signature {
+ name: *c_schar,
+ email: *c_schar,
+ when: git_time
+}
-type struct_git_reference = c_void;
+type git_signature = Struct_git_signature;
-type git_reference = struct_git_reference;
+type Struct_git_reference = c_void;
+type git_reference = Struct_git_reference;
type git_ref_t = c_uint;
-const GIT_REF_INVALID: u32 = 0_u32;
-const GIT_REF_OID: u32 = 1_u32;
-const GIT_REF_SYMBOLIC: u32 = 2_u32;
-const GIT_REF_PACKED: u32 = 4_u32;
-const GIT_REF_HAS_PEEL: u32 = 8_u32;
-const GIT_REF_LISTALL: u32 = 7_u32;
+const GIT_REF_INVALID: c_uint = 0;
+const GIT_REF_OID: c_uint = 1;
+const GIT_REF_SYMBOLIC: c_uint = 2;
+const GIT_REF_PACKED: c_uint = 4;
+const GIT_REF_HAS_PEEL: c_uint = 8;
+const GIT_REF_LISTALL: c_uint = 7;
type git_branch_t = c_uint;
-const GIT_BRANCH_LOCAL: u32 = 1_u32;
-const GIT_BRANCH_REMOTE: u32 = 2_u32;
+const GIT_BRANCH_LOCAL: c_uint = 1;
+const GIT_BRANCH_REMOTE: c_uint = 2;
-type struct_git_refspec = c_void;
-type git_refspec = struct_git_refspec;
+type Struct_git_refspec = c_void;
-type struct_git_remote = c_void;
+type git_refspec = Struct_git_refspec;
-type git_remote = struct_git_remote;
+type Struct_git_remote = c_void;
-type git_remote_head = struct_git_remote_head;
+type git_remote = Struct_git_remote;
-type git_oid = struct__git_oid;
+type git_remote_head = Struct_git_remote_head;
-type struct__git_oid = {
- id: (c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar,c_uchar),
-};
+type git_oid = Struct__git_oid;
-type struct_git_oid_shorten = c_void;
+struct Struct__git_oid {
+ id: [c_uchar * 20]
+}
+
+type Struct_git_oid_shorten = c_void;
-type git_oid_shorten = struct_git_oid_shorten;
+type git_oid_shorten = Struct_git_oid_shorten;
-type struct_git_odb_backend = {
+struct Struct_git_odb_backend {
odb: *git_odb,
read: *u8,
read_prefix: *u8,
@@ -181,88 +193,130 @@ type struct_git_odb_backend = {
writestream: *u8,
readstream: *u8,
exists: *u8,
- free: *u8,
-};
+ free: *u8
+}
+type Enum_unnamed2 = c_uint;
+const GIT_STREAM_RDONLY: c_uint = 2;
+const GIT_STREAM_WRONLY: c_uint = 4;
+const GIT_STREAM_RW: c_uint = 6;
-type struct_git_odb_stream = {
- backend: *c_void /* struct_git_odb_backend */,
+
+struct Struct_git_odb_stream {
+ backend: *Struct_git_odb_backend,
mode: c_int,
read: *u8,
write: *u8,
finalize_write: *u8,
- free: *u8,
-};
+ free: *u8
+}
+
+type Enum_unnamed3 = c_uint;
+const GIT_REPOSITORY_OPEN_NO_SEARCH: c_uint = 1;
+const GIT_REPOSITORY_OPEN_CROSS_FS: c_uint = 2;
type git_treewalk_cb = *u8;
-type enum_git_treewalk_mode = c_uint;
-const GIT_TREEWALK_PRE: u32 = 0_u32;
-const GIT_TREEWALK_POST: u32 = 1_u32;
+type Enum_git_treewalk_mode = c_uint;
+const GIT_TREEWALK_PRE: c_uint = 0;
+const GIT_TREEWALK_POST: c_uint = 1;
+
+type Enum_unnamed4 = c_uint;
+const GIT_DIFF_NORMAL: c_uint = 0;
+const GIT_DIFF_REVERSE: c_uint = 1;
+const GIT_DIFF_FORCE_TEXT: c_uint = 2;
+const GIT_DIFF_IGNORE_WHITESPACE: c_uint = 4;
+const GIT_DIFF_IGNORE_WHITESPACE_CHANGE: c_uint = 8;
+const GIT_DIFF_IGNORE_WHITESPACE_EOL: c_uint = 16;
+const GIT_DIFF_IGNORE_SUBMODULES: c_uint = 32;
+const GIT_DIFF_PATIENCE: c_uint = 64;
+const GIT_DIFF_INCLUDE_IGNORED: c_uint = 128;
+const GIT_DIFF_INCLUDE_UNTRACKED: c_uint = 256;
+const GIT_DIFF_INCLUDE_UNMODIFIED: c_uint = 512;
+const GIT_DIFF_RECURSE_UNTRACKED_DIRS: c_uint = 1024;
-type git_diff_options = {
+
+struct git_diff_options {
flags: uint32_t,
context_lines: uint16_t,
interhunk_lines: uint16_t,
- old_prefix: *c_char,
- new_prefix: *c_char,
- pathspec: git_strarray,
-};
+ old_prefix: *c_schar,
+ new_prefix: *c_schar,
+ pathspec: git_strarray
+}
-type struct_git_diff_list = c_void;
+type Struct_git_diff_list = c_void;
-type git_diff_list = struct_git_diff_list;
+type git_diff_list = Struct_git_diff_list;
+type Enum_unnamed5 = c_uint;
+const GIT_DIFF_FILE_VALID_OID: c_uint = 1;
+const GIT_DIFF_FILE_FREE_PATH: c_uint = 2;
+const GIT_DIFF_FILE_BINARY: c_uint = 4;
+const GIT_DIFF_FILE_NOT_BINARY: c_uint = 8;
+const GIT_DIFF_FILE_FREE_DATA: c_uint = 16;
+const GIT_DIFF_FILE_UNMAP_DATA: c_uint = 32;
type git_delta_t = c_uint;
-const GIT_DELTA_UNMODIFIED: u32 = 0_u32;
-const GIT_DELTA_ADDED: u32 = 1_u32;
-const GIT_DELTA_DELETED: u32 = 2_u32;
-const GIT_DELTA_MODIFIED: u32 = 3_u32;
-const GIT_DELTA_RENAMED: u32 = 4_u32;
-const GIT_DELTA_COPIED: u32 = 5_u32;
-const GIT_DELTA_IGNORED: u32 = 6_u32;
-const GIT_DELTA_UNTRACKED: u32 = 7_u32;
-
-type git_diff_file = {
+const GIT_DELTA_UNMODIFIED: c_uint = 0;
+const GIT_DELTA_ADDED: c_uint = 1;
+const GIT_DELTA_DELETED: c_uint = 2;
+const GIT_DELTA_MODIFIED: c_uint = 3;
+const GIT_DELTA_RENAMED: c_uint = 4;
+const GIT_DELTA_COPIED: c_uint = 5;
+const GIT_DELTA_IGNORED: c_uint = 6;
+const GIT_DELTA_UNTRACKED: c_uint = 7;
+
+
+struct git_diff_file {
oid: git_oid,
- path: *c_char,
+ path: *c_schar,
mode: uint16_t,
size: git_off_t,
- flags: c_uint,
-};
+ flags: c_uint
+}
-type git_diff_delta = {
+struct git_diff_delta {
old_file: git_diff_file,
new_file: git_diff_file,
status: git_delta_t,
similarity: c_uint,
- binary: c_int,
-};
+ binary: c_int
+}
type git_diff_file_fn = *u8;
-type git_diff_range = {
+struct git_diff_range {
old_start: c_int,
old_lines: c_int,
new_start: c_int,
- new_lines: c_int,
-};
+ new_lines: c_int
+}
type git_diff_hunk_fn = *u8;
+type Enum_unnamed6 = c_uint;
+const GIT_DIFF_LINE_CONTEXT: c_uint = 32;
+const GIT_DIFF_LINE_ADDITION: c_uint = 43;
+const GIT_DIFF_LINE_DELETION: c_uint = 45;
+const GIT_DIFF_LINE_ADD_EOFNL: c_uint = 10;
+const GIT_DIFF_LINE_DEL_EOFNL: c_uint = 0;
+const GIT_DIFF_LINE_FILE_HDR: c_uint = 70;
+const GIT_DIFF_LINE_HUNK_HDR: c_uint = 72;
+const GIT_DIFF_LINE_BINARY: c_uint = 66;
+
type git_diff_data_fn = *u8;
-type git_index_time = {
+struct git_index_time {
seconds: git_time_t,
- nanoseconds: c_uint,
-};
+ nanoseconds: c_uint
+}
-type struct_git_index_entry = {
+struct Struct_git_index_entry {
ctime: git_index_time,
mtime: git_index_time,
dev: c_uint,
@@ -274,21 +328,21 @@ type struct_git_index_entry = {
oid: git_oid,
flags: c_ushort,
flags_extended: c_ushort,
- path: *c_char,
-};
+ path: *c_schar
+}
-type git_index_entry = struct_git_index_entry;
+type git_index_entry = Struct_git_index_entry;
-type struct_git_index_entry_unmerged = {
- mode: (c_uint,c_uint,c_uint),
- oid: (git_oid,git_oid,git_oid),
- path: *c_char,
-};
+struct Struct_git_index_entry_unmerged {
+ mode: [c_uint * 3],
+ oid: [git_oid * 3],
+ path: *c_schar
+}
-type git_index_entry_unmerged = struct_git_index_entry_unmerged;
+type git_index_entry_unmerged = Struct_git_index_entry_unmerged;
-type struct_git_config_file = {
- cfg: *c_void /* struct_git_config */,
+struct Struct_git_config_file {
+ cfg: *Struct_git_config,
open: *u8,
get: *u8,
get_multivar: *u8,
@@ -296,160 +350,109 @@ type struct_git_config_file = {
set_multivar: *u8,
del: *u8,
foreach: *u8,
- free: *u8,
-};
-
+ free: *u8
+}
type git_cvar_t = c_uint;
-const GIT_CVAR_FALSE: u32 = 0_u32;
-const GIT_CVAR_TRUE: u32 = 1_u32;
-const GIT_CVAR_INT32: u32 = 2_u32;
-const GIT_CVAR_STRING: u32 = 3_u32;
+const GIT_CVAR_FALSE: c_uint = 0;
+const GIT_CVAR_TRUE: c_uint = 1;
+const GIT_CVAR_INT32: c_uint = 2;
+const GIT_CVAR_STRING: c_uint = 3;
+
-type git_cvar_map = {
+struct git_cvar_map {
cvar_type: git_cvar_t,
- str_match: *c_char,
- map_value: c_int,
-};
+ str_match: *c_schar,
+ map_value: c_int
+}
-type struct_git_remote_head = {
+struct Struct_git_remote_head {
local: c_int,
oid: git_oid,
loid: git_oid,
- name: *c_char,
-};
+ name: *c_schar
+}
type git_headlist_cb = *u8;
-type struct_git_indexer_stats = {
+struct Struct_git_indexer_stats {
total: c_uint,
- processed: c_uint,
-};
+ processed: c_uint
+}
-type git_indexer_stats = struct_git_indexer_stats;
+type git_indexer_stats = Struct_git_indexer_stats;
-type struct_git_indexer = c_void;
+type Struct_git_indexer = c_void;
-type git_indexer = struct_git_indexer;
+type git_indexer = Struct_git_indexer;
-type struct_git_indexer_stream = c_void;
+type Struct_git_indexer_stream = c_void;
-type git_indexer_stream = struct_git_indexer_stream;
+type git_indexer_stream = Struct_git_indexer_stream;
+type Enum_unnamed7 = c_uint;
+const GIT_STATUS_CURRENT: c_uint = 0;
+const GIT_STATUS_INDEX_NEW: c_uint = 1;
+const GIT_STATUS_INDEX_MODIFIED: c_uint = 2;
+const GIT_STATUS_INDEX_DELETED: c_uint = 4;
+const GIT_STATUS_WT_NEW: c_uint = 8;
+const GIT_STATUS_WT_MODIFIED: c_uint = 16;
+const GIT_STATUS_WT_DELETED: c_uint = 32;
+const GIT_STATUS_IGNORED: c_uint = 64;
type git_status_show_t = c_uint;
-const GIT_STATUS_SHOW_INDEX_AND_WORKDIR: u32 = 0_u32;
-const GIT_STATUS_SHOW_INDEX_ONLY: u32 = 1_u32;
-const GIT_STATUS_SHOW_WORKDIR_ONLY: u32 = 2_u32;
-const GIT_STATUS_SHOW_INDEX_THEN_WORKDIR: u32 = 3_u32;
+const GIT_STATUS_SHOW_INDEX_AND_WORKDIR: c_uint = 0;
+const GIT_STATUS_SHOW_INDEX_ONLY: c_uint = 1;
+const GIT_STATUS_SHOW_WORKDIR_ONLY: c_uint = 2;
+const GIT_STATUS_SHOW_INDEX_THEN_WORKDIR: c_uint = 3;
+
+type Enum_unnamed8 = c_uint;
+const GIT_STATUS_OPT_INCLUDE_UNTRACKED: c_uint = 1;
+const GIT_STATUS_OPT_INCLUDE_IGNORED: c_uint = 2;
+const GIT_STATUS_OPT_INCLUDE_UNMODIFIED: c_uint = 4;
+const GIT_STATUS_OPT_EXCLUDE_SUBMODULED: c_uint = 8;
+const GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS: c_uint = 16;
-type git_status_options = {
+
+struct git_status_options {
show: git_status_show_t,
flags: c_uint,
- pathspec: git_strarray,
-};
-
+ pathspec: git_strarray
+}
type git_submodule_update_t = c_uint;
-const GIT_SUBMODULE_UPDATE_CHECKOUT: u32 = 0_u32;
-const GIT_SUBMODULE_UPDATE_REBASE: u32 = 1_u32;
-const GIT_SUBMODULE_UPDATE_MERGE: u32 = 2_u32;
+const GIT_SUBMODULE_UPDATE_CHECKOUT: c_uint = 0;
+const GIT_SUBMODULE_UPDATE_REBASE: c_uint = 1;
+const GIT_SUBMODULE_UPDATE_MERGE: c_uint = 2;
type git_submodule_ignore_t = c_uint;
-const GIT_SUBMODULE_IGNORE_ALL: u32 = 0_u32;
-const GIT_SUBMODULE_IGNORE_DIRTY: u32 = 1_u32;
-const GIT_SUBMODULE_IGNORE_UNTRACKED: u32 = 2_u32;
-const GIT_SUBMODULE_IGNORE_NONE: u32 = 3_u32;
-
-type git_submodule = {
- name: *c_char,
- path: *c_char,
- url: *c_char,
+const GIT_SUBMODULE_IGNORE_ALL: c_uint = 0;
+const GIT_SUBMODULE_IGNORE_DIRTY: c_uint = 1;
+const GIT_SUBMODULE_IGNORE_UNTRACKED: c_uint = 2;
+const GIT_SUBMODULE_IGNORE_NONE: c_uint = 3;
+
+
+struct git_submodule {
+ name: *c_schar,
+ path: *c_schar,
+ url: *c_schar,
oid: git_oid,
update: git_submodule_update_t,
ignore: git_submodule_ignore_t,
fetch_recurse: c_int,
- refcount: c_int,
-};
+ refcount: c_int
+}
-type git_note_data = {
+struct git_note_data {
blob_oid: git_oid,
- annotated_object_oid: git_oid,
-};
-
-type enum_unnamed1 = c_uint;
-const GIT_STATUS_CURRENT: u32 = 0_u32;
-const GIT_STATUS_INDEX_NEW: u32 = 1_u32;
-const GIT_STATUS_INDEX_MODIFIED: u32 = 2_u32;
-const GIT_STATUS_INDEX_DELETED: u32 = 4_u32;
-const GIT_STATUS_WT_NEW: u32 = 8_u32;
-const GIT_STATUS_WT_MODIFIED: u32 = 16_u32;
-const GIT_STATUS_WT_DELETED: u32 = 32_u32;
-const GIT_STATUS_IGNORED: u32 = 64_u32;
-
-type enum_unnamed2 = c_uint;
-const GIT_DIFF_FILE_VALID_OID: u32 = 1_u32;
-const GIT_DIFF_FILE_FREE_PATH: u32 = 2_u32;
-const GIT_DIFF_FILE_BINARY: u32 = 4_u32;
-const GIT_DIFF_FILE_NOT_BINARY: u32 = 8_u32;
-const GIT_DIFF_FILE_FREE_DATA: u32 = 16_u32;
-const GIT_DIFF_FILE_UNMAP_DATA: u32 = 32_u32;
-
-type enum_unnamed3 = c_uint;
-const GIT_DIFF_NORMAL: u32 = 0_u32;
-const GIT_DIFF_REVERSE: u32 = 1_u32;
-const GIT_DIFF_FORCE_TEXT: u32 = 2_u32;
-const GIT_DIFF_IGNORE_WHITESPACE: u32 = 4_u32;
-const GIT_DIFF_IGNORE_WHITESPACE_CHANGE: u32 = 8_u32;
-const GIT_DIFF_IGNORE_WHITESPACE_EOL: u32 = 16_u32;
-const GIT_DIFF_IGNORE_SUBMODULES: u32 = 32_u32;
-const GIT_DIFF_PATIENCE: u32 = 64_u32;
-const GIT_DIFF_INCLUDE_IGNORED: u32 = 128_u32;
-const GIT_DIFF_INCLUDE_UNTRACKED: u32 = 256_u32;
-const GIT_DIFF_INCLUDE_UNMODIFIED: u32 = 512_u32;
-const GIT_DIFF_RECURSE_UNTRACKED_DIRS: u32 = 1024_u32;
-
-type enum_unnamed4 = c_uint;
-const GIT_STREAM_RDONLY: u32 = 2_u32;
-const GIT_STREAM_WRONLY: u32 = 4_u32;
-const GIT_STREAM_RW: u32 = 6_u32;
-
-type enum_unnamed5 = c_uint;
-const GIT_DIFF_LINE_CONTEXT: u32 = 32_u32;
-const GIT_DIFF_LINE_ADDITION: u32 = 43_u32;
-const GIT_DIFF_LINE_DELETION: u32 = 45_u32;
-const GIT_DIFF_LINE_ADD_EOFNL: u32 = 10_u32;
-const GIT_DIFF_LINE_DEL_EOFNL: u32 = 0_u32;
-const GIT_DIFF_LINE_FILE_HDR: u32 = 70_u32;
-const GIT_DIFF_LINE_HUNK_HDR: u32 = 72_u32;
-const GIT_DIFF_LINE_BINARY: u32 = 66_u32;
-
-type enum_unnamed6 = c_uint;
-const GIT_REPOSITORY_OPEN_NO_SEARCH: u32 = 1_u32;
-const GIT_REPOSITORY_OPEN_CROSS_FS: u32 = 2_u32;
-
-type enum_unnamed7 = c_int;
-const GIT_OK: i32 = 0_i32;
-const GIT_ERROR: i32 = -1_i32;
-const GIT_ENOTFOUND: i32 = -3_i32;
-const GIT_EEXISTS: i32 = -4_i32;
-const GIT_EAMBIGUOUS: i32 = -5_i32;
-const GIT_EBUFS: i32 = -6_i32;
-const GIT_PASSTHROUGH: i32 = -30_i32;
-const GIT_REVWALKOVER: i32 = -31_i32;
-
-type enum_unnamed8 = c_uint;
-const GIT_STATUS_OPT_INCLUDE_UNTRACKED: u32 = 1_u32;
-const GIT_STATUS_OPT_INCLUDE_IGNORED: u32 = 2_u32;
-const GIT_STATUS_OPT_INCLUDE_UNMODIFIED: u32 = 4_u32;
-const GIT_STATUS_OPT_EXCLUDE_SUBMODULED: u32 = 8_u32;
-const GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS: u32 = 16_u32;
-
-#[link_name="git2"]
-extern mod bindgen {
+ annotated_object_oid: git_oid
+}
+
+#[link_args="-lgit2"]
+extern {
fn git_strarray_free(++array: *git_strarray);
@@ -465,19 +468,19 @@ fn giterr_last() -> *git_error;
fn giterr_clear();
-fn git_oid_fromstr(++out: *git_oid, ++str: *c_char) -> c_int;
+fn git_oid_fromstr(++out: *git_oid, ++str: *c_schar) -> c_int;
-fn git_oid_fromstrn(++out: *git_oid, ++str: *c_char, ++length: size_t) -> c_int;
+fn git_oid_fromstrn(++out: *git_oid, ++str: *c_schar, ++length: size_t) -> c_int;
fn git_oid_fromraw(++out: *git_oid, ++raw: *c_uchar);
-fn git_oid_fmt(++str: *c_char, ++oid: *git_oid);
+fn git_oid_fmt(++str: *c_schar, ++oid: *git_oid);
-fn git_oid_pathfmt(++str: *c_char, ++oid: *git_oid);
+fn git_oid_pathfmt(++str: *c_schar, ++oid: *git_oid);
-fn git_oid_allocfmt(++oid: *git_oid) -> *c_char;
+fn git_oid_allocfmt(++oid: *git_oid) -> *c_schar;
-fn git_oid_tostr(++out: *c_char, ++n: size_t, ++oid: *git_oid) -> *c_char;
+fn git_oid_tostr(++out: *c_schar, ++n: size_t, ++oid: *git_oid) -> *c_schar;
fn git_oid_cpy(++out: *git_oid, ++src: *git_oid);
@@ -485,31 +488,31 @@ fn git_oid_cmp(++a: *git_oid, ++b: *git_oid) -> c_int;
fn git_oid_ncmp(++a: *git_oid, ++b: *git_oid, ++len: c_uint) -> c_int;
-fn git_oid_streq(++a: *git_oid, ++str: *c_char) -> c_int;
+fn git_oid_streq(++a: *git_oid, ++str: *c_schar) -> c_int;
fn git_oid_iszero(++a: *git_oid) -> c_int;
fn git_oid_shorten_new(++min_length: size_t) -> *git_oid_shorten;
-fn git_oid_shorten_add(++os: *git_oid_shorten, ++text_oid: *c_char) -> c_int;
+fn git_oid_shorten_add(++os: *git_oid_shorten, ++text_oid: *c_schar) -> c_int;
fn git_oid_shorten_free(++os: *git_oid_shorten);
-fn git_signature_new(++sig_out: **git_signature, ++name: *c_char, ++email: *c_char, ++time: git_time_t, ++offset: c_int) -> c_int;
+fn git_signature_new(++sig_out: **git_signature, ++name: *c_schar, ++email: *c_schar, ++time: git_time_t, ++offset: c_int) -> c_int;
-fn git_signature_now(++sig_out: **git_signature, ++name: *c_char, ++email: *c_char) -> c_int;
+fn git_signature_now(++sig_out: **git_signature, ++name: *c_schar, ++email: *c_schar) -> c_int;
fn git_signature_dup(++sig: *git_signature) -> *git_signature;
fn git_signature_free(++sig: *git_signature);
-fn git_odb_backend_pack(++backend_out: **git_odb_backend, ++objects_dir: *c_char) -> c_int;
+fn git_odb_backend_pack(++backend_out: **git_odb_backend, ++objects_dir: *c_schar) -> c_int;
-fn git_odb_backend_loose(++backend_out: **git_odb_backend, ++objects_dir: *c_char, ++compression_level: c_int, ++do_fsync: c_int) -> c_int;
+fn git_odb_backend_loose(++backend_out: **git_odb_backend, ++objects_dir: *c_schar, ++compression_level: c_int, ++do_fsync: c_int) -> c_int;
fn git_odb_new(++out: **git_odb) -> c_int;
-fn git_odb_open(++out: **git_odb, ++objects_dir: *c_char) -> c_int;
+fn git_odb_open(++out: **git_odb, ++objects_dir: *c_schar) -> c_int;
fn git_odb_add_backend(++odb: *git_odb, ++backend: *git_odb_backend, ++priority: c_int) -> c_int;
@@ -533,7 +536,7 @@ fn git_odb_open_rstream(++stream: **git_odb_stream, ++db: *git_odb, ++oid: *git_
fn git_odb_hash(++id: *git_oid, ++data: *c_void, ++len: size_t, ++_type: git_otype) -> c_int;
-fn git_odb_hashfile(++out: *git_oid, ++path: *c_char, ++_type: git_otype) -> c_int;
+fn git_odb_hashfile(++out: *git_oid, ++path: *c_schar, ++_type: git_otype) -> c_int;
fn git_odb_object_free(++object: *git_odb_object);
@@ -545,15 +548,15 @@ fn git_odb_object_size(++object: *git_odb_object) -> size_t;
fn git_odb_object_type(++object: *git_odb_object) -> git_otype;
-fn git_repository_open(++repository: **git_repository, ++path: *c_char) -> c_int;
+fn git_repository_open(++repository: **git_repository, ++path: *c_schar) -> c_int;
-fn git_repository_discover(++repository_path: *c_char, ++size: size_t, ++start_path: *c_char, ++across_fs: c_int, ++ceiling_dirs: *c_char) -> c_int;
+fn git_repository_discover(++repository_path: *c_schar, ++size: size_t, ++start_path: *c_schar, ++across_fs: c_int, ++ceiling_dirs: *c_schar) -> c_int;
-fn git_repository_open_ext(++repo: **git_repository, ++start_path: *c_char, ++flags: uint32_t, ++ceiling_dirs: *c_char) -> c_int;
+fn git_repository_open_ext(++repo: **git_repository, ++start_path: *c_schar, ++flags: uint32_t, ++ceiling_dirs: *c_schar) -> c_int;
fn git_repository_free(++repo: *git_repository);
-fn git_repository_init(++repo_out: **git_repository, ++path: *c_char, ++is_bare: c_uint) -> c_int;
+fn git_repository_init(++repo_out: **git_repository, ++path: *c_schar, ++is_bare: c_uint) -> c_int;
fn git_repository_head(++head_out: **git_reference, ++repo: *git_repository) -> c_int;
@@ -563,11 +566,11 @@ fn git_repository_head_orphan(++repo: *git_repository) -> c_int;
fn git_repository_is_empty(++repo: *git_repository) -> c_int;
-fn git_repository_path(++repo: *git_repository) -> *c_char;
+fn git_repository_path(++repo: *git_repository) -> *c_schar;
-fn git_repository_workdir(++repo: *git_repository) -> *c_char;
+fn git_repository_workdir(++repo: *git_repository) -> *c_schar;
-fn git_repository_set_workdir(++repo: *git_repository, ++workdir: *c_char) -> c_int;
+fn git_repository_set_workdir(++repo: *git_repository, ++workdir: *c_schar) -> c_int;
fn git_repository_is_bare(++repo: *git_repository) -> c_int;
@@ -589,19 +592,19 @@ fn git_revwalk_reset(++walker: *git_revwalk);
fn git_revwalk_push(++walk: *git_revwalk, ++oid: *git_oid) -> c_int;
-fn git_revwalk_push_glob(++walk: *git_revwalk, ++glob: *c_char) -> c_int;
+fn git_revwalk_push_glob(++walk: *git_revwalk, ++glob: *c_schar) -> c_int;
fn git_revwalk_push_head(++walk: *git_revwalk) -> c_int;
fn git_revwalk_hide(++walk: *git_revwalk, ++oid: *git_oid) -> c_int;
-fn git_revwalk_hide_glob(++walk: *git_revwalk, ++glob: *c_char) -> c_int;
+fn git_revwalk_hide_glob(++walk: *git_revwalk, ++glob: *c_schar) -> c_int;
fn git_revwalk_hide_head(++walk: *git_revwalk) -> c_int;
-fn git_revwalk_push_ref(++walk: *git_revwalk, ++refname: *c_char) -> c_int;
+fn git_revwalk_push_ref(++walk: *git_revwalk, ++refname: *c_schar) -> c_int;
-fn git_revwalk_hide_ref(++walk: *git_revwalk, ++refname: *c_char) -> c_int;
+fn git_revwalk_hide_ref(++walk: *git_revwalk, ++refname: *c_schar) -> c_int;
fn git_revwalk_next(++oid: *git_oid, ++walk: *git_revwalk) -> c_int;
@@ -613,33 +616,33 @@ fn git_revwalk_repository(++walk: *git_revwalk) -> *git_repository;
fn git_merge_base(++out: *git_oid, ++repo: *git_repository, ++one: *git_oid, ++two: *git_oid) -> c_int;
-fn git_reference_lookup(++reference_out: **git_reference, ++repo: *git_repository, ++name: *c_char) -> c_int;
+fn git_reference_lookup(++reference_out: **git_reference, ++repo: *git_repository, ++name: *c_schar) -> c_int;
-fn git_reference_name_to_oid(++out: *git_oid, ++repo: *git_repository, ++name: *c_char) -> c_int;
+fn git_reference_name_to_oid(++out: *git_oid, ++repo: *git_repository, ++name: *c_schar) -> c_int;
-fn git_reference_create_symbolic(++ref_out: **git_reference, ++repo: *git_repository, ++name: *c_char, ++target: *c_char, ++force: c_int) -> c_int;
+fn git_reference_create_symbolic(++ref_out: **git_reference, ++repo: *git_repository, ++name: *c_schar, ++target: *c_schar, ++force: c_int) -> c_int;
-fn git_reference_create_oid(++ref_out: **git_reference, ++repo: *git_repository, ++name: *c_char, ++id: *git_oid, ++force: c_int) -> c_int;
+fn git_reference_create_oid(++ref_out: **git_reference, ++repo: *git_repository, ++name: *c_schar, ++id: *git_oid, ++force: c_int) -> c_int;
-fn git_reference_oid(++ref: *git_reference) -> *git_oid;
+fn git_reference_oid(++_ref: *git_reference) -> *git_oid;
-fn git_reference_target(++ref: *git_reference) -> *c_char;
+fn git_reference_target(++_ref: *git_reference) -> *c_schar;
-fn git_reference_type(++ref: *git_reference) -> git_ref_t;
+fn git_reference_type(++_ref: *git_reference) -> git_ref_t;
-fn git_reference_name(++ref: *git_reference) -> *c_char;
+fn git_reference_name(++_ref: *git_reference) -> *c_schar;
-fn git_reference_resolve(++resolved_ref: **git_reference, ++ref: *git_reference) -> c_int;
+fn git_reference_resolve(++resolved_ref: **git_reference, ++_ref: *git_reference) -> c_int;
-fn git_reference_owner(++ref: *git_reference) -> *git_repository;
+fn git_reference_owner(++_ref: *git_reference) -> *git_repository;
-fn git_reference_set_target(++ref: *git_reference, ++target: *c_char) -> c_int;
+fn git_reference_set_target(++_ref: *git_reference, ++target: *c_schar) -> c_int;
-fn git_reference_set_oid(++ref: *git_reference, ++id: *git_oid) -> c_int;
+fn git_reference_set_oid(++_ref: *git_reference, ++id: *git_oid) -> c_int;
-fn git_reference_rename(++ref: *git_reference, ++new_name: *c_char, ++force: c_int) -> c_int;
+fn git_reference_rename(++_ref: *git_reference, ++new_name: *c_schar, ++force: c_int) -> c_int;
-fn git_reference_delete(++ref: *git_reference) -> c_int;
+fn git_reference_delete(++_ref: *git_reference) -> c_int;
fn git_reference_packall(++repo: *git_repository) -> c_int;
@@ -647,21 +650,21 @@ fn git_reference_list(++array: *git_strarray, ++repo: *git_repository, ++list_fl
fn git_reference_foreach(++repo: *git_repository, ++list_flags: c_uint, ++callback: *u8, ++payload: *c_void) -> c_int;
-fn git_reference_is_packed(++ref: *git_reference) -> c_int;
+fn git_reference_is_packed(++_ref: *git_reference) -> c_int;
-fn git_reference_reload(++ref: *git_reference) -> c_int;
+fn git_reference_reload(++_ref: *git_reference) -> c_int;
-fn git_reference_free(++ref: *git_reference);
+fn git_reference_free(++_ref: *git_reference);
fn git_reference_cmp(++ref1: *git_reference, ++ref2: *git_reference) -> c_int;
-fn git_reflog_read(++reflog: **git_reflog, ++ref: *git_reference) -> c_int;
+fn git_reflog_read(++reflog: **git_reflog, ++_ref: *git_reference) -> c_int;
-fn git_reflog_write(++ref: *git_reference, ++oid_old: *git_oid, ++committer: *git_signature, ++msg: *c_char) -> c_int;
+fn git_reflog_write(++_ref: *git_reference, ++oid_old: *git_oid, ++committer: *git_signature, ++msg: *c_schar) -> c_int;
-fn git_reflog_rename(++ref: *git_reference, ++new_name: *c_char) -> c_int;
+fn git_reflog_rename(++_ref: *git_reference, ++new_name: *c_schar) -> c_int;
-fn git_reflog_delete(++ref: *git_reference) -> c_int;
+fn git_reflog_delete(++_ref: *git_reference) -> c_int;
fn git_reflog_entrycount(++reflog: *git_reflog) -> c_uint;
@@ -673,7 +676,7 @@ fn git_reflog_entry_oidnew(++entry: *git_reflog_entry) -> *git_oid;
fn git_reflog_entry_committer(++entry: *git_reflog_entry) -> *git_signature;
-fn git_reflog_entry_msg(++entry: *git_reflog_entry) -> *c_char;
+fn git_reflog_entry_msg(++entry: *git_reflog_entry) -> *c_schar;
fn git_reflog_free(++reflog: *git_reflog);
@@ -689,9 +692,9 @@ fn git_object_owner(++obj: *git_object) -> *git_repository;
fn git_object_free(++object: *git_object);
-fn git_object_type2string(++_type: git_otype) -> *c_char;
+fn git_object_type2string(++_type: git_otype) -> *c_schar;
-fn git_object_string2type(++str: *c_char) -> git_otype;
+fn git_object_string2type(++str: *c_schar) -> git_otype;
fn git_object_typeisloose(++_type: git_otype) -> c_int;
@@ -701,17 +704,17 @@ fn git_blob_rawcontent(++blob: *git_blob) -> *c_void;
fn git_blob_rawsize(++blob: *git_blob) -> size_t;
-fn git_blob_create_fromfile(++oid: *git_oid, ++repo: *git_repository, ++path: *c_char) -> c_int;
+fn git_blob_create_fromfile(++oid: *git_oid, ++repo: *git_repository, ++path: *c_schar) -> c_int;
-fn git_blob_create_fromdisk(++oid: *git_oid, ++repo: *git_repository, ++path: *c_char) -> c_int;
+fn git_blob_create_fromdisk(++oid: *git_oid, ++repo: *git_repository, ++path: *c_schar) -> c_int;
fn git_blob_create_frombuffer(++oid: *git_oid, ++repo: *git_repository, ++buffer: *c_void, ++len: size_t) -> c_int;
fn git_commit_id(++commit: *git_commit) -> *git_oid;
-fn git_commit_message_encoding(++commit: *git_commit) -> *c_char;
+fn git_commit_message_encoding(++commit: *git_commit) -> *c_schar;
-fn git_commit_message(++commit: *git_commit) -> *c_char;
+fn git_commit_message(++commit: *git_commit) -> *c_schar;
fn git_commit_time(++commit: *git_commit) -> git_time_t;
@@ -731,9 +734,9 @@ fn git_commit_parent(++parent: **git_commit, ++commit: *git_commit, ++n: c_uint)
fn git_commit_parent_oid(++commit: *git_commit, ++n: c_uint) -> *git_oid;
-fn git_commit_create(++oid: *git_oid, ++repo: *git_repository, ++update_ref: *c_char, ++author: *git_signature, ++committer: *git_signature, ++message_encoding: *c_char, ++message: *c_char, ++tree: *git_tree, ++parent_count: c_int, ++parents: **git_commit) -> c_int;
+fn git_commit_create(++oid: *git_oid, ++repo: *git_repository, ++update_ref: *c_schar, ++author: *git_signature, ++committer: *git_signature, ++message_encoding: *c_schar, ++message: *c_schar, ++tree: *git_tree, ++parent_count: c_int, ++parents: **git_commit) -> c_int;
-fn git_commit_create_v(++oid: *git_oid, ++repo: *git_repository, ++update_ref: *c_char, ++author: *git_signature, ++committer: *git_signature, ++message_encoding: *c_char, ++message: *c_char, ++tree: *git_tree, ++parent_count: c_int/* FIXME: variadic function */) -> c_int;
+fn git_commit_create_v(++oid: *git_oid, ++repo: *git_repository, ++update_ref: *c_schar, ++author: *git_signature, ++committer: *git_signature, ++message_encoding: *c_schar, ++message: *c_schar, ++tree: *git_tree, ++parent_count: c_int) -> c_int; /* FIXME: variadic function */
fn git_tag_id(++tag: *git_tag) -> *git_oid;
@@ -743,23 +746,23 @@ fn git_tag_target_oid(++tag: *git_tag) -> *git_oid;
fn git_tag_type(++tag: *git_tag) -> git_otype;
-fn git_tag_name(++tag: *git_tag) -> *c_char;
+fn git_tag_name(++tag: *git_tag) -> *c_schar;
fn git_tag_tagger(++tag: *git_tag) -> *git_signature;
-fn git_tag_message(++tag: *git_tag) -> *c_char;
+fn git_tag_message(++tag: *git_tag) -> *c_schar;
-fn git_tag_create(++oid: *git_oid, ++repo: *git_repository, ++tag_name: *c_char, ++target: *git_object, ++tagger: *git_signature, ++message: *c_char, ++force: c_int) -> c_int;
+fn git_tag_create(++oid: *git_oid, ++repo: *git_repository, ++tag_name: *c_schar, ++target: *git_object, ++tagger: *git_signature, ++message: *c_schar, ++force: c_int) -> c_int;
-fn git_tag_create_frombuffer(++oid: *git_oid, ++repo: *git_repository, ++buffer: *c_char, ++force: c_int) -> c_int;
+fn git_tag_create_frombuffer(++oid: *git_oid, ++repo: *git_repository, ++buffer: *c_schar, ++force: c_int) -> c_int;
-fn git_tag_create_lightweight(++oid: *git_oid, ++repo: *git_repository, ++tag_name: *c_char, ++target: *git_object, ++force: c_int) -> c_int;
+fn git_tag_create_lightweight(++oid: *git_oid, ++repo: *git_repository, ++tag_name: *c_schar, ++target: *git_object, ++force: c_int) -> c_int;
-fn git_tag_delete(++repo: *git_repository, ++tag_name: *c_char) -> c_int;
+fn git_tag_delete(++repo: *git_repository, ++tag_name: *c_schar) -> c_int;
fn git_tag_list(++tag_names: *git_strarray, ++repo: *git_repository) -> c_int;
-fn git_tag_list_match(++tag_names: *git_strarray, ++pattern: *c_char, ++repo: *git_repository) -> c_int;
+fn git_tag_list_match(++tag_names: *git_strarray, ++pattern: *c_schar, ++repo: *git_repository) -> c_int;
fn git_tag_peel(++tag_target: **git_object, ++tag: *git_tag) -> c_int;
@@ -767,13 +770,13 @@ fn git_tree_id(++tree: *git_tree) -> *git_oid;
fn git_tree_entrycount(++tree: *git_tree) -> c_uint;
-fn git_tree_entry_byname(++tree: *git_tree, ++filename: *c_char) -> *git_tree_entry;
+fn git_tree_entry_byname(++tree: *git_tree, ++filename: *c_schar) -> *git_tree_entry;
fn git_tree_entry_byindex(++tree: *git_tree, ++idx: c_uint) -> *git_tree_entry;
fn git_tree_entry_attributes(++entry: *git_tree_entry) -> c_uint;
-fn git_tree_entry_name(++entry: *git_tree_entry) -> *c_char;
+fn git_tree_entry_name(++entry: *git_tree_entry) -> *c_schar;
fn git_tree_entry_id(++entry: *git_tree_entry) -> *git_oid;
@@ -789,17 +792,17 @@ fn git_treebuilder_clear(++bld: *git_treebuilder);
fn git_treebuilder_free(++bld: *git_treebuilder);
-fn git_treebuilder_get(++bld: *git_treebuilder, ++filename: *c_char) -> *git_tree_entry;
+fn git_treebuilder_get(++bld: *git_treebuilder, ++filename: *c_schar) -> *git_tree_entry;
-fn git_treebuilder_insert(++entry_out: **git_tree_entry, ++bld: *git_treebuilder, ++filename: *c_char, ++id: *git_oid, ++attributes: c_uint) -> c_int;
+fn git_treebuilder_insert(++entry_out: **git_tree_entry, ++bld: *git_treebuilder, ++filename: *c_schar, ++id: *git_oid, ++attributes: c_uint) -> c_int;
-fn git_treebuilder_remove(++bld: *git_treebuilder, ++filename: *c_char) -> c_int;
+fn git_treebuilder_remove(++bld: *git_treebuilder, ++filename: *c_schar) -> c_int;
fn git_treebuilder_filter(++bld: *git_treebuilder, ++filter: *u8, ++payload: *c_void);
fn git_treebuilder_write(++oid: *git_oid, ++repo: *git_repository, ++bld: *git_treebuilder) -> c_int;
-fn git_tree_get_subtree(++subtree: **git_tree, ++root: *git_tree, ++subtree_path: *c_char) -> c_int;
+fn git_tree_get_subtree(++subtree: **git_tree, ++root: *git_tree, ++subtree_path: *c_schar) -> c_int;
fn git_tree_walk(++tree: *git_tree, ++callback: git_treewalk_cb, ++mode: c_int, ++payload: *c_void) -> c_int;
@@ -823,7 +826,7 @@ fn git_diff_print_patch(++diff: *git_diff_list, ++cb_data: *c_void, ++print_cb:
fn git_diff_blobs(++old_blob: *git_blob, ++new_blob: *git_blob, ++options: *git_diff_options, ++cb_data: *c_void, ++file_cb: git_diff_file_fn, ++hunk_cb: git_diff_hunk_fn, ++line_cb: git_diff_data_fn) -> c_int;
-fn git_index_open(++index: **git_index, ++index_path: *c_char) -> c_int;
+fn git_index_open(++index: **git_index, ++index_path: *c_schar) -> c_int;
fn git_index_clear(++index: *git_index);
@@ -833,15 +836,15 @@ fn git_index_read(++index: *git_index) -> c_int;
fn git_index_write(++index: *git_index) -> c_int;
-fn git_index_find(++index: *git_index, ++path: *c_char) -> c_int;
+fn git_index_find(++index: *git_index, ++path: *c_schar) -> c_int;
fn git_index_uniq(++index: *git_index);
-fn git_index_add(++index: *git_index, ++path: *c_char, ++stage: c_int) -> c_int;
+fn git_index_add(++index: *git_index, ++path: *c_schar, ++stage: c_int) -> c_int;
fn git_index_add2(++index: *git_index, ++source_entry: *git_index_entry) -> c_int;
-fn git_index_append(++index: *git_index, ++path: *c_char, ++stage: c_int) -> c_int;
+fn git_index_append(++index: *git_index, ++path: *c_schar, ++stage: c_int) -> c_int;
fn git_index_append2(++index: *git_index, ++source_entry: *git_index_entry) -> c_int;
@@ -853,7 +856,7 @@ fn git_index_entrycount(++index: *git_index) -> c_uint;
fn git_index_entrycount_unmerged(++index: *git_index) -> c_uint;
-fn git_index_get_unmerged_bypath(++index: *git_index, ++path: *c_char) -> *git_index_entry_unmerged;
+fn git_index_get_unmerged_bypath(++index: *git_index, ++path: *c_schar) -> *git_index_entry_unmerged;
fn git_index_get_unmerged_byindex(++index: *git_index, ++n: c_uint) -> *git_index_entry_unmerged;
@@ -861,59 +864,59 @@ fn git_index_entry_stage(++entry: *git_index_entry) -> c_int;
fn git_index_read_tree(++index: *git_index, ++tree: *git_tree) -> c_int;
-fn git_config_find_global(++global_config_path: *c_char, ++length: size_t) -> c_int;
+fn git_config_find_global(++global_config_path: *c_schar, ++length: size_t) -> c_int;
-fn git_config_find_system(++system_config_path: *c_char, ++length: size_t) -> c_int;
+fn git_config_find_system(++system_config_path: *c_schar, ++length: size_t) -> c_int;
fn git_config_open_global(++out: **git_config) -> c_int;
-fn git_config_file__ondisk(++out: **struct_git_config_file, ++path: *c_char) -> c_int;
+fn git_config_file__ondisk(++out: **Struct_git_config_file, ++path: *c_schar) -> c_int;
fn git_config_new(++out: **git_config) -> c_int;
fn git_config_add_file(++cfg: *git_config, ++file: *git_config_file, ++priority: c_int) -> c_int;
-fn git_config_add_file_ondisk(++cfg: *git_config, ++path: *c_char, ++priority: c_int) -> c_int;
+fn git_config_add_file_ondisk(++cfg: *git_config, ++path: *c_schar, ++priority: c_int) -> c_int;
-fn git_config_open_ondisk(++cfg: **git_config, ++path: *c_char) -> c_int;
+fn git_config_open_ondisk(++cfg: **git_config, ++path: *c_schar) -> c_int;
fn git_config_free(++cfg: *git_config);
-fn git_config_get_int32(++out: *int32_t, ++cfg: *git_config, ++name: *c_char) -> c_int;
+fn git_config_get_int32(++out: *int32_t, ++cfg: *git_config, ++name: *c_schar) -> c_int;
-fn git_config_get_int64(++out: *int64_t, ++cfg: *git_config, ++name: *c_char) -> c_int;
+fn git_config_get_int64(++out: *int64_t, ++cfg: *git_config, ++name: *c_schar) -> c_int;
-fn git_config_get_bool(++out: *c_int, ++cfg: *git_config, ++name: *c_char) -> c_int;
+fn git_config_get_bool(++out: *c_int, ++cfg: *git_config, ++name: *c_schar) -> c_int;
-fn git_config_get_string(++out: **c_char, ++cfg: *git_config, ++name: *c_char) -> c_int;
+fn git_config_get_string(++out: **c_schar, ++cfg: *git_config, ++name: *c_schar) -> c_int;
-fn git_config_get_multivar(++cfg: *git_config, ++name: *c_char, ++regexp: *c_char, ++_fn: *u8, ++data: *c_void) -> c_int;
+fn git_config_get_multivar(++cfg: *git_config, ++name: *c_schar, ++regexp: *c_schar, ++_fn: *u8, ++data: *c_void) -> c_int;
-fn git_config_set_int32(++cfg: *git_config, ++name: *c_char, ++value: int32_t) -> c_int;
+fn git_config_set_int32(++cfg: *git_config, ++name: *c_schar, ++value: int32_t) -> c_int;
-fn git_config_set_int64(++cfg: *git_config, ++name: *c_char, ++value: int64_t) -> c_int;
+fn git_config_set_int64(++cfg: *git_config, ++name: *c_schar, ++value: int64_t) -> c_int;
-fn git_config_set_bool(++cfg: *git_config, ++name: *c_char, ++value: c_int) -> c_int;
+fn git_config_set_bool(++cfg: *git_config, ++name: *c_schar, ++value: c_int) -> c_int;
-fn git_config_set_string(++cfg: *git_config, ++name: *c_char, ++value: *c_char) -> c_int;
+fn git_config_set_string(++cfg: *git_config, ++name: *c_schar, ++value: *c_schar) -> c_int;
-fn git_config_set_multivar(++cfg: *git_config, ++name: *c_char, ++regexp: *c_char, ++value: *c_char) -> c_int;
+fn git_config_set_multivar(++cfg: *git_config, ++name: *c_schar, ++regexp: *c_schar, ++value: *c_schar) -> c_int;
-fn git_config_delete(++cfg: *git_config, ++name: *c_char) -> c_int;
+fn git_config_delete(++cfg: *git_config, ++name: *c_schar) -> c_int;
fn git_config_foreach(++cfg: *git_config, ++callback: *u8, ++payload: *c_void) -> c_int;
-fn git_config_get_mapped(++out: *c_int, ++cfg: *git_config, ++name: *c_char, ++maps: *git_cvar_map, ++map_n: size_t) -> c_int;
+fn git_config_get_mapped(++out: *c_int, ++cfg: *git_config, ++name: *c_schar, ++maps: *git_cvar_map, ++map_n: size_t) -> c_int;
-fn git_refspec_src(++refspec: *git_refspec) -> *c_char;
+fn git_refspec_src(++refspec: *git_refspec) -> *c_schar;
-fn git_refspec_dst(++refspec: *git_refspec) -> *c_char;
+fn git_refspec_dst(++refspec: *git_refspec) -> *c_schar;
-fn git_refspec_src_matches(++refspec: *git_refspec, ++refname: *c_char) -> c_int;
+fn git_refspec_src_matches(++refspec: *git_refspec, ++refname: *c_schar) -> c_int;
-fn git_refspec_transform(++out: *c_char, ++outlen: size_t, ++spec: *git_refspec, ++name: *c_char) -> c_int;
+fn git_refspec_transform(++out: *c_schar, ++outlen: size_t, ++spec: *git_refspec, ++name: *c_schar) -> c_int;
-fn git_indexer_stream_new(++out: **git_indexer_stream, ++gitdir: *c_char) -> c_int;
+fn git_indexer_stream_new(++out: **git_indexer_stream, ++gitdir: *c_schar) -> c_int;
fn git_indexer_stream_add(++idx: *git_indexer_stream, ++data: *c_void, ++size: size_t, ++stats: *git_indexer_stats) -> c_int;
@@ -923,7 +926,7 @@ fn git_indexer_stream_hash(++idx: *git_indexer_stream) -> *git_oid;
fn git_indexer_stream_free(++idx: *git_indexer_stream);
-fn git_indexer_new(++out: **git_indexer, ++packname: *c_char) -> c_int;
+fn git_indexer_new(++out: **git_indexer, ++packname: *c_schar) -> c_int;
fn git_indexer_run(++idx: *git_indexer, ++stats: *git_indexer_stats) -> c_int;
@@ -933,21 +936,21 @@ fn git_indexer_hash(++idx: *git_indexer) -> *git_oid;
fn git_indexer_free(++idx: *git_indexer);
-fn git_remote_new(++out: **git_remote, ++repo: *git_repository, ++name: *c_char, ++url: *c_char, ++fetch: *c_char) -> c_int;
+fn git_remote_new(++out: **git_remote, ++repo: *git_repository, ++name: *c_schar, ++url: *c_schar, ++fetch: *c_schar) -> c_int;
-fn git_remote_load(++out: **git_remote, ++repo: *git_repository, ++name: *c_char) -> c_int;
+fn git_remote_load(++out: **git_remote, ++repo: *git_repository, ++name: *c_schar) -> c_int;
fn git_remote_save(++remote: *git_remote) -> c_int;
-fn git_remote_name(++remote: *git_remote) -> *c_char;
+fn git_remote_name(++remote: *git_remote) -> *c_schar;
-fn git_remote_url(++remote: *git_remote) -> *c_char;
+fn git_remote_url(++remote: *git_remote) -> *c_schar;
-fn git_remote_set_fetchspec(++remote: *git_remote, ++spec: *c_char) -> c_int;
+fn git_remote_set_fetchspec(++remote: *git_remote, ++spec: *c_schar) -> c_int;
fn git_remote_fetchspec(++remote: *git_remote) -> *git_refspec;
-fn git_remote_set_pushspec(++remote: *git_remote, ++spec: *c_char) -> c_int;
+fn git_remote_set_pushspec(++remote: *git_remote, ++spec: *c_schar) -> c_int;
fn git_remote_pushspec(++remote: *git_remote) -> *git_refspec;
@@ -965,66 +968,66 @@ fn git_remote_free(++remote: *git_remote);
fn git_remote_update_tips(++remote: *git_remote, ++cb: *u8) -> c_int;
-fn git_remote_valid_url(++url: *c_char) -> c_int;
+fn git_remote_valid_url(++url: *c_schar) -> c_int;
-fn git_remote_supported_url(++url: *c_char) -> c_int;
+fn git_remote_supported_url(++url: *c_schar) -> c_int;
fn git_remote_list(++remotes_list: *git_strarray, ++repo: *git_repository) -> c_int;
-fn git_remote_add(++out: **git_remote, ++repo: *git_repository, ++name: *c_char, ++url: *c_char) -> c_int;
+fn git_remote_add(++out: **git_remote, ++repo: *git_repository, ++name: *c_schar, ++url: *c_schar) -> c_int;
fn git_status_foreach(++repo: *git_repository, ++callback: *u8, ++payload: *c_void) -> c_int;
fn git_status_foreach_ext(++repo: *git_repository, ++opts: *git_status_options, ++callback: *u8, ++payload: *c_void) -> c_int;
-fn git_status_file(++status_flags: *c_uint, ++repo: *git_repository, ++path: *c_char) -> c_int;
+fn git_status_file(++status_flags: *c_uint, ++repo: *git_repository, ++path: *c_schar) -> c_int;
-fn git_status_should_ignore(++ignored: *c_int, ++repo: *git_repository, ++path: *c_char) -> c_int;
+fn git_status_should_ignore(++ignored: *c_int, ++repo: *git_repository, ++path: *c_schar) -> c_int;
fn git_submodule_foreach(++repo: *git_repository, ++callback: *u8, ++payload: *c_void) -> c_int;
-fn git_submodule_lookup(++submodule: **git_submodule, ++repo: *git_repository, ++name: *c_char) -> c_int;
+fn git_submodule_lookup(++submodule: **git_submodule, ++repo: *git_repository, ++name: *c_schar) -> c_int;
-fn git_note_read(++note: **git_note, ++repo: *git_repository, ++notes_ref: *c_char, ++oid: *git_oid) -> c_int;
+fn git_note_read(++note: **git_note, ++repo: *git_repository, ++notes_ref: *c_schar, ++oid: *git_oid) -> c_int;
-fn git_note_message(++note: *git_note) -> *c_char;
+fn git_note_message(++note: *git_note) -> *c_schar;
fn git_note_oid(++note: *git_note) -> *git_oid;
-fn git_note_create(++out: *git_oid, ++repo: *git_repository, ++author: *git_signature, ++committer: *git_signature, ++notes_ref: *c_char, ++oid: *git_oid, ++note: *c_char) -> c_int;
+fn git_note_create(++out: *git_oid, ++repo: *git_repository, ++author: *git_signature, ++committer: *git_signature, ++notes_ref: *c_schar, ++oid: *git_oid, ++note: *c_schar) -> c_int;
-fn git_note_remove(++repo: *git_repository, ++notes_ref: *c_char, ++author: *git_signature, ++committer: *git_signature, ++oid: *git_oid) -> c_int;
+fn git_note_remove(++repo: *git_repository, ++notes_ref: *c_schar, ++author: *git_signature, ++committer: *git_signature, ++oid: *git_oid) -> c_int;
fn git_note_free(++note: *git_note);
-fn git_note_default_ref(++out: **c_char, ++repo: *git_repository) -> c_int;
+fn git_note_default_ref(++out: **c_schar, ++repo: *git_repository) -> c_int;
+
+fn git_note_foreach(++repo: *git_repository, ++notes_ref: *c_schar, ++note_cb: *u8, ++payload: *c_void) -> c_int;
-fn git_note_foreach(++repo: *git_repository, ++notes_ref: *c_char, ++note_cb: *u8, ++payload: *c_void) -> c_int;
}
-// Inlines
-mod inline {
- fn git_commit_lookup(++commit: **git_commit, ++repo: *git_repository, oid: *git_oid) -> c_int {
- ret bindgen::git_object_lookup(commit as **git_object, repo, oid, GIT_OBJ_COMMIT);
- }
- fn git_commit_lookup_prefix(++commit: **git_commit, ++repo: *git_repository, oid: *git_oid, len: c_uint) -> c_int {
- ret bindgen::git_object_lookup_prefix(commit as **git_object, repo, oid, len, GIT_OBJ_COMMIT);
- }
+// Ports of inline functions, which bindgen can't handle automatically
+fn git_commit_lookup(++commit: **git_commit, ++repo: *git_repository, oid: *git_oid) -> c_int {
+ return git_object_lookup(commit as **git_object, repo, oid, GIT_OBJ_COMMIT);
+}
+
+fn git_commit_lookup_prefix(++commit: **git_commit, ++repo: *git_repository, oid: *git_oid, len: c_uint) -> c_int {
+ return git_object_lookup_prefix(commit as **git_object, repo, oid, len, GIT_OBJ_COMMIT);
+}
- fn git_commit_free(commit: *git_commit) {
- bindgen::git_object_free(commit as *git_object);
- }
+fn git_commit_free(commit: *git_commit) {
+ git_object_free(commit as *git_object);
+}
- fn git_tree_lookup(++tree: **git_tree, ++repo: *git_repository, oid: *git_oid) -> c_int {
- ret bindgen::git_object_lookup(tree as **git_object, repo, oid, GIT_OBJ_TREE);
- }
+fn git_tree_lookup(++tree: **git_tree, ++repo: *git_repository, oid: *git_oid) -> c_int {
+ return git_object_lookup(tree as **git_object, repo, oid, GIT_OBJ_TREE);
+}
- fn git_tree_lookup_prefix(++tree: **git_tree, ++repo: *git_repository, oid: *git_oid, len: c_uint) -> c_int {
- ret bindgen::git_object_lookup_prefix(tree as **git_object, repo, oid, len, GIT_OBJ_TREE);
- }
+fn git_tree_lookup_prefix(++tree: **git_tree, ++repo: *git_repository, oid: *git_oid, len: c_uint) -> c_int {
+ return git_object_lookup_prefix(tree as **git_object, repo, oid, len, GIT_OBJ_TREE);
+}
- fn git_tree_free(tree: *git_tree) {
- bindgen::git_object_free(tree as *git_object);
- }
+fn git_tree_free(tree: *git_tree) {
+ git_object_free(tree as *git_object);
}
View
53 git2/commit.rs
@@ -1,73 +1,76 @@
-use std;
+extern mod std;
-import c;
-import signature;
-import libc::types::os::arch::c95::{c_char,c_int,c_uint};
-import libc::types::common::c95::{c_void};
+use mod c;
+use mod signature;
+use libc::types::os::arch::c95::{c_char,c_int,c_uint};
+use libc::types::common::c95::{c_void};
-class Commit {
- let c_commit: *c::git_commit;
-
- new(c_commit: *c::git_commit) {
- self.c_commit = c_commit;
- }
+pub struct Commit {
+ c_commit: *c::git_commit,
drop {
- c::bindgen::git_object_free(self.c_commit as *c::git_object);
+ if self.c_commit != ptr::null() {
+ c::git_object_free(self.c_commit as *c::git_object);
+ }
}
+}
+pub fn Commit(c_commit: *c::git_commit) -> Commit {
+ return Commit{ c_commit: c_commit };
+}
+impl Commit {
fn id() -> ~str {
- let c_oid = c::bindgen::git_commit_id(self.c_commit);
+ let c_oid = c::git_commit_id(self.c_commit);
// TODO
fail;
}
- fn timestamp() -> std::time::tm {
+ fn timestamp() -> std::time::Tm {
// TODO finish me off
- let time = c::bindgen::git_commit_time(self.c_commit);
- let time_offset = c::bindgen::git_commit_time_offset(self.c_commit);
+ let time = c::git_commit_time(self.c_commit);
+ let time_offset = c::git_commit_time_offset(self.c_commit);
// TODO offset is minutes from UTC, remember
fail;
}
- fn message() -> str unsafe {
+ fn message() -> ~str unsafe {
// TODO: git_commit_message_encoding, should decode this
- ret str::unsafe::from_c_str(c::bindgen::git_commit_message(self.c_commit));
+ return str::raw::from_c_str(c::git_commit_message(self.c_commit));
}
fn author() -> signature::Signature {
- ret signature::Signature(c::bindgen::git_commit_author(self.c_commit));
+ return signature::Signature(c::git_commit_author(self.c_commit));
}
fn committer() -> signature::Signature {
- ret signature::Signature(c::bindgen::git_commit_committer(self.c_commit));
+ return signature::Signature(c::git_commit_committer(self.c_commit));
}
fn parents() -> ~[Commit] {
- let parent_ct = c::bindgen::git_commit_parentcount(self.c_commit) as uint;
+ let parent_ct = c::git_commit_parentcount(self.c_commit) as uint;
//let parents: ~[Commit] = ~[];
let c_commit: *c::git_commit = ptr::null();
let mut retval: c_int = 0;
//vec::reserve(parents, parent_ct);
// TODO wish this were a map to avoid the mut
- //ret vec::from_fn(parent_ct, |i| {
+ //return vec::from_fn(parent_ct, |i| {
let parents = do vec::from_fn(parent_ct) |i| {
- retval = c::bindgen::git_commit_parent(ptr::addr_of(c_commit), self.c_commit, i as c_uint);
+ retval = c::git_commit_parent(ptr::addr_of(&c_commit), self.c_commit, i as c_uint);
if retval != 0 {
fail;
}
- //ret Commit(c_commit);
+ //return Commit(c_commit);
Commit(c_commit)
// TODO lazy retrieval?
// GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned int n);
};
- ret parents;
+ return parents;
}
// TODO
View
11 git2/git2.rc
@@ -2,10 +2,11 @@
#[comment = "Rust bindings for git2"];
#[crate_type = "lib"];
+#[legacy_exports]
mod c;
-mod commit;
-mod index;
-mod objectid;
-mod repository;
-mod signature;
+pub mod commit;
+pub mod index;
+pub mod objectid;
+pub mod repository;
+pub mod signature;
View
41 git2/index.rs
@@ -1,21 +1,28 @@
-use std;
+extern mod std;
-import c;
-import objectid;
-import libc::types::os::arch::c95::{c_char,c_int,c_uint};
-import libc::types::common::c95::{c_void};
+use mod c;
+use mod objectid;
+use libc::types::os::arch::c95::{c_char,c_int,c_uint};
+use libc::types::common::c95::{c_void};
-class Index {
- let c_index: *c::git_index;
+pub struct Index {
+ c_index: *c::git_index,
- new(c_index: *c::git_index) {
- self.c_index = c_index;
+ drop {
+ if self.c_index != ptr::null() {
+ c::git_index_free(self.c_index);
+ }
}
+}
+pub fn Index(c_index: *c::git_index) -> Index {
+ return Index{ c_index: c_index };
+}
- fn add(path: str) {
+impl Index {
+ fn add(path: &str) {
let mut retval: c_int = 0;
do str::as_c_str(path) |bytes| {
- retval = c::bindgen::git_index_add(self.c_index, bytes, 0);
+ retval = c::git_index_add(self.c_index, bytes, 0);
}
if retval != 0 {
@@ -25,24 +32,20 @@ class Index {
fn write() -> c::git_oid {
let mut retval: c_int = 0;
- retval = c::bindgen::git_index_write(self.c_index);
+ retval = c::git_index_write(self.c_index);
if retval != 0 {
fail;
}
- let c_oid: c::git_oid = objectid::BLANK_OID();
- retval = c::bindgen::git_tree_create_fromindex(ptr::addr_of(c_oid), self.c_index);
+ let c_oid: c::git_oid = objectid::BLANK_OID;
+ retval = c::git_tree_create_fromindex(ptr::addr_of(&c_oid), self.c_index);
if retval != 0 {
fail;
}
- ret c_oid;
- }
-
- drop {
- c::bindgen::git_index_free(self.c_index);
+ return c_oid;
}
}
View
32 git2/objectid.rs
@@ -1,29 +1,33 @@
-use std;
+extern mod std;
-import c;
-import libc::types::os::arch::c95::{c_char,c_int,c_uchar,c_uint};
-import libc::types::common::c95::{c_void};
+use mod c;
+use libc::types::os::arch::c95::{c_char,c_int,c_uchar,c_uint};
+use libc::types::common::c95::{c_void};
//const OBJECTID_RAW_SIZE: uint = c::GIT_OID_RAWSZ;
//const OBJECTID_HEX_SIZE: uint = c::GIT_OID_HEXSZ;
// TODO: minprefixlen
// TODO what the fuck
-fn BLANK_OID() -> c::git_oid {
- ret { id: (0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar), };
-}
-
+//pub fn BLANK_OID() -> c::git_oid {
+ //return { id: (0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar, 0 as c_uchar), };
+//}
+pub const BLANK_OID: c::git_oid = c::Struct__git_oid{ id: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] };
-class ObjectID {
- let c_oid: *c::git_oid;
- new(c_oid: *c::git_oid) {
- self.c_oid = c_oid;
- }
+struct ObjectID {
+ c_oid: *c::git_oid,
drop {
- //c::bindgen::git_object_free(self.c_commit as *c::git_object);
+ //c::git_object_free(self.c_commit as *c::git_object);
}
// TODO not done...
}
+fn ObjectID(c_oid: *c::git_oid) -> ObjectID {
+ return ObjectID{ c_oid: c_oid };
+}
+
+impl ObjectID {
+ // ...
+}
View
79 git2/repository.rs
@@ -1,12 +1,12 @@
-use std;
+extern mod std;
-import c;
-import commit;
-import index;
-import objectid;
-import signature;
-import libc::types::os::arch::c95::{c_char,c_int,c_uint};
-import libc::types::common::c95::{c_void};
+use mod c;
+use mod commit;
+use mod index;
+use mod objectid;
+use mod signature;
+use libc::types::os::arch::c95::{c_char,c_int,c_uint};
+use libc::types::common::c95::{c_void};
// TODO:
// - ...
@@ -15,32 +15,35 @@ import libc::types::common::c95::{c_void};
fn maybe_fail(retval: int) {}
extern fn status_foreach_callback(path: *c_char, stat: c_uint, payload: *c_void) -> c_int unsafe {
- let path_str = str::unsafe::from_c_str(path);
- let f: *fn(str, uint) = unsafe::reinterpret_cast(payload);
+ let path_str = str::raw::from_c_str(path);
+ let f: *fn(&str, uint) = cast::reinterpret_cast(&payload);
(*f)(path_str, stat as uint);
- ret 0;
+ return 0;
}
-class Repository {
- let c_repository: *c::git_repository;
-
- new(c_repository: *c::git_repository) {
- self.c_repository = c_repository;
- }
+pub struct Repository {
+ c_repository: *c::git_repository,
drop {
- c::bindgen::git_repository_free(self.c_repository);
+ if self.c_repository != ptr::null() {
+ c::git_repository_free(self.c_repository);
+ }
}
+}
+pub fn Repository(c_repository: *c::git_repository) -> Repository {
+ return Repository{ c_repository: c_repository };
+}
- fn path() -> str unsafe {
- ret str::unsafe::from_c_str(
- c::bindgen::git_repository_path(self.c_repository));
+impl Repository {
+ fn path() -> ~str unsafe {
+ return str::raw::from_c_str(
+ c::git_repository_path(self.c_repository));
}
- fn for_status(f: fn(str, uint)) unsafe {
- c::bindgen::git_status_foreach(self.c_repository, status_foreach_callback, unsafe::reinterpret_cast(ptr::addr_of(f)));
+ fn for_status(f: fn(&str, uint)) unsafe {
+ c::git_status_foreach(self.c_repository, status_foreach_callback, cast::reinterpret_cast(&ptr::addr_of(&f)));
}
// TODO this should probably return the same index object every time?
@@ -48,22 +51,22 @@ class Repository {
let mut retval: c_int = 0;
let c_index: *c::git_index = ptr::null();
- retval = c::bindgen::git_repository_index(ptr::addr_of(c_index), self.c_repository);
+ retval = c::git_repository_index(ptr::addr_of(&c_index), self.c_repository);
if retval != 0 {
fail;
}
- ret index::Index(c_index);
+ return index::Index(c_index);
}
// TODO should this accept a tree, or use current index automatically...?
- fn commit(tree_oid: c::git_oid, message: str, author: signature::Signature) -> commit::Commit {
- let c_oid: c::git_oid = objectid::BLANK_OID();
+ fn commit(tree_oid: c::git_oid, message: &str, author: signature::Signature) -> commit::Commit {
+ let c_oid: c::git_oid = objectid::BLANK_OID;
let mut retval: c_int = 0;
let c_tree: *c::git_tree = ptr::null();
- retval = c::inline::git_tree_lookup(ptr::addr_of(c_tree), self.c_repository, ptr::addr_of(tree_oid));
+ retval = c::git_tree_lookup(ptr::addr_of(&c_tree), self.c_repository, ptr::addr_of(&tree_oid));
if retval != 0 {
fail;
@@ -71,8 +74,8 @@ class Repository {
do str::as_c_str(message) |message_bytes| {
do str::as_c_str("HEAD") |ref_name_bytes| {
- retval = c::bindgen::git_commit_create(
- ptr::addr_of(c_oid),
+ retval = c::git_commit_create(
+ ptr::addr_of(&c_oid),
self.c_repository,
ref_name_bytes, // TODO (update_ref)
author.c_sig,
@@ -95,13 +98,13 @@ class Repository {
}
let c_commit: *c::git_commit = ptr::null();
- retval = c::inline::git_commit_lookup(ptr::addr_of(c_commit), self.c_repository, ptr::addr_of(c_oid));
+ retval = c::git_commit_lookup(ptr::addr_of(&c_commit), self.c_repository, ptr::addr_of(&c_oid));
if retval != 0 {
fail;
}
- ret commit::Commit(c_commit);
+ return commit::Commit(c_commit);
}
fn find_commit(hash: &str) -> commit::Commit {
@@ -112,34 +115,34 @@ class Repository {
}
}
-fn Repository_init(path: str) -> Repository {
+pub fn Repository_init(path: &str) -> Repository {
// TODO verify this isn't already an initialized repo?
let mut retval: c_int = 0;
let c_repository: *c::git_repository = ptr::null();
do str::as_c_str(path) |bytes| {
// TODO bare vs not
- retval = c::bindgen::git_repository_init(ptr::addr_of(c_repository), bytes, 0);
+ retval = c::git_repository_init(ptr::addr_of(&c_repository), bytes, 0);
};
if retval != 0 {
fail;
}
- ret Repository(c_repository);
+ return Repository(c_repository);
}
-fn Repository_discover(path: str) -> Repository {
+pub fn Repository_discover(path: &str) -> Repository {
let mut retval: c_int = 0;
let c_repository: *c::git_repository = ptr::null();
do str::as_c_str(path) |bytes| {
- retval = c::bindgen::git_repository_open_ext(ptr::addr_of(c_repository), bytes, 0, ptr::null());
+ retval = c::git_repository_open_ext(ptr::addr_of(&c_repository), bytes, 0, ptr::null());
};
if retval != 0 {
fail;
}
- ret Repository(c_repository);
+ return Repository(c_repository);
}
View
35 git2/signature.rs
@@ -1,38 +1,41 @@
-use std;
+extern mod std;
-import std::time::tm;
+use std::time::Tm;
-import c;
-import libc::types::os::arch::c95::{c_char,c_int,c_uint};
-import libc::types::common::c95::{c_void};
+use mod c;
+use libc::types::os::arch::c95::{c_char,c_int,c_uint};
+use libc::types::common::c95::{c_void};
// TODO:
// - git_signature_dup
// - git_signature_now
-class Signature {
- let c_sig: *c::git_signature;
+pub struct Signature {
+ c_sig: *c::git_signature,
- new(c_sig: *c::git_signature) {
- self.c_sig = c_sig;
+ drop {
+ if self.c_sig != ptr::null() {
+ c::git_signature_free(self.c_sig);
+ }
}
+}
+pub fn Signature(c_sig: *c::git_signature) -> Signature {
+ return Signature{ c_sig: c_sig };
+}
+impl Signature {
// TODO accessors
-
- drop {
- c::bindgen::git_signature_free(self.c_sig);
- }
}
-fn Signature_create(name: str, email: str, time: std::time::tm) -> Signature {
+pub fn Signature_create(name: &str, email: &str, time: std::time::Tm) -> Signature {
let mut retval: c_int = 0;
let c_sig: *c::git_signature = ptr::null();
let spec = time.to_timespec();
do str::as_c_str(name) |name_bytes| {
do str::as_c_str(email) |email_bytes| {
- retval = c::bindgen::git_signature_new(ptr::addr_of(c_sig), name_bytes, email_bytes, spec.sec as c::git_time_t, time.tm_gmtoff);
+ retval = c::git_signature_new(ptr::addr_of(&c_sig), name_bytes, email_bytes, spec.sec as c::git_time_t, time.tm_gmtoff);
}
}
@@ -40,5 +43,5 @@ fn Signature_create(name: str, email: str, time: std::time::tm) -> Signature {
fail;
}
- ret Signature(c_sig);
+ return Signature(c_sig);
}
View
35 tcup.rs
@@ -1,50 +1,51 @@
-use std;
-use git2;
+extern mod std;
+extern mod git2;
-import git2::repository::Repository_discover;
-import git2::repository::Repository_init;
-import git2::signature::Signature_create;
+use git2::repository::Repository_discover;
+use git2::repository::Repository_init;
+use git2::signature::Signature_create;
-fn main(argv: ~[str]) {
- alt argv[1] {
- "dummy" {
+fn main() {
+ let args = os::args();
+ match args[1] {
+ ~"dummy" => {
let repo = Repository_discover(".");
io::println(repo.path());
}
- "new" {
+ ~"new" => {
// TODO check for existing repo
let repo = Repository_init(".");
io::println("Created a new repository.");
}
- "stage" {
- if vec::len(argv) == 2 {
+ ~"stage" => {
+ if vec::len(args) == 2 {
io::println("Need some filenames, chief.");
- ret;
+ return;
}
let repo = Repository_discover(".");
let index = repo.index();
- do vec::iter_between(argv, 2, argv.len()) |filename| {
- index.add(filename);
+ for vec::each(vec::view(args, 2, args.len())) |filename| {
+ index.add(*filename);
}
index.write();
}
- "status" {
+ ~"status" => {
let repo = Repository_discover(".");
// TODO this kinda sucks and is not amenable to `git status` style output
do repo.for_status() |path, status| {
io::println(#fmt("%s (%d)", path, status as int));
};
}
- "commit" {
+ ~"commit" => {
let repo = Repository_discover(".");
let tree_oid = repo.index().write();
let sig = Signature_create("Eevee", "git@veekun.com", std::time::now());
let commit = repo.commit(tree_oid, "Commit from Rust!", sig);
io::println("commit!");
}
- _ {
+ _ => {
io::println("error!");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.