~ecs/tm

436fa08315a0cc61796f3d393441118120512a98 — Ember Sawady 3 years ago 0ab5000
update-ref: index is a normal ref now
1 files changed, 3 insertions(+), 13 deletions(-)

M tm-update-ref
M tm-update-ref => tm-update-ref +3 -13
@@ 1,17 1,7 @@
#!/bin/sh -eu

. "$(dirname -- "$0")/lib.sh"
if [ $# -ne 2 ]; then
	abort "usage: tm update-ref <refname> <ref>"
fi
out=""
if [ "z$1" = "zindex" ]; then
	out="$TM_DIR/index"
elif [ -f "$TM_DIR/refs/$1" ]; then
	out="$TM_DIR/refs/$1"
else
	printf "creating ref %s\n" "$1"
	out="$TM_DIR/refs/$1"
fi
[ $# -ne 2 ] && abort "usage: tm update-ref <refname> <ref>"
[ -f "$TM_DIR/refs/$1" ] || printf "creating ref %s\n" "$1"
ref="$(tm resolve-ref "$2")" || abort "error: invalid ref $2"
printf "%s\n" "$ref" >"$out"
printf "%s\n" "$ref" >"$TM_DIR/refs/$1"