The following adds support VCPROMPT_FORMAT_GIT, VCPROMPT_FORMAT_HG, etc. environment variables, which are checked before the generic VCPROMPT_FORMAT one. This allows setting a different format string for different VC systems. (What is appropriate for git may not be for svn, or bzr, or fossil...)
Please consider merging. I'm open to suggestions if you think this should have been done another way.
I don't understand the point of your first patch (options_t) at all. Please provide a longer commit message that explains the problem you are trying to fix, and how your patch fixes the problem.
In the second patch, you're making way too many changes:
- changing context->options to a pointer
- moving parse_format() to common.c
- adding the VCPROMPT_FORMAT_* feature
I suspect this really needs to be 3 separate changesets, so I can evaluate each proposed change on its own merits.
As for the VCPROMPT_FORMAT_* feature: I completely understand what you are trying to achieve, but I'm not sure environment variables are the right way to do it. I think vcprompt would be much better off with config files. For example:
- read local <metadata>/vcprompt (eg. .hg/vcprompt, .svn/vcprompt, etc)
and look for "format = ..."
- then read /.vcprompt and look for "format = ..."
- maaaaybe read /etc/vcprompt and look for "format = ..."
So we would immediately gain a lot of flexibility, although not the precise feature you want. Then your per-VC-system idea could be implemented by adding