c8d/resolveImage: Fix Digested and Named reference
When resolving a reference that is both a Named and Digested, it could be resolved to an image that has the same digest, but completely different repository name.

This caused a bunch of test failing with `Error response from daemon: No such image: busybox:latest` with the containerd integration enabled (https://github.com/moby/moby/pull/45232) because the `testEnv.Clean` deleted the source busybox image instead of the new tag created in test.

<details>

<summary>Example failing tests</summary>

```
=== FAIL: amd64.integration-cli TestDockerAPISuite/TestPostContainersCreateMemorySwappinessHostConfigOmitted (0.03s)
    docker_api_containers_test.go:1540: assertion failed: error is not nil: Error response from daemon: No such image: busybox:latest
    --- FAIL: TestDockerAPISuite/TestPostContainersCreateMemorySwappinessHostConfigOmitted (0.03s)

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestPostContainersCreateShmSizeHostConfigOmitted (0.02s)
    docker_api_containers_test.go:1456: assertion failed: error is not nil: Error response from daemon: No such image: busybox:latest
    --- FAIL: TestDockerAPISuite/TestPostContainersCreateShmSizeHostConfigOmitted (0.02s)

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestPostContainersCreateShmSizeOmitted (0.02s)
    docker_api_containers_test.go:1483: assertion failed: error is not nil: Error response from daemon: No such image: busybox:latest
    --- FAIL: TestDockerAPISuite/TestPostContainersCreateShmSizeOmitted (0.02s)

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestPostContainersCreateWithShmSize (0.02s)
    docker_api_containers_test.go:1514: assertion failed: error is not nil: Error response from daemon: No such image: busybox:latest
    --- FAIL: TestDockerAPISuite/TestPostContainersCreateWithShmSize (0.02s)
```

</details>

<!--
Please make sure you've read and understood our contributing guidelines;
https://github.com/moby/moby/blob/master/CONTRIBUTING.md

** Make sure all your commits include a signature generated with `git commit -s` **

For additional information on our contributing process, read our contributing
guide https://docs.docker.com/opensource/code/

If this is a bug fix, make sure your description includes "fixes #xxxx", or
"closes #xxxx"

Please provide the following information:
-->

**- What I did**
Fix digested and named reference being resolved to an image with different repository

**- How I did it**

**- How to verify it**
Test: TestRemoveByDigest

manually:

Before:
```bash
$ docker pull alpine
Using default tag: latest
82d1e9d7ed48: Download complete
e3bd82196e98: Download complete
5053b247d78b: Download complete
8c6d1654570f: Download complete
ndocker.io/library/alpine:latest
$ docker tag alpine asdf
$docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
alpine       latest    82d1e9d7ed48   4 seconds ago   11.7MB
asdf         latest    82d1e9d7ed48   2 seconds ago   11.7MB
$ docker rmi asdf@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
Untagged: asdf@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
asdf         latest    82d1e9d7ed48   15 seconds ago   11.7MB
```

After:
```bash
$ docker tag alpine asdf
$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
alpine       latest    82d1e9d7ed48   5 seconds ago   11.7MB
asdf         latest    82d1e9d7ed48   2 seconds ago   11.7MB
$ docker rmi asdf@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
Untagged: asdf@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
alpine       latest    82d1e9d7ed48   9 seconds ago   11.7MB
```


**- Description for the changelog**
```release-notes
- Fix resolving a reference with repository name and digest to an image with a matching digest, but different repository.
```

**- A picture of a cute animal (not mandatory but encouraged)**


integration/image/remove_test.go
package image // import "github.com/docker/docker/integration/image"

import (
	"context"
	"strings"
	"testing"

	"github.com/docker/docker/api/types"
	"github.com/docker/docker/integration/internal/container"
	"gotest.tools/v3/assert"
	is "gotest.tools/v3/assert/cmp"
)

func TestRemoveImageOrphaning(t *testing.T) {
	defer setupTest(t)()
	ctx := context.Background()
	client := testEnv.APIClient()

	imgName := strings.ToLower(t.Name())

	// Create a container from busybox, and commit a small change so we have a new image
	cID1 := container.Create(ctx, t, client, container.WithCmd(""))
	commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
		Changes:   []string{`ENTRYPOINT ["true"]`},
		Reference: imgName,
	})
	assert.NilError(t, err)

	// verifies that reference now points to first image
	resp, _, err := client.ImageInspectWithRaw(ctx, imgName)
	assert.NilError(t, err)
	assert.Check(t, is.Equal(resp.ID, commitResp1.ID))

	// Create a container from created image, and commit a small change with same reference name
	cID2 := container.Create(ctx, t, client, container.WithImage(imgName), container.WithCmd(""))
	commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
		Changes:   []string{`LABEL Maintainer="Integration Tests"`},
		Reference: imgName,
	})
	assert.NilError(t, err)

	// verifies that reference now points to second image
	resp, _, err = client.ImageInspectWithRaw(ctx, imgName)
	assert.NilError(t, err)
	assert.Check(t, is.Equal(resp.ID, commitResp2.ID))

	// try to remove the image, should not error out.
	_, err = client.ImageRemove(ctx, imgName, types.ImageRemoveOptions{})
	assert.NilError(t, err)

	// check if the first image is still there
	resp, _, err = client.ImageInspectWithRaw(ctx, commitResp1.ID)
	assert.NilError(t, err)
	assert.Check(t, is.Equal(resp.ID, commitResp1.ID))

	// check if the second image has been deleted
	_, _, err = client.ImageInspectWithRaw(ctx, commitResp2.ID)
	assert.Check(t, is.ErrorContains(err, "No such image:"))
}

