For the past week (actually, even from a little before that), I’ve been working on duplicating the implementation of %(describe) and its friends from pretty to ref-filter. I haven’t sent them to the mailing list yet because they need to be cleaned up before that. So it’s still in a discussion phase between Christian, Hariom and me.

I faced a few challenges initially after the first (and rough) implementation of describe. One of them was the code that dealt with taking a boolean value for describe:tags=<bool>. I initially wrote it this way

if (strtoul_ui(arg, 10, tagbool) &&
    (tagbool != 0 || tagbool != 1)
	return error;


where strtoul_ui() takes a string arg as input, given the base to which we want to convert it to (here 10), will convert the string number to unsinged int number and put it in tagbool. For example, "14" will give 14. It returns 0 on success and -1 otherwise. This function is kind of a wrapper around the strtoul() function which does not have the property of returning errors and it takes negative inputs.

The above code seems to fail tests on CI as it doesn’t work as it is intended to.

I pushed this work onto my fork (it can be read on branch “describe”) and we had a call that day so I thought we could discuss a bit about it while also discussing about the transition table that I had made the week before.

In the call, I told Hariom that I was not really happy with the code dealing with describe:tags=<bool> and that it was failing the tests. He suggested to use gdb (GNU Debugger) to see what was going wrong.

Now, I have a bit of a history with gdb. I tried to learn to use it a long time ago and it hadn’t really made any sense to me at that time and I gave up, eventually. So I was kind of hestiant of using it but thought why not give it another try.

The power of this tool is huge. The time you take to analyze the code drastically reduces and it just makes making changes to the code so easy. It can also be used to read code, in the sense that we are always able to see what are the functions being called and in what files they are in.

I especially found the post “Using GDB for Debugging in Git” by Siddharth Asthana, to be super helpful.

Coming back to the call, Christian, Hariom and I discussed about the possible changes to the transition table and also discussed a bit about supporting .mailmap options in ref-filter.

Apart from this, I also wrote a small patch to fix a test in t4205-log-pretty-formats.sh as a test regarding the describe:abbrev=... option was not really doing what it should (it can be read on the branch “t4205-describe-fix”).

Work on using ref-filter in pretty

Unfortunately, I haven’t been able to put that much work onto this yet after my previous attempt. I really liked the idea of how Hariom used a function instead to map between the different atoms and the corresponding placeholders. So I think I’ll be doing something on similar lines too instead of the stupid approach I took last time. Maybe refactor some code in it and tweak it to work directly with pretty? I don’t know.

‘til next time,
Kousik