Code

merge, pull: add '--(no-)log' command line option
authorSZEDER Gábor <szeder@ira.uka.de>
Sun, 6 Apr 2008 01:23:46 +0000 (03:23 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 13 Apr 2008 02:28:18 +0000 (19:28 -0700)
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>
Documentation/merge-options.txt
contrib/completion/git-completion.bash
git-merge.sh
git-pull.sh
t/t7600-merge.sh

index d4af5e2664d3e26c9d360a9b8b59fdc7cc878db6..f37a77648934fcd8c707cfc1446ef5425cc7fa79 100644 (file)
@@ -9,6 +9,15 @@
        Synonyms to --stat and --no-stat; these are deprecated and will be
        removed in the future.
 
+--log::
+       In addition to branch names, populate the log message with
+       one-line descriptions from the actual commits that are being
+       merged.
+
+--no-log::
+       Do not list one-line descriptions from the actual commits being
+       merged.
+
 --no-commit::
        Perform the merge but pretend the merge failed and do
        not autocommit, to give the user a chance to inspect and
index 0f54cfd8a37d05281eea5652ceefd61431d9581b..8091d2deb7d01f79b15d31812dd733aca479f03b 100755 (executable)
@@ -779,7 +779,7 @@ _git_merge ()
                ;;
        --*)
                __gitcomp "
-                       --no-commit --no-stat --squash --strategy
+                       --no-commit --no-stat --log --no-log --squash --strategy
                        "
                return
        esac
index 793c015550e26a8107e868ee447665ff227210ab..69b35d87e62b628d45f8e934f163b7ef64e2dda6 100755 (executable)
@@ -12,6 +12,8 @@ stat                 show a diffstat at the end of the merge
 n,no-stat            don't show a diffstat at the end of the merge
 summary              (synonym to --stat)
 no-summary           (synonym to --no-stat)
+log                  add list of one-line log to merge commit message
+no-log               don't add list of one-line log to merge commit message
 squash               create a single commit instead of doing a merge
 commit               perform a commit if the merge sucesses (default)
 ff                   allow fast forward (default)
@@ -39,7 +41,7 @@ use_strategies=
 
 allow_fast_forward=t
 allow_trivial_merge=t
-squash= no_commit=
+squash= no_commit= log_arg=
 
 dropsave() {
        rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
@@ -154,6 +156,8 @@ parse_config () {
                        show_diffstat=false ;;
                --stat|--summary)
                        show_diffstat=t ;;
+               --log|--no-log)
+                       log_arg=$1 ;;
                --squash)
                        test "$allow_fast_forward" = t ||
                                die "You cannot combine --squash with --no-ff."
@@ -261,7 +265,7 @@ else
        merge_name=$(for remote
                do
                        merge_name "$remote"
-               done | git fmt-merge-msg
+               done | git fmt-merge-msg $log_arg
        )
        merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name"
 fi
index ed83ce1e4ff5dde68c28847b5e757866d19c0d4e..bf0c2985af875cdb7b2c64998390dbee908ff14c 100755 (executable)
@@ -16,7 +16,7 @@ cd_to_toplevel
 test -z "$(git ls-files -u)" ||
        die "You are in the middle of a conflicted merge."
 
-strategy_args= no_stat= no_commit= squash= no_ff=
+strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
 curr_branch=$(git symbolic-ref -q HEAD)
 curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
 rebase=$(git config --bool branch.$curr_branch_short.rebase)
@@ -27,6 +27,8 @@ do
                no_stat=-n ;;
        --stat|--summary)
                no_stat=$1 ;;
+       --log|--no-log)
+               log_arg=$1 ;;
        --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
                no_commit=--no-commit ;;
        --c|--co|--com|--comm|--commi|--commit)
@@ -170,9 +172,9 @@ then
        exit
 fi
 
-merge_name=$(git fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
+merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
 test true = "$rebase" &&
        exec git-rebase $strategy_args --onto $merge_head \
        ${oldremoteref:-$merge_head}
-exec git-merge $no_stat $no_commit $squash $no_ff $strategy_args \
+exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
        "$merge_name" HEAD $merge_head
index dd3eb9736301c6b6a6872cc9d7ab4202b8c5a6f9..d21cd290d3d8e3d912b94045f3d3d9db8bdd7e7d 100755 (executable)
@@ -104,7 +104,11 @@ create_merge_msgs() {
        git log --no-merges ^HEAD c2 >>squash.1-5 &&
        echo "Squashed commit of the following:" >squash.1-5-9 &&
        echo >>squash.1-5-9 &&
-       git log --no-merges ^HEAD c2 c3 >>squash.1-5-9
+       git log --no-merges ^HEAD c2 c3 >>squash.1-5-9 &&
+       echo > msg.nolog &&
+       echo "* commit 'c3':" >msg.log &&
+       echo "  commit 3" >>msg.log &&
+       echo >>msg.log
 }
 
 verify_diff() {
@@ -456,6 +460,16 @@ test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
        verify_head $c1
 '
 
+test_expect_success 'merge log message' '
+       git reset --hard c0 &&
+       git merge --no-log c2 &&
+       git show -s --pretty=format:%b HEAD >msg.act &&
+       verify_diff msg.nolog msg.act "[OOPS] bad merge log message" &&
+       git merge --log c3 &&
+       git show -s --pretty=format:%b HEAD >msg.act &&
+       verify_diff msg.log msg.act "[OOPS] bad merge log message"
+'
+
 test_debug 'gitk --all'
 
 test_done