OSDN Git Service

Merge branch 'ls/p4-lfs'
authorJunio C Hamano <gitster@pobox.com>
Thu, 15 Oct 2015 22:43:52 +0000 (15:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Oct 2015 22:43:53 +0000 (15:43 -0700)
Teach "git p4" to send large blobs outside the repository by
talking to Git LFS.

* ls/p4-lfs:
  git-p4: add Git LFS backend for large file system
  git-p4: add support for large file systems
  git-p4: check free space during streaming
  git-p4: add file streaming progress in verbose mode
  git-p4: return an empty list if a list config has no values
  git-p4: add gitConfigInt reader
  git-p4: add optional type specifier to gitConfig reader

1  2 
Documentation/git-p4.txt
git-p4.py

@@@ -510,13 -510,38 +510,45 @@@ git-p4.useClientSpec:
        option '--use-client-spec'.  See the "CLIENT SPEC" section above.
        This variable is a boolean, not the name of a p4 client.
  
 +git-p4.pathEncoding::
 +      Perforce keeps the encoding of a path as given by the originating OS.
 +      Git expects paths encoded as UTF-8. Use this config to tell git-p4
 +      what encoding Perforce had used for the paths. This encoding is used
 +      to transcode the paths to UTF-8. As an example, Perforce on Windows
 +      often uses “cp1252” to encode path names.
 +
+ git-p4.largeFileSystem::
+       Specify the system that is used for large (binary) files. Please note
+       that large file systems do not support the 'git p4 submit' command.
+       Only Git LFS [1] is implemented right now. Download
+       and install the Git LFS command line extension to use this option
+       and configure it like this:
+ +
+ -------------
+ git config       git-p4.largeFileSystem GitLFS
+ -------------
+ +
+       [1] https://git-lfs.github.com/
+ git-p4.largeFileExtensions::
+       All files matching a file extension in the list will be processed
+       by the large file system. Do not prefix the extensions with '.'.
+ git-p4.largeFileThreshold::
+       All files with an uncompressed size exceeding the threshold will be
+       processed by the large file system. By default the threshold is
+       defined in bytes. Add the suffix k, m, or g to change the unit.
+ git-p4.largeFileCompressedThreshold::
+       All files with a compressed size exceeding the threshold will be
+       processed by the large file system. This option might slow down
+       your clone/sync process. By default the threshold is defined in
+       bytes. Add the suffix k, m, or g to change the unit.
+ git-p4.largeFilePush::
+       Boolean variable which defines if large files are automatically
+       pushed to a server.
  Submit variables
  ~~~~~~~~~~~~~~~~
  git-p4.detectRenames::
diff --cc git-p4.py
+++ b/git-p4.py
@@@ -2225,27 -2440,10 +2445,20 @@@ class P4Sync(Command, P4UserMap)
              text = regexp.sub(r'$\1$', text)
              contents = [ text ]
  
-         self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))
 +        try:
 +            relPath.decode('ascii')
 +        except:
 +            encoding = 'utf8'
 +            if gitConfig('git-p4.pathEncoding'):
 +                encoding = gitConfig('git-p4.pathEncoding')
 +            relPath = relPath.decode(encoding, 'replace').encode('utf8', 'replace')
 +            if self.verbose:
 +                print 'Path with non-ASCII characters detected. Used %s to encode: %s ' % (encoding, relPath)
 +
+         if self.largeFileSystem:
+             (git_mode, contents) = self.largeFileSystem.processContent(git_mode, relPath, contents)
  
-         # total length...
-         length = 0
-         for d in contents:
-             length = length + len(d)
-         self.gitStream.write("data %d\n" % length)
-         for d in contents:
-             self.gitStream.write(d)
-         self.gitStream.write("\n")
+         self.writeToGitStream(git_mode, relPath, contents)
  
      def streamOneP4Deletion(self, file):
          relPath = self.stripRepoPath(file['path'], self.branchPrefixes)