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