git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC] git-merge.sh: better handling of combined --squash,--no-ff,--no-commit options

From
Gerrit Pape <pape@smarden.org>
Date
Mar 2, 2008, 17:58 UTC
Message-ID
<20080302175820.31385.qmail@9e9c5b8314ca7b.315fe32.mid.smarden.org>

git-merge used to use either the --squash,--no-squash, --no-ff,--ff, --no-commit,--commit option, whichever came last in the command line. This lead to some un-intuitive behavior, having

 git merge --no-commit --no-ff <branch>

actually commit the merge. Now git-merge respects --no-commit together with --no-ff, as well as other combinations of the options. However, this broke a selftest in t/t7600-merge.sh which expected to have --no-ff completely override the --squash option, so that

 git merge --squash --no-ff <branch>

fast-forwards, and makes a merge commit; now it prepares a squash commit. Combining --squash with --no-ff doesn't seem to make sense though, so the test is adapted to test --no-ff without the preceding --squash.

The unexpected behavior was reported by John Goerzen through
 http://bing.sdebian.org/468568
Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 git-merge.sh     |   13 +++++++------
 t/t7600-merge.sh |    1 +
 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/git-merge.sh b/git-merge.sh
index 1c123a3..2a5c456 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -37,6 +37,7 @@ use_strategies=
 
 allow_fast_forward=t
 allow_trivial_merge=t
+squash= no_commit=
 
 dropsave() {
 	rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
@@ -152,17 +153,17 @@ parse_config () {
 		--summary)
 			show_diffstat=t ;;
 		--squash)
-			allow_fast_forward=t squash=t no_commit=t ;;
+			squash=t no_commit=t ;;
 		--no-squash)
-			allow_fast_forward=t squash= no_commit= ;;
+			squash= no_commit= ;;
 		--commit)
-			allow_fast_forward=t squash= no_commit= ;;
+			no_commit= ;;
 		--no-commit)
-			allow_fast_forward=t squash= no_commit=t ;;
+			no_commit=t ;;
 		--ff)
-			allow_fast_forward=t squash= no_commit= ;;
+			allow_fast_forward=t ;;
 		--no-ff)
-			allow_fast_forward=false squash= no_commit= ;;
+			allow_fast_forward=f ;;
 		-s|--strategy)
 			shift
 			case " $all_strategies " in
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 50c51c8..085f55f 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -419,6 +419,7 @@ test_debug 'gitk --all'
 
 test_expect_success 'merge c0 with c1 (no-ff)' '
 	git reset --hard c0 &&
+	git config branch.master.mergeoptions "" &&
 	test_tick &&
 	git merge --no-ff c1 &&
 	verify_merge file result.1 &&
-- 
1.5.4.3
Next: Junio C Hamano
Message 1 of 3 in “git-merge.sh: better handling of combined --squash,--no-ff,--no-commit options”
  1. git-merge.sh: better handling of combined --squash,--no-ff,--no-commit optionsGerrit Pape, Mar 2, 2008
  2. Junio C HamanoMar 2, 2008
  3. git-merge.sh: better handling of combined --squash,--no-ff,--no-commit optionsGerrit Pape, Mar 3, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.