# libra **Repository Path**: vguo/libra ## Basic Information - **Project Name**: libra - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-18 - **Last Updated**: 2025-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Libra `Libra` is a partial implementation of a **Git** client, developed using **Rust**. Our goal is not to create a 100% replica of Git (for those interested in such a project, please refer to the [gitoxide](https://github.com/Byron/gitoxide)). Instead, `libra` focus on implementing the basic functionalities of Git for learning **Git** and **Rust**. A key feature of `libra` is the replacement of the original **Git** internal storage architecture with **SQLite**. ## Example ``` $ libra --help Simulates git commands Usage: libra Commands: init Initialize a new repository clone Clone a repository into a new directory add Add file contents to the index rm Remove files from the working tree and from the index restore Restore working tree files status Show the working tree status log Show commit logs diff Show changes between commits, commit and working tree, etc branch List, create, or delete branches commit Record changes to the repository switch Switch branches merge Merge changes push Update remote refs along with associated objects fetch Download objects and refs from another repository pull Fetch from and integrate with another repository or a local branch remote Manage set of tracked repositories help Print this message or the help of the given subcommand(s) Options: -h, --help Print help -V, --version Print version ``` ## Features ### Clean Code Our code is designed to be clean and easy to read, ensuring that it is both maintainable and understandable for developers of all skill levels. ### Cross-Platform - [x] Windows - [x] Linux - [x] MacOS ### Compatibility with Git Our implementation is essentially fully compatible with `Git` (developed with reference to the `Git` documentation), including formats such as `objects`, `index`, `pack`, and `pack-index`. Therefore, it can interact seamlessly with `Git` servers (like `push` and `pull`). ### Differences from Git: While maintaining compatibility with `Git`, we have made some innovations and changes: we use an `SQLite` database to manage loosely structured files such as `config`, `HEAD`, and `refs`, achieving unified management. ## CLI Compatibility with Git This section documents the compatibility between **Libra**’s CLI and **Git** at the level of commands and options, and serves as a roadmap for closing gaps. ### Legend - **Status** - ✅ Implemented and broadly compatible with Git semantics - ⚠️ Implemented but behavior may differ from Git, or Libra-specific extension (Git has no direct equivalent) - ⛔ Not implemented yet - **Priority** (for ⛔ items) - **P0** – High priority: very common in everyday Git workflows, or important for safety - **P1** – Medium priority: advanced workflows or scripting/tooling heavy usage - **P2** – Low priority: niche or rarely used options > Note: The tables below are based on the existing command/flag checklist in this README plus common Git options. If in doubt about exact semantic equality, we err on the conservative side and mark as ⚠️. --- ### Repository Setup: `init`, `clone` | Command | Option / Form | Git | Libra | Status | Priority (for ⛔) | Notes | | --- | --- | --- | --- | --- | --- | --- | | `init` | `` | Yes | Yes | ✅ | - | Basic repository directory | | | `--bare` | Yes | Yes | ✅ | - | Initialize bare repository | | | `--template ` | Yes | Yes | ✅ | - | Use template directory | | | `-b, --initial-branch ` | Yes | Yes | ✅ | - | Set initial branch name | | | `-q, --quiet` | Yes | Yes | ✅ | - | Suppress output | | | `--shared ` | Yes | Yes | ⚠️ | P1 | Supported, but effective semantics may differ from Git in edge cases | | | `--separate-git-dir ` | Yes | No | ⛔ | P1 | Separate `.git` directory; useful for advanced layouts | | | `--object-format ` | Yes | No | ⛔ | P0 | Important for SHA‑1/SHA‑256 migration/compatibility | | `clone` | `` | Yes | Yes | ✅ | - | Repository URL/path | | | `[local_path]` | Yes | Yes | ✅ | - | Target directory | | | `-b, --branch ` | Yes | Yes | ✅ | - | Check out given branch | | | `--depth ` | Yes | No | ⛔ | P0 | Shallow clone, widely used in CI and large repos | | | `--single-branch` | Yes | Yes | ✅ | - | Clone only the specified branch | | | `--recurse-submodules` | Yes | No | ⛔ | P1 | Requires submodule support; important in mono‑repos | | | `--bare` | Yes | No | ⛔ | P0 | Bare clone for server‑side usage | | | `--mirror` | Yes | No | ⛔ | P1 | Full mirror including refs, for replication scenarios | --- ### Working Tree & Index: `add`, `rm`, `restore`, `status` | Command | Option / Form | Git | Libra | Status | Priority (for ⛔) | Notes | | --- | --- | --- | --- | --- | --- | --- | | `add` | `` | Yes | Yes | ✅ | - | Add files matching pathspec | | | `-A, --all` | Yes | Yes | ✅ | - | Add all changes (tracked + untracked) | | | `-u, --update` | Yes | Yes | ✅ | - | Add only tracked changes | | | `--refresh` | Yes | Yes | ✅ | - | Refresh the index stat info | | | `-v, --verbose` | Yes | Yes | ✅ | - | Verbose output | | | `-n, --dry-run` | Yes | Yes | ✅ | - | Show what would be added | | | `--ignore-errors` | Yes | Yes | ✅ | - | Continue even if some paths fail | | | `-f, --force` | Yes | Yes | ✅ | - | Add ignored files | | | `-p, --patch` | Yes | No | ⛔ | P0 | Interactive hunk selection; core to many workflows | | | `-i, --interactive` | Yes | No | ⛔ | P0 | Interactive mode (`git add -i`) | | | `-N, --intent-to-add` | Yes | No | ⛔ | P1 | Mark paths as “to be added” later | | | `--chmod=(+x\|-x)` | Yes | No | ⛔ | P1 | Toggle executable bit | | | `--renormalize` | Yes | No | ⛔ | P2 | Re‑normalize line endings / attributes | | `rm` | `` | Yes | Yes | ✅ | - | Remove files | | | `--cached` | Yes | Yes | ✅ | - | Remove only from index | | | `-r, --recursive` | Yes | Yes | ✅ | - | Recurse into directories | | | `-f, --force` | Yes | Yes | ✅ | - | Force removal | | | `--dry-run` | Yes | Yes | ✅ | - | Show what would be removed | | | `--ignore-unmatch` | Yes | No | ⛔ | P0 | Don’t error if paths don’t match; important for scripts | | | `--pathspec-from-file ` | Yes | No | ⛔ | P1 | Read pathspecs from file | | | `--pathspec-file-nul` | Yes | No | ⛔ | P1 | NUL‑separated pathspec file | | `restore` | `` | Yes | Yes | ✅ | - | Restore paths | | | `-s, --source ` | Yes | Yes | ✅ | - | Restore from specific commit | | | `-W, --worktree` | Yes | Yes | ✅ | - | Restore working tree only | | | `-S, --staged` | Yes | Yes | ✅ | - | Restore index (staged) state | | `status` | `--porcelain` | Yes | Yes | ✅ | - | Machine‑readable output | | | `-s, --short` | Yes | Yes | ✅ | - | Short format | | | `--branch` | Yes | Yes | ✅ | - | Show branch info | | | `--ignored` | Yes | Yes | ✅ | - | Show ignored files | | | `--untracked-files[=no\|normal\|all]` | Yes | No | ⛔ | P0 | Control visibility of untracked files | | | `--show-stash` | No | Yes | ⚠️ | P1 | Libra extension; only in standard mode | --- ### Commit & History: `commit`, `log`, `tag`, `show`, `reflog` | Command | Option / Form | Git | Libra | Status | Priority (for ⛔) | Notes | | --- | --- | --- | --- | --- | --- | --- | | `commit` | `-m, --message ` | Yes | Yes | ✅ | - | Commit message | | | `-F, --file ` | Yes | Yes | ✅ | - | Read message from file | | | `--allow-empty` | Yes | Yes | ✅ | - | Allow empty commit | | | `--conventional` | No | Yes | ⚠️ | P1 | Libra extension for conventional commits | | | `--amend` | Yes | Yes | ✅ | - | Amend previous commit | | | `-s, --signoff` | Yes | Yes | ✅ | - | Add Signed-off-by | | | `--disable-pre` | Approx. `--no-verify` | Yes | ⚠️ | P0 | Behavior should be aligned with Git hook semantics as much as possible | | | `-a, --all` | Yes | Yes | ✅ | - | Auto‑stage tracked changes | | | `-p, --patch` | Yes | No | ⛔ | P1 | Patch‑mode commit (often paired with `add -p`) | | | `--no-verify` | Yes | No | ⛔ | P0 | Standard way to skip hooks; should coexist with or alias `--disable-pre` | | | `--no-edit` | Yes | No | ⛔ | P1 | Reuse previous message | | | `--author ` | Yes | No | ⛔ | P0 | Override author identity | | | `--date ` | Yes | No | ⛔ | P0 | Override author date | | | `-S, --gpg-sign` / `--no-gpg-sign` | Yes | No | ⛔ | P1 | GPG signing support | | `log` | `-n, --number ` | Yes | Yes | ✅ | - | Limit number of commits | | | `--oneline` | Yes | Yes | ✅ | - | One‑line output | | | `-p, --patch` | Yes | Yes | ✅ | - | Show patch | | | `--decorate / --no-decorate` | Yes | Yes | ✅ | - | Show/hide ref decorations | | | `[pathspec]` | Yes | Yes | ✅ | - | Restrict to paths | | | `--graph` | Yes | Yes | ✅ | - | ASCII commit graph | | | `--pretty=` | Yes | No | ⛔ | P0 | Customizable formatting; heavily used in tooling | | | `--abbrev-commit` | Yes | No | ⛔ | P1 | Shorten commit IDs | | | `--name-only / --name-status` | Yes | No | ⛔ | P0 | Show changed files, with or without status | | | `--stat` | Yes | Yes | ✅ | - | Diffstat summary | | | `--since / --until ` | Yes | No | ⛔ | P0 | Time‑based filtering | | | `--author ` | Yes | No | ⛔ | P0 | Author‑based filtering | | `tag` | `` | Yes | Yes | ✅ | - | Lightweight tag | | | `-l, --list [pattern]` | Yes | Yes | ✅ | - | List tags | | | `-d, --delete ` | Yes | Yes | ✅ | - | Delete tags | | | `-m, --message ` | Yes | Yes | ✅ | - | Annotated tag message | | | `-f, --force` | Yes | Yes | ✅ | - | Force re‑tag | | | `-a` | Yes | No | ⛔ | P0 | Explicit annotated tag | | | `-s, --sign` | Yes | No | ⛔ | P1 | GPG‑signed tags | | | `-u ` | Yes | No | ⛔ | P1 | Select signing key | | | `-n ` | Yes | Yes | ✅ | P2 | Show annotation lines | | | `-v, --verify` | Yes | No | ⛔ | P1 | Verify tag signatures | | `show` | (basic usage) | Yes | Yes | ⚠️ | P1 | Core behavior implemented; detailed flag parity needs further audit | | `reflog` | `show [--pretty=]` | Yes | Yes | ⚠️ | P1 | Supported; `--pretty` formatting parity may not be full Git parity | | | `delete ` | Yes | Yes | ✅ | - | Delete reflog entries | | | `exists ` | Yes | Yes | ✅ | - | Check reflog presence | | | `expire [--expire=