-
-
Notifications
You must be signed in to change notification settings - Fork 353
various improvements #1884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
various improvements #1884
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
518fbbc
feat: add `Repository::workdir()` as replacement for `Repository::wor…
Byron abb53fb
Adapt to changes in `gix`
Byron 776f9be
feat: add `Repository::workdir_path()` to easily obtain a `Path` for …
Byron 02878c9
feat: add `Repository::head_tree_id_or_empty()` for convenience.
Byron 7dcba9f
feat: make `SymlinkCheck::inner` available.
Byron f93aa61
feat: add `FileSnapshot::into_owned_or_cloned()`.
Byron 5054780
feat: add `Repository::checkout_options()`.
Byron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use gix_fs::SharedFileSnapshotMut; | ||
use std::path::Path; | ||
|
||
#[test] | ||
fn journey() -> Result<(), Box<dyn std::error::Error>> { | ||
let tmp = tempfile::tempdir().unwrap(); | ||
if !has_nanosecond_times(tmp.path())? { | ||
return Ok(()); | ||
} | ||
|
||
let file_path = tmp.path().join("content"); | ||
let smut = SharedFileSnapshotMut::<String>::new(); | ||
|
||
let check = || file_path.metadata().ok()?.modified().ok(); | ||
let open = || { | ||
Ok(match std::fs::read_to_string(&file_path) { | ||
Ok(s) => Some(s), | ||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => None, | ||
Err(err) => return Err(err), | ||
}) | ||
}; | ||
let snap = smut.recent_snapshot(check, open)?; | ||
assert!(snap.is_none()); | ||
|
||
std::fs::write(&file_path, "content")?; | ||
let snap = smut.recent_snapshot(check, open)?.expect("content read"); | ||
assert_eq!(&**snap, "content", "it read the file for the first time"); | ||
|
||
std::fs::write(&file_path, "change")?; | ||
let snap = smut.recent_snapshot(check, open)?.expect("content read"); | ||
assert_eq!(&**snap, "change", "it picks up the change"); | ||
|
||
std::fs::remove_file(&file_path)?; | ||
let snap = smut.recent_snapshot(check, open)?; | ||
assert!(snap.is_none(), "file deleted, nothing to see here"); | ||
|
||
std::fs::write(&file_path, "new")?; | ||
let snap = smut.recent_snapshot(check, open)?.expect("content read again"); | ||
let owned: String = snap.into_owned_or_cloned(); | ||
assert_eq!(owned, "new", "owned versions are possible easily and efficiently"); | ||
Ok(()) | ||
} | ||
|
||
fn has_nanosecond_times(root: &Path) -> std::io::Result<bool> { | ||
let test_file = root.join("nanosecond-test"); | ||
|
||
std::fs::write(&test_file, "a")?; | ||
let first_time = test_file.metadata()?.modified()?; | ||
|
||
std::fs::write(&test_file, "b")?; | ||
let second_time = test_file.metadata()?.modified()?; | ||
|
||
Ok(first_time != second_time) | ||
} |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::{config, Repository}; | ||
|
||
impl Repository { | ||
/// Return options that can be used to drive a low-level checkout operation. | ||
/// Use `attributes_source` to determine where `.gitattributes` files should be read from, which depends on | ||
/// the presence of a worktree to begin with. | ||
/// Here, typically this value would be [`gix_worktree::stack::state::attributes::Source::IdMapping`] | ||
pub fn checkout_options( | ||
&self, | ||
attributes_source: gix_worktree::stack::state::attributes::Source, | ||
) -> Result<gix_worktree_state::checkout::Options, config::checkout_options::Error> { | ||
self.config.checkout_options(self, attributes_source) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.