Merge branch 'ab/fetch-tags-noclobber'
authorJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 18:33:52 +0000 (11:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 18:33:52 +0000 (11:33 -0700)
Test and doc clean-ups.

* ab/fetch-tags-noclobber:
pull doc: fix a long-standing grammar error
fetch tests: correct a comment "remove it" -> "remove them"
push tests: assert re-pushing annotated tags
push tests: add more testing for forced tag pushing
push tests: fix logic error in "push" test assertion
push tests: remove redundant 'git push' invocation
fetch tests: change "Tag" test tag to "testTag"

1  2 
t/t5510-fetch.sh
t/t5516-fetch-push.sh
diff --combined t/t5510-fetch.sh
index 5e810f494e69625cc365955143a08567b8f783a9,6ab093207affbd5c15540a602606b761b2ec865b..3b7b30568cddd5d9ea1a8979e5366a262f81bf09
@@@ -535,41 -535,6 +535,41 @@@ test_expect_success "should be able to 
        )
  '
  
 +test_expect_success 'LHS of refspec follows ref disambiguation rules' '
 +      mkdir lhs-ambiguous &&
 +      (
 +              cd lhs-ambiguous &&
 +              git init server &&
 +              test_commit -C server unwanted &&
 +              test_commit -C server wanted &&
 +
 +              git init client &&
 +
 +              # Check a name coming after "refs" alphabetically ...
 +              git -C server update-ref refs/heads/s wanted &&
 +              git -C server update-ref refs/heads/refs/heads/s unwanted &&
 +              git -C client fetch ../server +refs/heads/s:refs/heads/checkthis &&
 +              git -C server rev-parse wanted >expect &&
 +              git -C client rev-parse checkthis >actual &&
 +              test_cmp expect actual &&
 +
 +              # ... and one before.
 +              git -C server update-ref refs/heads/q wanted &&
 +              git -C server update-ref refs/heads/refs/heads/q unwanted &&
 +              git -C client fetch ../server +refs/heads/q:refs/heads/checkthis &&
 +              git -C server rev-parse wanted >expect &&
 +              git -C client rev-parse checkthis >actual &&
 +              test_cmp expect actual &&
 +
 +              # Tags are preferred over branches like refs/{heads,tags}/*
 +              git -C server update-ref refs/tags/t wanted &&
 +              git -C server update-ref refs/heads/t unwanted &&
 +              git -C client fetch ../server +t:refs/heads/checkthis &&
 +              git -C server rev-parse wanted >expect &&
 +              git -C client rev-parse checkthis >actual
 +      )
 +'
 +
  # configured prune tests
  
  set_config_tristate () {
@@@ -648,7 -613,7 +648,7 @@@ test_configured_prune_type () 
                        git rev-parse --verify refs/tags/newtag
                ) &&
  
-               # now remove it
+               # now remove them
                git branch -d newbranch &&
                git tag -d newtag &&
  
@@@ -863,11 -828,9 +863,11 @@@ test_expect_success 'fetching with auto
        test_commit test2 &&
        (
                cd auto-gc &&
 +              git config fetch.unpackLimit 1 &&
                git config gc.autoPackLimit 1 &&
                git config gc.autoDetach false &&
                GIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 &&
 +              test_i18ngrep "Auto packing the repository" fetch.out &&
                ! grep "Should I try again" fetch.out
        )
  '
