logo

shit

Unnamed repository; edit this file 'description' to name the repository. git clone https://hacktivis.me/git/mirror/shit.git

commit-tree (1053B)


  1. #!/bin/sh -eu
  2. SHIT_PATH=$(dirname "$0")
  3. . $SHIT_PATH/common.sh
  4. tree="$1"
  5. shift
  6. parents=
  7. while getopts p: opt
  8. do
  9. case $opt in
  10. p)
  11. parents="$(printf "%s" "$OPTARG" | tr -s , ' ')"
  12. ;;
  13. ?)
  14. printf "Usage: %s [-p <parents...>]\n" "$0" >&2
  15. exit 1
  16. ;;
  17. esac
  18. done
  19. # TODO: Read from git config
  20. if [ -z "$GIT_AUTHOR_NAME" ]
  21. then
  22. printf "GIT_AUTHOR_NAME unset\n"
  23. exit 1
  24. fi
  25. if [ -z "$GIT_AUTHOR_EMAIL" ]
  26. then
  27. printf "GIT_AUTHOR_EMAIL unset\n"
  28. exit 1
  29. fi
  30. GIT_COMMITTER_NAME=${GIT_COMMITTER_NAME:-$GIT_AUTHOR_NAME}
  31. GIT_COMMITTER_EMAIL=${GIT_COMMITTER_EMAIL:-$GIT_AUTHOR_EMAIL}
  32. GIT_AUTHOR_DATE=${GIT_AUTHOR_DATE:-$(date -u +'%s +0000')}
  33. GIT_COMMITTER_DATE=${GIT_COMMITTER_DATE:-$(date -u +'%s +0000')}
  34. printf "tree %s\n" "$tree"
  35. for parent in $parents
  36. do
  37. printf "parent %s\n" "$parent"
  38. done
  39. printf "author %s <%s> %s\n" \
  40. "$GIT_AUTHOR_NAME" "$GIT_AUTHOR_EMAIL" "$GIT_AUTHOR_DATE"
  41. printf "committer %s <%s> %s\n" \
  42. "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" "$GIT_COMMITTER_DATE"
  43. printf "\n"
  44. printf 'Enter your comment message:\n' >&2
  45. cat