github.com/git-lfs/git-lfs@v2.5.2+incompatible/t/t-push.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  . "$(dirname "$0")/testlib.sh"
     4  
     5  # sets up the repos for the first few push tests. The passed argument is the
     6  # name of the repo to setup. The resuling repo will have a local file tracked
     7  # with LFS and committed, but not yet pushed to the remote
     8  push_repo_setup() {
     9    reponame="$1"
    10    setup_remote_repo "$reponame"
    11    clone_repo "$reponame" "$reponame"
    12  
    13    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" false
    14    git lfs track "*.dat"
    15    echo "push a" > a.dat
    16    git add .gitattributes a.dat
    17    git commit -m "add a.dat"
    18  }
    19  
    20  begin_test "push with good ref"
    21  (
    22    set -e
    23    push_repo_setup "push-master-branch-required"
    24  
    25    git lfs push origin master
    26  )
    27  end_test
    28  
    29  begin_test "push with tracked ref"
    30  (
    31    set -e
    32  
    33    push_repo_setup "push-tracked-branch-required"
    34  
    35    git config push.default upstream
    36    git config branch.master.merge refs/heads/tracked
    37    git lfs push origin master
    38  )
    39  end_test
    40  
    41  begin_test "push with bad ref"
    42  (
    43    set -e
    44    push_repo_setup "push-other-branch-required"
    45  
    46    git lfs push origin master 2>&1 | tee push.log
    47    if [ "0" -eq "${PIPESTATUS[0]}" ]; then
    48      echo "expected command to fail"
    49      exit 1
    50    fi
    51  
    52    grep 'batch response: Expected ref "refs/heads/other", got "refs/heads/master"' push.log
    53  )
    54  end_test
    55  
    56  begin_test "push with given remote, configured pushRemote"
    57  (
    58    set -e
    59    push_repo_setup "push-given-and-config"
    60  
    61    git remote add bad-remote "invalid-url"
    62  
    63    git config branch.master.pushRemote bad-remote
    64  
    65    git lfs push --all origin
    66  )
    67  end_test
    68  
    69  begin_test "push"
    70  (
    71    set -e
    72  
    73    reponame="$(basename "$0" ".sh")"
    74    setup_remote_repo "$reponame"
    75    clone_repo "$reponame" repo
    76  
    77    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
    78  
    79    git lfs track "*.dat"
    80    echo "push a" > a.dat
    81    git add .gitattributes a.dat
    82    git commit -m "add a.dat"
    83  
    84    git lfs push --dry-run origin master 2>&1 | tee push.log
    85    grep "push 4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 => a.dat" push.log
    86    [ $(grep -c "push" push.log) -eq 1 ]
    87  
    88    git lfs push origin master 2>&1 | tee push.log
    89    grep "Uploading LFS objects: 100% (1/1), 7 B" push.log
    90  
    91    git checkout -b push-b
    92    echo "push b" > b.dat
    93    git add b.dat
    94    git commit -m "add b.dat"
    95  
    96    git lfs push --dry-run origin push-b 2>&1 | tee push.log
    97    grep "push 4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 => a.dat" push.log
    98    grep "push 82be50ad35070a4ef3467a0a650c52d5b637035e7ad02c36652e59d01ba282b7 => b.dat" push.log
    99    [ $(grep -c "push" < push.log) -eq 2 ]
   100  
   101    # simulate remote ref
   102    mkdir -p .git/refs/remotes/origin
   103    git rev-parse HEAD > .git/refs/remotes/origin/HEAD
   104  
   105    git lfs push --dry-run origin push-b 2>&1 | tee push.log
   106    [ $(grep -c "push" push.log) -eq 0 ]
   107  
   108    rm -rf .git/refs/remotes
   109  
   110    git lfs push origin push-b 2>&1 | tee push.log
   111    grep "Uploading LFS objects: 100% (2/2), 14 B" push.log
   112  )
   113  end_test
   114  
   115  # sets up the tests for the next few push --all tests
   116  push_all_setup() {
   117    suffix="$1"
   118    reponame="$(basename "$0" ".sh")-all"
   119    content1="initial"
   120    content2="update"
   121    content3="branch"
   122    content4="tagged"
   123    content5="master"
   124    extracontent="extra"
   125    oid1=$(calc_oid "$content1")
   126    oid2=$(calc_oid "$content2")
   127    oid3=$(calc_oid "$content3")
   128    oid4=$(calc_oid "$content4")
   129    oid5=$(calc_oid "$content5")
   130    extraoid=$(calc_oid "$extracontent")
   131  
   132    # if the local repo exists, it has already been bootstrapped
   133    [ -d "push-all" ] && exit 0
   134  
   135    clone_repo "$reponame" "push-all"
   136    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
   137    git lfs track "*.dat"
   138  
   139    echo "[
   140    {
   141      \"CommitDate\":\"$(get_date -6m)\",
   142      \"Files\":[
   143        {\"Filename\":\"file1.dat\",\"Size\":${#content1},\"Data\":\"$content1\"}
   144      ]
   145    },
   146    {
   147      \"CommitDate\":\"$(get_date -5m)\",
   148      \"Files\":[
   149        {\"Filename\":\"file1.dat\",\"Size\":${#content2},\"Data\":\"$content2\"}
   150      ]
   151    },
   152    {
   153      \"CommitDate\":\"$(get_date -4m)\",
   154      \"NewBranch\":\"branch\",
   155      \"Files\":[
   156        {\"Filename\":\"file1.dat\",\"Size\":${#content3},\"Data\":\"$content3\"}
   157      ]
   158    },
   159    {
   160      \"CommitDate\":\"$(get_date -4m)\",
   161      \"ParentBranches\":[\"master\"],
   162      \"Tags\":[\"tag\"],
   163      \"Files\":[
   164        {\"Filename\":\"file1.dat\",\"Size\":${#content4},\"Data\":\"$content4\"}
   165      ]
   166    },
   167    {
   168      \"CommitDate\":\"$(get_date -2m)\",
   169      \"Files\":[
   170        {\"Filename\":\"file1.dat\",\"Size\":${#content5},\"Data\":\"$content5\"},
   171        {\"Filename\":\"file2.dat\",\"Size\":${#extracontent},\"Data\":\"$extracontent\"}
   172      ]
   173    }
   174    ]" | lfstest-testutils addcommits
   175  
   176    git rm file2.dat
   177    git commit -m "remove file2.dat"
   178  
   179    # simulate remote ref
   180    mkdir -p .git/refs/remotes/origin
   181    git rev-parse HEAD > .git/refs/remotes/origin/HEAD
   182  
   183    setup_alternate_remote "$reponame-$suffix"
   184    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix").locksverify" true
   185  }
   186  
   187  begin_test "push --all (no ref args)"
   188  (
   189    set -e
   190  
   191    push_all_setup "everything"
   192  
   193    git lfs push --dry-run --all origin 2>&1 | tee push.log
   194    grep "push $oid1 => file1.dat" push.log
   195    grep "push $oid2 => file1.dat" push.log
   196    grep "push $oid3 => file1.dat" push.log
   197    grep "push $oid4 => file1.dat" push.log
   198    grep "push $oid5 => file1.dat" push.log
   199    grep "push $extraoid => file2.dat" push.log
   200    [ $(grep -c "push" < push.log) -eq 6 ]
   201  
   202    git push --all origin 2>&1 | tee push.log
   203    [ $(grep -c "Uploading LFS objects: 100% (6/6), 36 B" push.log) -eq 1 ]
   204    assert_server_object "$reponame-$suffix" "$oid1"
   205    assert_server_object "$reponame-$suffix" "$oid2"
   206    assert_server_object "$reponame-$suffix" "$oid3"
   207    assert_server_object "$reponame-$suffix" "$oid4"
   208    assert_server_object "$reponame-$suffix" "$oid5"
   209    assert_server_object "$reponame-$suffix" "$extraoid"
   210  
   211    echo "push while missing old objects locally"
   212    setup_alternate_remote "$reponame-$suffix-2"
   213    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
   214  
   215    git lfs push --object-id origin $oid1
   216    assert_server_object "$reponame-$suffix-2" "$oid1"
   217    refute_server_object "$reponame-$suffix-2" "$oid2"
   218    refute_server_object "$reponame-$suffix-2" "$oid3"
   219    refute_server_object "$reponame-$suffix-2" "$oid4"
   220    refute_server_object "$reponame-$suffix-2" "$oid5"
   221    refute_server_object "$reponame-$suffix-2" "$extraoid"
   222    rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
   223  
   224    echo "dry run missing local object that exists on server"
   225    git lfs push --dry-run --all origin 2>&1 | tee push.log
   226    grep "push $oid1 => file1.dat" push.log
   227    grep "push $oid2 => file1.dat" push.log
   228    grep "push $oid3 => file1.dat" push.log
   229    grep "push $oid4 => file1.dat" push.log
   230    grep "push $oid5 => file1.dat" push.log
   231    grep "push $extraoid => file2.dat" push.log
   232    [ $(grep -c "push" push.log) -eq 6 ]
   233  
   234    git push --all origin 2>&1 | tee push.log
   235    grep "Uploading LFS objects: 100% (6/6), 36 B" push.log
   236    assert_server_object "$reponame-$suffix-2" "$oid2"
   237    assert_server_object "$reponame-$suffix-2" "$oid3"
   238    assert_server_object "$reponame-$suffix-2" "$oid4"
   239    assert_server_object "$reponame-$suffix-2" "$oid5"
   240    assert_server_object "$reponame-$suffix-2" "$extraoid"
   241  )
   242  end_test
   243  
   244  begin_test "push --all (1 ref arg)"
   245  (
   246    set -e
   247  
   248    push_all_setup "ref"
   249  
   250    git lfs push --dry-run --all origin branch 2>&1 | tee push.log
   251    grep "push $oid1 => file1.dat" push.log
   252    grep "push $oid2 => file1.dat" push.log
   253    grep "push $oid3 => file1.dat" push.log
   254    [ $(grep -c "push" < push.log) -eq 3 ]
   255  
   256    git lfs push --all origin branch 2>&1 | tee push.log
   257    grep "3 files" push.log
   258    assert_server_object "$reponame-$suffix" "$oid1"
   259    assert_server_object "$reponame-$suffix" "$oid2"
   260    assert_server_object "$reponame-$suffix" "$oid3"
   261    refute_server_object "$reponame-$suffix" "$oid4"     # in master and the tag
   262    refute_server_object "$reponame-$suffix" "$oid5"
   263    refute_server_object "$reponame-$suffix" "$extraoid"
   264  
   265    echo "push while missing old objects locally"
   266    setup_alternate_remote "$reponame-$suffix-2"
   267    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
   268    git lfs push --object-id origin $oid1
   269    assert_server_object "$reponame-$suffix-2" "$oid1"
   270    refute_server_object "$reponame-$suffix-2" "$oid2"
   271    refute_server_object "$reponame-$suffix-2" "$oid3"
   272    refute_server_object "$reponame-$suffix-2" "$oid4"
   273    refute_server_object "$reponame-$suffix-2" "$oid5"
   274    refute_server_object "$reponame-$suffix-2" "$extraoid"
   275    rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
   276  
   277    # dry run doesn't change
   278    git lfs push --dry-run --all origin branch 2>&1 | tee push.log
   279    grep "push $oid1 => file1.dat" push.log
   280    grep "push $oid2 => file1.dat" push.log
   281    grep "push $oid3 => file1.dat" push.log
   282    [ $(grep -c "push" push.log) -eq 3 ]
   283  
   284    git push --all origin branch 2>&1 | tee push.log
   285    grep "5 files, 1 skipped" push.log # should be 5?
   286    assert_server_object "$reponame-$suffix-2" "$oid2"
   287    assert_server_object "$reponame-$suffix-2" "$oid3"
   288    refute_server_object "$reponame-$suffix-2" "$oid4"
   289    refute_server_object "$reponame-$suffix-2" "$oid5"
   290    refute_server_object "$reponame-$suffix-2" "$extraoid"
   291  )
   292  end_test
   293  
   294  begin_test "push --all (multiple ref args)"
   295  (
   296    set -e
   297  
   298    push_all_setup "multiple-refs"
   299  
   300    git lfs push --dry-run --all origin branch tag 2>&1 | tee push.log
   301    grep "push $oid1 => file1.dat" push.log
   302    grep "push $oid2 => file1.dat" push.log
   303    grep "push $oid3 => file1.dat" push.log
   304    grep "push $oid4 => file1.dat" push.log
   305    [ $(grep -c "push" push.log) -eq 4 ]
   306  
   307    git lfs push --all origin branch tag 2>&1 | tee push.log
   308    grep "4 files" push.log
   309    assert_server_object "$reponame-$suffix" "$oid1"
   310    assert_server_object "$reponame-$suffix" "$oid2"
   311    assert_server_object "$reponame-$suffix" "$oid3"
   312    assert_server_object "$reponame-$suffix" "$oid4"
   313    refute_server_object "$reponame-$suffix" "$oid5"     # only in master
   314    refute_server_object "$reponame-$suffix" "$extraoid"
   315  
   316    echo "push while missing old objects locally"
   317    setup_alternate_remote "$reponame-$suffix-2"
   318    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
   319    git lfs push --object-id origin $oid1
   320    assert_server_object "$reponame-$suffix-2" "$oid1"
   321    refute_server_object "$reponame-$suffix-2" "$oid2"
   322    refute_server_object "$reponame-$suffix-2" "$oid3"
   323    refute_server_object "$reponame-$suffix-2" "$oid4"
   324    refute_server_object "$reponame-$suffix-2" "$oid5"
   325    refute_server_object "$reponame-$suffix-2" "$extraoid"
   326    rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
   327  
   328    # dry run doesn't change
   329    git lfs push --dry-run --all origin branch tag 2>&1 | tee push.log
   330    grep "push $oid1 => file1.dat" push.log
   331    grep "push $oid2 => file1.dat" push.log
   332    grep "push $oid3 => file1.dat" push.log
   333    grep "push $oid4 => file1.dat" push.log
   334    [ $(grep -c "push" push.log) -eq 3 ]
   335  
   336    git push --all origin branch tag 2>&1 | tee push.log
   337    grep "5 files, 1 skipped" push.log # should be 5?
   338    assert_server_object "$reponame-$suffix-2" "$oid2"
   339    assert_server_object "$reponame-$suffix-2" "$oid3"
   340    assert_server_object "$reponame-$suffix-2" "$oid4"
   341    refute_server_object "$reponame-$suffix-2" "$oid5"
   342    refute_server_object "$reponame-$suffix-2" "$extraoid"
   343  )
   344  end_test
   345  
   346  begin_test "push --all (ref with deleted files)"
   347  (
   348    set -e
   349  
   350    push_all_setup "ref-with-deleted"
   351  
   352    git lfs push --dry-run --all origin master 2>&1 | tee push.log
   353    grep "push $oid1 => file1.dat" push.log
   354    grep "push $oid2 => file1.dat" push.log
   355    grep "push $oid4 => file1.dat" push.log
   356    grep "push $oid5 => file1.dat" push.log
   357    grep "push $extraoid => file2.dat" push.log
   358    [ $(grep -c "push" push.log) -eq 5 ]
   359  
   360    git lfs push --all origin master 2>&1 | tee push.log
   361    grep "5 files" push.log
   362    assert_server_object "$reponame-$suffix" "$oid1"
   363    assert_server_object "$reponame-$suffix" "$oid2"
   364    refute_server_object "$reponame-$suffix" "$oid3" # only in the branch
   365    assert_server_object "$reponame-$suffix" "$oid4"
   366    assert_server_object "$reponame-$suffix" "$oid5"
   367    assert_server_object "$reponame-$suffix" "$extraoid"
   368  
   369    echo "push while missing old objects locally"
   370    setup_alternate_remote "$reponame-$suffix-2"
   371    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
   372    git lfs push --object-id origin $oid1
   373    assert_server_object "$reponame-$suffix-2" "$oid1"
   374    refute_server_object "$reponame-$suffix-2" "$oid2"
   375    refute_server_object "$reponame-$suffix-2" "$oid3"
   376    refute_server_object "$reponame-$suffix-2" "$oid4"
   377    refute_server_object "$reponame-$suffix-2" "$oid5"
   378    refute_server_object "$reponame-$suffix-2" "$extraoid"
   379    rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
   380  
   381    # dry run doesn't change
   382    git lfs push --dry-run --all origin master 2>&1 | tee push.log
   383    grep "push $oid1 => file1.dat" push.log
   384    grep "push $oid2 => file1.dat" push.log
   385    grep "push $oid4 => file1.dat" push.log
   386    grep "push $oid5 => file1.dat" push.log
   387    grep "push $extraoid => file2.dat" push.log
   388    [ $(grep -c "push" push.log) -eq 5 ]
   389  
   390    git push --all origin master 2>&1 | tee push.log
   391    grep "5 files, 1 skipped" push.log # should be 5?
   392    assert_server_object "$reponame-$suffix-2" "$oid2"
   393    refute_server_object "$reponame-$suffix-2" "$oid3"
   394    assert_server_object "$reponame-$suffix-2" "$oid4"
   395    assert_server_object "$reponame-$suffix-2" "$oid5"
   396    assert_server_object "$reponame-$suffix-2" "$extraoid"
   397  )
   398  end_test
   399  
   400  begin_test "push object id(s)"
   401  (
   402    set -e
   403  
   404    reponame="$(basename "$0" ".sh")"
   405    setup_remote_repo "$reponame"
   406    clone_repo "$reponame" repo2
   407  
   408    git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
   409  
   410    git lfs track "*.dat"
   411    echo "push a" > a.dat
   412    git add .gitattributes a.dat
   413    git commit -m "add a.dat"
   414  
   415    git lfs push --object-id origin \
   416      4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 \
   417      2>&1 | tee push.log
   418    grep "Uploading LFS objects: 100% (1/1), 7 B" push.log
   419  
   420    echo "push b" > b.dat
   421    git add b.dat
   422    git commit -m "add b.dat"
   423  
   424    git lfs push --object-id origin \
   425      4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 \
   426      82be50ad35070a4ef3467a0a650c52d5b637035e7ad02c36652e59d01ba282b7 \
   427      2>&1 | tee push.log
   428    grep "Uploading LFS objects: 100% (2/2), 14 B" push.log
   429  )
   430  end_test
   431  
   432  begin_test "push modified files"
   433  (
   434    set -e
   435  
   436    reponame="$(basename "$0" ".sh")-modified"
   437    setup_remote_repo "$reponame"
   438    clone_repo "$reponame" "$reponame"
   439  
   440    git lfs track "*.dat"
   441    # generate content we'll use
   442    content1="filecontent1"
   443    content2="filecontent2"
   444    content3="filecontent3"
   445    content4="filecontent4"
   446    content5="filecontent5"
   447    oid1=$(calc_oid "$content1")
   448    oid2=$(calc_oid "$content2")
   449    oid3=$(calc_oid "$content3")
   450    oid4=$(calc_oid "$content4")
   451    oid5=$(calc_oid "$content5")
   452  
   453    echo "[
   454    {
   455      \"CommitDate\":\"$(get_date -6m)\",
   456      \"Files\":[
   457        {\"Filename\":\"file1.dat\",\"Size\":${#content1}, \"Data\":\"$content1\"}]
   458    },
   459    {
   460      \"CommitDate\":\"$(get_date -3m)\",
   461      \"Files\":[
   462        {\"Filename\":\"file1.dat\",\"Size\":${#content2}, \"Data\":\"$content2\"}]
   463    },
   464    {
   465      \"CommitDate\":\"$(get_date -1m)\",
   466      \"NewBranch\":\"other_branch\",
   467      \"Files\":[
   468        {\"Filename\":\"file1.dat\",\"Size\":${#content5}, \"Data\":\"$content5\"}]
   469    },
   470    {
   471      \"CommitDate\":\"$(get_date -1m)\",
   472      \"ParentBranches\":[\"master\"],
   473      \"Files\":[
   474        {\"Filename\":\"file1.dat\",\"Size\":${#content3}, \"Data\":\"$content3\"},
   475        {\"Filename\":\"file2.dat\",\"Size\":${#content4}, \"Data\":\"$content4\"}]
   476    }
   477    ]" | lfstest-testutils addcommits
   478  
   479    git lfs push origin master
   480    git lfs push origin other_branch
   481    assert_server_object "$reponame" "$oid1"
   482    assert_server_object "$reponame" "$oid2"
   483    assert_server_object "$reponame" "$oid3"
   484    assert_server_object "$reponame" "$oid4"
   485    assert_server_object "$reponame" "$oid5"
   486  )
   487  end_test
   488  
   489  begin_test "push with invalid remote"
   490  (
   491    set -e
   492    cd repo
   493    git lfs push not-a-remote 2>&1 | tee push.log
   494    grep "Invalid remote name" push.log
   495  )
   496  end_test
   497  
   498  begin_test "push ambiguous branch name"
   499  (
   500    set -e
   501  
   502    reponame="$(basename "$0" ".sh")-ambiguous-branch"
   503    setup_remote_repo "$reponame"
   504    clone_repo "$reponame" "$reponame"
   505  
   506  
   507    git lfs track "*.dat" 2>&1 | tee track.log
   508    grep "Tracking \"\*.dat\"" track.log
   509  
   510    NUMFILES=5
   511    # generate content we'll use
   512    for ((a=0; a < NUMFILES ; a++))
   513    do
   514      content[$a]="filecontent$a"
   515      oid[$a]=$(calc_oid "${content[$a]}")
   516    done
   517  
   518    echo "[
   519    {
   520      \"CommitDate\":\"$(get_date -10d)\",
   521      \"Files\":[
   522        {\"Filename\":\"file1.dat\",\"Size\":${#content[0]}, \"Data\":\"${content[0]}\"},
   523        {\"Filename\":\"file2.dat\",\"Size\":${#content[1]}, \"Data\":\"${content[1]}\"}]
   524    },
   525    {
   526      \"NewBranch\":\"ambiguous\",
   527      \"CommitDate\":\"$(get_date -5d)\",
   528      \"Files\":[
   529        {\"Filename\":\"file3.dat\",\"Size\":${#content[2]}, \"Data\":\"${content[2]}\"}]
   530    },
   531    {
   532      \"CommitDate\":\"$(get_date -2d)\",
   533      \"Files\":[
   534        {\"Filename\":\"file4.dat\",\"Size\":${#content[3]}, \"Data\":\"${content[3]}\"}]
   535    },
   536    {
   537      \"ParentBranches\":[\"master\"],
   538      \"CommitDate\":\"$(get_date -1d)\",
   539      \"Files\":[
   540        {\"Filename\":\"file1.dat\",\"Size\":${#content[4]}, \"Data\":\"${content[4]}\"}]
   541    }
   542    ]" | lfstest-testutils addcommits
   543  
   544    # create tag with same name as branch
   545    git tag ambiguous
   546  
   547    # lfs push master, should work
   548    git lfs push origin master
   549  
   550    # push ambiguous, does not fail since lfs scans git with sha, not ref name
   551    git lfs push origin ambiguous
   552  )
   553  end_test
   554  
   555  begin_test "push (retry with expired actions)"
   556  (
   557    set -e
   558  
   559    reponame="push_retry_expired_action"
   560    setup_remote_repo "$reponame"
   561    clone_repo "$reponame" "$reponame"
   562  
   563    git lfs track "*.dat"
   564    contents="return-expired-action"
   565    contents_oid="$(calc_oid "$contents")"
   566    contents_size="$(printf "$contents" | wc -c | awk '{ print $1 }')"
   567    printf "$contents" > a.dat
   568    git add .gitattributes a.dat
   569  
   570    git commit -m "add a.dat, .gitattributes" 2>&1 | tee commit.log
   571    grep "master (root-commit)" commit.log
   572    grep "2 files changed" commit.log
   573    grep "create mode 100644 a.dat" commit.log
   574    grep "create mode 100644 .gitattributes" commit.log
   575  
   576    GIT_TRACE=1 git push origin master 2>&1 | tee push.log
   577  
   578    expected="enqueue retry #1 for \"$contents_oid\" (size: $contents_size): LFS: tq: action \"upload\" expires at"
   579  
   580    grep "$expected" push.log
   581    grep "Uploading LFS objects: 100% (1/1), 21 B" push.log
   582  )
   583  end_test
   584  
   585  begin_test "push to raw remote url"
   586  (
   587    set -e
   588  
   589    setup_remote_repo "push-raw"
   590    mkdir push-raw
   591    cd push-raw
   592    git init
   593  
   594    git lfs track "*.dat"
   595  
   596    contents="raw"
   597    contents_oid=$(calc_oid "$contents")
   598  
   599    printf "$contents" > raw.dat
   600    git add raw.dat .gitattributes
   601    git commit -m "add" 2>&1 | tee commit.log
   602    grep "master (root-commit)" commit.log
   603    grep "2 files changed" commit.log
   604    grep "create mode 100644 raw.dat" commit.log
   605    grep "create mode 100644 .gitattributes" commit.log
   606  
   607    refute_server_object push-raw "$contents_oid"
   608  
   609    git lfs push $GITSERVER/push-raw master
   610  
   611    assert_server_object push-raw "$contents_oid"
   612  )
   613  end_test
   614  
   615  begin_test "push (with invalid object size)"
   616  (
   617    set -e
   618  
   619    reponame="push-invalid-object-size"
   620    setup_remote_repo "$reponame"
   621    clone_repo "$reponame" "$reponame"
   622  
   623    git lfs track "*.dat"
   624    contents="return-invalid-size"
   625    printf "$contents" > a.dat
   626  
   627    git add a.dat .gitattributes
   628    git commit -m "add a.dat, .gitattributes" 2>&1 | tee commit.log
   629    grep "master (root-commit)" commit.log
   630    grep "2 files changed" commit.log
   631    grep "create mode 100644 a.dat" commit.log
   632    grep "create mode 100644 .gitattributes" commit.log
   633  
   634    set +e
   635    git push origin master 2>&1 2> push.log
   636    res="$?"
   637    set -e
   638  
   639    grep "invalid size (got: -1)" push.log
   640    [ "0" -eq "$(grep -c "panic" push.log)" ]
   641    [ "0" -ne "$res" ]
   642  
   643    refute_server_object "$reponame" "$(calc_oid "$contents")"
   644  )
   645  end_test
   646  
   647  begin_test "push with deprecated _links"
   648  (
   649    set -e
   650  
   651    reponame="$(basename "$0" ".sh")-deprecated"
   652    setup_remote_repo "$reponame"
   653    clone_repo "$reponame" "$reponame"
   654  
   655    git lfs track "*.dat"
   656    git add .gitattributes
   657    git commit -m "initial commit"
   658  
   659    contents="send-deprecated-links"
   660    contents_oid="$(calc_oid "$contents")"
   661    printf "$contents" > a.dat
   662    git add a.dat
   663    git commit -m "add a.dat"
   664  
   665    git push origin master
   666  
   667    assert_server_object "$reponame" "$contents_oid"
   668  )
   669  end_test