* [PATCH] subtree: Teach push the --force option
@ 2019-01-30 18:50 Joshua Watt
0 siblings, 0 replies; only message in thread
From: Joshua Watt @ 2019-01-30 18:50 UTC (permalink / raw)
To: git; +Cc: Joshua Watt
Force pushing to subtree remotes can occasionally be a useful workflow,
particularly when the remote uses a workflow like GitHub pull requests.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
contrib/subtree/git-subtree.sh | 14 +++++++++++++-
contrib/subtree/git-subtree.txt | 9 +++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 147201dc6c..39792198b4 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 'push'
+f,force force push
"
eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
@@ -48,6 +50,7 @@ annotate=
squash=
message=
prefix=
+force=
debug () {
if test -n "$debug"
@@ -137,6 +140,9 @@ do
--no-squash)
squash=
;;
+ -f)
+ force=1
+ ;;
--)
break
;;
@@ -892,7 +898,13 @@ cmd_push () {
refspec=$2
echo "git push using: " "$repository" "$refspec"
localrev=$(git subtree split --prefix="$prefix") || die
- git push "$repository" "$localrev":"refs/heads/$refspec"
+ if test -n "$force"
+ then
+ fopt="--force"
+ else
+ fopt=""
+ fi
+ git push $fopt "$repository" "$localrev":"refs/heads/$refspec"
else
die "'$dir' must already exist. Try 'git subtree add'."
fi
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 352deda69d..e956e6ab7d 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -175,6 +175,15 @@ remain intact and can be later split and send upstream to the
subproject.
+OPTIONS FOR push
+----------------
+-f::
+--force::
+ This option is only valid for the push command
++
+Force push to the remote branch, just like gitlink:git-push[1]
+
+
OPTIONS FOR split
-----------------
--annotate=<annotation>::
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-30 18:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-30 18:50 [PATCH] subtree: Teach push the --force option Joshua Watt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).