git: Use correct file mode when staging (#41900)
Closes #28667 Release Notes: - Fixed git not preserving file mode when committing. Now if an input file is executable it will be preserved when committed with Zed. --------- Signed-off-by: 11happy <soni5happy@gmail.com> Signed-off-by: 11happy <bhuminjaysoni@gmail.com> Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
This commit is contained in:
co-authored by
Jakub Konka
parent
00e93bfa11
commit
425d4c73f3
@@ -138,6 +138,7 @@ impl GitRepository for FakeGitRepository {
|
||||
path: RepoPath,
|
||||
content: Option<String>,
|
||||
_env: Arc<HashMap<String, String>>,
|
||||
_is_executable: bool,
|
||||
) -> BoxFuture<'_, anyhow::Result<()>> {
|
||||
self.with_state_async(true, move |state| {
|
||||
if let Some(message) = &state.simulated_index_write_error_message {
|
||||
|
||||
@@ -32,6 +32,7 @@ use std::mem::MaybeUninit;
|
||||
use async_tar::Archive;
|
||||
use futures::{AsyncRead, Stream, StreamExt, future::BoxFuture};
|
||||
use git::repository::{GitRepository, RealGitRepository};
|
||||
use is_executable::IsExecutable;
|
||||
use rope::Rope;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use smol::io::AsyncWriteExt;
|
||||
@@ -208,6 +209,7 @@ pub struct Metadata {
|
||||
pub is_dir: bool,
|
||||
pub len: u64,
|
||||
pub is_fifo: bool,
|
||||
pub is_executable: bool,
|
||||
}
|
||||
|
||||
/// Filesystem modification time. The purpose of this newtype is to discourage use of operations
|
||||
@@ -895,6 +897,12 @@ impl Fs for RealFs {
|
||||
#[cfg(unix)]
|
||||
let is_fifo = metadata.file_type().is_fifo();
|
||||
|
||||
let path_buf = path.to_path_buf();
|
||||
let is_executable = self
|
||||
.executor
|
||||
.spawn(async move { path_buf.is_executable() })
|
||||
.await;
|
||||
|
||||
Ok(Some(Metadata {
|
||||
inode,
|
||||
mtime: MTime(metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH)),
|
||||
@@ -902,6 +910,7 @@ impl Fs for RealFs {
|
||||
is_symlink,
|
||||
is_dir: metadata.file_type().is_dir(),
|
||||
is_fifo,
|
||||
is_executable,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -2602,6 +2611,7 @@ impl Fs for FakeFs {
|
||||
is_dir: false,
|
||||
is_symlink,
|
||||
is_fifo: false,
|
||||
is_executable: false,
|
||||
},
|
||||
FakeFsEntry::Dir {
|
||||
inode, mtime, len, ..
|
||||
@@ -2612,6 +2622,7 @@ impl Fs for FakeFs {
|
||||
is_dir: true,
|
||||
is_symlink,
|
||||
is_fifo: false,
|
||||
is_executable: false,
|
||||
},
|
||||
FakeFsEntry::Symlink { .. } => unreachable!(),
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user