Skip to content

Commit

Permalink
Merge pull request #887 from malor/blob-group-writable
Browse files Browse the repository at this point in the history
Add support for GIT_FILEMODE_BLOB_GROUP_WRITABLE
  • Loading branch information
ehuss authored Apr 1, 2023
2 parents 7805b63 + 5ab1d44 commit 76897b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ git_enum! {
GIT_FILEMODE_UNREADABLE = 0o000000,
GIT_FILEMODE_TREE = 0o040000,
GIT_FILEMODE_BLOB = 0o100644,
GIT_FILEMODE_BLOB_GROUP_WRITABLE = 0o100664,
GIT_FILEMODE_BLOB_EXECUTABLE = 0o100755,
GIT_FILEMODE_LINK = 0o120000,
GIT_FILEMODE_COMMIT = 0o160000,
Expand Down
1 change: 1 addition & 0 deletions src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ impl<'a> DiffFile<'a> {
raw::GIT_FILEMODE_UNREADABLE => FileMode::Unreadable,
raw::GIT_FILEMODE_TREE => FileMode::Tree,
raw::GIT_FILEMODE_BLOB => FileMode::Blob,
raw::GIT_FILEMODE_BLOB_GROUP_WRITABLE => FileMode::BlobGroupWritable,
raw::GIT_FILEMODE_BLOB_EXECUTABLE => FileMode::BlobExecutable,
raw::GIT_FILEMODE_LINK => FileMode::Link,
raw::GIT_FILEMODE_COMMIT => FileMode::Commit,
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,8 @@ pub enum FileMode {
Tree,
/// Blob
Blob,
/// Group writable blob. Obsolete mode kept for compatibility reasons
BlobGroupWritable,
/// Blob executable
BlobExecutable,
/// Link
Expand All @@ -1112,6 +1114,7 @@ impl From<FileMode> for i32 {
FileMode::Unreadable => raw::GIT_FILEMODE_UNREADABLE as i32,
FileMode::Tree => raw::GIT_FILEMODE_TREE as i32,
FileMode::Blob => raw::GIT_FILEMODE_BLOB as i32,
FileMode::BlobGroupWritable => raw::GIT_FILEMODE_BLOB_GROUP_WRITABLE as i32,
FileMode::BlobExecutable => raw::GIT_FILEMODE_BLOB_EXECUTABLE as i32,
FileMode::Link => raw::GIT_FILEMODE_LINK as i32,
FileMode::Commit => raw::GIT_FILEMODE_COMMIT as i32,
Expand All @@ -1125,6 +1128,7 @@ impl From<FileMode> for u32 {
FileMode::Unreadable => raw::GIT_FILEMODE_UNREADABLE as u32,
FileMode::Tree => raw::GIT_FILEMODE_TREE as u32,
FileMode::Blob => raw::GIT_FILEMODE_BLOB as u32,
FileMode::BlobGroupWritable => raw::GIT_FILEMODE_BLOB_GROUP_WRITABLE as u32,
FileMode::BlobExecutable => raw::GIT_FILEMODE_BLOB_EXECUTABLE as u32,
FileMode::Link => raw::GIT_FILEMODE_LINK as u32,
FileMode::Commit => raw::GIT_FILEMODE_COMMIT as u32,
Expand Down Expand Up @@ -1564,8 +1568,10 @@ mod tests {
#[test]
fn convert_filemode() {
assert_eq!(i32::from(FileMode::Blob), 0o100644);
assert_eq!(i32::from(FileMode::BlobGroupWritable), 0o100664);
assert_eq!(i32::from(FileMode::BlobExecutable), 0o100755);
assert_eq!(u32::from(FileMode::Blob), 0o100644);
assert_eq!(u32::from(FileMode::BlobGroupWritable), 0o100664);
assert_eq!(u32::from(FileMode::BlobExecutable), 0o100755);
}
}
3 changes: 3 additions & 0 deletions systest/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ fn main() {
_ => false,
});

// GIT_FILEMODE_BLOB_GROUP_WRITABLE is not a public const in libgit2
cfg.define("GIT_FILEMODE_BLOB_GROUP_WRITABLE", Some("0100664"));

// not entirely sure why this is failing...
cfg.skip_roundtrip(|t| t == "git_clone_options" || t == "git_submodule_update_options");

Expand Down

0 comments on commit 76897b8

Please # to comment.