logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

hash.sh (369B)


  1. set -e
  2. if [ "$#" != 4 ] ; then
  3. echo 'usage: hash.sh repo mode name file' >&2
  4. exit 2
  5. fi
  6. repo=$1
  7. mode=$2
  8. name=$3
  9. shift 3
  10. case "$mode" in
  11. 12????)
  12. hash=$(printf %s "$1" | git -C "$repo" hash-object -w --stdin) ;;
  13. 10????)
  14. hash=$(git -C "$repo" hash-object -w --stdin <"$1") ;;
  15. *)
  16. echo "invalid mode: $mode"
  17. exit 1
  18. esac
  19. printf '%s %s\t%s\n' "$mode" "$hash" "$name"