Skip to content

Commit

Permalink
Merge branch 'sg/merge-options' (early part)
Browse files Browse the repository at this point in the history
* 'sg/merge-options' (early part):
  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
  • Loading branch information
Junio C Hamano committed May 9, 2008
2 parents 31a3c6b + efb779f commit ca1c991
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 81 deletions.
32 changes: 1 addition & 31 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -809,37 +809,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[]

man.<tool>.cmd::
Specify the command to invoke the specified man viewer. The
Expand Down
18 changes: 13 additions & 5 deletions Documentation/git-fmt-merge-msg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand All @@ -24,26 +24,34 @@ 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.

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]
Expand Down
15 changes: 2 additions & 13 deletions Documentation/git-merge.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>...

Expand Down Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions Documentation/merge-config.txt
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 16 additions & 3 deletions Documentation/merge-options.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 10 additions & 4 deletions builtin-fmt-merge-msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ _git_merge ()
;;
--*)
__gitcomp "
--no-commit --no-summary --squash --strategy
--no-commit --no-stat --log --no-log --squash --strategy
"
return
esac
Expand Down
19 changes: 13 additions & 6 deletions git-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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" \
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions git-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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)
Expand Down Expand Up @@ -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
Loading

0 comments on commit ca1c991

Please sign in to comment.