@@@ -902,82 -865,4 +902,82 @@@ test_expect_success C_LOCALE_OUTPUT 'fe
        test_cmp expect actual
  '
  
 +setup_negotiation_tip () {
 +      SERVER="$1"
 +      URL="$2"
 +      USE_PROTOCOL_V2="$3"
 +
 +      rm -rf "$SERVER" client trace &&
 +      git init "$SERVER" &&
 +      test_commit -C "$SERVER" alpha_1 &&
 +      test_commit -C "$SERVER" alpha_2 &&
 +      git -C "$SERVER" checkout --orphan beta &&
 +      test_commit -C "$SERVER" beta_1 &&
 +      test_commit -C "$SERVER" beta_2 &&
 +
 +      git clone "$URL" client &&
 +
 +      if test "$USE_PROTOCOL_V2" -eq 1
 +      then
 +              git -C "$SERVER" config protocol.version 2 &&
 +              git -C client config protocol.version 2
 +      fi &&
 +
 +      test_commit -C "$SERVER" beta_s &&
 +      git -C "$SERVER" checkout master &&
 +      test_commit -C "$SERVER" alpha_s &&
 +      git -C "$SERVER" tag -d alpha_1 alpha_2 beta_1 beta_2
 +}
 +
 +check_negotiation_tip () {
 +      # Ensure that {alpha,beta}_1 are sent as "have", but not {alpha_beta}_2
 +      ALPHA_1=$(git -C client rev-parse alpha_1) &&
 +      grep "fetch> have $ALPHA_1" trace &&
 +      BETA_1=$(git -C client rev-parse beta_1) &&
 +      grep "fetch> have $BETA_1" trace &&
 +      ALPHA_2=$(git -C client rev-parse alpha_2) &&
 +      ! grep "fetch> have $ALPHA_2" trace &&
 +      BETA_2=$(git -C client rev-parse beta_2) &&
 +      ! grep "fetch> have $BETA_2" trace
 +}
 +
 +test_expect_success '--negotiation-tip limits "have" lines sent' '
 +      setup_negotiation_tip server server 0 &&
 +      GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \
 +              --negotiation-tip=alpha_1 --negotiation-tip=beta_1 \
 +              origin alpha_s beta_s &&
 +      check_negotiation_tip
 +'
 +
 +test_expect_success '--negotiation-tip understands globs' '
 +      setup_negotiation_tip server server 0 &&
 +      GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \
 +              --negotiation-tip=*_1 \
 +              origin alpha_s beta_s &&
 +      check_negotiation_tip
 +'
 +
 +test_expect_success '--negotiation-tip understands abbreviated SHA-1' '
 +      setup_negotiation_tip server server 0 &&
 +      GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \
 +              --negotiation-tip=$(git -C client rev-parse --short alpha_1) \
 +              --negotiation-tip=$(git -C client rev-parse --short beta_1) \
 +              origin alpha_s beta_s &&
 +      check_negotiation_tip
 +'
 +
 +. "$TEST_DIRECTORY"/lib-httpd.sh
 +start_httpd
 +
 +test_expect_success '--negotiation-tip limits "have" lines sent with HTTP protocol v2' '
 +      setup_negotiation_tip "$HTTPD_DOCUMENT_ROOT_PATH/server" \
 +              "$HTTPD_URL/smart/server" 1 &&
 +      GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \
 +              --negotiation-tip=alpha_1 --negotiation-tip=beta_1 \
 +              origin alpha_s beta_s &&
 +      check_negotiation_tip
 +'
 +
 +stop_httpd
 +
  test_done
