3 # use "$1" or something in a real script, this
8 echo "Getting object database"
9 rsync
-avz --ignore-existing $merge_repo/objects
/. .git
/objects
/.
11 echo "Getting remote head"
12 rsync
-avz $merge_repo/HEAD .git
/MERGE_HEAD
15 merge_head
=$
(cat .git
/MERGE_HEAD
)
16 common
=$
(merge-base
$head $merge_head)
17 if [ -z "$common" ]; then
18 echo "Unable to find common commit between" $merge_head $head
22 # Get the trees associated with those commits
23 common_tree
=$
(cat-file commit
$common |
sed 's/tree //;q')
24 head_tree
=$
(cat-file commit
$head |
sed 's/tree //;q')
25 merge_tree
=$
(cat-file commit
$merge_head |
sed 's/tree //;q')
27 if [ "$common" == "$merge_head" ]; then
28 echo "Already up-to-date. Yeeah!"
31 if [ "$common" == "$head" ]; then
32 echo "Updating from $head to $merge_head."
33 echo "Destroying all noncommitted data!"
34 echo "Kill me within 3 seconds.."
36 read-tree
$merge_tree && checkout-cache
-f -a && update-cache
--refresh
37 echo $merge_head > .git
/HEAD
40 echo "Trying to merge $merge_head into $head"
41 read-tree
-m $common_tree $head_tree $merge_tree
42 result_tree
=$
(write-tree
) ||
exit 1
43 result_commit
=$
(echo "Merge $merge_repo" | commit-tree
$result_tree -p $head -p $merge_head)
44 echo "Committed merge $result_commit"
45 echo $result_commit > .git
/HEAD
46 read-tree
$result_tree && checkout-cache
-f -a && update-cache
--refresh