Re: [PATCH 8/8] git-p4: support clone --bare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 5, 2011 at 11:52 PM, Pete Wyckoff <pw@xxxxxxxx> wrote:
> Just like git clone --bare, build a .git directory but no
> checked out files.
>
> Signed-off-by: Pete Wyckoff <pw@xxxxxxxx>

Acked-By: Tor Arvid Lund <torarvid@xxxxxxxxx>

> ---
> Âcontrib/fast-import/git-p4 | Â 17 +++++++++++++----
> Ât/t9800-git-p4.sh     Â|  10 ++++++++++
> Â2 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 5b08cd6..efc5dce 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -1771,10 +1771,13 @@ class P4Clone(P4Sync):
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âhelp="where to leave result of the clone"),
> Â Â Â Â Â Â optparse.make_option("-/", dest="cloneExclude",
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âaction="append", type="string",
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â help="exclude depot path")
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â help="exclude depot path"),
> + Â Â Â Â Â Âoptparse.make_option("--bare", dest="cloneBare",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â action="store_true", default=False),
> Â Â Â Â ]
> Â Â Â Â self.cloneDestination = None
> Â Â Â Â self.needsGit = False
> + Â Â Â Âself.cloneBare = False
>
> Â Â # This is required for the "append" cloneExclude action
> Â Â def ensure_value(self, attr, value):
> @@ -1814,11 +1817,16 @@ class P4Clone(P4Sync):
> Â Â Â Â Â Â self.cloneDestination = self.defaultDestination(args)
>
> Â Â Â Â print "Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination)
> +
> Â Â Â Â if not os.path.exists(self.cloneDestination):
> Â Â Â Â Â Â os.makedirs(self.cloneDestination)
> Â Â Â Â chdir(self.cloneDestination)
> - Â Â Â Âsystem("git init")
> - Â Â Â Âself.gitdir = os.getcwd() + "/.git"
> +
> + Â Â Â Âinit_cmd = [ "git", "init" ]
> + Â Â Â Âif self.cloneBare:
> + Â Â Â Â Â Âinit_cmd.append("--bare")
> + Â Â Â Âsubprocess.check_call(init_cmd)
> +
> Â Â Â Â if not P4Sync.run(self, depotPaths):
> Â Â Â Â Â Â return False
> Â Â Â Â if self.branch != "master":
> @@ -1828,7 +1836,8 @@ class P4Clone(P4Sync):
> Â Â Â Â Â Â Â Â masterbranch = "refs/heads/p4/master"
> Â Â Â Â Â Â if gitBranchExists(masterbranch):
> Â Â Â Â Â Â Â Â system("git branch master %s" % masterbranch)
> - Â Â Â Â Â Â Â Âsystem("git checkout -f")
> + Â Â Â Â Â Â Â Âif not self.cloneBare:
> + Â Â Â Â Â Â Â Â Â Âsystem("git checkout -f")
> Â Â Â Â Â Â else:
> Â Â Â Â Â Â Â Â print "Could not detect main branch. No checkout/master branch created."
>
> diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh
> index 72c38af..1e7639b 100755
> --- a/t/t9800-git-p4.sh
> +++ b/t/t9800-git-p4.sh
> @@ -87,6 +87,16 @@ test_expect_success 'wildcard files git-p4 clone' '
> Â Â Â Ârm -rf "$git" && mkdir "$git"
> Â'
>
> +test_expect_success 'clone bare' '
> + Â Â Â "$GITP4" clone --dest="$git" --bare //depot &&
> + Â Â Â cd "$git" &&
> + Â Â Â test ! -d .git &&
> + Â Â Â bare=`git config --get core.bare` &&
> + Â Â Â test "$bare" = true &&
> + Â Â Â cd "$TRASH_DIRECTORY" &&
> + Â Â Â rm -rf "$git" && mkdir "$git"
> +'
> +
> Âtest_expect_success 'shutdown' '
> Â Â Â Âpid=`pgrep -f p4d` &&
> Â Â Â Âtest -n "$pid" &&
> --
> 1.7.2.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]