{"thread":{"id":"398","subject":"[PATCH] Make cg-clone handle local directories as sources","startedAt":"2005-04-29T21:59:29Z","lastAt":"2005-04-29T22:17:10Z","messageCount":3,"participants":["Ryan Anderson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2203","messageId":"20050429215928.GF1233@mythryan2.michonline.com","threadId":"398","inReplyTo":null,"subject":"[PATCH] Make cg-clone handle local directories as sources","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-04-29T21:59:29Z","receivedAt":"2005-04-29T21:59:29Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"\ncg-clone is described as only being used with remote repositories, but\nit has the nice feature of creating the destination directory for you.\n\nThis patch adds two features:\n\t1. A destination directory can (optionally) be specified.\n\t2. The source directory can be in the local file system.\n\nThe following, for example, now works:\n\n\tcg-clone rsync://rsync.kernel.org/pub/scm/cogito/cogito.git\n\tmkdir test ; cd test\n\tcg-clone ../cogito ../cogito2/\n\nIndex: cg-clone\n===================================================================\n--- c3aa1e6b53cc59d5fbe261f3f859584904ae3a63/cg-clone  (mode:100755 sha1:4ee0685c358e094c5350b3968d013105da6ddf7e)\n+++ uncommitted/cg-clone  (mode:100755)\n@@ -11,13 +11,22 @@\n . cg-Xlib\n \n location=$1\n-[ \"$location\" ] || die \"usage: cg-clone SOURCE_LOC\"\n+[ \"$location\" ] || die \"usage: cg-clone SOURCE_LOC [DEST_LOC]\"\n location=${location%/}\n \n-dir=${location##*/}; dir=${dir%.git}\n+if [ \"$2\" == \"\" ]; then\n+\tdir=${location##*/}; dir=${dir%.git}\n+else\n+\tdir=$2\n+fi\n+\n+pwd=$(pwd)\n+relative_location=$(echo \"$location\" | sed -e \"s#^[^/]#$pwd\\/&#\")\n+\n [ -e \"$dir\" ] && die \"$dir/ already exists\"\n mkdir \"$dir\"\n cd \"$dir\"\n \n-cg-init $location || exit $?\n+echo \"cg-init $relative_location\"\n+cg-init $relative_location || exit $?\n echo \"Cloned to $dir/ (origin $location available as branch \\\"origin\\\")\"\n\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"2205","messageId":"20050429220802.GG1233@mythryan2.michonline.com","threadId":"398","inReplyTo":"20050429215928.GF1233@mythryan2.michonline.com","subject":"Re: [PATCH] Make cg-clone handle local directories as sources","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-04-29T22:08:02Z","receivedAt":"2005-04-29T22:08:02Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"Ignore this, I did something stupid - new patch to follow in a minute.\n\nOn Fri, Apr 29, 2005 at 05:59:29PM -0400, Ryan Anderson wrote:\n> \n> cg-clone is described as only being used with remote repositories, but\n> it has the nice feature of creating the destination directory for you.\n> \n> This patch adds two features:\n> \t1. A destination directory can (optionally) be specified.\n> \t2. The source directory can be in the local file system.\n> \n> The following, for example, now works:\n> \n> \tcg-clone rsync://rsync.kernel.org/pub/scm/cogito/cogito.git\n> \tmkdir test ; cd test\n> \tcg-clone ../cogito ../cogito2/\n> \n> Index: cg-clone\n> ===================================================================\n> --- c3aa1e6b53cc59d5fbe261f3f859584904ae3a63/cg-clone  (mode:100755 sha1:4ee0685c358e094c5350b3968d013105da6ddf7e)\n> +++ uncommitted/cg-clone  (mode:100755)\n> @@ -11,13 +11,22 @@\n>  . cg-Xlib\n>  \n>  location=$1\n> -[ \"$location\" ] || die \"usage: cg-clone SOURCE_LOC\"\n> +[ \"$location\" ] || die \"usage: cg-clone SOURCE_LOC [DEST_LOC]\"\n>  location=${location%/}\n>  \n> -dir=${location##*/}; dir=${dir%.git}\n> +if [ \"$2\" == \"\" ]; then\n> +\tdir=${location##*/}; dir=${dir%.git}\n> +else\n> +\tdir=$2\n> +fi\n> +\n> +pwd=$(pwd)\n> +relative_location=$(echo \"$location\" | sed -e \"s#^[^/]#$pwd\\/&#\")\n> +\n>  [ -e \"$dir\" ] && die \"$dir/ already exists\"\n>  mkdir \"$dir\"\n>  cd \"$dir\"\n>  \n> -cg-init $location || exit $?\n> +echo \"cg-init $relative_location\"\n> +cg-init $relative_location || exit $?\n>  echo \"Cloned to $dir/ (origin $location available as branch \\\"origin\\\")\"\n> \n> \n> -- \n> \n> Ryan Anderson\n>   sometimes Pug Majere\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"2208","messageId":"20050429221710.GH1233@mythryan2.michonline.com","threadId":"398","inReplyTo":"20050429215928.GF1233@mythryan2.michonline.com","subject":"Re: [PATCH] Make cg-clone handle local directories as sources","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-04-29T22:17:10Z","receivedAt":"2005-04-29T22:17:10Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"cg-clone is described as only being used with remote repositories, but\nit has the nice feature of creating the destination directory for you.\n\nThis patch adds two features:\n        1. A destination directory can (optionally) be specified.\n        2. The source directory can be in the local file system.\n\nThe following, for example, now works:\n\n        cg-clone rsync://rsync.kernel.org/pub/scm/cogito/cogito.git\n        mkdir test ; cd test\n        cg-clone ../cogito ../cogito2/\n\n(This version of the patch actually doesn't break existing\nfunctionality.)\n\nIndex: cg-clone\n===================================================================\n--- c3aa1e6b53cc59d5fbe261f3f859584904ae3a63/cg-clone  (mode:100755 sha1:4ee0685c358e094c5350b3968d013105da6ddf7e)\n+++ 3dc3edca08f66f90147d0cb2240274072fa8644a/cg-clone  (mode:100755 sha1:e42237e0408bc3f34cc70a956c29df1251bd1571)\n@@ -11,13 +11,25 @@\n . cg-Xlib\n \n location=$1\n-[ \"$location\" ] || die \"usage: cg-clone SOURCE_LOC\"\n+[ \"$location\" ] || die \"usage: cg-clone SOURCE_LOC [DEST_LOC]\"\n location=${location%/}\n \n-dir=${location##*/}; dir=${dir%.git}\n+if [ \"$2\" == \"\" ]; then\n+\tdir=${location##*/}; dir=${dir%.git}\n+else\n+\tdir=$2\n+fi\n+\n+pwd=$(pwd)\n+if ! echo \"$location\" | grep -q \":\" ; then\n+\trelative_location=$(echo \"$location\" | sed -e \"s#^[^/]#$pwd\\/&#\")\n+else\n+\trelative_location=\"$location\"\n+fi\n+\n [ -e \"$dir\" ] && die \"$dir/ already exists\"\n mkdir \"$dir\"\n cd \"$dir\"\n \n-cg-init $location || exit $?\n+cg-init \"$relative_location\" || exit $?\n echo \"Cloned to $dir/ (origin $location available as branch \\\"origin\\\")\"\n"}]}