Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
# This file:
#   http://anggtwu.net/GIT/eevgitlib1.sh.html
#   http://anggtwu.net/GIT/eevgitlib1.sh
#          (find-angg "GIT/eevgitlib1.sh")
#            (find-eevgit "eevgitlib1.sh")
# Author: Eduardo Ochs <eduardoochs@gmail.com>
# License: GPL3
# Version: 2024jan05
#
# This is the library that is used by:
#   http://anggtwu.net/eev-intros/find-git-intro.html
#                                (find-git-intro)
# it defines lots of shell functions and does a few other things, like
# "N=0" and "export PAGER=cat".
#
# See: (find-git-intro)
#      (find-git-intro "1. Preparation")
#      http://anggtwu.net/2023-eev-git.html
#
# (defun e () (interactive) (find-eevgit "eevgitlib1.sh"))
# (find-eevgitfile "eevgitlib1.sh")
# (find-eevgitsh0 "cp -v eevgitlib1.sh $S/http/anggtwu.net/GIT/")
#
# Index:
# «.basic»		(to "basic")
# «.basic-tests»	(to "basic-tests")
# «.MakeTree1»		(to "MakeTree1")
# «.MakeTree1-test»	(to "MakeTree1-test")
# «.Time»		(to "Time")
# «.Time-tests»		(to "Time-tests")


#  ____            _      
# | __ )  __ _ ___(_) ___ 
# |  _ \ / _` / __| |/ __|
# | |_) | (_| \__ \ | (__ 
# |____/ \__,_|___/_|\___|
#                         
# 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)
. eevgitlib1.sh
rm -Rfv /tmp/eevgit*
mkdir   /tmp/eevgit-test1/
cd      /tmp/eevgit-test1/

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

%%%%%



#  __  __       _       _____              _ 
# |  \/  | __ _| | ____|_   _| __ ___  ___/ |
# | |\/| |/ _` | |/ / _ \| || '__/ _ \/ _ \ |
# | |  | | (_| |   <  __/| || | |  __/  __/ |
# |_|  |_|\__,_|_|\_\___||_||_|  \___|\___|_|
#                                            
# See:
#   (find-git-intro "2. A first test")
#   http://anggtwu.net/eev-intros/find-git-intro.html#2
# This creates a git repository whose tree of commits has this shape:
#
# G   H   I   J
#  \ /     \ /
#   D   E   F
#    \  |  / \
#     \ | /   |
#      \|/    |
#       B     C
#        \   /
#         \ /
#          A
#
# «MakeTree1»  (to ".MakeTree1")
MakeTree1 () {
  git init
  Modify file1; git add file1
                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

# «MakeTree1-test»  (to ".MakeTree1-test")
: <<'%%%%%'
* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
. eevgitlib1.sh

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

git show HEAD
git show HEAD:file1
git show-ref
git show brFI
git ls-files
git log
git log --oneline

# TODO: add more examples of interrogators!
# See: (find-gitdoc-links "show")
#      (find-gitdoc-links "show-ref")
#      (find-gitdoc-links "log")
#      (find-gitdocfile    "cmds-plumbinginterrogators.txt")
#      (find-gitdocfile "" "cmds-plumbinginterrogators.txt")

%%%%%




#  _____ _                
# |_   _(_)_ __ ___   ___ 
#   | | | | '_ ` _ \ / _ \
#   | | | | | | | | |  __/
#   |_| |_|_| |_| |_|\___|
#                         
# 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")
# (find-git-intro "3. Timelines")
: <<'%%%%%'
* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
. eevgitlib1.sh
rm -Rfv /tmp/eevgit*
mkdir   /tmp/eevgit-test1/
cd      /tmp/eevgit-test1/

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

%%%%%






# Local Variables:
# mode:   sh
# coding: utf-8-unix
# End: