Skip to content

feature request: „git config merge.edit“ #1792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Thomas-Lohrum opened this issue Aug 14, 2018 · 6 comments
Closed

feature request: „git config merge.edit“ #1792

Thomas-Lohrum opened this issue Aug 14, 2018 · 6 comments

Comments

@Thomas-Lohrum
Copy link

By default, Git does not open an editor to edit a commit-message when merging. Instead a default message is used. When set to true, this variable tells Git to open an editor before a commit is completed (equivalent to giving the --edit option from the command line). When set to false a commit is completed without interference (equivalent to giving the --no-edit option from the command line).

@dscho
Copy link
Member

dscho commented Aug 16, 2018

By default, Git does not open an editor to edit a commit-message when merging.

That is the opposite of the behavior I observe here.

Since you have been asked gently in the issue reporting template, and chose to ignore it, let me ask you not so gently anymore: please provide an MCVE (and specify exactly what Git for Windows version you are using).

@dscho
Copy link
Member

dscho commented Aug 16, 2018

(FWIW https://git-scm.com/docs/git-merge#git-merge---edit also suggests that the default behavior is to always open the editor.)

@Thomas-Lohrum
Copy link
Author

Thanks to the MCVE hint.

I did a fresh install of git (64-Bit) on Windows 10 and accepted all default settings for the install.

The git version is "git version 2.18.0.windows.1".

I opened a default Windows command window (no bash).

Steps to reproduce:
git init repo
cd repo
echo Hallo >file1.txt
git add .
git commit -m "file1 added"
git checkout -b featureBranch
echo Hello >file2.txt
git add .
git commit -m "file2 added"
git checkout master
git merge --no-ff featureBranch

Result:

  • no editor gets opened here
    => expected result "open editor"
  • the editor gets opened, when i set GIT_MERGE_AUTOEDIT=true
    => works as expected
  • no editor gets opened, when GIT_MERGE_AUTOEDIT=true and a message gets passed using -m switch
    => works as designed; an editor can still be opened by passing "--edit"

Comments:
When working with a GUI client such as SourceTree it is not always possible to adjust the required settings to git. As a solution i added '[branch "master"]mergeoptions = --no-ff --edit' to my repo configuration. The trouble is that i need to do this for every branch as there is no wildcard support such as '[branch "release/*"]'. I can use "merge.ff=false" as an equivalent to "--no-ff". However, there is no equivalent to the "--edit" switch. It can be controlled by the env-var "GIT_MERGE_AUTOEDIT" to some extend, but not in combination with the "-m" switch.

Summary:
I can now workaround by setting GIT_MERGE_AUTOEDIT=true. However it is not clear, why the editor does not open in the first place.
The suggested setting "merge.edit=true" could by used as an alternative to the env-var. It also would allow configuration as a repository-setting. Another consideration is to also open an editor, when the -m switch is used.

@dscho
Copy link
Member

dscho commented Aug 22, 2018

I tried that MCVE, but I got this:

image

However it is not clear, why the editor does not open in the first place.

Indeed. I have no idea why, either. Could it be that there is already a GIT_* variable set?

I can use "merge.ff=false" as an equivalent to "--no-ff". However, there is no equivalent to the "--edit" switch. It can be controlled by the env-var "GIT_MERGE_AUTOEDIT" to some extend, but not in combination with the "-m" switch.

While I still do not understand what is different in your setup than in mine that would cause that difference in behavior, let's get you started on implementing your desired feature.

Step number one: install the Git for Windows SDK

Simply download the installer from here and run it. It will download several hundred megabytes of data, and a gigabyte on disk, I think, so please be patient.

Step number two: build Git from source

This should be as easy as sdk build git in the SDK Bash window that will be opened in the end (and for which a Desktop shortcut will be installed).

Step number three: patch the source code.

First, switch to the worktree: sdk cd git.

Next, exit the appropriate file. To find out which one that is, I would follow the lead of merge.ff. To find out where it is handled, I would call git grep merge.ff. To edit the file in question, either use start <file>, or vi <file> if you are comfortable with vim. Otherwise, open an Explorer window using start . and then edit the file in question via the context menu.

Then, imitate the code for merge.ff to implement that merge.edit.

If you get stuck at any point, please do not hesitate to ask for help.

@dscho
Copy link
Member

dscho commented Feb 27, 2019

@Thomas-Lohrum you do not intend to give back to this project by contributing a patch to implement this, do you?

@Thomas-Lohrum
Copy link
Author

Git's default behaviour is to open an editor on a merge. As such my suggestion is not required. I can not tell why it does not work on my machine or on my colleagues. Setting GIT_MERGE_AUTOEDIT to true, does solve the requirement, though. Thanks for your offer and your help.

Thomas

@dscho dscho closed this as completed Mar 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants