Commit 3230197c authored by Kirill Smelkov's avatar Kirill Smelkov

pull: test: Update expected error for "missing blob in pack" for Git ≥ 2.31

Starting from the same https://git.kernel.org/pub/scm/git/git.git/commit/?id=5476e1efded5
(see previous patch) git changed output when reporting error about a bad
pack. Before that patch it was something like

        $ git -c fetch.fsckObjects=true fetch-pack --thin --upload-pack=git -c uploadpack.allowAnySHA1InWant=true -c uploadpack.allowTipSHA1InWant=true -c uploadpack.allowReachableSHA1InWant=true upload-pack /home/kirr/src/neo/src/lab.nexedi.com/kirr/git-backup/testdata/3/incomplete-send-pack.git 46094318d7ea2dab446294556097361409ca1e84 </dev/null
        warning: no common commits
        remote: I: x-missing-blob/hook-pack-object is running ...
        remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
        remote: Total 4 (delta 1), reused 0 (delta 0)
        fatal: object of unexpected type                               <-- NOTE
        fatal: unpack-objects failed                                   <-- NOTE

and after the patch it became

        $ git -c fetch.fsckObjects=true fetch-pack --thin --upload-pack=git -c uploadpack.allowAnySHA1InWant=true -c uploadpack.allowTipSHA1InWant=true -c uploadpack.allowReachableSHA1InWant=true upload-pack /home/kirr/src/neo/src/lab.nexedi.com/kirr/git-backup/testdata/3/incomplete-send-pack.git 46094318d7ea2dab446294556097361409ca1e84 </dev/null
        remote: I: x-missing-blob/hook-pack-object is running ...
        remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
        remote: Total 4 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (4/4), 377 bytes | 377.00 KiB/s, done.
Resolving deltas: 100% (1/1), done.)
        fatal: did not receive expected object 737592d2855213009bd3fa689167fe9a8363e45f         <-- NOTE
        fatal: index-pack failed                                                                <-- NOTE

-> Adjust the test to detect the second case as also ok to avoid failing
tests with Git ≥ 2.31.
parent e60e2e94
...@@ -312,6 +312,7 @@ func TestPullRestore(t *testing.T) { ...@@ -312,6 +312,7 @@ func TestPullRestore(t *testing.T) {
// now try to pull repo where `git pack-objects` misbehaves // now try to pull repo where `git pack-objects` misbehaves
my3 := mydir + "/testdata/3" my3 := mydir + "/testdata/3"
checkIncompletePack := func(kind, errExpect string) { checkIncompletePack := func(kind, errExpect string) {
errExpectRe := regexp.MustCompile(errExpect)
defer exc.Catch(func(e *exc.Error) { defer exc.Catch(func(e *exc.Error) {
estr := e.Error() estr := e.Error()
bad := "" bad := ""
...@@ -319,7 +320,7 @@ func TestPullRestore(t *testing.T) { ...@@ -319,7 +320,7 @@ func TestPullRestore(t *testing.T) {
bad += fmt.Sprintf(format+"\n", argv...) bad += fmt.Sprintf(format+"\n", argv...)
} }
if !strings.Contains(estr, errExpect) { if errExpectRe.FindString(estr) == "" {
badf("- no %q", errExpect) badf("- no %q", errExpect)
} }
...@@ -349,9 +350,9 @@ func TestPullRestore(t *testing.T) { ...@@ -349,9 +350,9 @@ func TestPullRestore(t *testing.T) {
t.Fatalf("pull incomplete-send-pack.git/%s: did not complain", kind) t.Fatalf("pull incomplete-send-pack.git/%s: did not complain", kind)
} }
// missing blob: should be caught by git itself, because unpack-objects // missing blob: should be caught by git itself, because unpack-objects (git < 2.31)
// performs full reachability checks of fetched tips. // or index-pack (git ≥ 2.31) perform full reachability checks of fetched tips.
checkIncompletePack("x-missing-blob", "fatal: unpack-objects") checkIncompletePack("x-missing-blob", "fatal: (unpack-objects|index-pack)")
// missing commit: remote sends a pack that is closed under reachability, // missing commit: remote sends a pack that is closed under reachability,
// but it has objects starting from only parent of requested tip. This way // but it has objects starting from only parent of requested tip. This way
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment