default to the batch API if lfs.batch is not set

This commit is contained in:
risk danger olson 2015-09-01 14:31:51 -06:00
parent 86f9d3d8cb
commit 8491e60e61
6 changed files with 30 additions and 37 deletions

@ -8,18 +8,16 @@ endpoint that accepts multiple OIDs. All requests should have the following:
[v1]: ./http-v1-original.md
This is an experimental API introduced in Git LFS v0.5.2, and only used if the
`lfs.batch` config value is true. You can toggle support for any local
repository like this:
This is a newer API introduced in Git LFS v0.5.2, and made the default in
Git LFS v0.6.0. The client automatically detects if the server does not
implement the API yet, and falls back to the legacy API. You can toggle support
manually through the Git config:
# enable batch support
$ git config lfs.batch true
# disable batch support
$ git config --unset lfs.batch
The Batch API is subject to change until it becomes the _default_ API used by
Git LFS v0.6.0.
# disable batch support
$ git config lfs.batch false
## Authentication

@ -133,11 +133,10 @@ func (c *Configuration) BatchTransfer() bool {
}
// Any numeric value except 0 is considered true
if n, err := strconv.Atoi(v); err == nil && n != 0 {
return true
}
n, _ := strconv.Atoi(v)
return n != 0
}
return false
return true
}
// PrivateAccess will retrieve the access value and return true if

@ -353,11 +353,11 @@ func TestBatchPresentButBlankIsTrue(t *testing.T) {
assert.Equal(t, true, v)
}
func TestBatchAbsentIsFalse(t *testing.T) {
func TestBatchAbsentIsTrue(t *testing.T) {
config := &Configuration{}
v := config.BatchTransfer()
assert.Equal(t, false, v)
assert.Equal(t, true, v)
}
func TestLoadValidExtension(t *testing.T) {

@ -17,7 +17,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual=$(git lfs env)
@ -42,7 +42,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual=$(git lfs env)
@ -74,7 +74,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual=$(git lfs env)
@ -104,7 +104,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual=$(git lfs env)
@ -137,7 +137,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual=$(git lfs env)
@ -172,7 +172,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual=$(git lfs env)
@ -195,7 +195,7 @@ begin_test "env with multiple remotes and lfs url and batch configs"
git remote add origin "$GITSERVER/env-origin-remote"
git remote add other "$GITSERVER/env-other-remote"
git config lfs.url "http://foo/bar"
git config lfs.batch true
git config lfs.batch false
git config lfs.concurrenttransfers 5
git config remote.origin.lfsurl "http://custom/origin"
git config remote.other.lfsurl "http://custom/other"
@ -209,7 +209,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=5
BatchTransfer=true
BatchTransfer=false
$(env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual=$(git lfs env)
@ -277,7 +277,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
@ -303,7 +303,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual5=$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b git lfs env)
@ -316,7 +316,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(GIT_WORK_TREE=a/b env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual6=$(GIT_WORK_TREE=a/b git lfs env)
@ -330,7 +330,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(GIT_DIR=$gitDir env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual7=$(GIT_DIR=$gitDir git lfs env)
@ -344,7 +344,7 @@ LocalGitStorageDir=$TRASHDIR/$reponame/.git
LocalMediaDir=$TRASHDIR/$reponame/.git/lfs/objects
TempDir=$TRASHDIR/$reponame/.git/lfs/tmp
ConcurrentTransfers=3
BatchTransfer=false
BatchTransfer=true
$(GIT_WORK_TREE=$workTree env | grep "^GIT")
" "$(git lfs version)" "$(git version)")
actual8=$(GIT_WORK_TREE=$workTree git lfs env)

@ -100,7 +100,7 @@ begin_test "pre-push 307 redirects"
echo "refs/heads/master master refs/heads/master 0000000000000000000000000000000000000000" |
git lfs pre-push origin "$GITSERVER/redirect307/rel/$reponame.git/info/lfs" 2>&1 |
tee push.log
grep "(1 of 1 files)" push.log
grep "(0 of 1 files, 1 skipped)" push.log
assert_server_object "$reponame" 98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4
@ -116,9 +116,7 @@ begin_test "pre-push 307 redirects"
echo "refs/heads/master master refs/heads/master 0000000000000000000000000000000000000000" |
git lfs pre-push origin "$GITSERVER/redirect307/abs/$reponame.git/info/lfs" 2>&1 |
tee push.log
grep "(1 of 1 files)" push.log
grep "(0 of 1 files, 1 skipped)" push.log
)
end_test

@ -24,7 +24,7 @@ begin_test "push"
git commit -m "add b.dat"
git lfs push origin push-b 2>&1 | tee push.log
grep "(2 of 2 files)" push.log
grep "(1 of 2 files, 1 skipped)" push.log
)
end_test
@ -73,7 +73,7 @@ begin_test "push object id(s)"
git lfs push --object-id origin \
4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 \
2>&1 | tee push.log
grep "(1 of 1 files)" push.log
grep "(0 of 1 files, 1 skipped)" push.log
echo "push b" > b.dat
git add b.dat
@ -83,7 +83,7 @@ begin_test "push object id(s)"
4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 \
82be50ad35070a4ef3467a0a650c52d5b637035e7ad02c36652e59d01ba282b7 \
2>&1 | tee push.log
grep "(2 of 2 files)" push.log
grep "(0 of 2 files, 2 skipped)" push.log
)
end_test
@ -107,7 +107,7 @@ begin_test "push modified files"
oid3=$(printf "$content3" | shasum -a 256 | cut -f 1 -d " ")
oid4=$(printf "$content4" | shasum -a 256 | cut -f 1 -d " ")
oid5=$(printf "$content5" | shasum -a 256 | cut -f 1 -d " ")
echo "[
{
\"CommitDate\":\"$(get_date -6m)\",
@ -143,5 +143,3 @@ begin_test "push modified files"
assert_server_object "$reponame" "$oid5"
)
end_test