-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Evolve resolves commit graph after reorder + amend downstream | ||
# ============================================================= | ||
|
||
# --- SETUP --- | ||
|
||
# Add directory with `git` executable to PATH | ||
env PATH=$PATH${:}/usr/bin/ | ||
|
||
# Specify commit timestamp so commit hashes are fixed. | ||
env GIT_COMMITTER_DATE='01 Jan 2023 00:00:00 UTC' | ||
|
||
# Specify the test interactive sequence editor program (used in `git rebase -i`). | ||
env GIT_SEQUENCE_EDITOR='seq_editor' | ||
|
||
# The test interactive editor should paste the instructions in `SEQ_EDITOR_INPUT` | ||
# into Git's instruction sheet. | ||
env SEQ_EDITOR_INPUT='.git/tree/rebase-instructs' | ||
|
||
# Setup the Git repository | ||
exec git init | ||
exec git config user.email "[email protected]" | ||
exec git config user.name "Test" | ||
exec write_file README.txt readme | ||
exec git add . | ||
exec git commit -m 'initial commit' --date $GIT_COMMITTER_DATE | ||
|
||
# BUG: This commit is needed to prevent a nil pointer dereference (getting the | ||
# parent of an initial commit). Fix the algorithm and remove this extra commit. | ||
exec write_file dummy.txt dummy | ||
exec git add . | ||
exec git commit -m 'Add dummy.txt' --date $GIT_COMMITTER_DATE | ||
|
||
|
||
# Initial: | ||
# | ||
# [master] ─── (grovyle) ─── (treecko) ─── [sceptile] ─── [turtwig] | ||
# | ||
# Action: | ||
# 1. Reorder commits in [sceptile] | ||
# 2. Amend [turtwig] | ||
# | ||
# Result: | ||
# [master] ─── (treecko) ─── (grovyle) ─── [sceptile] ─── [turtwig] | ||
|
||
# Add commits to sceptile branch | ||
exec git checkout -b sceptile | ||
|
||
exec write_file grovyle.txt grovyle | ||
exec git add . | ||
exec git commit -m 'Add grovyle.txt' --date $GIT_COMMITTER_DATE | ||
|
||
exec write_file treecko.txt treecko | ||
exec git add . | ||
exec git commit -m 'Add treecko.txt' --date $GIT_COMMITTER_DATE | ||
|
||
exec write_file sceptile.txt sceptile | ||
exec git add . | ||
exec git commit -m 'Add sceptile.txt' --date $GIT_COMMITTER_DATE | ||
|
||
|
||
# Add commits to turtwig branch | ||
exec git checkout -b turtwig | ||
|
||
exec write_file turtwig.txt turtwig | ||
exec git add . | ||
exec git commit -m 'Add turtwig.txt' --date $GIT_COMMITTER_DATE | ||
|
||
|
||
# Initialize git-tree | ||
exec git-tree init | ||
|
||
# Reorder the commits in the graph. | ||
exec git checkout sceptile | ||
exec git rebase -i HEAD~3 | ||
|
||
|
||
# Amend a downstream commit | ||
exec git checkout turtwig | ||
exec git commit --amend -m 'Amend turtwig.txt' --date $GIT_COMMITTER_DATE | ||
|
||
|
||
# --- TEST --- | ||
|
||
# Run evolve | ||
exec git-tree evolve | ||
|
||
# BUG: The old commit still exists in the repository, since it's pointed to by | ||
# branch `git-tree-root`. Fix `git-tree-root` target instead of dropping git-tree. | ||
exec git-tree drop | ||
|
||
# Compare the git log | ||
exec git log --oneline --graph --all --decorate | ||
cp stdout .git/actual-log | ||
exec compare .git/actual-log .git/golden-log | ||
|
||
|
||
-- .git/tree/rebase-instructs -- | ||
pick 5f510c1 Add treecko.txt | ||
pick 9793ef5 Add grovyle.txt | ||
pick 286d656 Add sceptile.txt | ||
-- .git/golden-log -- | ||
* a71bab3 (HEAD -> turtwig) Amend turtwig.txt | ||
* 689eb6b (sceptile) Add sceptile.txt | ||
* 64f5fcb Add grovyle.txt | ||
* 68f0d35 Add treecko.txt | ||
* a7c56ea (master) Add dummy.txt | ||
* cbfe4ef initial commit |