Friday, November 23, 2007

What's The "Fuzz" All About?

As part of my day's work, I was trying to adjust a 'fuzz'[2] when I tried to patch [1] manually. Since I have never encountered much of fuzz while patching earlier, I didn't think of a better way of adjusting fuzz than doing manually.

For e.g. while patching you might get a message like:

"Hunk #3 succeeded at 717 with fuzz 2 (offset 7 lines)."

This means that patch had to adjust the location of the change (in this example it needed to move 7 lines from where it expected to make the change to make it fit). The fuzz factor as we see in this example is 2. This factor determines how far from its original line a hunk is allowed to match. The default is two I suppose.

Manually fixing the fuzz is a pain if the patch results in multiple fuzzes. This seems a simpler way to me if you are using 'quilt'[3] to manage patches:

1. quilt new # the patch name can be different from the original patch
2. quilt add file1.c file2.c # files that are changed by this patch
3. patch -p1 < ../file.diff # Apply the original patch using patch command 4. quilt refresh # creates the new patch that is fuzz adjusted This can also be done manually by applying the original patch and recreating the patch without quilt as Jony pointed out. However, if you are working on a patchset it is difficult to manage without patch managing utilities like quilt.
] when I tried to patch [1] manually. Since I have never encountered much of fuzz while patching earlier, I didn't think of a better way of adjusting fuzz than doing manually.

----
NOTE: There seems to be a much simpler way using quilt for adjusting fuzz and handling rejects.
$quilt import
$quilt push

(a) If there are no rejects, quilt applies the changes and doing a
$quilt refresh
ensures that the patch is and fuzz adjusted and updated.

(b) If there are rejects, quilt will not apply the changes by default, you need to force quilt using
$quilt push -f'
to apply changes and it create file.c.rej files which gives details about the rejects.
Now look at the file.c.rej file and manually edit the file to reflect the changes.
$vim file.c.rej file.c
Once done with the changes, do
$quilt refresh
This ensures that the rejects are being handled and the new patch reflects the change. So simple, right?
----

This comes in handy when you need to create patches for multiple versions and you have multiple patches to manage.

Be warned that a 'fuzz' could indicate that the source has changed and the resulting file after patch adjusts may or may not be OK. Double check to be sure.


[1] - A patch is a file containing the delta of changes between two different versions of a source tree. Patches are created with the "diff" program and they are so common in *nix world.

[2] - Whenever patch utility applies a patch that it had to modify a bit to make it fit, it'll tell you about it by saying the patch applied with 'fuzz'. When patch encounters a change that it can't fix up with fuzz it rejects it outright and leaves a file with a .rej extension (a reject file)

[3] - quilt allows to manage a series of patches by keeping track of the changes each patch makes. Patches can be applied, un-applied, refreshed, etc.

Thursday, November 1, 2007

Are you Right or Left brained?

I had thought about this subject a couple of times sometime ago. But, never did any research on this. Shankar's post - Right brain or left brain prompted me to do a little research on this subject. Going by this quiz it seems I use more of my Right brain.

Here is the result:

You Are 40% Left Brained, 60% Right Brained




The left side of your brain controls verbal ability, attention to detail, and reasoning.
Left brained people are good at communication and persuading others.
If you're left brained, you are likely good at math and logic.
Your left brain prefers dogs, reading, and quiet.

The right side of your brain is all about creativity and flexibility.
Daring and intuitive, right brained people see the world in their unique way.
If you're right brained, you likely have a talent for creative writing and art.
Your right brain prefers day dreaming, philosophy, and sports.


And this test too confirms this!