t / t1200-tutorial.shon commit default pull: forget about "newbie protection" for now. (fb8696d)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Johannes Schindelin
   4#
   5
   6test_description='A simple turial in the form of a test case'
   7
   8. ./test-lib.sh
   9
  10echo "Hello World" > hello
  11echo "Silly example" > example
  12
  13git-update-index --add hello example
  14
  15test_expect_success 'blob' "test blob = \"$(git-cat-file -t 557db03)\""
  16
  17test_expect_success 'blob 557db03' "test \"Hello World\" = \"$(git-cat-file blob 557db03)\""
  18
  19echo "It's a new day for git" >>hello
  20cat > diff.expect << EOF
  21diff --git a/hello b/hello
  22index 557db03..263414f 100644
  23--- a/hello
  24+++ b/hello
  25@@ -1 +1,2 @@
  26 Hello World
  27+It's a new day for git
  28EOF
  29git-diff-files -p > diff.output
  30test_expect_success 'git-diff-files -p' 'cmp diff.expect diff.output'
  31git diff > diff.output
  32test_expect_success 'git diff' 'cmp diff.expect diff.output'
  33
  34tree=$(git-write-tree 2>/dev/null)
  35
  36test_expect_success 'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tree"
  37
  38output="$(echo "Initial commit" | git-commit-tree $(git-write-tree) 2>&1 > .git/refs/heads/master)"
  39
  40git-diff-index -p HEAD > diff.output
  41test_expect_success 'git-diff-index -p HEAD' 'cmp diff.expect diff.output'
  42
  43git diff HEAD > diff.output
  44test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output'
  45
  46#rm hello
  47#test_expect_success 'git-read-tree --reset HEAD' "git-read-tree --reset HEAD ; test \"hello: needs update\" = \"$(git-update-index --refresh)\""
  48
  49cat > whatchanged.expect << EOF
  50commit VARIABLE
  51Author: VARIABLE
  52Date:   VARIABLE
  53
  54    Initial commit
  55
  56diff --git a/example b/example
  57new file mode 100644
  58index 0000000..f24c74a
  59--- /dev/null
  60+++ b/example
  61@@ -0,0 +1 @@
  62+Silly example
  63diff --git a/hello b/hello
  64new file mode 100644
  65index 0000000..557db03
  66--- /dev/null
  67+++ b/hello
  68@@ -0,0 +1 @@
  69+Hello World
  70EOF
  71
  72git-whatchanged -p --root | \
  73        sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \
  74                -e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \
  75> whatchanged.output
  76test_expect_success 'git-whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output'
  77
  78git tag my-first-tag
  79test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag'
  80
  81# TODO: test git-clone
  82
  83git checkout -b mybranch
  84test_expect_success 'git checkout -b mybranch' 'cmp .git/refs/heads/master .git/refs/heads/mybranch'
  85
  86cat > branch.expect <<EOF
  87  master
  88* mybranch
  89EOF
  90
  91git branch > branch.output
  92test_expect_success 'git branch' 'cmp branch.expect branch.output'
  93
  94git checkout mybranch
  95echo "Work, work, work" >>hello
  96git commit -m 'Some work.' -i hello
  97
  98git checkout master
  99
 100echo "Play, play, play" >>hello
 101echo "Lots of fun" >>example
 102git commit -m 'Some fun.' -i hello example
 103
 104test_expect_failure 'git resolve now fails' 'git resolve HEAD mybranch "Merge work in mybranch"'
 105
 106cat > hello << EOF
 107Hello World
 108It's a new day for git
 109Play, play, play
 110Work, work, work
 111EOF
 112
 113git commit -m 'Merged "mybranch" changes.' -i hello
 114
 115test_done
 116
 117cat > show-branch.expect << EOF
 118* [master] Merged "mybranch" changes.
 119 ! [mybranch] Some work.
 120--
 121-  [master] Merged "mybranch" changes.
 122*+ [mybranch] Some work.
 123EOF
 124
 125git show-branch --topo-order master mybranch > show-branch.output
 126test_expect_success 'git show-branch' 'cmp show-branch.expect show-branch.output'
 127
 128git checkout mybranch
 129
 130cat > resolve.expect << EOF
 131Updating from VARIABLE to VARIABLE
 132 example |    1 +
 133 hello   |    1 +
 134 2 files changed, 2 insertions(+), 0 deletions(-)
 135EOF
 136
 137git resolve HEAD master "Merge upstream changes." | \
 138        sed -e "1s/[0-9a-f]\{40\}/VARIABLE/g" > resolve.output
 139test_expect_success 'git resolve' 'cmp resolve.expect resolve.output'
 140
 141cat > show-branch2.expect << EOF
 142! [master] Merged "mybranch" changes.
 143 * [mybranch] Merged "mybranch" changes.
 144--
 145-- [master] Merged "mybranch" changes.
 146EOF
 147
 148git show-branch --topo-order master mybranch > show-branch2.output
 149test_expect_success 'git show-branch' 'cmp show-branch2.expect show-branch2.output'
 150
 151# TODO: test git fetch
 152
 153# TODO: test git push
 154
 155test_expect_success 'git repack' 'git repack'
 156test_expect_success 'git prune-packed' 'git prune-packed'
 157test_expect_failure '-> only packed objects' 'find -type f .git/objects/[0-9a-f][0-9a-f]'
 158
 159test_done
 160