Show More
@@ -96,6 +96,20 b' ask_if_merged() {' | |||||
96 | done |
|
96 | done | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
|
99 | # Check if conflict markers are present and ask if the merge was successful | |||
|
100 | conflicts_or_success() { | |||
|
101 | while egrep '^(<<<<<<< .*|=======|>>>>>>> .*)$' "$LOCAL" >/dev/null; do | |||
|
102 | echo "$LOCAL contains conflict markers." | |||
|
103 | echo "Keep this version? [y/n]" | |||
|
104 | read answer | |||
|
105 | case "$answer" in | |||
|
106 | y*|Y*) success;; | |||
|
107 | n*|N*) failure;; | |||
|
108 | esac | |||
|
109 | done | |||
|
110 | success | |||
|
111 | } | |||
|
112 | ||||
99 | # Clean up when interrupted |
|
113 | # Clean up when interrupted | |
100 | trap "failure" 1 2 3 6 15 # HUP INT QUIT ABRT TERM |
|
114 | trap "failure" 1 2 3 6 15 # HUP INT QUIT ABRT TERM | |
101 |
|
115 | |||
@@ -123,20 +137,20 b' if [ -n "$FILEMERGE" ]; then' | |||||
123 | # filemerge prefers the right by default |
|
137 | # filemerge prefers the right by default | |
124 | $FILEMERGE -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL" |
|
138 | $FILEMERGE -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL" | |
125 | [ $? -ne 0 ] && echo "FileMerge failed to launch" && failure |
|
139 | [ $? -ne 0 ] && echo "FileMerge failed to launch" && failure | |
126 | $TEST "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged |
|
140 | $TEST "$LOCAL" -nt "$CHGTEST" && conflicts_or_success || ask_if_merged | |
127 | fi |
|
141 | fi | |
128 |
|
142 | |||
129 | if [ -n "$DISPLAY" ]; then |
|
143 | if [ -n "$DISPLAY" ]; then | |
130 | # try using kdiff3, which is fairly nice |
|
144 | # try using kdiff3, which is fairly nice | |
131 | if [ -n "$KDIFF3" ]; then |
|
145 | if [ -n "$KDIFF3" ]; then | |
132 | $KDIFF3 --auto "$BASE" "$BACKUP" "$OTHER" -o "$LOCAL" || failure |
|
146 | $KDIFF3 --auto "$BASE" "$BACKUP" "$OTHER" -o "$LOCAL" || failure | |
133 | success |
|
147 | conflicts_or_success | |
134 | fi |
|
148 | fi | |
135 |
|
149 | |||
136 | # try using tkdiff, which is a bit less sophisticated |
|
150 | # try using tkdiff, which is a bit less sophisticated | |
137 | if [ -n "$TKDIFF" ]; then |
|
151 | if [ -n "$TKDIFF" ]; then | |
138 | $TKDIFF "$BACKUP" "$OTHER" -a "$BASE" -o "$LOCAL" || failure |
|
152 | $TKDIFF "$BACKUP" "$OTHER" -a "$BASE" -o "$LOCAL" || failure | |
139 | success |
|
153 | conflicts_or_success | |
140 | fi |
|
154 | fi | |
141 |
|
155 | |||
142 | if [ -n "$MELD" ]; then |
|
156 | if [ -n "$MELD" ]; then | |
@@ -147,7 +161,7 b' if [ -n "$DISPLAY" ]; then' | |||||
147 | # use the file with conflicts |
|
161 | # use the file with conflicts | |
148 | $MELD "$LOCAL.tmp.$RAND" "$LOCAL" "$OTHER" || failure |
|
162 | $MELD "$LOCAL.tmp.$RAND" "$LOCAL" "$OTHER" || failure | |
149 | # Also it doesn't return good error code |
|
163 | # Also it doesn't return good error code | |
150 | $TEST "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged |
|
164 | $TEST "$LOCAL" -nt "$CHGTEST" && conflicts_or_success || ask_if_merged | |
151 | fi |
|
165 | fi | |
152 | fi |
|
166 | fi | |
153 |
|
167 | |||
@@ -158,7 +172,7 b' if [ -n "$MERGE" -o -n "$DIFF3" ]; then' | |||||
158 | $EDITOR "$LOCAL" || failure |
|
172 | $EDITOR "$LOCAL" || failure | |
159 | # Some editors do not return meaningful error codes |
|
173 | # Some editors do not return meaningful error codes | |
160 | # Do not take any chances |
|
174 | # Do not take any chances | |
161 | $TEST "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged |
|
175 | $TEST "$LOCAL" -nt "$CHGTEST" && conflicts_or_success || ask_if_merged | |
162 | fi |
|
176 | fi | |
163 |
|
177 | |||
164 | # attempt to manually merge with diff and patch |
|
178 | # attempt to manually merge with diff and patch |
General Comments 0
You need to be logged in to leave comments.
Login now