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