Merge branch 'ls/p4-empty-file-on-lfs' into maint
"git p4" LFS support was broken when LFS stores an empty blob. * ls/p4-empty-file-on-lfs: git-p4: fix empty file processing for large file system backend GitLFS
This commit is contained in:
commit
cf479b4fb5
29
git-p4.py
29
git-p4.py
@ -1005,18 +1005,20 @@ class LargeFileSystem(object):
|
|||||||
steps."""
|
steps."""
|
||||||
if self.exceedsLargeFileThreshold(relPath, contents) or self.hasLargeFileExtension(relPath):
|
if self.exceedsLargeFileThreshold(relPath, contents) or self.hasLargeFileExtension(relPath):
|
||||||
contentTempFile = self.generateTempFile(contents)
|
contentTempFile = self.generateTempFile(contents)
|
||||||
(git_mode, contents, localLargeFile) = self.generatePointer(contentTempFile)
|
(pointer_git_mode, contents, localLargeFile) = self.generatePointer(contentTempFile)
|
||||||
|
if pointer_git_mode:
|
||||||
# Move temp file to final location in large file system
|
git_mode = pointer_git_mode
|
||||||
largeFileDir = os.path.dirname(localLargeFile)
|
if localLargeFile:
|
||||||
if not os.path.isdir(largeFileDir):
|
# Move temp file to final location in large file system
|
||||||
os.makedirs(largeFileDir)
|
largeFileDir = os.path.dirname(localLargeFile)
|
||||||
shutil.move(contentTempFile, localLargeFile)
|
if not os.path.isdir(largeFileDir):
|
||||||
self.addLargeFile(relPath)
|
os.makedirs(largeFileDir)
|
||||||
if gitConfigBool('git-p4.largeFilePush'):
|
shutil.move(contentTempFile, localLargeFile)
|
||||||
self.pushFile(localLargeFile)
|
self.addLargeFile(relPath)
|
||||||
if verbose:
|
if gitConfigBool('git-p4.largeFilePush'):
|
||||||
sys.stderr.write("%s moved to large file system (%s)\n" % (relPath, localLargeFile))
|
self.pushFile(localLargeFile)
|
||||||
|
if verbose:
|
||||||
|
sys.stderr.write("%s moved to large file system (%s)\n" % (relPath, localLargeFile))
|
||||||
return (git_mode, contents)
|
return (git_mode, contents)
|
||||||
|
|
||||||
class MockLFS(LargeFileSystem):
|
class MockLFS(LargeFileSystem):
|
||||||
@ -1056,6 +1058,9 @@ class GitLFS(LargeFileSystem):
|
|||||||
the actual content. Return also the new location of the actual
|
the actual content. Return also the new location of the actual
|
||||||
content.
|
content.
|
||||||
"""
|
"""
|
||||||
|
if os.path.getsize(contentFile) == 0:
|
||||||
|
return (None, '', None)
|
||||||
|
|
||||||
pointerProcess = subprocess.Popen(
|
pointerProcess = subprocess.Popen(
|
||||||
['git', 'lfs', 'pointer', '--file=' + contentFile],
|
['git', 'lfs', 'pointer', '--file=' + contentFile],
|
||||||
stdout=subprocess.PIPE
|
stdout=subprocess.PIPE
|
||||||
|
@ -42,6 +42,8 @@ test_expect_success 'Create repo with binary files' '
|
|||||||
(
|
(
|
||||||
cd "$cli" &&
|
cd "$cli" &&
|
||||||
|
|
||||||
|
>file0.dat &&
|
||||||
|
p4 add file0.dat &&
|
||||||
echo "content 1 txt 23 bytes" >file1.txt &&
|
echo "content 1 txt 23 bytes" >file1.txt &&
|
||||||
p4 add file1.txt &&
|
p4 add file1.txt &&
|
||||||
echo "content 2-3 bin 25 bytes" >file2.dat &&
|
echo "content 2-3 bin 25 bytes" >file2.dat &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user