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

     1  #!/usr/bin/env bash
     2  
     3  . "test/testlib.sh"
     4  
     5  begin_test "alternates (single)"
     6  (
     7    set -e
     8  
     9    reponame="alternates-single-alternate"
    10    setup_remote_repo_with_file "$reponame" "a.txt"
    11  
    12    pushd "$TRASHDIR" > /dev/null
    13      clone_repo "$reponame" "${reponame}_alternate"
    14    popd > /dev/null
    15  
    16    rm -rf .git/lfs/objects
    17  
    18    alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
    19    echo "$alternate" > .git/objects/info/alternates
    20  
    21    GIT_TRACE=1 git lfs fetch origin master 2>&1 | tee fetch.log
    22    [ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
    23  )
    24  end_test
    25  
    26  begin_test "alternates (multiple)"
    27  (
    28    set -e
    29  
    30    reponame="alternates-multiple-alternates"
    31    setup_remote_repo_with_file "$reponame" "a.txt"
    32  
    33    pushd "$TRASHDIR" > /dev/null
    34      clone_repo "$reponame" "${reponame}_alternate_stale"
    35      rm -rf .git/lfs/objects
    36    popd > /dev/null
    37    pushd "$TRASHDIR" > /dev/null
    38      clone_repo "$reponame" "${reponame}_alternate"
    39    popd > /dev/null
    40  
    41    rm -rf .git/lfs/objects
    42  
    43    alternate_stale="$TRASHDIR/${reponame}_alternate_stale/.git/objects"
    44    alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
    45    echo "$alternate" > .git/objects/info/alternates
    46    echo "$alternate_stale" >> .git/objects/info/alternates
    47  
    48    GIT_TRACE=1 git lfs fetch origin master 2>&1 | tee fetch.log
    49    [ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
    50  )
    51  end_test
    52  
    53  begin_test "alternates (commented)"
    54  (
    55    set -e
    56  
    57    reponame="alternates-commented-alternate"
    58    setup_remote_repo_with_file "$reponame" "a.txt"
    59  
    60    pushd "$TRASHDIR" > /dev/null
    61      clone_repo "$reponame" "${reponame}_alternate"
    62    popd > /dev/null
    63  
    64    rm -rf .git/lfs/objects
    65  
    66    alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
    67    echo "# $alternate" > .git/objects/info/alternates
    68  
    69    GIT_TRACE=1 git lfs fetch origin master 2>&1 | tee fetch.log
    70    [ "1" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
    71  )
    72  end_test
    73  
    74  begin_test "alternates (quoted)"
    75  (
    76    set -e
    77  
    78    reponame="alternates-quoted-alternate"
    79    setup_remote_repo_with_file "$reponame" "a.txt"
    80  
    81    pushd "$TRASHDIR" > /dev/null
    82      clone_repo "$reponame" "${reponame}_alternate"
    83    popd > /dev/null
    84  
    85    rm -rf .git/lfs/objects
    86  
    87    alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
    88    echo "\"$alternate\"" > .git/objects/info/alternates
    89  
    90    GIT_TRACE=1 git lfs fetch origin master 2>&1 | tee fetch.log
    91    [ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
    92  )
    93  end_test
    94  
    95  begin_test "alternates (OS environment, single)"
    96  (
    97    set -e
    98  
    99    reponame="alternates-environment-single-alternate"
   100    setup_remote_repo_with_file "$reponame" "a.txt"
   101  
   102    pushd "$TRASHDIR" > /dev/null
   103      clone_repo "$reponame" "${reponame}_alternate"
   104    popd > /dev/null
   105  
   106    rm -rf .git/lfs/objects
   107  
   108    alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
   109  
   110    GIT_ALTERNATE_OBJECT_DIRECTORIES="$alternate" \
   111    GIT_TRACE=1 \
   112      git lfs fetch origin master 2>&1 | tee fetch.log
   113    [ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
   114  )
   115  end_test
   116  
   117  begin_test "alternates (OS environment, multiple)"
   118  (
   119    set -e
   120  
   121    reponame="alternates-environment-multiple-alternates"
   122    setup_remote_repo_with_file "$reponame" "a.txt"
   123  
   124    pushd "$TRASHDIR" > /dev/null
   125      clone_repo "$reponame" "${reponame}_alternate_stale"
   126      rm -rf .git/lfs/objects
   127    popd > /dev/null
   128    pushd "$TRASHDIR" > /dev/null
   129      clone_repo "$reponame" "${reponame}_alternate"
   130    popd > /dev/null
   131  
   132    rm -rf .git/lfs/objects
   133  
   134    alternate_stale="$TRASHDIR/${reponame}_alternate_stale/.git/objects"
   135    alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
   136    sep="$(native_path_list_separator)"
   137  
   138    GIT_ALTERNATE_OBJECT_DIRECTORIES="$alternate_stale$sep$alternate" \
   139    GIT_TRACE=1 \
   140      git lfs fetch origin master 2>&1 | tee fetch.log
   141    [ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
   142  )
   143  end_test