spacepaste

  1.  
  2. #
  3. # create some example data
  4. #
  5. cd /tmp
  6. rm -rf exampledata workspace
  7. mkdir -p /tmp/exampledata/item123
  8. echo "file1 contents" > /tmp/exampledata/item123/file1
  9. echo "file2 contents" > /tmp/exampledata/item123/file2
  10. echo "file3 contents" > /tmp/exampledata/item123/file3
  11. mkdir -p /tmp/exampledata/item123/foo/bar
  12. echo "spam" > /tmp/exampledata/item123/foo/bar/eggs
  13. #
  14. # store that dummy data into a Git repo under /tmp/workspace/.db
  15. #
  16. rm -rf /tmp/workspace && mkdir /tmp/workspace
  17. git --git-dir=/tmp/workspace/.db init
  18. git --git-dir=/tmp/workspace/.db --work-tree=/tmp/exampledata/item123 add .
  19. tree_sha=`git --git-dir=/tmp/workspace/.db --work-tree=/tmp/exampledata/item123 write-tree`
  20. commit_sha=`git --git-dir=/tmp/workspace/.db commit-tree -m "initial storing of item123" $tree_sha`
  21. git --git-dir=/tmp/workspace/.db update-ref refs/heads/item123 $commit_sha
  22. #
  23. # check out a copy of the data we just started tracking
  24. #
  25. mkdir -p /tmp/workspace/iii
  26. git --git-dir=/tmp/workspace/.db --work-tree=/tmp/workspace/iii checkout item123 .
  27. #
  28. # The contents of /tmp/workspace/iii is now exactly the same as /tmp/exampledata/item123
  29. # It has been put in and retreives from a Git repo under /tmp/workspace/.db
  30. #
  31. #
  32. # make a change
  33. #
  34. echo "hello" >> /tmp/workspace/iii/world
  35. # how do I show differences between the contents of /tmp/workspace/iii and
  36. # the tree pointed to by the item123 commit?
  37.