Comments (1)
Insights gained
All the time the trait I was looking for was Borrow
. The current implementation that enforces Owned
and Borrowed
versions of the same thing are me trying to poorly emulate what AsRef<> could do, with the difference that Borrow<> will take ownership if you let it (along with possibly instantiating huge functions/methods.
Thus we should do the following:
- Remove
git_object::(borrowed|owned)::Id
andHashKind
as these lead to people depending on git_object instead of git_hash (like happed with git-commitgraph) - Find a way to have multi-length borrowed Ids (as slice) and use the fact that the length of a hash digest encodes its type. It's likely these will only grow so we should be safe for a while. Effectively, this is relevant for
borrowed::Tree
, so we might even keep the code there and greatly simplify git-hash (pushing some of the code into git-object). Conversions from owned Ids to borrowed ones are cheap, the other way around involves a copy. It's also relevant for all zero-copy return values of hashes.- The type ideally is properly borrowed, such as in
&borrowed::Id
, which enablesToOwned
traits andBorrow
to be used properly.
- The type ideally is properly borrowed, such as in
Receivers of borrowed hashes that are public facing should useimpl Borrow<hash::Id>
for convenience, internal receivers should use plain references. Avoid putting generics into receivers with lots of code but instead use 'landing pads'.- Review crates to find refactoring opportunities. There is great benefit in having zero-copy object Ids and there is no way to remove them from the equation. However, they should just be slices, see the next point. Maybe make it easy to use owned Ids as borrowed ones.
- git-commitgraph lookup
- git-object
- git-odb::*::locate()
- Review crates to find refactoring opportunities. There is great benefit in having zero-copy object Ids and there is no way to remove them from the equation. However, they should just be slices, see the next point. Maybe make it easy to use owned Ids as borrowed ones.
- Unify name to be
Id
everywhere. Add Sha256 support for good measure (it should be representable in the type system, not working for everything), assure that adding it actually works as anticipated.It' not the time yet, see comment at bb24dc4- Rename git_hash::Oid to git_hash::ObjectId and git_hash::borrowed::Id to git_hash::oid 🎉
- Make ObjectId and oid comparable (Eq, Ord) for convenience, remove 'as_ref()' where it was added because of these missing
Then republish these crates with breaking changes:
- git-features (git-hash in public interface)
- git-hash (rename)
- git-object (less public export)
- git-odb
- git-commitgraph (use git-hash)
- git-protocol
- gitoxide-core
Correction
When looking at how git_hash::Borrowed
is actually used it's clear these are for keeping them in fields of structures, which seemed impossible to do with git_hash::Owned()
- let's test more.
This usage as field is in exactly one spot: Tree::entries
refers to a vector of borrowed name/bin-hash-id . Packs for instance can be created from readers and thus copy the hash's bytes (there is no buffer to reference), or from a byte buffer, but the API ops to always copy the bytes instead of referencing them. It's a potential optimization which probably isn't worth it as these deltas are only used in thin packs. So the verdict remains: all the fuzz about Owned and Borrowed hashes is merely for one use in the deserialized zero copy Tree.
from gitoxide.
Related Issues (20)
- PermissionDenied checking Windows symlink target is misinterpreted as collision HOT 3
- Test suite does not assert directory symlink creation HOT 2
- `gix_mailmap::Snapshot` does not implement `Debug` or `Eq` HOT 4
- gix cannot clone a repo with a branch called HEAD HOT 2
- ssh clone does not correctly detect the location of ssh.exe HOT 12
- parsing failure of invalid author/committer line - missing space before email HOT 3
- gix-diff make_diff_repo test fixture archive is always regenerated HOT 2
- many_different_states fails on Windows with GIX_TEST_IGNORE_ARCHIVES=1 HOT 3
- 9 tests rely on commands like `ln -s` making copies instead of symlinks on Windows HOT 4
- gix-config set configuration values HOT 1
- OSS-Fuzz issue 70323 HOT 1
- Something went wrong... & Merge conflict after working on another device HOT 1
- `gix clean -xde` deletes whole repo if `.gitignore` lists `*` or `/` HOT 6
- The kstring integration in gix-attributes is unsound HOT 5
- Fallback to git commands? HOT 3
- `gix clean` with `-r` or `-xd` deletes the repo's own nested worktrees HOT 5
- audit uses of `as_ref()` and remove those that are ambiguous HOT 6
- gitoxide fails to compile with bstr 1.9.2 HOT 1
- `gix clean -xde` deletes the repo's own hidden nested worktrees, but they are not really hidden HOT 5
- The 32-bit Windows releases are 64-bit HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gitoxide.