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

[PATCH] contrib/subtree: add "--no-commit" flag for merge and pull

From
MLMike Lewis <mike@mplew.is>
Date
Mar 26, 2017, 07:02 UTC
Message-ID
<20170326070238.64522-1-mike@mplew.is>

Allows the user to verify and/or change the contents of the merge before committing as necessary

Signed-off-by: Mike Lewis <mike@mplew.is>
---
 contrib/subtree/git-subtree.sh | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index dec085a23..c30087485 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -29,6 +29,8 @@ onto=         try connecting new tree to an existing one
 rejoin        merge the new branch back into HEAD
  options for 'add', 'merge', and 'pull'
 squash        merge subtree changes as a single commit
+ options for 'merge' and 'pull'
+no-commit     perform the merge, but don't commit
 "
 eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
 
@@ -48,6 +50,7 @@ annotate=
 squash=
 message=
 prefix=
+commit_option="--commit"
 
 debug () {
 	if test -n "$debug"
@@ -137,6 +140,12 @@ do
 	--no-squash)
 		squash=
 		;;
+	--no-commit)
+		commit_option="--no-commit"
+		;;
+	--no-no-commit)
+		commit_option="--commit"
+		;;
 	--)
 		break
 		;;
@@ -815,17 +824,17 @@ cmd_merge () {
 	then
 		if test -n "$message"
 		then
-			git merge -s subtree --message="$message" "$rev"
+			git merge -s subtree --message="$message" "$commit_option" "$rev"
 		else
-			git merge -s subtree "$rev"
+			git merge -s subtree "$commit_option" "$rev"
 		fi
 	else
 		if test -n "$message"
 		then
 			git merge -Xsubtree="$prefix" \
-				--message="$message" "$rev"
+				--message="$message" "$commit_option" "$rev"
 		else
-			git merge -Xsubtree="$prefix" $rev
+			git merge -Xsubtree="$prefix" "$commit_option" $rev
 		fi
 	fi
 }
-- 
2.12.2
Next: David Aguilar
Message 1 of 3 in “contrib/subtree: add "--no-commit" flag for merge and pull”
  1. contrib/subtree: add "--no-commit" flag for merge and pullMike Lewis, Mar 26, 2017
  2. David AguilarMar 29, 2017
  3. Mike LewisMar 29, 2017

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.