Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#!/bin/bash
# This file:
#   http://anggtwu.net/bin/eevgitlib1.sh.html
#   http://anggtwu.net/bin/eevgitlib1.sh
#          (find-angg "bin/eevgitlib1.sh")
# Author: Eduardo Ochs <eduardoochs@gmail.com>
#
# (defun e () (interactive) (find-angg "bin/eevgitlib1.sh"))
# (defun c () (interactive) (find-sh0 "cp -v ~/bin/eevgitlib1.sh $S/http/anggtwu.net/bin/"))
# (find-sh0 "cp -v ~/bin/eevgitlib1.sh $S/http/anggtwu.net/bin/")

# Based on: (find-angg "bin/git-defs")
# Usage on my machine:
#   . ~/bin/eevgitlib1.sh
# Usage elsewhere:
#   . /tmp/eevgitlib1.sh
#
# Used by: (find-es "git" "git-animations")
#          (find-es "git" "git-test-2")

# (find-gitdoc-links "log")
# (find-gitdoc-links "commit")
# (find-gitdoc-links "branch")
# (find-gitdoc-links "checkout")
# (find-gitdoc-links "merge")
# (find-git-intro)

# Index:
# «.basic»		(to "basic")
# «.basic-tests»	(to "basic-tests")
# «.Time»		(to "Time")
# «.Time-tests»		(to "Time-tests")
# «.MakeTree1»		(to "MakeTree1")
# «.eval»		(to "eval")
# «.eval-test»		(to "eval-test")


#  ____            _      
# | __ )  __ _ ___(_) ___ 
# |  _ \ / _` / __| |/ __|
# | |_) | (_| \__ \ | (__ 
# |____/ \__,_|___/_|\___|
#                         
# Basic commands, all implemented as shell functions.
# All of them start with an uppercase letter, except for "++N".
# Several of them use the environment variable N as a counter.
# «basic»  (to ".basic")

  N=0
  N () { echo $N; }
++N () { N=$[$N+1]; echo $N; }
Dump1   () { echo $1 \($(cat $1)\); }
Dumps   () { for i in $*; do Dump1 $i; done; }
Dump    () { Dumps $(find * -type f | sort); }
Modify1 () { ++N >> $1; }
Modify  () { for i in $*; do Modify1 $i; done; }
Commit  () { git commit -a -m $(N); }
Commit  () { git commit -a -m ${1:-$N}; }
Diagram () { git log --oneline --graph --decorate --all $*; }
Diagram () { git log --oneline --graph --decorate --all --date-order $*; }
Log1    () { git log --oneline -1 $*; }

Branch    () { git branch $*; }
Checkout  () { git checkout $*; }
Merge     () { git merge $*; }
MergeOurs () { git merge -s ours $*; }

# «basic-tests»  (to ".basic-tests")
: <<'%%%%%'
* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
rm -Rfv /tmp/eevgit*
mkdir   /tmp/eevgit-test1/
cd      /tmp/eevgit-test1/
cp -v $S/http/anggtwu.net/bin/eevgitlib1.sh /tmp/
.       /tmp/eevgitlib1.sh

N; ++N; N
Modify file1 file1 file1 file2
ls -lAF
cat file1
cat file2
Dump

git init
git add file1 file2
Diagram
               Commit A; Diagram
Modify  file1; Commit B; Diagram
                         Diagram

%%%%%


#  _____ _                
# |_   _(_)_ __ ___   ___ 
#   | | | | '_ ` _ \ / _ \
#   | | | | | | | | |  __/
#   |_| |_|_| |_| |_|\___|
#                         
# Commands for recording how a repository changes through time.
# Look at this flipbook animation:
#
#   http://anggtwu.net/LATEX/2023loeliger.pdf
#   http://anggtwu.net/IMAGES/2023loeliger.gif
#
# It shows how to build "_the_ Loelinger diagram" step by step - each
# page shows a step. More precisely, each page shows the Loelinger
# diagram of that step, and the small label at the right of each
# diagram is the timestamp of that step.
#
# A command like "Time 4:20" in a script means "it's 4:20 now", or "at
# this point of the script the timestamp is 4:20", or - as an action -
# "take a low-resolution picture of the git repository and save it in
# the file /tmp/eevgit_4:20". I usually use timestamps like "A1",
# "C1.5" and "D0", and my convention is that "E1" means "we're just
# after Commit E".
#
# The command "Timeline" cats all saved pictures and outputs them, in
# alphabetical/asciibetical/chronological order, to stdout.
#
# «Time»  (to ".Time")

Time0    () { echo "Time: $1"; Diagram; echo; }
Time     () { Time0 $1 | tee /tmp/eevgit_$1; }
Timeline () { cat /tmp/eevgit_*; }

