@matheusbsbs / matheus-bagliano / commits / efb779f887
Fork 0

merge, pull: add '--(no-)log' command line option

These are the command line option equivalents of the 'merge.log' config variable. The patch also updates documentation and bash completion accordingly, and adds a test. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Apr 6, 2008 at 03:23 UTC efb779f8873e5aa36be29a4e551186c62c1b580c
5 files changed +36 -7
Documentation/merge-options.txt
+9
@@ -9,6 +9,15 @@
9 Synonyms to --stat and --no-stat; these are deprecated and will be
10 removed in the future.
11
12 +--log::
13 + In addition to branch names, populate the log message with
14 + one-line descriptions from the actual commits that are being
15 + merged.
16 +
17 +--no-log::
18 + Do not list one-line descriptions from the actual commits being
19 + merged.
20 +
21 --no-commit::
22 Perform the merge but pretend the merge failed and do
23 not autocommit, to give the user a chance to inspect and
contrib/completion/git-completion.bash
+1 -1
@@ -779,7 +779,7 @@ _git_merge ()
779 ;;
780 --*)
781 __gitcomp "
782 - --no-commit --no-stat --squash --strategy
782 + --no-commit --no-stat --log --no-log --squash --strategy
783 "
784 return
785 esac
git-merge.sh
+6 -2
@@ -12,6 +12,8 @@ stat show a diffstat at the end of the merge
12 n,no-stat don't show a diffstat at the end of the merge
13 summary (synonym to --stat)
14 no-summary (synonym to --no-stat)
15 +log add list of one-line log to merge commit message
16 +no-log don't add list of one-line log to merge commit message
17 squash create a single commit instead of doing a merge
18 commit perform a commit if the merge sucesses (default)
19 ff allow fast forward (default)
@@ -39,7 +41,7 @@ use_strategies=
41
42 allow_fast_forward=t
43 allow_trivial_merge=t
42 -squash= no_commit=
44 +squash= no_commit= log_arg=
45
46 dropsave() {
47 rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
@@ -154,6 +156,8 @@ parse_config () {
156 show_diffstat=false ;;
157 --stat|--summary)
158 show_diffstat=t ;;
159 + --log|--no-log)
160 + log_arg=$1 ;;
161 --squash)
162 test "$allow_fast_forward" = t ||
163 die "You cannot combine --squash with --no-ff."
@@ -261,7 +265,7 @@ else
265 merge_name=$(for remote
266 do
267 merge_name "$remote"
264 - done | git fmt-merge-msg
268 + done | git fmt-merge-msg $log_arg
269 )
270 merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name"
271 fi
git-pull.sh
+5 -3
@@ -16,7 +16,7 @@ cd_to_toplevel
16 test -z "$(git ls-files -u)" ||
17 die "You are in the middle of a conflicted merge."
18
19 -strategy_args= no_stat= no_commit= squash= no_ff=
19 +strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
20 curr_branch=$(git symbolic-ref -q HEAD)
21 curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
22 rebase=$(git config --bool branch.$curr_branch_short.rebase)
@@ -27,6 +27,8 @@ do
27 no_stat=-n ;;
28 --stat|--summary)
29 no_stat=$1 ;;
30 + --log|--no-log)
31 + log_arg=$1 ;;
32 --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
33 no_commit=--no-commit ;;
34 --c|--co|--com|--comm|--commi|--commit)
@@ -170,9 +172,9 @@ then
172 exit
173 fi
174
173 -merge_name=$(git fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
175 +merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
176 test true = "$rebase" &&
177 exec git-rebase $strategy_args --onto $merge_head \
178 ${oldremoteref:-$merge_head}
177 -exec git-merge $no_stat $no_commit $squash $no_ff $strategy_args \
179 +exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
180 "$merge_name" HEAD $merge_head
t/t7600-merge.sh
+15 -1
@@ -104,7 +104,11 @@ create_merge_msgs() {
104 git log --no-merges ^HEAD c2 >>squash.1-5 &&
105 echo "Squashed commit of the following:" >squash.1-5-9 &&
106 echo >>squash.1-5-9 &&
107 - git log --no-merges ^HEAD c2 c3 >>squash.1-5-9
107 + git log --no-merges ^HEAD c2 c3 >>squash.1-5-9 &&
108 + echo > msg.nolog &&
109 + echo "* commit 'c3':" >msg.log &&
110 + echo " commit 3" >>msg.log &&
111 + echo >>msg.log
112 }
113
114 verify_diff() {
@@ -456,6 +460,16 @@ test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
460 verify_head $c1
461 '
462
463 +test_expect_success 'merge log message' '
464 + git reset --hard c0 &&
465 + git merge --no-log c2 &&
466 + git show -s --pretty=format:%b HEAD >msg.act &&
467 + verify_diff msg.nolog msg.act "[OOPS] bad merge log message" &&
468 + git merge --log c3 &&
469 + git show -s --pretty=format:%b HEAD >msg.act &&
470 + verify_diff msg.log msg.act "[OOPS] bad merge log message"
471 +'
472 +
473 test_debug 'gitk --all'
474
475 test_done