summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-01-17 22:49:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-17 22:49:27 (GMT)
commitcf479b4fb5d8417ccea306fa9f3491ec2e873399 (patch)
tree372268c7b11fe5889f43a58f24d861c90373ff81
parentb3dac9c07858e7b8b9c99a371c67129c2e7909e3 (diff)
parentd5eb3cf5e7e4274e12e0f249b3a026c029f3b02c (diff)
downloadgit-cf479b4fb5d8417ccea306fa9f3491ec2e873399.zip
git-cf479b4fb5d8417ccea306fa9f3491ec2e873399.tar.gz
git-cf479b4fb5d8417ccea306fa9f3491ec2e873399.tar.bz2
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
-rwxr-xr-xgit-p4.py29
-rwxr-xr-xt/t9824-git-p4-git-lfs.sh2
2 files changed, 19 insertions, 12 deletions
diff --git a/git-p4.py b/git-p4.py
index fd5ca52..ccfb681 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1005,18 +1005,20 @@ class LargeFileSystem(object):
steps."""
if self.exceedsLargeFileThreshold(relPath, contents) or self.hasLargeFileExtension(relPath):
contentTempFile = self.generateTempFile(contents)
- (git_mode, contents, localLargeFile) = self.generatePointer(contentTempFile)
-
- # Move temp file to final location in large file system
- largeFileDir = os.path.dirname(localLargeFile)
- if not os.path.isdir(largeFileDir):
- os.makedirs(largeFileDir)
- shutil.move(contentTempFile, localLargeFile)
- self.addLargeFile(relPath)
- if gitConfigBool('git-p4.largeFilePush'):
- self.pushFile(localLargeFile)
- if verbose:
- sys.stderr.write("%s moved to large file system (%s)\n" % (relPath, localLargeFile))
+ (pointer_git_mode, contents, localLargeFile) = self.generatePointer(contentTempFile)
+ if pointer_git_mode:
+ git_mode = pointer_git_mode
+ if localLargeFile:
+ # Move temp file to final location in large file system
+ largeFileDir = os.path.dirname(localLargeFile)
+ if not os.path.isdir(largeFileDir):
+ os.makedirs(largeFileDir)
+ shutil.move(contentTempFile, localLargeFile)
+ self.addLargeFile(relPath)
+ if gitConfigBool('git-p4.largeFilePush'):
+ self.pushFile(localLargeFile)
+ if verbose:
+ sys.stderr.write("%s moved to large file system (%s)\n" % (relPath, localLargeFile))
return (git_mode, contents)
class MockLFS(LargeFileSystem):
@@ -1056,6 +1058,9 @@ class GitLFS(LargeFileSystem):
the actual content. Return also the new location of the actual
content.
"""
+ if os.path.getsize(contentFile) == 0:
+ return (None, '', None)
+
pointerProcess = subprocess.Popen(
['git', 'lfs', 'pointer', '--file=' + contentFile],
stdout=subprocess.PIPE
diff --git a/t/t9824-git-p4-git-lfs.sh b/t/t9824-git-p4-git-lfs.sh
index 110a7e7..734b8db 100755
--- a/t/t9824-git-p4-git-lfs.sh
+++ b/t/t9824-git-p4-git-lfs.sh
@@ -42,6 +42,8 @@ test_expect_success 'Create repo with binary files' '
(
cd "$cli" &&
+ >file0.dat &&
+ p4 add file0.dat &&
echo "content 1 txt 23 bytes" >file1.txt &&
p4 add file1.txt &&
echo "content 2-3 bin 25 bytes" >file2.dat &&