Skip to content
Open
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
15 changes: 0 additions & 15 deletions rust/file_utils/src/safe_file_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ impl SafeFileCreator {
if let Some(metadata) = self.original_metadata.as_ref() {
set_file_metadata(&self.dest_path, metadata, false)?;
}
let original_permissions = if self.dest_path.exists() {
Some(fs::metadata(&self.dest_path)?.permissions())
} else {
None
};

// Set the original file's permissions to the new file if they exist
if let Some(permissions) = original_permissions {
fs::set_permissions(&self.dest_path, permissions.clone())?;
}

Ok(())
}
Expand Down Expand Up @@ -140,11 +130,6 @@ mod tests {
.read_to_string(&mut contents)
.unwrap();
assert_eq!(contents.trim(), "Hello, world!");

// Verify file permissions
let metadata = fs::metadata(&dest_path).unwrap();
let permissions = metadata.permissions();
assert_eq!(permissions.mode() & 0o777, 0o644); // Assuming default creation mode
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion rust/gitxetcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ nfsserve = "0.10"
atty = "0.2"
libc = "0.2"
itertools = "0.10.5"
shellish_parse = "2.2"
snailquote = "0.3.1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely an incorrect merge happened, this reverted #416

ring = "0.16.20"
humantime = "2.1.0"
toml = "0.5"
Expand Down
44 changes: 9 additions & 35 deletions rust/gitxetcore/src/git_integration/git_file_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub fn decode_git_string(s_in: &str) -> String {
return s_in.to_owned();
}

// Are there any actually unicode characters here?
// Are there any actually unicode charcters here?
let mut i = match s_in.find('\\') {
Some(idx) => idx,
None => {
Expand Down Expand Up @@ -289,24 +289,14 @@ pub fn decode_git_string(s_in: &str) -> String {
};

// this unescapes all the rest of the \t, \\, etc.
if s_utf8.len() <= 1 {
s_utf8.to_owned()
} else {
match shellish_parse::parse(&s_utf8[1..], false) {
Ok(s) => {
if !s.is_empty() {
s[0].clone()
} else {
s_utf8.to_owned()
}
}
Err(e) => {
warn!(
"Error interpreting raw git string {} from git: {:?}.",
&s_utf8, e
);
s_utf8.to_owned()
}
match snailquote::unescape(s_utf8) {
Ok(s) => s,
Err(e) => {
warn!(
"Error interpreting raw git string {} from git: {:?}.",
&s_utf8, e
);
s_utf8.to_owned()
}
}
}
Expand Down Expand Up @@ -462,20 +452,4 @@ mod git_file_tools_tests {
assert_eq!(out_list(None, false)?, files);
Ok(())
}

#[tokio::test(flavor = "multi_thread")]
async fn test_decode_git_string() -> Result<()> {
// let strange_file_name = r#""\303\273n\303\255c\303\265d\303\251"#;
let strange_file_name = r#""another\tstrange\tfile.dat"#;
assert_eq!(
decode_git_string(strange_file_name),
String::from("another\tstrange\tfile.dat")
);
let strange_file_name = r#""\\backslash\\\\"#;
assert_eq!(
decode_git_string(strange_file_name),
String::from("\\backslash\\\\")
);
Ok(())
}
}
10 changes: 8 additions & 2 deletions rust/gitxetcore/src/git_integration/git_xet_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,19 @@ impl GitXetRepo {
.map(|(_name, url)| url)
.collect())
}
pub fn open(config: XetConfig) -> Result<Self> {
let repo_path = config.repo_path()?.clone();
Self::open_at(config, repo_path)
}

/// Open the repository, assuming that the current directory is itself in the repository.
///
/// If we are running in a way that is not associated with a repo, then the XetConfig path
/// will not show we are in a repo.
pub fn open(config: XetConfig) -> Result<Self> {
let repo = open_libgit2_repo(config.repo_path()?)?;
pub fn open_at(mut config: XetConfig, repo_path: PathBuf) -> Result<Self> {
let repo = open_libgit2_repo(&repo_path)?;
config.repo_path_if_present = Some(repo_path);
let config = config;

let git_dir = repo.path().to_path_buf();
let repo_dir = repo_dir_from_repo(&repo);
Expand Down