Skip to content

Porting across Option Modernization

Matthew Woehlke edited this page Dec 26, 2018 · 2 revisions

#1852 (and its predecessor #1945) made significant changes to how uncrustify registers and uses options. Long lived forks, or option-changing PR's that were in flight when #1852 landed, will need to carefully address the resulting conflicts. This brief guide is intended to help with that process.

  1. First, if possible, rebase your changes onto 36f0078b. This should minimize the conflicts you have to deal with.

  2. Compare your version of src/options.cpp to the version at 36f0078b. Save this diff somewhere.

    $ git diff 36f0078b HEAD -- src/options.cpp > options.diff
  3. Run sed -r 's/cpd.settings\[UO_(\w+)\]\.\w+/options::\1()/g' on all of your source files. This will adapt the use of options in your branch to match the new mechanism, which will both reduce the number of changes that need to be made by hand, and also reduce merge conflicts. Commit the result.

  4. Merge master with your branch. Discard changes to src/options.cpp and src/options.h (git checkout HEAD -- src/options.*). Don't commit the conflicting merge yet.

    • You may want to merge 8c69fef3 first, then follow the rest of the steps, and only then merge master. This may break the set of conflicts into smaller, more manageable pieces.
  5. Manually apply your changes from (2) to src/options.h, following updated format.

    • For example, if your diff looks like:

       unc_add_option("sp_after_type", UO_sp_after_type, AT_IARF,
                      "Add or remove space between type and word. Default=Force.");
      +unc_add_option("sp_after_decltype", UO_sp_after_decltype, AT_IARF,
      +               "Add or remove space between 'decltype(...)' and word.");
       unc_add_option("sp_before_template_paren", UO_sp_before_template_paren, AT_IARF,
                      "Add or remove space before the paren in the D constructs 'template Foo(' and 'class Foo('.");

      You would find sp_after_type in src/options.h and, just below it, add this:

      // Add or remove space between 'decltype(...)' and word.
      extern option<iarf_e>
      sp_after_decltype;

      (Make sure to include the blank line before and after!)

  6. Build and test the result. Commit when ready.

Clone this wiki locally