Skip to contentSkip to conversation

merge: --no-ff configuration setting

PATCH In review Bryan Alves 3 participants 3 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 merge: --no-ff configuration setting

Add a new configuration option, merge.allowfastforward

When set to false, causes --no-ff to be the default behavior for merges. When set to true, or not present, the default behavior is unchanged, and acts like --ff is set.

---
 Documentation/merge-options.txt |    4 +++-
 builtin-merge.c                 |    3 +++
 2 files changed, 6 insertions(+), 1 deletions(-)
Documentation/merge-options.txt +3 -1
index 3b83dba..6638af7 100644
@@ -14,7 +14,9 @@ inspect and further tweak the merge result before committing.
 	the default behavior of git-merge.
 +
 With --no-ff Generate a merge commit even if the merge
-resolved as a fast-forward.
+resolved as a fast-forward.  --no-ff can be made the
+default behavior with the configuration option
+merge.allowfastforward
 
 --log::
 --no-log::
builtin-merge.c +3 -0
index 3aaec7b..a96aaac 100644
@@ -495,6 +495,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 		free(buf);
 	}
 
+	if (!strcmp(k, "merge.allowfastforward"))
+		allow_fast_forward = !git_config_bool(k, v);
+
 	if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
 		show_diffstat = git_config_bool(k, v);
 	else if (!strcmp(k, "pull.twohead"))
Signature · 1 line
1.6.6.1
#1 lore raw
Quoted 5 lines · Bryan Alves

Add a new configuration option, merge.allowfastforward

When set to false, causes --no-ff to be the default behavior for merges. When set to true, or not present, the default behavior is unchanged, and acts like --ff is set.

The subject says --no-ff configuration but the option is for --ff. Sounds confusing. In other words, shouldn't it be merge.disallowfastforward or merge.nofastforward? Or maybe the subject should be "merge: --ff configuration setting"

Also could you just use branch.<name>.mergeoptions and not introduce yet another config option? Or maybe there's some reasoning why you always want to have merge commits in your workflow?

Finally if this goes in please add a description to Documentation/config.txt

#2 lore raw
In reply to Bryan Alves
Quoted 2 lines · Bryan Alves
 Documentation/merge-options.txt |    4 +++-
 builtin-merge.c                 |    3 +++

This needs tests to make sure that existing programs that internally use "git merge" (e.g. "rebase -m", "rebase -i") do not break when the end user has this configuration set in the repository, in addition to that "merge" works as expected with and without this configuration variable, with combinations with the use of relevant command line options.