Guest User

Untitled

a guest
May 20th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #!/bin/bash -ex
  2.  
  3. orig_git=$HOME/caas
  4.  
  5. # want to make sure that what is pointed to has a .git directory ...
  6. git_dir=$(cd "$orig_git" 2>/dev/null && git rev-parse --git-dir 2>/dev/null)
  7. if test $? -ne 0; then
  8. echo "Not a git repository: \"$orig_git\""
  9. exit 128
  10. fi
  11.  
  12. case "$git_dir" in
  13. .git)
  14. git_dir="$orig_git/.git"
  15. ;;
  16. .)
  17. git_dir=$orig_git
  18. ;;
  19. esac
  20.  
  21. # don't link to a configured bare repository
  22. isbare=$(git --git-dir="$git_dir" config --bool --get core.bare)
  23. if test ztrue = "z$isbare"; then
  24. echo "\"$git_dir\" has core.bare set to true, remove from \"$git_dir/config\" to use $0"
  25. exit 128
  26. fi
  27.  
  28. # don't link to a workdir
  29. if test -h "$git_dir/config"; then
  30. echo "\"$orig_git\" is a working directory only, please specify a complete repository."
  31. exit 128
  32. fi
  33.  
  34. # make sure the links in the workdir have full paths to the original repo
  35. git_dir=$(cd "$git_dir" && pwd) || exit 1
  36.  
  37. mkdir -p "$WORKSPACE/.git"
  38.  
  39. # create the links to the original repo. explicitly exclude index, HEAD and
  40. # logs/HEAD from the list since they are purely related to the current working
  41. # directory, and should not be shared.
  42. for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn
  43. do
  44. # create a containing directory if needed
  45. case $x in
  46. */*)
  47. mkdir -p "$WORKSPACE/.git/${x%/*}"
  48. ;;
  49. esac
  50.  
  51. ln -s "$git_dir/$x" "$WORKSPACE/.git/$x"
  52. done
  53.  
  54. # copy the HEAD from the original repository as a default branch
  55. cp "$git_dir/HEAD" $WORKSPACE/.git/HEAD
Add Comment
Please, Sign In to add comment