Allow the default for --edit/--no-edit to be configured

The commands `git imerge continue` and `git imerge record` allow an
`--edit`/`--no-edit` option to choose whether to ask the user to edit
the commit messages if a merge commit is ready to be committed. These
messages are pretty useless, so add a configuration option
`imerge.editmergemessages` that can be used to set the default to
`--no-edit`.
This commit is contained in:
Michael Haggerty 2015-06-12 14:22:32 +02:00
parent e017c2b494
commit 33c6fe830b
2 changed files with 33 additions and 7 deletions

View File

@ -260,6 +260,30 @@ else:
return s
def get_default_edit():
"""Should '--edit' be used when committing intermediate user merges?
When 'git imerge continue' or 'git imerge record' finds a user
merge that can be committed, should it (by default) ask the user
to edit the commit message? This behavior can be configured via
'imerge.editmergemessages'. If it is not configured, return True.
Please note that this function is only used to choose the default
value. It can be overridden on the command line using '--edit' or
'--no-edit'.
"""
try:
return {'true' : True, 'false' : False}[
check_output(
['git', 'config', '--bool', 'imerge.editmergemessages']
).rstrip()
]
except CalledProcessError:
return True
class UncleanWorkTreeError(Failure):
pass
@ -2622,11 +2646,13 @@ def incorporate_user_merge(merge_state, edit_log_msg=None):
# There are staged changes; commit them if possible.
cmd = ['git', 'commit', '--no-verify']
if edit_log_msg is not None:
if edit_log_msg:
cmd += ['--edit']
else:
cmd += ['--no-edit']
if edit_log_msg is None:
edit_log_msg = get_default_edit()
if edit_log_msg:
cmd += ['--edit']
else:
cmd += ['--no-edit']
try:
check_call(cmd)

View File

@ -25,7 +25,7 @@ git checkout c
"$GIT_IMERGE" diagram --commits --frontier --html=imerge0.html
"$GIT_IMERGE" autofill || true
"$GIT_IMERGE" diagram --commits --frontier --html=imerge1.html
"$GIT_IMERGE" continue
"$GIT_IMERGE" continue --edit
echo 'cd version' >conflict.txt
git add conflict.txt
"$GIT_IMERGE" continue --no-edit
@ -41,7 +41,7 @@ git checkout c
echo 'cd version' >conflict.txt
git add conflict.txt
GIT_EDITOR=cat git commit
"$GIT_IMERGE" continue
"$GIT_IMERGE" continue --edit
"$GIT_IMERGE" diagram --commits --frontier --html=imerge4.html
"$GIT_IMERGE" finish --branch=c-d-full