threads / patch / 33137

patch, 19 partsAdded --force option to push

Subject: [PATCH 18/19] Added --force option to push

## tl;dr

One message between Mar 9, 2013 and Mar 9, 2013. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Paul Campbell· Mar 9, 2013, 19:30 UTC · lore
>From ae7c05bdc6d02fa89deabb59cec6150308f227f7 Mon Sep 17 00:00:00 2001
From: Paul Campbell <pcampbell@kemitix.net>
Date: Sat, 9 Mar 2013 18:35:42 +0000
Subject: [PATCH 18/19] Added --force option to push
Conflicts:
	contrib/subtree/git-subtree.sh
Original-Author: James Roper <jroper@vz.net>
Conflicts-resolved-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.sh  | 9 ++++++++-
 contrib/subtree/git-subtree.txt | 5 +++++
 2 files changed, 13 insertions(+), 1 deletion(-)
Show changes to 2 files +13 −1

contrib/subtree/git-subtree.sh, contrib/subtree/git-subtree.txt

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 4605203..3582a55 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -32,6 +32,8 @@ b,branch=     create a new branch from the split subtree
 ignore-joins  ignore prior --rejoin commits
 onto=         try connecting new tree to an existing one
 rejoin        merge the new branch back into HEAD
+ options for 'push'
+f,force       use force push
  options for 'add', 'merge', 'pull' and 'push'
 squash        merge subtree changes as a single commit
 "
@@ -90,6 +92,7 @@ while [ $# -gt 0 ]; do
 		-b) branch="$1"; shift ;;
 		-P) prefix="$1"; shift ;;
 		-m) message="$1"; shift ;;
+        -f|--force) force=1 ;;
 		--no-prefix) prefix= ;;
 		--onto) onto="$1"; shift ;;
 		--no-onto) onto= ;;
@@ -790,10 +793,14 @@ cmd_push()
 	      repository=$(git config -f .gittrees subtree.$prefix.url)
         refspec=$(git config -f .gittrees subtree.$prefix.branch)
       fi
+        push_opts=
+        if [ "$force" == "1" ]; then
+            push_opts="$push_opts --force"
+        fi
 	    echo "git push using: " $repository $refspec
 	    rev=$(git subtree split --prefix=$prefix)
 	    if [ -n "$rev" ]; then
-	        git push $repository $rev:refs/heads/$refspec
+	        git push $push_opts $repository $rev:refs/heads/$refspec
 	    else
 	        die "Couldn't push, 'git subtree split' failed."
 	    fi
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 385bde8..9e9eb9e 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -278,6 +278,11 @@ OPTIONS FOR split
 	'--rejoin' when you split, because you don't want the
 	subproject's history to be part of your project anyway.

+OPTIONS FOR push
+----------------
+-f::
+--force::
+    Uses 'git push --force'.

 EXAMPLE 1. Add command
 ----------------------
-- 
1.8.2.rc1


-- 
Paul [W] Campbell

← back to recent threads