All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Campbell <pcampbell@kemitix.net>
To: git <git@vger.kernel.org>
Cc: David Greene <greened@obbligato.org>,
	Herman van Rink <rink@initfour.nl>,
	Paul Campbell <pcampbell@kemitix.net>,
	"Peter Jaros" <pjaros@pivotallabs.com>,
	"James Roper" <jroper@vz.net>,
	"Michael Hart" <michael@adslot.com>,
	"Matt Hoffman" <matt.hoffman@quantumretail.com>,
	"Avery Pennarun" <apenwarr@gmail.com>,
	"Jakub Suder" <jakub.suder@gmail.com>,
	"Nate Jones" <nate@endot.org>, "bibendi" <bibendi@bk.ru>,
	"Win Treese" <treese@acm.org>,
	"Wayne Walter" <wayne@tickzoom.com>
Subject: [PATCH v2 21/23] contrib/subtree: Convert spaces to tabs and remove some trailing whitespace
Date: Sun, 10 Mar 2013 23:41:29 +0000	[thread overview]
Message-ID: <1362958891-26941-22-git-send-email-pcampbell@kemitix.net> (raw)
In-Reply-To: <1362958891-26941-1-git-send-email-pcampbell@kemitix.net>

From: Herman van Rink <rink@initfour.nl>

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>

Conflicts:
	contrib/subtree/.gitignore
	contrib/subtree/git-subtree.sh
	contrib/subtree/test.sh
---

It's a nasty formatting only patch and I won't be surprised or too dissappiointed
if this doesn't make it. Or are the rules for this more lax for contrib? How else
can contrib be brought in-line with coding standards?

 contrib/subtree/git-subtree.sh | 213 +++++++++++++++++++++--------------------
 1 file changed, 109 insertions(+), 104 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 3582a55..263ea9f 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -92,7 +92,7 @@ while [ $# -gt 0 ]; do
 		-b) branch="$1"; shift ;;
 		-P) prefix="$1"; shift ;;
 		-m) message="$1"; shift ;;
-        -f|--force) force=1 ;;
+		-f|--force) force=1 ;;
 		--no-prefix) prefix= ;;
 		--onto) onto="$1"; shift ;;
 		--no-onto) onto= ;;
@@ -123,8 +123,10 @@ if [ -z "$prefix" -a "$command" != "pull-all" -a "$command" != "push-all" -a "$c
 fi
 
 case "$command" in
-    pull-all);;
-    push-all);;
+	pull-all);;
+	push-all);;
+	list);;
+	prune);;
 	add) [ -e "$prefix" ] && 
 		die "prefix '$prefix' already exists." ;;
 	*)   [ -e "$prefix" ] || 
@@ -541,14 +543,14 @@ cmd_add_repository()
 	revs=FETCH_HEAD
 	set -- $revs
 	cmd_add_commit "$@"
-  
-  # now add it to our list of repos 
-  git config -f .gittrees --unset subtree.$dir.url
-  git config -f .gittrees --add subtree.$dir.url $repository
-  git config -f .gittrees --unset subtree.$dir.path
-  git config -f .gittrees --add subtree.$dir.path $dir
-  git config -f .gittrees --unset subtree.$dir.branch
-  git config -f .gittrees --add subtree.$dir.branch $refspec
+
+	# now add it to our list of repos
+	git config -f .gittrees --unset subtree.$dir.url
+	git config -f .gittrees --add subtree.$dir.url $repository
+	git config -f .gittrees --unset subtree.$dir.path
+	git config -f .gittrees --add subtree.$dir.path $dir
+	git config -f .gittrees --unset subtree.$dir.branch
+	git config -f .gittrees --add subtree.$dir.branch $refspec
 }
 
 cmd_add_commit()
@@ -721,89 +723,91 @@ cmd_merge()
 
 cmd_pull()
 {
-  if [ $# -gt 2 ]; then
-	    die "You should provide either <refspec> or <repository> <refspec>"
+	if [ $# -gt 2 ]; then
+		die "You should provide either <refspec> or <repository> <refspec>"
 	fi
 	if [ -e "$dir" ]; then
-	    ensure_clean
-      if [ $# -eq 1 ]; then 
-	      repository=$(git config -f .gittrees subtree.$prefix.url)
-	      refspec=$1
-      elif [ $# -eq 2 ]; then 
-        repository=$1
-        refspec=$2
-      else 
-	      repository=$(git config -f .gittrees subtree.$prefix.url)
-        refspec=$(git config -f .gittrees subtree.$prefix.branch)
-      fi
-	    git fetch $repository $refspec || exit $?
-	    echo "git fetch using: " $repository $refspec
-	    revs=FETCH_HEAD
-	    set -- $revs
-	    cmd_merge "$@"
+		ensure_clean
+		if [ $# -eq 1 ]; then
+			repository=$(git config -f .gittrees subtree.$prefix.url)
+			refspec=$1
+		elif [ $# -eq 2 ]; then
+			repository=$1
+			refspec=$2
+		else
+			repository=$(git config -f .gittrees subtree.$prefix.url)
+			refspec=$(git config -f .gittrees subtree.$prefix.branch)
+		fi
+		git fetch $repository $refspec || exit $?
+		echo "git fetch using: " $repository $refspec
+		revs=FETCH_HEAD
+		set -- $revs
+		cmd_merge "$@"
 	else
-	    die "'$dir' must already exist. Try 'git subtree add'."
+		die "'$dir' must already exist. Try 'git subtree add'."
 	fi
 }
 
-cmd_diff() 
-{
-    if [ -e "$dir" ]; then
-        if [ $# -eq 1 ]; then 
-            repository=$(git config -f .gittrees subtree.$prefix.url)
-            refspec=$1
-        elif [ $# -eq 2 ]; then 
-            repository=$1
-            refspec=$2
-        else
-            repository=$(git config -f .gittrees subtree.$prefix.url)
-            refspec=$(git config -f .gittrees subtree.$prefix.branch)
-        fi
-        # this is ugly, but I don't know of a better way to do it. My git-fu is weak. 
-        # git diff-tree expects a treeish, but I have only a repository and branch name.
-        # I don't know how to turn that into a treeish without creating a remote.
-        # Please change this if you know a better way! 
-        tmp_remote=__diff-tmp
-        git remote rm $tmp_remote > /dev/null 2>&1
-        git remote add -t $refspec $tmp_remote $repository > /dev/null
-        # we fetch as a separate step so we can pass -q (quiet), which isn't an option for "git remote"
-        # could this instead be "git fetch -q $repository $refspec" and leave aside creating the remote?
-        # Still need a treeish for the diff-tree command...
-        git fetch -q $tmp_remote 
-        git diff-tree -p refs/remotes/$tmp_remote/$refspec
-        git remote rm $tmp_remote > /dev/null 2>&1
-    else 
-        die "Cannot resolve directory '$dir'. Please point to an existing subtree directory to diff. Try 'git subtree add' to add a subtree."
-    fi
+cmd_diff()
+{
+	if [ -e "$dir" ]; then
+		if [ $# -eq 1 ]; then
+			repository=$(git config -f .gittrees subtree.$prefix.url)
+			refspec=$1
+		elif [ $# -eq 2 ]; then
+			repository=$1
+			refspec=$2
+		else
+			repository=$(git config -f .gittrees subtree.$prefix.url)
+			refspec=$(git config -f .gittrees subtree.$prefix.branch)
+		fi
+		# this is ugly, but I don't know of a better way to do it. My git-fu is weak.
+		# git diff-tree expects a treeish, but I have only a repository and branch name.
+		# I don't know how to turn that into a treeish without creating a remote.
+		# Please change this if you know a better way!
+		tmp_remote=__diff-tmp
+		git remote rm $tmp_remote > /dev/null 2>&1
+		git remote add -t $refspec $tmp_remote $repository > /dev/null
+		# we fetch as a separate step so we can pass -q (quiet), which isn't an option for "git remote"
+		# could this instead be "git fetch -q $repository $refspec" and leave aside creating the remote?
+		# Still need a treeish for the diff-tree command...
+		git fetch -q $tmp_remote
+		git diff-tree -p refs/remotes/$tmp_remote/$refspec
+		git remote rm $tmp_remote > /dev/null 2>&1
+	else
+		die "Cannot resolve directory '$dir'. Please point to an existing subtree directory to diff. Try 'git subtree add' to add a subtree."
+	fi
 }
 
 cmd_push()
 {
 	if [ $# -gt 2 ]; then
-	    die "You shold provide either <refspec> or <repository> <refspec>"
+		die "You shold provide either <refspec> or <repository> <refspec>"
 	fi
 	if [ -e "$dir" ]; then
-      if [ $# -eq 1 ]; then 
-	      repository=$(git config -f .gittrees subtree.$prefix.url)
-        refspec=$1
-      elif [ $# -eq 2 ]; then 
-        repository=$1
-        refspec=$2
-      else
-	      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 $push_opts $repository $rev:refs/heads/$refspec
-	    else
-	        die "Couldn't push, 'git subtree split' failed."
-	    fi
+		if [ $# -eq 1 ]; then
+			repository=$(git config -f .gittrees subtree.$prefix.url)
+			refspec=$1
+		elif [ $# -eq 2 ]; then
+			repository=$1
+			refspec=$2
+		else
+			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 $push_opts $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
@@ -831,6 +835,7 @@ cmd_from-submodule()
 	git commit -m "Remove '$prefix/' submodule"
 
 	# subtree add from submodule repo.
+	# TODO: Could be determin HEAD to be a specific branch
 	cmd_add_repository $tmp_repo HEAD
 
 	# Update .gittrees with the original repo url
@@ -841,46 +846,46 @@ cmd_from-submodule()
 	rm -rf $tmp_repo
 }
 
-subtree_list() 
+subtree_list()
 {
-    git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
-    while read path; do 
-        repository=$(git config -f .gittrees subtree.$path.url)
-        refspec=$(git config -f .gittrees subtree.$path.branch)
-        echo "    $path        (merged from $repository branch $refspec) "
-    done
+	git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+	while read path; do
+		repository=$(git config -f .gittrees subtree.$path.url)
+		refspec=$(git config -f .gittrees subtree.$path.branch)
+		echo "	$path		(merged from $repository branch $refspec) "
+	done
 }
 
 cmd_list()
 {
-  subtree_list 
+  subtree_list
 }
 
 cmd_prune()
 {
-    git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
-    while read path; do
-        if [ ! -e "$path" ]; then
-            echo "pruning $path"
-            git config -f .gittrees --remove-section subtree.$path
-        fi
-    done
+	git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+	while read path; do
+		if [ ! -e "$path" ]; then
+			echo "pruning $path"
+			git config -f .gittrees --remove-section subtree.$path
+		fi
+	done
 }
 
 cmd_pull-all()
 {
-    git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
-        while read path; do
-            git subtree pull -P $path master || exit $?
-        done
+	git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+	while read path; do
+		git subtree pull -P $path $(git config -f .gittrees subtree.$path.url) $(git config -f .gittrees subtree.$path.branch) || exit $?
+	done
 }
 
 cmd_push-all()
 {
-    git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
-        while read path; do
-            git subtree push -P $path master || exit $?
-        done
+	git config -f .gittrees -l | grep subtree | grep path | grep -o '=.*' | grep -o '[^=].*' |
+	while read path; do
+		git subtree push -P $path $(git config -f .gittrees subtree.$path.url) $(git config -f .gittrees subtree.$path.branch) || exit $?
+	done
 }
 
 "cmd_$command" "$@"
-- 
1.8.2.rc1

  parent reply	other threads:[~2013-03-10 23:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-10 23:41 [PATCH v2 00/23] contrib/subtree: Collected updates Paul Campbell
2013-03-10 23:41 ` [PATCH v2 01/23] contrib/subtree: Fix typo (s/incldued/included/) Paul Campbell
2013-03-10 23:41 ` [PATCH v2 02/23] contrib/subtree: Add command from-submodule Paul Campbell
2013-03-11  3:19   ` Junio C Hamano
2013-03-24 20:59     ` [PATCH] " Paul Campbell
2013-03-10 23:41 ` [PATCH v2 03/23] contrib/subtree: Teach add to store repository & branch in .gittrees Paul Campbell
2013-03-11  3:24   ` Junio C Hamano
2013-03-24 20:17     ` Paul Campbell
2013-03-24 20:22       ` [PATCH] " Paul Campbell
2013-03-10 23:41 ` [PATCH v2 04/23] contrib/subtree: Teach push and pull to use .gittrees for defaults Paul Campbell
2013-03-11  3:35   ` Junio C Hamano
2013-03-24 21:22     ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 05/23] contrib/subtree: Add commands pull_all and push_all Paul Campbell
2013-03-11  5:03   ` Junio C Hamano
2013-03-11 11:49     ` Paul Campbell
2013-03-10 23:41 ` [PATCH v2 06/23] contrib/subtree: Rename commands push_all/pull_all to push-all/pull-all Paul Campbell
2013-03-10 23:41 ` [PATCH v2 07/23] contrib/subtree: Teach push and pull to use .gittrees if needed Paul Campbell
2013-03-10 23:41 ` [PATCH v2 08/23] contrib/subtree: Replace invisible carriage return with a visible \r Paul Campbell
2013-03-10 23:41 ` [PATCH v2 09/23] contrib/subtree: Teach push to abort if split fails Paul Campbell
2013-03-10 23:41 ` [PATCH v2 10/23] contrib/subtree: Add command diff Paul Campbell
2013-03-10 23:41 ` [PATCH v2 11/23] contrib/subtree: Add command list Paul Campbell
2013-03-10 23:41 ` [PATCH v2 12/23] contrib/subtree: Add command prune Paul Campbell
2013-03-10 23:41 ` [PATCH v2 13/23] contrib/subtree: Add prune command to OPTS_SPEC Paul Campbell
2013-03-10 23:41 ` [PATCH v2 14/23] contrib/subtree: Remove trailing slash from prefix parameter Paul Campbell
2013-03-10 23:41 ` [PATCH v2 15/23] contrib/subtree: Teach from-submodule to add new subtree to .gittrees Paul Campbell
2013-03-10 23:41 ` [PATCH v2 16/23] contrib/subtree: Document pull-all and push-all Paul Campbell
2013-03-10 23:41 ` [PATCH v2 17/23] contrib/subtree: Document from-submodule and prune commands Paul Campbell
2013-03-10 23:41 ` [PATCH v2 18/23] contrib/subtree: Add missing commands to SYNOPSIS Paul Campbell
2013-03-10 23:41 ` [PATCH v2 19/23] contrib/subtree: Document list command Paul Campbell
2013-03-10 23:41 ` [PATCH v2 20/23] contrib/subtree: Teach push to use --force option Paul Campbell
2013-03-10 23:41 ` Paul Campbell [this message]
2013-03-10 23:41 ` [PATCH v2 22/23] contrib/subtree: Parameters repository/branch for push/pull are optional Paul Campbell
2013-03-10 23:41 ` [PATCH v2 23/23] contrib/subtree: Fix order of case switches so default case is last Paul Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1362958891-26941-22-git-send-email-pcampbell@kemitix.net \
    --to=pcampbell@kemitix.net \
    --cc=apenwarr@gmail.com \
    --cc=bibendi@bk.ru \
    --cc=git@vger.kernel.org \
    --cc=greened@obbligato.org \
    --cc=jakub.suder@gmail.com \
    --cc=jroper@vz.net \
    --cc=matt.hoffman@quantumretail.com \
    --cc=michael@adslot.com \
    --cc=nate@endot.org \
    --cc=pjaros@pivotallabs.com \
    --cc=rink@initfour.nl \
    --cc=treese@acm.org \
    --cc=wayne@tickzoom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.