Git on Windows: “You have some suspicious patch lines”

Update 2008-04-24: as commenter Jakub Narebski correctly points out, it should be better to use core.autocrlf and crlf attribute for resolving this issue, but I have had no chance to test this up to now. The solution below is still valid, but more of the sort of an ugly hack.
Update 2008-06-11: I have stopped using this solution and only use “git-config core.autocrlf true” and “git-config core.safecrlf true” any more. It works reliably and is exactly what I need and not such an ugly hack.
Update 2008-06-22: Well, of course you can still get “You have some suspicious patch lines” if you follow the core.autocrlf approach… but this time it really means you have trailing whitespace, not just line-breaks. If you really don’t care about trailing white-space at all, my initial solution is still valid, as it simply disables this check.

If you are using Git under Windows using cygwin, and you got through the initial problems, you will soon realize that Git likes to fail with “You have some suspicious patch lines” when committing.

The cause for this problem is the carriage-return/line-feed problem of Git under Windows/cygwin: The patches contain a trailing line-feed if you edited them with a Windows editor and not strictly inside cygwin. This will trigger the pre-commit hook to fail on patches where the last line of a file has been changed.

To solve the problem, you need to edit .git/hooks/pre-commit and comment out the following lines:

if (/\s$/) {
bad_line("trailing whitespace", $_);
}

Now committing should work.

DWR with “Reverse AJAX”

In a previous article I already mentioned Direct Web Remoting (DWR), the best AJAX-library I encountered up to now. I just had the time to re-discover it, as I sought something to get back to my Java skills. This library really keeps one promise: it really starts making fun to develop web-applications with AJAX. A short summary: DWR provides a very easy means for calling server-side methods which are hosted in a Java Servlet Container like Tomcat or Jetty. It masks the communication effort by providing client-side abstraction to the method calls of exported Java methods, so remote calls look local to the developer.

The new version 2.0 (release-candidate) introduces a new concept, which they call “reverse AJAX“. Reverse AJAX allows the server to asynchronously send data to its clients. It works by either polling, persistent connection or additional information on your next AJAX call. It means, that the server at any time can push data to the client, without the client’s request. In “persistent connection” this works almost “real-time”, while polling takes at least a poll-interval to notice the new information and additionally increases load on the server.

This feature allows highly interactive applications where new information can be published right away, in best case without noticeable delay. Developing a simple chat-application becomes the matter of just a few lines of server-side code.

For an example of what you can easily do now, look at this example (fake) stock ticker, which updates the data on the client without the client being required to poll for changes. Also note the simple, yet cool, inclusion of script.aculo.us effects during the update. (Hint: you need to move the mouse over the table for the application to start.)

The downside is, the feature is still in an early stage of development, it still has some problems. On my Gentoo Linux box, I can reproducibly increase my CPU load to 100% by duplicating a tab with an open persistent connection in Opera. In Firefox, duplicating the tab leads to normal AJAX calls to no longer function with about 50% chance. If Firefox enters this mode, it will queue up XMLHttpRequest causing a “normal” call to be queued behind the persistent call which will be kept open for around 60 seconds if no data is pushed from the server or even longer, if there is data. This of course makes it almost unusable at the moment, unless you can be sure, users won’t hit your site twice within the same session and/or are not using tab-duplication.

I’m really looking forward to this feature becoming stable, this is so cool and you can do so much awesome stuff with it. Thanks to all developers for their great work!

Microsft Vista x64 Mandatory Driver Signing (Update)

In an earlier article I made a mistake. I told that Microsoft Vista x64 will only work with signed drivers and assumed (wrongly) that this means every driver has to go through the WHQL program for getting a signature of Microsoft’s driver quality program, which would be a quite costly process.

I now discovered an older (German) blog-article by Daniel Melanchton, in which he points out that only a digital signature with a certificate from a trusted CA is required. It seems that it is not required to go through the WHQL process, you just need a certificate. The trusted CAs seem to comprise most root authorities also accepted by Internet Explorer by default, so driver developers are not dependent on Microsoft for getting a signature.

While this still might be a problem for some established Open Source drivers, it is still an affordable and in my opinion useful approach, as digital signatures at least in most ways make the originator of a software known. Of course, this does not tell anything about the quality of the software nor if it is benign or malware. Microsoft’s approach seems to be that without force hardly any publisher will sign their drivers. Unfortunately, they might be true…

Update 2007-02-21: It seems that I still missed one point. The “Secure Media Path” depends on a valid Microsoft signature. Without this signature, drivers are supposed to disable the “Secure Media Path”, so that high-quality (e.g. HDTV, Dolby 7.1) multimedia content is rendered to lower quality.

DWR – Easy AJAX for Java

DWR is a really fantastic library for Java: it allows to write JavaScript applications in web browsers that will directly and almost transparently call Java-methods of objects that live in the Java-Servlet-Container (e.g. Tomcat) as part of the web-application.

Continue reading “DWR – Easy AJAX for Java”

VisualStudio.NET: Text-Editor Guide at 80

Guiding lines in VS.NET 2005It is still considered good style to keep code-lines within a certain bound (e.g. 80 characters). IDEs like Eclipse offer to display a red guiding line at the chosen offset to help developers keep within this bound.

By modifying the registry a similar guide can be enabled for Visual Studio 2003 / 2005. Add a string value Guides to the key (VS.NET 2005, VS 2003 has version 7.1)

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor.

Set the value to

RGB(128,0,0) 80

To have multiple guides (like in the screenshot), add the additional columns space delimited, e.g.

RGB(128,0,0) 80 100

Ackn.: This information has been provided by Hannes Pavelka in Microsoft’s newsgroup microsoft.public.dotnet.languages.csharp, Message-ID: <e1jag7$qk7$02$1@news.t-online.com> (Article in Google Groups):

Microsoft: Shared Source Common Language Infrastructure 2.0 Release

Just came accross this: seems like Microsoft has released some parts of the CLI under one of their “free” licenses.

Download details: Shared Source Common Language Infrastructure 2.0 Release

Update 2006/03/26: As I just noticed at Mono’s “Contributing” page, they won’t accept any contributions from people who had a look at the download.

Microsoft: Only signed drivers for Windows Vista x64

According to this Microsoft page and this Golem-Article (German), Microsoft is going to make driver signatures from Microsoft mandatory for any driver running in kernel space in Windows Vista x64. They claim security reason for this.While (faulty) drivers definitely can lead to serious (security) problems under Windows, they sometimes fulfill cruitial parts, especially in windows file system monitoring, for which there are many legitimate reasons. Having to go through the WHQL for every driver (and every minor patch) seems a little costly and time consuming to me…

Well, after all, for me it seems to be three things:

  • Additional money through additional drivers going through WHQL,
  • Anti Open-Source projects,
  • Building up the infrastructure for an (almost unbreakable) Digital Rights Management system.

Update 2007-01-23: I have to revise most points of this, as I now learned something new about it. Vista x64 will accept digitally signed drivers, but they do not necessarily be signed by Microsoft. Read more in my updated article.

IKVM.NET: Interaction between C# and Java

A nice project, everyone coming from Java and migrating to C#:
IKVM.NET Home Page

It is a JVM implemented in .NET, contains a .NET implementation of a lot classes from the Java class libraries (JDK), compliance of 1.4 almost complete and contains tools for interop between Java and .NET.