Group Development with
Git, Github & Forth

October 26, 2019

Brad Nelson / @flagxor

Motivation

  • Keep a record of software as it changes
  • Go back to different versions
  • Compare versions
  • Work on software in groups
  • Hell is other people

polyFORTH AUDIT

  • Compare and merge two versions of a set of source blocks
  • 2 PART 100 150 MATCHING
    2 PART 100 200 4 AGAINST
  • Integrated with block editor
  • L, O (without diff) V, W (with diff highlighted)
  • KEEP, TOSS to finish a block

polyFORTH AUDIT

History

SCCS

  • SCCS = Source Code Control System
  • SCCS (SNOBOL) - 1972
  • SCCS (C) - 1977
  • Store version history per file
  • Record changes a series of edits
  • Used as internal format of BitKeeper, Teamware

RCS - 1982

  • RCS = Revision Control System
  • Store version history per file
  • Files are checked in and out with locking
  • Support for branches and merging
  • Used internally by CVS
  • Sharing often via NFS or other file shares

RCS Usage

( create a new file called foo.txt)
ci foo.txt
co foo.txt
( compile or otherwise use it )
co -l foo.txt
( edit foo.txt )
ci foo.txt

RCS Branches

diff - 1974

diff a.txt b.txt 
2,3c2,3
< In this example, some
< things will be changed.
---
> In this example, one
> thing will be changed.
This is an example.
In this example, some
things will be changed.
The quick brown fox jumped
over the lazy dog.
This is an example.
In this example, one
thing will be changed.
The quick brown fox jumped
over the lazy dog.

diff (unified) - 1990

diff -u a.txt b.txt 
--- a.txt	2019-10-25 22:56:26.000000000 -0700
+++ b.txt	2019-10-25 22:56:52.000000000 -0700
@@ -1,6 +1,6 @@
 This is an example.
-In this example, some
-things will be changed.
+In this example, one
+thing will be changed.
 The quick brown fox jumped
 over the lazy dog.
This is an example.
In this example, some
things will be changed.
The quick brown fox jumped
over the lazy dog.
This is an example.
In this example, one
thing will be changed.
The quick brown fox jumped
over the lazy dog.

patch - 1985

  • Reverse what diff does!
  • Created by Larry Wall (inventor of Perl)
  • Developers can now send "patches"
  • Diffs can sometimes apply even if things change
  • Diffs can partially apply

CVS - 1990

  • CVS = Concurrent Version System
  • Created by Dick Grune to work with his grad students
  • Checkouts can be edited conncurrently
  • Before a develop can commit they have update and resolve conflicts
  • Uses RCS underneath
  • Commits are not atomic

CVS Usage

