summaryrefslogtreecommitdiff
path: root/scripts/tree.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/tree.sh')
-rw-r--r--scripts/tree.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/tree.sh b/scripts/tree.sh
new file mode 100644
index 00000000..15ae6991
--- /dev/null
+++ b/scripts/tree.sh
@@ -0,0 +1,19 @@
+set -e
+
+repo=$1
+tag=$2
+index=$3
+out=$4
+
+export GIT_INDEX_FILE="$PWD/$out.index"
+git -C "$repo" read-tree --empty
+git -C "$repo" update-index --index-info <"$index"
+tree=$(git -C "$repo" write-tree)
+git -C "$repo" update-ref "refs/tags/$tag" "$tree"
+
+printf '%s\n' "$tree" >"$out.tmp"
+if cmp -s "$out" "$out.tmp" ; then
+ rm "$out.tmp"
+else
+ mv "$out.tmp" "$out"
+fi