# «Time-tests»  (to ".Time-tests")
: <<'%%%%%'
* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
rm -Rfv /tmp/eevgit*
mkdir   /tmp/eevgit-test1/
cd      /tmp/eevgit-test1/
cp -v $S/http/anggtwu.net/bin/eevgitlib1.sh /tmp/
.       /tmp/eevgitlib1.sh

T   () { Time $*; }
Chk () { Checkout $*; }

git init
Modify file1; git add file1
              T A0; Commit A; T A1; Branch brAC;  T A2
Modify file1; T B0; Commit B; T B1; Branch brBDG; T B2; Chk brAC;         T B3
Modify file1; T C0; Commit C; T C1;                     Chk brBDG;        T C3
Modify file1; T D0; Commit D; T D1;                     Chk HEAD^ -b brE; T D4
Modify file1; T E0; Commit E; T E1;                     Chk HEAD^;        T E3
   MergeOurs brAC -m F;       T F1; Branch brFI;  T F2; Chk brBDG;        T F3
Modify file1; T G0; Commit G; T G1;                     Chk HEAD^ -b brH; T G4
Modify file1; T H0; Commit H; T H1;                     Chk brFI;         T H3
Modify file1; T I0; Commit I; T I1;                     Chk HEAD^ -b brJ; T I4
Modify file1; T J0; Commit J; T J1;

Timeline
Timeline | tee /tmp/all

%%%%%











# (find-gitdocfile "revisions.txt")
# (find-gitdocfile "revisions.txt" "illustration, by Jon Loeliger")
#
# G   H   I   J
#  \ /     \ /
#   D   E   F
#    \  |  / \
#     \ | /   |
#      \|/    |
#       B     C
#        \   /
#         \ /
#          A

# «MakeTree1»  (to ".MakeTree1")
MakeTree1 () {
  git init
  Modify file1; Modify file2; git add file1 file2
                Commit A; Branch brAC
  Modify file1; Commit B; Branch brBDG; Checkout brAC
  Modify file1; Commit C;               Checkout brBDG
  Modify file1; Commit D;               Checkout HEAD^ -b brE
  Modify file1; Commit E;               Checkout HEAD^
     MergeOurs brAC -m F; Branch brFI;  Checkout brBDG
  Modify file1; Commit G;               Checkout HEAD^ -b brH
  Modify file1; Commit H;               Checkout brFI
  Modify file1; Commit I;               Checkout HEAD^ -b brJ
  Modify file1; Commit J
}

export PAGER=cat

: <<'%%%%%'
* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
. eevgitlib1.sh

rm -Rfv /tmp/eevgit-test1/
mkdir   /tmp/eevgit-test1/
cd      /tmp/eevgit-test1/
MakeTree1
Diagram

Modify file1; Modify file2; git add file1 file2
              Commit A; Branch brAC
Modify file1; Commit B; Branch brBDG; Checkout brAC
Modify file1; Commit C;               Checkout brBDG
Modify file1; Commit D;               Checkout HEAD^ -b brE
Modify file1; Commit E;               Checkout HEAD^
   MergeOurs brAC -m F; Branch brFI;  Checkout brBDG
Modify file1; Commit G;               Checkout HEAD^ -b brH
Modify file1; Commit H;               Checkout brFI
Modify file1; Commit I;               Checkout HEAD^ -b brJ
Modify file1; Commit J

Diagram
Dumps file1 file2
git ls-files
Log1

# (find-man "1 gitk")
gitk                    /tmp/eevgit-test1/
gitk --date-order       /tmp/eevgit-test1/
gitk --date-order --all /tmp/eevgit-test1/
gitk --decorate --date-order --all /tmp/eevgit-test1/
--date-order

# (find-gitk "/tmp/eevgit-test1/")
# (find-git-intro)

%%%%%


# «eval»  (to ".eval")
# (find-angg ".emacs" "find-gitdiag")
eval $1

# «eval-test»  (to ".eval-test")
: <<'%%%%%'
* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
rm -v   /tmp/eevgitlib1.sh
laf          eevgitlib1.sh
laf     /tmp/eevgitlib1.sh
cp -v        eevgitlib1.sh /tmp/
laf     /tmp/eevgitlib1.sh
.       /tmp/eevgitlib1.sh
rm -Rfv /tmp/eevgit-test1/
mkdir   /tmp/eevgit-test1/
cd      /tmp/eevgit-test1/
git init
Modify file1 file2
        /tmp/eevgitlib1.sh "Dump; echo; Diagram"


%%%%%




# Local Variables:
# mode:   sh
# End: