From e16c93486d16ac4f3a05f720ee6478b5cef93f10 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 3 Jun 2013 10:19:20 +0000 Subject: [PATCH 1/2] fix Path corruption in 'docker diff' --- changes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes.go b/changes.go index 4c79918887..e50b88758a 100644 --- a/changes.go +++ b/changes.go @@ -65,7 +65,7 @@ func Changes(layers []string, rw string) ([]Change, error) { file := filepath.Base(path) // If there is a whiteout, then the file was removed if strings.HasPrefix(file, ".wh.") { - originalFile := strings.TrimLeft(file, ".wh.") + originalFile := strings.TrimPrefix(file, ".wh.") change.Path = filepath.Join(filepath.Dir(path), originalFile) change.Kind = ChangeDelete } else { From 71b1657e8d22b6dfa0a426f6244c6a3101f66bc4 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 3 Jun 2013 17:02:57 +0000 Subject: [PATCH 2/2] added test --- container_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/container_test.go b/container_test.go index 3ed1763a3e..117f0f3eb3 100644 --- a/container_test.go +++ b/container_test.go @@ -217,6 +217,37 @@ func TestDiff(t *testing.T) { t.Fatalf("/etc/passwd should not be present in the diff after commit.") } } + + // Create a new containere + container3, err := builder.Create( + &Config{ + Image: GetTestImage(runtime).Id, + Cmd: []string{"rm", "/bin/httpd"}, + }, + ) + if err != nil { + t.Fatal(err) + } + defer runtime.Destroy(container3) + + if err := container3.Run(); err != nil { + t.Fatal(err) + } + + // Check the changelog + c, err = container3.Changes() + if err != nil { + t.Fatal(err) + } + success = false + for _, elem := range c { + if elem.Path == "/bin/httpd" && elem.Kind == 2 { + success = true + } + } + if !success { + t.Fatalf("/bin/httpd should be present in the diff after commit.") + } } func TestCommitAutoRun(t *testing.T) {