diff --combined t/t5516-fetch-push.sh
index bd8f23e4300218fba33a5bea5effa167a2e9155a,1331a8de082008b2712e62edc7952f565aeefccf..539c25aadafdcf6aa9fbcce0988631702d3fb02d
@@@ -923,7 -923,7 +923,7 @@@ test_expect_success 'push into aliased 
        (
                cd child1 &&
                git branch foo &&
 -              git symbolic-ref refs/heads/bar refs/heads/foo
 +              git symbolic-ref refs/heads/bar refs/heads/foo &&
                git config receive.denyCurrentBranch false
        ) &&
        (
@@@ -945,7 -945,7 +945,7 @@@ test_expect_success 'push into aliased 
        (
                cd child1 &&
                git branch foo &&
 -              git symbolic-ref refs/heads/bar refs/heads/foo
 +              git symbolic-ref refs/heads/bar refs/heads/foo &&
                git config receive.denyCurrentBranch false
        ) &&
        (
        )
  '
  
- test_expect_success 'push requires --force to update lightweight tag' '
-       mk_test testrepo heads/master &&
-       mk_child testrepo child1 &&
-       mk_child testrepo child2 &&
-       (
-               cd child1 &&
-               git tag Tag &&
-               git push ../child2 Tag &&
-               git push ../child2 Tag &&
-               >file1 &&
-               git add file1 &&
-               git commit -m "file1" &&
-               git tag -f Tag &&
-               test_must_fail git push ../child2 Tag &&
-               git push --force ../child2 Tag &&
-               git tag -f Tag &&
-               test_must_fail git push ../child2 Tag HEAD~ &&
-               git push --force ../child2 Tag
-       )
- '
+ test_force_push_tag () {
+       tag_type_description=$1
+       tag_args=$2
+       test_expect_success 'force pushing required to update lightweight tag' "
+               mk_test testrepo heads/master &&
+               mk_child testrepo child1 &&
+               mk_child testrepo child2 &&
+               (
+                       cd child1 &&
+                       git tag testTag &&
+                       git push ../child2 testTag &&
+                       >file1 &&
+                       git add file1 &&
+                       git commit -m 'file1' &&
+                       git tag $tag_args testTag &&
+                       test_must_fail git push ../child2 testTag &&
+                       git push --force ../child2 testTag &&
+                       git tag $tag_args testTag HEAD~ &&
+                       test_must_fail git push ../child2 testTag &&
+                       git push --force ../child2 testTag &&
+                       # Clobbering without + in refspec needs --force
+                       git tag -f testTag &&
+                       test_must_fail git push ../child2 'refs/tags/*:refs/tags/*' &&
+                       git push --force ../child2 'refs/tags/*:refs/tags/*' &&
+                       # Clobbering with + in refspec does not need --force
+                       git tag -f testTag HEAD~ &&
+                       git push ../child2 '+refs/tags/*:refs/tags/*' &&
+                       # Clobbering with --no-force still obeys + in refspec
+                       git tag -f testTag &&
+                       git push --no-force ../child2 '+refs/tags/*:refs/tags/*' &&
+                       # Clobbering with/without --force and 'tag <name>' format
+                       git tag -f testTag HEAD~ &&
+                       test_must_fail git push ../child2 tag testTag &&
+                       git push --force ../child2 tag testTag
+               )
+       "
+ }
+ test_force_push_tag "lightweight tag" "-f"
+ test_force_push_tag "annotated tag" "-f -a -m'msg'"
  
  test_expect_success 'push --porcelain' '
        mk_empty testrepo &&
@@@ -1011,7 -1036,7 +1036,7 @@@ test_expect_success 'push --porcelain r
        mk_empty testrepo &&
        git push testrepo refs/heads/master:refs/remotes/origin/master &&
        (cd testrepo &&
 -              git reset --hard origin/master^
 +              git reset --hard origin/master^ &&
                git config receive.denyCurrentBranch true) &&
  
        echo >.git/foo  "To testrepo"  &&
@@@ -1025,7 -1050,7 +1050,7 @@@ test_expect_success 'push --porcelain -
        mk_empty testrepo &&
        git push testrepo refs/heads/master:refs/remotes/origin/master &&
        (cd testrepo &&
 -              git reset --hard origin/master
 +              git reset --hard origin/master &&
                git config receive.denyCurrentBranch true) &&
  
        echo >.git/foo  "To testrepo"  &&
@@@ -1333,7 -1358,7 +1358,7 @@@ test_expect_success 'push --follow-tag 
                git commit --allow-empty -m "future commit" &&
                git tag -m "future" future &&
                git checkout master &&
 -              git for-each-ref refs/heads/master refs/tags/tag >../expect
 +              git for-each-ref refs/heads/master refs/tags/tag >../expect &&
                git push --follow-tag ../dst master
        ) &&
        (