@@ -161,7 +161,8 @@ function finish() {
161161}
162162trap finish INT EXIT
163163
164- SLOW_GIT=/slow_git.sh
164+ SLOW_GIT_CLONE=/slow_git_clone.sh
165+ SLOW_GIT_FETCH=/slow_git_fetch.sh
165166ASKPASS_GIT=/askpass_git.sh
166167SYNC_HOOK_COMMAND=/test_sync_hook_command.sh
167168
@@ -174,7 +175,8 @@ function GIT_SYNC() {
174175 --network=" host" \
175176 -u $( id -u) :$( id -g) \
176177 -v " $DIR " :" $DIR " :rw \
177- -v " $( pwd) /slow_git.sh" :" $SLOW_GIT " :ro \
178+ -v " $( pwd) /slow_git_clone.sh" :" $SLOW_GIT_CLONE " :ro \
179+ -v " $( pwd) /slow_git_fetch.sh" :" $SLOW_GIT_FETCH " :ro \
178180 -v " $( pwd) /askpass_git.sh" :" $ASKPASS_GIT " :ro \
179181 -v " $( pwd) /test_sync_hook_command.sh" :" $SYNC_HOOK_COMMAND " :ro \
180182 -v " $DOT_SSH /id_test" :" /etc/git-secret/ssh" :ro \
@@ -609,7 +611,7 @@ testcase "sync-loop-timeout"
609611echo " $TESTCASE 1" > " $REPO " /file
610612git -C " $REPO " commit -qam " $TESTCASE 1"
611613GIT_SYNC \
612- --git=" $SLOW_GIT " \
614+ --git=" $SLOW_GIT_CLONE " \
613615 --one-time \
614616 --timeout=1 \
615617 --repo=" file://$REPO " \
@@ -621,7 +623,7 @@ GIT_SYNC \
621623assert_file_absent " $ROOT " /link/file
622624# run with slow_git but without timing out
623625GIT_SYNC \
624- --git=" $SLOW_GIT " \
626+ --git=" $SLOW_GIT_CLONE " \
625627 --wait=0.1 \
626628 --timeout=16 \
627629 --repo=" file://$REPO " \
691693# Wrap up
692694pass
693695
696+ # #############################################
697+ # Test fetch skipping commit
698+ # #############################################
699+ testcase " fetch-skip-depth-1"
700+ echo " $TESTCASE " > " $REPO " /file
701+ git -C " $REPO " commit -qam " $TESTCASE "
702+ GIT_SYNC \
703+ --git=" $SLOW_GIT_FETCH " \
704+ --wait=0.1 \
705+ --depth=1 \
706+ --repo=" file://$REPO " \
707+ --branch=e2e-branch \
708+ --rev=HEAD \
709+ --root=" $ROOT " \
710+ --dest=" link" \
711+ > " $DIR " /log." $TESTCASE " 2>&1 &
712+
713+ # wait for first sync which does a clone followed by an artifically slowed fetch
714+ sleep 8
715+ assert_link_exists " $ROOT " /link
716+ assert_file_exists " $ROOT " /link/file
717+ assert_file_eq " $ROOT " /link/file " $TESTCASE "
718+
719+ # make a second commit to trigger a sync with shallow fetch
720+ echo " $TESTCASE -ok" > " $REPO " /file2
721+ git -C " $REPO " add file2
722+ git -C " $REPO " commit -qam " $TESTCASE new file"
723+
724+ # Give time for ls-remote to detect the commit and slowed fetch to start
725+ sleep 2
726+
727+ # make a third commit to insert the commit between ls-remote and fetch
728+ echo " $TESTCASE -ok" > " $REPO " /file3
729+ git -C " $REPO " add file3
730+ git -C " $REPO " commit -qam " $TESTCASE third file"
731+ sleep 10
732+ assert_link_exists " $ROOT " /link
733+ assert_file_exists " $ROOT " /link/file3
734+ assert_file_eq " $ROOT " /link/file3 " $TESTCASE -ok"
735+
736+ pass
737+
694738# #############################################
695739# Test password
696740# #############################################
@@ -945,7 +989,7 @@ BINDPORT=8888
945989echo " $TESTCASE 1" > " $REPO " /file
946990git -C " $REPO " commit -qam " $TESTCASE 1"
947991GIT_SYNC \
948- --git=" $SLOW_GIT " \
992+ --git=" $SLOW_GIT_CLONE " \
949993 --repo=" file://$REPO " \
950994 --branch=e2e-branch \
951995 --root=" $ROOT " \
0 commit comments