i18n: rebase: fix marked string to use eval_gettext variant
[git.git] / git-merge-octopus.sh
blobd79fc84029293818e7baf14c414eaa3ca3989ac6
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
5 # Resolve two or more trees.
8 . git-sh-setup
9 . git-sh-i18n
11 LF='
14 # The first parameters up to -- are merge bases; the rest are heads.
15 bases= head= remotes= sep_seen=
16 for arg
18 case ",$sep_seen,$head,$arg," in
19 *,--,)
20 sep_seen=yes
22 ,yes,,*)
23 head=$arg
25 ,yes,*)
26 remotes="$remotes$arg "
29 bases="$bases$arg "
31 esac
32 done
34 # Reject if this is not an Octopus -- resolve should be used instead.
35 case "$remotes" in
36 ?*' '?*)
39 exit 2 ;;
40 esac
42 # MRC is the current "merge reference commit"
43 # MRT is the current "merge result tree"
45 if ! git diff-index --quiet --cached HEAD --
46 then
47 gettextln "Error: Your local changes to the following files would be overwritten by merge"
48 git diff-index --cached --name-only HEAD -- | sed -e 's/^/ /'
49 exit 2
51 MRC=$(git rev-parse --verify -q $head)
52 MRT=$(git write-tree)
53 NON_FF_MERGE=0
54 OCTOPUS_FAILURE=0
55 for SHA1 in $remotes
57 case "$OCTOPUS_FAILURE" in
59 # We allow only last one to have a hand-resolvable
60 # conflicts. Last round failed and we still had
61 # a head to merge.
62 gettextln "Automated merge did not work."
63 gettextln "Should not be doing an Octopus."
64 exit 2
65 esac
67 eval pretty_name=\${GITHEAD_$SHA1:-$SHA1}
68 if test "$SHA1" = "$pretty_name"
69 then
70 SHA1_UP="$(echo "$SHA1" | tr a-z A-Z)"
71 eval pretty_name=\${GITHEAD_$SHA1_UP:-$pretty_name}
73 common=$(git merge-base --all $SHA1 $MRC) ||
74 die "$(eval_gettext "Unable to find common commit with \$pretty_name")"
76 case "$LF$common$LF" in
77 *"$LF$SHA1$LF"*)
78 eval_gettextln "Already up-to-date with \$pretty_name"
79 continue
81 esac
83 if test "$common,$NON_FF_MERGE" = "$MRC,0"
84 then
85 # The first head being merged was a fast-forward.
86 # Advance MRC to the head being merged, and use that
87 # tree as the intermediate result of the merge.
88 # We still need to count this as part of the parent set.
90 eval_gettextln "Fast-forwarding to: \$pretty_name"
91 git read-tree -u -m $head $SHA1 || exit
92 MRC=$SHA1 MRT=$(git write-tree)
93 continue
96 NON_FF_MERGE=1
98 eval_gettextln "Trying simple merge with \$pretty_name"
99 git read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2
100 next=$(git write-tree 2>/dev/null)
101 if test $? -ne 0
102 then
103 gettextln "Simple merge did not work, trying automatic merge."
104 git-merge-index -o git-merge-one-file -a ||
105 OCTOPUS_FAILURE=1
106 next=$(git write-tree 2>/dev/null)
109 MRC="$MRC $SHA1"
110 MRT=$next
111 done
113 exit "$OCTOPUS_FAILURE"