Skip to content

Commit

Permalink
Merge branch 'rev-parse-delegate'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 3, 2022
2 parents 796b2a2 + b83f6bd commit 2f506c7
Show file tree
Hide file tree
Showing 149 changed files with 5,781 additions and 1,106 deletions.
19 changes: 12 additions & 7 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ prodash-render-line-crossterm = ["prodash-render-line", "prodash/render-line-cro
#! These combine common choices of the above features to represent typical builds

## *fast* + *prodash-render-tui-crossterm* + *prodash-render-line-crossterm* + *http* + *gitoxide-core-tools* + *client-networking*
max = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client", "prodash-render-line", "prodash-render-tui", "prodash/render-line-autoconfigure" ]
max = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client", "prodash-render-line", "prodash-render-tui", "prodash/render-line-autoconfigure", "git-repository/regex" ]

## *fast* + *prodash-render-line-crossterm* + *gitoxide-core-tools* + *client-networking*.
lean = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client", "prodash-render-line" ]
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ unit-tests: ## run all unit tests
cd git-protocol && cargo test --features blocking-client \
&& cargo test --features async-client \
&& cargo test
cd git-repository && cargo test \
&& cargo test --features regex
cd gitoxide-core && cargo test --lib

nextest: ## run tests with `cargo nextest` (all unit-tests, no doc-tests, faster)
Expand Down
30 changes: 4 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ Please see _'Development Status'_ for a listing of all crates and their capabili
* **mailmap**
* [x] **entries** - display all entries of the aggregated mailmap git would use for substitution
* **revision**
* [ ] **explain** - show what would be done while parsing a revision specification like `HEAD~1`
* [x] **explain** - show what would be done while parsing a revision specification like `HEAD~1`
* [x] **resolve** - show which objects a revspec resolves to, similar to `git rev-parse` but faster and with much better error handling
* [x] **previous-branches** - list all previously checked out branches, powered by the ref-log.
* **free** - no git repository necessary
* **pack**
* [x] [verify](https://asciinema.org/a/352942)
Expand Down Expand Up @@ -347,31 +349,7 @@ Provide a CLI to for the most basic user journey:

## Shortcomings & Limitations

* **fetches using protocol V1 and stateful connections, i.e. ssh, git, file, may hang**
* This can be fixed by making response parsing.
* Note that this does not affect cloning, which works fine.
* **lean** and **light** and **small** builds don't support non-UTF-8 paths _in the CLI_
* This is because they depend on `argh`, which [does not yet support parsing OsStrings](https://github.com/google/argh/issues/33). We however
believe it eventually will do so and thus don't move on to [`pico-args`](https://github.com/RazrFalcon/pico-args/blob/master/examples/app.rs).
* Only one level of sub-commands are supported due to a limitation of `argh`, which forces porcelain to limit itself as well despite using `clap`.
We deem this acceptable for plumbing commands and think that porcelain will be high-level and smart enough to not ever require deeply nested sub-commands.
* **Packfiles use memory maps**
* Even though they are comfortable to use and fast, they squelch IO errors.
* _potential remedy_: We could generalize the Pack to make it possible to work on in-memory buffers directly. That way, one
would initialize a Pack by reading the whole file into memory, thus not squelching IO errors at the expense of latency as well
as memory efficiency.
* **Packfiles cannot load files bigger than 2^31 or 2^32 on 32 bit systems**
* As these systems cannot address more memory than that.
* _potential remedy_: implement a sliding window to map and unmap portions of the file as needed.
* However, those who need to access big packs on these systems would rather resort to `git` itself, allowing
our implementation to be simpler and potentially more performant.
* **Objects larger than 32 bits cannot be loaded on 32 bit systems**
* in-memory representations objects cannot handle objects greater than the amount of addressable memory.
* This should not affect git LFS though.
* **git-url** _might_ be more restrictive than what git allows as for the most part, it uses a browser grade URL parser.
* Thus far there is no proof for this, and as _potential remedy_ we could certainly re-implement exactly what git does
to handle its URLs.
* **local time** is currently impeded by [this issue](https://github.com/time-rs/time/issues/293#issuecomment-909158529) but it's planned to resolve it eventually.
Please take a look at the [`SHORTCOMINGS.md` file](https://github.com/Byron/gitoxide/blob/main/git-lock/SHORTCOMINGS.md) for details.

## Credits

Expand Down
43 changes: 43 additions & 0 deletions SHORTCOMINGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
This file is for tracking features that are less well implemented or less powerful than their `git` counterparts for one reason or another.

#### `git-repository`

##### RevSpec parsing

- cannot disambiguate trees using blob-access syntax like `000000:blob`
- See [this test](https://github.com/Byron/gitoxide/blob/5278cbc9b91ce01761a96a6962564a92daa77b7f/git-repository/tests/rev_spec/mod.rs#L102).
- cannot disambiguate objects using their **object type** like `000000^{blob}`
- See [this test](https://github.com/Byron/gitoxide/blob/9d2e1eb3defc3ddd7ade7fe2bdd26d8a21afe55f/git-repository/tests/rev_spec/mod.rs#L83)
which mentions the current behaviour.
- There are more tests around the same behaviour, check for `parse_spec_no_baseline(…)` to see where we fall short. Note that git can't disambiguate
consistently either, so eventually I would expect to get ahead.

### git-protocol
* **fetches using protocol V1 and stateful connections, i.e. ssh, git, file, may hang**
* This can be fixed by making response parsing.
* Note that this does not affect cloning, which works fine.

### `git-pack`
* **Packfiles use memory maps**
* Even though they are comfortable to use and fast, they squelch IO errors.
* _potential remedy_: We could generalize the Pack to make it possible to work on in-memory buffers directly. That way, one
would initialize a Pack by reading the whole file into memory, thus not squelching IO errors at the expense of latency as well
as memory efficiency.
* **Packfiles cannot load files bigger than 2^31 or 2^32 on 32 bit systems**
* As these systems cannot address more memory than that.
* _potential remedy_: implement a sliding window to map and unmap portions of the file as needed.
* However, those who need to access big packs on these systems would rather resort to `git` itself, allowing
our implementation to be simpler and potentially more performant.
* **Objects larger than 32 bits cannot be loaded on 32 bit systems**
* in-memory representations objects cannot handle objects greater than the amount of addressable memory.
* This will not affect git LFS though.

### `git-url`

* **git-url** _might_ be more restrictive than what git allows as for the most part, it uses a browser grade URL parser.
* Thus far there is no proof for this, and as _potential remedy_ we could certainly re-implement exactly what git does
to handle its URLs.

### `git-features`

* **local time** is currently impeded by [this issue](https://github.com/time-rs/time/issues/293#issuecomment-909158529) but it's planned to resolve it eventually.
11 changes: 7 additions & 4 deletions crate-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
* [x] multi-pack indices
* [x] perfect scaling with cores
* [x] support for pack caches, object caches and MRU for best per-thread performance.
* [x] prefix/short-id lookup
* [x] prefix/short-id lookup, with optional listing of ambiguous objects.
* [x] object replacements (`git replace`)
* **sink**
* [x] write objects and obtain id
Expand Down Expand Up @@ -424,9 +424,12 @@ See its [README.md](https://github.com/Byron/gitoxide/blob/main/git-lock/README.
* [x] handle git-common-dir
* [ ] support for `GIT_CEILING_DIRECTORIES` environment variable
* [ ] handle other non-discovery modes and provide control over environment variable usage required in applications
* [ ] rev-parse
- **unsupported**
* regex
* [x] rev-parse
- **deviation**
* `@` actually stands for `HEAD`, whereas `git` resolves it to the object pointed to by `HEAD` without making the `HEAD` ref available for lookups.
* [x] rev-walk
* [x] include tips
* [ ] exclude commits
* [x] instantiation
* [x] access to refs and objects
* **traverse**
Expand Down
2 changes: 1 addition & 1 deletion etc/check-package-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ echo "in root: gitoxide CLI"
(enter git-odb && indent cargo diet -n --package-size-limit 120KB)
(enter git-protocol && indent cargo diet -n --package-size-limit 50KB)
(enter git-packetline && indent cargo diet -n --package-size-limit 35KB)
(enter git-repository && indent cargo diet -n --package-size-limit 120KB)
(enter git-repository && indent cargo diet -n --package-size-limit 130KB)
(enter git-transport && indent cargo diet -n --package-size-limit 50KB)
(enter gitoxide-core && indent cargo diet -n --package-size-limit 80KB)
7 changes: 6 additions & 1 deletion git-actor/src/signature/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod _ref {
use bstr::ByteSlice;
use bstr::{BStr, ByteSlice};

use crate::{signature::decode, Signature, SignatureRef};

Expand Down Expand Up @@ -29,6 +29,11 @@ mod _ref {
time: self.time,
}
}

/// Return the actor's name and email, effectively exclusing the time stamp of this signature.
pub fn actor(&self) -> (&BStr, &BStr) {
(self.name, self.email)
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions git-attributes/src/match_group.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::{Assignment, MatchGroup, PatternList, PatternMapping};
use bstr::{BStr, BString, ByteSlice, ByteVec};
use std::{
ffi::OsString,
io::Read,
path::{Path, PathBuf},
};

use bstr::{BStr, BString, ByteSlice, ByteVec};

use crate::{Assignment, MatchGroup, PatternList, PatternMapping};

fn into_owned_assignments<'a>(
attrs: impl Iterator<Item = Result<crate::AssignmentRef<'a>, crate::name::Error>>,
) -> Result<Vec<Assignment>, crate::name::Error> {
Expand Down
3 changes: 2 additions & 1 deletion git-attributes/src/name.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{Name, NameRef};
use bstr::BString;

use crate::{Name, NameRef};

impl<'a> NameRef<'a> {
/// Turn this ref into its owned counterpart.
pub fn to_owned(self) -> Name {
Expand Down
6 changes: 4 additions & 2 deletions git-attributes/src/parse/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{name, AssignmentRef, Name, NameRef, StateRef};
use bstr::{BStr, ByteSlice};
use std::borrow::Cow;

use bstr::{BStr, ByteSlice};

use crate::{name, AssignmentRef, Name, NameRef, StateRef};

/// The kind of attribute that was parsed.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
Expand Down
3 changes: 2 additions & 1 deletion git-attributes/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{State, StateRef};
use bstr::ByteSlice;

use crate::{State, StateRef};

impl<'a> StateRef<'a> {
/// Turn ourselves into our owned counterpart.
pub fn to_owned(self) -> State {
Expand Down
1 change: 1 addition & 0 deletions git-bitmap/src/ewah.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ mod access {

/// A growable collection of u64 that are seen as stream of individual bits.
#[allow(dead_code)]
#[derive(Clone)]
pub struct Vec {
num_bits: u32,
bits: std::vec::Vec<u64>,
Expand Down
9 changes: 9 additions & 0 deletions git-date/src/time.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::{convert::TryInto, io, ops::Sub};

use bstr::BString;

use crate::Time;

/// Indicates if a number is positive or negative for use in [`Time`].
Expand Down Expand Up @@ -107,6 +109,13 @@ impl Time {
self.seconds_since_unix_epoch
}

/// Serialize this instance into a BString.
pub fn to_bstring(&self) -> BString {
let mut buf = Vec::with_capacity(128);
self.write_to(&mut buf).expect("enough memory");
buf.into()
}

/// Serialize this instance to `out` in a format suitable for use in header fields of serialized git commits or tags.
pub fn write_to(&self, mut out: impl io::Write) -> io::Result<()> {
let mut itoa = itoa::Buffer::new();
Expand Down
3 changes: 2 additions & 1 deletion git-discover/src/upwards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ fn parse_ceiling_dirs(ceiling_dirs: &[u8]) -> Vec<PathBuf> {

#[cfg(test)]
mod parse_ceiling_dirs {
use super::*;

#[test]
#[cfg(unix)]
fn from_environment_format() -> std::io::Result<()> {
use std::{fs, os::unix::fs::symlink};

use super::*;

// Setup filesystem
let dir = tempfile::tempdir().expect("success creating temp dir");
let direct_path = dir.path().join("direct");
Expand Down
4 changes: 3 additions & 1 deletion git-features/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,7 @@ features = ["document-features"]
all-features = true

# Assembly doesn't yet compile on MSVC on windows, but does on GNU, see https://github.com/RustCrypto/asm-hashes/issues/17
[target.'cfg(not(all(target_os = "windows", target_env = "msvc")))'.dependencies]
# TODO: potentially include it only for certain architectures
# [target.'cfg(all(any(target_arch = "x86", target_arch = "x86_64"), not(target_env = "msvc")))'.dependencies]
[target.'cfg(not(target_env = "msvc"))'.dependencies]
sha-1 = { version = "0.10.0", optional = true, features = ["asm"] }

0 comments on commit 2f506c7

Please sign in to comment.