[Gambas-user] Patch with non text files?
Tobias Boege
taboege at ...626...
Sun Jun 15 15:18:47 CEST 2014
On Sun, 15 Jun 2014, Beno?t Minisini wrote:
> Le 15/06/2014 14:16, Tobias Boege a ?crit :
> > On Sun, 15 Jun 2014, Antonio S??nchez wrote:
> >> Hi, is there any way to create a patch in Gambas in a project where you
> >> have added new non text files as images or sounds?
> >>
> >
> > There is no difference between text and non-text files as far as it concerns
> > the programs "diff" and "patch" which are used by the IDE for patching. It
> > just happens that the IDE tests for the patch to be a text file. We have to
> > blame Benoit for that behaviour ;-)
> >
> > $ svn blame FPatch.class | grep -B1 -A2 look
> > 5835 gambas If Not Project.IsTextFile(Dialog.Path) Then
> > 5835 gambas Message.Warning(("That file does not look like a patch file!"))
> > 5835 gambas Return
> > 5835 gambas Endif
> >
> > I'll fix it in one of the next revisions.
> >
> > Benoit, if there is a reason you added this code, please tell me and feel
> > free to revert my commit. However, the commit message for #5835 doesn't say
> > anything about it.
> >
> > Regards,
> > Tobi
> >
>
> I think I added that just to prevent the user to choose a file by
> mistake. I don't know what "patch" will do with a random file, and so I
> wanted to prevent it from transforming the project into garbage.
>
> So if you have a way to detect if a file is actually a patch or not, I
> suggest you create a Project.IsPatchFile() and use it in the test.
>
Done. It looks for the first four bytes to be "diff" because apparently GNU
diff outputs the command line it was invoked with into the patch file. I
have looked through the diff manual but haven't found any mention of this
behaviour. They just list it in example files. I'm tempted to take the
presence of this header line as granted until someone reports this as a bug
because the line is missing on their system... In worst case, the patch is
just rejected by the IDE, so no danger here.
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list