2
0

setup-git.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
  3. ##### setup git properly for FreeSWITCH
  4. if [ ! -d .git ]; then
  5. echo "error: must be run from within the top level of a FreeSWITCH git tree." 1>&2
  6. exit 1;
  7. fi
  8. err () {
  9. echo "error: $1" 1>&2
  10. exit 1
  11. }
  12. if ! git config user.name >/dev/null 2>&1; then
  13. name=$(git config user.name)
  14. [ -z "$name" ] \
  15. && [ -n "$NAME" ] && name="$NAME" || name=""
  16. echo -n "What is your full real name? [$name]: "
  17. read name_
  18. [ -n "$name_" ] && name="$name_"
  19. [ -z "$name" ] && err "Your name is required."
  20. git config --global user.name "$name"
  21. fi
  22. if ! git config user.email >/dev/null 2>&1; then
  23. email=$(git config user.email)
  24. [ -z "$email" ] \
  25. && [ -n "$EMAIL" ] && email="$EMAIL" || email=""
  26. echo -n "What is your email? [$email]: "
  27. read email_
  28. [ -n "$email_" ] && email="$email_"
  29. [ -z "$email" ] && err "Your email is required."
  30. git config --global user.email "$email"
  31. fi
  32. git config pull.rebase true
  33. git config branch.master.rebase true
  34. cat 1>&2 <<EOF
  35. ----------------------------------------------------------------------
  36. Git has been configured for FS successfully.
  37. pull.rebase and branch.master.rebase have been set to true
  38. This means that when you do a 'git pull' to fetch remote changes,
  39. your local changes will be rebased on top of the remote changes.
  40. This does NOT rewrite history on the remote FS repo, but it does
  41. change the commit hashes in your local tree.
  42. By default, 'git pull' is equivalent to running:
  43. git fetch && git merge origin/master
  44. What we've done here is change things such that 'git pull' is now
  45. equivalent to:
  46. git fetch && git rebase origin/master
  47. If you really want to merge rather than rebasing, run:
  48. git merge <commit>
  49. See 'man git-config' for more information. Also see the man pages
  50. for git-pull, git-fetch, git-merge, and git-rebase.
  51. EOF
  52. [ -n "$name" ] \
  53. && cat 1>&2 <<EOF
  54. Your name has been set to: $name
  55. via 'git config --global user.name "$name"
  56. EOF
  57. [ -n "$name" ] \
  58. && cat 1>&2 <<EOF
  59. Your email has been set to: $email
  60. via 'git config --global user.email "$email"
  61. EOF
  62. cat 1>&2 <<EOF
  63. If you're creating patches for FS, please review this document:
  64. docs/SubmittingPatches
  65. ----------------------------------------------------------------------
  66. EOF