Monday, November 14, 2011

Devoxx day 1

Well, everyone seem to be posting about day one on Devoxx, so why not join? We've started with Scala. After a usual bullshit about Java convoluted code guys switched to a standard Scala tutorial. Informative, but extremely boring. Second part, Scala as Agile enabler was enthusiastic, but even more loaded with bullshit. We've found out that Scala guys are clever and nice talking to. Java developers are apparently morons as I an, so being a moron, I've just checked a quickie about the "no accessors" claim in Scala. Shared mutable state, anyone? Here's a public variable for you as default visibility. Well, I do admit Scala is a decent language, but the impression wasn't nice; OTOH, Ruby and Groovy guys have exactly the same problem: they blame some made-up Java code in made-up situations, never caring that noone would write this crap. Moreover, if you don't care enough to encapsulate your state, you can easily write in Java something much more concise: it's just that it would be way beyond any acceptable norm. On the second session, we've split: Olga went to HTML5 session, and I've joined the @jclouds guys. @jclouds is basically a uniform wrapper over all the cloud storage APIs: S2, EBS, ninefold, you-name-it. Not particularly fluent API, but it works — and, to be honest, neither are any of the cloud APIs. So all in all a great work; will use it when I need it. Other than these two sessions, there was a GC session by not Kirk Pepperdine, but Ben Evans. Given that he was only notified in 2h before, it was a great talk. Well, it was an ok talk by Kirk's slides, but a great topic to think about. I wish I'd listened it 2 years ago, just before I needed to tune my server. As for the evening, sad news. Kulminator is closed; Het Elfde Gebod is renamed to Het Kafedraal and doesn't serve snacks after 18:00 anymore. Good news are, Kulminator will be back by 16th, and there's a new (new?) bar called Bier Centraal next door (and apparently under the same management as) Kelly's Irish Pub. Great choice of Belgian beers, good food. What else a developer needs to be happy? See you tomorrow at Devoxx!

Tuesday, August 23, 2011

git mv and case-insensitive file system

Many of you Java programmers have seem a problem with git or SVN: if you made a typo in class name, e.g.
test.java instead of Test.java, you cannot rename a file:


alf-imac:case alf$ echo "Test file" > test.java
alf-imac:case alf$ git add test.java
alf-imac:case alf$ git commit -m "Oh, what a stupid mistake"
[master (root-commit) 8ffb354] Oh, what a stupid mistake
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 test.java
alf-imac:case alf$ git mv test.java Test.java
fatal: destination exists, source=test.java, destination=Test.java


As you can see, git does not want to rename test.java to Test.java since there's no difference. When you're using
an IDE, the problem gets worse: you can end up changing the code and even committing it, just to find out a bit
later it's not running on your Linux server any more.


Anyway, how do we fix it? The trick is plain and simple, we use an intermediate name:



alf-imac:case alf$ git mv test.java test1.java
alf-imac:case alf$ git commit -m "Step 1"
[master c6f8021] Step 1
1 files changed, 0 insertions(+), 0 deletions(-)
rename test.java => test1.java (100%)
alf-imac:case alf$ git mv test1.java Test.java
alf-imac:case alf$ git commit -m "Step 2"
[master d7ca2ef] Step 2
1 files changed, 0 insertions(+), 0 deletions(-)
rename test1.java => Test.java (100%)


Unfortunately, it leaves us with an ugly history, so we need to adjust it:




alf-imac:case alf$ git log
commit d7ca2ef313d9b273baffcb6c15b3a96310659767
Author: Alexey Filippov <alf@*****>
Date: Tue Aug 23 12:02:18 2011 +0100


Step 2


commit c6f80218d69c5019db5f2b16fcf652e1a0445cb4
Author: Alexey Filippov <alf@*****>
Date: Tue Aug 23 12:01:49 2011 +0100


Step 1


commit 8ffb3542567057978cb7932fddaa38c2a2fbb59c
Author: Alexey Filippov <alf@*****>
Date: Tue Aug 23 11:55:21 2011 +0100


Oh, what a stupid mistake
alf-imac:case alf$ git rebase -i 8ffb3542567057978cb7932fddaa38c2a2fbb59c
[detached HEAD bb3f659] Renaming the file
1 files changed, 0 insertions(+), 0 deletions(-)
rename test.java => Test.java (100%)
Successfully rebased and updated refs/heads/master.

alf-imac:case alf$ git log
commit bb3f659989d43851e1600c93a922c59b8c7c64d3
Author: Alexey Filippov <alf@*****>
Date: Tue Aug 23 12:01:49 2011 +0100


Renaming the file


commit 8ffb3542567057978cb7932fddaa38c2a2fbb59c
Author: Alexey Filippov <alf@*****>
Date: Tue Aug 23 11:55:21 2011 +0100


Oh, what a stupid mistake

Obviously, the same effect could be achieved using --amend in the second commit.


PS. As I always suspected, the same approach is explained on StackOverflow in two lines. Silly me.