git2-rs icon indicating copy to clipboard operation
git2-rs copied to clipboard

Expose git_merge_file function from libgit2 to repo.rs of git2-rs

Open kvzn opened this issue 4 years ago • 4 comments

kvzn avatar Nov 22 '20 07:11 kvzn

@alexcrichton BTW, could you point out how I can fix the issue in CI / Test (windows)? Tried but have no idea.

kvzn avatar Nov 24 '20 02:11 kvzn

Oh the windows error I think has to do with the fact that enums in C have a different signededness than other platforms. I think you can probably fix things with some casts?

I tried this, but doesn't work, any idea:

trait FileModeConvert {
    type ValueType;
    fn from(mode: Self::ValueType) -> Self;
}

impl FileModeConvert for FileMode {
    #[cfg(target_env = "msvc")]
    type ValueType = i32;

    #[cfg(not(target_env = "msvc"))]
    type ValueType = u32;

    fn from(mode: Self::ValueType) -> Self {
        match mode {
            raw::GIT_FILEMODE_UNREADABLE => FileMode::Unreadable,
            raw::GIT_FILEMODE_TREE => FileMode::Tree,
            raw::GIT_FILEMODE_BLOB => FileMode::Blob,
            raw::GIT_FILEMODE_BLOB_EXECUTABLE => FileMode::BlobExecutable,
            raw::GIT_FILEMODE_LINK => FileMode::Link,
            raw::GIT_FILEMODE_COMMIT => FileMode::Commit,
            mode => panic!("unknown file mode: {}", mode),
        }
    }
}

kvzn avatar Nov 26 '20 05:11 kvzn

@alexcrichton Can we merge this PR now? Thank you!

kvzn avatar May 20 '22 07:05 kvzn