threads / patch / 33175

patch, 4 partscontrib/subtree: general updates

Subject: [PATCH 0/4] contrib/subtree: general updates

## tl;dr

10 messages between Mar 13, 2013 and Mar 24, 2013. Diffs are folded; open one to read it.

replies: 9people: 3as markdown or json

Paul Campbell· Mar 13, 2013, 22:32 UTC · lore
Less ambitious patch series this time.

James and Michael's patches add if clauses that use the bashism 'if []' rather than 'if test'. I've left them as they are to match the other if clauses within the git-subtree.sh file. I remember reading a comment on the list about matching the local style being more important than the overall project's style. I'm happy to change them otherwise.

James Roper (1):
  contrib/subtree: Teach push to use --force option
Matt Hoffman (1):
  contrib/subtree: Replace invisible carriage return with a visible \r
Michael Hart (1):
  contrib/subtree: Teach push to abort if split fails
Paul Cartwright (1):
  contrib/subtree: Fix typo (s/incldued/included/)
 contrib/subtree/git-subtree.sh  | 16 ++++++++++++++--
 contrib/subtree/git-subtree.txt |  7 ++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)
-- 
1.8.2
Paul Campbell· Mar 13, 2013, 22:32 UTC · re: Paul Campbell · lore

[PATCH 1/4] contrib/subtree: Teach push to abort if split fails

From: Michael Hart <michael@adslot.com>

If the subtree split fails it doesn't return the SHA that should be pushed to the other repository.

Added a check to ensure that split succeeds before trying to push and display an error message.

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Show changes to contrib/subtree/git-subtree.sh +6 −1
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..c68cc6f 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -715,7 +715,12 @@ cmd_push()
 	    repository=$1
 	    refspec=$2
 	    echo "git push using: " $repository $refspec
-	    git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
+	    rev=$(git subtree split --prefix=$prefix)
+	    if [ -n "$rev" ]; then
+		git push $repository $rev:refs/heads/$refspec
+	    else
+		die "Couldn't push, 'git subtree split' failed."
+	    fi
 	else
 	    die "'$dir' must already exist. Try 'git subtree add'."
 	fi
-- 
1.8.2
Paul Campbell· Mar 13, 2013, 22:32 UTC · re: Paul Campbell · lore

[PATCH 2/4] contrib/subtree: Teach push to use --force option

From: James Roper <jroper@vz.net>
Allow the --force option to be passed to the child push command.
Signed-off-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 c68cc6f..2d9b071 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -26,6 +26,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
 "
@@ -84,6 +86,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= ;;
@@ -712,12 +715,16 @@ cmd_push()
 	    die "You must provide <repository> <refspec>"
 	fi
 	if [ -e "$dir" ]; then
+	    push_opts=
+	    if [ "$force" == "1" ]; then
+		push_opts="$push_opts --force"
+	    fi
 	    repository=$1
 	    refspec=$2
 	    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 7ba853e..97dd3c9 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -255,6 +255,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
Paul Campbell· Mar 13, 2013, 22:32 UTC · re: Paul Campbell · lore

[PATCH 3/4] contrib/subtree: Fix typo (s/incldued/included/)

From: Paul Cartwright <paul.cartwright@ziilabs.com>
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to contrib/subtree/git-subtree.txt +1 −1
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 97dd3c9..e1bfa61 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -275,7 +275,7 @@ git-extensions repository in ~/git-extensions/:
 name
 
 You can omit the --squash flag, but doing so will increase the number
-of commits that are incldued in your local repository.
+of commits that are included in your local repository.
 
 We now have a ~/git-extensions/git-subtree directory containing code
 from the master branch of git://github.com/apenwarr/git-subtree.git
-- 
1.8.2
Paul Campbell· Mar 13, 2013, 22:32 UTC · re: Paul Campbell · lore

[PATCH 4/4] contrib/subtree: Replace invisible carriage return with a visible \r

From: Matt Hoffman <matt.hoffman@quantumretail.com>

The ctrl-M (^M) character used for the carriage return (CR) is not visible in all (most) text editors and is often silently converted to a new line (NL) or CR/NL combo.

'say' is a wrapper for echo with accepts the option -e to interperet escaped characters. \r becomes a CR, yet is not munged by text editors.

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
Conflicts:
	git-subtree.sh
---
 contrib/subtree/git-subtree.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to contrib/subtree/git-subtree.sh +1 −1
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 2d9b071..5314bd0 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -595,7 +595,7 @@ cmd_split()
 	eval "$grl" |
 	while read rev parents; do
 		revcount=$(($revcount + 1))
-		say -n "$revcount/$revmax ($createcount)
"
+		say -ne "$revcount/$revmax ($createcount)\r"
 		debug "Processing commit: $rev"
 		exists=$(cache_get $rev)
 		if [ -n "$exists" ]; then
