Comment 2 for bug 1706219

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

This is somewhat (extremely!) hairy but seems to work:

#!/bin/bash
set -eux
tarball=$1

#tmpdir=$(mktemp -d)
#cleanup () { rm -rf $tmpdir; }
#trap cleanup EXIT
tmpdir=../my-uupdate-work
mkdir $tmpdir

mkdir $tmpdir/unpacked
tar -C $tmpdir/unpacked -xf $tarball --strip-components=1

index_file=$(realpath .git/my-uupdate-index)
rm -f $index_file
GIT_INDEX_FILE=$index_file GIT_WORK_TREE=$tmpdir/unpacked git add -A
tmp_tree=$(GIT_INDEX_FILE=$index_file git write-tree)
git ls-tree ${tmp_tree} > $tmpdir/tree
deb_sha=$(git ls-tree HEAD^{tree} | awk '{ if ($4 == "debian") { print $3; } }')
echo -e "040000 tree $deb_sha\tdebian" >> $tmpdir/tree
new_tree=$(cat $tmpdir/tree | git mktree)
echo "Update upstream source from '$(basename $tarball)'" > $tmpdir/commit-msg
commit=$(git commit-tree -p HEAD -F $tmpdir/commit-msg ${new_tree})
git merge $commit

(cobbled together from reading bits of what gdb import-orig does)