Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-16

Re: [PATCH v1 2/2] git-p4: fix Git LFS pointer parsing

From: Lars Schneider <hidden>
Date: 2016-06-16 02:18:52

On 19 Apr 2016, at 22:30, Junio C Hamano [off-list ref] wrote:

larsxschneider@gmail.com writes:
quoted
From: Lars Schneider <redacted>

Git LFS 1.2.0 removed a line from the output of the 'git lfs pointer'
command [1] which broke the parsing of this output. Adjust the parser
to the new output and add minimum Git LFS version to the docs.
Hmph, adjust to operate with both, or drop the support for the old
one?
I dropped the support for the older version to keep the code as simple as possible (plus it would be cumbersome to test with an outdated Git LFS version). Since it is probably a niche feature I thought that might be acceptable.

Thanks,
Lars
quoted
[1] https://github.com/github/git-lfs/pull/1105

Signed-off-by: Lars Schneider <redacted>
---
Documentation/git-p4.txt | 3 ++-
git-p4.py                | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index 88ba42b..b862cb9 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -522,7 +522,8 @@ git-p4.largeFileSystem::
   that large file systems do not support the 'git p4 submit' command.
   Only Git LFS is implemented right now (see https://git-lfs.github.com/
   for more information). Download and install the Git LFS command line
-    extension to use this option and configure it like this:
+    extension (minimum version 1.2.0) to use this option and configure it
+    like this:
+
-------------
git config       git-p4.largeFileSystem GitLFS
diff --git a/git-p4.py b/git-p4.py
index 527d44b..d2be574 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1064,8 +1064,8 @@ class GitLFS(LargeFileSystem):
        if pointerProcess.wait():
            os.remove(contentFile)
            die('git-lfs pointer command failed. Did you install the extension?')
-        pointerContents = [i+'\n' for i in pointerFile.split('\n')[2:][:-1]]
-        oid = pointerContents[1].split(' ')[1].split(':')[1][:-1]
+        oidEntry = [i for i in pointerFile.split('\n') if i.startswith('oid')]
+        oid = oidEntry[0].split(' ')[1].split(':')[1]
        localLargeFile = os.path.join(
            os.getcwd(),
            '.git', 'lfs', 'objects', oid[:2], oid[2:4],
@@ -1073,7 +1073,7 @@ class GitLFS(LargeFileSystem):
        )
        # LFS Spec states that pointer files should not have the executable bit set.
        gitMode = '100644'
-        return (gitMode, pointerContents, localLargeFile)
+        return (gitMode, pointerFile, localLargeFile)

    def pushFile(self, localLargeFile):
        uploadProcess = subprocess.Popen(
--
2.5.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help