Jump to content

Plist comparison


Slice
 Share

19 posts in this topic

Recommended Posts

Still nobody created a plist editor able to compare two plists with mixed lines. Compare key by key, not line by line.

For example Meld

image.png

They looks to be different? No. They are different sorted.

 

Is there any programmer?

 

PS. The solution is

https://www.insanelymac.com/forum/topic/352734-plist-comparison/?do=findComment&comment=2789715

 

  • Like 5
Link to comment
Share on other sites

4 minutes ago, 5T33Z0 said:

@Slice I don't know if that is what you are looking for but there's a plugin for Visual Studio Code called Diff

No, Visual Studio has no relation to plist format liked by Apple. So this is just one more text compare.

  • Like 2
Link to comment
Share on other sites

13 hours ago, Slice said:

Still nobody created a plist editor able to compare two plists with mixed lines. Compare key by key, not line by line.

For example Meld

image.png

They looks to be different? No. They are different sorted.

 

Is there any programmer?

 

In BBEdit.app, I can find and replace to put all the values on the same line as their key.

find:
(</key>)\s+(<(string|integer|true/|false/|data))
replace:
\1 \2

find:
(<data>)\s+([^<]*?)\s+(</data>)
replace:
\1\2\3

You could make a perl script to do the same.

 

After doing the find and replace, the plist remains as a valid plist file which OpenCore can still parse. I'm not sure about the plist parser in Clover. I remember it had some bugs and couldn't handle xml comments

<!--
xml comment which you can use to describe important fields in the config.plist
-->

 

As for sorting, doesn't plutil or PListBuddy resort the dictionary keys for you?

 

  • Like 1
Link to comment
Share on other sites

18 hours ago, Slice said:

Still nobody created a plist editor able to compare two plists with mixed lines. Compare key by key, not line by line.

For example Meld

 

They looks to be different? No. They are different sorted.

 

Is there any programmer?

 

Hi @Slice Have you seen Yousseb on GitHub. There is a fork of Meld packaged and bundled for OSX. This app is mentioned on official Meld site.

Link to comment
Share on other sites

7 hours ago, joevt said:

 

In BBEdit.app, I can find and replace to put all the values on the same line as their key.

find:
(</key>)\s+(<(string|integer|true/|false/|data))
replace:
\1 \2

find:
(<data>)\s+([^<]*?)\s+(</data>)
replace:
\1\2\3

You could make a perl script to do the same.

 

After doing the find and replace, the plist remains as a valid plist file which OpenCore can still parse. I'm not sure about the plist parser in Clover. I remember it had some bugs and couldn't handle xml comments

<!--
xml comment which you can use to describe important fields in the config.plist
-->

 

As for sorting, doesn't plutil or PListBuddy resort the dictionary keys for you?

 

I can do this in C++ just have a few time for the work.

I don't know how to use plutil or PListBuddy. I saw PlistEditorPro some version which always sorted plist after save. And I know application PlistEDPlus by ic005K which can sort one section, not enough. I asked him about comparing but no.

Link to comment
Share on other sites

On 7/22/2022 at 6:31 AM, Slice said:

I can do this in C++ just have a few time for the work.

I don't know how to use plutil or PListBuddy. I saw PlistEditorPro some version which always sorted plist after save. And I know application PlistEDPlus by ic005K which can sort one section, not enough. I asked him about comparing but no.

plutil and PListBuddy both have man pages. Right click the command in Terminal.app and select "Open man Page".

 

Using plutil by itself, you can create a file, and add keys. Then you can manually scramble the keys. Then you can use plutil to sort the keys.

plutil -create xml1 /tmp/myplist.plist
plutil -insert "a" -dictionary /tmp/myplist.plist
plutil -insert "a.a" -integer 123 /tmp/myplist.plist
plutil -insert "a.z" -integer 123 /tmp/myplist.plist
plutil -insert "a.m" -integer 123 /tmp/myplist.plist
plutil -insert "b" -integer 123 /tmp/myplist.plist
plutil -insert "z" -array /tmp/myplist.plist
plutil -insert "z.0" -integer 789 /tmp/myplist.plist
plutil -insert "z.1" -integer 456 /tmp/myplist.plist
plutil -insert "z" -integer 333 -append /tmp/myplist.plist
plutil -insert "z" -integer 111 -append /tmp/myplist.plist
plutil -insert "x" -integer 123 /tmp/myplist.plist
plutil -insert "m" -integer 123 /tmp/myplist.plist