-- 
1.8.2
Paul Campbell· Mar 13, 2013, 22:36 UTC · re: Paul Campbell · lore

Re: [PATCH 4/4] contrib/subtree: Replace invisible carriage return with a visible \r

On Wed, Mar 13, 2013 at 10:32 PM, Paul Campbell <pcampbell@kemitix.net> wrote:
Show 14 quoted lines
> From: Matt Hoffman <matt.hoffman@quantumretail.com>
>
> The ctrl-M (^M) character used for the carriage return (CR) is not visible
> in all (most) text editors and is often silently converted to a new
> line (NL) or CR/NL combo.
>
> 'say' is a wrapper for echo with accepts the option -e to interperet
> escaped characters. \r becomes a CR, yet is not munged by text
> editors.
>
> Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
>
> Conflicts:
>         git-subtree.sh
Oops. Meant to replace this Conflict line.
Show 21 quoted lines
> ---
>  contrib/subtree/git-subtree.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 2d9b071..5314bd0 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -595,7 +595,7 @@ cmd_split()
>         eval "$grl" |
>         while read rev parents; do
>                 revcount=$(($revcount + 1))
> -               say -n "$revcount/$revmax ($createcount)
> "
> +               say -ne "$revcount/$revmax ($createcount)\r"
>                 debug "Processing commit: $rev"
>                 exists=$(cache_get $rev)
>                 if [ -n "$exists" ]; then
> --
> 1.8.2
>
-- 
Paul [W] Campbell
Paul Campbell· Mar 13, 2013, 22:42 UTC · re: Paul Campbell · lore

[PATCH] contrib/subtree: Replace invisible carriage return with a visible \r

From: Matt Hoffman <matt.hoffman@quantumretail.com>

The ctrl-M (^M) character used for the carriage return (CR) is not visible in all (most) text editors and is often silently converted to a new line (NL) or CR/NL combo.

'say' is a wrapper for echo with accepts the option -e to interperet escaped characters. \r becomes a CR, yet is not munged by text editors.

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
Rerolled with the Conflicts lines removed.
 contrib/subtree/git-subtree.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to contrib/subtree/git-subtree.sh +1 −1
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 2d9b071..5314bd0 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -595,7 +595,7 @@ cmd_split()
 	eval "$grl" |
 	while read rev parents; do
 		revcount=$(($revcount + 1))
-		say -n "$revcount/$revmax ($createcount)
"
+		say -ne "$revcount/$revmax ($createcount)\r"
 		debug "Processing commit: $rev"
 		exists=$(cache_get $rev)
 		if [ -n "$exists" ]; then
-- 
1.8.2
Miles Bader· Mar 14, 2013, 02:52 UTC · re: Paul Campbell · lore

Re: [PATCH 0/4] contrib/subtree: general updates

Paul Campbell <pcampbell@kemitix.net> writes:
> James and Michael's patches add if clauses that use the
> bashism 'if []' rather than 'if test'.

"Bashism"...? I dunno how portable is, but "[" is an old unix alias for "test" ... it certainly predates bash...

-miles
-- 
Occam's razor split hairs so well, I bought the whole argument!
Junio C Hamano· Mar 14, 2013, 03:30 UTC · re: Miles Bader · lore

Re: [PATCH 0/4] contrib/subtree: general updates

Miles Bader <miles@gnu.org> writes:
Show 6 quoted lines
> Paul Campbell <pcampbell@kemitix.net> writes:
>> James and Michael's patches add if clauses that use the
>> bashism 'if []' rather than 'if test'.
>
> "Bashism"...?  I dunno how portable is, but "[" is an old unix alias
> for "test" ... it certainly predates bash...

Correct. [[ ... ]] is new and spelling out "test" indeed is more traditionalist than [ ... ], but for contrib/subtree/ that does not work with anything but bash, I do not think such a rewrite has much merit in the first place. Being consistently "bash script" (as opposed to being old-style) is more appropriate for it.

Paul Campbell· Mar 24, 2013, 00:16 UTC · re: Junio C Hamano · lore

Re: [PATCH 0/4] contrib/subtree: general updates

On Thu, Mar 14, 2013 at 3:30 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 16 quoted lines
> Miles Bader <miles@gnu.org> writes:
>
>> Paul Campbell <pcampbell@kemitix.net> writes:
>>> James and Michael's patches add if clauses that use the
>>> bashism 'if []' rather than 'if test'.
>>
>> "Bashism"...?  I dunno how portable is, but "[" is an old unix alias
>> for "test" ... it certainly predates bash...
>
> Correct. [[ ... ]] is new and spelling out "test" indeed is more
> traditionalist than [ ... ], but for contrib/subtree/ that does not
> work with anything but bash, I do not think such a rewrite has much
> merit in the first place.  Being consistently "bash script" (as
> opposed to being old-style) is more appropriate for it.
>
>
Does no-one have any other comments about these patches?
-- 
Paul [W] Campbell

← back to recent threads