Skip to content

Diff between worktree and index #805

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 32 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c49f12d
allow access to index timestamp
pascalkuthe Apr 2, 2023
38e228c
add function to read blob from worktree
pascalkuthe Apr 2, 2023
efcbf0d
accept paths in scripted_fixture_writable
pascalkuthe Apr 2, 2023
0a8e50f
feat: diff between worktree and index
pascalkuthe Apr 2, 2023
31ddda2
refactor
Byron Apr 3, 2023
16eab81
refactor gix_worktree::read module
pascalkuthe Apr 4, 2023
1c43c75
change index/worktree diff to a visitor based API
pascalkuthe Apr 4, 2023
870bdb2
centralize index entry Stat creation/comparison
pascalkuthe Apr 12, 2023
0f747f3
streamline status API
pascalkuthe Apr 12, 2023
d7f250d
parallel status check
pascalkuthe Apr 7, 2023
f2a9b3f
update index::entry::stat tests
pascalkuthe Apr 12, 2023
9cb76e9
Cleanup entry::mode API
pascalkuthe Apr 12, 2023
bf8a7a4
Improve Mode::change_to_match_fs documentation
pascalkuthe Apr 12, 2023
c5f3fc8
use existing concurrency primitive in_parallel
pascalkuthe Apr 13, 2023
4736b60
clarify Stat::is_racy documentation
pascalkuthe Apr 13, 2023
1e19760
improve documentation of gix_index::entry::Stat::matches
pascalkuthe Apr 13, 2023
8df154b
clean up status::Diff implementations
pascalkuthe Apr 13, 2023
8b2bcdc
improve terminology and documentation
pascalkuthe Apr 13, 2023
0582ec5
ensure stable sort order for deterministic tests
pascalkuthe Apr 13, 2023
55d8902
remove unused config option
pascalkuthe Apr 13, 2023
c5adbe1
add test for racy git detection
pascalkuthe Apr 13, 2023
23ee47f
Merge branch 'main' into dev
Byron Apr 15, 2023
6acc5f1
make it compile
Byron Apr 15, 2023
35cb6b4
feat: Allow `USE_NSEC` and `USE_STDEV` compile time flags to configur…
Byron Apr 15, 2023
691758a
refactor
Byron Apr 15, 2023
9af47c3
feat: add `Index::entries_mut_and_pathbacking()`.
Byron Apr 15, 2023
cae539b
adjust to changes in `gix-index`
Byron Apr 15, 2023
27471e7
Add a test for --intend-to-add and clarify what this flag means.
Byron Apr 15, 2023
055611c
Add a test to assure we can detect conflicts
Byron Apr 15, 2023
f8cc33c
create new `gix-fs` crate to consolidate all filesystem utilities
Byron Apr 16, 2023
8920229
Minor adjustments to the worktree structure.
Byron Apr 16, 2023
cdef398
Merge branch 'main' into dev
Byron Apr 17, 2023
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
24 changes: 18 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ members = [
"gix-refspec",
"gix-path",
"gix-utils",
"gix-fs",
"gix",
"gitoxide-core",
"gix-hashtable",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ is usable to some extent.
* `gitoxide-core`
* **very early** _(possibly without any documentation and many rough edges)_
* [gix-utils](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-utils)
* [gix-fs](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-fs)
* [gix-worktree](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-worktree)
* [gix-bitmap](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-bitmap)
* [gix-date](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-date)
Expand Down
7 changes: 6 additions & 1 deletion crate-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ and itself relies on all `git-*` crates. It's not meant for consumption, for app
* [x] hashset

### gix-utils

* **filesystem**
* [x] probe capabilities
* [x] symlink creation and removal
* [x] file snapshots

### gix-fs
* [x] probe capabilities
* [x] symlink creation and removal
* [x] file snapshots
* [x] stack abstraction

### gix-object
* *decode (zero-copy)* borrowed objects
Expand Down
3 changes: 3 additions & 0 deletions etc/check-package-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function indent () {
echo "in root: gitoxide CLI"
(enter cargo-smart-release && indent cargo diet -n --package-size-limit 110KB)
(enter gix-actor && indent cargo diet -n --package-size-limit 5KB)
(enter gix-archive && indent cargo diet -n --package-size-limit 10KB)
(enter gix-utils && indent cargo diet -n --package-size-limit 10KB)
(enter gix-fs && indent cargo diet -n --package-size-limit 10KB)
(enter gix-pathspec && indent cargo diet -n --package-size-limit 30KB)
(enter gix-refspec && indent cargo diet -n --package-size-limit 30KB)
(enter gix-path && indent cargo diet -n --package-size-limit 25KB)
Expand Down
10 changes: 5 additions & 5 deletions gitoxide-core/src/index/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use anyhow::bail;
use gix::{odb::FindExt, worktree::index::checkout, Progress};
use gix::{odb::FindExt, worktree::checkout, Progress};

use crate::{
index,
Expand Down Expand Up @@ -55,8 +55,8 @@ pub fn checkout_exclusive(
progress.info(format!("Skipping {} DIR/SYMLINK/COMMIT entries", num_skipped));
}

let opts = gix::worktree::index::checkout::Options {
fs: gix::utils::FilesystemCapabilities::probe(dest_directory),
let opts = gix::worktree::checkout::Options {
fs: gix::fs::Capabilities::probe(dest_directory),

destination_is_initially_empty: true,
overwrite_existing: false,
Expand All @@ -80,7 +80,7 @@ pub fn checkout_exclusive(
files_updated,
bytes_written,
} = match repo {
Some(repo) => gix::worktree::index::checkout(
Some(repo) => gix::worktree::checkout(
&mut index,
dest_directory,
{
Expand All @@ -103,7 +103,7 @@ pub fn checkout_exclusive(
should_interrupt,
opts,
),
None => gix::worktree::index::checkout(
None => gix::worktree::checkout(
&mut index,
dest_directory,
|_, buf| {
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/repository/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub(crate) mod function {
}
};

if let Some(gix::worktree::index::checkout::Outcome { collisions, errors, .. }) = outcome {
if let Some(gix::worktree::checkout::Outcome { collisions, errors, .. }) = outcome {
if !(collisions.is_empty() && errors.is_empty()) {
let mut messages = Vec::new();
if !errors.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion gix-attributes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ document-features = { version = "0.2.1", optional = true }

[dev-dependencies]
gix-testtools = { path = "../tests/tools"}
gix-utils = { path = "../gix-utils" }
gix-fs = { path = "../gix-fs" }

[package.metadata.docs.rs]
all-features = true
Expand Down
4 changes: 2 additions & 2 deletions gix-attributes/tests/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bstr::{BStr, ByteSlice};
use gix_attributes::search::{AttributeId, Outcome};
use gix_attributes::{AssignmentRef, NameRef, StateRef};
use gix_glob::pattern::Case;
use gix_utils::FilesystemCapabilities;

use std::collections::BTreeMap;

mod specials {
Expand Down Expand Up @@ -62,7 +62,7 @@ fn baseline() -> crate::Result {
let mut buf = Vec::new();
// Due to the way our setup differs from gits dynamic stack (which involves trying to read files from disk
// by path) we can only test one case baseline, so we require multiple platforms (or filesystems) to run this.
let case = if FilesystemCapabilities::probe("../.git").ignore_case {
let case = if gix_fs::Capabilities::probe("../.git").ignore_case {
Case::Fold
} else {
Case::Sensitive
Expand Down
18 changes: 18 additions & 0 deletions gix-fs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "gix-fs"
version = "0.1.0"
repository = "https://github.com/Byron/gitoxide"
license = "MIT/Apache-2.0"
description = "A crate providing file system specific utilities to `gitoxide`"
authors = ["Sebastian Thiel <sebastian.thiel@icloud.com>"]
edition = "2021"
rust-version = "1.64"

[lib]
doctest = false

[dependencies]
gix-features = { path = "../gix-features" }

[dev-dependencies]
tempfile = "3.5.0"
20 changes: 10 additions & 10 deletions gix-utils/src/fs_capabilities.rs → gix-fs/src/capabilities.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// TODO: tests
use crate::FilesystemCapabilities;
use crate::Capabilities;
use std::path::Path;

#[cfg(windows)]
impl Default for FilesystemCapabilities {
impl Default for Capabilities {
fn default() -> Self {
FilesystemCapabilities {
Capabilities {
precompose_unicode: false,
ignore_case: true,
executable_bit: false,
Expand All @@ -15,9 +15,9 @@ impl Default for FilesystemCapabilities {
}

#[cfg(target_os = "macos")]
impl Default for FilesystemCapabilities {
impl Default for Capabilities {
fn default() -> Self {
FilesystemCapabilities {
Capabilities {
precompose_unicode: true,
ignore_case: true,
executable_bit: true,
Expand All @@ -27,9 +27,9 @@ impl Default for FilesystemCapabilities {
}

#[cfg(all(unix, not(target_os = "macos")))]
impl Default for FilesystemCapabilities {
impl Default for Capabilities {
fn default() -> Self {
FilesystemCapabilities {
Capabilities {
precompose_unicode: false,
ignore_case: false,
executable_bit: true,
Expand All @@ -38,16 +38,16 @@ impl Default for FilesystemCapabilities {
}
}

impl FilesystemCapabilities {
impl Capabilities {
/// try to determine all values in this context by probing them in the given `git_dir`, which
/// should be on the file system the git repository is located on.
/// `git_dir` is a typical git repository, expected to be populated with the typical files like `config`.
///
/// All errors are ignored and interpreted on top of the default for the platform the binary is compiled for.
pub fn probe(git_dir: impl AsRef<Path>) -> Self {
let root = git_dir.as_ref();
let ctx = FilesystemCapabilities::default();
FilesystemCapabilities {
let ctx = Capabilities::default();
Capabilities {
symlink: Self::probe_symlink(root).unwrap_or(ctx.symlink),
ignore_case: Self::probe_ignore_case(root).unwrap_or(ctx.ignore_case),
precompose_unicode: Self::probe_precompose_unicode(root).unwrap_or(ctx.precompose_unicode),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Default for Retries {
mod error {
use std::{fmt, path::Path};

use crate::fs::create_dir::Retries;
use crate::dir::create::Retries;

/// The error returned by [all()][super::all()].
#[allow(missing_docs)]
Expand Down
4 changes: 4 additions & 0 deletions gix-fs/src/dir/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
///
pub mod create;
///
pub mod remove;
File renamed without changes.
53 changes: 53 additions & 0 deletions gix-fs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//! A crate with file-system specific utilities.
#![deny(rust_2018_idioms)]
#![forbid(unsafe_code)]

/// Common knowledge about the worktree that is needed across most interactions with the work tree
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
pub struct Capabilities {
/// If true, the filesystem will store paths as decomposed unicode, i.e. `ä` becomes `"a\u{308}"`, which means that
/// we have to turn these forms back from decomposed to precomposed unicode before storing it in the index or generally
/// using it. This also applies to input received from the command-line, so callers may have to be aware of this and
/// perform conversions accordingly.
/// If false, no conversions will be performed.
pub precompose_unicode: bool,
/// If true, the filesystem ignores the case of input, which makes `A` the same file as `a`.
/// This is also called case-folding.
pub ignore_case: bool,
/// If true, we assume the executable bit is honored as part of the files mode. If false, we assume the file system
/// ignores the executable bit, hence it will be reported as 'off' even though we just tried to set it to be on.
pub executable_bit: bool,
/// If true, the file system supports symbolic links and we should try to create them. Otherwise symbolic links will be checked
/// out as files which contain the link as text.
pub symlink: bool,
}
mod capabilities;

mod snapshot;

pub use snapshot::{FileSnapshot, SharedFileSnapshot, SharedFileSnapshotMut};
use std::path::PathBuf;

///
pub mod symlink;

///
pub mod dir;

/// A stack of path components with the delegation of side-effects as the currently set path changes, component by component.
#[derive(Clone)]
pub struct Stack {
/// The prefix/root for all paths we handle.
root: PathBuf,
/// the most recent known cached that we know is valid.
current: PathBuf,
/// The relative portion of `valid` that was added previously.
current_relative: PathBuf,
/// The amount of path components of 'current' beyond the roots components.
valid_components: usize,
/// If set, we assume the `current` element is a directory to affect calls to `(push|pop)_directory()`.
current_is_directory: bool,
}

pub mod stack;
File renamed without changes.
3 changes: 2 additions & 1 deletion gix-worktree/src/fs/stack.rs → gix-fs/src/stack.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::path::{Path, PathBuf};

use crate::fs::Stack;
use crate::Stack;

/// Access
impl Stack {
/// Returns the top-level path of the stack.
pub fn root(&self) -> &Path {
Expand Down
Loading