bbedit /tmp/myplist.plist # scrample the keys manually

cp /tmp/myplist.plist /tmp/myplist_sorted.plist # copy the file
plutil -convert xml1 /tmp/myplist_sorted.plist # sort the keys

 

Notes:

- plutil remove xml comments <!--  --> (which makes sense since there's no way to determine what key/value a comment belongs to unless it were placed between a key and value but even then plutil strips it because comments contain no data)

- plutil does not sort arrays (which makes sense since the order in an array matters but the order in a dictionary doesn't matter)

 

Regarding the regular expression idea, I would use a small perl script.

perl -0777 -pE '
	s!(</key>)\s+(<(string|integer|true/|false/|data))!$1 $2!g;
	s!(<data>)\s+([^<]*?)\s+(</data>)!$1$2$3!g;
' \
/tmp/myplist_sorted.plist > /tmp/myplist_sorted_for_compare.plist

 

plutil can check that the format of the result is still correct for a plist.

plutil /private/tmp/myplist_sorted_for_compare.plist
/private/tmp/myplist_sorted_for_compare.plist: OK

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

@joevt Big thanks!

The command

plutil -convert xml1 config.plist 

is that I dreamed

I converted my config.plist and config-sample.plist and really see the difference.

sergey@iMac PCompare % plutil -convert xml1 configImacPro.plist 
sergey@iMac PCompare % plutil -convert xml1 config-sample.plist 

The application is DiffFork.app. It is free(?), worked in Ventura as well.

Screenshot 2022-07-25 at 18.32.14.png

Link to comment
Share on other sites

Check after sorting

sergey@iMac PCompare % /Users/sergey/src/CloverBootloader/CloverPackage/CloverConfigPlistValidator/ccpv /Users/sergey/Desktop/PCompare/config-sample.plist 
Your plist looks good. Well done!
sergey@iMac PCompare % 

 

Link to comment
Share on other sites

14 minutes ago, Cyberdevs said:

@Slice

I'm usually using BeyondCompare when I want to compare config files. The app clearly does more than that so I thought you might wanna check it out.

There are many text compare applications. Most of them are not free. This one is free for 30 days.

And comparison is not very good

 

Screenshot 2022-07-25 at 20.01.36.png

Link to comment
Share on other sites

10 hours ago, Slice said:

@joevt Big thanks!

The command

plutil -convert xml1 config.plist 

is that I dreamed

I converted my config.plist and config-sample.plist and really see the difference.

sergey@iMac PCompare % plutil -convert xml1 configImacPro.plist 
sergey@iMac PCompare % plutil -convert xml1 config-sample.plist 

The application is DiffFork.app. It is free(?), worked in Ventura as well.

Screenshot 2022-07-25 at 18.32.14.png

It's a pity this is not full solution because commented out lines float up in the dictionary whle it will be better to keep original order ignoring # sign.

Link to comment
Share on other sites

8 hours ago, Slice said:

It's a pity this is not full solution because commented out lines float up in the dictionary whle it will be better to keep original order ignoring # sign.

Can't the # sign be put at the end of the name? The point is to make the name not the same as a valid name, so any change should work.

 

Link to comment
Share on other sites

2 hours ago, joevt said:

Can't the # sign be put at the end of the name? The point is to make the name not the same as a valid name, so any change should work.

 

Yes, I also think about this. Some manual work required for the best future...

There is more logical to put sign "?" at the end of the key meaning "Ask Clover to choose a default  calculated value".

 

@ CloverConfigurator Maintainers. It will be good if you'll implement the sign "?" to be written into a key value with the same meaning as I said.

Link to comment
Share on other sites

 Share

×
×
  • Create New...