Skip to content
New issue

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

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

Already on GitHub? # to your account

Add support for GIT_FILEMODE_BLOB_GROUP_WRITABLE #887

Merged
merged 1 commit into from
Apr 1, 2023
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 libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,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 @@ -1562,8 +1566,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 @@ -39,6 +39,9 @@ fn main() {
}
});

// 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