package image // import "github.com/docker/docker/integration/image"

import (
	"context"
	"strings"
	"testing"

	"github.com/docker/docker/api/types"
	"github.com/docker/docker/errdefs"
	"github.com/docker/docker/integration/internal/container"
	"gotest.tools/v3/assert"
	is "gotest.tools/v3/assert/cmp"
	"gotest.tools/v3/skip"
)

func TestRemoveImageOrphaning(t *testing.T) {
	defer setupTest(t)()
	ctx := context.Background()
	client := testEnv.APIClient()

	imgName := strings.ToLower(t.Name())

	// Create a container from busybox, and commit a small change so we have a new image
	cID1 := container.Create(ctx, t, client, container.WithCmd(""))
	commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
		Changes:   []string{`ENTRYPOINT ["true"]`},
		Reference: imgName,
	})
	assert.NilError(t, err)

	// verifies that reference now points to first image
	resp, _, err := client.ImageInspectWithRaw(ctx, imgName)
	assert.NilError(t, err)
	assert.Check(t, is.Equal(resp.ID, commitResp1.ID))

	// Create a container from created image, and commit a small change with same reference name
	cID2 := container.Create(ctx, t, client, container.WithImage(imgName), container.WithCmd(""))
	commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
		Changes:   []string{`LABEL Maintainer="Integration Tests"`},
		Reference: imgName,
	})
	assert.NilError(t, err)

	// verifies that reference now points to second image
	resp, _, err = client.ImageInspectWithRaw(ctx, imgName)
	assert.NilError(t, err)
	assert.Check(t, is.Equal(resp.ID, commitResp2.ID))

	// try to remove the image, should not error out.
	_, err = client.ImageRemove(ctx, imgName, types.ImageRemoveOptions{})
	assert.NilError(t, err)

	// check if the first image is still there
	resp, _, err = client.ImageInspectWithRaw(ctx, commitResp1.ID)
	assert.NilError(t, err)
	assert.Check(t, is.Equal(resp.ID, commitResp1.ID))

	// check if the second image has been deleted
	_, _, err = client.ImageInspectWithRaw(ctx, commitResp2.ID)
	assert.Check(t, is.ErrorContains(err, "No such image:"))
}

func TestRemoveByDigest(t *testing.T) {
	skip.If(t, !testEnv.UsingSnapshotter(), "RepoDigests doesn't include tags when using graphdrivers")

	defer setupTest(t)()
	ctx := context.Background()
	client := testEnv.APIClient()

	err := client.ImageTag(ctx, "busybox", "test-remove-by-digest:latest")
	assert.NilError(t, err)

	inspect, _, err := client.ImageInspectWithRaw(ctx, "test-remove-by-digest")
	assert.NilError(t, err)

	id := ""
	for _, ref := range inspect.RepoDigests {
		if strings.Contains(ref, "test-remove-by-digest") {
			id = ref
			break
		}
	}
	assert.Assert(t, id != "")

	t.Logf("removing %s", id)
	_, err = client.ImageRemove(ctx, id, types.ImageRemoveOptions{})
	assert.NilError(t, err)

	inspect, _, err = client.ImageInspectWithRaw(ctx, "busybox")
	assert.Check(t, err, "busybox image got deleted")

	inspect, _, err = client.ImageInspectWithRaw(ctx, "test-remove-by-digest")
	assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
}

nit: remove empty line