Nov 12, 2015

Git: Single Line History

You get a bug report from a user:
/usr/lib/foo/bar.rb:432:in `doit': undefined method `[]' for nil:NilClass (NoMethodError)
but in bar.rb at the line 432 there are no square brackets. The user must be using an older version of the script. Can we find out which one without asking them?

Git can help. This code will go back in history and show the line how it appeared during the past. It's a history of a single line, kind of like "git blame" but in a different dimension.

FILE=lib/foo/bar.rb
LINE=432
git log --format=format:%H $FILE \
| while read COMMIT_ID; do
    echo -n $COMMIT_ID:$FILE:$LINE:
    git show $COMMIT_ID:$FILE | sed -n "$LINE{p;q}"
  done \
| less 

Have I reinvented the wheel? What is its name?

Nov 10, 2015

Arabic Text Bugfix

Can you spot the difference?

Before:
 After:
If this rings a bell but you can't quite remember why, here's an English version of the screen, and the spoiler for the puzzle is below it:
Spoiler: The line containing "passwd" is clipped at the (left) end, showing only "المحا" instead of "المحلي۔". This bug got popular in the YaST team because the localization testers dutifully reported every instance of a truncated label so the bug accumulated 22 duplicates. It only happened for the Arabic script which made it a bit more challenging to work with, but luckily I know the script and a few words.

Thanks to Max Lin who pointed me to a problem between the Qt UI library and the HarfBuzz text shaping engine, the problem is now fixed.