Coder Social home page Coder Social logo

coinmamo / extremely-linear Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zegl/extremely-linear

0.0 0.0 0.0 55 KB

Extremely Linear Git History // git-linearize

Home Page: https://westling.dev/b/extremely-linear-git

License: MIT License

Shell 100.00%

extremely-linear's Introduction

Extremely Linear Git History

Dreaming of a git commit history that looks like this?

Screenshot 2022-11-22 at 16 16 40

  • Create meaningful checksums: The first commit is 0000000, then 0000001, then 0000002
  • Easy overview of your history
  • No need for semver or other external versioning, your commits are your version numbers
  • With the shit ("short git") wrapper, you can use commands like shit show 14, and shit log 100..150
  • 100% production ready, 0% recommended

Installation

brew install zegl/tap/git-linearize zegl/tap/git-shit

or copy the scripts (from the root of this repo) to somewhere on your PATH.

Usage

Run as git linearize.

git linearize - Create an extremely linear git history - github.com/zegl/extremely-linear

git linearize [command] [options]

command: (default command is to run the linearization process)
  -h, --help           show brief help
  --install-hook       installs git-linearize as a post-commit hook (current repo only)
  --make-epoch         makes the current commit the linearized epoch (00000000), use to adopt git-linearize in
                       existing repositories without having to rewrite the full history

general options (for all command):
  -v, --verbose                   more verbose logging
  --short                         use shorter 6 digit prefix (quick mode)
  --format [format]               specify your own prefix format (pritnf style)
  --if-branch [name]              only run if the current branch is [name]

  All command generally support all general options. For example, specifying --format to --install-hook means
  that git-linearize will be called with the same format in the future when triggered by the hook.

git-linearize requires the history to already be linear (no merge commits).

Beware: git-linearize will rebase your entire project history. Do not run unless you know what you're doing. Create a backup first!

shit โ€“ "short git"

This repository also contains shit. A git wrapper that converts non-padded prefixes to their padded counterpart.

  • shit show 14 translates to git show 00000140
  • shit log 10..14 --> git log 00000100..00000140

Install with brew install zegl/tap/git-shit, or copy the the script to somewhere on your PATH.

What's happening here

Read more in the "Extremely Linear Git History" blog post.

The hash of a git commit is created by combining the tree, commit parent(s), author, and the commit message.

git-linearize uses lucky_commit which inserts invisible whitespace characters at the end of the commit message until we get a SHA1 hash with the desired prefix.

git-linearize will convert/rebase your repository so that the first commit in the history has a prefix that starts with 00000000, the second commit will have the prefix 00000010, the third one will have 00000020 and so on.

Prefix format

Many git clients and forges, abbreviate commit hashes to the first 7 characters. git-linearize uses the first 7 characters for the counter (0 to 9 999 999), followed by a fixed 0, making the total prefix length 8 characters long.

| NNNNNNN | 0 | XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| counter |    \                 can be anything |
           \ always zero

Performance? Is this fast? ๐ŸŽ

Thanks to the GPU powered crashing in lucky_commit, generating a 8 character prefix takes roughly 2 seconds on my computer (2021 Macbook Pro with M1 Pro).

Using CPU-only crashing (if your computer does not have a GPU) attached, the same operation takes ~43 seconds on the same computer.

Future ideas and epic hacks

  • A pre-merge GitHub action that runs git-linearize
  • โœ… A post-commit commit hook
  • Make it easier to organize git-linearize on multiple branches (see: --if-branch)

Credits

Thanks to lucky_commit and githashcrash for the hard work of actually crunching the checksums, and for the inspiration to this project.

extremely-linear's People

Contributors

zegl avatar feefladder avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.