Skip to content

Commit 803fd70

Browse files
committed
Merge branch 'ls/p4-lfs' into HEAD
Recent update to Git LFS broke "git p4" by changing the output from its "lfs pointer" subcommand. * ls/p4-lfs: git-p4: fix Git LFS pointer parsing travis-ci: express Linux/OS X dependency versions more clearly travis-ci: update Git-LFS and P4 to the latest version
2 parents 7ab6da3 + 82f2567 commit 803fd70

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

.travis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ addons:
2222
env:
2323
global:
2424
- DEVELOPER=1
25-
- P4_VERSION="15.2"
26-
- GIT_LFS_VERSION="1.1.0"
25+
# The Linux build installs the defined dependency versions below.
26+
# The OS X build installs the latest available versions. Keep that
27+
# in mind when you encounter a broken OS X build!
28+
- LINUX_P4_VERSION="16.1"
29+
- LINUX_GIT_LFS_VERSION="1.2.0"
2730
- DEFAULT_TEST_TARGET=prove
2831
- GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
2932
- GIT_TEST_OPTS="--verbose --tee"
@@ -38,17 +41,17 @@ before_install:
3841
linux)
3942
mkdir --parents custom/p4
4043
pushd custom/p4
41-
wget --quiet http://filehost.perforce.com/perforce/r$P4_VERSION/bin.linux26x86_64/p4d
42-
wget --quiet http://filehost.perforce.com/perforce/r$P4_VERSION/bin.linux26x86_64/p4
44+
wget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4d
45+
wget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4
4346
chmod u+x p4d
4447
chmod u+x p4
4548
export PATH="$(pwd):$PATH"
4649
popd
4750
mkdir --parents custom/git-lfs
4851
pushd custom/git-lfs
49-
wget --quiet https://github.com/github/git-lfs/releases/download/v$GIT_LFS_VERSION/git-lfs-linux-amd64-$GIT_LFS_VERSION.tar.gz
50-
tar --extract --gunzip --file "git-lfs-linux-amd64-$GIT_LFS_VERSION.tar.gz"
51-
cp git-lfs-$GIT_LFS_VERSION/git-lfs .
52+
wget --quiet https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz
53+
tar --extract --gunzip --file "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
54+
cp git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs .
5255
export PATH="$(pwd):$PATH"
5356
popd
5457
;;

git-p4.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,16 +1064,23 @@ def generatePointer(self, contentFile):
10641064
if pointerProcess.wait():
10651065
os.remove(contentFile)
10661066
die('git-lfs pointer command failed. Did you install the extension?')
1067-
pointerContents = [i+'\n' for i in pointerFile.split('\n')[2:][:-1]]
1068-
oid = pointerContents[1].split(' ')[1].split(':')[1][:-1]
1067+
1068+
# Git LFS removed the preamble in the output of the 'pointer' command
1069+
# starting from version 1.2.0. Check for the preamble here to support
1070+
# earlier versions.
1071+
# c.f. https://github.com/github/git-lfs/commit/da2935d9a739592bc775c98d8ef4df9c72ea3b43
1072+
if pointerFile.startswith('Git LFS pointer for'):
1073+
pointerFile = re.sub(r'Git LFS pointer for.*\n\n', '', pointerFile)
1074+
1075+
oid = re.search(r'^oid \w+:(\w+)', pointerFile, re.MULTILINE).group(1)
10691076
localLargeFile = os.path.join(
10701077
os.getcwd(),
10711078
'.git', 'lfs', 'objects', oid[:2], oid[2:4],
10721079
oid,
10731080
)
10741081
# LFS Spec states that pointer files should not have the executable bit set.
10751082
gitMode = '100644'
1076-
return (gitMode, pointerContents, localLargeFile)
1083+
return (gitMode, pointerFile, localLargeFile)
10771084

10781085
def pushFile(self, localLargeFile):
10791086
uploadProcess = subprocess.Popen(

t/t9824-git-p4-git-lfs.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ test_file_in_lfs () {
1313
FILE="$1" &&
1414
SIZE="$2" &&
1515
EXPECTED_CONTENT="$3" &&
16+
sed -n '1,1 p' "$FILE" | grep "^version " &&
17+
sed -n '2,2 p' "$FILE" | grep "^oid " &&
18+
sed -n '3,3 p' "$FILE" | grep "^size " &&
19+
test_line_count = 3 "$FILE" &&
1620
cat "$FILE" | grep "size $SIZE" &&
1721
HASH=$(cat "$FILE" | grep "oid sha256:" | sed -e "s/oid sha256://g") &&
1822
LFS_FILE=".git/lfs/objects/$(echo "$HASH" | cut -c1-2)/$(echo "$HASH" | cut -c3-4)/$HASH" &&

0 commit comments

Comments
 (0)