Skip to content

web3infra-foundation/libra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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). 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 <COMMAND>

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

  • Windows
  • Linux
  • 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.

Commands

  • init

    • --bare
    • --template
    • -b, --initial-branch
    • -q, --quiet
    • --shared
    • <repo_directory>
    • --separate-git-dir
    • --object-format
  • clone

    • <remote_repo>
    • [local_path]
    • -b, --branch
    • --depth
    • --single-branch
    • --recurse-submodules
    • --bare
    • --mirror
  • add

    • <pathspec...>
    • -A, --all
    • -u, --update
    • --refresh
    • -v, --verbose
    • -n, --dry-run
    • --ignore-errors
    • -f, --force
    • -p, --patch
    • -i, --interactive
    • -N, --intent-to-add
    • --chmod=(+x|-x)
    • --renormalize
  • rm

    • <pathspec...>
    • --cached
    • -r, --recursive
    • -f, --force
    • --dry-run
    • --ignore-unmatch
    • --pathspec-from-file
    • --pathspec-file-nul
  • status

    • --porcelain
    • -s, --short
    • --branch
    • --ignored
    • --untracked-files[=no|normal|all]
    • --show-stash
  • commit

    • -m, --message
    • -F, --file
    • --allow-empty
    • --conventional
    • --amend
    • -s, --signoff
    • --disable-pre
    • -a, --all
    • -p, --patch
    • --no-verify
    • --no-edit
    • --author
    • --date
    • -S, --gpg-sign
    • --no-gpg-sign
  • log

    • -n, --number
    • --oneline
    • -p, --patch
    • --decorate
    • --no-decorate
    • [pathspec]
    • --graph
    • --pretty=
    • --abbrev-commit
    • --name-only
    • --name-status
    • --stat
    • --since / --until
    • --author
  • tag

    • -l, --list [pattern]
    • -d, --delete
    • -m, --message
    • -f, --force
    • -a
    • -s, --sign
    • -u
    • -n
    • -v, --verify
  • branch

    • <new_branch> [commit_hash]
    • -D, --delete
    • -u, --set-upstream-to
    • --show-current
    • -r, --remotes
    • --list
    • -d, --delete (safe)
    • -m, --move
    • -M, --move --force
    • -a, --all
    • --unset-upstream
    • --format
  • switch

    • -c, --create <new_branch>
    • -d, --detach
    • -C, --force-create
    • --guess / --no-guess
    • --track
    • --merge
    • --conflict=<style>
  • restore

    • <pathspec...>
    • -s, --source
    • -W, --worktree
    • -S, --staged
    • -p, --patch
    • --ignore-unmerged
    • --merge
    • --conflict=<style>
  • reset

    • [ (default HEAD)]
    • --soft
    • --mixed
    • --hard
    • [<pathspec...>]
    • --merge
    • --keep
    • --pathspec-from-file
  • diff

    • --old
    • --new
    • --staged
    • [pathspec]
    • --algorithm
    • --output
    • --cached
    • --name-only
    • --stat
    • --color
    • --word-diff
    • --ignore-space-at-eol / --ignore-space-change / --ignore-all-space
    • --submodule
  • merge

    • --no-ff / --ff-only
    • --squash
    • --commit / --no-commit
    • -m, --message
    • --strategy
    • --strategy-option
  • rebase

    • -i, --interactive
    • --onto
    • --autostash
    • --continue / --abort / --skip
  • cherry-pick

    • <commits...>
    • -n, --no-commit
    • -x
    • -e, --edit
    • -m, --mainline
    • --continue / --abort / --quit
  • revert

    • -n, --no-commit
    • --edit / --no-edit
    • -m, --mainline
    • --continue / --abort / --quit
  • remote

    • rename
    • set-url [--add] [--delete] [--push] [--all]
    • get-url [--push] [--all]
    • prune
    • update [ | ...]
    • add -f
    • add --tags / --no-tags
    • add -t
    • add -m
    • add --mirror=<push|fetch>
    • --verbose
  • lfs

    • track
    • untrack
    • locks
    • lock
    • unlock
    • install / uninstall
    • fetch / pull / push
    • ls-files
    • env / version
  • push

    • -u, --set-upstream
    • --force / --force-with-lease
    • --tags / --all
    • --delete
    • --dry-run
  • fetch

    • [] []
    • -a, --all
    • --tags
    • --prune
    • --force
    • --depth / --shallow-exclude
    • --multiple
  • pull

    • --rebase
    • --ff-only / --no-ff
    • --squash
    • --strategy
  • reflog

    • show [--pretty=]
    • delete <selectors...>
    • exists
    • expire [--expire=]
  • checkout

    • -b <new_branch> [start-point]
    • -B <new_branch> [start-point]
    • --detach
    • -f, --force
  • index-pack

    • <pack_file>
    • -o <index_file>
    • --index-version
    • --stdin
    • --fix-thin
    • --verify
  • config

    • --add
    • --get
    • --get-all
    • --unset
    • --unset-all
    • -l, --list
    • --name-only
    • -d, --default
    • --global / --system / --local
    • --file
    • --replace-all
    • --type=<bool|int|path>

Remote

  • push
  • pull
  • clone
  • fetch

Others

  • .gitignore
  • .gitattributes (only for lfs now)
  • LFS (embedded, with p2p feature)
  • ssh

Development

Refs to Development

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 24

Languages