cvs checkout prog1
cd prog1
( create foo.txt )
cvs add foo.txt
cvs commit
( edit foo.txt 0
cvs commit

ClearCase - 1992

  • Proprietary
  • Source control integrated with file system
  • Non-atomic commits
  • Track a "bill of materials"
  • Integration with build system
  • Centralized repository and administration

Perforce - 1995

  • Proprietary
  • Scales to large repositories
  • External APIs
  • Atomic commits, monotonically increasing CL# (Change List)
  • Branches supported, but merging is so-so
  • Centralized repository and administration
  • Influenced internal tools at Google and Microsoft

Subversion - 2000

  • Atomic commits, monotonically increasing revision numbers
  • Network protocol
  • A better CVS

Subversion Usage

svn checkout http://src.chromium.org/chrome/
svn update
( add foo.c )
svn add foo.c
svn commit

BitKeeper - 2000

  • Proprietary
  • First major distributed version control system
  • Local copy of reposity history
  • Fast atomic local operation, low effort merges
  • Used to much controversy for Linux Kernel

Darcs - 2003

  • Darcs Advanced Revision Control System
  • Implemented in Haskell
  • History is viewed as series of patches
  • Patch algebra involving commuting and inverting patches
  • Potentially exponential time merges

Git - 2005

  • Distributed Version Control
  • Linus Tovalds implements in reaction to BitKeeper fiasco
  • Fast atomic local operation, low effort merges
  • Implemented in C, with some Perl, Bash, Tcl

Mercurial - 2005

  • Distributed Version Control
  • Also kicked off by BitKeeper incident
  • Fast atomic local operation, low effort merges
  • "Friendly" syntax closer to subversion
  • Implemented in Python, with some C
  • Used at Facebook and somewhat at Google

Crytographic Hashing

  • Input bits should maximally impact hash bits
  • Unbiased in constrast to a CRC
  • Likelihood of collisions low enough it can be ignored
  • Allows a "global unique id" for data without centralization coordination
  • Used as a digest for cryptographic signing
  • Used in proof of work algorithms for cryptocurrencies (Bitcoin)

SHA1 for Git

  • 160-bit, 20-byte, 40-hex digit digest
  • Theoretical attacks since 2005
  • Deprecated by NIST in 2011
  • PDF collision demonstrated by Google in 2017
  • Used for Git!

Git Structure

Git Commit

git cat-file -p 84526055cbc8ef43f5352766066f43598acbf464
----------------------------------------------------------
tree 3d3efe3c0a3cfd859a6c3946e6976f503c763c46
parent f45dde8ffd994689de229b67439021484164a7a3
author Brad Nelson  1571510583 -0700
committer Brad Nelson  1571510583 -0700

Starting next talk.

Git Tree

git cat-file -p 3d3efe3c0a3cfd859a6c3946e6976f503c763c46
--------------------------------------------------------
100644 blob d140ea...919970e7f88263	.gitignore
100644 blob 0908dd...2abe8af39aa0c4	.gitmodules
100644 blob b31ff8...f815b589370f27	Makefile
100644 blob 42d896...1dede9bcc9cfb4	README.md
040000 tree e9ce26...d8a43fd617c6fa	common
160000 commit 525e4f...41ac574475819f	impress.js
100644 blob b3560e...9392b53bbc2318	index.html
040000 tree 46efbd...28d5cc4c3b77cc	intro-2018-01-30
160000 commit 43eada...7831aef8e76759	reveal.js
040000 tree a92893...28aa4839243024	svfig-2015-04-25
040000 tree f2d72f...c232d967724c9c	svfig-2015-06-27
040000 tree 1fb97e...300822c331f04d	svfig-2015-07-25
040000 tree 699e54...1d2e885827f13b	svfig-2015-08-22
040000 tree 44991d...800e5d821d263d	svfig-2015-11-21
040000 tree 9ee021...f31bd91df36274	svfig-2016-01-23

Git Blob

git cat-file -p 42d896146a714d53b123706dfd1dede9bcc9cfb4
--------------------------------------------------------
Slides for Brad Nelson's SVFIG Talks.

View at: https://flagxor.github.io/svfig-talks

Git Branch / Merge

Git Rebasing

pick 4ffe208 Adding more to the talk.
pick c16e35a More improvements.
pick 1993d9d More

# Rebase 933b026..1993d9d onto 933b026 (3 commands)
#
# Commands:
# p, pick  = use commit
# r, reword  = use commit, but edit the commit message
# e, edit  = use commit, but stop for amending
# s, squash  = use commit, but meld into previous commit
# f, fixup  = like "squash", but discard this commit's log message
# x, exec  = run command (the rest of the line) using shell
# d, drop  = remove commit
# l, label 

Getting Git

  • Linux: sudo apt-get install git
  • Windows: Linux subsystem, cygwin, or native

Git Usage

git init
( create foo.fs )
git add foo.fs
git commit
( edit foo.fs )
git commit -a

Git Pushing and Pull

  • git push - push a branch to a remote server
  • git pull - fetch and merge changes from a remote server

Github

  • Centralized hosting for git repositories
  • Free for open source
  • Integrated code review via "pull requests"
  • Integrated web hosting of revisioned content
  • Integrated web based editor, syntax highlighting
  • Integrated markdown documentation
  • Wildly popular for hosting open source projects
  • Recently acquired by Microsoft

Travis-CI

  • Continuous Integration, integrated with github
  • Free (as in beer) for open source projects
  • Build instructions with each commit run in the cloud
  • Integration with github API to show status, enforce policy
  • Possible to provide credential keys to upload artifacts

.travis.yml

language: node_js

node_js:
  - "node"

script:
  - bash ./test/run-tests.sh

os:
  - linux
  - osx

Tutorial

slides at: github.com/flagxor

Thank you