|
3 | 3 | # Copyright (c) 2005 Junio C Hamano |
4 | 4 | # |
5 | 5 |
|
6 | | - |
7 | | -USAGE='[-n] [--no-commit] [-s <strategy>]... <merge-message> <head> <remote>+' |
| 6 | +USAGE='[-n] [--no-commit] [--squash] [-s <strategy>]... <merge-message> <head> <remote>+' |
8 | 7 | . git-sh-setup |
9 | 8 |
|
10 | 9 | LF=' |
@@ -42,20 +41,49 @@ restorestate() { |
42 | 41 | fi |
43 | 42 | } |
44 | 43 |
|
| 44 | +finish_up_to_date () { |
| 45 | + case "$squash" in |
| 46 | + t) |
| 47 | + echo "$1 (nothing to squash)" ;; |
| 48 | + '') |
| 49 | + echo "$1" ;; |
| 50 | + esac |
| 51 | + dropsave |
| 52 | +} |
| 53 | + |
| 54 | +squash_message () { |
| 55 | + echo Squashed commit of the following: |
| 56 | + echo |
| 57 | + git-log --no-merges ^"$head" $remote |
| 58 | +} |
| 59 | + |
45 | 60 | finish () { |
46 | 61 | test '' = "$2" || echo "$2" |
47 | | - case "$merge_msg" in |
48 | | - '') |
49 | | - echo "No merge message -- not updating HEAD" |
| 62 | + case "$squash" in |
| 63 | + t) |
| 64 | + echo "Squash commit -- not updating HEAD" |
| 65 | + squash_message >"$GIT_DIR/SQUASH_MSG" |
50 | 66 | ;; |
51 | | - *) |
52 | | - git-update-ref HEAD "$1" "$head" || exit 1 |
| 67 | + '') |
| 68 | + case "$merge_msg" in |
| 69 | + '') |
| 70 | + echo "No merge message -- not updating HEAD" |
| 71 | + ;; |
| 72 | + *) |
| 73 | + git-update-ref HEAD "$1" "$head" || exit 1 |
| 74 | + ;; |
| 75 | + esac |
53 | 76 | ;; |
54 | 77 | esac |
55 | | - |
56 | | - case "$no_summary" in |
| 78 | + case "$1" in |
57 | 79 | '') |
58 | | - git-diff-tree --stat --summary -M "$head" "$1" |
| 80 | + ;; |
| 81 | + ?*) |
| 82 | + case "$no_summary" in |
| 83 | + '') |
| 84 | + git-diff-tree --stat --summary -M "$head" "$1" |
| 85 | + ;; |
| 86 | + esac |
59 | 87 | ;; |
60 | 88 | esac |
61 | 89 | } |
|
66 | 94 | -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\ |
67 | 95 | --no-summa|--no-summar|--no-summary) |
68 | 96 | no_summary=t ;; |
| 97 | + --sq|--squ|--squa|--squas|--squash) |
| 98 | + squash=t no_commit=t ;; |
69 | 99 | --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit) |
70 | 100 | no_commit=t ;; |
71 | 101 | -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\ |
|
152 | 182 | ?,1,"$1",*) |
153 | 183 | # If head can reach all the merge then we are up to date. |
154 | 184 | # but first the most common case of merging one remote. |
155 | | - echo "Already up-to-date." |
156 | | - dropsave |
| 185 | + finish_up_to_date "Already up-to-date." |
157 | 186 | exit 0 |
158 | 187 | ;; |
159 | 188 | ?,1,"$head",*) |
|
205 | 234 | done |
206 | 235 | if test "$up_to_date" = t |
207 | 236 | then |
208 | | - echo "Already up-to-date. Yeeah!" |
209 | | - dropsave |
| 237 | + finish_up_to_date "Already up-to-date. Yeeah!" |
210 | 238 | exit 0 |
211 | 239 | fi |
212 | 240 | ;; |
@@ -310,11 +338,17 @@ case "$best_strategy" in |
310 | 338 | git-merge-$best_strategy $common -- "$head_arg" "$@" |
311 | 339 | ;; |
312 | 340 | esac |
313 | | -for remote |
314 | | -do |
315 | | - echo $remote |
316 | | -done >"$GIT_DIR/MERGE_HEAD" |
317 | | -echo "$merge_msg" >"$GIT_DIR/MERGE_MSG" |
| 341 | + |
| 342 | +if test "$squash" = t |
| 343 | +then |
| 344 | + finish |
| 345 | +else |
| 346 | + for remote |
| 347 | + do |
| 348 | + echo $remote |
| 349 | + done >"$GIT_DIR/MERGE_HEAD" |
| 350 | + echo "$merge_msg" >"$GIT_DIR/MERGE_MSG" |
| 351 | +fi |
318 | 352 |
|
319 | 353 | if test "$merge_was_ok" = t |
320 | 354 | then |
|
0 commit comments