1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #792 from dotcloud/780-diff-fix

- Runtime: fix Path corruption in 'docker diff'
This commit is contained in:
Guillaume J. Charmes 2013-06-03 10:06:25 -07:00
commit 070923b14f
2 changed files with 32 additions and 1 deletions

View file

@ -65,7 +65,7 @@ func Changes(layers []string, rw string) ([]Change, error) {
file := filepath.Base(path) file := filepath.Base(path)
// If there is a whiteout, then the file was removed // If there is a whiteout, then the file was removed
if strings.HasPrefix(file, ".wh.") { if strings.HasPrefix(file, ".wh.") {
originalFile := strings.TrimLeft(file, ".wh.") originalFile := strings.TrimPrefix(file, ".wh.")
change.Path = filepath.Join(filepath.Dir(path), originalFile) change.Path = filepath.Join(filepath.Dir(path), originalFile)
change.Kind = ChangeDelete change.Kind = ChangeDelete
} else { } else {

View file

@ -217,6 +217,37 @@ func TestDiff(t *testing.T) {
t.Fatalf("/etc/passwd should not be present in the diff after commit.") 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) { func TestCommitAutoRun(t *testing.T) {