<< Docker: mysql5 | Home | Working with old (Android 4) Eclipse-ADT based Android-Projects >>

old-school patching

I actually can't remember when it was the last time I 'manually' patched a file. But it was quite common in the pre git-days. A patch basically is the same as a git-commit, telling the code where to insert what and where to remove what... As I'm trying to get 'Wood Games 3D' back to life, I first need to get it to compile. Strangely I did not keep my highly altered libgdx-version for some reason only one patch-file. At least I wrote down a date in the file (I guess that meant the day when I created the patch and not the day of its svn-revision). But still a good point to start.

A patch looks like something like this:

Index: src/com/badlogic/gdx/scenes/scene2d/ui/Label.java
===================================================================
--- src/com/badlogic/gdx/scenes/scene2d/ui/Label.java	(revision 2440)
+++ src/com/badlogic/gdx/scenes/scene2d/ui/Label.java	(working copy)
@@ -62,7 +62,7 @@
  *
  */
 public class Label extends Widget {		
-	final LabelStyle style;
+	LabelStyle style;
 	String label;
 	final TextBounds bounds = new TextBounds();
 	final Vector2 textPos = new Vector2();
@@ -139,4 +139,13 @@
 		this.label = text;
 		invalidateHierarchy();
 	}
+	
+	/**
+	 * Sets the {@link LabelStyle} of this Label  

In order to apply it to a folder. You need to 'cd' into it and write

patch -p0 < patch.txt

And then pray. 🙂 In my case I had a line ending mismatch resulting in lots of those errors:

Hunk #1 FAILED at 1 (different line endings).
Hunk #2 FAILED at 48 (different line endings).

And it makes sense. I developed the game on windows but I'm working now on my beloved linux. So, I applied dos2unix on both, the whole folder as well as on the patch:

find . -type f -print0 | xargs -0 dos2unix

(This command calls dos2unix on all files from the current folder upwards)

After this, calling the patch-command (as above) just worked. I call this a miracle 🙂

Refs:

Tags :

Export this post as PDF document  Export this post to PDF document

Social Bookmarks :  Add this post to Slashdot    Add this post to Digg    Add this post to Reddit    Add this post to Delicious    Add this post to Stumble it    Add this post to Google    Add this post to Technorati    Add this post to Bloglines    Add this post to Facebook    Add this post to Furl    Add this post to Windows Live    Add this post to Yahoo!
Home