mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
Merge commit 'sg/merge-options^' into jk/renamelimit
* commit 'sg/merge-options^': merge, pull: add '--(no-)log' command line option fmt-merge-msg: add '--(no-)log' options and 'merge.log' config variable add 'merge.stat' config variable merge, pull: introduce '--(no-)stat' option doc: moved merge.* config variables into separate merge-config.txt
This commit is contained in:
commit
ec845695c4
11 changed files with 186 additions and 81 deletions
|
@ -779,37 +779,7 @@ man.viewer::
|
|||
Specify the programs that may be used to display help in the
|
||||
'man' format. See linkgit:git-help[1].
|
||||
|
||||
merge.summary::
|
||||
Whether to include summaries of merged commits in newly created
|
||||
merge commit messages. False by default.
|
||||
|
||||
merge.tool::
|
||||
Controls which merge resolution program is used by
|
||||
linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3",
|
||||
"tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
|
||||
"opendiff". Any other value is treated is custom merge tool
|
||||
and there must be a corresponing mergetool.<tool>.cmd option.
|
||||
|
||||
merge.verbosity::
|
||||
Controls the amount of output shown by the recursive merge
|
||||
strategy. Level 0 outputs nothing except a final error
|
||||
message if conflicts were detected. Level 1 outputs only
|
||||
conflicts, 2 outputs conflicts and file changes. Level 5 and
|
||||
above outputs debugging information. The default is level 2.
|
||||
Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
|
||||
|
||||
merge.<driver>.name::
|
||||
Defines a human readable name for a custom low-level
|
||||
merge driver. See linkgit:gitattributes[5] for details.
|
||||
|
||||
merge.<driver>.driver::
|
||||
Defines the command that implements a custom low-level
|
||||
merge driver. See linkgit:gitattributes[5] for details.
|
||||
|
||||
merge.<driver>.recursive::
|
||||
Names a low-level merge driver to be used when
|
||||
performing an internal merge between common ancestors.
|
||||
See linkgit:gitattributes[5] for details.
|
||||
include::merge-config.txt[]
|
||||
|
||||
mergetool.<tool>.path::
|
||||
Override the path for the given tool. This is useful in case
|
||||
|
|
|
@ -9,8 +9,8 @@ git-fmt-merge-msg - Produce a merge commit message
|
|||
SYNOPSIS
|
||||
--------
|
||||
[verse]
|
||||
git-fmt-merge-msg [--summary | --no-summary] <$GIT_DIR/FETCH_HEAD
|
||||
git-fmt-merge-msg [--summary | --no-summary] -F <file>
|
||||
git-fmt-merge-msg [--log | --no-log] <$GIT_DIR/FETCH_HEAD
|
||||
git-fmt-merge-msg [--log | --no-log] -F <file>
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
@ -24,15 +24,19 @@ automatically invoking `git-merge`.
|
|||
OPTIONS
|
||||
-------
|
||||
|
||||
--summary::
|
||||
--log::
|
||||
In addition to branch names, populate the log message with
|
||||
one-line descriptions from the actual commits that are being
|
||||
merged.
|
||||
|
||||
--no-summary::
|
||||
--no-log::
|
||||
Do not list one-line descriptions from the actual commits being
|
||||
merged.
|
||||
|
||||
--summary,--no-summary::
|
||||
Synonyms to --log and --no-log; these are deprecated and will be
|
||||
removed in the future.
|
||||
|
||||
--file <file>, -F <file>::
|
||||
Take the list of merged objects from <file> instead of
|
||||
stdin.
|
||||
|
@ -40,10 +44,14 @@ OPTIONS
|
|||
CONFIGURATION
|
||||
-------------
|
||||
|
||||
merge.summary::
|
||||
merge.log::
|
||||
Whether to include summaries of merged commits in newly
|
||||
merge commit messages. False by default.
|
||||
|
||||
merge.summary::
|
||||
Synonym to `merge.log`; this is deprecated and will be removed in
|
||||
the future.
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
linkgit:git-merge[1]
|
||||
|
|
|
@ -9,7 +9,7 @@ git-merge - Join two or more development histories together
|
|||
SYNOPSIS
|
||||
--------
|
||||
[verse]
|
||||
'git-merge' [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]...
|
||||
'git-merge' [-n] [--stat] [--no-commit] [--squash] [-s <strategy>]...
|
||||
[-m <msg>] <remote> <remote>...
|
||||
'git-merge' <msg> HEAD <remote>...
|
||||
|
||||
|
@ -46,18 +46,7 @@ linkgit:git-reset[1].
|
|||
|
||||
CONFIGURATION
|
||||
-------------
|
||||
|
||||
merge.summary::
|
||||
Whether to include summaries of merged commits in newly
|
||||
created merge commit. False by default.
|
||||
|
||||
merge.verbosity::
|
||||
Controls the amount of output shown by the recursive merge
|
||||
strategy. Level 0 outputs nothing except a final error
|
||||
message if conflicts were detected. Level 1 outputs only
|
||||
conflicts, 2 outputs conflicts and file changes. Level 5 and
|
||||
above outputs debugging information. The default is level 2.
|
||||
Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
|
||||
include::merge-config.txt[]
|
||||
|
||||
branch.<name>.mergeoptions::
|
||||
Sets default options for merging into branch <name>. The syntax and
|
||||
|
|
35
Documentation/merge-config.txt
Normal file
35
Documentation/merge-config.txt
Normal file
|
@ -0,0 +1,35 @@
|
|||
merge.stat::
|
||||
Whether to print the diffstat berween ORIG_HEAD and merge result
|
||||
at the end of the merge. True by default.
|
||||
|
||||
merge.log::
|
||||
Whether to include summaries of merged commits in newly created
|
||||
merge commit messages. False by default.
|
||||
|
||||
merge.tool::
|
||||
Controls which merge resolution program is used by
|
||||
linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3",
|
||||
"tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
|
||||
"opendiff". Any other value is treated is custom merge tool
|
||||
and there must be a corresponing mergetool.<tool>.cmd option.
|
||||
|
||||
merge.verbosity::
|
||||
Controls the amount of output shown by the recursive merge
|
||||
strategy. Level 0 outputs nothing except a final error
|
||||
message if conflicts were detected. Level 1 outputs only
|
||||
conflicts, 2 outputs conflicts and file changes. Level 5 and
|
||||
above outputs debugging information. The default is level 2.
|
||||
Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
|
||||
|
||||
merge.<driver>.name::
|
||||
Defines a human readable name for a custom low-level
|
||||
merge driver. See linkgit:gitattributes[5] for details.
|
||||
|
||||
merge.<driver>.driver::
|
||||
Defines the command that implements a custom low-level
|
||||
merge driver. See linkgit:gitattributes[5] for details.
|
||||
|
||||
merge.<driver>.recursive::
|
||||
Names a low-level merge driver to be used when
|
||||
performing an internal merge between common ancestors.
|
||||
See linkgit:gitattributes[5] for details.
|
|
@ -1,10 +1,23 @@
|
|||
--summary::
|
||||
--stat::
|
||||
Show a diffstat at the end of the merge. The diffstat is also
|
||||
controlled by the configuration option merge.diffstat.
|
||||
controlled by the configuration option merge.stat.
|
||||
|
||||
-n, \--no-summary::
|
||||
-n, \--no-stat::
|
||||
Do not show diffstat at the end of the merge.
|
||||
|
||||
--summary, \--no-summary::
|
||||
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
|
||||
|
|
|
@ -6,13 +6,18 @@
|
|||
#include "tag.h"
|
||||
|
||||
static const char *fmt_merge_msg_usage =
|
||||
"git-fmt-merge-msg [--summary] [--no-summary] [--file <file>]";
|
||||
"git-fmt-merge-msg [--log] [--no-log] [--file <file>]";
|
||||
|
||||
static int merge_summary;
|
||||
|
||||
static int fmt_merge_msg_config(const char *key, const char *value)
|
||||
{
|
||||
if (!strcmp("merge.summary", key))
|
||||
static int found_merge_log = 0;
|
||||
if (!strcmp("merge.log", key)) {
|
||||
found_merge_log = 1;
|
||||
merge_summary = git_config_bool(key, value);
|
||||
}
|
||||
if (!found_merge_log && !strcmp("merge.summary", key))
|
||||
merge_summary = git_config_bool(key, value);
|
||||
return 0;
|
||||
}
|
||||
|
@ -258,9 +263,10 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
|
|||
git_config(fmt_merge_msg_config);
|
||||
|
||||
while (argc > 1) {
|
||||
if (!strcmp(argv[1], "--summary"))
|
||||
if (!strcmp(argv[1], "--log") || !strcmp(argv[1], "--summary"))
|
||||
merge_summary = 1;
|
||||
else if (!strcmp(argv[1], "--no-summary"))
|
||||
else if (!strcmp(argv[1], "--no-log")
|
||||
|| !strcmp(argv[1], "--no-summary"))
|
||||
merge_summary = 0;
|
||||
else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
|
||||
if (argc < 3)
|
||||
|
|
|
@ -780,7 +780,7 @@ _git_merge ()
|
|||
;;
|
||||
--*)
|
||||
__gitcomp "
|
||||
--no-commit --no-summary --squash --strategy
|
||||
--no-commit --no-stat --log --no-log --squash --strategy
|
||||
"
|
||||
return
|
||||
esac
|
||||
|
|
19
git-merge.sh
19
git-merge.sh
|
@ -8,8 +8,12 @@ OPTIONS_SPEC="\
|
|||
git-merge [options] <remote>...
|
||||
git-merge [options] <msg> HEAD <remote>
|
||||
--
|
||||
summary show a diffstat at the end of the merge
|
||||
n,no-summary don't show a diffstat at the end of the merge
|
||||
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)
|
||||
|
@ -37,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" \
|
||||
|
@ -148,10 +152,12 @@ merge_name () {
|
|||
parse_config () {
|
||||
while test $# != 0; do
|
||||
case "$1" in
|
||||
-n|--no-summary)
|
||||
-n|--no-stat|--no-summary)
|
||||
show_diffstat=false ;;
|
||||
--summary)
|
||||
--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."
|
||||
|
@ -210,6 +216,7 @@ while test $args_left -lt $#; do shift; done
|
|||
|
||||
if test -z "$show_diffstat"; then
|
||||
test "$(git config --bool merge.diffstat)" = false && show_diffstat=false
|
||||
test "$(git config --bool merge.stat)" = false && show_diffstat=false
|
||||
test -z "$show_diffstat" && show_diffstat=t
|
||||
fi
|
||||
|
||||
|
@ -258,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
|
||||
|
|
20
git-pull.sh
20
git-pull.sh
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
# Fetch one or more remote refs and merge it/them into the current HEAD.
|
||||
|
||||
USAGE='[-n | --no-summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...'
|
||||
USAGE='[-n | --no-stat] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...'
|
||||
LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'
|
||||
SUBDIRECTORY_OK=Yes
|
||||
OPTIONS_SPEC=
|
||||
|
@ -16,19 +16,19 @@ cd_to_toplevel
|
|||
test -z "$(git ls-files -u)" ||
|
||||
die "You are in the middle of a conflicted merge."
|
||||
|
||||
strategy_args= no_summary= 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)
|
||||
while :
|
||||
do
|
||||
case "$1" in
|
||||
-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
|
||||
--no-summa|--no-summar|--no-summary)
|
||||
no_summary=-n ;;
|
||||
--summary)
|
||||
no_summary=$1
|
||||
;;
|
||||
-n|--no-stat|--no-summary)
|
||||
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)
|
||||
|
@ -172,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_summary $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
|
||||
|
|
|
@ -106,8 +106,24 @@ Merge branch 'left'
|
|||
Common #1
|
||||
EOF
|
||||
|
||||
test_expect_success 'merge-msg test #3' '
|
||||
test_expect_success 'merge-msg test #3-1' '
|
||||
|
||||
git config --unset-all merge.log
|
||||
git config --unset-all merge.summary
|
||||
git config merge.log true &&
|
||||
|
||||
git checkout master &&
|
||||
setdate &&
|
||||
git fetch . left &&
|
||||
|
||||
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
|
||||
git diff actual expected
|
||||
'
|
||||
|
||||
test_expect_success 'merge-msg test #3-2' '
|
||||
|
||||
git config --unset-all merge.log
|
||||
git config --unset-all merge.summary
|
||||
git config merge.summary true &&
|
||||
|
||||
git checkout master &&
|
||||
|
@ -136,8 +152,24 @@ Merge branches 'left' and 'right'
|
|||
Common #1
|
||||
EOF
|
||||
|
||||
test_expect_success 'merge-msg test #4' '
|
||||
test_expect_success 'merge-msg test #4-1' '
|
||||
|
||||
git config --unset-all merge.log
|
||||
git config --unset-all merge.summary
|
||||
git config merge.log true &&
|
||||
|
||||
git checkout master &&
|
||||
setdate &&
|
||||
git fetch . left right &&
|
||||
|
||||
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
|
||||
git diff actual expected
|
||||
'
|
||||
|
||||
test_expect_success 'merge-msg test #4-2' '
|
||||
|
||||
git config --unset-all merge.log
|
||||
git config --unset-all merge.summary
|
||||
git config merge.summary true &&
|
||||
|
||||
git checkout master &&
|
||||
|
@ -148,8 +180,24 @@ test_expect_success 'merge-msg test #4' '
|
|||
git diff actual expected
|
||||
'
|
||||
|
||||
test_expect_success 'merge-msg test #5' '
|
||||
test_expect_success 'merge-msg test #5-1' '
|
||||
|
||||
git config --unset-all merge.log
|
||||
git config --unset-all merge.summary
|
||||
git config merge.log yes &&
|
||||
|
||||
git checkout master &&
|
||||
setdate &&
|
||||
git fetch . left right &&
|
||||
|
||||
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
|
||||
git diff actual expected
|
||||
'
|
||||
|
||||
test_expect_success 'merge-msg test #5-2' '
|
||||
|
||||
git config --unset-all merge.log
|
||||
git config --unset-all merge.summary
|
||||
git config merge.summary yes &&
|
||||
|
||||
git checkout master &&
|
||||
|
|
|
@ -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() {
|
||||
|
@ -364,7 +368,7 @@ test_expect_success 'merge c1 with c2 (squash in config)' '
|
|||
|
||||
test_debug 'gitk --all'
|
||||
|
||||
test_expect_success 'override config option -n' '
|
||||
test_expect_success 'override config option -n with --summary' '
|
||||
git reset --hard c1 &&
|
||||
git config branch.master.mergeoptions "-n" &&
|
||||
test_tick &&
|
||||
|
@ -373,15 +377,30 @@ test_expect_success 'override config option -n' '
|
|||
verify_parents $c1 $c2 &&
|
||||
if ! grep "^ file | *2 +-$" diffstat.txt
|
||||
then
|
||||
echo "[OOPS] diffstat was not generated"
|
||||
echo "[OOPS] diffstat was not generated with --summary"
|
||||
false
|
||||
fi
|
||||
'
|
||||
|
||||
test_expect_success 'override config option -n with --stat' '
|
||||
git reset --hard c1 &&
|
||||
git config branch.master.mergeoptions "-n" &&
|
||||
test_tick &&
|
||||
git merge --stat c2 >diffstat.txt &&
|
||||
verify_merge file result.1-5 msg.1-5 &&
|
||||
verify_parents $c1 $c2 &&
|
||||
if ! grep "^ file | *2 +-$" diffstat.txt
|
||||
then
|
||||
echo "[OOPS] diffstat was not generated with --stat"
|
||||
false
|
||||
fi
|
||||
'
|
||||
|
||||
test_debug 'gitk --all'
|
||||
|
||||
test_expect_success 'override config option --summary' '
|
||||
test_expect_success 'override config option --stat' '
|
||||
git reset --hard c1 &&
|
||||
git config branch.master.mergeoptions "--summary" &&
|
||||
git config branch.master.mergeoptions "--stat" &&
|
||||
test_tick &&
|
||||
git merge -n c2 >diffstat.txt &&
|
||||
verify_merge file result.1-5 msg.1-5 &&
|
||||
|
@ -441,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
|
||||
|
|
Loading…
Reference in a new issue