Subject: Re: suggestions for local configs?

From: Johannes Sixt <[email-masked]>
Date: Fri, 06 Nov 2009 08:21:39 +0100

Tim Rupp schrieb:
> I have a piece of software that has default and local configuration
> files. The default files ship with the tarball. The local files are
> copied over from the default folder during installation and can be
> modified for a particular install.

This is how *I* would organize it, but it is a bit overengineered if the
changes needed in the configuration are only minimal:

  ---o--o--X1--o--o--X2--o          master (aka upstream)
      \     \             \
       R-----M1------------M3       rename
        \     \             \
         Y-----M2------------M4     production

We need two branches in addition to master, which tracks upstream version.

1. The first branch *renames* the example configuration to the effective
configuration:

   git mv foo.conf.example foo.conf
   # commit R
   git commit -m "Use the example configuration"

It is important that *no change* is made to the configuration file, and it
furthermore assumes that the production configuration (foo.conf) does not
exist [*].

The point of this commit is that git can determine that the file was
renamed with 100% similarity.

2. The second branch is actually where the customization happens, this is
commit Y:

   git checkout production
   edit foo.conf
   # commit Y
   git commit -m "configuration changes needed in production"

Assume, upstream made changes to the configuration (commit X1). These
changes are merged in the following way:

1.  git checkout rename && git merge master

This creates M1. git detects that on our side the file was renamed, and
merges the upstream changes into the renamed file. Since we didn't modify
the file in R, there are no conflicts.

2.  git checkout production && git merge rename

This creates M2. This is a regular merge that integrates upstream changes
with the local changes made in Y, possibly with conflicts.

You repeat the procedure when upstream makes more changes to the example
configuration in X2. This time, git merge again detects that the file was
renamed with 100% similarity, and things work just like with M1 and M2.

[*] If there is a configuration file in addition to the example
configuration, another branch is needed that removes it.

-- Hannes