Skip to content

Conversation

sina-hide
Copy link
Contributor

This adds another configuration possibility for the default merge mode to the already existing per branch git configuration branch.<name>.mergeoptions (#540) and the per repo preference "Preferred Merge Mode" (#1156).

Defined values:

  • false: do no fast-forward merge
  • only: do only a fast-forward merge

This is configurable by for example git config set --global merge.ff <value> for a global (meaning the current user) configuration.

The priority between these configurations/preferences is:

This adds another configuration possibility for the default merge mode
to the already existing per branch git configuration
`branch.<name>.mergeoptions` (sourcegit-scm#540) and the per repo preference
"Preferred Merge Mode" (sourcegit-scm#1156).

Defined values:
 - `false`: do no fast-forward merge
 - `only`: do only a fast-forward merge

This is configurable by for example `git config set --global merge.ff
<value>` for a global (meaning the current user) configuration.

The priority between these configurations/preferences is:

 - git configuration `branch.<name>.mergeoptions` (sourcegit-scm#540)
 - git configuration `merge.ff`
 - preference "Preferred Merge Mode" (sourcegit-scm#1156)
@sina-hide
Copy link
Contributor Author

@love-linger In addition to adding this feature I have done a few refactorings regarding MergeMode. If you don't like them, I can revert them.

@love-linger
Copy link
Collaborator

I think the Preferred Merge Mode in repository configuration (which can be traited as local setting) should use higher-priority than git config merge.ff.

I'll merge this first and modify it myself.

@love-linger love-linger self-assigned this Jul 3, 2025
@love-linger love-linger added the enhancement New feature or request label Jul 3, 2025
@love-linger love-linger merged commit 626a20a into sourcegit-scm:develop Jul 3, 2025
13 checks passed
love-linger added a commit that referenced this pull request Jul 3, 2025
- remove unused namespace using
- prefer to use repository's configuration than the global `merge.ff`

Signed-off-by: leo <[email protected]>
@sina-hide sina-hide deleted the config-merge-ff branch July 3, 2025 06:01
sina-hide added a commit to sina-hide/sourcegit that referenced this pull request Jul 3, 2025
After changing the priority of the preferences/configurations for the
merge mode in sourcegit-scm#1495, the git configuration `merge.ff` was ignored.  The
reason is, that `GetSettingsPreferredMergeMode()` does not return `null`
in the default case.  This is now fixed.
@sina-hide
Copy link
Contributor Author

I think the Preferred Merge Mode in repository configuration (which can be traited as local setting) should use higher-priority than git config merge.ff.

Okay!

I'll merge this first and modify it myself.

There was a little problem so merge.ff didn't work. See PR #1501.

love-linger pushed a commit that referenced this pull request Jul 3, 2025
After changing the priority of the preferences/configurations for the
merge mode in #1495, the git configuration `merge.ff` was ignored.  The
reason is, that `GetSettingsPreferredMergeMode()` does not return `null`
in the default case.  This is now fixed.
@love-linger
Copy link
Collaborator

I just realized that when the user selects the Default merge mode, SourceGit does not pass parameters related to the merge mode to the git merge command. That is to say, if the user selects the Default merge mode, the merge.ff configuration should take effect automatically. We don't need the GetGitConfigMergeFF function.

Moreover, the description of the Default mode may be a bit misleading. It should not be Fast-forward if possible, but rather Use git configuration.

@sina-hide
Copy link
Contributor Author

You are right, @love-linger. Your corresponding commit is d3d1377.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants