* [PATCH] Make cg-clone handle local directories as sources
@ 2005-04-29 21:59 Ryan Anderson
2005-04-29 22:08 ` Ryan Anderson
2005-04-29 22:17 ` Ryan Anderson
0 siblings, 2 replies; 3+ messages in thread
From: Ryan Anderson @ 2005-04-29 21:59 UTC (permalink / raw)
To: git
cg-clone is described as only being used with remote repositories, but
it has the nice feature of creating the destination directory for you.
This patch adds two features:
1. A destination directory can (optionally) be specified.
2. The source directory can be in the local file system.
The following, for example, now works:
cg-clone rsync://rsync.kernel.org/pub/scm/cogito/cogito.git
mkdir test ; cd test
cg-clone ../cogito ../cogito2/
Index: cg-clone
===================================================================
--- c3aa1e6b53cc59d5fbe261f3f859584904ae3a63/cg-clone (mode:100755 sha1:4ee0685c358e094c5350b3968d013105da6ddf7e)
+++ uncommitted/cg-clone (mode:100755)
@@ -11,13 +11,22 @@
. cg-Xlib
location=$1
-[ "$location" ] || die "usage: cg-clone SOURCE_LOC"
+[ "$location" ] || die "usage: cg-clone SOURCE_LOC [DEST_LOC]"
location=${location%/}
-dir=${location##*/}; dir=${dir%.git}
+if [ "$2" == "" ]; then
+ dir=${location##*/}; dir=${dir%.git}
+else
+ dir=$2
+fi
+
+pwd=$(pwd)
+relative_location=$(echo "$location" | sed -e "s#^[^/]#$pwd\/&#")
+
[ -e "$dir" ] && die "$dir/ already exists"
mkdir "$dir"
cd "$dir"
-cg-init $location || exit $?
+echo "cg-init $relative_location"
+cg-init $relative_location || exit $?
echo "Cloned to $dir/ (origin $location available as branch \"origin\")"
--
Ryan Anderson
sometimes Pug Majere
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Make cg-clone handle local directories as sources
2005-04-29 21:59 [PATCH] Make cg-clone handle local directories as sources Ryan Anderson
@ 2005-04-29 22:08 ` Ryan Anderson
2005-04-29 22:17 ` Ryan Anderson
1 sibling, 0 replies; 3+ messages in thread
From: Ryan Anderson @ 2005-04-29 22:08 UTC (permalink / raw)
To: Ryan Anderson; +Cc: git
Ignore this, I did something stupid - new patch to follow in a minute.
On Fri, Apr 29, 2005 at 05:59:29PM -0400, Ryan Anderson wrote:
>
> cg-clone is described as only being used with remote repositories, but
> it has the nice feature of creating the destination directory for you.
>
> This patch adds two features:
> 1. A destination directory can (optionally) be specified.
> 2. The source directory can be in the local file system.
>
> The following, for example, now works:
>
> cg-clone rsync://rsync.kernel.org/pub/scm/cogito/cogito.git
> mkdir test ; cd test
> cg-clone ../cogito ../cogito2/
>
> Index: cg-clone
> ===================================================================
> --- c3aa1e6b53cc59d5fbe261f3f859584904ae3a63/cg-clone (mode:100755 sha1:4ee0685c358e094c5350b3968d013105da6ddf7e)
> +++ uncommitted/cg-clone (mode:100755)
> @@ -11,13 +11,22 @@
> . cg-Xlib
>
> location=$1
> -[ "$location" ] || die "usage: cg-clone SOURCE_LOC"
> +[ "$location" ] || die "usage: cg-clone SOURCE_LOC [DEST_LOC]"
> location=${location%/}
>
> -dir=${location##*/}; dir=${dir%.git}
> +if [ "$2" == "" ]; then
> + dir=${location##*/}; dir=${dir%.git}
> +else
> + dir=$2
> +fi
> +
> +pwd=$(pwd)
> +relative_location=$(echo "$location" | sed -e "s#^[^/]#$pwd\/&#")
> +
> [ -e "$dir" ] && die "$dir/ already exists"
> mkdir "$dir"
> cd "$dir"
>
> -cg-init $location || exit $?
> +echo "cg-init $relative_location"
> +cg-init $relative_location || exit $?
> echo "Cloned to $dir/ (origin $location available as branch \"origin\")"
>
>
> --
>
> Ryan Anderson
> sometimes Pug Majere
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Ryan Anderson
sometimes Pug Majere
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Make cg-clone handle local directories as sources
2005-04-29 21:59 [PATCH] Make cg-clone handle local directories as sources Ryan Anderson
2005-04-29 22:08 ` Ryan Anderson
@ 2005-04-29 22:17 ` Ryan Anderson
1 sibling, 0 replies; 3+ messages in thread
From: Ryan Anderson @ 2005-04-29 22:17 UTC (permalink / raw)
To: Ryan Anderson; +Cc: git
cg-clone is described as only being used with remote repositories, but
it has the nice feature of creating the destination directory for you.
This patch adds two features:
1. A destination directory can (optionally) be specified.
2. The source directory can be in the local file system.
The following, for example, now works:
cg-clone rsync://rsync.kernel.org/pub/scm/cogito/cogito.git
mkdir test ; cd test
cg-clone ../cogito ../cogito2/
(This version of the patch actually doesn't break existing
functionality.)
Index: cg-clone
===================================================================
--- c3aa1e6b53cc59d5fbe261f3f859584904ae3a63/cg-clone (mode:100755 sha1:4ee0685c358e094c5350b3968d013105da6ddf7e)
+++ 3dc3edca08f66f90147d0cb2240274072fa8644a/cg-clone (mode:100755 sha1:e42237e0408bc3f34cc70a956c29df1251bd1571)
@@ -11,13 +11,25 @@
. cg-Xlib
location=$1
-[ "$location" ] || die "usage: cg-clone SOURCE_LOC"
+[ "$location" ] || die "usage: cg-clone SOURCE_LOC [DEST_LOC]"
location=${location%/}
-dir=${location##*/}; dir=${dir%.git}
+if [ "$2" == "" ]; then
+ dir=${location##*/}; dir=${dir%.git}
+else
+ dir=$2
+fi
+
+pwd=$(pwd)
+if ! echo "$location" | grep -q ":" ; then
+ relative_location=$(echo "$location" | sed -e "s#^[^/]#$pwd\/&#")
+else
+ relative_location="$location"
+fi
+
[ -e "$dir" ] && die "$dir/ already exists"
mkdir "$dir"
cd "$dir"
-cg-init $location || exit $?
+cg-init "$relative_location" || exit $?
echo "Cloned to $dir/ (origin $location available as branch \"origin\")"
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-04-29 22:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-29 21:59 [PATCH] Make cg-clone handle local directories as sources Ryan Anderson
2005-04-29 22:08 ` Ryan Anderson
2005-04-29 22:17 ` Ryan Anderson
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).