@@ -703,6 +703,14 @@ func (d *differ) loadLayer(ctx context.Context, node *EventTreeNode, inputIdx in
703703 hdr .Name = strings .TrimPrefix (hdr .Name , "./" )
704704 hdr .Linkname = strings .TrimPrefix (hdr .Linkname , "/" )
705705 hdr .Linkname = strings .TrimPrefix (hdr .Linkname , "./" )
706+ if path , ok := hdr .PAXRecords ["path" ]; ok {
707+ path = strings .TrimPrefix (path , "/" )
708+ hdr .PAXRecords ["path" ] = strings .TrimPrefix (path , "./" )
709+ }
710+ if path , ok := hdr .PAXRecords ["linkpath" ]; ok {
711+ path = strings .TrimPrefix (path , "/" )
712+ hdr .PAXRecords ["linkpath" ] = strings .TrimPrefix (path , "./" )
713+ }
706714 }
707715 if os .Geteuid () != 0 && runtime .GOOS == "linux" {
708716 //nolint:staticcheck // SA1019: hdr.Xattrs has been deprecated since Go 1.10: Use PAXRecords instead.
@@ -868,10 +876,19 @@ func (d *differ) diffTarEntries(ctx context.Context, node *EventTreeNode, in [2]
868876
869877func (d * differ ) diffTarEntry (ctx context.Context , node * EventTreeNode , in [2 ]EventInput ) (dirsToBeRemovedIfEmpty []string , retErr error ) {
870878 var negligibleTarFields []string
879+ negligiblePAXFields := map [string ]struct {}{}
871880 if d .o .IgnoreFileTimestamps {
872- negligibleTarFields = append (negligibleTarFields , "ModTime" , "AccessTime" , "ChangeTime" )
881+ negligibleTarFields = append (negligibleTarFields , "ModTime" , "AccessTime" , "ChangeTime" , "PAXRecords" )
882+ negligiblePAXFields ["mtime" ] = struct {}{}
883+ negligiblePAXFields ["atime" ] = struct {}{}
884+ negligiblePAXFields ["ctime" ] = struct {}{}
885+ }
886+ discardFunc := func (k , _ string ) bool {
887+ _ , ok := negligiblePAXFields [k ]
888+ return ok
873889 }
874890 cmpOpts := []cmp.Option {cmpopts .IgnoreUnexported (TarEntry {}), cmpopts .IgnoreFields (tar.Header {}, negligibleTarFields ... )}
891+ paxOpts := []cmp.Option {cmpopts .IgnoreMapEntries (discardFunc )}
875892 ent0 , ent1 := * in [0 ].TarEntry , * in [1 ].TarEntry
876893 if d .o .IgnoreFileOrder {
877894 // cmpopts.IgnoreFields cannot be used for int
@@ -884,6 +901,14 @@ func (d *differ) diffTarEntry(ctx context.Context, node *EventTreeNode, in [2]Ev
884901 ent0 .Header .Mode &= 0x0FFF
885902 ent1 .Header .Mode &= 0x0FFF
886903 }
904+ pax0 := ent0 .Header .PAXRecords
905+ if pax0 == nil {
906+ pax0 = map [string ]string {}
907+ }
908+ pax1 := ent1 .Header .PAXRecords
909+ if pax1 == nil {
910+ pax1 = map [string ]string {}
911+ }
887912 var errs []error
888913 if diff := cmp .Diff (ent0 , ent1 , cmpOpts ... ); diff != "" {
889914 ev := Event {
@@ -895,6 +920,16 @@ func (d *differ) diffTarEntry(ctx context.Context, node *EventTreeNode, in [2]Ev
895920 if err := d .raiseEvent (ctx , node , ev , "tarentry" ); err != nil {
896921 errs = append (errs , err )
897922 }
923+ } else if diff := cmp .Diff (pax0 , pax1 , paxOpts ... ); diff != "" {
924+ ev := Event {
925+ Type : EventTypeTarEntryMismatch ,
926+ Inputs : in ,
927+ Diff : diff ,
928+ Note : fmt .Sprintf ("name %q" , ent0 .Header .Name ),
929+ }
930+ if err := d .raiseEvent (ctx , node , ev , "tarentry" ); err != nil {
931+ errs = append (errs , err )
932+ }
898933 } else {
899934 // entry matches, so no need to retain the extracted files and dirs
900935 // (but dirs cannot be removed until processing all the tar entries in the layer)
0 commit comments