From 73a239c4ee9cccdcd9cdd76db3d5816ae870ef9b Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 1/104] deprecate make_source and add option to disable auto_packing


---

diff --git a/rpkg b/rpkg
index a8b64b5..454a656 100755
--- a/rpkg
+++ b/rpkg
@@ -16,7 +16,7 @@ import pyrpkg.utils
 import os
 import sys
 import logging
-from six.moves import configparser
+import configparser
 import argparse
 from rpkglib.cli import rpkgClient
 from os.path import expanduser
diff --git a/rpkg.conf b/rpkg.conf
index 85717c4..803f46d 100644
--- a/rpkg.conf
+++ b/rpkg.conf
@@ -1,3 +1,9 @@
+[rpkg]
+preprocessor = True
+
+# auto-packing is deprecated
+auto_pack = False
+
 [distgit]
 lookaside = https://src.fedoraproject.org/repo/pkgs/%(ns1)s/%(pkg)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s
 lookaside_cgi = https://src.fedoraproject.org/repo/pkgs/upload.cgi
diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 68cba40..e8abc23 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -209,6 +209,8 @@ class Commands(pyrpkg.Commands):
 
     def make_source(self, destdir=None):
         """
+        @deprecated
+
         Create source mentioned according to Source0 spec
         directive from an unpacked repository. Does nothing
         on a packed repo.
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 7be79fb..9921f62 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -1,6 +1,9 @@
+from __future__ import print_function
+
 import argparse
 import os
 import rpm
+import sys
 
 from pyrpkg.cli import cliClient
 from pyrpkg import utils
@@ -155,6 +158,7 @@ class rpkgClient(cliClient):
         super(rpkgClient, self).tag()
 
     def make_source(self):
+        print('This function is deprecated and will be removed in a future release.', file=sys.stderr)
         self.cmd.sources()
         self.cmd.set_specloc(self.args.spec)
         self.cmd.make_source(self.args.outdir)
@@ -162,10 +166,12 @@ class rpkgClient(cliClient):
     def srpm(self):
         self.cmd.sources()
         self.cmd.set_specloc(self.args.spec)
-        try:
-            self.cmd.make_source()
-        except NotUnpackedException:
-            pass
+        if self.config['rpkg'].getboolean('auto_pack', False):
+            print('Auto-packing is deprecated and will be removed in a future release.', file=sys.stderr)
+            try:
+                self.cmd.make_source()
+            except NotUnpackedException:
+                pass
         self.cmd.srpm(self.args.outdir)
 
     def copr_build(self):
@@ -173,6 +179,7 @@ class rpkgClient(cliClient):
         super(rpkgClient, self).copr_build()
 
     def is_packed(self):
+        print('This function is deprecated and will be removed in a future release.', file=sys.stderr)
         self.cmd.set_specloc(self.args.spec)
         ts = rpm.ts()
         try:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 2929231..eee6797 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -5,8 +5,8 @@ import base
 import os
 import glob
 import tempfile
+import configparser
 
-from six.moves import configparser
 from rpkglib.cli import rpkgClient
 from rpkglib.exceptions import NotUnpackedException
 
@@ -20,6 +20,9 @@ else:
     from mock import MagicMock
 
 RPKG_CONFIG = """
+[rpkg]
+auto_pack = True
+
 [distgit]
 lookaside = http://localhost/repo/pkgs/%(ns1)s/%(pkg)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s
 lookaside_cgi = https://localhost/repo/pkgs/upload.cgi

From ce0f5f6fa0dc6146f4bdd999aa54b59bd8de30b8 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 2/104] added spec file preprocessing


---

diff --git a/rpkg b/rpkg
index 454a656..c33d92c 100755
--- a/rpkg
+++ b/rpkg
@@ -67,7 +67,7 @@ else:
 
 # Run the necessary command
 try:
-    sys.exit(client.args.command())
+    client.args.command()
 except KeyboardInterrupt:
     pass
 except Exception as e:
diff --git a/rpkg-client.spec b/rpkg-client.spec
index 949675e..04705ed 100644
--- a/rpkg-client.spec
+++ b/rpkg-client.spec
@@ -28,6 +28,7 @@ BuildRequires: python2-setuptools
 BuildRequires: python2-devel
 BuildRequires: python2-rpkg
 BuildRequires: python2-mock
+BuildRequires: python2-pyparsing
 
 %if 0%{?rhel}
 BuildRequires: pytest
@@ -36,6 +37,7 @@ BuildRequires: python2-pytest
 %endif
 
 Requires: python2-rpkg
+Requires: python2-pyparsing
 
 %description -n rpkg
 This is an RPM packaging utility based on python-rpkg library.
diff --git a/rpkg.conf b/rpkg.conf
index 803f46d..899c66e 100644
--- a/rpkg.conf
+++ b/rpkg.conf
@@ -1,7 +1,6 @@
 [rpkg]
-preprocessor = True
-
-# auto-packing is deprecated
+preprocess_spec = True
+# auto-packing is deprecated:
 auto_pack = False
 
 [distgit]
diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index e8abc23..8392153 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -9,6 +9,7 @@ from pyrpkg.errors import rpkgError
 from pyrpkg.sources import SourcesFile
 
 from rpkglib.lookaside import CGILookasideCache
+from rpkglib.preproc import preprocess
 from rpkglib import utils
 
 from exceptions import NotUnpackedException, RpmSpecParseException, NoSourceZeroException
@@ -16,6 +17,7 @@ from exceptions import NotUnpackedException, RpmSpecParseException, NoSourceZero
 class Commands(pyrpkg.Commands):
     def __init__(self, *args, **kwargs):
         """Init the object and some configuration details."""
+        self.outdir = kwargs.pop("outdir")
         super(Commands, self).__init__(*args, **kwargs)
         self.source_entry_type = 'bsd'
         self.distgit_namespaced = True
@@ -32,18 +34,12 @@ class Commands(pyrpkg.Commands):
         self.load_spec()
 
     def load_rpmdefines(self):
-        """Populate rpmdefines"""
-        if os.path.isdir(self._specloc):
-            specdir = self._specloc
-        else:
-            specdir = os.path.dirname(self._specloc)
-
         self._rpmdefines = [
-            "--define '_sourcedir %s'" % self.path,
-            "--define '_specdir %s'" % specdir,
-            "--define '_builddir %s'" % self.path,
-            "--define '_srcrpmdir %s'" % self.path,
-            "--define '_rpmdir %s'" % self.path,
+            "--define '_sourcedir %s'" % self.outdir,
+            "--define '_specdir %s'" % self.outdir,
+            "--define '_builddir %s'" % self.outdir,
+            "--define '_srcrpmdir %s'" % self.outdir,
+            "--define '_rpmdir %s'" % self.outdir,
         ]
 
     def load_spec(self):
@@ -52,10 +48,13 @@ class Commands(pyrpkg.Commands):
             self._spec = os.path.abspath(self._specloc)
             return
 
-        # Get a list of files in the path we're looking at
         files = os.listdir(self._specloc)
 
-        # Search the files for the first one that ends with ".spec"
+        for f in files:
+            if f.endswith('.spec.rpkg') and not f.startswith('.'):
+                self._spec = os.path.abspath(os.path.join(self._specloc, f))
+                return
+
         for f in files:
             if f.endswith('.spec') and not f.startswith('.'):
                 self._spec = os.path.abspath(os.path.join(self._specloc, f))
@@ -63,7 +62,6 @@ class Commands(pyrpkg.Commands):
 
         raise rpkgError('No spec file found.')
 
-
     @cached_property
     def lookasidecache(self):
         return CGILookasideCache(
@@ -105,35 +103,30 @@ class Commands(pyrpkg.Commands):
         raise rpkgError('Could not find current module name.'
                         ' Use --module-name.')
 
-    def sources(self, outdir=None):
+    def sources(self):
         """Download source files"""
         if not os.path.exists(self.sources_filename):
             return
 
-        # Default to putting the files where the module is
-        if not outdir:
-            outdir = self.path
-
         sourcesf = SourcesFile(self.sources_filename, self.source_entry_type)
 
         for entry in sourcesf.entries:
-            outfile = os.path.join(outdir, entry.file)
+            outfile = os.path.join(self.outdir, entry.file)
             self.lookasidecache.download(
                 self.ns_module_name,
                 entry.file, entry.hash, outfile,
                 hashtype=entry.hashtype)
 
-    def srpm(self, outdir=None):
+    def srpm(self):
         """Create an srpm using hashtype from content in the module
 
         Requires sources already downloaded.
         """
-
-        self.srpmname = os.path.join(self.path, "%s-%s-%s.src.rpm"
-                                     % (self.module_name, self.ver, self.rel))
+        srpm_path = os.path.join(self.outdir, "%s-%s-%s.src.rpm"
+                                     % (os.path.basename(self.ns_module_name), self.ver, self.rel))
 
         # See if we need to build the srpm
-        if os.path.exists(self.srpmname):
+        if os.path.exists(srpm_path):
             self.log.debug('Srpm found, rewriting it.')
 
         cmd = ['rpmbuild']
@@ -146,14 +139,15 @@ class Commands(pyrpkg.Commands):
                         % self.hashtype,
                         "--define '_binary_filedigest_algorithm %s'"
                         % self.hashtype])
-        if outdir:
-            cmd.extend(["--define '_srcrpmdir %s'" % outdir])
 
         cmd.extend(['--nodeps', '-bs', self.spec])
         self._run_command(cmd, shell=True)
+        return srpm_path
 
     def is_unpacked(self, dirpath, rpm_sources):
         """
+        @deprecated
+
         Decide, whether we are dealing with "unpacked"
         or "packed" type of source content at the
         given dirpath.
@@ -202,12 +196,12 @@ class Commands(pyrpkg.Commands):
         ignored_file_filter = lambda f: not re.search(
             ignore_file_regex, f, re.IGNORECASE)
 
-        if not list(filter(ignored_file_filter, os.listdir(dirpath))):
+        if not list(filter(ignored_file_filter, os.listdir(self.path))):
             return False
 
         return True
 
-    def make_source(self, destdir=None):
+    def make_source(self):
         """
         @deprecated
 
@@ -232,26 +226,23 @@ class Commands(pyrpkg.Commands):
         The behaviour is the same as if you called rpmbuild
         directly in your system.
 
-        :param str destdir: where to put the generated sources
-
         :returns path to the packed archive (alias Source0)
         """
         ts = rpm.ts()
         try:
-            rpm.addMacro("_sourcedir", self.path)
+            rpm.addMacro("_sourcedir", self.outdir)
             rpm_spec = ts.parseSpec(self.spec)
         except ValueError as e:
             raise RpmSpecParseException(str(e))
 
-        if not self.is_unpacked(self.path, rpm_spec.sources):
+        if not self.is_unpacked(self.outdir, rpm_spec.sources):
             raise NotUnpackedException("Not an unpacked content.")
 
         source_zero_name = utils.find_source_zero(rpm_spec.sources)
         if not source_zero_name:
             raise NoSourceZeroException("Source zero not found")
 
-        target_source_path = os.path.join(
-            destdir or self.path, source_zero_name)
+        target_source_path = os.path.join(self.outdir, source_zero_name)
 
         name = rpm.expandMacro("%{name}")
         version = rpm.expandMacro("%{version}")
@@ -265,3 +256,9 @@ class Commands(pyrpkg.Commands):
         )
         self.log.info('Wrote: {}'.format(target_source_path))
         return target_source_path
+
+    def preprocess_spec(self):
+        out_spec_path = os.path.join(
+            self.outdir, os.path.basename(self.spec.strip('.rpkg')))
+        preprocess(self.spec, out_spec_path)
+        return out_spec_path
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 9921f62..682c2fe 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -10,9 +10,15 @@ from pyrpkg import utils
 
 from exceptions import NotUnpackedException, RpmSpecParseException
 
+DEFAULT_OUTDIR = "/tmp/rpkg/"
+
 class rpkgClient(cliClient):
     def __init__(self, config, name=None):
         self.DEFAULT_CLI_NAME = 'rpkg'
+
+        if not os.path.isdir(DEFAULT_OUTDIR):
+            os.makedirs(DEFAULT_OUTDIR)
+
         super(rpkgClient, self).__init__(config, name)
 
     def setup_argparser(self):
@@ -103,6 +109,8 @@ class rpkgClient(cliClient):
                   for realm in items.get("kerberos_realms", '').split(',')
                   if realm]
 
+        outdir = self.args.outdir if 'outdir' in self.args else DEFAULT_OUTDIR
+
         # Create the cmd object
         self._cmd = self.site.Commands(self.args.path,
                                        items.get('lookaside'),
@@ -115,7 +123,8 @@ class rpkgClient(cliClient):
                                        build_client=None,
                                        user=self.args.user,
                                        quiet=self.args.q,
-                                       realms=realms
+                                       realms=realms,
+                                       outdir=outdir
                                        )
 
         self._cmd.module_name = self.args.module_name
@@ -148,8 +157,8 @@ class rpkgClient(cliClient):
             'spec file can be found. By default .spec file '
             'is autodiscovered in the working directory.')
         make_source_parser.add_argument(
-            '--outdir', default=os.getcwd(),
-            help='Where to put the generated source. '
+            '--outdir', default=DEFAULT_OUTDIR,
+            help='Where to put the generated files. '
             'By default cwd.')
         make_source_parser.set_defaults(command=self.make_source)
 
@@ -161,22 +170,31 @@ class rpkgClient(cliClient):
         print('This function is deprecated and will be removed in a future release.', file=sys.stderr)
         self.cmd.sources()
         self.cmd.set_specloc(self.args.spec)
-        self.cmd.make_source(self.args.outdir)
+        if self.config['rpkg'].getboolean('preprocess_spec', True):
+            spec_path = self.cmd.preprocess_spec()
+            self.cmd.set_specloc(spec_path)
+        self.cmd.make_source()
 
     def srpm(self):
         self.cmd.sources()
         self.cmd.set_specloc(self.args.spec)
+        if self.config['rpkg'].getboolean('preprocess_spec', True):
+            spec_path = self.cmd.preprocess_spec()
+            self.cmd.set_specloc(spec_path)
         if self.config['rpkg'].getboolean('auto_pack', False):
             print('Auto-packing is deprecated and will be removed in a future release.', file=sys.stderr)
             try:
                 self.cmd.make_source()
             except NotUnpackedException:
                 pass
-        self.cmd.srpm(self.args.outdir)
+        return self.cmd.srpm()
 
     def copr_build(self):
-        self.args.outdir = None
-        super(rpkgClient, self).copr_build()
+        srpm_path = self.srpm()
+        self.cmd.copr_build(self.args.project[0],
+                            srpm_path,
+                            self.args.nowait,
+                            self.args.copr_config)
 
     def is_packed(self):
         print('This function is deprecated and will be removed in a future release.', file=sys.stderr)
@@ -207,8 +225,8 @@ class rpkgClient(cliClient):
             'spec file can be found. By default .spec file '
             'is autodiscovered in the working directory.')
         srpm_parser.add_argument(
-            '--outdir', default=os.getcwd(),
-            help='Where to put the generated srpm.')
+            '--outdir', default=DEFAULT_OUTDIR,
+            help='Where to put the generated output files.')
         srpm_parser.set_defaults(command=self.srpm)
 
     def register_is_packed(self):
@@ -253,4 +271,8 @@ class rpkgClient(cliClient):
             help="Don't wait on build")
         copr_parser.add_argument(
             'project', nargs=1, help='Name of the project in format USER/PROJECT')
+        copr_parser.add_argument(
+            '--outdir', default=DEFAULT_OUTDIR,
+            help='Where to put the generated files. '
+            'By default cwd.')
         copr_parser.set_defaults(command=self.copr_build)
diff --git a/rpkglib/exceptions.py b/rpkglib/exceptions.py
index 7cc15d0..87640bb 100644
--- a/rpkglib/exceptions.py
+++ b/rpkglib/exceptions.py
@@ -7,6 +7,3 @@ class NotUnpackedException(Exception):
 
 class NoSourceZeroException(Exception):
     pass
-
-class SourceArchiveAlreadyExists(Exception):
-    pass
diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
new file mode 100644
index 0000000..0e9b1c2
--- /dev/null
+++ b/rpkglib/preproc.py
@@ -0,0 +1,29 @@
+import os
+import subprocess
+
+from pyparsing import nestedExpr
+
+preproc_path = os.path.join(
+    os.path.dirname(__file__), "preproc", "preproc.sh")
+
+
+def invoke_wrapper(outdir):
+    def invoke(toks):
+        subcmd = list(toks[0])
+        p = subprocess.Popen([preproc_path]+subcmd, env={'OUTDIR': outdir}, stdout=subprocess.PIPE)
+        (stdout, stderr) = p.communicate()
+        return stdout
+    return invoke
+
+
+def preprocess(in_spec_path, out_spec_path):
+    with open(in_spec_path, 'r') as f:
+        in_spec_data = f.read()
+        expr = nestedExpr('{{{', '}}}')
+        expr.setParseAction(
+            invoke_wrapper(os.path.dirname(out_spec_path))
+        )
+        out_spec_data = expr.transformString(in_spec_data)
+        outf = open(out_spec_path, 'w')
+        outf.write(out_spec_data)
+        outf.close()
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
new file mode 100644
index 0000000..e28296f
--- /dev/null
+++ b/rpkglib/preproc/lib.sh
@@ -0,0 +1,31 @@
+SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+function make_source {
+    dir_name="$(git_name)-$(git_version)"
+    source_name="$dir_name.tar.gz"
+    $SCRIPTDIR/scripts/make_source.sh $dir_name $OUTDIR/$source_name &> /dev/null
+    echo -n $source_name
+}
+
+function make_source_def {
+    dir_name="$(git_name)-$(git_version)"
+    source_name="$dir_name.tar.gz"
+    $SCRIPTDIR/scripts/make_source.sh $dir_name $OUTDIR/$source_name &> /dev/null
+    echo -n "Source: $source_name"
+}
+
+function setup {
+    echo -n "%setup -q"
+}
+
+function git_name {
+    echo -n "Name"
+}
+
+function git_version {
+    echo -n "1.0"
+}
+
+function git_change_log {
+    echo -n "%changelog"
+}
diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
new file mode 100755
index 0000000..897b041
--- /dev/null
+++ b/rpkglib/preproc/preproc.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+source $SCRIPTDIR/lib.sh
+
+if [ -f ./.rpkg.sh ]; then
+    source ./.rpkg.sh
+fi
+
+$*
diff --git a/rpkglib/preproc/scripts/make_source.sh b/rpkglib/preproc/scripts/make_source.sh
new file mode 100755
index 0000000..fbb44ec
--- /dev/null
+++ b/rpkglib/preproc/scripts/make_source.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+# creates a gzipped tarball out of the CWD content
+# to be used as a Source in a spec file.
+
+usage() {
+    cat <<EOF
+Usage:
+    $0 [--include-vcs] [--include-vcs-ignores] dir_name source_name
+
+    Creates a compressed tarball out of the CWD content
+    to be used as a Source in a spec file. Uses tar
+    to do the job.
+
+Options:
+    -h, --help             Print help
+    --include-vcs          Include version control system directories. By default excluded.
+    --include-vcs-ignores  Include files that match patterns read from VCS-specific ignore files. By default excluded.
+
+Arguments:
+    dir_name               Name of the directory in the created tarball.
+    source_name            Name of the resulting tarball file.
+EOF
+}
+
+DIR_NAME=""
+SOURCE_NAME=""
+EXCLUDE_VCS="--exclude-vcs"
+EXCLUDE_VCS_IGNORES="--exclude-vcs-ignores"
+
+while [ -n "$1" ] ; do
+    case "$1" in
+    -h|--help)
+        usage
+        exit 0
+        ;;
+    -d|--dirname)
+        DIR_NAME="$1"
+        shift
+        ;;
+    --include-vcs)
+        EXCLUDE_VCS=""
+        ;;
+    --include-vcs-ignores)
+        EXCLUDE_VCS_IGNORES=""
+        ;;
+    *)
+        DIR_NAME="$1"
+        shift
+        SOURCE_NAME="$1"
+        ;;
+    esac
+    shift
+done
+
+if [ -z "$SOURCE_NAME" ] || [ -z "$DIR_NAME" ]; then
+    usage
+    exit -1
+fi
+
+if [ -f $SOURCE_NAME ]; then
+    echo "Source file already exists."
+    exit 0
+fi
+
+ORIG_DIR_NAME=`basename $(pwd)`
+cd ..
+
+tar caf $SOURCE_NAME $EXCLUDE_VCS $EXCLUDE_VCS_IGNORES --transform "s/^$ORIG_DIR_NAME/$DIR_NAME/" $ORIG_DIR_NAME
diff --git a/rpkglib/utils.py b/rpkglib/utils.py
index f456b46..3927b6e 100644
--- a/rpkglib/utils.py
+++ b/rpkglib/utils.py
@@ -4,8 +4,6 @@ import re
 import shutil
 import tarfile
 
-from exceptions import SourceArchiveAlreadyExists
-
 log = logging.getLogger("__main__")
 
 
@@ -17,10 +15,6 @@ def pack_sources(dir_to_pack, target_path, pack_dir_as):
     :param str target_path: path to the resulting archive
     :param str pack_dir_as: packed directory name inside the archive
     """
-    if os.path.exists(target_path):
-        raise SourceArchiveAlreadyExists("{} already exists"
-                                         .format(target_path))
-
     log.debug("Packing {} as {} into {}...".format(
         dir_to_pack, pack_dir_as, target_path))
 
diff --git a/setup.py b/setup.py
index dd26058..15e2acc 100755
--- a/setup.py
+++ b/setup.py
@@ -20,6 +20,9 @@ setup(
         "Topic :: Software Development :: Build Tools",
     ],
     packages=find_packages(),
+    package_data={
+        '': ['preproc/*', 'preproc/*/*'],
+    },
     scripts=['rpkg'],
     include_package_data=True,
 )
diff --git a/tests/test_cli.py b/tests/test_cli.py
index eee6797..c01f649 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -6,6 +6,7 @@ import os
 import glob
 import tempfile
 import configparser
+import munch
 
 from rpkglib.cli import rpkgClient
 from rpkglib.exceptions import NotUnpackedException
@@ -21,6 +22,7 @@ else:
 
 RPKG_CONFIG = """
 [rpkg]
+preprocess_spec = True
 auto_pack = True
 
 [distgit]
@@ -43,7 +45,7 @@ class TestCli(base.TestCase):
 
         self.client = rpkgClient(config, name='rpkg')
         self.client.do_imports('rpkglib')
-        self.client.args = MagicMock(user='user', q='q', path=self.tmpdir)
+        self.client.args = munch.Munch(user='user', q='q', path=self.tmpdir, outdir=self.tmpdir, module_name=None, debug=False, v=False)
 
     def tearDown(self):
         os.unlink(self.config_path)
@@ -65,6 +67,7 @@ class TestCli(base.TestCase):
             user='user',
             quiet='q',
             realms=[],
+            outdir=self.tmpdir
         )
 
     def test_make_source_from_packed_raises(self):
@@ -75,14 +78,12 @@ class TestCli(base.TestCase):
 
     def test_make_source_from_unpacked(self):
         self.make_unpacked_content()
-        self.client.args.outdir = self.tmpdir
         self.client.args.spec = ''
         self.client.make_source()
         self.assertTrue(glob.glob('{}/{}'.format(self.tmpdir, '*.tar.gz')))
 
     def test_unpacked_changes_into_packed_by_make_sources(self):
         self.make_unpacked_content()
-        self.client.args.outdir = self.tmpdir
         self.client.args.spec = ''
         self.client.make_source()
         self.assertTrue(glob.glob('{}/{}'.format(self.tmpdir, '*.tar.gz')))
@@ -93,7 +94,6 @@ class TestCli(base.TestCase):
         self.make_packed_content()
         dircontent = os.listdir(self.tmpdir)
         self.client.args.spec = ''
-        self.client.args.outdir = self.tmpdir
         self.client.srpm()
         self.assertItemsEqual(
             os.listdir(self.tmpdir),
@@ -103,7 +103,6 @@ class TestCli(base.TestCase):
         self.make_unpacked_content()
         dircontent = os.listdir(self.tmpdir)
         self.client.args.spec = ''
-        self.client.args.outdir = self.tmpdir
         self.client.srpm()
         self.assertItemsEqual(
             os.listdir(self.tmpdir),
@@ -117,8 +116,6 @@ class TestCli(base.TestCase):
         self.touch_file('source0.tar.gz')
         dircontent = os.listdir(self.tmpdir)
 
-        self.client.args.outdir = self.tmpdir
-
         self.client.args.spec = spec1_path
         self.client.srpm()
         self.assertItemsEqual(
@@ -139,10 +136,9 @@ class TestCli(base.TestCase):
         self.touch_file('source0.tar.gz', subdir='SOURCES')
         self.client.args.spec = spec_path
         path = os.path.join(self.tmpdir, 'SOURCES')
-        self.client.args.path = path
         self.client.args.outdir = path
         dircontent = os.listdir(path)
         self.client.srpm()
         self.assertItemsEqual(
             os.listdir(path),
-            dircontent+['testpkg1-1-1.src.rpm'])
+            dircontent+['testpkg1.spec', 'testpkg1-1-1.src.rpm'])
diff --git a/tests/test_cmd.py b/tests/test_cmd.py
index 349ae19..9284d9b 100644
--- a/tests/test_cmd.py
+++ b/tests/test_cmd.py
@@ -30,7 +30,8 @@ class TestCommands(base.TestCase):
                                     'http://copr-dist-git.fedorainfracloud.org/git/%(module)s',
                                     branchre='.*',
                                     kojiconfig='',
-                                    build_client=None)
+                                    build_client=None,
+                                    outdir=self.tmpdir)
 
     def tearDown(self):
         super(TestCommands, self).tearDown()
@@ -169,12 +170,12 @@ class TestCommands(base.TestCase):
     def test_make_source_raises_on_packed(self):
         self.dump_spec(SPEC_TEMPLATE, source0='source0.tar.gz')
         with self.assertRaises(NotUnpackedException):
-            self.cmd.make_source(self.tmpdir)
+            self.cmd.make_source()
 
     def test_make_source_packs_on_unpacked(self):
         spec_path = self.dump_spec(SPEC_TEMPLATE, source0='source0.tar.gz')
         self.touch_file('patch.txt', subdir='dir')
-        archive_path = self.cmd.make_source(self.tmpdir)
+        archive_path = self.cmd.make_source()
         self.assertTrue(os.path.exists(archive_path))
 
         parsed_spec = self.get_parsed_spec(spec_path)
@@ -194,10 +195,10 @@ class TestCommands(base.TestCase):
     def test_make_source_raises_on_invalid_spec(self):
         self.dump_spec(INVALID_SPEC_TEMPLATE)
         with self.assertRaises(RpmSpecParseException):
-            self.cmd.make_source(self.tmpdir)
+            self.cmd.make_source()
 
     def test_make_source_raises_on_no_source_zero(self):
         self.dump_spec(NO_SOURCE_ZERO_SPEC_TEMPLATE)
         self.touch_file('patch.txt')
         with self.assertRaises(NoSourceZeroException):
-            self.cmd.make_source(self.tmpdir)
+            self.cmd.make_source()
diff --git a/tests/test_lookaside.py b/tests/test_lookaside.py
index 34a98e3..11c76d9 100644
--- a/tests/test_lookaside.py
+++ b/tests/test_lookaside.py
@@ -12,7 +12,8 @@ class TestLookasideCache(base.TestCase):
                                'anongiturl',
                                branchre='.*',
                                kojiconfig='',
-                               build_client=None)
+                               build_client=None,
+                               outdir=self.tmpdir)
         url = cmd.lookasidecache.get_download_url('forks/user/ns1/pkg', 'bar.tar.gz', '123asdf', 'outfile', 'sha512')
         self.assertEqual(url, 'http://localhost/repo/pkgs/ns1/pkg/bar.tar.gz/sha512/123asdf/bar.tar.gz')
 
@@ -25,6 +26,7 @@ class TestLookasideCache(base.TestCase):
                                'anongiturl',
                                branchre='.*',
                                kojiconfig='',
-                               build_client=None)
+                               build_client=None,
+                               outdir=self.tmpdir)
         url = cmd.lookasidecache.get_download_url('forks/user/ns1/pkg', 'bar.tar.gz', '123asdf', 'outfile', 'sha512')
         self.assertEqual(url, 'http://localhost/repo/pkgs/user/ns1/pkg/bar.tar.gz/sha512/123asdf/bar.tar.gz')

From 36386a1c69fe863b113769f0898121cf93a8d199 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 3/104] add missing dep on python-configparser


---

diff --git a/rpkg-client.spec b/rpkg-client.spec
index 04705ed..62f7a7c 100644
--- a/rpkg-client.spec
+++ b/rpkg-client.spec
@@ -29,6 +29,7 @@ BuildRequires: python2-devel
 BuildRequires: python2-rpkg
 BuildRequires: python2-mock
 BuildRequires: python2-pyparsing
+BuildRequires: python2-configparser
 
 %if 0%{?rhel}
 BuildRequires: pytest
@@ -38,6 +39,7 @@ BuildRequires: python2-pytest
 
 Requires: python2-rpkg
 Requires: python2-pyparsing
+Requires: python2-configparser
 
 %description -n rpkg
 This is an RPM packaging utility based on python-rpkg library.

From 1eee55433bea502b67664d2c9c03bb028ad515fd Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 4/104] fix deps and update README


---

diff --git a/README.md b/README.md
index 5aba0b9..bbb5daf 100644
--- a/README.md
+++ b/README.md
@@ -4,21 +4,45 @@ and Git repositories and it handles two types of directory content: _packed_ con
 - Packed (unexpanded) content is that composed of tarballs, patches, and a .spec file.
 - Unpacked (expanded) content is that composed of plain source files and a .spec file.
 
-For packed content, if you ask `rpkg` to make srpm (`rpkg srpm`), it will download any external
-files from the appropriate storage (e.g. lookaside cache for DistGit) and then it will invoke
-`rpmbuild -bs` with `_sourcedir`, `_specdir`, `_builddir`, `_srcrpmdir`,`_rpmdir` macros all
-set to the working directory.
+Currently `rpkg` offer two ways of achieving this:
+
+- spec templates
+- autopacking (deprecated)
+
+Spec templates:
+
+    Name:       {{{ git_name }}}
+    Version:    {{{ git_version }}}
+    Release:    1%{?dist}
+    Summary:    This is a test package.
+
+    License:    GPLv2+
+    URL:        https://someurl.org
+
+    Source: {{{ make_source }}}
+
+    %description
+    This is a test package.
+
+    %prep
+    {{{ setup }}}
+
+    {{{ git_change_log }}}
+
+TODO: write up more!
+
+Autopacking (deprecated):
+
+If you have auto_pack option enabled in your config, then for packed content, if you ask `rpkg`
+to make srpm (`rpkg srpm`), it will download any external files from the appropriate storage
+(e.g. lookaside cache for DistGit) and then it will invoke `rpmbuild -bs` with `_sourcedir`,
+`_specdir`, `_builddir`, `_srcrpmdir`,`_rpmdir` macros all set to the working directory.
 
 For unpacked content, if you ask `rpkg` to do the same thing, it will download external sources (if any)
 and then it will also generate a tarball from the whole content of the working directory named according
 to `Source0` definition present in the associated .spec file. This tarball and the .spec are then passed
 to the same rpmbuild command as above for the packed content.
 
-Note that by dynamically creating the tarball in the working directory according to the `Source0`
-definition, the directory content becomes packed because there is at least one file, which is referenced
-from the .spec file as `Source` or `Patch`. You can find the exact definitions of "packed" and "unpacked"
-in `rpkg` man pages (see PACKED VS UNPACKED section for examples) or with `rpkg make-source --help`.
-
 Apart from generating srpms from the application sources, you can also run other useful packaging commands
 like `rpkg lint` to check the .spec file and the overall package conformance to RPM standard, `rpkg local`
 to locally build the package into an rpm, or `rpkg copr-build` to build an srpm and send it for build to
diff --git a/rpkg-client.spec b/rpkg-client.spec
index 62f7a7c..72d1d73 100644
--- a/rpkg-client.spec
+++ b/rpkg-client.spec
@@ -28,18 +28,27 @@ BuildRequires: python2-setuptools
 BuildRequires: python2-devel
 BuildRequires: python2-rpkg
 BuildRequires: python2-mock
-BuildRequires: python2-pyparsing
-BuildRequires: python2-configparser
+BuildRequires: python-munch
 
 %if 0%{?rhel}
 BuildRequires: pytest
+BuildRequires: pyparsing
+BuildRequires: python-configparser
 %else
 BuildRequires: python2-pytest
+BuildRequires: python2-pyparsing
+BuildRequires: python2-configparser
 %endif
 
 Requires: python2-rpkg
+
+%if 0%{?rhel}
+Requires: pyparsing
+Requires: python-configparser
+%else
 Requires: python2-pyparsing
 Requires: python2-configparser
+%endif
 
 %description -n rpkg
 This is an RPM packaging utility based on python-rpkg library.

From 0483b2433945177d2b19a02872d6368c7103eee7 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 5/104] change preproc shell type to bash


---

diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index 897b041..7a908fb 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 

From 3c28adceb085805f03b01541a0ca7bda2a1d46ec Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 6/104] change argument expansion from $* to "$@"


...so that user is able to pass space separated strings to the functions as a single parameter

---

diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index 7a908fb..4d12448 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -8,4 +8,4 @@ if [ -f ./.rpkg.sh ]; then
     source ./.rpkg.sh
 fi
 
-$*
+"$@"

From dd7556cc7a85f5daa72ce073e9c751619766dc6d Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 7/104] rename lib.sh to rpkg.sh, use lib.sh for generic helper methods


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index e28296f..2dcd129 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -1,31 +1,2 @@
-SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-function make_source {
-    dir_name="$(git_name)-$(git_version)"
-    source_name="$dir_name.tar.gz"
-    $SCRIPTDIR/scripts/make_source.sh $dir_name $OUTDIR/$source_name &> /dev/null
-    echo -n $source_name
-}
-
-function make_source_def {
-    dir_name="$(git_name)-$(git_version)"
-    source_name="$dir_name.tar.gz"
-    $SCRIPTDIR/scripts/make_source.sh $dir_name $OUTDIR/$source_name &> /dev/null
-    echo -n "Source: $source_name"
-}
-
-function setup {
-    echo -n "%setup -q"
-}
-
-function git_name {
-    echo -n "Name"
-}
-
-function git_version {
-    echo -n "1.0"
-}
-
-function git_change_log {
-    echo -n "%changelog"
+function params {
 }
diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index 4d12448..b4155be 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -2,7 +2,7 @@
 
 SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
-source $SCRIPTDIR/lib.sh
+source $SCRIPTDIR/rpkg.sh
 
 if [ -f ./.rpkg.sh ]; then
     source ./.rpkg.sh
diff --git a/rpkglib/preproc/rpkg.sh b/rpkglib/preproc/rpkg.sh
new file mode 100644
index 0000000..ae94587
--- /dev/null
+++ b/rpkglib/preproc/rpkg.sh
@@ -0,0 +1,80 @@
+SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+source $SCRIPTDIR/lib.sh
+
+############## REPO FUNCTIONS ##############
+
+function git_pack {
+    echo "foo";
+}
+
+function git_archive {
+    echo "foo";
+}
+
+function git_name {
+    origin_last_part=$(basename $(git config --get remote.origin.url))
+    echo -n "${origin_last_part%.git}";
+}
+
+function git_version {
+    params name major minor subminor suffix
+
+    mapfile -t tags < <(git tag --list --sort=taggerdate);
+    for tag in "${tags[@]}"; do
+        echo $tag | sed 's/(.*)-([^-])+-([^-])+$/\0 \1 \2/'
+    done
+
+    for tag in "${tags[@]}"; do 
+        a+=($(echo $tag | sed -E "s/^\s*$name-([^-]+)-[^-]+\s*$/\1/"));
+    done
+
+    level1=${#tags[@]}
+    latest_tag=${#tags[-1]}
+    level2=$(git rev-list $latest_tag^..HEAD | wc -l)
+
+    echo -n "$level1.$level2";
+}
+
+function git_release {
+    mapfile -t tags < <(git tag --list --sort=taggerdate "$git_name*")
+    major=${#tags[@]}
+    latest_tag=${#tags[-1]}
+    minor=$(git rev-list $latest_tag^..HEAD | wc -l)
+    #last_tag=$(git tag --list --sort=taggerdate "$git_name*" | tail -n -1)
+    echo "foo";
+}
+
+function git_source_name {
+    echo "foo";
+}
+
+function git_changelog {
+    echo "foo";
+}
+
+############## DIR FUNCTIONS ##############
+
+function git_dir_pack {
+    echo "foo";
+}
+
+function git_dir_achive {
+    echo "foo";
+}
+
+function git_dir_name {
+    echo "foo";
+}
+
+function git_dir_source_name {
+    echo "foo";
+}
+
+function git_dir_version {
+    echo "foo";
+}
+
+function git_dir_changelog {
+    echo "foo";
+}

From ae8e8d0e4438492a4d7a8f1eb84852fd1e3c964f Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 8/104] rename make_source.sh script to pack_sources.sh


---

diff --git a/rpkglib/preproc/scripts/make_source.sh b/rpkglib/preproc/scripts/make_source.sh
deleted file mode 100755
index fbb44ec..0000000
--- a/rpkglib/preproc/scripts/make_source.sh
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/bin/sh
-
-# creates a gzipped tarball out of the CWD content
-# to be used as a Source in a spec file.
-
-usage() {
-    cat <<EOF
-Usage:
-    $0 [--include-vcs] [--include-vcs-ignores] dir_name source_name
-
-    Creates a compressed tarball out of the CWD content
-    to be used as a Source in a spec file. Uses tar
-    to do the job.
-
-Options:
-    -h, --help             Print help
-    --include-vcs          Include version control system directories. By default excluded.
-    --include-vcs-ignores  Include files that match patterns read from VCS-specific ignore files. By default excluded.
-
-Arguments:
-    dir_name               Name of the directory in the created tarball.
-    source_name            Name of the resulting tarball file.
-EOF
-}
-
-DIR_NAME=""
-SOURCE_NAME=""
-EXCLUDE_VCS="--exclude-vcs"
-EXCLUDE_VCS_IGNORES="--exclude-vcs-ignores"
-
-while [ -n "$1" ] ; do
-    case "$1" in
-    -h|--help)
-        usage
-        exit 0
-        ;;
-    -d|--dirname)
-        DIR_NAME="$1"
-        shift
-        ;;
-    --include-vcs)
-        EXCLUDE_VCS=""
-        ;;
-    --include-vcs-ignores)
-        EXCLUDE_VCS_IGNORES=""
-        ;;
-    *)
-        DIR_NAME="$1"
-        shift
-        SOURCE_NAME="$1"
-        ;;
-    esac
-    shift
-done
-
-if [ -z "$SOURCE_NAME" ] || [ -z "$DIR_NAME" ]; then
-    usage
-    exit -1
-fi
-
-if [ -f $SOURCE_NAME ]; then
-    echo "Source file already exists."
-    exit 0
-fi
-
-ORIG_DIR_NAME=`basename $(pwd)`
-cd ..
-
-tar caf $SOURCE_NAME $EXCLUDE_VCS $EXCLUDE_VCS_IGNORES --transform "s/^$ORIG_DIR_NAME/$DIR_NAME/" $ORIG_DIR_NAME
diff --git a/rpkglib/preproc/scripts/pack_sources.sh b/rpkglib/preproc/scripts/pack_sources.sh
new file mode 100755
index 0000000..fbb44ec
--- /dev/null
+++ b/rpkglib/preproc/scripts/pack_sources.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+# creates a gzipped tarball out of the CWD content
+# to be used as a Source in a spec file.
+
+usage() {
+    cat <<EOF
+Usage:
+    $0 [--include-vcs] [--include-vcs-ignores] dir_name source_name
+
+    Creates a compressed tarball out of the CWD content
+    to be used as a Source in a spec file. Uses tar
+    to do the job.
+
+Options:
+    -h, --help             Print help
+    --include-vcs          Include version control system directories. By default excluded.
+    --include-vcs-ignores  Include files that match patterns read from VCS-specific ignore files. By default excluded.
+
+Arguments:
+    dir_name               Name of the directory in the created tarball.
+    source_name            Name of the resulting tarball file.
+EOF
+}
+
+DIR_NAME=""
+SOURCE_NAME=""
+EXCLUDE_VCS="--exclude-vcs"
+EXCLUDE_VCS_IGNORES="--exclude-vcs-ignores"
+
+while [ -n "$1" ] ; do
+    case "$1" in
+    -h|--help)
+        usage
+        exit 0
+        ;;
+    -d|--dirname)
+        DIR_NAME="$1"
+        shift
+        ;;
+    --include-vcs)
+        EXCLUDE_VCS=""
+        ;;
+    --include-vcs-ignores)
+        EXCLUDE_VCS_IGNORES=""
+        ;;
+    *)
+        DIR_NAME="$1"
+        shift
+        SOURCE_NAME="$1"
+        ;;
+    esac
+    shift
+done
+
+if [ -z "$SOURCE_NAME" ] || [ -z "$DIR_NAME" ]; then
+    usage
+    exit -1
+fi
+
+if [ -f $SOURCE_NAME ]; then
+    echo "Source file already exists."
+    exit 0
+fi
+
+ORIG_DIR_NAME=`basename $(pwd)`
+cd ..
+
+tar caf $SOURCE_NAME $EXCLUDE_VCS $EXCLUDE_VCS_IGNORES --transform "s/^$ORIG_DIR_NAME/$DIR_NAME/" $ORIG_DIR_NAME

From c8b15f1d1242f3e0a4731ff71fc68da3c1120d0c Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 9/104] rpkg.sh back to lib.sh as we can just do name params with declare


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 2dcd129..bc1f6bf 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -1,2 +1,83 @@
-function params {
+SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+############## REPO FUNCTIONS ##############
+
+function git_pack {
+    echo "foo";
+}
+
+function git_archive {
+    echo "foo";
+}
+
+function git_name {
+    origin_last_part=$(basename $(git config --get remote.origin.url))
+    echo -n "${origin_last_part%.git}";
+}
+
+function test_params {
+    declare name=$(git_name) major=0 minor=+0 subminor=+0 suffix='' "$@"
+    echo $name $major $minor $subminor $suffix
+}
+
+function git_version {
+    declare name=$(git_name) major=0 minor=+0 subminor=+0 suffix='' "$@"
+
+    mapfile -t tags < <(git tag --list --sort=taggerdate);
+    for tag in "${tags[@]}"; do
+        echo $tag | sed 's/(.*)-([^-])+-([^-])+$/\0 \1 \2/'
+    done
+
+    for tag in "${tags[@]}"; do
+        a+=($(echo $tag | sed -E "s/^\s*$name-([^-]+)-[^-]+\s*$/\1/"));
+    done
+
+    level1=${#tags[@]}
+    latest_tag=${#tags[-1]}
+    level2=$(git rev-list $latest_tag^..HEAD | wc -l)
+
+    echo -n "$level1.$level2";
+}
+
+function git_release {
+    mapfile -t tags < <(git tag --list --sort=taggerdate "$git_name*")
+    major=${#tags[@]}
+    latest_tag=${#tags[-1]}
+    minor=$(git rev-list $latest_tag^..HEAD | wc -l)
+    #last_tag=$(git tag --list --sort=taggerdate "$git_name*" | tail -n -1)
+    echo "foo";
+}
+
+function git_source_name {
+    echo "foo";
+}
+
+function git_changelog {
+    echo "foo";
+}
+
+############## DIR FUNCTIONS ##############
+
+function git_dir_pack {
+    echo "foo";
+}
+
+function git_dir_achive {
+    echo "foo";
+}
+
+function git_dir_name {
+    echo "foo";
+}
+
+function git_dir_source_name {
+    echo "foo";
+}
+
+function git_dir_version {
+    echo "foo";
+}
+
+function git_dir_changelog {
+    echo "foo";
 }
diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index b4155be..4d12448 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -2,7 +2,7 @@
 
 SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
-source $SCRIPTDIR/rpkg.sh
+source $SCRIPTDIR/lib.sh
 
 if [ -f ./.rpkg.sh ]; then
     source ./.rpkg.sh
diff --git a/rpkglib/preproc/rpkg.sh b/rpkglib/preproc/rpkg.sh
deleted file mode 100644
index ae94587..0000000
--- a/rpkglib/preproc/rpkg.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-source $SCRIPTDIR/lib.sh
-
-############## REPO FUNCTIONS ##############
-
-function git_pack {
-    echo "foo";
-}
-
-function git_archive {
-    echo "foo";
-}
-
-function git_name {
-    origin_last_part=$(basename $(git config --get remote.origin.url))
-    echo -n "${origin_last_part%.git}";
-}
-
-function git_version {
-    params name major minor subminor suffix
-
-    mapfile -t tags < <(git tag --list --sort=taggerdate);
-    for tag in "${tags[@]}"; do
-        echo $tag | sed 's/(.*)-([^-])+-([^-])+$/\0 \1 \2/'
-    done
-
-    for tag in "${tags[@]}"; do 
-        a+=($(echo $tag | sed -E "s/^\s*$name-([^-]+)-[^-]+\s*$/\1/"));
-    done
-
-    level1=${#tags[@]}
-    latest_tag=${#tags[-1]}
-    level2=$(git rev-list $latest_tag^..HEAD | wc -l)
-
-    echo -n "$level1.$level2";
-}
-
-function git_release {
-    mapfile -t tags < <(git tag --list --sort=taggerdate "$git_name*")
-    major=${#tags[@]}
-    latest_tag=${#tags[-1]}
-    minor=$(git rev-list $latest_tag^..HEAD | wc -l)
-    #last_tag=$(git tag --list --sort=taggerdate "$git_name*" | tail -n -1)
-    echo "foo";
-}
-
-function git_source_name {
-    echo "foo";
-}
-
-function git_changelog {
-    echo "foo";
-}
-
-############## DIR FUNCTIONS ##############
-
-function git_dir_pack {
-    echo "foo";
-}
-
-function git_dir_achive {
-    echo "foo";
-}
-
-function git_dir_name {
-    echo "foo";
-}
-
-function git_dir_source_name {
-    echo "foo";
-}
-
-function git_dir_version {
-    echo "foo";
-}
-
-function git_dir_changelog {
-    echo "foo";
-}

From 8269e470437ba280d0a1caa724e09025cba9392d Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 10/104] tagging and git_version macro implemented


---

diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
new file mode 100644
index 0000000..4d33f59
--- /dev/null
+++ b/rpkg-client.spec.rpkg
@@ -0,0 +1,154 @@
+Name: {{{ git_name }}}
+Version: {{{ git_version }}}
+Release: 1%{?dist}
+Summary: RPM packaging utitility
+License: GPLv2+
+URL: https://pagure.io/rpkg-client.git
+
+# How to obtain the sources
+# git clone https://pagure.io/rpkg-client.git
+# cd rpkg-client
+# tito build --tgz
+Source0: %{name}-%{version}.tar.gz
+
+BuildArch: noarch
+
+%description
+This package contains the rpkg utility. We are putting
+the actual 'rpkg' package into a subpackage because there already
+exists package https://src.fedoraproject.org/rpms/rpkg. That package,
+however, does not actually produce rpkg rpm whereas rpkg-client does.
+
+%package -n rpkg
+Summary: RPM packaging utitility
+BuildArch: noarch
+
+BuildRequires: python
+BuildRequires: python-setuptools
+BuildRequires: python-devel
+BuildRequires: python2-rpkg
+BuildRequires: python2-mock
+BuildRequires: python-munch
+
+%if 0%{?rhel}
+BuildRequires: pytest
+BuildRequires: pyparsing
+BuildRequires: python-configparser
+%else
+BuildRequires: python2-pytest
+BuildRequires: python2-pyparsing
+BuildRequires: python2-configparser
+%endif
+
+Requires: python2-rpkg
+
+%if 0%{?rhel}
+Requires: pyparsing
+Requires: python-configparser
+%else
+Requires: python2-pyparsing
+Requires: python2-configparser
+%endif
+
+%description -n rpkg
+This is an RPM packaging utility based on python-rpkg library.
+It works with both DistGit and standard Git repositories and
+it handles packed directory content as well as unpacked content.
+
+%prep
+%setup -q
+
+%check
+./run_tests.sh
+
+%build
+%py2_build
+%{__python2} doc/rpkg_man_page.py > rpkg.1
+
+%install
+%py2_install
+install -d %{buildroot}%{_mandir}/man1
+install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1
+
+install -d %{buildroot}%{_sysconfdir}
+install -d %{buildroot}%{_datarootdir}/bash-completion/completions
+
+cp -a rpkg.conf %{buildroot}%{_sysconfdir}/
+cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
+
+%files -n rpkg
+%license LICENSE
+%{python2_sitelib}/*
+
+%config(noreplace) %{_sysconfdir}/rpkg.conf
+%{_datadir}/bash-completion/completions/rpkg.bash
+
+%{_bindir}/rpkg
+%{_mandir}/*/*
+
+%changelog
+* Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
+- add LICENSE to ignored file regex
+
+* Mon Oct 23 2017 clime <clime@redhat.com> 0.12-1
+- respect hashtype from the sources file if any
+
+* Fri Oct 20 2017 clime <clime@redhat.com> 0.11-1
+- set default distgit target to src.fedoraproject.org
+- fix downloading sources for any-length-namespace
+  modules
+- make the whole lookaside url template explict in
+  the config file
+- rename 'rpkg' config section to 'distgit'
+- update in command descriptions
+
+* Wed Oct 18 2017 clime <clime@redhat.com> 0.10-1
+- possibility to give directory to --spec
+- also take --spec in account for rpmdefines
+
+* Mon Oct 16 2017 clime <clime@redhat.com> 0.9-1
+- update spec descriptions
+- added is-packed subcommand
+- try reading ~/.config/rpkg before /etc/rpkg
+- add unittests
+- for source downloading, try both url formats
+  with/without hashtype
+- add make-source subcommand
+- patch srpm to generate Source0 if unpacked content
+- override load_ns_module_name to work with any length
+  namespaces
+- added --spec for srpm, make-source, and copr-build
+- fixed tagging not to include host dist tag
+- docs update
+- make all config values optional
+
+* Thu Jul 27 2017 clime <clime@redhat.com> 0.8-1
+- fix man pages to only include actually provided part of pyrpkg functionality
+- add rpkglib to provide functional interface
+- change summary of wrapper package
+
+* Wed Jul 26 2017 clime <clime@redhat.com> 0.7-1
+- use %%py2_build and %%py2_install macros
+- explicitly invoke python2 for doc generation
+- remove no longer needed $BUILDROOT removal in %%install clause
+- add missing BuildRequires on python-setuptools
+
+* Fri Jul 07 2017 clime <clime@redhat.com> 0.6-1
+- fix build error
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.5-1
+- remove Requires bash-completion
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.4-1
+- move config file to /etc/rpkg.conf
+- add Requires bash-completion
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.3-1
+- remove some directories from %%files in .spec
+- add (for now) short README.md
+
+* Tue Jun 20 2017 clime <clime@redhat.com> 0.2-1
+- new rpkg-client package built with tito
+
+* Mon Jun 12 2017 clime <clime@redhat.com> 0.1-1
+- Initial version
diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 8392153..732f4df 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -2,6 +2,8 @@ import os
 import rpm
 import shutil
 import re
+import subprocess
+import tempfile
 
 import pyrpkg
 from pyrpkg.utils import cached_property
@@ -18,6 +20,7 @@ class Commands(pyrpkg.Commands):
     def __init__(self, *args, **kwargs):
         """Init the object and some configuration details."""
         self.outdir = kwargs.pop("outdir")
+        self.preprocess = kwargs.pop("preprocess")
         super(Commands, self).__init__(*args, **kwargs)
         self.source_entry_type = 'bsd'
         self.distgit_namespaced = True
@@ -45,22 +48,23 @@ class Commands(pyrpkg.Commands):
     def load_spec(self):
         """This sets the spec attribute"""
         if not os.path.isdir(self._specloc):
-            self._spec = os.path.abspath(self._specloc)
+            self._spec = self.preprocess_spec(self._specloc)
             return
 
         files = os.listdir(self._specloc)
 
         for f in files:
-            if f.endswith('.spec.rpkg') and not f.startswith('.'):
-                self._spec = os.path.abspath(os.path.join(self._specloc, f))
-                return
+            if f.endswith('.spec') and not f.startswith('.'):
+                spec_template = os.path.abspath(os.path.join(self._specloc, f))
 
         for f in files:
-            if f.endswith('.spec') and not f.startswith('.'):
-                self._spec = os.path.abspath(os.path.join(self._specloc, f))
-                return
+            if f.endswith('.spec.rpkg') and not f.startswith('.'):
+                spec_template = os.path.abspath(os.path.join(self._specloc, f))
+
+        if not spec_template:
+            raise rpkgError('No spec file found.')
 
-        raise rpkgError('No spec file found.')
+        self._spec = self.preprocess_spec(spec_template)
 
     @cached_property
     def lookasidecache(self):
@@ -74,6 +78,10 @@ class Commands(pyrpkg.Commands):
             self.load_ns_module_name()
         return self._ns_module_name
 
+    @ns_module_name.setter
+    def ns_module_name(self, ns_module_name):
+        self._ns_module_name = ns_module_name
+
     def load_ns_module_name(self):
         """Loads the namespace module name"""
         try:
@@ -94,14 +102,12 @@ class Commands(pyrpkg.Commands):
         except rpkgError:
             pass
 
-        self.load_nameverrel()
-        if self._module_name_spec:
-            self.log.info('Getting module name from spec file.')
-            self._ns_module_name = self._module_name_spec
-            return
+        self.log.info('Getting module name from spec file.')
+        self._ns_module_name = self.module_name
 
-        raise rpkgError('Could not find current module name.'
-                        ' Use --module-name.')
+        if not self._ns_module_name:
+            raise rpkgError('Could not find current module name.'
+                            ' Use --module-name.')
 
     def sources(self):
         """Download source files"""
@@ -123,7 +129,7 @@ class Commands(pyrpkg.Commands):
         Requires sources already downloaded.
         """
         srpm_path = os.path.join(self.outdir, "%s-%s-%s.src.rpm"
-                                     % (os.path.basename(self.ns_module_name), self.ver, self.rel))
+                                     % (self.module_name, self.ver, self.rel))
 
         # See if we need to build the srpm
         if os.path.exists(srpm_path):
@@ -257,8 +263,139 @@ class Commands(pyrpkg.Commands):
         self.log.info('Wrote: {}'.format(target_source_path))
         return target_source_path
 
-    def preprocess_spec(self):
+    def preprocess_spec(self, spec_template):
         out_spec_path = os.path.join(
-            self.outdir, os.path.basename(self.spec.strip('.rpkg')))
-        preprocess(self.spec, out_spec_path)
+            self.outdir, os.path.basename(spec_template.strip('.rpkg')))
+
+        if self.preprocess:
+            preprocess(spec_template, out_spec_path)
+        else:
+            shutil.copy(spec_template, out_spec_path)
+
         return out_spec_path
+
+    @property
+    def module_name(self):
+        """This property ensures the name attribute"""
+        if not self._module_name_spec:
+            self.load_nameverrel()
+        return self._module_name_spec
+
+    def git_tag(self, tagname, force=False, message=None, file=None, log_info=True):
+        if not message and not file:
+            message = self.get_tag_message()
+
+        cmd = ['git', 'tag']
+        cmd.extend(['-a'])
+        # force tag creation, if tag already exists
+        if force:
+            cmd.extend(['-f'])
+        # Description for the tag
+        if message:
+            cmd.extend(['-m', message])
+        elif file:
+            cmd.extend(['-F', os.path.abspath(file)])
+        cmd.append(tagname)
+        # make it so
+        self._run_command(cmd, cwd=self.path)
+
+        if log_info:
+            self.log.info('Created tag: %s', tagname)
+
+    def add_tag(self, tagname=None, force=False, message=None, file=None, ver_strip=".git.", rel_strip=".git."):
+        """Add a git tag to the repository
+
+        Takes a tagname
+
+        Optionally can force the tag, include a message,
+        or reference a message file.
+
+        Runs the tag command and returns nothing
+        """
+        if tagname:
+            self.git_tag(tagname, force, message, file)
+            return
+
+        if self.repo.is_dirty(self.spec):
+            raise rpkgError('%s has uncommitted changes.' % self.spec)
+
+        ver = utils.strip_at(self.ver, ver_strip)
+        rel = utils.strip_at(self.rel, rel_strip)
+        ver_parts = ver.split('.')
+        rel_parts = rel.split('.')
+
+        if not ver_parts or not rel_parts:
+            raise rpkgError('Invalid version or release returned from %s.' % self.spec)
+
+        tagname_template = '{name}-{version}-{release}'
+        next_ver = ver
+        next_rel = rel
+
+        if re.match(r'\d+', ver_parts[-1]):
+            next_ver = '{lead}.{last_part}'.format({
+                'lead': '.'.join(ver_parts[:-1]),
+                'last_part': int(ver_parts[-1]) + 1
+            })
+
+        if re.match(r'\d+', rel_parts[-1]):
+            next_rel = '{lead}.{last_part}'.format({
+                'lead': '.'.join(rel_parts[:-1]),
+                'last_part': int(rel_parts[-1]) + 1
+            })
+
+        if next_ver == ver and next_rel == rel:
+            tagname = tagname_template.format({
+                'name': self.module_name,
+                'version': ver,
+                'release': rel,
+            })
+            self.git_tag(tagname, force, message, file)
+            return
+
+        tagname = tagname_template.format({
+            'name': self.module_name,
+            'version': next_ver,
+            'release': next_rel,
+        })
+
+        self.git_tag(tagname, message='tmp', log_info=False)
+        self.load_nameverrel()
+
+        if utils.strip_at(self.ver, ver_strip) != next_ver:
+            next_ver = ver
+
+        if utils.strip_at(self.rel, rel_strip) != next_rel:
+            next_rel = rel
+
+        tagname = tagname_template.format({
+            'name': self.module_name,
+            'version': next_ver,
+            'release': next_rel,
+        })
+
+        self.del_tag(tagname)
+        self.git_tag(tagname, force, message, file)
+
+    def del_tag(self, tagname):
+        cmd = ['git', 'tag', '-d', tagname]
+        self._run_command(cmd, cwd=self.path)
+
+    def get_tag_message(self):
+        tag_pattern = '{}*'.format(self.module_name) # TODO: include $lead?
+        tag_names = repo.git.tag('--list', '--sort=taggerdate', tag_pattern).split()
+
+        if tag_names:
+            rev_list_expr = '{}..HEAD'.format(tag_names[-1]) # TODO: what about broken paths
+        else:
+            rev_list_expr = 'HEAD'
+
+        message_lines = [utils.changelog_get_line(commit.message) for commit
+                         in self.repo.iter_commits(rev_list_expr)] # TODO: commit ordering?
+
+        with tempfile.NamedTemporaryFile() as f:
+            f.writelines(message_lines)
+            editor = self.repo.git.var('GIT_EDITOR')
+            subprocess.call([editor, f.name])
+            message = f.read()
+
+        return message
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 682c2fe..b12cc54 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -124,10 +124,10 @@ class rpkgClient(cliClient):
                                        user=self.args.user,
                                        quiet=self.args.q,
                                        realms=realms,
-                                       outdir=outdir
-                                       )
+                                       outdir=outdir,
+                                       preprocess=items.get('preprocess_spec', True))
 
-        self._cmd.module_name = self.args.module_name
+        self._cmd.ns_module_name = self.args.module_name
         self._cmd.debug = self.args.debug
         self._cmd.verbose = self.args.v
         self._cmd.clone_config = items.get('clone_config')
@@ -164,23 +164,27 @@ class rpkgClient(cliClient):
 
     def tag(self):
         self.cmd._rpmdefines = self.cmd.rpmdefines + ["--define 'dist %nil'"]
-        super(rpkgClient, self).tag()
-
+        if self.args.list:
+            self.cmd.list_tag(self.args.tag)
+        elif self.args.delete:
+            self.cmd.delete_tag(self.args.tag)
+        else:
+            filename = self.args.file
+            tagname = self.args.tag
+            if self.args.clog:
+                self.cmd.clog(self.args.raw)
+                filename = 'clog'
+            self.cmd.add_tag(tagname, self.args.force,
+                             self.args.message, filename)
     def make_source(self):
         print('This function is deprecated and will be removed in a future release.', file=sys.stderr)
         self.cmd.sources()
         self.cmd.set_specloc(self.args.spec)
-        if self.config['rpkg'].getboolean('preprocess_spec', True):
-            spec_path = self.cmd.preprocess_spec()
-            self.cmd.set_specloc(spec_path)
         self.cmd.make_source()
 
     def srpm(self):
         self.cmd.sources()
         self.cmd.set_specloc(self.args.spec)
-        if self.config['rpkg'].getboolean('preprocess_spec', True):
-            spec_path = self.cmd.preprocess_spec()
-            self.cmd.set_specloc(spec_path)
         if self.config['rpkg'].getboolean('auto_pack', False):
             print('Auto-packing is deprecated and will be removed in a future release.', file=sys.stderr)
             try:
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index bc1f6bf..2acc737 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -3,81 +3,97 @@ SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 ############## REPO FUNCTIONS ##############
 
 function git_pack {
-    echo "foo";
+    echo "foo"
 }
 
 function git_archive {
-    echo "foo";
+    echo "foo"
 }
 
 function git_name {
-    origin_last_part=$(basename $(git config --get remote.origin.url))
-    echo -n "${origin_last_part%.git}";
-}
-
-function test_params {
-    declare name=$(git_name) major=0 minor=+0 subminor=+0 suffix='' "$@"
-    echo $name $major $minor $subminor $suffix
-}
-
-function git_version {
-    declare name=$(git_name) major=0 minor=+0 subminor=+0 suffix='' "$@"
-
-    mapfile -t tags < <(git tag --list --sort=taggerdate);
-    for tag in "${tags[@]}"; do
-        echo $tag | sed 's/(.*)-([^-])+-([^-])+$/\0 \1 \2/'
-    done
+    url=$(git config --get remote.origin.url)
 
-    for tag in "${tags[@]}"; do
-        a+=($(echo $tag | sed -E "s/^\s*$name-([^-]+)-[^-]+\s*$/\1/"));
-    done
+    if [ -z "$url" ]; then
+        echo "Start by setting origin URL." > $ERRORLOG
+        return 1
+    fi
 
-    level1=${#tags[@]}
-    latest_tag=${#tags[-1]}
-    level2=$(git rev-list $latest_tag^..HEAD | wc -l)
-
-    echo -n "$level1.$level2";
+    url_last_part=$(basename $url)
+    echo -n "${url_last_part%.git}"
 }
 
-function git_release {
-    mapfile -t tags < <(git tag --list --sort=taggerdate "$git_name*")
-    major=${#tags[@]}
-    latest_tag=${#tags[-1]}
-    minor=$(git rev-list $latest_tag^..HEAD | wc -l)
-    #last_tag=$(git tag --list --sort=taggerdate "$git_name*" | tail -n -1)
-    echo "foo";
+function git_version {
+    declare name=$(git_name) lead=0 follow= "$@"
+
+    if [ -z $name ]; then
+        echo "git_version: name cannot be empty." > $ERRORLOG
+        return 1
+    fi
+
+    if echo $lead.$follow | grep -q '-'; then
+        echo "git_version: lead and follow cannot contains dashes." > $ERRORLOG
+        return 1
+    fi
+    
+    mapfile -t tags < <(git tag --list --sort=taggerdate "$name-$lead*")
+
+    if [ ${#tags[@]} -gt 0 ]; then
+        latest_tag=${tags[-1]}
+        latest_tag_version=$(echo $latest_tag | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1/p")
+    else
+        latest_tag=
+        latest_tag_version=${lead}.0
+    fi
+
+    if [ -n "$latest_tag" ]; then
+        commit_count=$(git rev-list $latest_tag..HEAD --count)
+    else
+        commit_count=$(git rev-list HEAD --count 2> /dev/null || printf 0)
+    fi
+
+    if [ $commit_count -eq 0 ]; then
+        commit_count_appendix=
+    else
+        commit_count_appendix=.git.$commit_count.$(git rev-list HEAD --max-count=1 | cut -c -8)
+    fi
+
+    if [ -n "$follow" ]; then
+        echo -n ${lead}.${follow}${commit_count_appendix}
+    else
+        echo -n ${latest_tag_version}${commit_count_appendix}
+    fi
 }
 
 function git_source_name {
-    echo "foo";
+    echo "foo"
 }
 
 function git_changelog {
-    echo "foo";
+    echo "foo"
 }
 
 ############## DIR FUNCTIONS ##############
 
 function git_dir_pack {
-    echo "foo";
+    echo "foo"
 }
 
 function git_dir_achive {
-    echo "foo";
+    echo "foo"
 }
 
 function git_dir_name {
-    echo "foo";
+    echo "foo"
 }
 
 function git_dir_source_name {
-    echo "foo";
+    echo "foo"
 }
 
 function git_dir_version {
-    echo "foo";
+    echo "foo"
 }
 
 function git_dir_changelog {
-    echo "foo";
+    echo "foo"
 }
diff --git a/rpkglib/utils.py b/rpkglib/utils.py
index 3927b6e..c353ed5 100644
--- a/rpkglib/utils.py
+++ b/rpkglib/utils.py
@@ -3,6 +3,7 @@ import os
 import re
 import shutil
 import tarfile
+import textwrap
 
 log = logging.getLogger("__main__")
 
@@ -43,3 +44,13 @@ def find_source_zero(rpm_sources):
         if num == 0 and flags == 1:
             return os.path.basename(filepath)
     return None
+
+
+def changelog_get_line(message):
+    msg_first_line = '- ' + (message.split()[0] if message else '')
+    return texwrap.wrap(re.sub('r(\s+)%([^%])', r'\1%%\2', msg_first_line), 80)
+
+
+def strip_at(self, string, strip_token):
+    return re.sub(r'(.*){}.*'.format(re.escape(strip_token)), r'\1', string)
+
diff --git a/tests/test_cli.py b/tests/test_cli.py
index c01f649..b3caf23 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -67,7 +67,8 @@ class TestCli(base.TestCase):
             user='user',
             quiet='q',
             realms=[],
-            outdir=self.tmpdir
+            outdir=self.tmpdir,
+            preprocess=True
         )
 
     def test_make_source_from_packed_raises(self):
diff --git a/tests/test_cmd.py b/tests/test_cmd.py
index 9284d9b..a2b6fbe 100644
--- a/tests/test_cmd.py
+++ b/tests/test_cmd.py
@@ -31,7 +31,8 @@ class TestCommands(base.TestCase):
                                     branchre='.*',
                                     kojiconfig='',
                                     build_client=None,
-                                    outdir=self.tmpdir)
+                                    outdir=self.tmpdir,
+                                    preprocess=True)
 
     def tearDown(self):
         super(TestCommands, self).tearDown()
diff --git a/tests/test_lookaside.py b/tests/test_lookaside.py
index 11c76d9..18cf717 100644
--- a/tests/test_lookaside.py
+++ b/tests/test_lookaside.py
@@ -13,7 +13,8 @@ class TestLookasideCache(base.TestCase):
                                branchre='.*',
                                kojiconfig='',
                                build_client=None,
-                               outdir=self.tmpdir)
+                               outdir=self.tmpdir,
+                               preprocess=True)
         url = cmd.lookasidecache.get_download_url('forks/user/ns1/pkg', 'bar.tar.gz', '123asdf', 'outfile', 'sha512')
         self.assertEqual(url, 'http://localhost/repo/pkgs/ns1/pkg/bar.tar.gz/sha512/123asdf/bar.tar.gz')
 
@@ -27,6 +28,7 @@ class TestLookasideCache(base.TestCase):
                                branchre='.*',
                                kojiconfig='',
                                build_client=None,
-                               outdir=self.tmpdir)
+                               outdir=self.tmpdir,
+                               preprocess=True)
         url = cmd.lookasidecache.get_download_url('forks/user/ns1/pkg', 'bar.tar.gz', '123asdf', 'outfile', 'sha512')
         self.assertEqual(url, 'http://localhost/repo/pkgs/user/ns1/pkg/bar.tar.gz/sha512/123asdf/bar.tar.gz')

From c714bc1290107f32c8e41943d639cf5338a2e52a Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 11/104] add `rpkg spec`


---

diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
index 4d33f59..f94339c 100644
--- a/rpkg-client.spec.rpkg
+++ b/rpkg-client.spec.rpkg
@@ -1,3 +1,4 @@
+# vim: syntax=spec
 Name: {{{ git_name }}}
 Version: {{{ git_version }}}
 Release: 1%{?dist}
diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 732f4df..5b3be2d 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -34,8 +34,6 @@ class Commands(pyrpkg.Commands):
         else:
             self._specloc = specloc
 
-        self.load_spec()
-
     def load_rpmdefines(self):
         self._rpmdefines = [
             "--define '_sourcedir %s'" % self.outdir,
@@ -264,14 +262,17 @@ class Commands(pyrpkg.Commands):
         return target_source_path
 
     def preprocess_spec(self, spec_template):
-        out_spec_path = os.path.join(
-            self.outdir, os.path.basename(spec_template.strip('.rpkg')))
+        out_spec_basename = os.path.basename(
+            spec_template[:-5] if spec_template.endswith('.rpkg') else spec_template)
+
+        out_spec_path = os.path.join(self.outdir, out_spec_basename)
 
         if self.preprocess:
             preprocess(spec_template, out_spec_path)
         else:
             shutil.copy(spec_template, out_spec_path)
 
+        self.log.info('Wrote: {}'.format(out_spec_path))
         return out_spec_path
 
     @property
@@ -381,16 +382,17 @@ class Commands(pyrpkg.Commands):
         self._run_command(cmd, cwd=self.path)
 
     def get_tag_message(self):
-        tag_pattern = '{}*'.format(self.module_name) # TODO: include $lead?
-        tag_names = repo.git.tag('--list', '--sort=taggerdate', tag_pattern).split()
+        tag_pattern = '{}*'.format(self.module_name)
+        tag_names = repo.git.tag('--list', '--merged',
+                                 '--sort=taggerdate', tag_pattern).split()
 
         if tag_names:
-            rev_list_expr = '{}..HEAD'.format(tag_names[-1]) # TODO: what about broken paths
+            rev_list_expr = '{}..HEAD'.format(tag_names[-1])
         else:
             rev_list_expr = 'HEAD'
 
         message_lines = [utils.changelog_get_line(commit.message) for commit
-                         in self.repo.iter_commits(rev_list_expr)] # TODO: commit ordering?
+                         in self.repo.iter_commits(rev_list_expr)]
 
         with tempfile.NamedTemporaryFile() as f:
             f.writelines(message_lines)
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index b12cc54..eec1490 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -90,6 +90,7 @@ class rpkgClient(cliClient):
         self.register_pull()
         self.register_push()
         self.register_sources()
+        self.register_spec()
         self.register_srpm()
         self.register_switch_branch()
         self.register_tag()
@@ -193,6 +194,10 @@ class rpkgClient(cliClient):
                 pass
         return self.cmd.srpm()
 
+    def spec(self):
+        self.cmd.set_specloc(self.args.spec)
+        self.cmd.load_spec()
+
     def copr_build(self):
         srpm_path = self.srpm()
         self.cmd.copr_build(self.args.project[0],
@@ -215,6 +220,25 @@ class rpkgClient(cliClient):
         else:
             self.log.info('Yes')
 
+    def register_spec(self):
+        """Register the spec target"""
+        spec_parser = self.subparsers.add_parser(
+            'spec', help='Generate spec file from a spec template',
+            description='Preprocess a given spec template '
+            'and put the resulting spec file into outdir. '
+            'The spec template is simply copied into the outdir if '
+            'spec preprocessing is turned off or if the input spec template '
+            'does not contain any preprocessor macros.')
+        spec_parser.add_argument(
+            '--spec', action='store', default=None,
+            help='An input spec template. If not given, '
+            'the spec template is auto-located in path as a '
+            'file ending with ".spec.rpkg" or ".spec" suffix.')
+        spec_parser.add_argument(
+            '--outdir', default=DEFAULT_OUTDIR,
+            help='Where to put the generated spec file.')
+        spec_parser.set_defaults(command=self.spec)
+
     def register_srpm(self):
         """Register the srpm target"""
         srpm_parser = self.subparsers.add_parser(
@@ -230,7 +254,7 @@ class rpkgClient(cliClient):
             'is autodiscovered in the working directory.')
         srpm_parser.add_argument(
             '--outdir', default=DEFAULT_OUTDIR,
-            help='Where to put the generated output files.')
+            help='Where to put the generated srpm.')
         srpm_parser.set_defaults(command=self.srpm)
 
     def register_is_packed(self):
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 2acc737..30561a2 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -35,7 +35,7 @@ function git_version {
         return 1
     fi
     
-    mapfile -t tags < <(git tag --list --sort=taggerdate "$name-$lead*")
+    mapfile -t tags < <(git tag --list --sort=taggerdate "$name-$lead*" --merged)
 
     if [ ${#tags[@]} -gt 0 ]; then
         latest_tag=${tags[-1]}
diff --git a/tests/test_cli.py b/tests/test_cli.py
index b3caf23..fab3d81 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -125,7 +125,8 @@ class TestCli(base.TestCase):
 
         os.unlink(os.path.join(self.tmpdir, 'testpkg1-1-1.src.rpm'))
 
-        self.client.args.spec = spec2_path
+        self.client.cmd.set_specloc(spec2_path)
+        self.client.cmd.load_spec()
         self.client.srpm()
         self.assertItemsEqual(
             os.listdir(self.tmpdir),

From 10bb88e69f6a82f4e2bf7274e1e5a0215105548e Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 12/104] git_pack and git_source_name implemented


---

diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
index f94339c..ffb8354 100644
--- a/rpkg-client.spec.rpkg
+++ b/rpkg-client.spec.rpkg
@@ -10,7 +10,7 @@ URL: https://pagure.io/rpkg-client.git
 # git clone https://pagure.io/rpkg-client.git
 # cd rpkg-client
 # tito build --tgz
-Source0: %{name}-%{version}.tar.gz
+Source0: {{{ git_pack }}}
 
 BuildArch: noarch
 
diff --git a/rpkg.conf b/rpkg.conf
index 899c66e..f656c88 100644
--- a/rpkg.conf
+++ b/rpkg.conf
@@ -1,7 +1,7 @@
 [rpkg]
 preprocess_spec = True
 # auto-packing is deprecated:
-auto_pack = False
+auto_pack = True
 
 [distgit]
 lookaside = https://src.fedoraproject.org/repo/pkgs/%(ns1)s/%(pkg)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 30561a2..1f7978b 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -3,7 +3,12 @@ SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 ############## REPO FUNCTIONS ##############
 
 function git_pack {
-    echo "foo"
+    declare name=$(git_name) version=$(git_version) "$@"
+
+    dir_name=$name-$version
+    source_name=$(git_source_name name=$name name=$version)
+    $SCRIPTDIR/scripts/pack_sources $dir_name $OUTDIR/$source_name &> /dev/null
+    echo -n $source_name
 }
 
 function git_archive {
@@ -65,7 +70,8 @@ function git_version {
 }
 
 function git_source_name {
-    echo "foo"
+    declare name=$(git_name) version=$(git_version) "$@"
+    echo -n "$name-$version.tar.gz"
 }
 
 function git_changelog {

From 496c9713bcd153d06ed3c7b9f8b66c2ddfa21f9a Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 13/104] very basic logging implemented


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 5b3be2d..62a8ff3 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -268,7 +268,7 @@ class Commands(pyrpkg.Commands):
         out_spec_path = os.path.join(self.outdir, out_spec_basename)
 
         if self.preprocess:
-            preprocess(spec_template, out_spec_path)
+            preprocess(spec_template, out_spec_path, self.log)
         else:
             shutil.copy(spec_template, out_spec_path)
 
diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 0e9b1c2..d70613a 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -1,5 +1,6 @@
 import os
 import subprocess
+import tempfile
 
 from pyparsing import nestedExpr
 
@@ -7,21 +8,35 @@ preproc_path = os.path.join(
     os.path.dirname(__file__), "preproc", "preproc.sh")
 
 
-def invoke_wrapper(outdir):
+def invoke_wrapper(outdir, log):
     def invoke(toks):
         subcmd = list(toks[0])
-        p = subprocess.Popen([preproc_path]+subcmd, env={'OUTDIR': outdir}, stdout=subprocess.PIPE)
+        debug_log_file = tempfile.NamedTemporaryFile()
+        info_log_file = tempfile.NamedTemporaryFile()
+
+        env = {'OUTDIR': outdir, 'DEBUGLOG': debug_log_file.name, 'INFOLOG': info_log_file.name}
+        p = subprocess.Popen([preproc_path]+subcmd, env=env, stdout=subprocess.PIPE)
         (stdout, stderr) = p.communicate()
+
+        info_log = info_log_file.read()
+        debug_log = debug_log_file.read()
+        if info_log:
+            log.info(info_log.strip())
+        if debug_log:
+            log.debug(debug_log.strip())
+        info_log_file.close()
+        debug_log_file.close()
+
         return stdout
     return invoke
 
 
-def preprocess(in_spec_path, out_spec_path):
+def preprocess(in_spec_path, out_spec_path, log):
     with open(in_spec_path, 'r') as f:
         in_spec_data = f.read()
         expr = nestedExpr('{{{', '}}}')
         expr.setParseAction(
-            invoke_wrapper(os.path.dirname(out_spec_path))
+            invoke_wrapper(os.path.dirname(out_spec_path), log)
         )
         out_spec_data = expr.transformString(in_spec_data)
         outf = open(out_spec_path, 'w')
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 1f7978b..610734f 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -6,8 +6,9 @@ function git_pack {
     declare name=$(git_name) version=$(git_version) "$@"
 
     dir_name=$name-$version
-    source_name=$(git_source_name name=$name name=$version)
-    $SCRIPTDIR/scripts/pack_sources $dir_name $OUTDIR/$source_name &> /dev/null
+    source_name=$(git_source_name name=$name version=$version)
+    $SCRIPTDIR/scripts/pack_sources.sh $dir_name $OUTDIR/$source_name > $DEBUGLOG
+    if [ $? -eq 0 ]; then echo "Wrote: $OUTDIR/$source_name" > $INFOLOG; fi
     echo -n $source_name
 }
 

From f7fc8dcd939486310165372c3b0000f951b976de Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 14/104] initialize spec_template


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 62a8ff3..08480a5 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -50,6 +50,7 @@ class Commands(pyrpkg.Commands):
             return
 
         files = os.listdir(self._specloc)
+        spec_template = None
 
         for f in files:
             if f.endswith('.spec') and not f.startswith('.'):

From 7cb6a2a0d640b6fde455e95d30fa53ee1c1e94f3 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 15/104] strip_at fix


---

diff --git a/rpkglib/utils.py b/rpkglib/utils.py
index c353ed5..e942a48 100644
--- a/rpkglib/utils.py
+++ b/rpkglib/utils.py
@@ -51,6 +51,6 @@ def changelog_get_line(message):
     return texwrap.wrap(re.sub('r(\s+)%([^%])', r'\1%%\2', msg_first_line), 80)
 
 
-def strip_at(self, string, strip_token):
+def strip_at(string, strip_token):
     return re.sub(r'(.*){}.*'.format(re.escape(strip_token)), r'\1', string)
 

From 6fe7595643c00e98d7c77d1afe2af94392c13345 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 16/104] added self.repo_spec, fixes in tagging


---

diff --git a/rpkg b/rpkg
index c33d92c..ca952fd 100755
--- a/rpkg
+++ b/rpkg
@@ -71,7 +71,7 @@ try:
 except KeyboardInterrupt:
     pass
 except Exception as e:
-    log.error('Could not execute %s: %s' %
+    log.error('Could not execute subcommand %s: %s' %
               (client.args.command.__name__, str(e)))
     if client.args.v:
         raise
diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 08480a5..9428ed9 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -27,6 +27,7 @@ class Commands(pyrpkg.Commands):
         self.lookaside_namespaced = True
         self._specloc = self.path
         self._ns_module_name = None
+        self._repo_spec = None
 
     def set_specloc(self, specloc):
         if not specloc:
@@ -43,10 +44,17 @@ class Commands(pyrpkg.Commands):
             "--define '_rpmdir %s'" % self.outdir,
         ]
 
+    @property
+    def repo_spec(self):
+        if not self._repo_spec:
+            self.load_spec()
+        return self._repo_spec
+
     def load_spec(self):
         """This sets the spec attribute"""
         if not os.path.isdir(self._specloc):
-            self._spec = self.preprocess_spec(self._specloc)
+            self._repo_spec = os.path.abspath(self._specloc)
+            self._spec = self.preprocess_spec(self._repo_spec)
             return
 
         files = os.listdir(self._specloc)
@@ -63,6 +71,7 @@ class Commands(pyrpkg.Commands):
         if not spec_template:
             raise rpkgError('No spec file found.')
 
+        self._repo_spec = spec_template
         self._spec = self.preprocess_spec(spec_template)
 
     @cached_property
@@ -318,8 +327,8 @@ class Commands(pyrpkg.Commands):
             self.git_tag(tagname, force, message, file)
             return
 
-        if self.repo.is_dirty(self.spec):
-            raise rpkgError('%s has uncommitted changes.' % self.spec)
+        if self.repo.is_dirty(path=self.repo_spec):
+            raise rpkgError('%s has uncommitted changes.' % self.repo_spec)
 
         ver = utils.strip_at(self.ver, ver_strip)
         rel = utils.strip_at(self.rel, rel_strip)
@@ -334,19 +343,19 @@ class Commands(pyrpkg.Commands):
         next_rel = rel
 
         if re.match(r'\d+', ver_parts[-1]):
-            next_ver = '{lead}.{last_part}'.format({
+            next_ver = '{lead}.{last_part}'.format(**{
                 'lead': '.'.join(ver_parts[:-1]),
-                'last_part': int(ver_parts[-1]) + 1
+                'last_part': (int(ver_parts[-1]) + 1)
             })
 
         if re.match(r'\d+', rel_parts[-1]):
-            next_rel = '{lead}.{last_part}'.format({
+            next_rel = '{lead}.{last_part}'.format(**{
                 'lead': '.'.join(rel_parts[:-1]),
-                'last_part': int(rel_parts[-1]) + 1
+                'last_part': (int(rel_parts[-1]) + 1)
             })
 
         if next_ver == ver and next_rel == rel:
-            tagname = tagname_template.format({
+            tagname = tagname_template.format(**{
                 'name': self.module_name,
                 'version': ver,
                 'release': rel,
@@ -354,7 +363,7 @@ class Commands(pyrpkg.Commands):
             self.git_tag(tagname, force, message, file)
             return
 
-        tagname = tagname_template.format({
+        tagname = tagname_template.format(**{
             'name': self.module_name,
             'version': next_ver,
             'release': next_rel,
@@ -362,6 +371,7 @@ class Commands(pyrpkg.Commands):
 
         self.git_tag(tagname, message='tmp', log_info=False)
         self.load_nameverrel()
+        self.del_tag(tagname)
 
         if utils.strip_at(self.ver, ver_strip) != next_ver:
             next_ver = ver
@@ -369,13 +379,12 @@ class Commands(pyrpkg.Commands):
         if utils.strip_at(self.rel, rel_strip) != next_rel:
             next_rel = rel
 
-        tagname = tagname_template.format({
+        tagname = tagname_template.format(**{
             'name': self.module_name,
             'version': next_ver,
             'release': next_rel,
         })
 
-        self.del_tag(tagname)
         self.git_tag(tagname, force, message, file)
 
     def del_tag(self, tagname):
@@ -384,8 +393,7 @@ class Commands(pyrpkg.Commands):
 
     def get_tag_message(self):
         tag_pattern = '{}*'.format(self.module_name)
-        tag_names = repo.git.tag('--list', '--merged',
-                                 '--sort=taggerdate', tag_pattern).split()
+        tag_names = self.repo.git.tag('--list', '--sort=taggerdate', tag_pattern, '--merged').split()
 
         if tag_names:
             rev_list_expr = '{}..HEAD'.format(tag_names[-1])

From e27732e358b96e2b2d20fbc12a16b1e9bf65349d Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 17/104] tagging editor fixed + code cleanup + git_changelog implemented


---

diff --git a/rpkg b/rpkg
index ca952fd..8b4e470 100755
--- a/rpkg
+++ b/rpkg
@@ -10,8 +10,6 @@
 # option) any later version.  See http://www.gnu.org/copyleft/gpl.html for
 # the full text of the license.
 
-import pyrpkg
-import pyrpkg.cli
 import pyrpkg.utils
 import os
 import sys
@@ -25,8 +23,7 @@ from os.path import expanduser
 parser = argparse.ArgumentParser(add_help=False)
 parser.add_argument('-C', '--config', help='Specify a config file to use. '
                     'If not specified, ~/.config/rpkg is used and if that '
-                    'does not exists, then /etc/rpkg.conf is tried.')
-
+                    'does not exists, then /etc/rpkg.conf is used.')
 (args, other) = parser.parse_known_args()
 
 config_to_use = '/etc/rpkg.conf'
@@ -65,14 +62,12 @@ elif client.args.q:
 else:
     log.setLevel(logging.INFO)
 
-# Run the necessary command
 try:
     client.args.command()
-except KeyboardInterrupt:
-    pass
 except Exception as e:
-    log.error('Could not execute subcommand %s: %s' %
-              (client.args.command.__name__, str(e)))
     if client.args.v:
         raise
-    sys.exit(1)
+    else:
+        log.error(str(e))
+except KeyboardInterrupt:
+    pass
diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
index ffb8354..ee91eab 100644
--- a/rpkg-client.spec.rpkg
+++ b/rpkg-client.spec.rpkg
@@ -88,6 +88,8 @@ cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
 %{_mandir}/*/*
 
 %changelog
+{{{ git_changelog }}}
+
 * Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
 - add LICENSE to ignored file regex
 
diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 9428ed9..5fd2176 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -47,32 +47,35 @@ class Commands(pyrpkg.Commands):
     @property
     def repo_spec(self):
         if not self._repo_spec:
-            self.load_spec()
+            self.load_repo_spec()
         return self._repo_spec
 
-    def load_spec(self):
-        """This sets the spec attribute"""
+    def load_repo_spec(self):
         if not os.path.isdir(self._specloc):
             self._repo_spec = os.path.abspath(self._specloc)
-            self._spec = self.preprocess_spec(self._repo_spec)
             return
 
         files = os.listdir(self._specloc)
-        spec_template = None
+        spec = None
 
         for f in files:
             if f.endswith('.spec') and not f.startswith('.'):
-                spec_template = os.path.abspath(os.path.join(self._specloc, f))
+                spec = os.path.abspath(os.path.join(self._specloc, f))
 
-        for f in files:
-            if f.endswith('.spec.rpkg') and not f.startswith('.'):
-                spec_template = os.path.abspath(os.path.join(self._specloc, f))
+        if self.preprocess:
+            for f in files:
+                if f.endswith('.spec.rpkg') and not f.startswith('.'):
+                    spec = os.path.abspath(os.path.join(self._specloc, f))
 
-        if not spec_template:
-            raise rpkgError('No spec file found.')
+        if not spec:
+            raise rpkgError('No spec file found at {}.'
+                            .format(self._specloc))
 
-        self._repo_spec = spec_template
-        self._spec = self.preprocess_spec(spec_template)
+        self._repo_spec = spec
+
+    def load_spec(self):
+        """This sets the spec attribute"""
+        self._spec = self.preprocess_spec(self.repo_spec)
 
     @cached_property
     def lookasidecache(self):
@@ -122,7 +125,8 @@ class Commands(pyrpkg.Commands):
         if not os.path.exists(self.sources_filename):
             return
 
-        sourcesf = SourcesFile(self.sources_filename, self.source_entry_type)
+        sourcesf = SourcesFile(
+            self.sources_filename, self.source_entry_type)
 
         for entry in sourcesf.entries:
             outfile = os.path.join(self.outdir, entry.file)
@@ -271,16 +275,16 @@ class Commands(pyrpkg.Commands):
         self.log.info('Wrote: {}'.format(target_source_path))
         return target_source_path
 
-    def preprocess_spec(self, spec_template):
+    def preprocess_spec(self, spec_templ):
         out_spec_basename = os.path.basename(
-            spec_template[:-5] if spec_template.endswith('.rpkg') else spec_template)
+            spec_templ[:-5] if spec_templ.endswith('.rpkg') else spec_templ)
 
         out_spec_path = os.path.join(self.outdir, out_spec_basename)
 
         if self.preprocess:
-            preprocess(spec_template, out_spec_path, self.log)
+            preprocess(spec_templ, out_spec_path, self.log)
         else:
-            shutil.copy(spec_template, out_spec_path)
+            shutil.copy(spec_templ, out_spec_path)
 
         self.log.info('Wrote: {}'.format(out_spec_path))
         return out_spec_path
@@ -293,22 +297,20 @@ class Commands(pyrpkg.Commands):
         return self._module_name_spec
 
     def git_tag(self, tagname, force=False, message=None, file=None, log_info=True):
+        cmd = ['git', 'tag', '-a']
+
         if not message and not file:
             message = self.get_tag_message()
 
-        cmd = ['git', 'tag']
-        cmd.extend(['-a'])
-        # force tag creation, if tag already exists
         if force:
             cmd.extend(['-f'])
-        # Description for the tag
         if message:
             cmd.extend(['-m', message])
         elif file:
             cmd.extend(['-F', os.path.abspath(file)])
+
         cmd.append(tagname)
-        # make it so
-        self._run_command(cmd, cwd=self.path)
+        utils.run_command(cmd, cwd=self.path)
 
         if log_info:
             self.log.info('Created tag: %s', tagname)
@@ -343,16 +345,10 @@ class Commands(pyrpkg.Commands):
         next_rel = rel
 
         if re.match(r'\d+', ver_parts[-1]):
-            next_ver = '{lead}.{last_part}'.format(**{
-                'lead': '.'.join(ver_parts[:-1]),
-                'last_part': (int(ver_parts[-1]) + 1)
-            })
+            next_ver = utils.increment_ver(ver_parts)
 
         if re.match(r'\d+', rel_parts[-1]):
-            next_rel = '{lead}.{last_part}'.format(**{
-                'lead': '.'.join(rel_parts[:-1]),
-                'last_part': (int(rel_parts[-1]) + 1)
-            })
+            next_rel = utils.increment_ver(rel_parts)
 
         if next_ver == ver and next_rel == rel:
             tagname = tagname_template.format(**{
@@ -370,6 +366,7 @@ class Commands(pyrpkg.Commands):
         })
 
         self.git_tag(tagname, message='tmp', log_info=False)
+        self.load_spec()
         self.load_nameverrel()
         self.del_tag(tagname)
 
@@ -384,16 +381,17 @@ class Commands(pyrpkg.Commands):
             'version': next_ver,
             'release': next_rel,
         })
-
         self.git_tag(tagname, force, message, file)
 
     def del_tag(self, tagname):
         cmd = ['git', 'tag', '-d', tagname]
-        self._run_command(cmd, cwd=self.path)
+        utils.run_command(cmd, cwd=self.path)
 
     def get_tag_message(self):
         tag_pattern = '{}*'.format(self.module_name)
-        tag_names = self.repo.git.tag('--list', '--sort=taggerdate', tag_pattern, '--merged').split()
+
+        tag_names = self.repo.git.tag(
+            '--list', '--sort=taggerdate', tag_pattern, '--merged').split()
 
         if tag_names:
             rev_list_expr = '{}..HEAD'.format(tag_names[-1])
@@ -403,10 +401,7 @@ class Commands(pyrpkg.Commands):
         message_lines = [utils.changelog_get_line(commit.message) for commit
                          in self.repo.iter_commits(rev_list_expr)]
 
-        with tempfile.NamedTemporaryFile() as f:
-            f.writelines(message_lines)
-            editor = self.repo.git.var('GIT_EDITOR')
-            subprocess.call([editor, f.name])
-            message = f.read()
-
-        return message
+        editor = self.repo.git.var('GIT_EDITOR')
+        subject = "Commits: {0}".format(rev_list_expr)
+        body = utils.edit(editor, message_lines)
+        return '{0}\n\n{1}'.format(subject, body)
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index eec1490..31b2c53 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -25,23 +25,14 @@ class rpkgClient(cliClient):
         """Setup the argument parser and register some basic commands."""
 
         self.parser = argparse.ArgumentParser(
-            prog=self.name,
-            epilog='For detailed help pass --help to a target')
-
-        # Add some basic arguments that should be used by all.
-        # Add a config file
-        self.parser.add_argument('--config', '-C',
-                                 default=None,
-                                 help='Specify a config file to use')
-        # Allow forcing the package name
+            prog=self.name, epilog='For detailed help pass --help to a target')
+
         self.parser.add_argument('--module-name',
                                  help='Override the module name. Otherwise'
                                       ' it is discovered from: Git push URL'
                                       ' or Git URL. ')
-        # Override the  discovered user name
         self.parser.add_argument('--user', default=None,
                                  help='Override the discovered user name')
-        # Let the user define a path to work in rather than cwd
         self.parser.add_argument('--path', default=None,
                                  type=utils.u,
                                  help='Define the directory to work in '
diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index d70613a..1ecb2fd 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -20,13 +20,16 @@ def invoke_wrapper(outdir, log):
 
         info_log = info_log_file.read()
         debug_log = debug_log_file.read()
+
         if info_log:
             log.info(info_log.strip())
         if debug_log:
             log.debug(debug_log.strip())
+        if stderr:
+            log.error(stderr)
+
         info_log_file.close()
         debug_log_file.close()
-
         return stdout
     return invoke
 
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 610734f..202f403 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -31,7 +31,7 @@ function git_name {
 function git_version {
     declare name=$(git_name) lead=0 follow= "$@"
 
-    if [ -z $name ]; then
+    if [ -z "$name" ]; then
         echo "git_version: name cannot be empty." > $ERRORLOG
         return 1
     fi
@@ -76,7 +76,26 @@ function git_source_name {
 }
 
 function git_changelog {
-    echo "foo"
+    declare name=$(git_name) since_tag= "$@"
+
+    mapfile -t tags < <(git tag --list --sort=taggerdate "$name-*" --merged)
+
+    changelog=
+    for tag in "${tags[@]}"; do
+        data=$(git tag -l $tag --format='%(body)')
+        if [ -z "$data" ]; then
+            continue
+        fi
+
+        verrel=$(echo $tag | sed -E -n "s/^$name-([^-]+-[^-]+)$/\1/p")
+        header="$(git tag -l $tag --format='* %(taggerdate) %(taggername) %(taggeremail)') $verrel"
+        changelog=${changelog}${header}$'\n'${data}
+
+        if [ "$since_tag" = "$tag" ]; then
+            break
+        fi
+    done
+    echo -n "$changelog"
 }
 
 ############## DIR FUNCTIONS ##############
diff --git a/rpkglib/utils.py b/rpkglib/utils.py
index e942a48..c24edf3 100644
--- a/rpkglib/utils.py
+++ b/rpkglib/utils.py
@@ -4,6 +4,10 @@ import re
 import shutil
 import tarfile
 import textwrap
+import subprocess
+import tempfile
+
+from pyrpkg.errors import rpkgError
 
 log = logging.getLogger("__main__")
 
@@ -47,10 +51,43 @@ def find_source_zero(rpm_sources):
 
 
 def changelog_get_line(message):
-    msg_first_line = '- ' + (message.split()[0] if message else '')
-    return texwrap.wrap(re.sub('r(\s+)%([^%])', r'\1%%\2', msg_first_line), 80)
+    msg_first_line = '- ' + (message.split('\n')[0] if message else '')
+    return '\n'.join(textwrap.wrap(re.sub('r(\s+)%([^%])', r'\1%%\2', msg_first_line), 80))
 
 
 def strip_at(string, strip_token):
     return re.sub(r'(.*){}.*'.format(re.escape(strip_token)), r'\1', string)
 
+
+def run_command(cmd, shell=False, env=None, cwd=None):
+    try:
+        output = subprocess.check_output(cmd, shell=shell, env=env, cwd=cwd)
+    except (subprocess.CalledProcessError, OSError) as e:
+        raise rpkgError(e)
+    except KeyboardInterrupt:
+        raise rpkgError('Command is terminated by user.')
+    except Exception as e:
+        raise rpkgError(e)
+    return output
+
+
+def edit(editor, lines):
+    data = '\n'.join(lines)
+    tmp_f = tempfile.NamedTemporaryFile('w', delete=False)
+    tmp_f.write(data)
+    tmp_f.close()
+    subprocess.check_call([editor, tmp_f.name])
+    tmp_f = open(tmp_f.name, 'r')
+    result = tmp_f.read()
+    tmp_f.close()
+    os.unlink(tmp_f.name)
+    return result
+
+
+def increment_ver(ver_parts):
+    ver_inc = str(int(ver_parts[-1])+1)
+    if ver_parts[:-1]:
+        lead_prefix = '.'.join(ver_parts[:-1]) + '.'
+    else:
+        lead_prefix = ""
+    return lead_prefix + ver_inc
diff --git a/tests/test_cli.py b/tests/test_cli.py
index fab3d81..7eb0703 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -126,6 +126,7 @@ class TestCli(base.TestCase):
         os.unlink(os.path.join(self.tmpdir, 'testpkg1-1-1.src.rpm'))
 
         self.client.cmd.set_specloc(spec2_path)
+        self.client.cmd.load_repo_spec()
         self.client.cmd.load_spec()
         self.client.srpm()
         self.assertItemsEqual(

From 624d398084b9d44f00a95739ccff2c2b07f1c06b Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 18/104] fix git_changelog date


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 202f403..52264e9 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -76,7 +76,7 @@ function git_source_name {
 }
 
 function git_changelog {
-    declare name=$(git_name) since_tag= "$@"
+    declare name=$(git_name) since_tag= locale=POSIX "$@"
 
     mapfile -t tags < <(git tag --list --sort=taggerdate "$name-*" --merged)
 
@@ -88,7 +88,7 @@ function git_changelog {
         fi
 
         verrel=$(echo $tag | sed -E -n "s/^$name-([^-]+-[^-]+)$/\1/p")
-        header="$(git tag -l $tag --format='* %(taggerdate) %(taggername) %(taggeremail)') $verrel"
+        header="$(LC_ALL=$locale git tag -l $tag --format='* %(taggerdate:format:%a %b %d %Y) %(taggername) %(taggeremail)') $verrel"
         changelog=${changelog}${header}$'\n'${data}
 
         if [ "$since_tag" = "$tag" ]; then

From e74d4a743ed772bc3a3ef82a95419a6b4b859ced Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 19/104] sort tags by unixdate, additional load_spec after tagging


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 5fd2176..8fd8eca 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -382,6 +382,7 @@ class Commands(pyrpkg.Commands):
             'release': next_rel,
         })
         self.git_tag(tagname, force, message, file)
+        self.load_spec()
 
     def del_tag(self, tagname):
         cmd = ['git', 'tag', '-d', tagname]
@@ -391,7 +392,8 @@ class Commands(pyrpkg.Commands):
         tag_pattern = '{}*'.format(self.module_name)
 
         tag_names = self.repo.git.tag(
-            '--list', '--sort=taggerdate', tag_pattern, '--merged').split()
+            '--list', '--sort=taggerdate:unix', tag_pattern,
+            '--merged').split()
 
         if tag_names:
             rev_list_expr = '{}..HEAD'.format(tag_names[-1])
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 52264e9..3a97f8c 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -41,7 +41,7 @@ function git_version {
         return 1
     fi
     
-    mapfile -t tags < <(git tag --list --sort=taggerdate "$name-$lead*" --merged)
+    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-$lead*" --merged)
 
     if [ ${#tags[@]} -gt 0 ]; then
         latest_tag=${tags[-1]}
@@ -78,7 +78,7 @@ function git_source_name {
 function git_changelog {
     declare name=$(git_name) since_tag= locale=POSIX "$@"
 
-    mapfile -t tags < <(git tag --list --sort=taggerdate "$name-*" --merged)
+    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-*" --merged)
 
     changelog=
     for tag in "${tags[@]}"; do

From 8b53a58031344c115ed5361018895267165efbee Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 20/104] added env, added latest function call caching, finished basics of git_ functions, no "artifacts" generated when not needed, renamed distgit config section to dist-git


---

diff --git a/rpkg.conf b/rpkg.conf
index f656c88..c599700 100644
--- a/rpkg.conf
+++ b/rpkg.conf
@@ -3,7 +3,7 @@ preprocess_spec = True
 # auto-packing is deprecated:
 auto_pack = True
 
-[distgit]
+[dist-git]
 lookaside = https://src.fedoraproject.org/repo/pkgs/%(ns1)s/%(pkg)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s
 lookaside_cgi = https://src.fedoraproject.org/repo/pkgs/upload.cgi
 gitbaseurl = ssh://%(user)s@pkgs.fedoraproject.org/%(module)s
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 31b2c53..703c083 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -94,7 +94,7 @@ class rpkgClient(cliClient):
         """This sets up the cmd object"""
 
         # load items from the config file
-        items = dict(self.config.items('distgit', raw=True))
+        items = dict(self.config.items('dist-git', raw=True))
 
         # Read comma separated list of kerberos realms
         realms = [realm
diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 1ecb2fd..3575fe6 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -7,17 +7,33 @@ from pyparsing import nestedExpr
 preproc_path = os.path.join(
     os.path.dirname(__file__), "preproc", "preproc.sh")
 
+STORED_ENV = ""
 
 def invoke_wrapper(outdir, log):
     def invoke(toks):
+        global STORED_ENV
+
         subcmd = list(toks[0])
         debug_log_file = tempfile.NamedTemporaryFile()
         info_log_file = tempfile.NamedTemporaryFile()
+        write_env_file = tempfile.NamedTemporaryFile()
+
+        env_store_file = tempfile.NamedTemporaryFile(delete=False)
+        env_store_file.write(STORED_ENV)
+        env_store_file.close()
 
-        env = {'OUTDIR': outdir, 'DEBUGLOG': debug_log_file.name, 'INFOLOG': info_log_file.name}
+        env = {
+            'OUTDIR': outdir,
+            'DEBUGLOG': debug_log_file.name,
+            'INFOLOG': info_log_file.name,
+            'ENVSTORE': env_store_file.name,
+        }
         p = subprocess.Popen([preproc_path]+subcmd, env=env, stdout=subprocess.PIPE)
         (stdout, stderr) = p.communicate()
 
+        env_store_file = open(env_store_file.name, 'r')
+        STORED_ENV = env_store_file.read()
+
         info_log = info_log_file.read()
         debug_log = debug_log_file.read()
 
@@ -30,18 +46,26 @@ def invoke_wrapper(outdir, log):
 
         info_log_file.close()
         debug_log_file.close()
+        env_store_file.close()
+        os.unlink(env_store_file.name)
         return stdout
     return invoke
 
 
-def preprocess(in_spec_path, out_spec_path, log):
+def preprocess(in_spec_path, out_spec_path, log, dump_spec_only=False):
+    if dump_spec_only:
+        outdir = ""
+    else:
+        outdir = os.path.dirname(out_spec_path)
+
     with open(in_spec_path, 'r') as f:
         in_spec_data = f.read()
         expr = nestedExpr('{{{', '}}}')
+
         expr.setParseAction(
-            invoke_wrapper(os.path.dirname(out_spec_path), log)
-        )
+            invoke_wrapper(outdir, log))
         out_spec_data = expr.transformString(in_spec_data)
+
         outf = open(out_spec_path, 'w')
         outf.write(out_spec_data)
         outf.close()
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 3a97f8c..3d5a295 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -1,26 +1,60 @@
 SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
+function cached {
+    if [ -n "${__cached[$1]}" ]; then
+        echo -n "${__cached[$1]}";
+        return
+    fi
+    "$@"
+}
+
 ############## REPO FUNCTIONS ##############
 
 function git_pack {
-    declare name=$(git_name) version=$(git_version) "$@"
+    declare name=$(cached git_name) version=$(cached git_version) source_name=$(cached git_source_name) "$@"
+
+    if [ -z "$OUTDIR" ]; then
+        echo "git_pack: OUTDIR is not set. No action taken." > $DEBUGLOG
+        echo -n "$source_name"
+        return
+    fi
 
-    dir_name=$name-$version
-    source_name=$(git_source_name name=$name version=$version)
-    $SCRIPTDIR/scripts/pack_sources.sh $dir_name $OUTDIR/$source_name > $DEBUGLOG
-    if [ $? -eq 0 ]; then echo "Wrote: $OUTDIR/$source_name" > $INFOLOG; fi
-    echo -n $source_name
+    $SCRIPTDIR/scripts/pack_sources.sh "$name-$version" "$OUTDIR/$source_name" > $DEBUGLOG
+
+    if [ $? -eq 0 ]; then
+        echo "git_pack: Wrote: $OUTDIR/$source_name"
+    else
+        echo "git_pack: Error during source creation."
+    fi > $INFOLOG
+
+    echo -n "$source_name"
 }
 
 function git_archive {
-    echo "foo"
+    declare name=$(cached git_name) version=$(cached git_version) source_name=$(cached git_source_name) "$@"
+
+    if [ -z "$OUTDIR" ]; then
+        echo "git_archive: OUTDIR is not set. No action taken." > $DEBUGLOG
+        echo -n "$source_name"
+        return
+    fi
+
+    git archive --prefix="$name-$version" -o "$OUTDIR/$source_name" HEAD: > $DEBUGLOG
+
+    if [ $? -eq 0 ]; then
+        echo "git_archive: Wrote: $OUTDIR/$source_name"
+    else
+        echo "git_archive: Error during source creation."
+    fi > $INFOLOG
+
+    echo -n "$source_name"
 }
 
 function git_name {
     url=$(git config --get remote.origin.url)
 
     if [ -z "$url" ]; then
-        echo "Start by setting origin URL." > $ERRORLOG
+        echo "git_name: Start by setting origin URL." > $ERRORLOG
         return 1
     fi
 
@@ -29,7 +63,7 @@ function git_name {
 }
 
 function git_version {
-    declare name=$(git_name) lead=0 follow= "$@"
+    declare name=$(cached git_name) lead=0 follow= "$@"
 
     if [ -z "$name" ]; then
         echo "git_version: name cannot be empty." > $ERRORLOG
@@ -37,7 +71,7 @@ function git_version {
     fi
 
     if echo $lead.$follow | grep -q '-'; then
-        echo "git_version: lead and follow cannot contains dashes." > $ERRORLOG
+        echo "git_version: lead and follow cannot contain dashes." > $ERRORLOG
         return 1
     fi
     
@@ -71,19 +105,26 @@ function git_version {
 }
 
 function git_source_name {
-    declare name=$(git_name) version=$(git_version) "$@"
-    echo -n "$name-$version.tar.gz"
+    declare name=$(cached git_name) version=$(cached git_version) format=tar.gz "$@"
+    echo -n "$name-$version.$format"
 }
 
 function git_changelog {
-    declare name=$(git_name) since_tag= locale=POSIX "$@"
+    declare name=$(cached git_name) since_tag= until_tag= locale=POSIX "$@"
 
     mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-*" --merged)
 
     changelog=
+    until_tag_hit=
     for tag in "${tags[@]}"; do
+        if [ -n "$until_tag" ] && [ -z "$until_tag_hit" ] && [ "$until_tag" != "$tag" ]; then
+            continue
+        fi
+        until_tag_hit="1"
+
         data=$(git tag -l $tag --format='%(body)')
         if [ -z "$data" ]; then
+            echo "Skipping $tag with empty body." > $DEBUGLOG
             continue
         fi
 
@@ -98,6 +139,11 @@ function git_changelog {
     echo -n "$changelog"
 }
 
+function git_setup_macro {
+    declare name=$(cached git_name) version=$(cached git_version) "$@"
+    echo -n "%setup -q -n $name-$version"
+}
+
 ############## DIR FUNCTIONS ##############
 
 function git_dir_pack {
diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index 4d12448..61aa5b3 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -1,11 +1,15 @@
 #!/bin/bash
+declare -Ax __cached
+source $ENVSTORE
 
-SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
+SCRIPTDIR="$(builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
 source $SCRIPTDIR/lib.sh
 
 if [ -f ./.rpkg.sh ]; then
     source ./.rpkg.sh
 fi
 
-"$@"
+__cached[$1]=$("$@")
+echo -n "${__cached[$1]}"
+
+declare -x > $ENVSTORE
diff --git a/rpkglib/preproc/scripts/pack_sources.sh b/rpkglib/preproc/scripts/pack_sources.sh
index fbb44ec..217825f 100755
--- a/rpkglib/preproc/scripts/pack_sources.sh
+++ b/rpkglib/preproc/scripts/pack_sources.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # creates a gzipped tarball out of the CWD content
 # to be used as a Source in a spec file.
@@ -9,8 +9,10 @@ Usage:
     $0 [--include-vcs] [--include-vcs-ignores] dir_name source_name
 
     Creates a compressed tarball out of the CWD content
-    to be used as a Source in a spec file. Uses tar
-    to do the job.
+    to be used as a Source0 in a spec file. Uses tar
+    to do the job. By default, omits any VCS-specific files
+    and dirs as well as files mentioned in a VCS-ignore
+    file.
 
 Options:
     -h, --help             Print help
@@ -58,12 +60,12 @@ if [ -z "$SOURCE_NAME" ] || [ -z "$DIR_NAME" ]; then
     exit -1
 fi
 
-if [ -f $SOURCE_NAME ]; then
+if [ -f "$SOURCE_NAME" ]; then
     echo "Source file already exists."
     exit 0
 fi
 
 ORIG_DIR_NAME=`basename $(pwd)`
-cd ..
+builtin cd ..
 
 tar caf $SOURCE_NAME $EXCLUDE_VCS $EXCLUDE_VCS_IGNORES --transform "s/^$ORIG_DIR_NAME/$DIR_NAME/" $ORIG_DIR_NAME
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 7eb0703..e8a5615 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -25,7 +25,7 @@ RPKG_CONFIG = """
 preprocess_spec = True
 auto_pack = True
 
-[distgit]
+[dist-git]
 lookaside = http://localhost/repo/pkgs/%(ns1)s/%(pkg)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s
 lookaside_cgi = https://localhost/repo/pkgs/upload.cgi
 gitbaseurl = ssh://%(user)s@localhost/%(module)s

From c51c0b1fdac39ce397fd4842e979fb099a11e29a Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 21/104] quoting + logging improvements + source creation tweak


---

diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 3575fe6..20acadc 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -1,71 +1,70 @@
 import os
 import subprocess
 import tempfile
+import re
 
 from pyparsing import nestedExpr
 
 preproc_path = os.path.join(
     os.path.dirname(__file__), "preproc", "preproc.sh")
 
-STORED_ENV = ""
 
-def invoke_wrapper(outdir, log):
-    def invoke(toks):
-        global STORED_ENV
+def log_line_strip(line):
+    return re.sub(r'(DEBUG|INFO|ERROR):\s*(.*)\s*', r'\2', line)
 
-        subcmd = list(toks[0])
-        debug_log_file = tempfile.NamedTemporaryFile()
-        info_log_file = tempfile.NamedTemporaryFile()
-        write_env_file = tempfile.NamedTemporaryFile()
 
-        env_store_file = tempfile.NamedTemporaryFile(delete=False)
-        env_store_file.write(STORED_ENV)
-        env_store_file.close()
+def invoke_wrapper(outdir, app_log, env_store_name):
+    def invoke(toks):
+        subcmd = list(toks[0])
 
         env = {
             'OUTDIR': outdir,
-            'DEBUGLOG': debug_log_file.name,
-            'INFOLOG': info_log_file.name,
-            'ENVSTORE': env_store_file.name,
+            'ENVSTORE': env_store_name,
         }
-        p = subprocess.Popen([preproc_path]+subcmd, env=env, stdout=subprocess.PIPE)
+        p = subprocess.Popen([preproc_path]+subcmd,
+                             env=env,
+                             stderr=subprocess.PIPE,
+                             stdout=subprocess.PIPE)
+
         (stdout, stderr) = p.communicate()
 
-        env_store_file = open(env_store_file.name, 'r')
-        STORED_ENV = env_store_file.read()
+        for line in stderr.split('\n'):
+            if not line:
+                continue
 
-        info_log = info_log_file.read()
-        debug_log = debug_log_file.read()
+            if line.startswith('DEBUG:'):
+                log_func = app_log.debug
+            elif line.startswith('INFO:'):
+                log_func = app_log.info
+            else:
+                log_func = app_log.error
 
-        if info_log:
-            log.info(info_log.strip())
-        if debug_log:
-            log.debug(debug_log.strip())
-        if stderr:
-            log.error(stderr)
+            stripped_line = log_line_strip(line)
+            log_func(stripped_line)
 
-        info_log_file.close()
-        debug_log_file.close()
-        env_store_file.close()
-        os.unlink(env_store_file.name)
         return stdout
     return invoke
 
 
-def preprocess(in_spec_path, out_spec_path, log, dump_spec_only=False):
+def preprocess(in_spec_path, out_spec_path, app_log, dump_spec_only=False):
     if dump_spec_only:
         outdir = ""
     else:
         outdir = os.path.dirname(out_spec_path)
 
+    env_store_file = tempfile.NamedTemporaryFile(delete=False)
+
     with open(in_spec_path, 'r') as f:
         in_spec_data = f.read()
         expr = nestedExpr('{{{', '}}}')
 
         expr.setParseAction(
-            invoke_wrapper(outdir, log))
-        out_spec_data = expr.transformString(in_spec_data)
+            invoke_wrapper(outdir, app_log, env_store_file.name))
 
+        out_spec_data = expr.transformString(in_spec_data)
         outf = open(out_spec_path, 'w')
         outf.write(out_spec_data)
         outf.close()
+
+    env_store_file.close()
+    os.unlink(env_store_file.name)
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 3d5a295..f618496 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -1,5 +1,11 @@
 SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
+############## HELPER FUNCTIONS ##############
+
+function output {
+    echo -n "$@"
+}
+
 function cached {
     if [ -n "${__cached[$1]}" ]; then
         echo -n "${__cached[$1]}";
@@ -8,109 +14,137 @@ function cached {
     "$@"
 }
 
+function log_debug {
+    echo "DEBUG: ${FUNCNAME[1]}: $@" > /dev/stderr
+}
+
+function log_info {
+    echo "INFO: ${FUNCNAME[1]}: $@" > /dev/stderr
+}
+
+function log_error {
+    echo "ERROR: ${FUNCNAME[1]}: $@" > /dev/stderr
+}
+
 ############## REPO FUNCTIONS ##############
 
 function git_pack {
-    declare name=$(cached git_name) version=$(cached git_version) source_name=$(cached git_source_name) "$@"
+    declare name="$(cached git_name)" version="$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
 
     if [ -z "$OUTDIR" ]; then
-        echo "git_pack: OUTDIR is not set. No action taken." > $DEBUGLOG
-        echo -n "$source_name"
+        log_debug "OUTDIR is not set. No action taken."
+        output "$source_name"
+        return
+    fi
+
+    if [ -f "$OUTDIR/$source_name" ] && [ -z "$force" ]; then
+        log_debug "Source file already exists. No action taken."
+        output "$source_name"
         return
     fi
 
-    $SCRIPTDIR/scripts/pack_sources.sh "$name-$version" "$OUTDIR/$source_name" > $DEBUGLOG
+    cmd_stdout="$($SCRIPTDIR/scripts/pack_sources.sh "$name-$version" "$OUTDIR/$source_name")"
+    cmd_retcode=$?
 
-    if [ $? -eq 0 ]; then
-        echo "git_pack: Wrote: $OUTDIR/$source_name"
+    log_debug "$cmd_stdout"
+
+    if [ $cmd_retcode -eq 0 ]; then
+        log_info "Wrote: $OUTDIR/$source_name"
     else
-        echo "git_pack: Error during source creation."
-    fi > $INFOLOG
+        log_error "Error during source creation."
+    fi
 
-    echo -n "$source_name"
+    output "$source_name"
 }
 
 function git_archive {
-    declare name=$(cached git_name) version=$(cached git_version) source_name=$(cached git_source_name) "$@"
+    declare name="$(cached git_name)" version="$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
 
     if [ -z "$OUTDIR" ]; then
-        echo "git_archive: OUTDIR is not set. No action taken." > $DEBUGLOG
-        echo -n "$source_name"
+        log_debug "OUTDIR is not set. No action taken."
+        output "$source_name"
         return
     fi
 
-    git archive --prefix="$name-$version" -o "$OUTDIR/$source_name" HEAD: > $DEBUGLOG
+    if [ -f "$OUTDIR/$source_name" ] && [ -z "$force" ]; then
+        log_debug "Source file already exists. No action taken."
+        output "$source_name"
+        return
+    fi
+
+    cmd_stdout="$(git archive --prefix="$name-$version" -o "$OUTDIR/$source_name" HEAD:)"
+    cmd_retcode=$?
 
     if [ $? -eq 0 ]; then
-        echo "git_archive: Wrote: $OUTDIR/$source_name"
+        log_info "Wrote: $OUTDIR/$source_name"
     else
-        echo "git_archive: Error during source creation."
-    fi > $INFOLOG
+        log_error "Error during source creation."
+    fi
 
-    echo -n "$source_name"
+    output "$source_name"
 }
 
 function git_name {
-    url=$(git config --get remote.origin.url)
+    url="$(git config --get remote.origin.url)"
 
     if [ -z "$url" ]; then
-        echo "git_name: Start by setting origin URL." > $ERRORLOG
+        log_error "Start by setting origin URL."
         return 1
     fi
 
-    url_last_part=$(basename $url)
-    echo -n "${url_last_part%.git}"
+    url_last_part="$(basename $url)"
+    output "${url_last_part%.git}"
 }
 
 function git_version {
-    declare name=$(cached git_name) lead=0 follow= "$@"
+    declare name="$(cached git_name)" lead=0 follow= "$@"
 
     if [ -z "$name" ]; then
-        echo "git_version: name cannot be empty." > $ERRORLOG
+        log_error "name cannot be empty."
         return 1
     fi
 
-    if echo $lead.$follow | grep -q '-'; then
-        echo "git_version: lead and follow cannot contain dashes." > $ERRORLOG
+    if echo "$lead.$follow" | grep -q '-'; then
+        log_error "lead and follow cannot contain dashes."
         return 1
     fi
     
     mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-$lead*" --merged)
 
     if [ ${#tags[@]} -gt 0 ]; then
-        latest_tag=${tags[-1]}
-        latest_tag_version=$(echo $latest_tag | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1/p")
+        latest_tag="${tags[-1]}"
+        latest_tag_version="$(echo $latest_tag | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1/p")"
     else
         latest_tag=
-        latest_tag_version=${lead}.0
+        latest_tag_version="${lead}.0"
     fi
 
     if [ -n "$latest_tag" ]; then
-        commit_count=$(git rev-list $latest_tag..HEAD --count)
+        commit_count="$(git rev-list $latest_tag..HEAD --count)"
     else
-        commit_count=$(git rev-list HEAD --count 2> /dev/null || printf 0)
+        commit_count="$(git rev-list HEAD --count 2> /dev/null || printf 0)"
     fi
 
     if [ $commit_count -eq 0 ]; then
         commit_count_appendix=
     else
-        commit_count_appendix=.git.$commit_count.$(git rev-list HEAD --max-count=1 | cut -c -8)
+        commit_count_appendix=".git.$commit_count.$(git rev-list HEAD --max-count=1 | cut -c -8)"
     fi
 
     if [ -n "$follow" ]; then
-        echo -n ${lead}.${follow}${commit_count_appendix}
+        output "${lead}.${follow}${commit_count_appendix}"
     else
-        echo -n ${latest_tag_version}${commit_count_appendix}
+        output "${latest_tag_version}${commit_count_appendix}"
     fi
 }
 
 function git_source_name {
-    declare name=$(cached git_name) version=$(cached git_version) format=tar.gz "$@"
-    echo -n "$name-$version.$format"
+    declare name="$(cached git_name)" version="$(cached git_version)" format=tar.gz "$@"
+    output "$name-$version.$format"
 }
 
 function git_changelog {
-    declare name=$(cached git_name) since_tag= until_tag= locale=POSIX "$@"
+    declare name="$(cached git_name)" since_tag= until_tag= locale=POSIX "$@"
 
     mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-*" --merged)
 
@@ -122,26 +156,27 @@ function git_changelog {
         fi
         until_tag_hit="1"
 
-        data=$(git tag -l $tag --format='%(body)')
+        data="$(git tag -l $tag --format='%(body)')"
         if [ -z "$data" ]; then
-            echo "Skipping $tag with empty body." > $DEBUGLOG
+            log_debug "Skipping $tag with empty body."
             continue
         fi
 
-        verrel=$(echo $tag | sed -E -n "s/^$name-([^-]+-[^-]+)$/\1/p")
+        verrel="$(echo $tag | sed -E -n "s/^$name-([^-]+-[^-]+)$/\1/p")"
         header="$(LC_ALL=$locale git tag -l $tag --format='* %(taggerdate:format:%a %b %d %Y) %(taggername) %(taggeremail)') $verrel"
-        changelog=${changelog}${header}$'\n'${data}
+        changelog="${changelog}${header}$'\n'${data}"
 
         if [ "$since_tag" = "$tag" ]; then
             break
         fi
     done
-    echo -n "$changelog"
+
+    output "$changelog"
 }
 
 function git_setup_macro {
-    declare name=$(cached git_name) version=$(cached git_version) "$@"
-    echo -n "%setup -q -n $name-$version"
+    declare name="$(cached git_name)" version="$(cached git_version)" "$@"
+    output "%setup -q -n $name-$version"
 }
 
 ############## DIR FUNCTIONS ##############
diff --git a/rpkglib/preproc/scripts/pack_sources.sh b/rpkglib/preproc/scripts/pack_sources.sh
index 217825f..275979f 100755
--- a/rpkglib/preproc/scripts/pack_sources.sh
+++ b/rpkglib/preproc/scripts/pack_sources.sh
@@ -60,11 +60,6 @@ if [ -z "$SOURCE_NAME" ] || [ -z "$DIR_NAME" ]; then
     exit -1
 fi
 
-if [ -f "$SOURCE_NAME" ]; then
-    echo "Source file already exists."
-    exit 0
-fi
-
 ORIG_DIR_NAME=`basename $(pwd)`
 builtin cd ..
 

From fba584134207c527f97c481649f11317f9dff4d8 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 22/104] fixed source generation, further improvements in logging


---

diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
index ee91eab..25f6d50 100644
--- a/rpkg-client.spec.rpkg
+++ b/rpkg-client.spec.rpkg
@@ -1,6 +1,6 @@
 # vim: syntax=spec
 Name: {{{ git_name }}}
-Version: {{{ git_version }}}
+Version: {{{ git_version lead=1 }}}
 Release: 1%{?dist}
 Summary: RPM packaging utitility
 License: GPLv2+
diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 8fd8eca..5dd4a23 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -21,6 +21,7 @@ class Commands(pyrpkg.Commands):
         """Init the object and some configuration details."""
         self.outdir = kwargs.pop("outdir")
         self.preprocess = kwargs.pop("preprocess")
+        self.dump_spec_only = False
         super(Commands, self).__init__(*args, **kwargs)
         self.source_entry_type = 'bsd'
         self.distgit_namespaced = True
@@ -282,7 +283,8 @@ class Commands(pyrpkg.Commands):
         out_spec_path = os.path.join(self.outdir, out_spec_basename)
 
         if self.preprocess:
-            preprocess(spec_templ, out_spec_path, self.log)
+            preprocess(self.path, spec_templ, out_spec_path,
+                       self.log, self.dump_spec_only)
         else:
             shutil.copy(spec_templ, out_spec_path)
 
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 703c083..1127e13 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -186,6 +186,7 @@ class rpkgClient(cliClient):
         return self.cmd.srpm()
 
     def spec(self):
+        self.cmd.dump_spec_only = True
         self.cmd.set_specloc(self.args.spec)
         self.cmd.load_spec()
 
diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 20acadc..c22c757 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -13,7 +13,7 @@ def log_line_strip(line):
     return re.sub(r'(DEBUG|INFO|ERROR):\s*(.*)\s*', r'\2', line)
 
 
-def invoke_wrapper(outdir, app_log, env_store_name):
+def invoke_wrapper(path, outdir, app_log, env_store_name):
     def invoke(toks):
         subcmd = list(toks[0])
 
@@ -22,7 +22,7 @@ def invoke_wrapper(outdir, app_log, env_store_name):
             'ENVSTORE': env_store_name,
         }
         p = subprocess.Popen([preproc_path]+subcmd,
-                             env=env,
+                             env=env, cwd=path,
                              stderr=subprocess.PIPE,
                              stdout=subprocess.PIPE)
 
@@ -46,7 +46,7 @@ def invoke_wrapper(outdir, app_log, env_store_name):
     return invoke
 
 
-def preprocess(in_spec_path, out_spec_path, app_log, dump_spec_only=False):
+def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False):
     if dump_spec_only:
         outdir = ""
     else:
@@ -59,7 +59,7 @@ def preprocess(in_spec_path, out_spec_path, app_log, dump_spec_only=False):
         expr = nestedExpr('{{{', '}}}')
 
         expr.setParseAction(
-            invoke_wrapper(outdir, app_log, env_store_file.name))
+            invoke_wrapper(path, outdir, app_log, env_store_file.name))
 
         out_spec_data = expr.transformString(in_spec_data)
         outf = open(out_spec_path, 'w')
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index f618496..ce8f846 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -8,28 +8,40 @@ function output {
 
 function cached {
     if [ -n "${__cached[$1]}" ]; then
-        echo -n "${__cached[$1]}";
+        echo -n "${__cached[$1]}"
         return
     fi
     "$@"
 }
 
 function log_debug {
-    echo "DEBUG: ${FUNCNAME[1]}: $@" > /dev/stderr
+    log "DEBUG" "$@"
 }
 
 function log_info {
-    echo "INFO: ${FUNCNAME[1]}: $@" > /dev/stderr
+    log "INFO" "$@"
 }
 
 function log_error {
-    echo "ERROR: ${FUNCNAME[1]}: $@" > /dev/stderr
+    log "ERROR" "$@"
+}
+
+function log {
+    PREFIX=$1
+    shift
+
+    regexp="^\s*$"
+    if [[ "$*" =~ $regexp ]]; then
+        return
+    fi
+
+    echo "$PREFIX: ${FUNCNAME[-2]}: $@" > /dev/stderr
 }
 
 ############## REPO FUNCTIONS ##############
 
 function git_pack {
-    declare name="$(cached git_name)" version="$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
+    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
 
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
@@ -43,7 +55,7 @@ function git_pack {
         return
     fi
 
-    cmd_stdout="$($SCRIPTDIR/scripts/pack_sources.sh "$name-$version" "$OUTDIR/$source_name")"
+    cmd_stdout="$($SCRIPTDIR/scripts/pack_sources.sh "$path" "$dir_name" "$OUTDIR/$source_name")"
     cmd_retcode=$?
 
     log_debug "$cmd_stdout"
@@ -58,7 +70,7 @@ function git_pack {
 }
 
 function git_archive {
-    declare name="$(cached git_name)" version="$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
+    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
 
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
@@ -72,10 +84,12 @@ function git_archive {
         return
     fi
 
-    cmd_stdout="$(git archive --prefix="$name-$version" -o "$OUTDIR/$source_name" HEAD:)"
+    cmd_stdout="$(git -C "$path" archive --prefix="$dir_name/" -o "$OUTDIR/$source_name" HEAD)"
     cmd_retcode=$?
 
-    if [ $? -eq 0 ]; then
+    log_debug "$cmd_stdout"
+
+    if [ $cmd_retcode -eq 0 ]; then
         log_info "Wrote: $OUTDIR/$source_name"
     else
         log_error "Error during source creation."
@@ -85,6 +99,13 @@ function git_archive {
 }
 
 function git_name {
+    declare name= "$@"
+
+    if [ -n "$name" ]; then
+        output "$name"
+        return
+    fi
+
     url="$(git config --get remote.origin.url)"
 
     if [ -z "$url" ]; then
@@ -175,8 +196,8 @@ function git_changelog {
 }
 
 function git_setup_macro {
-    declare name="$(cached git_name)" version="$(cached git_version)" "$@"
-    output "%setup -q -n $name-$version"
+    declare dir_name="$(cached git_name)-$(cached git_version)" "$@"
+    output "%setup -q -n $dir_name"
 }
 
 ############## DIR FUNCTIONS ##############
diff --git a/rpkglib/preproc/scripts/pack_sources.sh b/rpkglib/preproc/scripts/pack_sources.sh
index 275979f..953bd91 100755
--- a/rpkglib/preproc/scripts/pack_sources.sh
+++ b/rpkglib/preproc/scripts/pack_sources.sh
@@ -1,30 +1,30 @@
 #!/bin/bash
 
-# creates a gzipped tarball out of the CWD content
-# to be used as a Source in a spec file.
+# Creates a tarball out of content at the specified directory path.
 
 usage() {
     cat <<EOF
 Usage:
-    $0 [--include-vcs] [--include-vcs-ignores] dir_name source_name
+    $0 [--include-vcs] [--include-vcs-ignores] path dir_name source_name
 
-    Creates a compressed tarball out of the CWD content
-    to be used as a Source0 in a spec file. Uses tar
-    to do the job. By default, omits any VCS-specific files
-    and dirs as well as files mentioned in a VCS-ignore
-    file.
+    Creates a compressed tarball out of the
+    specified path content. Uses tar to do the job.
+    By default, omits any VCS-specific files
+    as well as files mentioned in a VCS-ignore file.
 
 Options:
     -h, --help             Print help
     --include-vcs          Include version control system directories. By default excluded.
-    --include-vcs-ignores  Include files that match patterns read from VCS-specific ignore files. By default excluded.
+    --include-vcs-ignores  Include files that match patterns present in VCS-specific ignore file. By default excluded.
 
 Arguments:
+    path                   Path to the content that should be packed.
     dir_name               Name of the directory in the created tarball.
     source_name            Name of the resulting tarball file.
 EOF
 }
 
+CONTENT_PATH=""
 DIR_NAME=""
 SOURCE_NAME=""
 EXCLUDE_VCS="--exclude-vcs"
@@ -36,10 +36,6 @@ while [ -n "$1" ] ; do
         usage
         exit 0
         ;;
-    -d|--dirname)
-        DIR_NAME="$1"
-        shift
-        ;;
     --include-vcs)
         EXCLUDE_VCS=""
         ;;
@@ -47,6 +43,8 @@ while [ -n "$1" ] ; do
         EXCLUDE_VCS_IGNORES=""
         ;;
     *)
+        CONTENT_PATH="$1"
+        shift
         DIR_NAME="$1"
         shift
         SOURCE_NAME="$1"
@@ -55,12 +53,9 @@ while [ -n "$1" ] ; do
     shift
 done
 
-if [ -z "$SOURCE_NAME" ] || [ -z "$DIR_NAME" ]; then
+if [ -z "$CONTENT_PATH" ] || [ -z "$SOURCE_NAME" ] || [ -z "$DIR_NAME" ]; then
     usage
     exit -1
 fi
 
-ORIG_DIR_NAME=`basename $(pwd)`
-builtin cd ..
-
-tar caf $SOURCE_NAME $EXCLUDE_VCS $EXCLUDE_VCS_IGNORES --transform "s/^$ORIG_DIR_NAME/$DIR_NAME/" $ORIG_DIR_NAME
+tar caf "$SOURCE_NAME" -C "$CONTENT_PATH" "$EXCLUDE_VCS" "$EXCLUDE_VCS_IGNORES" --transform "s|^|$DIR_NAME/|" .

From d2ffe6a393b5b77f9ef5d80498b4d9741041cba3 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 23/104] basic implementation of git_dir_* and git_cwd_* function families


---

diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index c22c757..850fca6 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -13,12 +13,13 @@ def log_line_strip(line):
     return re.sub(r'(DEBUG|INFO|ERROR):\s*(.*)\s*', r'\2', line)
 
 
-def invoke_wrapper(path, outdir, app_log, env_store_name):
+def invoke_wrapper(path, in_spec_path, outdir, app_log, env_store_name):
     def invoke(toks):
         subcmd = list(toks[0])
 
         env = {
             'OUTDIR': outdir,
+            'SPECPATH': in_spec_path,
             'ENVSTORE': env_store_name,
         }
         p = subprocess.Popen([preproc_path]+subcmd,
@@ -59,7 +60,7 @@ def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False)
         expr = nestedExpr('{{{', '}}}')
 
         expr.setParseAction(
-            invoke_wrapper(path, outdir, app_log, env_store_file.name))
+            invoke_wrapper(path, in_spec_path, outdir, app_log, env_store_file.name))
 
         out_spec_data = expr.transformString(in_spec_data)
         outf = open(out_spec_path, 'w')
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index ce8f846..7584907 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -203,25 +203,59 @@ function git_setup_macro {
 ############## DIR FUNCTIONS ##############
 
 function git_dir_pack {
-    echo "foo"
+    git_pack path="$(dirname $SPECPATH)" dir_name="$(cached git_dir_name)-$(cached git_dir_version)" source_name="$(cached git_dir_source_name)" "$@"
 }
 
 function git_dir_achive {
-    echo "foo"
+    git_archive path="$(dirname $SPECPATH)" dir_name="$(cached git_dir_name)-$(cached git_dir_version)" source_name="$(cached git_dir_source_name)" "$@"
 }
 
 function git_dir_name {
-    echo "foo"
+    git_name name="$(basename $(dirname $SPECPATH))" "$@"
 }
 
 function git_dir_source_name {
-    echo "foo"
+    git_source_name name="$(cached git_dir_name)" version="$(cached git_dir_version)" "$@"
 }
 
 function git_dir_version {
-    echo "foo"
+    git_version name="$(cached git_dir_name)" "$@"
 }
 
 function git_dir_changelog {
-    echo "foo"
+    git_changelog name="$(cached git_dir_name)" "$@"
+}
+
+function git_dir_setup_macro {
+    git_setup_macro dir_name="$(cached git_dir_name)-$(cached git_dir_version)" "$@"
+}
+
+############## CURRENT WORKING DIR FUNCTIONS ##############
+
+function git_cwd_pack {
+    git_pack path="$(pwd)" dir_name="$(cached git_cwd_name)-$(cached git_cwd_version)" source_name="$(cached git_cwd_source_name)" "$@"
+}
+
+function git_cwd_achive {
+    git_archive path="$(pwd)" dir_name="$(cached git_cwd_name)-$(cached git_cwd_version)" source_name="$(cached git_cwd_source_name)" "$@"
+}
+
+function git_cwd_name {
+    git_name name="$(basename $(pwd))" "$@"
+}
+
+function git_cwd_source_name {
+    git_source_name name="$(cached git_cwd_name)" version="$(cached git_cwd_version)" "$@"
+}
+
+function git_cwd_version {
+    git_version name="$(cached git_cwd_name)" "$@"
+}
+
+function git_cwd_changelog {
+    git_changelog name="$(cached git_cwd_name)" "$@"
+}
+
+function git_cwd_setup_macro {
+    git_setup_macro dir_name="$(cached git_cwd_name)-$(cached git_cwd_version)" "$@"
 }

From 29a44f532f60ffe258afa4e467e73bc5df5840ca Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 24/104] add --sources param for spec subcommand


---

diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 1127e13..d452df8 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -126,7 +126,7 @@ class rpkgClient(cliClient):
 
     def register_make_source(self):
         make_source_parser = self.subparsers.add_parser(
-            'make-source', help='Create Source0 from the '
+            'make-source', help='Deprecated. Create Source0 from the '
             'content of the current working directory '
             'after downloading any external sources. '
             'The content must be of unpacked type.',
@@ -178,15 +178,17 @@ class rpkgClient(cliClient):
         self.cmd.sources()
         self.cmd.set_specloc(self.args.spec)
         if self.config['rpkg'].getboolean('auto_pack', False):
-            print('Auto-packing is deprecated and will be removed in a future release.', file=sys.stderr)
             try:
                 self.cmd.make_source()
             except NotUnpackedException:
                 pass
+            else:
+                print('Auto-packing is deprecated and will be removed in a future release.', file=sys.stderr)
         return self.cmd.srpm()
 
     def spec(self):
-        self.cmd.dump_spec_only = True
+        if not self.args.sources:
+            self.cmd.dump_spec_only = True
         self.cmd.set_specloc(self.args.spec)
         self.cmd.load_spec()
 
@@ -225,10 +227,16 @@ class rpkgClient(cliClient):
             '--spec', action='store', default=None,
             help='An input spec template. If not given, '
             'the spec template is auto-located in path as a '
-            'file ending with ".spec.rpkg" or ".spec" suffix.')
+            'file ending with ".spec.rpkg" or ".spec" suffix '
+            'in this order.')
+        spec_parser.add_argument(
+            '--sources', action='store', default=False,
+            help='Enable source generation by the input '
+            'spec template. By default disabled.')
         spec_parser.add_argument(
             '--outdir', default=DEFAULT_OUTDIR,
-            help='Where to put the generated spec file.')
+            help='Where to put the generated spec file '
+            'and sources if any.')
         spec_parser.set_defaults(command=self.spec)
 
     def register_srpm(self):
@@ -252,7 +260,7 @@ class rpkgClient(cliClient):
     def register_is_packed(self):
         """Determine whether the package content is packed or not"""
         is_packed_parser = self.subparsers.add_parser(
-            'is-packed', help='Tell user whether content is packed',
+            'is-packed', help='Deprecated. Tell user whether content is packed',
             description='Determine whether the package content '
             'in the working directory is packed or unpacked '
             'and print that information to the screen.')

From 5a7959409e9729bada2696a596a6b6f2fc9a5ab9 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 25/104] fix in numeric version check in add_tag


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 5dd4a23..6525be7 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -346,10 +346,10 @@ class Commands(pyrpkg.Commands):
         next_ver = ver
         next_rel = rel
 
-        if re.match(r'\d+', ver_parts[-1]):
+        if re.match(r'^\d+$', ver_parts[-1]):
             next_ver = utils.increment_ver(ver_parts)
 
-        if re.match(r'\d+', rel_parts[-1]):
+        if re.match(r'^\d+$', rel_parts[-1]):
             next_rel = utils.increment_ver(rel_parts)
 
         if next_ver == ver and next_rel == rel:

From 08af94e3dbb1f2790e35273267fe929632d803c7 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 26/104] add debug messages, do not dump sources on tagging


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 6525be7..e0f88f7 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -373,9 +373,11 @@ class Commands(pyrpkg.Commands):
         self.del_tag(tagname)
 
         if utils.strip_at(self.ver, ver_strip) != next_ver:
+            self.log.debug('Spec does not follow version in the latest tag. Reverting.')
             next_ver = ver
 
         if utils.strip_at(self.rel, rel_strip) != next_rel:
+            self.log.debug('Spec does not follow release in the latest tag. Reverting.')
             next_rel = rel
 
         tagname = tagname_template.format(**{
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index d452df8..17d357f 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -155,6 +155,7 @@ class rpkgClient(cliClient):
         make_source_parser.set_defaults(command=self.make_source)
 
     def tag(self):
+        self.cmd.dump_spec_only = True
         self.cmd._rpmdefines = self.cmd.rpmdefines + ["--define 'dist %nil'"]
         if self.args.list:
             self.cmd.list_tag(self.args.tag)

From 9d5c56046090e4df089548b51bdbc5a3b6a7d226 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 27/104] fix quoting in git_changelog


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 7584907..3ff54f0 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -185,7 +185,7 @@ function git_changelog {
 
         verrel="$(echo $tag | sed -E -n "s/^$name-([^-]+-[^-]+)$/\1/p")"
         header="$(LC_ALL=$locale git tag -l $tag --format='* %(taggerdate:format:%a %b %d %Y) %(taggername) %(taggeremail)') $verrel"
-        changelog="${changelog}${header}$'\n'${data}"
+        changelog="${changelog}${header}"$'\n'"${data}"
 
         if [ "$since_tag" = "$tag" ]; then
             break

From a99d8a45c89c19b5ab7cdd54b6d9cb4ced4c73ad Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 28/104] fix silent logging


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index e0f88f7..ba3d342 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -74,9 +74,9 @@ class Commands(pyrpkg.Commands):
 
         self._repo_spec = spec
 
-    def load_spec(self):
+    def load_spec(self, silent=False):
         """This sets the spec attribute"""
-        self._spec = self.preprocess_spec(self.repo_spec)
+        self._spec = self.preprocess_spec(self.repo_spec, silent)
 
     @cached_property
     def lookasidecache(self):
@@ -276,7 +276,7 @@ class Commands(pyrpkg.Commands):
         self.log.info('Wrote: {}'.format(target_source_path))
         return target_source_path
 
-    def preprocess_spec(self, spec_templ):
+    def preprocess_spec(self, spec_templ, silent=False):
         out_spec_basename = os.path.basename(
             spec_templ[:-5] if spec_templ.endswith('.rpkg') else spec_templ)
 
@@ -288,7 +288,8 @@ class Commands(pyrpkg.Commands):
         else:
             shutil.copy(spec_templ, out_spec_path)
 
-        self.log.info('Wrote: {}'.format(out_spec_path))
+        log_func = self.log.debug if silent else self.log.info
+        log_func('Wrote: {}'.format(out_spec_path))
         return out_spec_path
 
     @property
@@ -298,7 +299,7 @@ class Commands(pyrpkg.Commands):
             self.load_nameverrel()
         return self._module_name_spec
 
-    def git_tag(self, tagname, force=False, message=None, file=None, log_info=True):
+    def git_tag(self, tagname, force=False, message=None, file=None, silent=False):
         cmd = ['git', 'tag', '-a']
 
         if not message and not file:
@@ -314,8 +315,8 @@ class Commands(pyrpkg.Commands):
         cmd.append(tagname)
         utils.run_command(cmd, cwd=self.path)
 
-        if log_info:
-            self.log.info('Created tag: %s', tagname)
+        log_func = self.log.debug if silent else self.log.info
+        log_func('Created tag: %s', tagname)
 
     def add_tag(self, tagname=None, force=False, message=None, file=None, ver_strip=".git.", rel_strip=".git."):
         """Add a git tag to the repository
@@ -334,6 +335,7 @@ class Commands(pyrpkg.Commands):
         if self.repo.is_dirty(path=self.repo_spec):
             raise rpkgError('%s has uncommitted changes.' % self.repo_spec)
 
+        self.load_spec(silent=True)
         ver = utils.strip_at(self.ver, ver_strip)
         rel = utils.strip_at(self.rel, rel_strip)
         ver_parts = ver.split('.')
@@ -367,8 +369,8 @@ class Commands(pyrpkg.Commands):
             'release': next_rel,
         })
 
-        self.git_tag(tagname, message='tmp', log_info=False)
-        self.load_spec()
+        self.git_tag(tagname, message='tmp', silent=True)
+        self.load_spec(silent=True)
         self.load_nameverrel()
         self.del_tag(tagname)
 

From 886cf875703261a0bbf5ac0cbbd765dedcc83d27 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 29/104] del tag in case of exception in load_spec or load_nameverrel


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index ba3d342..a821800 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -370,9 +370,12 @@ class Commands(pyrpkg.Commands):
         })
 
         self.git_tag(tagname, message='tmp', silent=True)
-        self.load_spec(silent=True)
-        self.load_nameverrel()
-        self.del_tag(tagname)
+
+        try:
+            self.load_spec(silent=True)
+            self.load_nameverrel()
+        finally:
+            self.del_tag(tagname)
 
         if utils.strip_at(self.ver, ver_strip) != next_ver:
             self.log.debug('Spec does not follow version in the latest tag. Reverting.')

From aaa3ef2c9d664650ac10f073dba6c32f80fe695d Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 30/104] add check for tag existence into git_tag


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index a821800..f7c9227 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -300,11 +300,14 @@ class Commands(pyrpkg.Commands):
         return self._module_name_spec
 
     def git_tag(self, tagname, force=False, message=None, file=None, silent=False):
-        cmd = ['git', 'tag', '-a']
+        if tagname in self.repo.tags:
+            raise rpkgError("Tag {} already exists.".format(tagname))
 
         if not message and not file:
             message = self.get_tag_message()
 
+        cmd = ['git', 'tag', '-a']
+
         if force:
             cmd.extend(['-f'])
         if message:

From da792ef04fd0f1165b0a14796cdbed964fceb6e6 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:26 +0000
Subject: [PATCH 31/104] fix sources param for spec subcommand


---

diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 17d357f..cdefb46 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -231,7 +231,7 @@ class rpkgClient(cliClient):
             'file ending with ".spec.rpkg" or ".spec" suffix '
             'in this order.')
         spec_parser.add_argument(
-            '--sources', action='store', default=False,
+            '--sources', action='store_true', default=False,
             help='Enable source generation by the input '
             'spec template. By default disabled.')
         spec_parser.add_argument(

From 7cf73f0a24e65f3797c0b32a19b5d815e55d6654 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 32/104] make info of 'Source file already exists.' message


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 3ff54f0..41009ee 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -50,7 +50,7 @@ function git_pack {
     fi
 
     if [ -f "$OUTDIR/$source_name" ] && [ -z "$force" ]; then
-        log_debug "Source file already exists. No action taken."
+        log_info "Source file already exists. No action taken."
         output "$source_name"
         return
     fi

From 6a11a210dd9ae6f4694ad60e2e2a2f0cf0eff631 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 33/104] help message for tagging


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index f7c9227..c0427c1 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -304,7 +304,7 @@ class Commands(pyrpkg.Commands):
             raise rpkgError("Tag {} already exists.".format(tagname))
 
         if not message and not file:
-            message = self.get_tag_message()
+            message = self.get_tag_message(tagname)
 
         cmd = ['git', 'tag', '-a']
 
@@ -400,7 +400,7 @@ class Commands(pyrpkg.Commands):
         cmd = ['git', 'tag', '-d', tagname]
         utils.run_command(cmd, cwd=self.path)
 
-    def get_tag_message(self):
+    def get_tag_message(self, tagname):
         tag_pattern = '{}*'.format(self.module_name)
 
         tag_names = self.repo.git.tag(
@@ -417,5 +417,11 @@ class Commands(pyrpkg.Commands):
 
         editor = self.repo.git.var('GIT_EDITOR')
         subject = "Commits: {0}".format(rev_list_expr)
-        body = utils.edit(editor, message_lines)
+
+        help_text = ("#\n"
+        "# Write a changelog for tag:\n"
+        "#   " + tagname + "\n"
+        "# Lines starting with '#' will be ignored.\n")
+
+        body = utils.edit(editor, message_lines, help_text)
         return '{0}\n\n{1}'.format(subject, body)
diff --git a/rpkglib/utils.py b/rpkglib/utils.py
index c24edf3..f2cb9ab 100644
--- a/rpkglib/utils.py
+++ b/rpkglib/utils.py
@@ -71,8 +71,8 @@ def run_command(cmd, shell=False, env=None, cwd=None):
     return output
 
 
-def edit(editor, lines):
-    data = '\n'.join(lines)
+def edit(editor, lines, help_text):
+    data = '\n'.join(lines) + '\n' + help_text
     tmp_f = tempfile.NamedTemporaryFile('w', delete=False)
     tmp_f.write(data)
     tmp_f.close()

From 570aa0e31cfcc0badf0b14e4067e62dbe63469a7 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 34/104] make rel optional in git_changelog


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 41009ee..e41b914 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -183,7 +183,7 @@ function git_changelog {
             continue
         fi
 
-        verrel="$(echo $tag | sed -E -n "s/^$name-([^-]+-[^-]+)$/\1/p")"
+        verrel="$(echo $tag | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1\2/p")"
         header="$(LC_ALL=$locale git tag -l $tag --format='* %(taggerdate:format:%a %b %d %Y) %(taggername) %(taggeremail)') $verrel"
         changelog="${changelog}${header}"$'\n'"${data}"
 

From f82769e834b8da9f69e21f90dca7fb866e03e70e Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 35/104] subcommand fixes


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index c0427c1..c856bb6 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -4,6 +4,7 @@ import shutil
 import re
 import subprocess
 import tempfile
+import git
 
 import pyrpkg
 from pyrpkg.utils import cached_property
@@ -45,6 +46,14 @@ class Commands(pyrpkg.Commands):
             "--define '_rpmdir %s'" % self.outdir,
         ]
 
+    def load_repo(self):
+        """Create a repo object from our path"""
+        self.log.debug('Creating repo object from %s', self.path)
+        try:
+            self._repo = git.Repo(self.path, search_parent_directories=True)
+        except (git.InvalidGitRepositoryError, git.NoSuchPathError):
+            raise rpkgError('%s is not a valid repo' % self.path)
+
     @property
     def repo_spec(self):
         if not self._repo_spec:
@@ -163,6 +172,43 @@ class Commands(pyrpkg.Commands):
         self._run_command(cmd, shell=True)
         return srpm_path
 
+    def lint(self, info=False, rpmlintconf=None):
+        """Run rpmlint over a built srpm
+
+        Log the output and returns nothing
+        rpmlintconf is the name of the config file passed to rpmlint if
+        specified by the command line argument.
+        """
+
+        # Check for srpm
+        srpm = "%s-%s-%s.src.rpm" % (self.module_name, self.ver, self.rel)
+        if not os.path.exists(os.path.join(self.outdir, srpm)):
+            self.log.warning('No srpm found')
+
+        # Get the possible built arches
+        arches = set(self._get_build_arches_from_spec())
+        rpms = set()
+        for arch in arches:
+            if os.path.exists(os.path.join(self.outdir, arch)):
+                # For each available arch folder, lists file and keep
+                # those ending with .rpm
+                rpms.update(glob.glob(os.path.join(self.outdir, arch, '*.rpm')))
+        if not rpms:
+            self.log.warning('No rpm found')
+        cmd = ['rpmlint']
+        if info:
+            cmd.extend(['-i'])
+        if rpmlintconf:
+            cmd.extend(["-f", os.path.join(self.outdir, rpmlintconf)])
+        elif os.path.exists(os.path.join(self.outdir, ".rpmlint")):
+            cmd.extend(["-f", os.path.join(self.outdir, ".rpmlint")])
+        cmd.append(os.path.join(self.outdir, self.spec))
+        if os.path.exists(os.path.join(self.outdir, srpm)):
+            cmd.append(os.path.join(self.outdir, srpm))
+        cmd.extend(sorted(rpms))
+        # Run the command
+        self._run_command(cmd, shell=True)
+
     def is_unpacked(self, dirpath, rpm_sources):
         """
         @deprecated
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index cdefb46..7abfb8e 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -23,20 +23,26 @@ class rpkgClient(cliClient):
 
     def setup_argparser(self):
         """Setup the argument parser and register some basic commands."""
+        self.rpm_spec_parser = argparse.ArgumentParser(add_help=False)
+        self.rpm_spec_parser.add_argument('--outdir', action='store', default=DEFAULT_OUTDIR,
+                                          help='Where to put generated or downloaded rpm content.')
+        self.rpm_spec_parser.add_argument('--spec', action='store', default=None,
+                                          help='An input spec template. If not given, '
+                                          'the spec template is auto-located in path as a '
+                                          'file ending with ".spec.rpkg" or ".spec" suffix '
+                                          'in this order.')
 
         self.parser = argparse.ArgumentParser(
             prog=self.name, epilog='For detailed help pass --help to a target')
 
         self.parser.add_argument('--module-name',
-                                 help='Override the module name. Otherwise'
-                                      ' it is discovered from: Git push URL'
-                                      ' or Git URL. ')
+                                 help='Override the module name. Otherwise '
+                                 'it is discovered from: Git push URL '
+                                 'or Git URL.')
         self.parser.add_argument('--user', default=None,
                                  help='Override the discovered user name')
-        self.parser.add_argument('--path', default=None,
-                                 type=utils.u,
-                                 help='Define the directory to work in '
-                                 '(defaults to cwd)')
+        self.parser.add_argument('--path', action='store', default=None, type=utils.u,
+                                 help='Define the directory to work in (defaults to cwd)')
         # Verbosity
         self.parser.add_argument('--verbose', '-v', dest='v',
                                  action='store_true',
@@ -63,9 +69,9 @@ class rpkgClient(cliClient):
         self.register_clean()
         self.register_clog()
         self.register_clone()
-        self.register_copr_build()
         self.register_commit()
         self.register_compile()
+        self.register_copr_build()
         self.register_diff()
         self.register_gimmespec()
         self.register_giturl()
@@ -90,6 +96,24 @@ class rpkgClient(cliClient):
         self.register_verify_files()
         self.register_verrel()
 
+        self.extend_subparsers()
+
+    def extend_subparsers(self):
+        cmds = set(['make-source', 'clean', 'clog', 'clone', 'commit',
+                    'compile', 'copr-build', 'diff', 'gimmespec', 'giturl',
+                    'import', 'install', 'is-packed', 'lint', 'local',
+                    'new', 'new-sources', 'patch', 'prep', 'pull', 'push',
+                    'sources', 'spec', 'srpm', 'switch-branch', 'tag',
+                    'unused-patches', 'upload', 'verify-files', 'verrel'])
+
+        spec_parse_cmds = cmds - set(['clean', 'clone', 'commit', 'diff',
+                                      'import', 'new', 'switch-branch'])
+
+        for spec_parse_cmd in spec_parse_cmds:
+            self.subparsers.add_parser(name=spec_parse_cmd, add_help=False,
+                description=self.subparsers.choices[spec_parse_cmd].description,
+                parents=[self.subparsers.choices[spec_parse_cmd], self.rpm_spec_parser])
+
     def load_cmd(self):
         """This sets up the cmd object"""
 
@@ -101,8 +125,6 @@ class rpkgClient(cliClient):
                   for realm in items.get("kerberos_realms", '').split(',')
                   if realm]
 
-        outdir = self.args.outdir if 'outdir' in self.args else DEFAULT_OUTDIR
-
         # Create the cmd object
         self._cmd = self.site.Commands(self.args.path,
                                        items.get('lookaside'),
@@ -116,43 +138,14 @@ class rpkgClient(cliClient):
                                        user=self.args.user,
                                        quiet=self.args.q,
                                        realms=realms,
-                                       outdir=outdir,
+                                       outdir=getattr(self.args, 'outdir', None),
                                        preprocess=items.get('preprocess_spec', True))
 
         self._cmd.ns_module_name = self.args.module_name
         self._cmd.debug = self.args.debug
         self._cmd.verbose = self.args.v
         self._cmd.clone_config = items.get('clone_config')
-
-    def register_make_source(self):
-        make_source_parser = self.subparsers.add_parser(
-            'make-source', help='Deprecated. Create Source0 from the '
-            'content of the current working directory '
-            'after downloading any external sources. '
-            'The content must be of unpacked type.',
-            description='Puts content of the current '
-            'working directory into a gzip-compressed archive named '
-            'according to Source0 filename as specfied in the .spec file. '
-            'The content must be of unpacked type, otherwise no action is taken. '
-            'Unpacked content is such that it contains a .spec file '
-            'that references no present source or patch '
-            '(typically it contains only Source0 being '
-            'generated automatically) and there is at least '
-            'one file not in the list of ignored content (README, '
-            'README.md, sources, LICENSE, tito.props, hidden files, '
-            '.spec file). Note that by invoking this command '
-            'with --outdir ./, the directory content becomes '
-            '"packed".')
-        make_source_parser.add_argument(
-            '--spec', action='store', default=None,
-            help='Path to the spec file or directory where the '
-            'spec file can be found. By default .spec file '
-            'is autodiscovered in the working directory.')
-        make_source_parser.add_argument(
-            '--outdir', default=DEFAULT_OUTDIR,
-            help='Where to put the generated files. '
-            'By default cwd.')
-        make_source_parser.set_defaults(command=self.make_source)
+        self._cmd.set_specloc(getattr(self.args, 'spec', None))
 
     def tag(self):
         self.cmd.dump_spec_only = True
@@ -169,15 +162,22 @@ class rpkgClient(cliClient):
                 filename = 'clog'
             self.cmd.add_tag(tagname, self.args.force,
                              self.args.message, filename)
+
+    def lint(self):
+        self.cmd.dump_spec_only = True
+        self.cmd.lint(self.args.info, self.args.rpmlintconf)
+
+    def verrel(self):
+        self.cmd.dump_spec_only = True
+        super(rpkgClient, self).verrel()
+
     def make_source(self):
         print('This function is deprecated and will be removed in a future release.', file=sys.stderr)
         self.cmd.sources()
-        self.cmd.set_specloc(self.args.spec)
         self.cmd.make_source()
 
     def srpm(self):
         self.cmd.sources()
-        self.cmd.set_specloc(self.args.spec)
         if self.config['rpkg'].getboolean('auto_pack', False):
             try:
                 self.cmd.make_source()
@@ -187,12 +187,17 @@ class rpkgClient(cliClient):
                 print('Auto-packing is deprecated and will be removed in a future release.', file=sys.stderr)
         return self.cmd.srpm()
 
+    def gimmespec(self):
+        print(self.cmd.repo_spec)
+
     def spec(self):
         if not self.args.sources:
             self.cmd.dump_spec_only = True
-        self.cmd.set_specloc(self.args.spec)
         self.cmd.load_spec()
 
+    def sources(self):
+        self.cmd.sources()
+
     def copr_build(self):
         srpm_path = self.srpm()
         self.cmd.copr_build(self.args.project[0],
@@ -202,7 +207,6 @@ class rpkgClient(cliClient):
 
     def is_packed(self):
         print('This function is deprecated and will be removed in a future release.', file=sys.stderr)
-        self.cmd.set_specloc(self.args.spec)
         ts = rpm.ts()
         try:
             rpm.addMacro("_sourcedir", self.cmd.path)
@@ -215,93 +219,54 @@ class rpkgClient(cliClient):
         else:
             self.log.info('Yes')
 
+    def register_make_source(self):
+        make_source_parser = self.subparsers.add_parser(
+            name='make-source', help='Deprecated. Create Source0 from the '
+            'content of the current working directory '
+            'after downloading any external sources. '
+            'The content must be of unpacked type.',
+            description='Puts content of the current '
+            'working directory into a gzip-compressed archive named '
+            'according to Source0 filename as specfied in the .spec file. '
+            'The content must be of unpacked type, otherwise no action is taken. '
+            'Unpacked content is such that it contains a .spec file '
+            'that references no present source or patch '
+            '(typically it contains only Source0 being '
+            'generated automatically) and there is at least '
+            'one file not in the list of ignored content (README, '
+            'README.md, sources, LICENSE, tito.props, hidden files, '
+            '.spec file). Note that by invoking this command '
+            'with --outdir ./, the directory content becomes '
+            '"packed".')
+        make_source_parser.set_defaults(command=self.make_source)
+
     def register_spec(self):
         """Register the spec target"""
         spec_parser = self.subparsers.add_parser(
-            'spec', help='Generate spec file from a spec template',
+            name='spec', help='Generate spec file from a spec template',
             description='Preprocess a given spec template '
             'and put the resulting spec file into outdir. '
             'The spec template is simply copied into the outdir if '
             'spec preprocessing is turned off or if the input spec template '
             'does not contain any preprocessor macros.')
         spec_parser.add_argument(
-            '--spec', action='store', default=None,
-            help='An input spec template. If not given, '
-            'the spec template is auto-located in path as a '
-            'file ending with ".spec.rpkg" or ".spec" suffix '
-            'in this order.')
-        spec_parser.add_argument(
             '--sources', action='store_true', default=False,
             help='Enable source generation by the input '
             'spec template. By default disabled.')
-        spec_parser.add_argument(
-            '--outdir', default=DEFAULT_OUTDIR,
-            help='Where to put the generated spec file '
-            'and sources if any.')
         spec_parser.set_defaults(command=self.spec)
 
-    def register_srpm(self):
-        """Register the srpm target"""
-        srpm_parser = self.subparsers.add_parser(
-            'srpm', help='Create a source rpm',
-            description='Create a source rpm out of '
-            'packed or unpacked content. See '
-            'make-sources for the description of the '
-            'two content types and their recognition.')
-        srpm_parser.add_argument(
-            '--spec', action='store', default=None,
-            help='Path to the spec file or directory where the '
-            'spec file can be found. By default .spec file '
-            'is autodiscovered in the working directory.')
-        srpm_parser.add_argument(
-            '--outdir', default=DEFAULT_OUTDIR,
-            help='Where to put the generated srpm.')
-        srpm_parser.set_defaults(command=self.srpm)
-
     def register_is_packed(self):
         """Determine whether the package content is packed or not"""
         is_packed_parser = self.subparsers.add_parser(
-            'is-packed', help='Deprecated. Tell user whether content is packed',
+            name='is-packed', help='Deprecated. Tell user whether content is packed',
             description='Determine whether the package content '
             'in the working directory is packed or unpacked '
             'and print that information to the screen.')
-        is_packed_parser.add_argument(
-            '--spec', action='store', default=None,
-            help='Path to an alternative spec file or to directory '
-            'where the spec file can be found. Note that '
-            'whether the content is packed on unpacked depends '
-            'on Source and Patch definitions in the spec '
-            'file as well as on the actual content in the '
-            'working directory.')
         is_packed_parser.set_defaults(command=self.is_packed)
 
-    def register_copr_build(self):
-        """Register the copr-build target"""
-        copr_parser = self.subparsers.add_parser(
-            'copr-build', help='Build package in COPR',
-            formatter_class=argparse.RawDescriptionHelpFormatter,
-            description="""
-            Build package in COPR.
-
-            Note: you need to have set up correct api key. For more information
-            see API KEY section of copr-cli(1) man page.
-            """)
-        copr_parser.add_argument(
-            '--spec', action='store', default=None,
-            help='Path to the spec file or directory where the '
-            'spec file can be found. By default .spec file '
-            'is autodiscovered.')
-        copr_parser.add_argument(
-            '--config', required=False,
-            metavar='CONFIG', dest='copr_config',
-            help="Path to an alternative Copr configuration file")
-        copr_parser.add_argument(
-            '--nowait', action='store_true', default=False,
-            help="Don't wait on build")
-        copr_parser.add_argument(
-            'project', nargs=1, help='Name of the project in format USER/PROJECT')
-        copr_parser.add_argument(
-            '--outdir', default=DEFAULT_OUTDIR,
-            help='Where to put the generated files. '
-            'By default cwd.')
-        copr_parser.set_defaults(command=self.copr_build)
+    def register_sources(self):
+        """Register the sources target"""
+        sources_parser = self.subparsers.add_parser(
+            'sources', help='Download source files',
+            description='Download source files')
+        sources_parser.set_defaults(command=self.sources)

From 723c8044c9edc9b5371660222f44646b5aed5333 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 36/104] register clog with dump_spec_only


---

diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 7abfb8e..5a925fa 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -147,6 +147,10 @@ class rpkgClient(cliClient):
         self._cmd.clone_config = items.get('clone_config')
         self._cmd.set_specloc(getattr(self.args, 'spec', None))
 
+    def clog(self):
+        self.cmd.dump_spec_only = True
+        self.cmd.clog(raw=self.args.raw)
+
     def tag(self):
         self.cmd.dump_spec_only = True
         self.cmd._rpmdefines = self.cmd.rpmdefines + ["--define 'dist %nil'"]

From eb54b7a898a3a05499169aced0f84185b62e9657 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 37/104] fix git archive functions


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index e41b914..e52a03d 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -79,7 +79,7 @@ function git_archive {
     fi
 
     if [ -f "$OUTDIR/$source_name" ] && [ -z "$force" ]; then
-        log_debug "Source file already exists. No action taken."
+        log_info "Source file already exists. No action taken."
         output "$source_name"
         return
     fi
@@ -206,7 +206,7 @@ function git_dir_pack {
     git_pack path="$(dirname $SPECPATH)" dir_name="$(cached git_dir_name)-$(cached git_dir_version)" source_name="$(cached git_dir_source_name)" "$@"
 }
 
-function git_dir_achive {
+function git_dir_archive {
     git_archive path="$(dirname $SPECPATH)" dir_name="$(cached git_dir_name)-$(cached git_dir_version)" source_name="$(cached git_dir_source_name)" "$@"
 }
 
@@ -236,7 +236,7 @@ function git_cwd_pack {
     git_pack path="$(pwd)" dir_name="$(cached git_cwd_name)-$(cached git_cwd_version)" source_name="$(cached git_cwd_source_name)" "$@"
 }
 
-function git_cwd_achive {
+function git_cwd_archive {
     git_archive path="$(pwd)" dir_name="$(cached git_cwd_name)-$(cached git_cwd_version)" source_name="$(cached git_cwd_source_name)" "$@"
 }
 

From e28a671e6d27c2d724a90277c479cada0a636cff Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 38/104] add some spec template into root repo dir for testing


---

diff --git a/rpkg-client.spec.rpkg.cwd b/rpkg-client.spec.rpkg.cwd
new file mode 100644
index 0000000..145e9b3
--- /dev/null
+++ b/rpkg-client.spec.rpkg.cwd
@@ -0,0 +1,157 @@
+# vim: syntax=spec
+Name: {{{ git_cwd_name }}}
+Version: {{{ git_cwd_version lead=1 }}}
+Release: 1%{?dist}
+Summary: RPM packaging utitility
+License: GPLv2+
+URL: https://pagure.io/rpkg-client.git
+
+# How to obtain the sources
+# git clone https://pagure.io/rpkg-client.git
+# cd rpkg-client
+# tito build --tgz
+Source0: {{{ git_cwd_archive }}}
+
+BuildArch: noarch
+
+%description
+This package contains the rpkg utility. We are putting
+the actual 'rpkg' package into a subpackage because there already
+exists package https://src.fedoraproject.org/rpms/rpkg. That package,
+however, does not actually produce rpkg rpm whereas rpkg-client does.
+
+%package -n rpkg
+Summary: RPM packaging utitility
+BuildArch: noarch
+
+BuildRequires: python
+BuildRequires: python-setuptools
+BuildRequires: python-devel
+BuildRequires: python2-rpkg
+BuildRequires: python2-mock
+BuildRequires: python-munch
+
+%if 0%{?rhel}
+BuildRequires: pytest
+BuildRequires: pyparsing
+BuildRequires: python-configparser
+%else
+BuildRequires: python2-pytest
+BuildRequires: python2-pyparsing
+BuildRequires: python2-configparser
+%endif
+
+Requires: python2-rpkg
+
+%if 0%{?rhel}
+Requires: pyparsing
+Requires: python-configparser
+%else
+Requires: python2-pyparsing
+Requires: python2-configparser
+%endif
+
+%description -n rpkg
+This is an RPM packaging utility based on python-rpkg library.
+It works with both DistGit and standard Git repositories and
+it handles packed directory content as well as unpacked content.
+
+%prep
+%setup -q
+
+%check
+./run_tests.sh
+
+%build
+%py2_build
+%{__python2} doc/rpkg_man_page.py > rpkg.1
+
+%install
+%py2_install
+install -d %{buildroot}%{_mandir}/man1
+install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1
+
+install -d %{buildroot}%{_sysconfdir}
+install -d %{buildroot}%{_datarootdir}/bash-completion/completions
+
+cp -a rpkg.conf %{buildroot}%{_sysconfdir}/
+cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
+
+%files -n rpkg
+%license LICENSE
+%{python2_sitelib}/*
+
+%config(noreplace) %{_sysconfdir}/rpkg.conf
+%{_datadir}/bash-completion/completions/rpkg.bash
+
+%{_bindir}/rpkg
+%{_mandir}/*/*
+
+%changelog
+{{{ git_cwd_changelog }}}
+
+* Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
+- add LICENSE to ignored file regex
+
+* Mon Oct 23 2017 clime <clime@redhat.com> 0.12-1
+- respect hashtype from the sources file if any
+
+* Fri Oct 20 2017 clime <clime@redhat.com> 0.11-1
+- set default distgit target to src.fedoraproject.org
+- fix downloading sources for any-length-namespace
+  modules
+- make the whole lookaside url template explict in
+  the config file
+- rename 'rpkg' config section to 'distgit'
+- update in command descriptions
+
+* Wed Oct 18 2017 clime <clime@redhat.com> 0.10-1
+- possibility to give directory to --spec
+- also take --spec in account for rpmdefines
+
+* Mon Oct 16 2017 clime <clime@redhat.com> 0.9-1
+- update spec descriptions
+- added is-packed subcommand
+- try reading ~/.config/rpkg before /etc/rpkg
+- add unittests
+- for source downloading, try both url formats
+  with/without hashtype
+- add make-source subcommand
+- patch srpm to generate Source0 if unpacked content
+- override load_ns_module_name to work with any length
+  namespaces
+- added --spec for srpm, make-source, and copr-build
+- fixed tagging not to include host dist tag
+- docs update
+- make all config values optional
+
+* Thu Jul 27 2017 clime <clime@redhat.com> 0.8-1
+- fix man pages to only include actually provided part of pyrpkg functionality
+- add rpkglib to provide functional interface
+- change summary of wrapper package
+
+* Wed Jul 26 2017 clime <clime@redhat.com> 0.7-1
+- use %%py2_build and %%py2_install macros
+- explicitly invoke python2 for doc generation
+- remove no longer needed $BUILDROOT removal in %%install clause
+- add missing BuildRequires on python-setuptools
+
+* Fri Jul 07 2017 clime <clime@redhat.com> 0.6-1
+- fix build error
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.5-1
+- remove Requires bash-completion
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.4-1
+- move config file to /etc/rpkg.conf
+- add Requires bash-completion
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.3-1
+- remove some directories from %%files in .spec
+- add (for now) short README.md
+
+* Tue Jun 20 2017 clime <clime@redhat.com> 0.2-1
+- new rpkg-client package built with tito
+
+* Mon Jun 12 2017 clime <clime@redhat.com> 0.1-1
+- Initial version
diff --git a/rpkg-client.spec.rpkg.dir b/rpkg-client.spec.rpkg.dir
new file mode 100644
index 0000000..8a229e9
--- /dev/null
+++ b/rpkg-client.spec.rpkg.dir
@@ -0,0 +1,157 @@
+# vim: syntax=spec
+Name: {{{ git_dir_name }}}
+Version: {{{ git_dir_version lead=1 }}}
+Release: 1%{?dist}
+Summary: RPM packaging utitility
+License: GPLv2+
+URL: https://pagure.io/rpkg-client.git
+
+# How to obtain the sources
+# git clone https://pagure.io/rpkg-client.git
+# cd rpkg-client
+# tito build --tgz
+Source0: {{{ git_dir_pack }}}
+
+BuildArch: noarch
+
+%description
+This package contains the rpkg utility. We are putting
+the actual 'rpkg' package into a subpackage because there already
+exists package https://src.fedoraproject.org/rpms/rpkg. That package,
+however, does not actually produce rpkg rpm whereas rpkg-client does.
+
+%package -n rpkg
+Summary: RPM packaging utitility
+BuildArch: noarch
+
+BuildRequires: python
+BuildRequires: python-setuptools
+BuildRequires: python-devel
+BuildRequires: python2-rpkg
+BuildRequires: python2-mock
+BuildRequires: python-munch
+
+%if 0%{?rhel}
+BuildRequires: pytest
+BuildRequires: pyparsing
+BuildRequires: python-configparser
+%else
+BuildRequires: python2-pytest
+BuildRequires: python2-pyparsing
+BuildRequires: python2-configparser
+%endif
+
+Requires: python2-rpkg
+
+%if 0%{?rhel}
+Requires: pyparsing
+Requires: python-configparser
+%else
+Requires: python2-pyparsing
+Requires: python2-configparser
+%endif
+
+%description -n rpkg
+This is an RPM packaging utility based on python-rpkg library.
+It works with both DistGit and standard Git repositories and
+it handles packed directory content as well as unpacked content.
+
+%prep
+%setup -q
+
+%check
+./run_tests.sh
+
+%build
+%py2_build
+%{__python2} doc/rpkg_man_page.py > rpkg.1
+
+%install
+%py2_install
+install -d %{buildroot}%{_mandir}/man1
+install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1
+
+install -d %{buildroot}%{_sysconfdir}
+install -d %{buildroot}%{_datarootdir}/bash-completion/completions
+
+cp -a rpkg.conf %{buildroot}%{_sysconfdir}/
+cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
+
+%files -n rpkg
+%license LICENSE
+%{python2_sitelib}/*
+
+%config(noreplace) %{_sysconfdir}/rpkg.conf
+%{_datadir}/bash-completion/completions/rpkg.bash
+
+%{_bindir}/rpkg
+%{_mandir}/*/*
+
+%changelog
+{{{ git_dir_changelog }}}
+
+* Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
+- add LICENSE to ignored file regex
+
+* Mon Oct 23 2017 clime <clime@redhat.com> 0.12-1
+- respect hashtype from the sources file if any
+
+* Fri Oct 20 2017 clime <clime@redhat.com> 0.11-1
+- set default distgit target to src.fedoraproject.org
+- fix downloading sources for any-length-namespace
+  modules
+- make the whole lookaside url template explict in
+  the config file
+- rename 'rpkg' config section to 'distgit'
+- update in command descriptions
+
+* Wed Oct 18 2017 clime <clime@redhat.com> 0.10-1
+- possibility to give directory to --spec
+- also take --spec in account for rpmdefines
+
+* Mon Oct 16 2017 clime <clime@redhat.com> 0.9-1
+- update spec descriptions
+- added is-packed subcommand
+- try reading ~/.config/rpkg before /etc/rpkg
+- add unittests
+- for source downloading, try both url formats
+  with/without hashtype
+- add make-source subcommand
+- patch srpm to generate Source0 if unpacked content
+- override load_ns_module_name to work with any length
+  namespaces
+- added --spec for srpm, make-source, and copr-build
+- fixed tagging not to include host dist tag
+- docs update
+- make all config values optional
+
+* Thu Jul 27 2017 clime <clime@redhat.com> 0.8-1
+- fix man pages to only include actually provided part of pyrpkg functionality
+- add rpkglib to provide functional interface
+- change summary of wrapper package
+
+* Wed Jul 26 2017 clime <clime@redhat.com> 0.7-1
+- use %%py2_build and %%py2_install macros
+- explicitly invoke python2 for doc generation
+- remove no longer needed $BUILDROOT removal in %%install clause
+- add missing BuildRequires on python-setuptools
+
+* Fri Jul 07 2017 clime <clime@redhat.com> 0.6-1
+- fix build error
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.5-1
+- remove Requires bash-completion
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.4-1
+- move config file to /etc/rpkg.conf
+- add Requires bash-completion
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.3-1
+- remove some directories from %%files in .spec
+- add (for now) short README.md
+
+* Tue Jun 20 2017 clime <clime@redhat.com> 0.2-1
+- new rpkg-client package built with tito
+
+* Mon Jun 12 2017 clime <clime@redhat.com> 0.1-1
+- Initial version

From d2aafa7418da0339c114bd59a5c96cfc57ff6d37 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 39/104] we can rely on just basic git_* functions caching


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index e52a03d..31c9309 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -203,11 +203,11 @@ function git_setup_macro {
 ############## DIR FUNCTIONS ##############
 
 function git_dir_pack {
-    git_pack path="$(dirname $SPECPATH)" dir_name="$(cached git_dir_name)-$(cached git_dir_version)" source_name="$(cached git_dir_source_name)" "$@"
+    git_pack path="$(dirname $SPECPATH)" "$@"
 }
 
 function git_dir_archive {
-    git_archive path="$(dirname $SPECPATH)" dir_name="$(cached git_dir_name)-$(cached git_dir_version)" source_name="$(cached git_dir_source_name)" "$@"
+    git_archive path="$(dirname $SPECPATH)" "$@"
 }
 
 function git_dir_name {
@@ -215,29 +215,29 @@ function git_dir_name {
 }
 
 function git_dir_source_name {
-    git_source_name name="$(cached git_dir_name)" version="$(cached git_dir_version)" "$@"
+    git_source_name "$@"
 }
 
 function git_dir_version {
-    git_version name="$(cached git_dir_name)" "$@"
+    git_version "$@"
 }
 
 function git_dir_changelog {
-    git_changelog name="$(cached git_dir_name)" "$@"
+    git_changelog "$@"
 }
 
 function git_dir_setup_macro {
-    git_setup_macro dir_name="$(cached git_dir_name)-$(cached git_dir_version)" "$@"
+    git_setup_macro "$@"
 }
 
 ############## CURRENT WORKING DIR FUNCTIONS ##############
 
 function git_cwd_pack {
-    git_pack path="$(pwd)" dir_name="$(cached git_cwd_name)-$(cached git_cwd_version)" source_name="$(cached git_cwd_source_name)" "$@"
+    git_pack path="$(pwd)" "$@"
 }
 
 function git_cwd_archive {
-    git_archive path="$(pwd)" dir_name="$(cached git_cwd_name)-$(cached git_cwd_version)" source_name="$(cached git_cwd_source_name)" "$@"
+    git_archive path="$(pwd)" "$@"
 }
 
 function git_cwd_name {
@@ -245,17 +245,17 @@ function git_cwd_name {
 }
 
 function git_cwd_source_name {
-    git_source_name name="$(cached git_cwd_name)" version="$(cached git_cwd_version)" "$@"
+    git_source_name "$@"
 }
 
 function git_cwd_version {
-    git_version name="$(cached git_cwd_name)" "$@"
+    git_version "$@"
 }
 
 function git_cwd_changelog {
-    git_changelog name="$(cached git_cwd_name)" "$@"
+    git_changelog "$@"
 }
 
 function git_cwd_setup_macro {
-    git_setup_macro dir_name="$(cached git_cwd_name)-$(cached git_cwd_version)" "$@"
+    git_setup_macro "$@"
 }

From ca172097ea84232d18a5b2099e6afae20d10e580 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 40/104] unhide rpkg.sh


---

diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index 61aa5b3..0c61bc8 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -5,8 +5,8 @@ source $ENVSTORE
 SCRIPTDIR="$(builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
 source $SCRIPTDIR/lib.sh
 
-if [ -f ./.rpkg.sh ]; then
-    source ./.rpkg.sh
+if [ -f ./rpkg.sh ]; then
+    source ./rpkg.sh
 fi
 
 __cached[$1]=$("$@")

From 5f78d6b3afc98dd1a45e694abab5fd0be46e142d Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 41/104] read rpkg.conf from the current working directory, use config merging


---

diff --git a/rpkg b/rpkg
index 8b4e470..9b2aaa3 100755
--- a/rpkg
+++ b/rpkg
@@ -16,25 +16,23 @@ import sys
 import logging
 import configparser
 import argparse
+
 from rpkglib.cli import rpkgClient
 from os.path import expanduser
 
 # Setup an argparser and parse the known commands to get the config file
 parser = argparse.ArgumentParser(add_help=False)
-parser.add_argument('-C', '--config', help='Specify a config file to use. '
-                    'If not specified, ~/.config/rpkg is used and if that '
-                    'does not exists, then /etc/rpkg.conf is used.')
+parser.add_argument('-C', '--config', help='Specify a config file to use.'
+                    'If not specified, /etc/rpkg.conf, ~/.config/rpkg, and '
+                    './rpkg.conf are read in this order.')
 (args, other) = parser.parse_known_args()
 
-config_to_use = '/etc/rpkg.conf'
-for custom_config in [args.config, expanduser('~/.config/rpkg')]:
-    if custom_config and os.path.exists(custom_config):
-        config_to_use = custom_config
-        break
-
 # Setup a configuration object and read config file data
 config = configparser.SafeConfigParser()
-config.read(config_to_use)
+if args.config:
+    config.read([args.config])
+else:
+    config.read(['/etc/rpkg.conf', os.path.expanduser('~/.config/rpkg'), './rpkg.conf'])
 
 client = rpkgClient(config)
 client.do_imports('rpkglib')

From 59fa8c64f7774532c5a7c9f32ae609694460d976 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 42/104] add append= param to git_name and use it


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 31c9309..8ae8410 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -2,6 +2,10 @@ SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
 ############## HELPER FUNCTIONS ##############
 
+function name_convert {
+    sed -e 's|/|-|g' -e 's|-$||'
+}
+
 function output {
     echo -n "$@"
 }
@@ -99,10 +103,16 @@ function git_archive {
 }
 
 function git_name {
-    declare name= "$@"
+    declare name= append= "$@"
+
+    if [ -n "$append" ]; then
+        appendix="-$append"
+    else
+        appendix=
+    fi
 
     if [ -n "$name" ]; then
-        output "$name"
+        output "${name}${appendix}"
         return
     fi
 
@@ -114,7 +124,9 @@ function git_name {
     fi
 
     url_last_part="$(basename $url)"
-    output "${url_last_part%.git}"
+    name="${url_last_part%.git}"
+
+    output "${name}${appendix}"
 }
 
 function git_version {
@@ -211,7 +223,7 @@ function git_dir_archive {
 }
 
 function git_dir_name {
-    git_name name="$(basename $(dirname $SPECPATH))" "$@"
+    git_name append="$(git -C $(dirname $SPECPATH) rev-parse --show-prefix | name_convert)" "$@"
 }
 
 function git_dir_source_name {
@@ -241,7 +253,7 @@ function git_cwd_archive {
 }
 
 function git_cwd_name {
-    git_name name="$(basename $(pwd))" "$@"
+    git_name append="$(git -C $(pwd) rev-parse --show-prefix | name_convert)" "$@"
 }
 
 function git_cwd_source_name {

From c2da039acf9bda6a3abdcb56069f2afb99d6774f Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 43/104] cache output of the 'output' caller


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 8ae8410..19ddc5a 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -1,5 +1,7 @@
 SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
+declare -Ax __cached
+
 ############## HELPER FUNCTIONS ##############
 
 function name_convert {
@@ -7,7 +9,8 @@ function name_convert {
 }
 
 function output {
-    echo -n "$@"
+    __cached["${FUNCNAME[1]}"]="$@"
+    echo -n "${__cached[${FUNCNAME[1]}]}"
 }
 
 function cached {
diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index 0c61bc8..cb39afd 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -1,5 +1,4 @@
 #!/bin/bash
-declare -Ax __cached
 source $ENVSTORE
 
 SCRIPTDIR="$(builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
@@ -9,7 +8,6 @@ if [ -f ./rpkg.sh ]; then
     source ./rpkg.sh
 fi
 
-__cached[$1]=$("$@")
-echo -n "${__cached[$1]}"
+"$@"
 
 declare -x > $ENVSTORE

From 03e3f0ba6462d4b18bbe3aa1344bfefd1ed55cbd Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 44/104] fix missing import


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index c856bb6..cc24580 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -5,6 +5,7 @@ import re
 import subprocess
 import tempfile
 import git
+import glob
 
 import pyrpkg
 from pyrpkg.utils import cached_property

From cb9e08f92e98f1abc732e7b577c2b1a0d5e01a64 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 45/104] replace in dir spec template


---

diff --git a/rpkg-client.spec.rpkg.dir b/rpkg-client.spec.rpkg.dir
index 8a229e9..b341493 100644
--- a/rpkg-client.spec.rpkg.dir
+++ b/rpkg-client.spec.rpkg.dir
@@ -57,7 +57,7 @@ It works with both DistGit and standard Git repositories and
 it handles packed directory content as well as unpacked content.
 
 %prep
-%setup -q
+{{{ git_dir_setup_macro }}}
 
 %check
 ./run_tests.sh

From 1c17add04a9d6eb4fe9976d9a0083acf1ef0b778 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 46/104] fix git_changelog


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 19ddc5a..a416441 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -182,7 +182,7 @@ function git_source_name {
 function git_changelog {
     declare name="$(cached git_name)" since_tag= until_tag= locale=POSIX "$@"
 
-    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-*" --merged)
+    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name-*" --merged)
 
     changelog=
     until_tag_hit=
@@ -200,6 +200,9 @@ function git_changelog {
 
         verrel="$(echo $tag | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1\2/p")"
         header="$(LC_ALL=$locale git tag -l $tag --format='* %(taggerdate:format:%a %b %d %Y) %(taggername) %(taggeremail)') $verrel"
+        if [ -n "$changelog" ]; then
+            changelog="$changelog"$'\n\n'
+        fi
         changelog="${changelog}${header}"$'\n'"${data}"
 
         if [ "$since_tag" = "$tag" ]; then

From 61457f4758093c90d48c12d1990968df5b5d483a Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 47/104] update README.md


---

diff --git a/README.md b/README.md
index bbb5daf..ce2f63c 100644
--- a/README.md
+++ b/README.md
@@ -19,15 +19,15 @@ Spec templates:
     License:    GPLv2+
     URL:        https://someurl.org
 
-    Source: {{{ make_source }}}
+    Source: {{{ git_pack }}}
 
     %description
     This is a test package.
 
     %prep
-    {{{ setup }}}
+    {{{ git_setup_macro }}}
 
-    {{{ git_change_log }}}
+    {{{ git_changelog }}}
 
 TODO: write up more!
 

From 9d7d1dd57766d3957029649bd6be062f111b2f35 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 48/104] whitespace tweaking + is_packed fixed


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index cc24580..a1cc8eb 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -18,6 +18,7 @@ from rpkglib import utils
 
 from exceptions import NotUnpackedException, RpmSpecParseException, NoSourceZeroException
 
+
 class Commands(pyrpkg.Commands):
     def __init__(self, *args, **kwargs):
         """Init the object and some configuration details."""
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 5a925fa..2d7c6fb 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -211,6 +211,7 @@ class rpkgClient(cliClient):
 
     def is_packed(self):
         print('This function is deprecated and will be removed in a future release.', file=sys.stderr)
+        self.cmd.dump_spec_only = True
         ts = rpm.ts()
         try:
             rpm.addMacro("_sourcedir", self.cmd.path)
@@ -218,7 +219,7 @@ class rpkgClient(cliClient):
         except ValueError as e:
             raise RpmSpecParseException(str(e))
 
-        if self.cmd.is_unpacked(self.cmd.path, rpm_spec.sources):
+        if self.cmd.is_unpacked(self.cmd.outdir, rpm_spec.sources):
             self.log.info('No')
         else:
             self.log.info('Yes')
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index a416441..b6f065d 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -1,4 +1,4 @@
-SCRIPTDIR="$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+SCRIPTDIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 
 declare -Ax __cached
 

From 16e07190543d209535813ef334010700b74d3afc Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 49/104] more debugging info about spec substitutions


---

diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 850fca6..c2a97dc 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -13,7 +13,7 @@ def log_line_strip(line):
     return re.sub(r'(DEBUG|INFO|ERROR):\s*(.*)\s*', r'\2', line)
 
 
-def invoke_wrapper(path, in_spec_path, outdir, app_log, env_store_name):
+def invoke_wrapper(cwd, in_spec_path, outdir, app_log, env_store_name):
     def invoke(toks):
         subcmd = list(toks[0])
 
@@ -23,10 +23,14 @@ def invoke_wrapper(path, in_spec_path, outdir, app_log, env_store_name):
             'ENVSTORE': env_store_name,
         }
         p = subprocess.Popen([preproc_path]+subcmd,
-                             env=env, cwd=path,
+                             env=env, cwd=cwd,
                              stderr=subprocess.PIPE,
                              stdout=subprocess.PIPE)
 
+        app_log.debug('> Invoke: {}'.format(subcmd))
+        app_log.debug('> cwd: {}'.format(cwd))
+        app_log.debug('> env: {}'.format(env))
+
         (stdout, stderr) = p.communicate()
 
         for line in stderr.split('\n'):
@@ -43,6 +47,7 @@ def invoke_wrapper(path, in_spec_path, outdir, app_log, env_store_name):
             stripped_line = log_line_strip(line)
             log_func(stripped_line)
 
+        app_log.debug('---')
         return stdout
     return invoke
 

From 9e46ccca345ad7bb2bed608ebff7f3b37c1d80a9 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 50/104] propagate errors


---

diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index c2a97dc..ddcc16b 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -3,6 +3,7 @@ import subprocess
 import tempfile
 import re
 
+from pyrpkg.errors import rpkgError
 from pyparsing import nestedExpr
 
 preproc_path = os.path.join(
@@ -27,7 +28,7 @@ def invoke_wrapper(cwd, in_spec_path, outdir, app_log, env_store_name):
                              stderr=subprocess.PIPE,
                              stdout=subprocess.PIPE)
 
-        app_log.debug('> Invoke: {}'.format(subcmd))
+        app_log.debug('> subcmd: {}'.format(subcmd))
         app_log.debug('> cwd: {}'.format(cwd))
         app_log.debug('> env: {}'.format(env))
 
@@ -47,7 +48,13 @@ def invoke_wrapper(cwd, in_spec_path, outdir, app_log, env_store_name):
             stripped_line = log_line_strip(line)
             log_func(stripped_line)
 
-        app_log.debug('---')
+        if p.returncode != 0:
+            raise rpkgError(
+                "subcmd {} failed with value {}"
+                .format(subcmd, p.returncode))
+        else:
+            app_log.debug('---')
+
         return stdout
     return invoke
 
diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index cb39afd..abeb86a 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -9,5 +9,7 @@ if [ -f ./rpkg.sh ]; then
 fi
 
 "$@"
+retcode=$?
 
 declare -x > $ENVSTORE
+exit $retcode

From b351c16037c0b23552400e31809ccb37510b7b9c Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 51/104] no HEAD handling


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index b6f065d..ac712a4 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -79,6 +79,11 @@ function git_pack {
 function git_archive {
     declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
 
+    if ! git rev-parse HEAD&>/dev/null; then
+        log_info "No commits yet. Cannot archive the content."
+        return 1
+    fi
+
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
         output "$source_name"
@@ -145,7 +150,7 @@ function git_version {
         return 1
     fi
     
-    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-$lead*" --merged)
+    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-$lead*" --merged 2> /dev/null)
 
     if [ ${#tags[@]} -gt 0 ]; then
         latest_tag="${tags[-1]}"
@@ -182,7 +187,7 @@ function git_source_name {
 function git_changelog {
     declare name="$(cached git_name)" since_tag= until_tag= locale=POSIX "$@"
 
-    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name-*" --merged)
+    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name-*" --merged 2> /dev/null)
 
     changelog=
     until_tag_hit=

From 6635ecb01cbb6c700e9c13d55f312e85bb5d8f02 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 52/104] use git rev-parse --short HEAD to get the short commit hash


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index ac712a4..f3a5a26 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -169,7 +169,7 @@ function git_version {
     if [ $commit_count -eq 0 ]; then
         commit_count_appendix=
     else
-        commit_count_appendix=".git.$commit_count.$(git rev-list HEAD --max-count=1 | cut -c -8)"
+        commit_count_appendix=".git.$commit_count.$(git rev-parse --short HEAD)"
     fi
 
     if [ -n "$follow" ]; then

From bbf7e31cc8873437b575ad5b5b19b5982fb55382 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 53/104] update README.md


---

diff --git a/README.md b/README.md
index ce2f63c..d5a2cb5 100644
--- a/README.md
+++ b/README.md
@@ -1,79 +1,110 @@
-This application is an RPM packaging utility based on python-rpkg library. It works with both [DistGit](https://github.com/release-engineering/dist-git)
-and Git repositories and it handles two types of directory content: _packed_ content and _unpacked_ content.
+`rpkg` is an RPM packaging utility based on python-rpkg library.
 
-- Packed (unexpanded) content is that composed of tarballs, patches, and a .spec file.
-- Unpacked (expanded) content is that composed of plain source files and a .spec file.
+It works with both [DistGit](https://github.com/release-engineering/dist-git)
+and standard Git repositories.
 
-Currently `rpkg` offer two ways of achieving this:
+It handles two types of directory content: _packed_ and _unpacked_.
+
+- *Packed (unexpanded) content is that composed of tarballs, patches, and a .spec file*
+- *Unpacked (expanded) content is that composed of plain source files and a .spec file*
+
+There are currently two ways of handling those two different content types:
 
 - spec templates
 - autopacking (deprecated)
 
-Spec templates:
 
-    Name:       {{{ git_name }}}
-    Version:    {{{ git_version }}}
-    Release:    1%{?dist}
-    Summary:    This is a test package.
+Spec templates
+--------------
 
-    License:    GPLv2+
-    URL:        https://someurl.org
+Apart from being useful as a means to handle unpacked (as well as packed) content,
+they also make it possible to generate potentially large parts of your spec file
+automatically from a Git repository where your spec file is located.
 
-    Source: {{{ git_pack }}}
+An example spec template might look like this:
 
-    %description
-    This is a test package.
+```
+Name:       {{{ git_name }}}
+Version:    {{{ git_version }}}
+Release:    1%{?dist}
+Summary:    This is a test package.
 
-    %prep
-    {{{ git_setup_macro }}}
+License:    GPLv2+
+URL:        https://someurl.org
 
-    {{{ git_changelog }}}
+Source: {{{ git_pack }}}
 
-TODO: write up more!
+%description
+This is a test package.
 
-Autopacking (deprecated):
+%prep
+{{{ git_setup_macro }}}
 
-If you have auto_pack option enabled in your config, then for packed content, if you ask `rpkg`
-to make srpm (`rpkg srpm`), it will download any external files from the appropriate storage
-(e.g. lookaside cache for DistGit) and then it will invoke `rpmbuild -bs` with `_sourcedir`,
-`_specdir`, `_builddir`, `_srcrpmdir`,`_rpmdir` macros all set to the working directory.
+%changelog
+{{{ git_changelog }}}
+```
 
-For unpacked content, if you ask `rpkg` to do the same thing, it will download external sources (if any)
-and then it will also generate a tarball from the whole content of the working directory named according
-to `Source0` definition present in the associated .spec file. This tarball and the .spec are then passed
-to the same rpmbuild command as above for the packed content.
+Having a spec template like this in your project (instead of just a plain spec file)
+allows your built source packages to automatically follow git history of your project.
 
-Apart from generating srpms from the application sources, you can also run other useful packaging commands
-like `rpkg lint` to check the .spec file and the overall package conformance to RPM standard, `rpkg local`
-to locally build the package into an rpm, or `rpkg copr-build` to build an srpm and send it for build to
-[COPR](https://copr.fedorainfracloud.org).
+Read more [here](https://docs.pagure.org/rpkg-util/tutorials.html#spec-templates-from-scratch).
+
+
+Auto-packing (deprecated)
+-------------------------
+
+Auto-packing works only if `auto_pack` configuration option is set to `True` and only if the content
+you are working with is not packed (see `rpkg is-packed`).
+
+When invoking `rpkg srpm` on an unpacked content, `rpkg` will download external sources (if any)
+and then it will generate a tarball from the whole content of the working directory named according
+to `Source0` definition present in the associated .spec file. This tarball and the .spec file are
+then passed to rpmbuild to generate the resulting srpm.
+
+
+More examples
+-------------
+
+Run %prep phase of an rpm build:
 
-Examples:
-```
-    $ cd unpacked-copr-build-example
-    $ ls .
-    doc  LICENSE  README.md  rpkg  rpkg.bash  rpkg-client.spec  rpkg.conf  rpkglib  run_tests.sh  setup.py  tests
-    $ rpkg copr-build user/project
-    Wrote: copr-build-example/rpkg-client-0.8.tar.gz
-    Wrote: copr-build-example/rpkg-client-0.8-1.fc25.src.rpm
-    Uploading package rpkg-client-0.8-1.fc25.src.rpm
-    100% |################################| 49kB 263kB/s eta 0:00:00
-    Build was added to example:
-      https://copr.fedorainfracloud.org/coprs/build/625402/
-    Created builds: 625402
-    ...
-```
 ```
-    $ cd prep-example
-    $ ls .
-    doc  LICENSE  README.md  rpkg  rpkg.bash  rpkg-client.spec  rpkg.conf  rpkglib  run_tests.sh  setup.py  tests
-    $ rpkg make-source
-    Wrote: rpkg-client/rpkg-client-0.8.tar.gz
     $ rpkg prep
-    Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.bd5cCF
+    git_pack: Source file already exists. No action taken.
+    Wrote: /tmp/rpkg/rpkg-client.spec
+    Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.4iFciz
     + umask 022
-    ...
-    $ rpkg clean
+    + cd /tmp/rpkg/
+    + cd /tmp/rpkg
+    + rm -rf rpkg-client-1.0.git.122.e59a5b11
+    + /usr/bin/gzip -dc /tmp/rpkg/rpkg-client-1.0.git.122.e59a5b11.tar.gz
+    + /usr/bin/tar -xof -
+    + STATUS=0
+    + '[' 0 -ne 0 ']'
+    + cd rpkg-client-1.0.git.122.e59a5b11
+    + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+    + exit 0
 ```
 
-You can find more information and more examples in rpkg man pages (`man rpkg`).
+For the following command, you need to have a project in COPR created.
+See quick tutorial [here](https://docs.pagure.org/copr.copr/user_documentation.html#quick-start) on how to do it.
+
+```
+    $ rpkg copr-build @releng/rpkg-util
+    git_pack: Wrote: /tmp/rpkg/rpkg-util-1.0.git.122.e59a5b11.tar.gz
+    Wrote: /tmp/rpkg/rpkg-util.spec
+    Wrote: /tmp/rpkg/rpkg-util-1.0.git.122.e59a5b11-1.fc27.src.rpm
+    Uploading package /tmp/rpkg/rpkg-util-1.0.git.122.e59a5b11-1.fc27.src.rpm
+    100% |################################| 57kB 339kB/s eta 0:00:00
+    Build was added to rpkg-util:
+      https://copr.fedorainfracloud.org/coprs/build/724892/
+    Created builds: 724892
+    Watching build(s): (this may be safely interrupted)
+      15:50:12 Build 724892: importing ...
+```
+
+Other useful commands that you can use:
+
+- `rpkg lint` to check the .spec file and the overall package conformance to RPM standard
+- `rpkg local` to locally build the package into an rpm
+- `rpkg upload` to upload a new source to DistGit lookaside cache
+- `rpkg ...` (see `rpkg --help` or `man rpkg`)

From bba13a807d441714ded0cf0c2e1287e1302ba7e3 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 54/104] add check for dirty working tree into git_archive


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index f3a5a26..43437db 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -79,11 +79,16 @@ function git_pack {
 function git_archive {
     declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
 
-    if ! git rev-parse HEAD&>/dev/null; then
-        log_info "No commits yet. Cannot archive the content."
+    if ! git rev-parse HEAD &> /dev/null; then
+        log_error "No commits yet. Cannot archive the content."
         return 1
     fi
 
+    if git describe --dirty | grep -q -E '.*-dirty$'; then
+        log_error "Your working tree is dirty. Commit first."
+        return 2
+    fi
+
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
         output "$source_name"

From d9edd80e38135e97f2cf425374ad298bf6de28e8 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 55/104] when bash function is invoked directly from console, ${FUNCNAME[-1]} is not main


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 43437db..e5d8aaf 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -42,7 +42,11 @@ function log {
         return
     fi
 
-    echo "$PREFIX: ${FUNCNAME[-2]}: $@" > /dev/stderr
+    if [ ${FUNCNAME[-1]} != "main" ]; then
+        echo "$PREFIX: ${FUNCNAME[-1]}: $@"
+    else
+        echo "$PREFIX: ${FUNCNAME[-2]}: $@"
+    fi > /dev/stderr
 }
 
 ############## REPO FUNCTIONS ##############

From 95ce6350cbe71fa530c525da3ddca95d1a10fb7c Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 56/104] add missing quotes


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index e5d8aaf..5634ac3 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -140,7 +140,7 @@ function git_name {
         return 1
     fi
 
-    url_last_part="$(basename $url)"
+    url_last_part="$(basename "$url")"
     name="${url_last_part%.git}"
 
     output "${name}${appendix}"

From 85c7c4cfa95ec9224eec67ed56782db9613c64d2 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 57/104] fix rpmlint config file lookup in lint method


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index a1cc8eb..483edd2 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -201,9 +201,9 @@ class Commands(pyrpkg.Commands):
         if info:
             cmd.extend(['-i'])
         if rpmlintconf:
-            cmd.extend(["-f", os.path.join(self.outdir, rpmlintconf)])
-        elif os.path.exists(os.path.join(self.outdir, ".rpmlint")):
-            cmd.extend(["-f", os.path.join(self.outdir, ".rpmlint")])
+            cmd.extend(["-f", os.path.join(self.path, rpmlintconf)])
+        elif os.path.exists(os.path.join(self.path, ".rpmlint")):
+            cmd.extend(["-f", os.path.join(self.path, ".rpmlint")])
         cmd.append(os.path.join(self.outdir, self.spec))
         if os.path.exists(os.path.join(self.outdir, srpm)):
             cmd.append(os.path.join(self.outdir, srpm))

From ffb46eef94ee23cd338ef2ad493c4f3565af6bd2 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 58/104] encode also the latest file modification time into version if working tree is dirty


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 5634ac3..25fa523 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -4,6 +4,33 @@ declare -Ax __cached
 
 ############## HELPER FUNCTIONS ##############
 
+function encode_decimal {
+    radixdigits=(a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9)
+    x="$1"
+    result=
+    while [ "$x" -gt 0 ]; do
+        div=$(($x/${#radixdigits[@]}))
+        mod=$(($x-$div*${#radixdigits[@]}))
+        result="${radixdigits[$mod]}${result}"
+        x="$div"
+    done
+    echo -n "$result"
+}
+
+function git_latest_mtime {
+    mapfile -t files < <(git status --porcelain | cut -c 4- | sed -E -e 's|(.*) -> (.*)|\1\n\2|')
+    latest_mtime=0
+    for f in "${files[@]}"; do
+        if [ -f "$f" ]; then
+            mtime=$(stat --format='%Y' "$f")
+            if [ "$mtime" -gt "$latest_mtime" ]; then
+                latest_mtime="$mtime"
+            fi
+        fi
+    done
+    echo -n "$latest_mtime"
+}
+
 function name_convert {
     sed -e 's|/|-|g' -e 's|-$||'
 }
@@ -175,16 +202,23 @@ function git_version {
         commit_count="$(git rev-list HEAD --count 2> /dev/null || printf 0)"
     fi
 
-    if [ $commit_count -eq 0 ]; then
+    if [ "$commit_count" -eq 0 ]; then
         commit_count_appendix=
     else
         commit_count_appendix=".git.$commit_count.$(git rev-parse --short HEAD)"
     fi
 
+    latest_mtime="$(git_latest_mtime)"
+    if [ "$latest_mtime" -eq 0 ]; then
+        wtree_appendix=
+    else
+        wtree_appendix=".wtree.$(encode_decimal "$latest_mtime")"
+    fi
+
     if [ -n "$follow" ]; then
-        output "${lead}.${follow}${commit_count_appendix}"
+        output "${lead}.${follow}${commit_count_appendix}${wtree_appendix}"
     else
-        output "${latest_tag_version}${commit_count_appendix}"
+        output "${latest_tag_version}${commit_count_appendix}${wtree_appendix}"
     fi
 }
 

From 92a40bd8a52d6f2ecdc7661283469a9239d980a8 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 59/104] use brace expansion to generate radix digits, fix dirty check position in git archive


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 25fa523..f61aa61 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -5,7 +5,7 @@ declare -Ax __cached
 ############## HELPER FUNCTIONS ##############
 
 function encode_decimal {
-    radixdigits=(a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9)
+    radixdigits=({a..z} {0..9})
     x="$1"
     result=
     while [ "$x" -gt 0 ]; do
@@ -115,17 +115,17 @@ function git_archive {
         return 1
     fi
 
-    if git describe --dirty | grep -q -E '.*-dirty$'; then
-        log_error "Your working tree is dirty. Commit first."
-        return 2
-    fi
-
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
         output "$source_name"
         return
     fi
 
+    if git describe --dirty | grep -q -E '.*-dirty$'; then
+        log_error "Your working tree is dirty. Commit first."
+        return 2
+    fi
+
     if [ -f "$OUTDIR/$source_name" ] && [ -z "$force" ]; then
         log_info "Source file already exists. No action taken."
         output "$source_name"

From 4a7d0b9ef6cf3a93fecc39cd36c7d8596107bb8b Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 60/104] always regenerate the tarball


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index f61aa61..8cc3580 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -79,7 +79,7 @@ function log {
 ############## REPO FUNCTIONS ##############
 
 function git_pack {
-    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
+    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
 
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
@@ -87,12 +87,6 @@ function git_pack {
         return
     fi
 
-    if [ -f "$OUTDIR/$source_name" ] && [ -z "$force" ]; then
-        log_info "Source file already exists. No action taken."
-        output "$source_name"
-        return
-    fi
-
     cmd_stdout="$($SCRIPTDIR/scripts/pack_sources.sh "$path" "$dir_name" "$OUTDIR/$source_name")"
     cmd_retcode=$?
 
@@ -108,7 +102,7 @@ function git_pack {
 }
 
 function git_archive {
-    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" force= "$@"
+    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
 
     if ! git rev-parse HEAD &> /dev/null; then
         log_error "No commits yet. Cannot archive the content."
@@ -126,12 +120,6 @@ function git_archive {
         return 2
     fi
 
-    if [ -f "$OUTDIR/$source_name" ] && [ -z "$force" ]; then
-        log_info "Source file already exists. No action taken."
-        output "$source_name"
-        return
-    fi
-
     cmd_stdout="$(git -C "$path" archive --prefix="$dir_name/" -o "$OUTDIR/$source_name" HEAD)"
     cmd_retcode=$?
 

From 2f3f7d072c92e7bd880c71c40bea707065b4dfb1 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 61/104] fix Summary in spec


---

diff --git a/rpkg-client.spec b/rpkg-client.spec
index 72d1d73..9727594 100644
--- a/rpkg-client.spec
+++ b/rpkg-client.spec
@@ -1,7 +1,7 @@
 Name: rpkg-client
 Version: 0.14
 Release: 1%{?dist}
-Summary: RPM packaging utitility
+Summary: RPM packaging utility
 License: GPLv2+
 URL: https://pagure.io/rpkg-client.git
 

From 70d11dded9ea875cdce7d7899a72ccc431c02989 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 62/104] use ctime instead of mtime to account for file renames and permission changes


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 8cc3580..36178aa 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -17,18 +17,18 @@ function encode_decimal {
     echo -n "$result"
 }
 
-function git_latest_mtime {
+function git_latest_ctime {
     mapfile -t files < <(git status --porcelain | cut -c 4- | sed -E -e 's|(.*) -> (.*)|\1\n\2|')
-    latest_mtime=0
+    latest_ctime=0
     for f in "${files[@]}"; do
         if [ -f "$f" ]; then
-            mtime=$(stat --format='%Y' "$f")
-            if [ "$mtime" -gt "$latest_mtime" ]; then
-                latest_mtime="$mtime"
+            ctime=$(stat --format='%Z' "$f")
+            if [ "$ctime" -gt "$latest_ctime" ]; then
+                latest_ctime="$ctime"
             fi
         fi
     done
-    echo -n "$latest_mtime"
+    echo -n "$latest_ctime"
 }
 
 function name_convert {
@@ -196,11 +196,11 @@ function git_version {
         commit_count_appendix=".git.$commit_count.$(git rev-parse --short HEAD)"
     fi
 
-    latest_mtime="$(git_latest_mtime)"
-    if [ "$latest_mtime" -eq 0 ]; then
+    latest_ctime="$(git_latest_ctime)"
+    if [ "$latest_ctime" -eq 0 ]; then
         wtree_appendix=
     else
-        wtree_appendix=".wtree.$(encode_decimal "$latest_mtime")"
+        wtree_appendix=".wtree.$(encode_decimal "$latest_ctime")"
     fi
 
     if [ -n "$follow" ]; then

From f1e8c4996aeefeac1e4395f77ee604713a77510b Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 63/104] add header_date_format param for git_changelog, locale->header_locale, quoting


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 36178aa..77061a5 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -216,7 +216,7 @@ function git_source_name {
 }
 
 function git_changelog {
-    declare name="$(cached git_name)" since_tag= until_tag= locale=POSIX "$@"
+    declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" "$@"
 
     mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name-*" --merged 2> /dev/null)
 
@@ -228,14 +228,14 @@ function git_changelog {
         fi
         until_tag_hit="1"
 
-        data="$(git tag -l $tag --format='%(body)')"
+        data="$(git tag -l "$tag" --format='%(body)')"
         if [ -z "$data" ]; then
             log_debug "Skipping $tag with empty body."
             continue
         fi
 
-        verrel="$(echo $tag | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1\2/p")"
-        header="$(LC_ALL=$locale git tag -l $tag --format='* %(taggerdate:format:%a %b %d %Y) %(taggername) %(taggeremail)') $verrel"
+        verrel="$(echo "$tag" | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1\2/p")"
+        header="$(LC_ALL="$header_locale" git tag -l "$tag" --format="* %(taggerdate:format:$header_date_format) %(taggername) %(taggeremail)") $verrel"
         if [ -n "$changelog" ]; then
             changelog="$changelog"$'\n\n'
         fi

From 04903368c5d08be9afcaedb5382b923b08de6d97 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 64/104] nestedExpression is probably not what we want for parsing


---

diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
index 25f6d50..8f00cbb 100644
--- a/rpkg-client.spec.rpkg
+++ b/rpkg-client.spec.rpkg
@@ -88,7 +88,7 @@ cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
 %{_mandir}/*/*
 
 %changelog
-{{{ git_changelog }}}
+{{{ git_changelog header_locale="cs_CZ.UTF-8" header_date_format="%c" }}}
 
 * Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
 - add LICENSE to ignored file regex
diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index ddcc16b..5031b58 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -4,7 +4,7 @@ import tempfile
 import re
 
 from pyrpkg.errors import rpkgError
-from pyparsing import nestedExpr
+from pyparsing import Combine, CharsNotIn, Regex, ZeroOrMore, Group, Suppress, Keyword
 
 preproc_path = os.path.join(
     os.path.dirname(__file__), "preproc", "preproc.sh")
@@ -15,48 +15,60 @@ def log_line_strip(line):
 
 
 def invoke_wrapper(cwd, in_spec_path, outdir, app_log, env_store_name):
-    def invoke(toks):
-        subcmd = list(toks[0])
-
-        env = {
-            'OUTDIR': outdir,
-            'SPECPATH': in_spec_path,
-            'ENVSTORE': env_store_name,
-        }
-        p = subprocess.Popen([preproc_path]+subcmd,
-                             env=env, cwd=cwd,
-                             stderr=subprocess.PIPE,
-                             stdout=subprocess.PIPE)
-
-        app_log.debug('> subcmd: {}'.format(subcmd))
-        app_log.debug('> cwd: {}'.format(cwd))
-        app_log.debug('> env: {}'.format(env))
-
-        (stdout, stderr) = p.communicate()
-
-        for line in stderr.split('\n'):
-            if not line:
-                continue
-
-            if line.startswith('DEBUG:'):
-                log_func = app_log.debug
-            elif line.startswith('INFO:'):
-                log_func = app_log.info
+    def invoke(tokens):
+        retval = ""
+        for token in tokens:
+            cmd = '{} {}'.format(preproc_path, token)
+
+            env = {
+                'OUTDIR': outdir,
+                'SPECPATH': in_spec_path,
+                'ENVSTORE': env_store_name,
+            }
+            p = subprocess.Popen(cmd, shell=True,
+                                 env=env, cwd=cwd,
+                                 stderr=subprocess.PIPE,
+                                 stdout=subprocess.PIPE)
+
+            app_log.debug('> cmd: {}'.format(cmd))
+            app_log.debug('> cwd: {}'.format(cwd))
+            app_log.debug('> env: {}'.format(env))
+
+            (stdout, stderr) = p.communicate()
+
+            for line in stderr.split('\n'):
+                if not line:
+                    continue
+
+                if line.startswith('DEBUG:'):
+                    log_func = app_log.debug
+                elif line.startswith('INFO:'):
+                    log_func = app_log.info
+                else:
+                    log_func = app_log.error
+
+                stripped_line = log_line_strip(line)
+                log_func(stripped_line)
+
+            if p.returncode != 0:
+                raise rpkgError(
+                    "cmd {} failed with value {}"
+                    .format(cmd, p.returncode))
             else:
-                log_func = app_log.error
+                app_log.debug('---')
 
-            stripped_line = log_line_strip(line)
-            log_func(stripped_line)
+            retval += '\n' if retval else ''
+            retval += stdout
+        return retval
+    return invoke
 
-        if p.returncode != 0:
-            raise rpkgError(
-                "subcmd {} failed with value {}"
-                .format(subcmd, p.returncode))
-        else:
-            app_log.debug('---')
 
-        return stdout
-    return invoke
+def get_parse_expr():
+    opener, closer = '{{{', '}}}'
+    nonquoted = ~Keyword(opener) + ~Keyword(closer) + CharsNotIn('\n', exact=1)
+    quoted = Regex(r'".*"') ^ Regex(r"'.*'")
+    content = Combine(ZeroOrMore(nonquoted^quoted)).setParseAction(lambda t:t[0].strip())
+    return Suppress(opener) + content + Suppress(closer)
 
 
 def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False):
@@ -69,12 +81,11 @@ def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False)
 
     with open(in_spec_path, 'r') as f:
         in_spec_data = f.read()
-        expr = nestedExpr('{{{', '}}}')
 
-        expr.setParseAction(
+        expr = get_parse_expr().setParseAction(
             invoke_wrapper(path, in_spec_path, outdir, app_log, env_store_file.name))
-
         out_spec_data = expr.transformString(in_spec_data)
+
         outf = open(out_spec_path, 'w')
         outf.write(out_spec_data)
         outf.close()

From 1d99bd102a35e51e17e505d2780ea7153f2597e7 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 65/104] allow empty date format to get the git default


---

diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
index 8f00cbb..f020e31 100644
--- a/rpkg-client.spec.rpkg
+++ b/rpkg-client.spec.rpkg
@@ -88,7 +88,7 @@ cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
 %{_mandir}/*/*
 
 %changelog
-{{{ git_changelog header_locale="cs_CZ.UTF-8" header_date_format="%c" }}}
+{{{ git_changelog header_date_format= }}}
 
 * Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
 - add LICENSE to ignored file regex
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 77061a5..df98b74 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -220,6 +220,12 @@ function git_changelog {
 
     mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name-*" --merged 2> /dev/null)
 
+    if [ -n "$header_date_format" ]; then
+        header_date_format_suffix=":format:$header_date_format"
+    else
+        header_date_format_suffix=
+    fi
+
     changelog=
     until_tag_hit=
     for tag in "${tags[@]}"; do
@@ -235,7 +241,7 @@ function git_changelog {
         fi
 
         verrel="$(echo "$tag" | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1\2/p")"
-        header="$(LC_ALL="$header_locale" git tag -l "$tag" --format="* %(taggerdate:format:$header_date_format) %(taggername) %(taggeremail)") $verrel"
+        header="$(LC_ALL="$header_locale" git tag -l "$tag" --format="* %(taggerdate$header_date_format_suffix) %(taggername) %(taggeremail)") $verrel"
         if [ -n "$changelog" ]; then
             changelog="$changelog"$'\n\n'
         fi

From 0402b5288f6d25906c48daa8bd0ed2eaa2dc9b2a Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 66/104] revision version bumping, fix git_archive when repo is not inited


---

diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
index f020e31..aa1df54 100644
--- a/rpkg-client.spec.rpkg
+++ b/rpkg-client.spec.rpkg
@@ -1,5 +1,5 @@
 # vim: syntax=spec
-Name: {{{ git_name }}}
+Name: {{{ git_name name=rpkg-client }}}
 Version: {{{ git_version lead=1 }}}
 Release: 1%{?dist}
 Summary: RPM packaging utitility
@@ -88,7 +88,7 @@ cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
 %{_mandir}/*/*
 
 %changelog
-{{{ git_changelog header_date_format= }}}
+{{{ git_changelog }}}
 
 * Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
 - add LICENSE to ignored file regex
diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 483edd2..125c892 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -25,6 +25,7 @@ class Commands(pyrpkg.Commands):
         self.outdir = kwargs.pop("outdir")
         self.preprocess = kwargs.pop("preprocess")
         self.dump_spec_only = False
+        self.bump = False
         super(Commands, self).__init__(*args, **kwargs)
         self.source_entry_type = 'bsd'
         self.distgit_namespaced = True
@@ -85,9 +86,9 @@ class Commands(pyrpkg.Commands):
 
         self._repo_spec = spec
 
-    def load_spec(self, silent=False):
+    def load_spec(self):
         """This sets the spec attribute"""
-        self._spec = self.preprocess_spec(self.repo_spec, silent)
+        self._spec = self.preprocess_spec(self.repo_spec)
 
     @cached_property
     def lookasidecache(self):
@@ -324,7 +325,7 @@ class Commands(pyrpkg.Commands):
         self.log.info('Wrote: {}'.format(target_source_path))
         return target_source_path
 
-    def preprocess_spec(self, spec_templ, silent=False):
+    def preprocess_spec(self, spec_templ):
         out_spec_basename = os.path.basename(
             spec_templ[:-5] if spec_templ.endswith('.rpkg') else spec_templ)
 
@@ -332,12 +333,11 @@ class Commands(pyrpkg.Commands):
 
         if self.preprocess:
             preprocess(self.path, spec_templ, out_spec_path,
-                       self.log, self.dump_spec_only)
+                       self.log, self.dump_spec_only, self.bump)
         else:
             shutil.copy(spec_templ, out_spec_path)
 
-        log_func = self.log.debug if silent else self.log.info
-        log_func('Wrote: {}'.format(out_spec_path))
+        self.log.info('Wrote: {}'.format(out_spec_path))
         return out_spec_path
 
     @property
@@ -347,7 +347,17 @@ class Commands(pyrpkg.Commands):
             self.load_nameverrel()
         return self._module_name_spec
 
-    def git_tag(self, tagname, force=False, message=None, file=None, silent=False):
+    def add_tag(self, tagname, force=False, message=None, file=None):
+        """Add a git tag to the repository
+
+        Takes a tagname
+
+        Optionally can force the tag, include a message,
+        or reference a message file.
+
+        Runs the tag command and returns nothing
+
+        """
         if tagname in self.repo.tags:
             raise rpkgError("Tag {} already exists.".format(tagname))
 
@@ -365,89 +375,11 @@ class Commands(pyrpkg.Commands):
 
         cmd.append(tagname)
         utils.run_command(cmd, cwd=self.path)
+        self.log.info('Created tag: %s', tagname)
 
-        log_func = self.log.debug if silent else self.log.info
-        log_func('Created tag: %s', tagname)
-
-    def add_tag(self, tagname=None, force=False, message=None, file=None, ver_strip=".git.", rel_strip=".git."):
-        """Add a git tag to the repository
-
-        Takes a tagname
-
-        Optionally can force the tag, include a message,
-        or reference a message file.
-
-        Runs the tag command and returns nothing
-        """
-        if tagname:
-            self.git_tag(tagname, force, message, file)
-            return
-
-        if self.repo.is_dirty(path=self.repo_spec):
-            raise rpkgError('%s has uncommitted changes.' % self.repo_spec)
-
-        self.load_spec(silent=True)
-        ver = utils.strip_at(self.ver, ver_strip)
-        rel = utils.strip_at(self.rel, rel_strip)
-        ver_parts = ver.split('.')
-        rel_parts = rel.split('.')
-
-        if not ver_parts or not rel_parts:
-            raise rpkgError('Invalid version or release returned from %s.' % self.spec)
-
-        tagname_template = '{name}-{version}-{release}'
-        next_ver = ver
-        next_rel = rel
-
-        if re.match(r'^\d+$', ver_parts[-1]):
-            next_ver = utils.increment_ver(ver_parts)
-
-        if re.match(r'^\d+$', rel_parts[-1]):
-            next_rel = utils.increment_ver(rel_parts)
-
-        if next_ver == ver and next_rel == rel:
-            tagname = tagname_template.format(**{
-                'name': self.module_name,
-                'version': ver,
-                'release': rel,
-            })
-            self.git_tag(tagname, force, message, file)
-            return
-
-        tagname = tagname_template.format(**{
-            'name': self.module_name,
-            'version': next_ver,
-            'release': next_rel,
-        })
-
-        self.git_tag(tagname, message='tmp', silent=True)
-
-        try:
-            self.load_spec(silent=True)
-            self.load_nameverrel()
-        finally:
-            self.del_tag(tagname)
-
-        if utils.strip_at(self.ver, ver_strip) != next_ver:
-            self.log.debug('Spec does not follow version in the latest tag. Reverting.')
-            next_ver = ver
-
-        if utils.strip_at(self.rel, rel_strip) != next_rel:
-            self.log.debug('Spec does not follow release in the latest tag. Reverting.')
-            next_rel = rel
-
-        tagname = tagname_template.format(**{
-            'name': self.module_name,
-            'version': next_ver,
-            'release': next_rel,
-        })
-        self.git_tag(tagname, force, message, file)
+        self.bump = False
         self.load_spec()
 
-    def del_tag(self, tagname):
-        cmd = ['git', 'tag', '-d', tagname]
-        utils.run_command(cmd, cwd=self.path)
-
     def get_tag_message(self, tagname):
         tag_pattern = '{}*'.format(self.module_name)
 
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 2d7c6fb..7b1f889 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -153,19 +153,10 @@ class rpkgClient(cliClient):
 
     def tag(self):
         self.cmd.dump_spec_only = True
+        if not self.args.tag:
+            self.cmd.bump = True
         self.cmd._rpmdefines = self.cmd.rpmdefines + ["--define 'dist %nil'"]
-        if self.args.list:
-            self.cmd.list_tag(self.args.tag)
-        elif self.args.delete:
-            self.cmd.delete_tag(self.args.tag)
-        else:
-            filename = self.args.file
-            tagname = self.args.tag
-            if self.args.clog:
-                self.cmd.clog(self.args.raw)
-                filename = 'clog'
-            self.cmd.add_tag(tagname, self.args.force,
-                             self.args.message, filename)
+        super(rpkgClient, self).tag()
 
     def lint(self):
         self.cmd.dump_spec_only = True
diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 5031b58..c459c06 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -14,13 +14,16 @@ def log_line_strip(line):
     return re.sub(r'(DEBUG|INFO|ERROR):\s*(.*)\s*', r'\2', line)
 
 
-def invoke_wrapper(cwd, in_spec_path, outdir, app_log, env_store_name):
+def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log):
+    bump = str(bump) if bump else ''
+
     def invoke(tokens):
         retval = ""
         for token in tokens:
             cmd = '{} {}'.format(preproc_path, token)
 
             env = {
+                'BUMP': bump,
                 'OUTDIR': outdir,
                 'SPECPATH': in_spec_path,
                 'ENVSTORE': env_store_name,
@@ -52,13 +55,14 @@ def invoke_wrapper(cwd, in_spec_path, outdir, app_log, env_store_name):
 
             if p.returncode != 0:
                 raise rpkgError(
-                    "cmd {} failed with value {}"
+                    "{} failed with value {}"
                     .format(cmd, p.returncode))
             else:
                 app_log.debug('---')
 
             retval += '\n' if retval else ''
             retval += stdout
+
         return retval
     return invoke
 
@@ -71,19 +75,15 @@ def get_parse_expr():
     return Suppress(opener) + content + Suppress(closer)
 
 
-def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False):
-    if dump_spec_only:
-        outdir = ""
-    else:
-        outdir = os.path.dirname(out_spec_path)
-
+def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False, bump=False):
+    outdir = os.path.dirname(out_spec_path) if not dump_spec_only else ''
     env_store_file = tempfile.NamedTemporaryFile(delete=False)
 
     with open(in_spec_path, 'r') as f:
         in_spec_data = f.read()
 
-        expr = get_parse_expr().setParseAction(
-            invoke_wrapper(path, in_spec_path, outdir, app_log, env_store_file.name))
+        expr = get_parse_expr().setParseAction(invoke_wrapper(
+            path, in_spec_path, outdir, bump, env_store_file.name, app_log))
         out_spec_data = expr.transformString(in_spec_data)
 
         outf = open(out_spec_path, 'w')
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index df98b74..b107eb7 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -104,18 +104,18 @@ function git_pack {
 function git_archive {
     declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
 
-    if ! git rev-parse HEAD &> /dev/null; then
-        log_error "No commits yet. Cannot archive the content."
-        return 1
-    fi
-
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
         output "$source_name"
         return
     fi
 
-    if git describe --dirty | grep -q -E '.*-dirty$'; then
+    if ! git rev-parse HEAD &> /dev/null; then
+        log_error "No commits yet. Cannot archive the content."
+        return 1
+    fi
+
+    if git describe --dirty | grep -q '^.*-dirty$'; then
         log_error "Your working tree is dirty. Commit first."
         return 2
     fi
@@ -161,6 +161,30 @@ function git_name {
     output "${name}${appendix}"
 }
 
+function git_bumped_version {
+    declare lead= follow= latest_tag_version= "$@"
+
+    if [ -n "$follow" ]; then
+        echo -n "${lead}.${follow}"
+        return
+    fi
+
+    if [[ ! "$latest_tag_version" =~ ^$lead && $lead != 0 ]]; then
+        echo -n "${lead}.0"
+        return
+    fi
+
+    last_item="$(echo "$latest_tag_version" | sed -E -n "s/^.*\.([^.]*)$/\1/p")"
+
+    if echo "$last_item" | grep -q '[^0-9]'; then
+        log_error "$last_item is not a number. Please, bump version manually."
+        return 1
+    fi
+
+    bumped_last_item=$(( $last_item + 1 ))
+    echo -n "${lead}.${bumped_last_item}"
+}
+
 function git_version {
     declare name="$(cached git_name)" lead=0 follow= "$@"
 
@@ -173,6 +197,11 @@ function git_version {
         log_error "lead and follow cannot contain dashes."
         return 1
     fi
+
+    if echo "$follow" | grep -q '\.'; then
+        log_error "follow cannot contain dots."
+        return 1
+    fi
     
     mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-$lead*" --merged 2> /dev/null)
 
@@ -181,7 +210,18 @@ function git_version {
         latest_tag_version="$(echo $latest_tag | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1/p")"
     else
         latest_tag=
-        latest_tag_version="${lead}.0"
+        latest_tag_version=
+    fi
+
+    if [ -n "$BUMP" ]; then
+        version="$(git_bumped_version lead="$lead" follow="$follow" latest_tag_version="$latest_tag_version")"
+
+        retcode=$?
+        if [ $retcode -ne 0 ]; then
+            return $retcode
+        fi
+        output "$version"
+        return
     fi
 
     if [ -n "$latest_tag" ]; then
@@ -203,11 +243,11 @@ function git_version {
         wtree_appendix=".wtree.$(encode_decimal "$latest_ctime")"
     fi
 
-    if [ -n "$follow" ]; then
-        output "${lead}.${follow}${commit_count_appendix}${wtree_appendix}"
-    else
-        output "${latest_tag_version}${commit_count_appendix}${wtree_appendix}"
+    if [ -z "$follow" ]; then
+        follow="$(echo "$latest_tag_version" | sed -E -n "s/^.*\.([^.]*)$/\1/p")"
     fi
+
+    output "${lead}.${follow:-0}${commit_count_appendix}${wtree_appendix}"
 }
 
 function git_source_name {

From da9541e252a66b00ed98733d5e04d3be8eea3afa Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 67/104] code improvements


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index b107eb7..2a0ecba 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -174,15 +174,15 @@ function git_bumped_version {
         return
     fi
 
-    last_item="$(echo "$latest_tag_version" | sed -E -n "s/^.*\.([^.]*)$/\1/p")"
+    follow="$(echo "$latest_tag_version" | sed -E -n "s/^.*\.([^.]*)$/\1/p")"
 
-    if echo "$last_item" | grep -q '[^0-9]'; then
-        log_error "$last_item is not a number. Please, bump version manually."
+    if echo "$follow" | grep -q '[^0-9]'; then
+        log_error "$follow is not a number. Please, bump version manually."
         return 1
     fi
 
-    bumped_last_item=$(( $last_item + 1 ))
-    echo -n "${lead}.${bumped_last_item}"
+    bumped_follow=$(( $follow + 1 ))
+    echo -n "${lead}.${bumped_follow}"
 }
 
 function git_version {
@@ -203,7 +203,7 @@ function git_version {
         return 1
     fi
     
-    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name-$lead*" --merged 2> /dev/null)
+    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name*" --merged 2> /dev/null)
 
     if [ ${#tags[@]} -gt 0 ]; then
         latest_tag="${tags[-1]}"
@@ -258,7 +258,7 @@ function git_source_name {
 function git_changelog {
     declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" "$@"
 
-    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name-*" --merged 2> /dev/null)
+    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name*" --merged 2> /dev/null)
 
     if [ -n "$header_date_format" ]; then
         header_date_format_suffix=":format:$header_date_format"

From e3fd49132fa7e8a894a2e70fc3f538dc2bdc0b03 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 68/104] remove no longer needed function


---

diff --git a/rpkglib/utils.py b/rpkglib/utils.py
index f2cb9ab..b6ba5f7 100644
--- a/rpkglib/utils.py
+++ b/rpkglib/utils.py
@@ -82,12 +82,3 @@ def edit(editor, lines, help_text):
     tmp_f.close()
     os.unlink(tmp_f.name)
     return result
-
-
-def increment_ver(ver_parts):
-    ver_inc = str(int(ver_parts[-1])+1)
-    if ver_parts[:-1]:
-        lead_prefix = '.'.join(ver_parts[:-1]) + '.'
-    else:
-        lead_prefix = ""
-    return lead_prefix + ver_inc

From 31e2fb1112cfd32ba0d74a3e0cbb8e82bfbf0ed2 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 69/104] include changelog formatting also in git_changelog, variable and function cleanup


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 125c892..5d4114f 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -392,8 +392,8 @@ class Commands(pyrpkg.Commands):
         else:
             rev_list_expr = 'HEAD'
 
-        message_lines = [utils.changelog_get_line(commit.message) for commit
-                         in self.repo.iter_commits(rev_list_expr)]
+        entries = [utils.get_changelog_entry(commit.message)
+                   for commit in self.repo.iter_commits(rev_list_expr)]
 
         editor = self.repo.git.var('GIT_EDITOR')
         subject = "Commits: {0}".format(rev_list_expr)
@@ -403,5 +403,5 @@ class Commands(pyrpkg.Commands):
         "#   " + tagname + "\n"
         "# Lines starting with '#' will be ignored.\n")
 
-        body = utils.edit(editor, message_lines, help_text)
+        body = utils.edit(editor, entries, help_text)
         return '{0}\n\n{1}'.format(subject, body)
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 2a0ecba..a9f3bcd 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -256,7 +256,7 @@ function git_source_name {
 }
 
 function git_changelog {
-    declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" "$@"
+    declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" body_width=80 "$@"
 
     mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name*" --merged 2> /dev/null)
 
@@ -285,7 +285,9 @@ function git_changelog {
         if [ -n "$changelog" ]; then
             changelog="$changelog"$'\n\n'
         fi
-        changelog="${changelog}${header}"$'\n'"${data}"
+
+        formatted_data="$(echo "$data" | fold -cs --width="$body_width" | sed -E -e 's/(\s+)%([^%])/\1%%\2/g' -e 's/\s*$//')"
+        changelog="${changelog}${header}"$'\n'"${formatted_data}"
 
         if [ "$since_tag" = "$tag" ]; then
             break
diff --git a/rpkglib/utils.py b/rpkglib/utils.py
index b6ba5f7..73ed98f 100644
--- a/rpkglib/utils.py
+++ b/rpkglib/utils.py
@@ -50,13 +50,9 @@ def find_source_zero(rpm_sources):
     return None
 
 
-def changelog_get_line(message):
-    msg_first_line = '- ' + (message.split('\n')[0] if message else '')
-    return '\n'.join(textwrap.wrap(re.sub('r(\s+)%([^%])', r'\1%%\2', msg_first_line), 80))
-
-
-def strip_at(string, strip_token):
-    return re.sub(r'(.*){}.*'.format(re.escape(strip_token)), r'\1', string)
+def get_changelog_entry(commit_message):
+    entry = '- ' + commit_message.split('\n')[0] if commit_message else ''
+    return '\n'.join(textwrap.wrap(re.sub('r(\s+)%([^%])', r'\1%%\2', entry), 80))
 
 
 def run_command(cmd, shell=False, env=None, cwd=None):

From 502db81bf7e466d674885211fbab13f43877abc5 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 70/104] bash tweaks according shellcheck


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index a9f3bcd..343486c 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -36,7 +36,7 @@ function name_convert {
 }
 
 function output {
-    __cached["${FUNCNAME[1]}"]="$@"
+    __cached["${FUNCNAME[1]}"]="$*"
     echo -n "${__cached[${FUNCNAME[1]}]}"
 }
 
@@ -69,10 +69,10 @@ function log {
         return
     fi
 
-    if [ ${FUNCNAME[-1]} != "main" ]; then
-        echo "$PREFIX: ${FUNCNAME[-1]}: $@"
+    if [ "${FUNCNAME[-1]}" != "main" ]; then
+        echo "$PREFIX: ${FUNCNAME[-1]}: $*"
     else
-        echo "$PREFIX: ${FUNCNAME[-2]}: $@"
+        echo "$PREFIX: ${FUNCNAME[-2]}: $*"
     fi > /dev/stderr
 }
 
@@ -305,15 +305,15 @@ function git_setup_macro {
 ############## DIR FUNCTIONS ##############
 
 function git_dir_pack {
-    git_pack path="$(dirname $SPECPATH)" "$@"
+    git_pack path="$(dirname "$SPECPATH")" "$@"
 }
 
 function git_dir_archive {
-    git_archive path="$(dirname $SPECPATH)" "$@"
+    git_archive path="$(dirname "$SPECPATH")" "$@"
 }
 
 function git_dir_name {
-    git_name append="$(git -C $(dirname $SPECPATH) rev-parse --show-prefix | name_convert)" "$@"
+    git_name append="$(git -C $(dirname "$SPECPATH") rev-parse --show-prefix | name_convert)" "$@"
 }
 
 function git_dir_source_name {
@@ -343,7 +343,7 @@ function git_cwd_archive {
 }
 
 function git_cwd_name {
-    git_name append="$(git -C $(pwd) rev-parse --show-prefix | name_convert)" "$@"
+    git_name append="$(git -C "$(pwd)" rev-parse --show-prefix | name_convert)" "$@"
 }
 
 function git_cwd_source_name {

From 50cd6237af9776a8b98e881a90def889819d6553 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 71/104] use token in error log to get more dense output


---

diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index c459c06..0ef1258 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -56,7 +56,7 @@ def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log):
             if p.returncode != 0:
                 raise rpkgError(
                     "{} failed with value {}"
-                    .format(cmd, p.returncode))
+                    .format(token, p.returncode))
             else:
                 app_log.debug('---')
 

From a55b6dc012b53c5d242047c944543d4aad514e0b Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 72/104] only fetch follows of a given lead from tag, code cleanup


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 343486c..6fee743 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -165,24 +165,24 @@ function git_bumped_version {
     declare lead= follow= latest_tag_version= "$@"
 
     if [ -n "$follow" ]; then
-        echo -n "${lead}.${follow}"
+        echo -n "$lead.$follow"
         return
     fi
 
-    if [[ ! "$latest_tag_version" =~ ^$lead && $lead != 0 ]]; then
-        echo -n "${lead}.0"
+    follow="$(echo "$latest_tag_version" | sed -E -n "s/^$lead\.([^.]*)$/\1/p")"
+
+    if [ -z "$follow" ] && [ $lead -ne 0 ]; then
+        echo -n "$lead.0"
         return
     fi
 
-    follow="$(echo "$latest_tag_version" | sed -E -n "s/^.*\.([^.]*)$/\1/p")"
-
     if echo "$follow" | grep -q '[^0-9]'; then
         log_error "$follow is not a number. Please, bump version manually."
         return 1
     fi
 
     bumped_follow=$(( $follow + 1 ))
-    echo -n "${lead}.${bumped_follow}"
+    echo -n "$lead.$bumped_follow"
 }
 
 function git_version {
@@ -244,7 +244,7 @@ function git_version {
     fi
 
     if [ -z "$follow" ]; then
-        follow="$(echo "$latest_tag_version" | sed -E -n "s/^.*\.([^.]*)$/\1/p")"
+        follow="$(echo "$latest_tag_version" | sed -E -n "s/^$lead\.([^.]*)$/\1/p")"
     fi
 
     output "${lead}.${follow:-0}${commit_count_appendix}${wtree_appendix}"

From c04722e7a74d9bcfe6e67e569fba726dd163e0f5 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 73/104] use Literal instead of Keyword for parsing so that e.g. '{{{ foo}}}' is parsed


---

diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 0ef1258..967cb89 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -4,7 +4,7 @@ import tempfile
 import re
 
 from pyrpkg.errors import rpkgError
-from pyparsing import Combine, CharsNotIn, Regex, ZeroOrMore, Group, Suppress, Keyword
+from pyparsing import Combine, CharsNotIn, Regex, ZeroOrMore, Group, Suppress, Literal
 
 preproc_path = os.path.join(
     os.path.dirname(__file__), "preproc", "preproc.sh")
@@ -69,7 +69,7 @@ def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log):
 
 def get_parse_expr():
     opener, closer = '{{{', '}}}'
-    nonquoted = ~Keyword(opener) + ~Keyword(closer) + CharsNotIn('\n', exact=1)
+    nonquoted = ~Literal(opener) + ~Literal(closer) + CharsNotIn('\n', exact=1)
     quoted = Regex(r'".*"') ^ Regex(r"'.*'")
     content = Combine(ZeroOrMore(nonquoted^quoted)).setParseAction(lambda t:t[0].strip())
     return Suppress(opener) + content + Suppress(closer)

From 5c1f929f99676846fafbc988e66c8388f68809a4 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 74/104] add git_vcs macro to denote canonical source


---

diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
index aa1df54..47766f7 100644
--- a/rpkg-client.spec.rpkg
+++ b/rpkg-client.spec.rpkg
@@ -5,6 +5,7 @@ Release: 1%{?dist}
 Summary: RPM packaging utitility
 License: GPLv2+
 URL: https://pagure.io/rpkg-client.git
+VCS: {{{ git_vcs }}}
 
 # How to obtain the sources
 # git clone https://pagure.io/rpkg-client.git
diff --git a/rpkg-client.spec.rpkg.cwd b/rpkg-client.spec.rpkg.cwd
index 145e9b3..a96bc13 100644
--- a/rpkg-client.spec.rpkg.cwd
+++ b/rpkg-client.spec.rpkg.cwd
@@ -5,6 +5,7 @@ Release: 1%{?dist}
 Summary: RPM packaging utitility
 License: GPLv2+
 URL: https://pagure.io/rpkg-client.git
+VCS: {{{ git_cwd_vcs }}}
 
 # How to obtain the sources
 # git clone https://pagure.io/rpkg-client.git
diff --git a/rpkg-client.spec.rpkg.dir b/rpkg-client.spec.rpkg.dir
index b341493..2d64745 100644
--- a/rpkg-client.spec.rpkg.dir
+++ b/rpkg-client.spec.rpkg.dir
@@ -5,6 +5,7 @@ Release: 1%{?dist}
 Summary: RPM packaging utitility
 License: GPLv2+
 URL: https://pagure.io/rpkg-client.git
+VCS: {{{ git_dir_vcs }}}
 
 # How to obtain the sources
 # git clone https://pagure.io/rpkg-client.git
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 6fee743..eb415b3 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -78,6 +78,27 @@ function log {
 
 ############## REPO FUNCTIONS ##############
 
+function git_vcs {
+    declare subtree= "$@"
+
+    url="$(git config --get remote.origin.url)"
+
+    if [ -z "$url" ]; then
+        log_error "Start by setting origin URL."
+        return 1
+    fi
+
+    ref="$(git rev-parse HEAD 2> /dev/null)"
+
+    if [ -n "$ref" ]; then
+        treeish_suffix="#$ref:$subtree"
+    else
+        treeish_suffix=
+    fi
+
+    output "git+${url}${treeish_suffix}"
+}
+
 function git_pack {
     declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
 
@@ -304,6 +325,10 @@ function git_setup_macro {
 
 ############## DIR FUNCTIONS ##############
 
+function git_dir_vcs {
+    git_vcs subtree="$(git -C "$(dirname "$SPECPATH")" rev-parse --show-prefix)" "$@"
+}
+
 function git_dir_pack {
     git_pack path="$(dirname "$SPECPATH")" "$@"
 }
@@ -313,7 +338,7 @@ function git_dir_archive {
 }
 
 function git_dir_name {
-    git_name append="$(git -C $(dirname "$SPECPATH") rev-parse --show-prefix | name_convert)" "$@"
+    git_name append="$(git -C "$(dirname "$SPECPATH")" rev-parse --show-prefix | name_convert)" "$@"
 }
 
 function git_dir_source_name {
@@ -334,6 +359,10 @@ function git_dir_setup_macro {
 
 ############## CURRENT WORKING DIR FUNCTIONS ##############
 
+function git_cwd_vcs {
+    git_vcs subtree="$(git -C "$(pwd)" rev-parse --show-prefix)" "$@"
+}
+
 function git_cwd_pack {
     git_pack path="$(pwd)" "$@"
 }

From 5a19ed81caafc1780faa5d8340c291dd18c487fb Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 75/104] reorder functions in lib.sh, body_width -> body_wrap in git_changelog


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index eb415b3..dc3c6dc 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -78,83 +78,6 @@ function log {
 
 ############## REPO FUNCTIONS ##############
 
-function git_vcs {
-    declare subtree= "$@"
-
-    url="$(git config --get remote.origin.url)"
-
-    if [ -z "$url" ]; then
-        log_error "Start by setting origin URL."
-        return 1
-    fi
-
-    ref="$(git rev-parse HEAD 2> /dev/null)"
-
-    if [ -n "$ref" ]; then
-        treeish_suffix="#$ref:$subtree"
-    else
-        treeish_suffix=
-    fi
-
-    output "git+${url}${treeish_suffix}"
-}
-
-function git_pack {
-    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
-
-    if [ -z "$OUTDIR" ]; then
-        log_debug "OUTDIR is not set. No action taken."
-        output "$source_name"
-        return
-    fi
-
-    cmd_stdout="$($SCRIPTDIR/scripts/pack_sources.sh "$path" "$dir_name" "$OUTDIR/$source_name")"
-    cmd_retcode=$?
-
-    log_debug "$cmd_stdout"
-
-    if [ $cmd_retcode -eq 0 ]; then
-        log_info "Wrote: $OUTDIR/$source_name"
-    else
-        log_error "Error during source creation."
-    fi
-
-    output "$source_name"
-}
-
-function git_archive {
-    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
-
-    if [ -z "$OUTDIR" ]; then
-        log_debug "OUTDIR is not set. No action taken."
-        output "$source_name"
-        return
-    fi
-
-    if ! git rev-parse HEAD &> /dev/null; then
-        log_error "No commits yet. Cannot archive the content."
-        return 1
-    fi
-
-    if git describe --dirty | grep -q '^.*-dirty$'; then
-        log_error "Your working tree is dirty. Commit first."
-        return 2
-    fi
-
-    cmd_stdout="$(git -C "$path" archive --prefix="$dir_name/" -o "$OUTDIR/$source_name" HEAD)"
-    cmd_retcode=$?
-
-    log_debug "$cmd_stdout"
-
-    if [ $cmd_retcode -eq 0 ]; then
-        log_info "Wrote: $OUTDIR/$source_name"
-    else
-        log_error "Error during source creation."
-    fi
-
-    output "$source_name"
-}
-
 function git_name {
     declare name= append= "$@"
 
@@ -183,7 +106,7 @@ function git_name {
 }
 
 function git_bumped_version {
-    declare lead= follow= latest_tag_version= "$@"
+    declare lead=0 follow= latest_tag_version= "$@"
 
     if [ -n "$follow" ]; then
         echo -n "$lead.$follow"
@@ -241,6 +164,7 @@ function git_version {
         if [ $retcode -ne 0 ]; then
             return $retcode
         fi
+
         output "$version"
         return
     fi
@@ -271,13 +195,95 @@ function git_version {
     output "${lead}.${follow:-0}${commit_count_appendix}${wtree_appendix}"
 }
 
+function git_vcs {
+    declare subtree= "$@"
+
+    url="$(git config --get remote.origin.url)"
+
+    if [ -z "$url" ]; then
+        log_error "Start by setting origin URL."
+        return 1
+    fi
+
+    ref="$(git rev-parse HEAD 2> /dev/null)"
+
+    if [ -n "$ref" ]; then
+        treeish_suffix="#$ref:$subtree"
+    else
+        treeish_suffix=
+    fi
+
+    output "git+${url}${treeish_suffix}"
+}
+
+function git_pack {
+    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
+
+    if [ -z "$OUTDIR" ]; then
+        log_debug "OUTDIR is not set. No action taken."
+        output "$source_name"
+        return
+    fi
+
+    cmd_stdout="$($SCRIPTDIR/scripts/pack_sources.sh "$path" "$dir_name" "$OUTDIR/$source_name")"
+    cmd_retcode=$?
+
+    log_debug "$cmd_stdout"
+
+    if [ $cmd_retcode -eq 0 ]; then
+        log_info "Wrote: $OUTDIR/$source_name"
+    else
+        log_error "Error during source creation."
+    fi
+
+    output "$source_name"
+}
+
+function git_archive {
+    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
+
+    if [ -z "$OUTDIR" ]; then
+        log_debug "OUTDIR is not set. No action taken."
+        output "$source_name"
+        return
+    fi
+
+    if ! git rev-parse HEAD &> /dev/null; then
+        log_error "No commits yet. Cannot archive the content."
+        return 1
+    fi
+
+    if git describe --dirty | grep -q '^.*-dirty$'; then
+        log_error "Your working tree is dirty. Commit first."
+        return 2
+    fi
+
+    cmd_stdout="$(git -C "$path" archive --prefix="$dir_name/" -o "$OUTDIR/$source_name" HEAD)"
+    cmd_retcode=$?
+
+    log_debug "$cmd_stdout"
+
+    if [ $cmd_retcode -eq 0 ]; then
+        log_info "Wrote: $OUTDIR/$source_name"
+    else
+        log_error "Error during source creation."
+    fi
+
+    output "$source_name"
+}
+
 function git_source_name {
     declare name="$(cached git_name)" version="$(cached git_version)" format=tar.gz "$@"
     output "$name-$version.$format"
 }
 
+function git_setup_macro {
+    declare dir_name="$(cached git_name)-$(cached git_version)" "$@"
+    output "%setup -q -n $dir_name"
+}
+
 function git_changelog {
-    declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" body_width=80 "$@"
+    declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" body_wrap=80 "$@"
 
     mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name*" --merged 2> /dev/null)
 
@@ -293,7 +299,7 @@ function git_changelog {
         if [ -n "$until_tag" ] && [ -z "$until_tag_hit" ] && [ "$until_tag" != "$tag" ]; then
             continue
         fi
-        until_tag_hit="1"
+        until_tag_hit=1
 
         data="$(git tag -l "$tag" --format='%(body)')"
         if [ -z "$data" ]; then
@@ -307,7 +313,7 @@ function git_changelog {
             changelog="$changelog"$'\n\n'
         fi
 
-        formatted_data="$(echo "$data" | fold -cs --width="$body_width" | sed -E -e 's/(\s+)%([^%])/\1%%\2/g' -e 's/\s*$//')"
+        formatted_data="$(echo "$data" | fold -cs --width="$body_wrap" | sed -E -e 's/(\s+)%([^%])/\1%%\2/g' -e 's/\s*$//')"
         changelog="${changelog}${header}"$'\n'"${formatted_data}"
 
         if [ "$since_tag" = "$tag" ]; then
@@ -318,12 +324,15 @@ function git_changelog {
     output "$changelog"
 }
 
-function git_setup_macro {
-    declare dir_name="$(cached git_name)-$(cached git_version)" "$@"
-    output "%setup -q -n $dir_name"
+############## DIR FUNCTIONS ##############
+
+function git_dir_name {
+    git_name append="$(git -C "$(dirname "$SPECPATH")" rev-parse --show-prefix | name_convert)" "$@"
 }
 
-############## DIR FUNCTIONS ##############
+function git_dir_version {
+    git_version "$@"
+}
 
 function git_dir_vcs {
     git_vcs subtree="$(git -C "$(dirname "$SPECPATH")" rev-parse --show-prefix)" "$@"
@@ -337,27 +346,27 @@ function git_dir_archive {
     git_archive path="$(dirname "$SPECPATH")" "$@"
 }
 
-function git_dir_name {
-    git_name append="$(git -C "$(dirname "$SPECPATH")" rev-parse --show-prefix | name_convert)" "$@"
-}
-
 function git_dir_source_name {
     git_source_name "$@"
 }
 
-function git_dir_version {
-    git_version "$@"
+function git_dir_setup_macro {
+    git_setup_macro "$@"
 }
 
 function git_dir_changelog {
     git_changelog "$@"
 }
 
-function git_dir_setup_macro {
-    git_setup_macro "$@"
+############## CURRENT WORKING DIR FUNCTIONS ##############
+
+function git_cwd_name {
+    git_name append="$(git -C "$(pwd)" rev-parse --show-prefix | name_convert)" "$@"
 }
 
-############## CURRENT WORKING DIR FUNCTIONS ##############
+function git_cwd_version {
+    git_version "$@"
+}
 
 function git_cwd_vcs {
     git_vcs subtree="$(git -C "$(pwd)" rev-parse --show-prefix)" "$@"
@@ -371,22 +380,14 @@ function git_cwd_archive {
     git_archive path="$(pwd)" "$@"
 }
 
-function git_cwd_name {
-    git_name append="$(git -C "$(pwd)" rev-parse --show-prefix | name_convert)" "$@"
-}
-
 function git_cwd_source_name {
     git_source_name "$@"
 }
 
-function git_cwd_version {
-    git_version "$@"
+function git_cwd_setup_macro {
+    git_setup_macro "$@"
 }
 
 function git_cwd_changelog {
     git_changelog "$@"
 }
-
-function git_cwd_setup_macro {
-    git_setup_macro "$@"
-}

From 54db8db3712fc3fe119ca79c96bf42dc6aa6fec3 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 76/104] we shouldn't invoke the command in 'cached', improve exit control


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index dc3c6dc..377ce0d 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -43,9 +43,7 @@ function output {
 function cached {
     if [ -n "${__cached[$1]}" ]; then
         echo -n "${__cached[$1]}"
-        return
     fi
-    "$@"
 }
 
 function log_debug {
@@ -234,6 +232,7 @@ function git_pack {
         log_info "Wrote: $OUTDIR/$source_name"
     else
         log_error "Error during source creation."
+        return $cmd_retcode
     fi
 
     output "$source_name"
@@ -267,6 +266,7 @@ function git_archive {
         log_info "Wrote: $OUTDIR/$source_name"
     else
         log_error "Error during source creation."
+        return $cmd_retcode
     fi
 
     output "$source_name"
diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
index abeb86a..a79591f 100755
--- a/rpkglib/preproc/preproc.sh
+++ b/rpkglib/preproc/preproc.sh
@@ -8,8 +8,10 @@ if [ -f ./rpkg.sh ]; then
     source ./rpkg.sh
 fi
 
-"$@"
+("$@")
 retcode=$?
 
-declare -x > $ENVSTORE
+if [ $retcode -eq 0 ]; then
+    declare -x > $ENVSTORE
+fi
 exit $retcode

From b848b2aa800b0532ff3e8d28f1c1ada9873ea05e Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 77/104] macro tests initial setup


---

diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 967cb89..97e3b66 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -14,7 +14,7 @@ def log_line_strip(line):
     return re.sub(r'(DEBUG|INFO|ERROR):\s*(.*)\s*', r'\2', line)
 
 
-def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log):
+def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log, break_on_error):
     bump = str(bump) if bump else ''
 
     def invoke(tokens):
@@ -33,7 +33,7 @@ def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log):
                                  stderr=subprocess.PIPE,
                                  stdout=subprocess.PIPE)
 
-            app_log.debug('> cmd: {}'.format(cmd))
+            app_log.debug('> {}'.format(token))
             app_log.debug('> cwd: {}'.format(cwd))
             app_log.debug('> env: {}'.format(env))
 
@@ -54,12 +54,15 @@ def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log):
                 log_func(stripped_line)
 
             if p.returncode != 0:
-                raise rpkgError(
-                    "{} failed with value {}"
-                    .format(token, p.returncode))
-            else:
-                app_log.debug('---')
+                error_msg = "{} failed with value {}".format(
+                    token, p.returncode)
 
+                if break_on_error:
+                    raise rpkgError(error_msg)
+
+                app_log.error(error_msg)
+
+            app_log.debug('---')
             retval += '\n' if retval else ''
             retval += stdout
 
@@ -75,7 +78,7 @@ def get_parse_expr():
     return Suppress(opener) + content + Suppress(closer)
 
 
-def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False, bump=False):
+def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False, bump=False, break_on_error=True):
     outdir = os.path.dirname(out_spec_path) if not dump_spec_only else ''
     env_store_file = tempfile.NamedTemporaryFile(delete=False)
 
@@ -83,7 +86,7 @@ def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False,
         in_spec_data = f.read()
 
         expr = get_parse_expr().setParseAction(invoke_wrapper(
-            path, in_spec_path, outdir, bump, env_store_file.name, app_log))
+            path, in_spec_path, outdir, bump, env_store_file.name, app_log, break_on_error))
         out_spec_data = expr.transformString(in_spec_data)
 
         outf = open(out_spec_path, 'w')
diff --git a/tests/preproc/input_git b/tests/preproc/input_git
new file mode 100644
index 0000000..a9efbd7
--- /dev/null
+++ b/tests/preproc/input_git
@@ -0,0 +1,55 @@
+{{{ git_name }}}
+{{{ git_name name=foo }}}
+{{{ git_name name=foo append=foo-bar }}}
+{{{ git_name append=foo }}}
+{{{ git_name append=foo-bar }}}
+
+{{{ git_version }}}
+{{{ git_version name=foo }}}
+{{{ git_version lead=1 }}}
+{{{ git_version lead=0.1 }}}
+{{{ git_version follow=2 }}}
+{{{ git_version lead=1 follow=2 }}}
+{{{ git_version lead=x follow=x }}}
+{{{ git_version lead=1-1 }}} # invalid
+{{{ git_version follow=2.0 }}} # invalid
+{{{ git_version follow=2-2 }}} # invalid
+{{{ git_version name= }}} # invalid
+
+{{{ git_bumped_version }}}
+{{{ git_bumped_version lead=1 }}}
+{{{ git_bumped_version follow=2 }}}
+{{{ git_bumped_version lead=1 follow=2 }}}
+{{{ git_bumped_version lead=1 latest_tag_version=1.2 }}}
+{{{ git_bumped_version follow=2 latest_tag_version=1.4 }}}
+{{{ git_bumped_version latest_tag_version=1.2 }}}
+{{{ git_bumped_version latest_tag_version=0.1.2 }}}
+{{{ git_bumped_version latest_tag_version=1.x }}}
+{{{ git_bumped_version latest_tag_version=0.1.x }}}
+{{{ git_bumped_version latest_tag_version=0.1 }}}
+{{{ git_bumped_version follow=2.0 }}} # invalid but works
+{{{ git_bumped_version latest_tag_version=1-2 }}} # invalid but works
+
+{{{ git_vcs }}}
+{{{ git_vcs subtree=foo }}}
+
+{{{ git_pack }}}
+{{{ git_pack dir_name=foo }}}
+{{{ git_pack dir_name=foo source_name=foo.tar.gz }}}
+{{{ git_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+{{{ git_archive }}}
+{{{ git_archive dir_name=foo }}}
+{{{ git_archive dir_name=foo source_name=foo.tar.gz }}}
+{{{ git_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+{{{ git_source_name }}}
+{{{ git_source_name name=foo }}}
+{{{ git_source_name version=1.2 }}}
+{{{ git_source_name name=foo version=1.2 format=tar }}}
+
+{{{ git_changelog }}}
+{{{ git_changelog since_tag=foo-1.2 }}}
+{{{ git_changelog until_tag=foo-1.2 }}}
+{{{ git_changelog since_tag=foo-1.2 until_tag=foo-1.4 }}}
+{{{ git_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
diff --git a/tests/preproc/input_git_cwd b/tests/preproc/input_git_cwd
new file mode 100644
index 0000000..d41586a
--- /dev/null
+++ b/tests/preproc/input_git_cwd
@@ -0,0 +1,39 @@
+{{{ git_cwd_name }}}
+{{{ git_cwd_name append=foo }}}
+{{{ git_cwd_name append=foo-bar }}}
+
+{{{ git_cwd_version }}}
+{{{ git_cwd_version name=foo }}}
+{{{ git_cwd_version lead=1 }}}
+{{{ git_cwd_version lead=0.1 }}}
+{{{ git_cwd_version follow=2 }}}
+{{{ git_cwd_version lead=1 follow=2 }}}
+{{{ git_cwd_version lead=x follow=x }}}
+{{{ git_cwd_version lead=1-1 }}} # invalid
+{{{ git_cwd_version follow=2.0 }}} # invalid
+{{{ git_cwd_version follow=2-2 }}} # invalid
+{{{ git_cwd_version name= }}} # invalid
+
+{{{ git_cwd_vcs }}}
+{{{ git_cwd_vcs subtree=foo }}}
+
+{{{ git_cwd_pack }}}
+{{{ git_cwd_pack dir_name=foo }}}
+{{{ git_cwd_pack dir_name=foo source_name=foo.tar.gz }}}
+{{{ git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+{{{ git_cwd_archive }}}
+{{{ git_cwd_archive dir_name=foo }}}
+{{{ git_cwd_archive dir_name=foo source_name=foo.tar.gz }}}
+{{{ git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+{{{ git_cwd_source_name }}}
+{{{ git_cwd_source_name name=foo }}}
+{{{ git_cwd_source_name version=1.2 }}}
+{{{ git_cwd_source_name name=foo version=1.2 format=tar }}}
+
+{{{ git_cwd_changelog }}}
+{{{ git_cwd_changelog since_tag=foo-1.2 }}}
+{{{ git_cwd_changelog until_tag=foo-1.2 }}}
+{{{ git_cwd_changelog since_tag=foo-1.2 until_tag=foo-1.4 }}}
+{{{ git_cwd_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
diff --git a/tests/preproc/input_git_dir b/tests/preproc/input_git_dir
new file mode 100644
index 0000000..0ad1e6f
--- /dev/null
+++ b/tests/preproc/input_git_dir
@@ -0,0 +1,39 @@
+{{{ git_dir_name }}}
+{{{ git_dir_name append=foo }}}
+{{{ git_dir_name append=foo-bar }}}
+
+{{{ git_dir_version }}}
+{{{ git_dir_version name=foo }}}
+{{{ git_dir_version lead=1 }}}
+{{{ git_dir_version lead=0.1 }}}
+{{{ git_dir_version follow=2 }}}
+{{{ git_dir_version lead=1 follow=2 }}}
+{{{ git_dir_version lead=x follow=x }}}
+{{{ git_dir_version lead=1-1 }}} # invalid
+{{{ git_dir_version follow=2.0 }}} # invalid
+{{{ git_dir_version follow=2-2 }}} # invalid
+{{{ git_dir_version name= }}} # invalid
+
+{{{ git_dir_vcs }}}
+{{{ git_dir_vcs subtree=foo }}}
+
+{{{ git_dir_pack }}}
+{{{ git_dir_pack dir_name=foo }}}
+{{{ git_dir_pack dir_name=foo source_name=foo.tar.gz }}}
+{{{ git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+{{{ git_dir_archive }}}
+{{{ git_dir_archive dir_name=foo }}}
+{{{ git_dir_archive dir_name=foo source_name=foo.tar.gz }}}
+{{{ git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+{{{ git_dir_source_name }}}
+{{{ git_dir_source_name name=foo }}}
+{{{ git_dir_source_name version=1.2 }}}
+{{{ git_dir_source_name name=foo version=1.2 format=tar }}}
+
+{{{ git_dir_changelog }}}
+{{{ git_dir_changelog since_tag=foo-1.2 }}}
+{{{ git_dir_changelog until_tag=foo-1.2 }}}
+{{{ git_dir_changelog since_tag=foo-1.2 until_tag=foo-1.4 }}}
+{{{ git_dir_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
diff --git a/tests/preproc/lib.sh b/tests/preproc/lib.sh
new file mode 100644
index 0000000..72820ee
--- /dev/null
+++ b/tests/preproc/lib.sh
@@ -0,0 +1,10 @@
+export libdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+  
+die() {
+    echo "fail." 
+    exit 1
+}
+
+log_filter() {
+    grep -Ev '^> (env|cwd):.*$'
+}
diff --git a/tests/preproc/run.sh b/tests/preproc/run.sh
new file mode 100755
index 0000000..647c954
--- /dev/null
+++ b/tests/preproc/run.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+export scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+for dir in `ls -d $scriptdir/test_*/`; do
+	$dir/test.sh || exit 1
+done
diff --git a/tests/preproc/run_preproc.py b/tests/preproc/run_preproc.py
new file mode 100755
index 0000000..54019d4
--- /dev/null
+++ b/tests/preproc/run_preproc.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python2
+
+import os
+import sys
+import logging
+import argparse
+
+project_path = os.path.realpath(os.path.join(os.path.realpath(__file__), '../../../'))
+sys.path.insert(0, project_path)
+
+from rpkglib.preproc import preprocess
+
+log = logging.getLogger(__name__)
+log.addHandler(logging.StreamHandler(sys.stdout))
+log.setLevel(logging.DEBUG)
+
+parser = argparse.ArgumentParser()
+
+parser.add_argument('--path', default='.')
+parser.add_argument('--input', required=True)
+parser.add_argument('--output', required=True)
+parser.add_argument('--dump-spec-only', action='store_true')
+parser.add_argument('--bump', action='store_true')
+parser.add_argument('--break-on-error', action='store_true')
+
+args = parser.parse_args()
+
+try:
+    preprocess(
+        args.path,
+        args.input,
+        args.output,
+        dump_spec_only=args.dump_spec_only,
+        bump=args.bump,
+        break_on_error=args.break_on_error,
+        app_log=log)
+
+except Exception as e:
+    log.error(str(e))
diff --git a/tests/preproc/test_inited/log_git b/tests/preproc/test_inited/log_git
new file mode 100644
index 0000000..675cab4
--- /dev/null
+++ b/tests/preproc/test_inited/log_git
@@ -0,0 +1,134 @@
+> git_name
+git_name: Start by setting origin URL.
+git_name failed with value 1
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+git_name: Start by setting origin URL.
+git_name append=foo failed with value 1
+---
+> git_name append=foo-bar
+git_name: Start by setting origin URL.
+git_name append=foo-bar failed with value 1
+---
+> git_version
+git_version: name cannot be empty.
+git_version failed with value 1
+---
+> git_version name=foo
+---
+> git_version lead=1
+git_version: name cannot be empty.
+git_version lead=1 failed with value 1
+---
+> git_version lead=0.1
+git_version: name cannot be empty.
+git_version lead=0.1 failed with value 1
+---
+> git_version follow=2
+git_version: name cannot be empty.
+git_version follow=2 failed with value 1
+---
+> git_version lead=1 follow=2
+git_version: name cannot be empty.
+git_version lead=1 follow=2 failed with value 1
+---
+> git_version lead=x follow=x
+git_version: name cannot be empty.
+git_version lead=x follow=x failed with value 1
+---
+> git_version lead=1-1
+git_version: name cannot be empty.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: name cannot be empty.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: name cannot be empty.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+git_vcs: Start by setting origin URL.
+git_vcs failed with value 1
+---
+> git_vcs subtree=foo
+git_vcs: Start by setting origin URL.
+git_vcs subtree=foo failed with value 1
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog since_tag=foo-1.2
+---
+> git_changelog until_tag=foo-1.2
+---
+> git_changelog since_tag=foo-1.2 until_tag=foo-1.4
+---
+> git_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_inited/log_git_cwd b/tests/preproc/test_inited/log_git_cwd
new file mode 100644
index 0000000..6720963
--- /dev/null
+++ b/tests/preproc/test_inited/log_git_cwd
@@ -0,0 +1,104 @@
+> git_cwd_name
+git_cwd_name: Start by setting origin URL.
+git_cwd_name failed with value 1
+---
+> git_cwd_name append=foo
+git_cwd_name: Start by setting origin URL.
+git_cwd_name append=foo failed with value 1
+---
+> git_cwd_name append=foo-bar
+git_cwd_name: Start by setting origin URL.
+git_cwd_name append=foo-bar failed with value 1
+---
+> git_cwd_version
+git_cwd_version: name cannot be empty.
+git_cwd_version failed with value 1
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version lead=1
+git_cwd_version: name cannot be empty.
+git_cwd_version lead=1 failed with value 1
+---
+> git_cwd_version lead=0.1
+git_cwd_version: name cannot be empty.
+git_cwd_version lead=0.1 failed with value 1
+---
+> git_cwd_version follow=2
+git_cwd_version: name cannot be empty.
+git_cwd_version follow=2 failed with value 1
+---
+> git_cwd_version lead=1 follow=2
+git_cwd_version: name cannot be empty.
+git_cwd_version lead=1 follow=2 failed with value 1
+---
+> git_cwd_version lead=x follow=x
+git_cwd_version: name cannot be empty.
+git_cwd_version lead=x follow=x failed with value 1
+---
+> git_cwd_version lead=1-1
+git_cwd_version: name cannot be empty.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: name cannot be empty.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: name cannot be empty.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_vcs
+git_cwd_vcs: Start by setting origin URL.
+git_cwd_vcs failed with value 1
+---
+> git_cwd_vcs subtree=foo
+git_cwd_vcs: Start by setting origin URL.
+git_cwd_vcs subtree=foo failed with value 1
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog since_tag=foo-1.2
+---
+> git_cwd_changelog until_tag=foo-1.2
+---
+> git_cwd_changelog since_tag=foo-1.2 until_tag=foo-1.4
+---
+> git_cwd_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_inited/log_git_dir b/tests/preproc/test_inited/log_git_dir
new file mode 100644
index 0000000..8e49948
--- /dev/null
+++ b/tests/preproc/test_inited/log_git_dir
@@ -0,0 +1,114 @@
+> git_dir_name
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_name failed with value 1
+---
+> git_dir_name append=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_name append=foo failed with value 1
+---
+> git_dir_name append=foo-bar
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_name append=foo-bar failed with value 1
+---
+> git_dir_version
+git_dir_version: name cannot be empty.
+git_dir_version failed with value 1
+---
+> git_dir_version name=foo
+---
+> git_dir_version lead=1
+git_dir_version: name cannot be empty.
+git_dir_version lead=1 failed with value 1
+---
+> git_dir_version lead=0.1
+git_dir_version: name cannot be empty.
+git_dir_version lead=0.1 failed with value 1
+---
+> git_dir_version follow=2
+git_dir_version: name cannot be empty.
+git_dir_version follow=2 failed with value 1
+---
+> git_dir_version lead=1 follow=2
+git_dir_version: name cannot be empty.
+git_dir_version lead=1 follow=2 failed with value 1
+---
+> git_dir_version lead=x follow=x
+git_dir_version: name cannot be empty.
+git_dir_version lead=x follow=x failed with value 1
+---
+> git_dir_version lead=1-1
+git_dir_version: name cannot be empty.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: name cannot be empty.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: name cannot be empty.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_vcs
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs failed with value 1
+---
+> git_dir_vcs subtree=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs subtree=foo failed with value 1
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog since_tag=foo-1.2
+---
+> git_dir_changelog until_tag=foo-1.2
+---
+> git_dir_changelog since_tag=foo-1.2 until_tag=foo-1.4
+---
+> git_dir_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_inited/output_git b/tests/preproc/test_inited/output_git
new file mode 100644
index 0000000..7b2df90
--- /dev/null
+++ b/tests/preproc/test_inited/output_git
@@ -0,0 +1,55 @@
+
+foo
+foo-foo-bar
+
+
+
+
+0.0
+
+
+
+
+
+ # invalid
+ # invalid
+ # invalid
+ # invalid
+
+0.1
+1.0
+0.2
+1.2
+1.3
+0.2
+0.1
+0.1
+0.1
+0.1
+0.2
+0.2.0 # invalid but works
+0.1 # invalid but works
+
+
+
+
+
+
+foo.tar.gz
+foo.tar.gz
+
+
+
+foo.tar.gz
+foo.tar.gz
+
+-.tar.gz
+foo-.tar.gz
+-1.2.tar.gz
+foo-1.2.tar
+
+
+
+
+
+
diff --git a/tests/preproc/test_inited/output_git_cwd b/tests/preproc/test_inited/output_git_cwd
new file mode 100644
index 0000000..34202b8
--- /dev/null
+++ b/tests/preproc/test_inited/output_git_cwd
@@ -0,0 +1,39 @@
+
+
+
+
+
+0.0
+
+
+
+
+
+ # invalid
+ # invalid
+ # invalid
+ # invalid
+
+
+
+
+
+
+foo.tar.gz
+foo.tar.gz
+
+
+
+foo.tar.gz
+foo.tar.gz
+
+-.tar.gz
+foo-.tar.gz
+-1.2.tar.gz
+foo-1.2.tar
+
+
+
+
+
+
diff --git a/tests/preproc/test_inited/output_git_dir b/tests/preproc/test_inited/output_git_dir
new file mode 100644
index 0000000..34202b8
--- /dev/null
+++ b/tests/preproc/test_inited/output_git_dir
@@ -0,0 +1,39 @@
+
+
+
+
+
+0.0
+
+
+
+
+
+ # invalid
+ # invalid
+ # invalid
+ # invalid
+
+
+
+
+
+
+foo.tar.gz
+foo.tar.gz
+
+
+
+foo.tar.gz
+foo.tar.gz
+
+-.tar.gz
+foo-.tar.gz
+-1.2.tar.gz
+foo-1.2.tar
+
+
+
+
+
+
diff --git a/tests/preproc/test_inited/run.sh b/tests/preproc/test_inited/run.sh
new file mode 100755
index 0000000..9df977a
--- /dev/null
+++ b/tests/preproc/test_inited/run.sh
@@ -0,0 +1,29 @@
+#!/bin/bash -x
+
+. ../lib.sh
+
+REPO=`mktemp -d`
+OUT=`mktemp -d`
+git init $REPO
+
+../run_preproc.py --path $REPO --input ../input_git --output $OUT/output_git --dump-spec-only | log_filter | tee $OUT/log_git
+../run_preproc.py --path $REPO --input ../input_git_dir --output $OUT/output_git_dir --dump-spec-only | log_filter | tee $OUT/log_git_dir
+../run_preproc.py --path $REPO --input ../input_git_cwd --output $OUT/output_git_cwd --dump-spec-only | log_filter | tee $OUT/log_git_cwd
+
+if [ "$1" == 'copy' ]; then
+    cp $OUT/* .
+    echo copied.
+    rm -r $REPO $OUT
+    exit
+fi
+
+diff output_git $OUT/output_git || die
+diff output_git_dir $OUT/output_git_dir || die
+diff output_git_cwd $OUT/output_git_cwd || die
+
+diff log_git $OUT/log_git || die
+diff log_git_dir $OUT/log_git_dir || die
+diff log_git_cwd $OUT/log_git_cwd || die
+
+rm -r $REPO $OUT
+echo success.
diff --git a/tests/preproc/test_uninited/log_git b/tests/preproc/test_uninited/log_git
new file mode 100644
index 0000000..5ef8e20
--- /dev/null
+++ b/tests/preproc/test_uninited/log_git
@@ -0,0 +1,2 @@
+git_name: Start by setting origin URL.
+git_name failed with value 1
diff --git a/tests/preproc/test_uninited/log_git_cwd b/tests/preproc/test_uninited/log_git_cwd
new file mode 100644
index 0000000..2f669a0
--- /dev/null
+++ b/tests/preproc/test_uninited/log_git_cwd
@@ -0,0 +1,4 @@
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_name: Start by setting origin URL.
+git_cwd_name failed with value 1
diff --git a/tests/preproc/test_uninited/log_git_dir b/tests/preproc/test_uninited/log_git_dir
new file mode 100644
index 0000000..8420d25
--- /dev/null
+++ b/tests/preproc/test_uninited/log_git_dir
@@ -0,0 +1,4 @@
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_name failed with value 1
diff --git a/tests/preproc/test_uninited/run.sh b/tests/preproc/test_uninited/run.sh
new file mode 100755
index 0000000..0970118
--- /dev/null
+++ b/tests/preproc/test_uninited/run.sh
@@ -0,0 +1,16 @@
+#!/bin/bash -x
+
+. ../lib.sh
+
+REPO=`mktemp -d`
+
+../run_preproc.py --path $REPO --input ../input_git --output $REPO/output_git --dump-spec-only --break-on-error > $REPO/log_git
+../run_preproc.py --path $REPO --input ../input_git_dir --output $REPO/output_git_dir --dump-spec-only --break-on-error > $REPO/log_git_dir
+../run_preproc.py --path $REPO --input ../input_git_cwd --output $REPO/output_git_cwd --dump-spec-only --break-on-error > $REPO/log_git_cwd
+
+diff log_git $REPO/log_git || die
+diff log_git_dir $REPO/log_git_dir || die
+diff log_git_cwd $REPO/log_git_cwd || die
+
+rm -r $REPO
+echo success.

From ee5ed2217bfa4da862d87ece8eaeebdc885ee7e6 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 78/104] introduce setup script to set env instead of preprocess.sh, cleaner ENV var names


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 5d4114f..226e71b 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -25,7 +25,7 @@ class Commands(pyrpkg.Commands):
         self.outdir = kwargs.pop("outdir")
         self.preprocess = kwargs.pop("preprocess")
         self.dump_spec_only = False
-        self.bump = False
+        self.version_bump = False
         super(Commands, self).__init__(*args, **kwargs)
         self.source_entry_type = 'bsd'
         self.distgit_namespaced = True
@@ -333,7 +333,7 @@ class Commands(pyrpkg.Commands):
 
         if self.preprocess:
             preprocess(self.path, spec_templ, out_spec_path,
-                       self.log, self.dump_spec_only, self.bump)
+                       self.log, self.dump_spec_only, self.version_bump)
         else:
             shutil.copy(spec_templ, out_spec_path)
 
@@ -377,7 +377,7 @@ class Commands(pyrpkg.Commands):
         utils.run_command(cmd, cwd=self.path)
         self.log.info('Created tag: %s', tagname)
 
-        self.bump = False
+        self.version_bump = False
         self.load_spec()
 
     def get_tag_message(self, tagname):
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 7b1f889..c93742c 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -154,7 +154,7 @@ class rpkgClient(cliClient):
     def tag(self):
         self.cmd.dump_spec_only = True
         if not self.args.tag:
-            self.cmd.bump = True
+            self.cmd.version_bump = True
         self.cmd._rpmdefines = self.cmd.rpmdefines + ["--define 'dist %nil'"]
         super(rpkgClient, self).tag()
 
diff --git a/rpkglib/preproc.py b/rpkglib/preproc.py
index 97e3b66..197b92c 100644
--- a/rpkglib/preproc.py
+++ b/rpkglib/preproc.py
@@ -6,30 +6,29 @@ import re
 from pyrpkg.errors import rpkgError
 from pyparsing import Combine, CharsNotIn, Regex, ZeroOrMore, Group, Suppress, Literal
 
-preproc_path = os.path.join(
-    os.path.dirname(__file__), "preproc", "preproc.sh")
+setup_path = os.path.join(
+    os.path.dirname(__file__), 'preproc', 'setup')
 
 
 def log_line_strip(line):
     return re.sub(r'(DEBUG|INFO|ERROR):\s*(.*)\s*', r'\2', line)
 
 
-def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log, break_on_error):
-    bump = str(bump) if bump else ''
+def invoke_wrapper(cwd, input_path, outdir, version_bump, env_store_name, app_log, break_on_failure):
+    version_bump = str(version_bump) if version_bump else ''
 
     def invoke(tokens):
         retval = ""
         for token in tokens:
-            cmd = '{} {}'.format(preproc_path, token)
+            cmd = ['/bin/bash', '-c' , '. {}; {};'.format(setup_path, token)]
 
             env = {
-                'BUMP': bump,
                 'OUTDIR': outdir,
-                'SPECPATH': in_spec_path,
-                'ENVSTORE': env_store_name,
+                'VERSION_BUMP': version_bump,
+                'INPUT_PATH': input_path,
+                'ENV_STORE': env_store_name,
             }
-            p = subprocess.Popen(cmd, shell=True,
-                                 env=env, cwd=cwd,
+            p = subprocess.Popen(cmd, env=env, cwd=cwd,
                                  stderr=subprocess.PIPE,
                                  stdout=subprocess.PIPE)
 
@@ -57,7 +56,7 @@ def invoke_wrapper(cwd, in_spec_path, outdir, bump, env_store_name, app_log, bre
                 error_msg = "{} failed with value {}".format(
                     token, p.returncode)
 
-                if break_on_error:
+                if break_on_failure:
                     raise rpkgError(error_msg)
 
                 app_log.error(error_msg)
@@ -78,20 +77,20 @@ def get_parse_expr():
     return Suppress(opener) + content + Suppress(closer)
 
 
-def preprocess(path, in_spec_path, out_spec_path, app_log, dump_spec_only=False, bump=False, break_on_error=True):
-    outdir = os.path.dirname(out_spec_path) if not dump_spec_only else ''
+def preprocess(path, input_path, output_path, app_log, dump_spec_only=False, version_bump=False, break_on_failure=True):
+    outdir = os.path.dirname(output_path) if not dump_spec_only else ''
     env_store_file = tempfile.NamedTemporaryFile(delete=False)
 
-    with open(in_spec_path, 'r') as f:
-        in_spec_data = f.read()
+    with open(input_path, 'r') as f:
+        in_data = f.read()
 
         expr = get_parse_expr().setParseAction(invoke_wrapper(
-            path, in_spec_path, outdir, bump, env_store_file.name, app_log, break_on_error))
-        out_spec_data = expr.transformString(in_spec_data)
+            path, input_path, outdir, version_bump, env_store_file.name, app_log, break_on_failure))
+        out_data = expr.transformString(in_data)
 
-        outf = open(out_spec_path, 'w')
-        outf.write(out_spec_data)
-        outf.close()
+        outfile = open(output_path, 'w')
+        outfile.write(out_data)
+        outfile.close()
 
     env_store_file.close()
     os.unlink(env_store_file.name)
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 377ce0d..d1c13b0 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -1,4 +1,4 @@
-SCRIPTDIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+export SCRIPTDIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 
 declare -Ax __cached
 
@@ -155,7 +155,7 @@ function git_version {
         latest_tag_version=
     fi
 
-    if [ -n "$BUMP" ]; then
+    if [ -n "$VERSION_BUMP" ]; then
         version="$(git_bumped_version lead="$lead" follow="$follow" latest_tag_version="$latest_tag_version")"
 
         retcode=$?
@@ -327,7 +327,7 @@ function git_changelog {
 ############## DIR FUNCTIONS ##############
 
 function git_dir_name {
-    git_name append="$(git -C "$(dirname "$SPECPATH")" rev-parse --show-prefix | name_convert)" "$@"
+    git_name append="$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix | name_convert)" "$@"
 }
 
 function git_dir_version {
@@ -335,15 +335,15 @@ function git_dir_version {
 }
 
 function git_dir_vcs {
-    git_vcs subtree="$(git -C "$(dirname "$SPECPATH")" rev-parse --show-prefix)" "$@"
+    git_vcs subtree="$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix)" "$@"
 }
 
 function git_dir_pack {
-    git_pack path="$(dirname "$SPECPATH")" "$@"
+    git_pack path="$(dirname "$INPUT_PATH")" "$@"
 }
 
 function git_dir_archive {
-    git_archive path="$(dirname "$SPECPATH")" "$@"
+    git_archive path="$(dirname "$INPUT_PATH")" "$@"
 }
 
 function git_dir_source_name {
diff --git a/rpkglib/preproc/preproc.sh b/rpkglib/preproc/preproc.sh
deleted file mode 100755
index a79591f..0000000
--- a/rpkglib/preproc/preproc.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-source $ENVSTORE
-
-SCRIPTDIR="$(builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
-source $SCRIPTDIR/lib.sh
-
-if [ -f ./rpkg.sh ]; then
-    source ./rpkg.sh
-fi
-
-("$@")
-retcode=$?
-
-if [ $retcode -eq 0 ]; then
-    declare -x > $ENVSTORE
-fi
-exit $retcode
diff --git a/rpkglib/preproc/setup b/rpkglib/preproc/setup
new file mode 100755
index 0000000..d6563ba
--- /dev/null
+++ b/rpkglib/preproc/setup
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+source $ENV_STORE
+
+SCRIPTDIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+source $SCRIPTDIR/lib.sh
+
+if [ -f ./rpkg.sh ]; then
+    source ./rpkg.sh
+fi
+
+function end {
+    retcode=$?
+
+    if [ $retcode -eq 0 ]; then
+        declare -x > $ENV_STORE
+    fi
+
+    exit $retcode
+}
+
+trap end EXIT

From 00b58a3ca0c71a78b9bcfa959fff5844245141c5 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 79/104] change name of the user-defined macro file to rpkg.macros, which is more obvious


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index d1c13b0..4a72b4f 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -1,3 +1,5 @@
+#!/bin/bash
+
 export SCRIPTDIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 
 declare -Ax __cached
diff --git a/rpkglib/preproc/setup b/rpkglib/preproc/setup
index d6563ba..03ae6b5 100755
--- a/rpkglib/preproc/setup
+++ b/rpkglib/preproc/setup
@@ -5,8 +5,8 @@ source $ENV_STORE
 SCRIPTDIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 source $SCRIPTDIR/lib.sh
 
-if [ -f ./rpkg.sh ]; then
-    source ./rpkg.sh
+if [ -f ./rpkg.macros ]; then
+    source ./rpkg.macros
 fi
 
 function end {

From e8607f1a7ac5daed23767c60e289c576af5a8a12 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 80/104] bug-fixes in git_latest_ctime


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 4a72b4f..988474a 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -23,8 +23,8 @@ function git_latest_ctime {
     mapfile -t files < <(git status --porcelain | cut -c 4- | sed -E -e 's|(.*) -> (.*)|\1\n\2|')
     latest_ctime=0
     for f in "${files[@]}"; do
-        if [ -f "$f" ]; then
-            ctime=$(stat --format='%Z' "$f")
+        if [ -e "$(git rev-parse --show-toplevel)/$f" ]; then
+            ctime=$(stat --format='%Z' "$(git rev-parse --show-toplevel)/$f")
             if [ "$ctime" -gt "$latest_ctime" ]; then
                 latest_ctime="$ctime"
             fi

From 1fa970e74cdc6bf34573e444e0f2ef5e592324f8 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 81/104] basic macro test suite


---

diff --git a/tests/preproc/input b/tests/preproc/input
new file mode 100644
index 0000000..7700322
--- /dev/null
+++ b/tests/preproc/input
@@ -0,0 +1,185 @@
+git_name: {{{ git_name }}}
+git_name name=foo: {{{ git_name name=foo }}}
+git_name name=foo append=foo-bar: {{{ git_name name=foo append=foo-bar }}}
+git_name append=foo: {{{ git_name append=foo }}}
+git_name append=foo-bar: {{{ git_name append=foo-bar }}}
+
+git_version: {{{ git_version }}}
+git_version name=foo: {{{ git_version name=foo }}}
+git_version lead=1: {{{ git_version lead=1 }}}
+git_version lead=0.1: {{{ git_version lead=0.1 }}}
+git_version follow=2: {{{ git_version follow=2 }}}
+git_version lead=1 follow=2: {{{ git_version lead=1 follow=2 }}}
+git_version lead=x follow=x: {{{ git_version lead=x follow=x }}}
+git_version lead=1-1: {{{ git_version lead=1-1 }}} # invalid
+git_version follow=2.0: {{{ git_version follow=2.0 }}} # invalid
+git_version follow=2-2: {{{ git_version follow=2-2 }}} # invalid
+git_version name=: {{{ git_version name= }}} # invalid
+
+git_version name="$(git_name)": {{{ git_version name="$(git_name)" }}}
+git_version echo 1.4: {{{ echo -n 1.4 }}}
+git_version echo -n 1; echo -n .; echo 4: {{{ echo -n 1; echo -n .; echo -n 4 }}}
+git_version date --date='@2147483647' +%y%m%d: {{{ date --date='@2147483647' +%y%m%d }}}
+
+git_bumped_version: {{{ git_bumped_version }}}
+git_bumped_version lead=1: {{{ git_bumped_version lead=1 }}}
+git_bumped_version follow=2: {{{ git_bumped_version follow=2 }}}
+git_bumped_version lead=1 follow=2: {{{ git_bumped_version lead=1 follow=2 }}}
+git_bumped_version lead=1 latest_tag_version=1.2: {{{ git_bumped_version lead=1 latest_tag_version=1.2 }}}
+git_bumped_version follow=2 latest_tag_version=1.4: {{{ git_bumped_version follow=2 latest_tag_version=1.4 }}}
+git_bumped_version latest_tag_version=1.2: {{{ git_bumped_version latest_tag_version=1.2 }}}
+git_bumped_version latest_tag_version=0.1.2: {{{ git_bumped_version latest_tag_version=0.1.2 }}}
+git_bumped_version latest_tag_version=1.x: {{{ git_bumped_version latest_tag_version=1.x }}}
+git_bumped_version latest_tag_version=0.1.x: {{{ git_bumped_version latest_tag_version=0.1.x }}}
+git_bumped_version latest_tag_version=0.1: {{{ git_bumped_version latest_tag_version=0.1 }}}
+git_bumped_version follow=2.0: {{{ git_bumped_version follow=2.0 }}} # invalid but works
+git_bumped_version latest_tag_version=1-2: {{{ git_bumped_version latest_tag_version=1-2 }}} # invalid but works
+
+git_vcs: {{{ git_vcs }}}
+git_vcs subtree=foo: {{{ git_vcs subtree=foo }}}
+
+git_pack: {{{ git_pack }}}
+git_pack dir_name=foo: {{{ git_pack dir_name=foo }}}
+git_pack dir_name=foo source_name=foo.tar.gz: {{{ git_pack dir_name=foo source_name=foo.tar.gz }}}
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+git_archive: {{{ git_archive }}}
+git_archive dir_name=foo: {{{ git_archive dir_name=foo }}}
+git_archive dir_name=foo source_name=foo.tar.gz: {{{ git_archive dir_name=foo source_name=foo.tar.gz }}}
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+git_source_name: {{{ git_source_name }}}
+git_source_name name=foo: {{{ git_source_name name=foo }}}
+git_source_name version=1.2: {{{ git_source_name version=1.2 }}}
+git_source_name name=foo version=1.2 format=tar: {{{ git_source_name name=foo version=1.2 format=tar }}}
+
+git_changelog:
+{{{ git_changelog }}}
+
+git_changelog name=foo since_tag=foo-1.2-1:
+{{{ git_changelog name=foo since_tag=foo-1.2-1 }}}
+
+git_changelog name=foo until_tag=foo-1.2-1:
+{{{ git_changelog name=foo until_tag=foo-1.2-1 }}}
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+{{{ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 }}}
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+{{{ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
+
+---
+
+git_cwd_name: {{{ git_cwd_name }}}
+git_cwd_name name=foo: {{{ git_cwd_name name=foo }}}
+git_cwd_name name=foo append=foo-bar: {{{ git_cwd_name name=foo append=foo-bar }}}
+git_cwd_name append=foo: {{{ git_cwd_name append=foo }}}
+git_cwd_name append=foo-bar: {{{ git_cwd_name append=foo-bar }}}
+
+git_cwd_version: {{{ git_cwd_version }}}
+git_cwd_version name=foo: {{{ git_cwd_version name=foo }}}
+git_cwd_version lead=1: {{{ git_cwd_version lead=1 }}}
+git_cwd_version lead=0.1: {{{ git_cwd_version lead=0.1 }}}
+git_cwd_version follow=2: {{{ git_cwd_version follow=2 }}}
+git_cwd_version lead=1 follow=2: {{{ git_cwd_version lead=1 follow=2 }}}
+git_cwd_version lead=x follow=x: {{{ git_cwd_version lead=x follow=x }}}
+git_cwd_version lead=1-1: {{{ git_cwd_version lead=1-1 }}} # invalid
+git_cwd_version follow=2.0: {{{ git_cwd_version follow=2.0 }}} # invalid
+git_cwd_version follow=2-2: {{{ git_cwd_version follow=2-2 }}} # invalid
+git_cwd_version name=: {{{ git_cwd_version name= }}} # invalid
+
+git_cwd_version name="$(git_name)": {{{ git_cwd_version name="$(git_cwd_name)" }}}
+git_cwd_version echo 1.4: {{{ echo -n 1.4 }}}
+git_cwd_version echo -n 1; echo -n .; echo -n 4: {{{ echo -n 1; echo -n .; echo -n 4 }}}
+git_cwd_version date --date='@2147483647' +%y%m%d: {{{ date --date='@2147483647' +%y%m%d }}}
+
+git_cwd_vcs: {{{ git_cwd_vcs }}}
+git_cwd_vcs subtree=foo: {{{ git_cwd_vcs subtree=foo }}}
+
+git_cwd_pack: {{{ git_cwd_pack }}}
+git_cwd_pack dir_name=foo: {{{ git_cwd_pack dir_name=foo }}}
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: {{{ git_cwd_pack dir_name=foo source_name=foo.tar.gz }}}
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+git_cwd_archive: {{{ git_cwd_archive }}}
+git_cwd_archive dir_name=foo: {{{ git_cwd_archive dir_name=foo }}}
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: {{{ git_cwd_archive dir_name=foo source_name=foo.tar.gz }}}
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+git_cwd_source_name: {{{ git_cwd_source_name }}}
+git_cwd_source_name name=foo: {{{ git_cwd_source_name name=foo }}}
+git_cwd_source_name version=1.2: {{{ git_cwd_source_name version=1.2 }}}
+git_cwd_source_name name=foo version=1.2 format=tar: {{{ git_cwd_source_name name=foo version=1.2 format=tar }}}
+
+git_cwd_changelog:
+{{{ git_cwd_changelog }}}
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+{{{ git_cwd_changelog name=foo since_tag=foo-1.2-1 }}}
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+{{{ git_cwd_changelog name=foo until_tag=foo-1.2-1 }}}
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+{{{ git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 }}}
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+{{{ git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
+
+---
+
+git_dir_name: {{{ git_dir_name }}}
+git_dir_name name=foo: {{{ git_dir_name name=foo }}}
+git_dir_name name=foo append=foo-bar: {{{ git_dir_name name=foo append=foo-bar }}}
+git_dir_name append=foo: {{{ git_dir_name append=foo }}}
+git_dir_name append=foo-bar: {{{ git_dir_name append=foo-bar }}}
+
+git_dir_version: {{{ git_dir_version }}}
+git_dir_version name=foo: {{{ git_dir_version name=foo }}}
+git_dir_version lead=1: {{{ git_dir_version lead=1 }}}
+git_dir_version lead=0.1: {{{ git_dir_version lead=0.1 }}}
+git_dir_version follow=2: {{{ git_dir_version follow=2 }}}
+git_dir_version lead=1 follow=2: {{{ git_dir_version lead=1 follow=2 }}}
+git_dir_version lead=x follow=x: {{{ git_dir_version lead=x follow=x }}}
+git_dir_version lead=1-1: {{{ git_dir_version lead=1-1 }}} # invalid
+git_dir_version follow=2.0: {{{ git_dir_version follow=2.0 }}} # invalid
+git_dir_version follow=2-2: {{{ git_dir_version follow=2-2 }}} # invalid
+git_dir_version name=: {{{ git_dir_version name= }}} # invalid
+
+git_dir_version name="$(git_name)": {{{ git_dir_version name="$(git_dir_name)" }}}
+git_dir_version echo 1.4: {{{ echo -n 1.4 }}}
+git_dir_version echo -n 1; echo -n .; echo -n 4: {{{ echo -n 1; echo -n .; echo -n 4 }}}
+git_dir_version date --date='@2147483647' %y%m%d: {{{ date --date='@2147483647' +%y%m%d }}}
+
+git_dir_vcs: {{{ git_dir_vcs }}}
+git_dir_vcs subtree=foo: {{{ git_dir_vcs subtree=foo }}}
+
+git_dir_pack: {{{ git_dir_pack }}}
+git_dir_pack dir_name=foo: {{{ git_dir_pack dir_name=foo }}}
+git_dir_pack dir_name=foo source_name=foo.tar.gz: {{{ git_dir_pack dir_name=foo source_name=foo.tar.gz }}}
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+git_dir_archive: {{{ git_dir_archive }}}
+git_dir_archive dir_name=foo: {{{ git_dir_archive dir_name=foo }}}
+git_dir_archive dir_name=foo source_name=foo.tar.gz: {{{ git_dir_archive dir_name=foo source_name=foo.tar.gz }}}
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
+
+git_dir_source_name: {{{ git_dir_source_name }}}
+git_dir_source_name name=foo: {{{ git_dir_source_name name=foo }}}
+git_dir_source_name version=1.2: {{{ git_dir_source_name version=1.2 }}}
+git_dir_source_name name=foo version=1.2 format=tar: {{{ git_dir_source_name name=foo version=1.2 format=tar }}}
+
+git_dir_changelog:
+{{{ git_dir_changelog }}}
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+{{{ git_dir_changelog name=foo since_tag=foo-1.2-1 }}}
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+{{{ git_dir_changelog name=foo until_tag=foo-1.2-1 }}}
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+{{{ git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 }}}
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+{{{ git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
diff --git a/tests/preproc/input_git b/tests/preproc/input_git
deleted file mode 100644
index a9efbd7..0000000
--- a/tests/preproc/input_git
+++ /dev/null
@@ -1,55 +0,0 @@
-{{{ git_name }}}
-{{{ git_name name=foo }}}
-{{{ git_name name=foo append=foo-bar }}}
-{{{ git_name append=foo }}}
-{{{ git_name append=foo-bar }}}
-
-{{{ git_version }}}
-{{{ git_version name=foo }}}
-{{{ git_version lead=1 }}}
-{{{ git_version lead=0.1 }}}
-{{{ git_version follow=2 }}}
-{{{ git_version lead=1 follow=2 }}}
-{{{ git_version lead=x follow=x }}}
-{{{ git_version lead=1-1 }}} # invalid
-{{{ git_version follow=2.0 }}} # invalid
-{{{ git_version follow=2-2 }}} # invalid
-{{{ git_version name= }}} # invalid
-
-{{{ git_bumped_version }}}
-{{{ git_bumped_version lead=1 }}}
-{{{ git_bumped_version follow=2 }}}
-{{{ git_bumped_version lead=1 follow=2 }}}
-{{{ git_bumped_version lead=1 latest_tag_version=1.2 }}}
-{{{ git_bumped_version follow=2 latest_tag_version=1.4 }}}
-{{{ git_bumped_version latest_tag_version=1.2 }}}
-{{{ git_bumped_version latest_tag_version=0.1.2 }}}
-{{{ git_bumped_version latest_tag_version=1.x }}}
-{{{ git_bumped_version latest_tag_version=0.1.x }}}
-{{{ git_bumped_version latest_tag_version=0.1 }}}
-{{{ git_bumped_version follow=2.0 }}} # invalid but works
-{{{ git_bumped_version latest_tag_version=1-2 }}} # invalid but works
-
-{{{ git_vcs }}}
-{{{ git_vcs subtree=foo }}}
-
-{{{ git_pack }}}
-{{{ git_pack dir_name=foo }}}
-{{{ git_pack dir_name=foo source_name=foo.tar.gz }}}
-{{{ git_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-{{{ git_archive }}}
-{{{ git_archive dir_name=foo }}}
-{{{ git_archive dir_name=foo source_name=foo.tar.gz }}}
-{{{ git_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-{{{ git_source_name }}}
-{{{ git_source_name name=foo }}}
-{{{ git_source_name version=1.2 }}}
-{{{ git_source_name name=foo version=1.2 format=tar }}}
-
-{{{ git_changelog }}}
-{{{ git_changelog since_tag=foo-1.2 }}}
-{{{ git_changelog until_tag=foo-1.2 }}}
-{{{ git_changelog since_tag=foo-1.2 until_tag=foo-1.4 }}}
-{{{ git_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
diff --git a/tests/preproc/input_git_cwd b/tests/preproc/input_git_cwd
deleted file mode 100644
index d41586a..0000000
--- a/tests/preproc/input_git_cwd
+++ /dev/null
@@ -1,39 +0,0 @@
-{{{ git_cwd_name }}}
-{{{ git_cwd_name append=foo }}}
-{{{ git_cwd_name append=foo-bar }}}
-
-{{{ git_cwd_version }}}
-{{{ git_cwd_version name=foo }}}
-{{{ git_cwd_version lead=1 }}}
-{{{ git_cwd_version lead=0.1 }}}
-{{{ git_cwd_version follow=2 }}}
-{{{ git_cwd_version lead=1 follow=2 }}}
-{{{ git_cwd_version lead=x follow=x }}}
-{{{ git_cwd_version lead=1-1 }}} # invalid
-{{{ git_cwd_version follow=2.0 }}} # invalid
-{{{ git_cwd_version follow=2-2 }}} # invalid
-{{{ git_cwd_version name= }}} # invalid
-
-{{{ git_cwd_vcs }}}
-{{{ git_cwd_vcs subtree=foo }}}
-
-{{{ git_cwd_pack }}}
-{{{ git_cwd_pack dir_name=foo }}}
-{{{ git_cwd_pack dir_name=foo source_name=foo.tar.gz }}}
-{{{ git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-{{{ git_cwd_archive }}}
-{{{ git_cwd_archive dir_name=foo }}}
-{{{ git_cwd_archive dir_name=foo source_name=foo.tar.gz }}}
-{{{ git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-{{{ git_cwd_source_name }}}
-{{{ git_cwd_source_name name=foo }}}
-{{{ git_cwd_source_name version=1.2 }}}
-{{{ git_cwd_source_name name=foo version=1.2 format=tar }}}
-
-{{{ git_cwd_changelog }}}
-{{{ git_cwd_changelog since_tag=foo-1.2 }}}
-{{{ git_cwd_changelog until_tag=foo-1.2 }}}
-{{{ git_cwd_changelog since_tag=foo-1.2 until_tag=foo-1.4 }}}
-{{{ git_cwd_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
diff --git a/tests/preproc/input_git_dir b/tests/preproc/input_git_dir
deleted file mode 100644
index 0ad1e6f..0000000
--- a/tests/preproc/input_git_dir
+++ /dev/null
@@ -1,39 +0,0 @@
-{{{ git_dir_name }}}
-{{{ git_dir_name append=foo }}}
-{{{ git_dir_name append=foo-bar }}}
-
-{{{ git_dir_version }}}
-{{{ git_dir_version name=foo }}}
-{{{ git_dir_version lead=1 }}}
-{{{ git_dir_version lead=0.1 }}}
-{{{ git_dir_version follow=2 }}}
-{{{ git_dir_version lead=1 follow=2 }}}
-{{{ git_dir_version lead=x follow=x }}}
-{{{ git_dir_version lead=1-1 }}} # invalid
-{{{ git_dir_version follow=2.0 }}} # invalid
-{{{ git_dir_version follow=2-2 }}} # invalid
-{{{ git_dir_version name= }}} # invalid
-
-{{{ git_dir_vcs }}}
-{{{ git_dir_vcs subtree=foo }}}
-
-{{{ git_dir_pack }}}
-{{{ git_dir_pack dir_name=foo }}}
-{{{ git_dir_pack dir_name=foo source_name=foo.tar.gz }}}
-{{{ git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-{{{ git_dir_archive }}}
-{{{ git_dir_archive dir_name=foo }}}
-{{{ git_dir_archive dir_name=foo source_name=foo.tar.gz }}}
-{{{ git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-{{{ git_dir_source_name }}}
-{{{ git_dir_source_name name=foo }}}
-{{{ git_dir_source_name version=1.2 }}}
-{{{ git_dir_source_name name=foo version=1.2 format=tar }}}
-
-{{{ git_dir_changelog }}}
-{{{ git_dir_changelog since_tag=foo-1.2 }}}
-{{{ git_dir_changelog until_tag=foo-1.2 }}}
-{{{ git_dir_changelog since_tag=foo-1.2 until_tag=foo-1.4 }}}
-{{{ git_dir_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
diff --git a/tests/preproc/lib.sh b/tests/preproc/lib.sh
index 72820ee..5d1b3d6 100644
--- a/tests/preproc/lib.sh
+++ b/tests/preproc/lib.sh
@@ -1,10 +1,55 @@
 export libdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+. $libdir/../../rpkglib/preproc/lib.sh
   
-die() {
-    echo "fail." 
+function die {
+    echo fail.
     exit 1
 }
 
-log_filter() {
-    grep -Ev '^> (env|cwd):.*$'
+function log_filter {
+    grep -Ev -e '^> (env|cwd):' -e '^git_pack: Wrote:'
+}
+
+function run {
+    echo '>' $@;
+    eval $@;
+}
+
+function wtree_sub {
+    latest_ctime="$(builtin cd "$1"; encode_decimal $(git_latest_ctime))"
+    sed -Ei "s/\.wtree\.[a-zA-Z0-9]+/.wtree.$latest_ctime/" "$2"
+}
+
+function head_commit_sub {
+    full_hash=$(git -C "$1" rev-parse HEAD)
+    short_hash=$(git -C "$1" rev-parse --short HEAD)
+    sed -Ei -e "s|(\.git\.[0-9]+)\.[a-zA-Z0-9]+|\1.$short_hash|" -e "s|#\w{40}:|#$full_hash:|" "$2"
+}
+
+function generic_test {
+    declare opts= path= input= expected_output= expected_log= expected_sources= copy_only= "$@"
+    local out="$(mktemp -d)"
+
+    run "../preproc.py --path $path --input $input --output $out/output $opts | log_filter &> $out/log"
+
+    if [ -n "$copy_only" ]; then
+        cp $out/log $out/output .
+        echo copied.
+        rm -r $out
+        exit
+    fi
+
+    run "diff $expected_output $out/output || die"
+    run "diff $expected_log $out/log || die"
+
+    for source_name in $expected_sources; do
+        echo "Checking for presence of source $source_name."
+        if ! [ -f "$out/$source_name" ]; then
+            die
+        fi
+    done
+
+    rm -r $out
+    echo success.
 }
diff --git a/tests/preproc/preproc.py b/tests/preproc/preproc.py
new file mode 100755
index 0000000..0944877
--- /dev/null
+++ b/tests/preproc/preproc.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python2
+
+import os
+import sys
+import logging
+import argparse
+
+project_path = os.path.realpath(os.path.join(os.path.realpath(__file__), '../../../'))
+sys.path.insert(0, project_path)
+
+from rpkglib.preproc import preprocess
+
+log = logging.getLogger(__name__)
+log.addHandler(logging.StreamHandler(sys.stdout))
+log.setLevel(logging.DEBUG)
+
+parser = argparse.ArgumentParser()
+
+parser.add_argument('--path', default='.')
+parser.add_argument('--input', required=True)
+parser.add_argument('--output', required=True)
+parser.add_argument('--dump-spec-only', action='store_true')
+parser.add_argument('--version-bump', action='store_true')
+parser.add_argument('--break-on-failure', action='store_true')
+
+args = parser.parse_args()
+
+try:
+    preprocess(
+        path=args.path,
+        input_path=args.input,
+        output_path=args.output,
+        dump_spec_only=args.dump_spec_only,
+        version_bump=args.version_bump,
+        break_on_failure=args.break_on_failure,
+        app_log=log)
+
+except Exception as e:
+    log.error(str(e))
diff --git a/tests/preproc/run.sh b/tests/preproc/run.sh
index 647c954..8d5d743 100755
--- a/tests/preproc/run.sh
+++ b/tests/preproc/run.sh
@@ -3,5 +3,6 @@
 export scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 
 for dir in `ls -d $scriptdir/test_*/`; do
-	$dir/test.sh || exit 1
+    echo "====================== $(basename ${dir}) ======================"
+    (builtin cd $dir && run.sh $1) || exit 1
 done
diff --git a/tests/preproc/run_preproc.py b/tests/preproc/run_preproc.py
deleted file mode 100755
index 54019d4..0000000
--- a/tests/preproc/run_preproc.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/python2
-
-import os
-import sys
-import logging
-import argparse
-
-project_path = os.path.realpath(os.path.join(os.path.realpath(__file__), '../../../'))
-sys.path.insert(0, project_path)
-
-from rpkglib.preproc import preprocess
-
-log = logging.getLogger(__name__)
-log.addHandler(logging.StreamHandler(sys.stdout))
-log.setLevel(logging.DEBUG)
-
-parser = argparse.ArgumentParser()
-
-parser.add_argument('--path', default='.')
-parser.add_argument('--input', required=True)
-parser.add_argument('--output', required=True)
-parser.add_argument('--dump-spec-only', action='store_true')
-parser.add_argument('--bump', action='store_true')
-parser.add_argument('--break-on-error', action='store_true')
-
-args = parser.parse_args()
-
-try:
-    preprocess(
-        args.path,
-        args.input,
-        args.output,
-        dump_spec_only=args.dump_spec_only,
-        bump=args.bump,
-        break_on_error=args.break_on_error,
-        app_log=log)
-
-except Exception as e:
-    log.error(str(e))
diff --git a/tests/preproc/test_committed/log b/tests/preproc/test_committed/log
new file mode 100644
index 0000000..e78c556
--- /dev/null
+++ b/tests/preproc/test_committed/log
@@ -0,0 +1,308 @@
+> git_name
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+---
+> git_name append=foo-bar
+---
+> git_version
+---
+> git_version name=foo
+---
+> git_version lead=1
+---
+> git_version lead=0.1
+---
+> git_version follow=2
+---
+> git_version lead=1 follow=2
+---
+> git_version lead=x follow=x
+---
+> git_version lead=1-1
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: follow cannot contain dots.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_version name="$(git_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+---
+> git_vcs subtree=foo
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog name=foo since_tag=foo-1.2-1
+---
+> git_changelog name=foo until_tag=foo-1.2-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_cwd_name
+---
+> git_cwd_name name=foo
+---
+> git_cwd_name name=foo append=foo-bar
+---
+> git_cwd_name append=foo
+---
+> git_cwd_name append=foo-bar
+---
+> git_cwd_version
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version lead=1
+---
+> git_cwd_version lead=0.1
+---
+> git_cwd_version follow=2
+---
+> git_cwd_version lead=1 follow=2
+---
+> git_cwd_version lead=x follow=x
+---
+> git_cwd_version lead=1-1
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_cwd_vcs
+---
+> git_cwd_vcs subtree=foo
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_dir_name
+---
+> git_dir_name name=foo
+---
+> git_dir_name name=foo append=foo-bar
+---
+> git_dir_name append=foo
+---
+> git_dir_name append=foo-bar
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=2
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_version name="$(git_dir_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_dir_vcs
+---
+> git_dir_vcs subtree=foo
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_committed/output b/tests/preproc/test_committed/output
new file mode 100644
index 0000000..ad15071
--- /dev/null
+++ b/tests/preproc/test_committed/output
@@ -0,0 +1,188 @@
+git_name: test
+git_name name=foo: foo
+git_name name=foo append=foo-bar: foo-foo-bar
+git_name append=foo: test-foo
+git_name append=foo-bar: test-foo-bar
+
+git_version: 0.0.git.3.efdcaea
+git_version name=foo: 0.0.git.3.efdcaea
+git_version lead=1: 1.0.git.3.efdcaea
+git_version lead=0.1: 0.1.0.git.3.efdcaea
+git_version follow=2: 0.2.git.3.efdcaea
+git_version lead=1 follow=2: 1.2.git.3.efdcaea
+git_version lead=x follow=x: x.x.git.3.efdcaea
+git_version lead=1-1:  # invalid
+git_version follow=2.0:  # invalid
+git_version follow=2-2:  # invalid
+git_version name=:  # invalid
+
+git_version name="$(git_name)": 0.0.git.3.efdcaea
+git_version echo 1.4: 1.4
+git_version echo -n 1; echo -n .; echo 4: 1.4
+git_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=2 latest_tag_version=1.4: 0.2
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=0.1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version latest_tag_version=0.1: 0.2
+git_bumped_version follow=2.0: 0.2.0 # invalid but works
+git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+
+git_vcs: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:foo
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: test-foo-bar-0.0.git.3.efdcaea.tar.gz
+git_source_name name=foo: foo-0.0.git.3.efdcaea.tar.gz
+git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog:
+
+
+git_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_cwd_name: test
+git_cwd_name name=foo: foo
+git_cwd_name name=foo append=foo-bar: foo-foo-bar
+git_cwd_name append=foo: test-foo
+git_cwd_name append=foo-bar: test-foo-bar
+
+git_cwd_version: 0.0.git.3.efdcaea
+git_cwd_version name=foo: 0.0.git.3.efdcaea
+git_cwd_version lead=1: 1.0.git.3.efdcaea
+git_cwd_version lead=0.1: 0.1.0.git.3.efdcaea
+git_cwd_version follow=2: 0.2.git.3.efdcaea
+git_cwd_version lead=1 follow=2: 1.2.git.3.efdcaea
+git_cwd_version lead=x follow=x: x.x.git.3.efdcaea
+git_cwd_version lead=1-1:  # invalid
+git_cwd_version follow=2.0:  # invalid
+git_cwd_version follow=2-2:  # invalid
+git_cwd_version name=:  # invalid
+
+git_cwd_version name="$(git_name)": 0.0.git.3.efdcaea
+git_cwd_version echo 1.4: 1.4
+git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:foo
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: test-foo-bar-0.0.git.3.efdcaea.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.3.efdcaea.tar.gz
+git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_dir_name: test
+git_dir_name name=foo: foo
+git_dir_name name=foo append=foo-bar: foo-foo-bar
+git_dir_name append=foo: test-foo
+git_dir_name append=foo-bar: test-foo-bar
+
+git_dir_version: 0.0.git.3.efdcaea
+git_dir_version name=foo: 0.0.git.3.efdcaea
+git_dir_version lead=1: 1.0.git.3.efdcaea
+git_dir_version lead=0.1: 0.1.0.git.3.efdcaea
+git_dir_version follow=2: 0.2.git.3.efdcaea
+git_dir_version lead=1 follow=2: 1.2.git.3.efdcaea
+git_dir_version lead=x follow=x: x.x.git.3.efdcaea
+git_dir_version lead=1-1:  # invalid
+git_dir_version follow=2.0:  # invalid
+git_dir_version follow=2-2:  # invalid
+git_dir_version name=:  # invalid
+
+git_dir_version name="$(git_name)": 0.0.git.3.efdcaea
+git_dir_version echo 1.4: 1.4
+git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_dir_version date --date='@2147483647' %y%m%d: 380119
+
+
+git_dir_vcs: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:foo
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: test-foo-bar-0.0.git.3.efdcaea.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.3.efdcaea.tar.gz
+git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
diff --git a/tests/preproc/test_committed/run.sh b/tests/preproc/test_committed/run.sh
new file mode 100755
index 0000000..51d74bd
--- /dev/null
+++ b/tests/preproc/test_committed/run.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+cp ../input $repo
+
+git init $repo
+git -C $repo remote add origin https://pagure.io/clime/test.git
+git -C $repo add -A
+git -C $repo commit -m 'commit 1'
+touch $repo/foo
+git -C $repo add foo
+git -C $repo commit -m 'commit 2'
+touch $repo/bar
+git -C $repo add bar
+git -C $repo commit -m 'commit 3'
+
+touch output && cp output $output
+wtree_sub $repo $output
+head_commit_sub $repo $output
+
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_dirty/log b/tests/preproc/test_dirty/log
new file mode 100644
index 0000000..e78c556
--- /dev/null
+++ b/tests/preproc/test_dirty/log
@@ -0,0 +1,308 @@
+> git_name
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+---
+> git_name append=foo-bar
+---
+> git_version
+---
+> git_version name=foo
+---
+> git_version lead=1
+---
+> git_version lead=0.1
+---
+> git_version follow=2
+---
+> git_version lead=1 follow=2
+---
+> git_version lead=x follow=x
+---
+> git_version lead=1-1
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: follow cannot contain dots.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_version name="$(git_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+---
+> git_vcs subtree=foo
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog name=foo since_tag=foo-1.2-1
+---
+> git_changelog name=foo until_tag=foo-1.2-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_cwd_name
+---
+> git_cwd_name name=foo
+---
+> git_cwd_name name=foo append=foo-bar
+---
+> git_cwd_name append=foo
+---
+> git_cwd_name append=foo-bar
+---
+> git_cwd_version
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version lead=1
+---
+> git_cwd_version lead=0.1
+---
+> git_cwd_version follow=2
+---
+> git_cwd_version lead=1 follow=2
+---
+> git_cwd_version lead=x follow=x
+---
+> git_cwd_version lead=1-1
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_cwd_vcs
+---
+> git_cwd_vcs subtree=foo
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_dir_name
+---
+> git_dir_name name=foo
+---
+> git_dir_name name=foo append=foo-bar
+---
+> git_dir_name append=foo
+---
+> git_dir_name append=foo-bar
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=2
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_version name="$(git_dir_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_dir_vcs
+---
+> git_dir_vcs subtree=foo
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_dirty/output b/tests/preproc/test_dirty/output
new file mode 100644
index 0000000..0a4e179
--- /dev/null
+++ b/tests/preproc/test_dirty/output
@@ -0,0 +1,188 @@
+git_name: test
+git_name name=foo: foo
+git_name name=foo append=foo-bar: foo-foo-bar
+git_name append=foo: test-foo
+git_name append=foo-bar: test-foo-bar
+
+git_version: 0.0.git.1.1aefe40.wtree.zfxvuf
+git_version name=foo: 0.0.git.1.1aefe40.wtree.zfxvuf
+git_version lead=1: 1.0.git.1.1aefe40.wtree.zfxvuf
+git_version lead=0.1: 0.1.0.git.1.1aefe40.wtree.zfxvuf
+git_version follow=2: 0.2.git.1.1aefe40.wtree.zfxvuf
+git_version lead=1 follow=2: 1.2.git.1.1aefe40.wtree.zfxvuf
+git_version lead=x follow=x: x.x.git.1.1aefe40.wtree.zfxvuf
+git_version lead=1-1:  # invalid
+git_version follow=2.0:  # invalid
+git_version follow=2-2:  # invalid
+git_version name=:  # invalid
+
+git_version name="$(git_name)": 0.0.git.1.1aefe40.wtree.zfxvuf
+git_version echo 1.4: 1.4
+git_version echo -n 1; echo -n .; echo 4: 1.4
+git_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=2 latest_tag_version=1.4: 0.2
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=0.1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version latest_tag_version=0.1: 0.2
+git_bumped_version follow=2.0: 0.2.0 # invalid but works
+git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+
+git_vcs: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:foo
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: test-foo-bar-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
+git_source_name name=foo: foo-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
+git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog:
+
+
+git_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_cwd_name: test
+git_cwd_name name=foo: foo
+git_cwd_name name=foo append=foo-bar: foo-foo-bar
+git_cwd_name append=foo: test-foo
+git_cwd_name append=foo-bar: test-foo-bar
+
+git_cwd_version: 0.0.git.1.1aefe40.wtree.zfxvuf
+git_cwd_version name=foo: 0.0.git.1.1aefe40.wtree.zfxvuf
+git_cwd_version lead=1: 1.0.git.1.1aefe40.wtree.zfxvuf
+git_cwd_version lead=0.1: 0.1.0.git.1.1aefe40.wtree.zfxvuf
+git_cwd_version follow=2: 0.2.git.1.1aefe40.wtree.zfxvuf
+git_cwd_version lead=1 follow=2: 1.2.git.1.1aefe40.wtree.zfxvuf
+git_cwd_version lead=x follow=x: x.x.git.1.1aefe40.wtree.zfxvuf
+git_cwd_version lead=1-1:  # invalid
+git_cwd_version follow=2.0:  # invalid
+git_cwd_version follow=2-2:  # invalid
+git_cwd_version name=:  # invalid
+
+git_cwd_version name="$(git_name)": 0.0.git.1.1aefe40.wtree.zfxvuf
+git_cwd_version echo 1.4: 1.4
+git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:foo
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: test-foo-bar-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
+git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_dir_name: test
+git_dir_name name=foo: foo
+git_dir_name name=foo append=foo-bar: foo-foo-bar
+git_dir_name append=foo: test-foo
+git_dir_name append=foo-bar: test-foo-bar
+
+git_dir_version: 0.0.git.1.1aefe40.wtree.zfxvuf
+git_dir_version name=foo: 0.0.git.1.1aefe40.wtree.zfxvuf
+git_dir_version lead=1: 1.0.git.1.1aefe40.wtree.zfxvuf
+git_dir_version lead=0.1: 0.1.0.git.1.1aefe40.wtree.zfxvuf
+git_dir_version follow=2: 0.2.git.1.1aefe40.wtree.zfxvuf
+git_dir_version lead=1 follow=2: 1.2.git.1.1aefe40.wtree.zfxvuf
+git_dir_version lead=x follow=x: x.x.git.1.1aefe40.wtree.zfxvuf
+git_dir_version lead=1-1:  # invalid
+git_dir_version follow=2.0:  # invalid
+git_dir_version follow=2-2:  # invalid
+git_dir_version name=:  # invalid
+
+git_dir_version name="$(git_name)": 0.0.git.1.1aefe40.wtree.zfxvuf
+git_dir_version echo 1.4: 1.4
+git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_dir_version date --date='@2147483647' %y%m%d: 380119
+
+
+git_dir_vcs: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:foo
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: test-foo-bar-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
+git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
diff --git a/tests/preproc/test_dirty/run.sh b/tests/preproc/test_dirty/run.sh
new file mode 100755
index 0000000..c00a83e
--- /dev/null
+++ b/tests/preproc/test_dirty/run.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+cp ../input $repo
+
+git init $repo
+git -C $repo remote add origin https://pagure.io/clime/test.git
+git -C $repo add -A
+git -C $repo commit -a -m 'inital_commit'
+
+touch $repo/foo
+
+touch output && cp output $output
+wtree_sub $repo $output
+head_commit_sub $repo $output
+
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_inited/log b/tests/preproc/test_inited/log
new file mode 100644
index 0000000..d84fcd1
--- /dev/null
+++ b/tests/preproc/test_inited/log
@@ -0,0 +1,347 @@
+> git_name
+git_name: Start by setting origin URL.
+git_name failed with value 1
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+git_name: Start by setting origin URL.
+git_name append=foo failed with value 1
+---
+> git_name append=foo-bar
+git_name: Start by setting origin URL.
+git_name append=foo-bar failed with value 1
+---
+> git_version
+---
+> git_version name=foo
+---
+> git_version lead=1
+---
+> git_version lead=0.1
+---
+> git_version follow=2
+---
+> git_version lead=1 follow=2
+---
+> git_version lead=x follow=x
+---
+> git_version lead=1-1
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: follow cannot contain dots.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_version name="$(git_name)"
+git_name: Start by setting origin URL.
+git_version: name cannot be empty.
+git_version name="$(git_name)" failed with value 1
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+git_vcs: Start by setting origin URL.
+git_vcs failed with value 1
+---
+> git_vcs subtree=foo
+git_vcs: Start by setting origin URL.
+git_vcs subtree=foo failed with value 1
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog name=foo since_tag=foo-1.2-1
+---
+> git_changelog name=foo until_tag=foo-1.2-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_cwd_name
+git_cwd_name: Start by setting origin URL.
+git_cwd_name failed with value 1
+---
+> git_cwd_name name=foo
+---
+> git_cwd_name name=foo append=foo-bar
+---
+> git_cwd_name append=foo
+git_cwd_name: Start by setting origin URL.
+git_cwd_name append=foo failed with value 1
+---
+> git_cwd_name append=foo-bar
+git_cwd_name: Start by setting origin URL.
+git_cwd_name append=foo-bar failed with value 1
+---
+> git_cwd_version
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version lead=1
+---
+> git_cwd_version lead=0.1
+---
+> git_cwd_version follow=2
+---
+> git_cwd_version lead=1 follow=2
+---
+> git_cwd_version lead=x follow=x
+---
+> git_cwd_version lead=1-1
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+git_cwd_name: Start by setting origin URL.
+git_cwd_version: name cannot be empty.
+git_cwd_version name="$(git_cwd_name)" failed with value 1
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_cwd_vcs
+git_cwd_vcs: Start by setting origin URL.
+git_cwd_vcs failed with value 1
+---
+> git_cwd_vcs subtree=foo
+git_cwd_vcs: Start by setting origin URL.
+git_cwd_vcs subtree=foo failed with value 1
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_dir_name
+git_dir_name: Start by setting origin URL.
+git_dir_name failed with value 1
+---
+> git_dir_name name=foo
+---
+> git_dir_name name=foo append=foo-bar
+---
+> git_dir_name append=foo
+git_dir_name: Start by setting origin URL.
+git_dir_name append=foo failed with value 1
+---
+> git_dir_name append=foo-bar
+git_dir_name: Start by setting origin URL.
+git_dir_name append=foo-bar failed with value 1
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=2
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_version name="$(git_dir_name)"
+git_dir_name: Start by setting origin URL.
+git_dir_version: name cannot be empty.
+git_dir_version name="$(git_dir_name)" failed with value 1
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_dir_vcs
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs failed with value 1
+---
+> git_dir_vcs subtree=foo
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs subtree=foo failed with value 1
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_inited/log_git b/tests/preproc/test_inited/log_git
deleted file mode 100644
index 675cab4..0000000
--- a/tests/preproc/test_inited/log_git
+++ /dev/null
@@ -1,134 +0,0 @@
-> git_name
-git_name: Start by setting origin URL.
-git_name failed with value 1
----
-> git_name name=foo
----
-> git_name name=foo append=foo-bar
----
-> git_name append=foo
-git_name: Start by setting origin URL.
-git_name append=foo failed with value 1
----
-> git_name append=foo-bar
-git_name: Start by setting origin URL.
-git_name append=foo-bar failed with value 1
----
-> git_version
-git_version: name cannot be empty.
-git_version failed with value 1
----
-> git_version name=foo
----
-> git_version lead=1
-git_version: name cannot be empty.
-git_version lead=1 failed with value 1
----
-> git_version lead=0.1
-git_version: name cannot be empty.
-git_version lead=0.1 failed with value 1
----
-> git_version follow=2
-git_version: name cannot be empty.
-git_version follow=2 failed with value 1
----
-> git_version lead=1 follow=2
-git_version: name cannot be empty.
-git_version lead=1 follow=2 failed with value 1
----
-> git_version lead=x follow=x
-git_version: name cannot be empty.
-git_version lead=x follow=x failed with value 1
----
-> git_version lead=1-1
-git_version: name cannot be empty.
-git_version lead=1-1 failed with value 1
----
-> git_version follow=2.0
-git_version: name cannot be empty.
-git_version follow=2.0 failed with value 1
----
-> git_version follow=2-2
-git_version: name cannot be empty.
-git_version follow=2-2 failed with value 1
----
-> git_version name=
-git_version: name cannot be empty.
-git_version name= failed with value 1
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
-> git_vcs
-git_vcs: Start by setting origin URL.
-git_vcs failed with value 1
----
-> git_vcs subtree=foo
-git_vcs: Start by setting origin URL.
-git_vcs subtree=foo failed with value 1
----
-> git_pack
-git_pack: OUTDIR is not set. No action taken.
----
-> git_pack dir_name=foo
-git_pack: OUTDIR is not set. No action taken.
----
-> git_pack dir_name=foo source_name=foo.tar.gz
-git_pack: OUTDIR is not set. No action taken.
----
-> git_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_pack: OUTDIR is not set. No action taken.
----
-> git_archive
-git_archive: OUTDIR is not set. No action taken.
----
-> git_archive dir_name=foo
-git_archive: OUTDIR is not set. No action taken.
----
-> git_archive dir_name=foo source_name=foo.tar.gz
-git_archive: OUTDIR is not set. No action taken.
----
-> git_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_archive: OUTDIR is not set. No action taken.
----
-> git_source_name
----
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
----
-> git_changelog
----
-> git_changelog since_tag=foo-1.2
----
-> git_changelog until_tag=foo-1.2
----
-> git_changelog since_tag=foo-1.2 until_tag=foo-1.4
----
-> git_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
----
diff --git a/tests/preproc/test_inited/log_git_cwd b/tests/preproc/test_inited/log_git_cwd
deleted file mode 100644
index 6720963..0000000
--- a/tests/preproc/test_inited/log_git_cwd
+++ /dev/null
@@ -1,104 +0,0 @@
-> git_cwd_name
-git_cwd_name: Start by setting origin URL.
-git_cwd_name failed with value 1
----
-> git_cwd_name append=foo
-git_cwd_name: Start by setting origin URL.
-git_cwd_name append=foo failed with value 1
----
-> git_cwd_name append=foo-bar
-git_cwd_name: Start by setting origin URL.
-git_cwd_name append=foo-bar failed with value 1
----
-> git_cwd_version
-git_cwd_version: name cannot be empty.
-git_cwd_version failed with value 1
----
-> git_cwd_version name=foo
----
-> git_cwd_version lead=1
-git_cwd_version: name cannot be empty.
-git_cwd_version lead=1 failed with value 1
----
-> git_cwd_version lead=0.1
-git_cwd_version: name cannot be empty.
-git_cwd_version lead=0.1 failed with value 1
----
-> git_cwd_version follow=2
-git_cwd_version: name cannot be empty.
-git_cwd_version follow=2 failed with value 1
----
-> git_cwd_version lead=1 follow=2
-git_cwd_version: name cannot be empty.
-git_cwd_version lead=1 follow=2 failed with value 1
----
-> git_cwd_version lead=x follow=x
-git_cwd_version: name cannot be empty.
-git_cwd_version lead=x follow=x failed with value 1
----
-> git_cwd_version lead=1-1
-git_cwd_version: name cannot be empty.
-git_cwd_version lead=1-1 failed with value 1
----
-> git_cwd_version follow=2.0
-git_cwd_version: name cannot be empty.
-git_cwd_version follow=2.0 failed with value 1
----
-> git_cwd_version follow=2-2
-git_cwd_version: name cannot be empty.
-git_cwd_version follow=2-2 failed with value 1
----
-> git_cwd_version name=
-git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
----
-> git_cwd_vcs
-git_cwd_vcs: Start by setting origin URL.
-git_cwd_vcs failed with value 1
----
-> git_cwd_vcs subtree=foo
-git_cwd_vcs: Start by setting origin URL.
-git_cwd_vcs subtree=foo failed with value 1
----
-> git_cwd_pack
-git_cwd_pack: OUTDIR is not set. No action taken.
----
-> git_cwd_pack dir_name=foo
-git_cwd_pack: OUTDIR is not set. No action taken.
----
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
----
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
----
-> git_cwd_archive
-git_cwd_archive: OUTDIR is not set. No action taken.
----
-> git_cwd_archive dir_name=foo
-git_cwd_archive: OUTDIR is not set. No action taken.
----
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
----
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
----
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
----
-> git_cwd_source_name name=foo version=1.2 format=tar
----
-> git_cwd_changelog
----
-> git_cwd_changelog since_tag=foo-1.2
----
-> git_cwd_changelog until_tag=foo-1.2
----
-> git_cwd_changelog since_tag=foo-1.2 until_tag=foo-1.4
----
-> git_cwd_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
----
diff --git a/tests/preproc/test_inited/log_git_dir b/tests/preproc/test_inited/log_git_dir
deleted file mode 100644
index 8e49948..0000000
--- a/tests/preproc/test_inited/log_git_dir
+++ /dev/null
@@ -1,114 +0,0 @@
-> git_dir_name
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_name: Start by setting origin URL.
-git_dir_name failed with value 1
----
-> git_dir_name append=foo
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_name: Start by setting origin URL.
-git_dir_name append=foo failed with value 1
----
-> git_dir_name append=foo-bar
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_name: Start by setting origin URL.
-git_dir_name append=foo-bar failed with value 1
----
-> git_dir_version
-git_dir_version: name cannot be empty.
-git_dir_version failed with value 1
----
-> git_dir_version name=foo
----
-> git_dir_version lead=1
-git_dir_version: name cannot be empty.
-git_dir_version lead=1 failed with value 1
----
-> git_dir_version lead=0.1
-git_dir_version: name cannot be empty.
-git_dir_version lead=0.1 failed with value 1
----
-> git_dir_version follow=2
-git_dir_version: name cannot be empty.
-git_dir_version follow=2 failed with value 1
----
-> git_dir_version lead=1 follow=2
-git_dir_version: name cannot be empty.
-git_dir_version lead=1 follow=2 failed with value 1
----
-> git_dir_version lead=x follow=x
-git_dir_version: name cannot be empty.
-git_dir_version lead=x follow=x failed with value 1
----
-> git_dir_version lead=1-1
-git_dir_version: name cannot be empty.
-git_dir_version lead=1-1 failed with value 1
----
-> git_dir_version follow=2.0
-git_dir_version: name cannot be empty.
-git_dir_version follow=2.0 failed with value 1
----
-> git_dir_version follow=2-2
-git_dir_version: name cannot be empty.
-git_dir_version follow=2-2 failed with value 1
----
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
----
-> git_dir_vcs
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_vcs: Start by setting origin URL.
-git_dir_vcs failed with value 1
----
-> git_dir_vcs subtree=foo
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_vcs: Start by setting origin URL.
-git_dir_vcs subtree=foo failed with value 1
----
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_source_name
----
-> git_dir_source_name name=foo
----
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
----
-> git_dir_changelog
----
-> git_dir_changelog since_tag=foo-1.2
----
-> git_dir_changelog until_tag=foo-1.2
----
-> git_dir_changelog since_tag=foo-1.2 until_tag=foo-1.4
----
-> git_dir_changelog since_tag=foo-1.2 until_tag=foo-1.4 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
----
diff --git a/tests/preproc/test_inited/output b/tests/preproc/test_inited/output
new file mode 100644
index 0000000..358a6c9
--- /dev/null
+++ b/tests/preproc/test_inited/output
@@ -0,0 +1,188 @@
+git_name: 
+git_name name=foo: foo
+git_name name=foo append=foo-bar: foo-foo-bar
+git_name append=foo: 
+git_name append=foo-bar: 
+
+git_version: 0.0.wtree.zfxvuh
+git_version name=foo: 0.0.wtree.zfxvuh
+git_version lead=1: 1.0.wtree.zfxvuh
+git_version lead=0.1: 0.1.0.wtree.zfxvuh
+git_version follow=2: 0.2.wtree.zfxvuh
+git_version lead=1 follow=2: 1.2.wtree.zfxvuh
+git_version lead=x follow=x: x.x.wtree.zfxvuh
+git_version lead=1-1:  # invalid
+git_version follow=2.0:  # invalid
+git_version follow=2-2:  # invalid
+git_version name=:  # invalid
+
+git_version name="$(git_name)": 
+git_version echo 1.4: 1.4
+git_version echo -n 1; echo -n .; echo 4: 1.4
+git_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=2 latest_tag_version=1.4: 0.2
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=0.1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version latest_tag_version=0.1: 0.2
+git_bumped_version follow=2.0: 0.2.0 # invalid but works
+git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+
+git_vcs: 
+git_vcs subtree=foo: 
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: foo-foo-bar-x.x.wtree.zfxvuh.tar.gz
+git_source_name name=foo: foo-x.x.wtree.zfxvuh.tar.gz
+git_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog:
+
+
+git_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_cwd_name: 
+git_cwd_name name=foo: foo
+git_cwd_name name=foo append=foo-bar: foo-foo-bar
+git_cwd_name append=foo: 
+git_cwd_name append=foo-bar: 
+
+git_cwd_version: 0.0.wtree.zfxvuh
+git_cwd_version name=foo: 0.0.wtree.zfxvuh
+git_cwd_version lead=1: 1.0.wtree.zfxvuh
+git_cwd_version lead=0.1: 0.1.0.wtree.zfxvuh
+git_cwd_version follow=2: 0.2.wtree.zfxvuh
+git_cwd_version lead=1 follow=2: 1.2.wtree.zfxvuh
+git_cwd_version lead=x follow=x: x.x.wtree.zfxvuh
+git_cwd_version lead=1-1:  # invalid
+git_cwd_version follow=2.0:  # invalid
+git_cwd_version follow=2-2:  # invalid
+git_cwd_version name=:  # invalid
+
+git_cwd_version name="$(git_name)": 
+git_cwd_version echo 1.4: 1.4
+git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_cwd_vcs: 
+git_cwd_vcs subtree=foo: 
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: foo-foo-bar-x.x.wtree.zfxvuh.tar.gz
+git_cwd_source_name name=foo: foo-x.x.wtree.zfxvuh.tar.gz
+git_cwd_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_dir_name: 
+git_dir_name name=foo: foo
+git_dir_name name=foo append=foo-bar: foo-foo-bar
+git_dir_name append=foo: 
+git_dir_name append=foo-bar: 
+
+git_dir_version: 0.0.wtree.zfxvuh
+git_dir_version name=foo: 0.0.wtree.zfxvuh
+git_dir_version lead=1: 1.0.wtree.zfxvuh
+git_dir_version lead=0.1: 0.1.0.wtree.zfxvuh
+git_dir_version follow=2: 0.2.wtree.zfxvuh
+git_dir_version lead=1 follow=2: 1.2.wtree.zfxvuh
+git_dir_version lead=x follow=x: x.x.wtree.zfxvuh
+git_dir_version lead=1-1:  # invalid
+git_dir_version follow=2.0:  # invalid
+git_dir_version follow=2-2:  # invalid
+git_dir_version name=:  # invalid
+
+git_dir_version name="$(git_name)": 
+git_dir_version echo 1.4: 1.4
+git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_dir_version date --date='@2147483647' %y%m%d: 380119
+
+
+git_dir_vcs: 
+git_dir_vcs subtree=foo: 
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: foo-foo-bar-x.x.wtree.zfxvuh.tar.gz
+git_dir_source_name name=foo: foo-x.x.wtree.zfxvuh.tar.gz
+git_dir_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
diff --git a/tests/preproc/test_inited/output_git b/tests/preproc/test_inited/output_git
deleted file mode 100644
index 7b2df90..0000000
--- a/tests/preproc/test_inited/output_git
+++ /dev/null
@@ -1,55 +0,0 @@
-
-foo
-foo-foo-bar
-
-
-
-
-0.0
-
-
-
-
-
- # invalid
- # invalid
- # invalid
- # invalid
-
-0.1
-1.0
-0.2
-1.2
-1.3
-0.2
-0.1
-0.1
-0.1
-0.1
-0.2
-0.2.0 # invalid but works
-0.1 # invalid but works
-
-
-
-
-
-
-foo.tar.gz
-foo.tar.gz
-
-
-
-foo.tar.gz
-foo.tar.gz
-
--.tar.gz
-foo-.tar.gz
--1.2.tar.gz
-foo-1.2.tar
-
-
-
-
-
-
diff --git a/tests/preproc/test_inited/output_git_cwd b/tests/preproc/test_inited/output_git_cwd
deleted file mode 100644
index 34202b8..0000000
--- a/tests/preproc/test_inited/output_git_cwd
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-0.0
-
-
-
-
-
- # invalid
- # invalid
- # invalid
- # invalid
-
-
-
-
-
-
-foo.tar.gz
-foo.tar.gz
-
-
-
-foo.tar.gz
-foo.tar.gz
-
--.tar.gz
-foo-.tar.gz
--1.2.tar.gz
-foo-1.2.tar
-
-
-
-
-
-
diff --git a/tests/preproc/test_inited/output_git_dir b/tests/preproc/test_inited/output_git_dir
deleted file mode 100644
index 34202b8..0000000
--- a/tests/preproc/test_inited/output_git_dir
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-0.0
-
-
-
-
-
- # invalid
- # invalid
- # invalid
- # invalid
-
-
-
-
-
-
-foo.tar.gz
-foo.tar.gz
-
-
-
-foo.tar.gz
-foo.tar.gz
-
--.tar.gz
-foo-.tar.gz
--1.2.tar.gz
-foo-1.2.tar
-
-
-
-
-
-
diff --git a/tests/preproc/test_inited/run.sh b/tests/preproc/test_inited/run.sh
index 9df977a..eaddf19 100755
--- a/tests/preproc/test_inited/run.sh
+++ b/tests/preproc/test_inited/run.sh
@@ -1,29 +1,17 @@
-#!/bin/bash -x
+#!/bin/bash
 
 . ../lib.sh
 
-REPO=`mktemp -d`
-OUT=`mktemp -d`
-git init $REPO
+repo=`mktemp -d`
+output=`mktemp`
 
-../run_preproc.py --path $REPO --input ../input_git --output $OUT/output_git --dump-spec-only | log_filter | tee $OUT/log_git
-../run_preproc.py --path $REPO --input ../input_git_dir --output $OUT/output_git_dir --dump-spec-only | log_filter | tee $OUT/log_git_dir
-../run_preproc.py --path $REPO --input ../input_git_cwd --output $OUT/output_git_cwd --dump-spec-only | log_filter | tee $OUT/log_git_cwd
+cp ../input $repo
+git init $repo
 
-if [ "$1" == 'copy' ]; then
-    cp $OUT/* .
-    echo copied.
-    rm -r $REPO $OUT
-    exit
-fi
+touch output && cp output $output
+wtree_sub $repo $output
 
-diff output_git $OUT/output_git || die
-diff output_git_dir $OUT/output_git_dir || die
-diff output_git_cwd $OUT/output_git_cwd || die
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
 
-diff log_git $OUT/log_git || die
-diff log_git_dir $OUT/log_git_dir || die
-diff log_git_cwd $OUT/log_git_cwd || die
-
-rm -r $REPO $OUT
-echo success.
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_inited_origin_set/log b/tests/preproc/test_inited_origin_set/log
new file mode 100644
index 0000000..e78c556
--- /dev/null
+++ b/tests/preproc/test_inited_origin_set/log
@@ -0,0 +1,308 @@
+> git_name
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+---
+> git_name append=foo-bar
+---
+> git_version
+---
+> git_version name=foo
+---
+> git_version lead=1
+---
+> git_version lead=0.1
+---
+> git_version follow=2
+---
+> git_version lead=1 follow=2
+---
+> git_version lead=x follow=x
+---
+> git_version lead=1-1
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: follow cannot contain dots.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_version name="$(git_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+---
+> git_vcs subtree=foo
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog name=foo since_tag=foo-1.2-1
+---
+> git_changelog name=foo until_tag=foo-1.2-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_cwd_name
+---
+> git_cwd_name name=foo
+---
+> git_cwd_name name=foo append=foo-bar
+---
+> git_cwd_name append=foo
+---
+> git_cwd_name append=foo-bar
+---
+> git_cwd_version
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version lead=1
+---
+> git_cwd_version lead=0.1
+---
+> git_cwd_version follow=2
+---
+> git_cwd_version lead=1 follow=2
+---
+> git_cwd_version lead=x follow=x
+---
+> git_cwd_version lead=1-1
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_cwd_vcs
+---
+> git_cwd_vcs subtree=foo
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_dir_name
+---
+> git_dir_name name=foo
+---
+> git_dir_name name=foo append=foo-bar
+---
+> git_dir_name append=foo
+---
+> git_dir_name append=foo-bar
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=2
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_version name="$(git_dir_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_dir_vcs
+---
+> git_dir_vcs subtree=foo
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_inited_origin_set/output b/tests/preproc/test_inited_origin_set/output
new file mode 100644
index 0000000..a4c8c83
--- /dev/null
+++ b/tests/preproc/test_inited_origin_set/output
@@ -0,0 +1,188 @@
+git_name: test
+git_name name=foo: foo
+git_name name=foo append=foo-bar: foo-foo-bar
+git_name append=foo: test-foo
+git_name append=foo-bar: test-foo-bar
+
+git_version: 0.0.wtree.zfxvuj
+git_version name=foo: 0.0.wtree.zfxvuj
+git_version lead=1: 1.0.wtree.zfxvuj
+git_version lead=0.1: 0.1.0.wtree.zfxvuj
+git_version follow=2: 0.2.wtree.zfxvuj
+git_version lead=1 follow=2: 1.2.wtree.zfxvuj
+git_version lead=x follow=x: x.x.wtree.zfxvuj
+git_version lead=1-1:  # invalid
+git_version follow=2.0:  # invalid
+git_version follow=2-2:  # invalid
+git_version name=:  # invalid
+
+git_version name="$(git_name)": 0.0.wtree.zfxvuj
+git_version echo 1.4: 1.4
+git_version echo -n 1; echo -n .; echo 4: 1.4
+git_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=2 latest_tag_version=1.4: 0.2
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=0.1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version latest_tag_version=0.1: 0.2
+git_bumped_version follow=2.0: 0.2.0 # invalid but works
+git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+
+git_vcs: git+https://pagure.io/clime/test.git#HEAD:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: test-foo-bar-0.0.wtree.zfxvuj.tar.gz
+git_source_name name=foo: foo-0.0.wtree.zfxvuj.tar.gz
+git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog:
+
+
+git_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_cwd_name: test
+git_cwd_name name=foo: foo
+git_cwd_name name=foo append=foo-bar: foo-foo-bar
+git_cwd_name append=foo: test-foo
+git_cwd_name append=foo-bar: test-foo-bar
+
+git_cwd_version: 0.0.wtree.zfxvuj
+git_cwd_version name=foo: 0.0.wtree.zfxvuj
+git_cwd_version lead=1: 1.0.wtree.zfxvuj
+git_cwd_version lead=0.1: 0.1.0.wtree.zfxvuj
+git_cwd_version follow=2: 0.2.wtree.zfxvuj
+git_cwd_version lead=1 follow=2: 1.2.wtree.zfxvuj
+git_cwd_version lead=x follow=x: x.x.wtree.zfxvuj
+git_cwd_version lead=1-1:  # invalid
+git_cwd_version follow=2.0:  # invalid
+git_cwd_version follow=2-2:  # invalid
+git_cwd_version name=:  # invalid
+
+git_cwd_version name="$(git_name)": 0.0.wtree.zfxvuj
+git_cwd_version echo 1.4: 1.4
+git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: test-foo-bar-0.0.wtree.zfxvuj.tar.gz
+git_cwd_source_name name=foo: foo-0.0.wtree.zfxvuj.tar.gz
+git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_dir_name: test
+git_dir_name name=foo: foo
+git_dir_name name=foo append=foo-bar: foo-foo-bar
+git_dir_name append=foo: test-foo
+git_dir_name append=foo-bar: test-foo-bar
+
+git_dir_version: 0.0.wtree.zfxvuj
+git_dir_version name=foo: 0.0.wtree.zfxvuj
+git_dir_version lead=1: 1.0.wtree.zfxvuj
+git_dir_version lead=0.1: 0.1.0.wtree.zfxvuj
+git_dir_version follow=2: 0.2.wtree.zfxvuj
+git_dir_version lead=1 follow=2: 1.2.wtree.zfxvuj
+git_dir_version lead=x follow=x: x.x.wtree.zfxvuj
+git_dir_version lead=1-1:  # invalid
+git_dir_version follow=2.0:  # invalid
+git_dir_version follow=2-2:  # invalid
+git_dir_version name=:  # invalid
+
+git_dir_version name="$(git_name)": 0.0.wtree.zfxvuj
+git_dir_version echo 1.4: 1.4
+git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_dir_version date --date='@2147483647' %y%m%d: 380119
+
+
+git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: test-foo-bar-0.0.wtree.zfxvuj.tar.gz
+git_dir_source_name name=foo: foo-0.0.wtree.zfxvuj.tar.gz
+git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
diff --git a/tests/preproc/test_inited_origin_set/run.sh b/tests/preproc/test_inited_origin_set/run.sh
new file mode 100755
index 0000000..19a9cd9
--- /dev/null
+++ b/tests/preproc/test_inited_origin_set/run.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+cp ../input $repo
+
+git init $repo
+git -C $repo remote add origin https://pagure.io/clime/test.git
+
+touch output && cp output $output
+wtree_sub $repo $output
+
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_sources/input b/tests/preproc/test_sources/input
new file mode 100644
index 0000000..df366bb
--- /dev/null
+++ b/tests/preproc/test_sources/input
@@ -0,0 +1,2 @@
+git_pack dir_name=foo source_name=foo.tar.gz: {{{ git_pack dir_name=foo source_name=foo.tar.gz }}}
+git_archive dir_name=foo source_name=foo.tar.gz: {{{ git_archive dir_name=foo source_name=foo.tar.gz }}}
diff --git a/tests/preproc/test_sources/log b/tests/preproc/test_sources/log
new file mode 100644
index 0000000..ccf47ce
--- /dev/null
+++ b/tests/preproc/test_sources/log
@@ -0,0 +1,6 @@
+> git_pack dir_name=foo source_name=foo.tar.gz
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: No commits yet. Cannot archive the content.
+git_archive dir_name=foo source_name=foo.tar.gz failed with value 1
+---
diff --git a/tests/preproc/test_sources/output b/tests/preproc/test_sources/output
new file mode 100644
index 0000000..071b182
--- /dev/null
+++ b/tests/preproc/test_sources/output
@@ -0,0 +1,2 @@
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive dir_name=foo source_name=foo.tar.gz: 
diff --git a/tests/preproc/test_sources/run.sh b/tests/preproc/test_sources/run.sh
new file mode 100755
index 0000000..f23008a
--- /dev/null
+++ b/tests/preproc/test_sources/run.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+cp input $repo
+git init $repo
+
+touch output && cp output $output
+wtree_sub $repo $output
+
+generic_test opts='' path=$repo input=$repo/input expected_output=$output expected_log=log expected_sources="foo.tar.gz" copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_subdir/log b/tests/preproc/test_subdir/log
new file mode 100644
index 0000000..e78c556
--- /dev/null
+++ b/tests/preproc/test_subdir/log
@@ -0,0 +1,308 @@
+> git_name
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+---
+> git_name append=foo-bar
+---
+> git_version
+---
+> git_version name=foo
+---
+> git_version lead=1
+---
+> git_version lead=0.1
+---
+> git_version follow=2
+---
+> git_version lead=1 follow=2
+---
+> git_version lead=x follow=x
+---
+> git_version lead=1-1
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: follow cannot contain dots.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_version name="$(git_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+---
+> git_vcs subtree=foo
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog name=foo since_tag=foo-1.2-1
+---
+> git_changelog name=foo until_tag=foo-1.2-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_cwd_name
+---
+> git_cwd_name name=foo
+---
+> git_cwd_name name=foo append=foo-bar
+---
+> git_cwd_name append=foo
+---
+> git_cwd_name append=foo-bar
+---
+> git_cwd_version
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version lead=1
+---
+> git_cwd_version lead=0.1
+---
+> git_cwd_version follow=2
+---
+> git_cwd_version lead=1 follow=2
+---
+> git_cwd_version lead=x follow=x
+---
+> git_cwd_version lead=1-1
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_cwd_vcs
+---
+> git_cwd_vcs subtree=foo
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_dir_name
+---
+> git_dir_name name=foo
+---
+> git_dir_name name=foo append=foo-bar
+---
+> git_dir_name append=foo
+---
+> git_dir_name append=foo-bar
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=2
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_version name="$(git_dir_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_dir_vcs
+---
+> git_dir_vcs subtree=foo
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_subdir/output b/tests/preproc/test_subdir/output
new file mode 100644
index 0000000..70d9b87
--- /dev/null
+++ b/tests/preproc/test_subdir/output
@@ -0,0 +1,188 @@
+git_name: test
+git_name name=foo: foo
+git_name name=foo append=foo-bar: foo-foo-bar
+git_name append=foo: test-foo
+git_name append=foo-bar: test-foo-bar
+
+git_version: 0.0.wtree.zfxvum
+git_version name=foo: 0.0.wtree.zfxvum
+git_version lead=1: 1.0.wtree.zfxvum
+git_version lead=0.1: 0.1.0.wtree.zfxvum
+git_version follow=2: 0.2.wtree.zfxvum
+git_version lead=1 follow=2: 1.2.wtree.zfxvum
+git_version lead=x follow=x: x.x.wtree.zfxvum
+git_version lead=1-1:  # invalid
+git_version follow=2.0:  # invalid
+git_version follow=2-2:  # invalid
+git_version name=:  # invalid
+
+git_version name="$(git_name)": 0.0.wtree.zfxvum
+git_version echo 1.4: 1.4
+git_version echo -n 1; echo -n .; echo 4: 1.4
+git_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=2 latest_tag_version=1.4: 0.2
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=0.1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version latest_tag_version=0.1: 0.2
+git_bumped_version follow=2.0: 0.2.0 # invalid but works
+git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+
+git_vcs: git+https://pagure.io/clime/test.git#HEAD:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: test-foo-bar-0.0.wtree.zfxvum.tar.gz
+git_source_name name=foo: foo-0.0.wtree.zfxvum.tar.gz
+git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog:
+
+
+git_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_cwd_name: test-subdir1
+git_cwd_name name=foo: foo-subdir1
+git_cwd_name name=foo append=foo-bar: foo-foo-bar
+git_cwd_name append=foo: test-foo
+git_cwd_name append=foo-bar: test-foo-bar
+
+git_cwd_version: 0.0.wtree.zfxvum
+git_cwd_version name=foo: 0.0.wtree.zfxvum
+git_cwd_version lead=1: 1.0.wtree.zfxvum
+git_cwd_version lead=0.1: 0.1.0.wtree.zfxvum
+git_cwd_version follow=2: 0.2.wtree.zfxvum
+git_cwd_version lead=1 follow=2: 1.2.wtree.zfxvum
+git_cwd_version lead=x follow=x: x.x.wtree.zfxvum
+git_cwd_version lead=1-1:  # invalid
+git_cwd_version follow=2.0:  # invalid
+git_cwd_version follow=2-2:  # invalid
+git_cwd_version name=:  # invalid
+
+git_cwd_version name="$(git_name)": 0.0.wtree.zfxvum
+git_cwd_version echo 1.4: 1.4
+git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir1/
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: test-foo-bar-0.0.wtree.zfxvum.tar.gz
+git_cwd_source_name name=foo: foo-0.0.wtree.zfxvum.tar.gz
+git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_dir_name: test-subdir2
+git_dir_name name=foo: foo-subdir2
+git_dir_name name=foo append=foo-bar: foo-foo-bar
+git_dir_name append=foo: test-foo
+git_dir_name append=foo-bar: test-foo-bar
+
+git_dir_version: 0.0.wtree.zfxvum
+git_dir_version name=foo: 0.0.wtree.zfxvum
+git_dir_version lead=1: 1.0.wtree.zfxvum
+git_dir_version lead=0.1: 0.1.0.wtree.zfxvum
+git_dir_version follow=2: 0.2.wtree.zfxvum
+git_dir_version lead=1 follow=2: 1.2.wtree.zfxvum
+git_dir_version lead=x follow=x: x.x.wtree.zfxvum
+git_dir_version lead=1-1:  # invalid
+git_dir_version follow=2.0:  # invalid
+git_dir_version follow=2-2:  # invalid
+git_dir_version name=:  # invalid
+
+git_dir_version name="$(git_name)": 0.0.wtree.zfxvum
+git_dir_version echo 1.4: 1.4
+git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_dir_version date --date='@2147483647' %y%m%d: 380119
+
+
+git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir2/
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: test-foo-bar-0.0.wtree.zfxvum.tar.gz
+git_dir_source_name name=foo: foo-0.0.wtree.zfxvum.tar.gz
+git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
diff --git a/tests/preproc/test_subdir/run.sh b/tests/preproc/test_subdir/run.sh
new file mode 100755
index 0000000..9374763
--- /dev/null
+++ b/tests/preproc/test_subdir/run.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+mkdir $repo/subdir1 $repo/subdir2
+cp ../input $repo/subdir2/
+
+git init $repo
+git -C $repo remote add origin https://pagure.io/clime/test.git
+
+touch output && cp output $output
+wtree_sub $repo $output
+
+generic_test opts='--dump-spec-only' path=$repo/subdir1 input=$repo/subdir2/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_tagged/log b/tests/preproc/test_tagged/log
new file mode 100644
index 0000000..e78c556
--- /dev/null
+++ b/tests/preproc/test_tagged/log
@@ -0,0 +1,308 @@
+> git_name
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+---
+> git_name append=foo-bar
+---
+> git_version
+---
+> git_version name=foo
+---
+> git_version lead=1
+---
+> git_version lead=0.1
+---
+> git_version follow=2
+---
+> git_version lead=1 follow=2
+---
+> git_version lead=x follow=x
+---
+> git_version lead=1-1
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: follow cannot contain dots.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_version name="$(git_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+---
+> git_vcs subtree=foo
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog name=foo since_tag=foo-1.2-1
+---
+> git_changelog name=foo until_tag=foo-1.2-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_cwd_name
+---
+> git_cwd_name name=foo
+---
+> git_cwd_name name=foo append=foo-bar
+---
+> git_cwd_name append=foo
+---
+> git_cwd_name append=foo-bar
+---
+> git_cwd_version
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version lead=1
+---
+> git_cwd_version lead=0.1
+---
+> git_cwd_version follow=2
+---
+> git_cwd_version lead=1 follow=2
+---
+> git_cwd_version lead=x follow=x
+---
+> git_cwd_version lead=1-1
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_cwd_vcs
+---
+> git_cwd_vcs subtree=foo
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_dir_name
+---
+> git_dir_name name=foo
+---
+> git_dir_name name=foo append=foo-bar
+---
+> git_dir_name append=foo
+---
+> git_dir_name append=foo-bar
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=2
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_version name="$(git_dir_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_dir_vcs
+---
+> git_dir_vcs subtree=foo
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_tagged/output b/tests/preproc/test_tagged/output
new file mode 100644
index 0000000..0a54d80
--- /dev/null
+++ b/tests/preproc/test_tagged/output
@@ -0,0 +1,326 @@
+git_name: test
+git_name name=foo: foo
+git_name name=foo append=foo-bar: foo-foo-bar
+git_name append=foo: test-foo
+git_name append=foo-bar: test-foo-bar
+
+git_version: 0.0.git.1.be51f06
+git_version name=foo: 0.0
+git_version lead=1: 1.0.git.1.be51f06
+git_version lead=0.1: 0.1.0.git.1.be51f06
+git_version follow=2: 0.2.git.1.be51f06
+git_version lead=1 follow=2: 1.2.git.1.be51f06
+git_version lead=x follow=x: x.x.git.1.be51f06
+git_version lead=1-1:  # invalid
+git_version follow=2.0:  # invalid
+git_version follow=2-2:  # invalid
+git_version name=:  # invalid
+
+git_version name="$(git_name)": 0.0.git.1.be51f06
+git_version echo 1.4: 1.4
+git_version echo -n 1; echo -n .; echo 4: 1.4
+git_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=2 latest_tag_version=1.4: 0.2
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=0.1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version latest_tag_version=0.1: 0.2
+git_bumped_version follow=2.0: 0.2.0 # invalid but works
+git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+
+git_vcs: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:foo
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: test-foo-bar-0.0.git.1.be51f06.tar.gz
+git_source_name name=foo: foo-0.0.git.1.be51f06.tar.gz
+git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog:
+
+
+git_changelog name=foo since_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.5-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_changelog name=foo until_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.1-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.4-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
+
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.3-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
+
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.2-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
+
+---
+
+git_cwd_name: test
+git_cwd_name name=foo: foo
+git_cwd_name name=foo append=foo-bar: foo-foo-bar
+git_cwd_name append=foo: test-foo
+git_cwd_name append=foo-bar: test-foo-bar
+
+git_cwd_version: 0.0.git.1.be51f06
+git_cwd_version name=foo: 0.0
+git_cwd_version lead=1: 1.0.git.1.be51f06
+git_cwd_version lead=0.1: 0.1.0.git.1.be51f06
+git_cwd_version follow=2: 0.2.git.1.be51f06
+git_cwd_version lead=1 follow=2: 1.2.git.1.be51f06
+git_cwd_version lead=x follow=x: x.x.git.1.be51f06
+git_cwd_version lead=1-1:  # invalid
+git_cwd_version follow=2.0:  # invalid
+git_cwd_version follow=2-2:  # invalid
+git_cwd_version name=:  # invalid
+
+git_cwd_version name="$(git_name)": 0.0.git.1.be51f06
+git_cwd_version echo 1.4: 1.4
+git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:foo
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: test-foo-bar-0.0.git.1.be51f06.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.1.be51f06.tar.gz
+git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.5-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.1-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.4-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
+
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.3-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
+
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.2-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
+
+---
+
+git_dir_name: test
+git_dir_name name=foo: foo
+git_dir_name name=foo append=foo-bar: foo-foo-bar
+git_dir_name append=foo: test-foo
+git_dir_name append=foo-bar: test-foo-bar
+
+git_dir_version: 0.0.git.1.be51f06
+git_dir_version name=foo: 0.0
+git_dir_version lead=1: 1.0.git.1.be51f06
+git_dir_version lead=0.1: 0.1.0.git.1.be51f06
+git_dir_version follow=2: 0.2.git.1.be51f06
+git_dir_version lead=1 follow=2: 1.2.git.1.be51f06
+git_dir_version lead=x follow=x: x.x.git.1.be51f06
+git_dir_version lead=1-1:  # invalid
+git_dir_version follow=2.0:  # invalid
+git_dir_version follow=2-2:  # invalid
+git_dir_version name=:  # invalid
+
+git_dir_version name="$(git_name)": 0.0.git.1.be51f06
+git_dir_version echo 1.4: 1.4
+git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_dir_version date --date='@2147483647' %y%m%d: 380119
+
+
+git_dir_vcs: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:foo
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: test-foo-bar-0.0.git.1.be51f06.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.1.be51f06.tar.gz
+git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.5-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.1-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
+- message that should be very long because we need to test git changelog family
+of macros and changelong body wrapping.
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.4-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
+
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.3-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
+
+* 2018 Thu Mar 15 clime <clime@redhat.com> 1.2-1
+- message that should be very long
+because we need to test git changelog
+family of macros and changelong body
+wrapping.
diff --git a/tests/preproc/test_tagged/run.sh b/tests/preproc/test_tagged/run.sh
new file mode 100755
index 0000000..d26e476
--- /dev/null
+++ b/tests/preproc/test_tagged/run.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+cp ../input $repo
+
+git init $repo
+git -C $repo remote add origin https://pagure.io/clime/test.git
+git -C $repo add -A
+git -C $repo commit -a -m 'inital_commit'
+git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.1-1
+git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.2-1
+git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.3-1
+git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.4-1
+git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.5-1
+
+touch output && cp output $output
+wtree_sub $repo $output
+head_commit_sub $repo $output
+
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_tagged_commited/log b/tests/preproc/test_tagged_commited/log
new file mode 100644
index 0000000..e78c556
--- /dev/null
+++ b/tests/preproc/test_tagged_commited/log
@@ -0,0 +1,308 @@
+> git_name
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+---
+> git_name append=foo-bar
+---
+> git_version
+---
+> git_version name=foo
+---
+> git_version lead=1
+---
+> git_version lead=0.1
+---
+> git_version follow=2
+---
+> git_version lead=1 follow=2
+---
+> git_version lead=x follow=x
+---
+> git_version lead=1-1
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: follow cannot contain dots.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_version name="$(git_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+---
+> git_vcs subtree=foo
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog name=foo since_tag=foo-1.2-1
+---
+> git_changelog name=foo until_tag=foo-1.2-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_cwd_name
+---
+> git_cwd_name name=foo
+---
+> git_cwd_name name=foo append=foo-bar
+---
+> git_cwd_name append=foo
+---
+> git_cwd_name append=foo-bar
+---
+> git_cwd_version
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version lead=1
+---
+> git_cwd_version lead=0.1
+---
+> git_cwd_version follow=2
+---
+> git_cwd_version lead=1 follow=2
+---
+> git_cwd_version lead=x follow=x
+---
+> git_cwd_version lead=1-1
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_cwd_vcs
+---
+> git_cwd_vcs subtree=foo
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_dir_name
+---
+> git_dir_name name=foo
+---
+> git_dir_name name=foo append=foo-bar
+---
+> git_dir_name append=foo
+---
+> git_dir_name append=foo-bar
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=2
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_version name="$(git_dir_name)"
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_dir_vcs
+---
+> git_dir_vcs subtree=foo
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_tagged_commited/output b/tests/preproc/test_tagged_commited/output
new file mode 100644
index 0000000..763716d
--- /dev/null
+++ b/tests/preproc/test_tagged_commited/output
@@ -0,0 +1,191 @@
+git_name: test
+git_name name=foo: foo
+git_name name=foo append=foo-bar: foo-foo-bar
+git_name append=foo: test-foo
+git_name append=foo-bar: test-foo-bar
+
+git_version: 0.0.git.2.4e08997
+git_version name=foo: 0.1.git.1.4e08997
+git_version lead=1: 1.0.git.2.4e08997
+git_version lead=0.1: 0.1.0.git.2.4e08997
+git_version follow=2: 0.2.git.2.4e08997
+git_version lead=1 follow=2: 1.2.git.2.4e08997
+git_version lead=x follow=x: x.x.git.2.4e08997
+git_version lead=1-1:  # invalid
+git_version follow=2.0:  # invalid
+git_version follow=2-2:  # invalid
+git_version name=:  # invalid
+
+git_version name="$(git_name)": 0.0.git.2.4e08997
+git_version echo 1.4: 1.4
+git_version echo -n 1; echo -n .; echo 4: 1.4
+git_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=2 latest_tag_version=1.4: 0.2
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=0.1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version latest_tag_version=0.1: 0.2
+git_bumped_version follow=2.0: 0.2.0 # invalid but works
+git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+
+git_vcs: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:foo
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: test-foo-bar-0.0.git.2.4e08997.tar.gz
+git_source_name name=foo: foo-0.0.git.2.4e08997.tar.gz
+git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog:
+
+
+git_changelog name=foo since_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 0.1-1
+- message.
+
+git_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_cwd_name: test
+git_cwd_name name=foo: foo
+git_cwd_name name=foo append=foo-bar: foo-foo-bar
+git_cwd_name append=foo: test-foo
+git_cwd_name append=foo-bar: test-foo-bar
+
+git_cwd_version: 0.0.git.2.4e08997
+git_cwd_version name=foo: 0.1.git.1.4e08997
+git_cwd_version lead=1: 1.0.git.2.4e08997
+git_cwd_version lead=0.1: 0.1.0.git.2.4e08997
+git_cwd_version follow=2: 0.2.git.2.4e08997
+git_cwd_version lead=1 follow=2: 1.2.git.2.4e08997
+git_cwd_version lead=x follow=x: x.x.git.2.4e08997
+git_cwd_version lead=1-1:  # invalid
+git_cwd_version follow=2.0:  # invalid
+git_cwd_version follow=2-2:  # invalid
+git_cwd_version name=:  # invalid
+
+git_cwd_version name="$(git_name)": 0.0.git.2.4e08997
+git_cwd_version echo 1.4: 1.4
+git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:foo
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: test-foo-bar-0.0.git.2.4e08997.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.2.4e08997.tar.gz
+git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 0.1-1
+- message.
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_dir_name: test
+git_dir_name name=foo: foo
+git_dir_name name=foo append=foo-bar: foo-foo-bar
+git_dir_name append=foo: test-foo
+git_dir_name append=foo-bar: test-foo-bar
+
+git_dir_version: 0.0.git.2.4e08997
+git_dir_version name=foo: 0.1.git.1.4e08997
+git_dir_version lead=1: 1.0.git.2.4e08997
+git_dir_version lead=0.1: 0.1.0.git.2.4e08997
+git_dir_version follow=2: 0.2.git.2.4e08997
+git_dir_version lead=1 follow=2: 1.2.git.2.4e08997
+git_dir_version lead=x follow=x: x.x.git.2.4e08997
+git_dir_version lead=1-1:  # invalid
+git_dir_version follow=2.0:  # invalid
+git_dir_version follow=2-2:  # invalid
+git_dir_version name=:  # invalid
+
+git_dir_version name="$(git_name)": 0.0.git.2.4e08997
+git_dir_version echo 1.4: 1.4
+git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_dir_version date --date='@2147483647' %y%m%d: 380119
+
+
+git_dir_vcs: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:foo
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: test-foo-bar-0.0.git.2.4e08997.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.2.4e08997.tar.gz
+git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+* Thu Mar 15 2018 clime <clime@redhat.com> 0.1-1
+- message.
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
diff --git a/tests/preproc/test_tagged_commited/run.sh b/tests/preproc/test_tagged_commited/run.sh
new file mode 100755
index 0000000..e9e56c1
--- /dev/null
+++ b/tests/preproc/test_tagged_commited/run.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+cp ../input $repo
+
+git init $repo
+git -C $repo remote add origin https://pagure.io/clime/test.git
+git -C $repo add -A
+git -C $repo commit -a -m 'inital_commit'
+git -C $repo tag -a -m 'subject' -m '- message.' foo-0.1-1
+touch $repo/foo
+git -C $repo add foo
+git -C $repo commit -m 'commit after tag'
+
+touch output && cp output $output
+wtree_sub $repo $output
+head_commit_sub $repo $output
+
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_uninited/log b/tests/preproc/test_uninited/log
new file mode 100644
index 0000000..c1effec
--- /dev/null
+++ b/tests/preproc/test_uninited/log
@@ -0,0 +1,469 @@
+> git_name
+git_name: Start by setting origin URL.
+git_name failed with value 1
+---
+> git_name name=foo
+---
+> git_name name=foo append=foo-bar
+---
+> git_name append=foo
+git_name: Start by setting origin URL.
+git_name append=foo failed with value 1
+---
+> git_name append=foo-bar
+git_name: Start by setting origin URL.
+git_name append=foo-bar failed with value 1
+---
+> git_version
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_version name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_version lead=1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_version lead=0.1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_version follow=2
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_version lead=1 follow=2
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_version lead=x follow=x
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_version lead=1-1
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 failed with value 1
+---
+> git_version follow=2.0
+git_version: follow cannot contain dots.
+git_version follow=2.0 failed with value 1
+---
+> git_version follow=2-2
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 failed with value 1
+---
+> git_version name=
+git_version: name cannot be empty.
+git_version name= failed with value 1
+---
+> git_version name="$(git_name)"
+git_name: Start by setting origin URL.
+git_version: name cannot be empty.
+git_version name="$(git_name)" failed with value 1
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=2 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=0.1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version latest_tag_version=0.1
+---
+> git_bumped_version follow=2.0
+---
+> git_bumped_version latest_tag_version=1-2
+---
+> git_vcs
+git_vcs: Start by setting origin URL.
+git_vcs failed with value 1
+---
+> git_vcs subtree=foo
+git_vcs: Start by setting origin URL.
+git_vcs subtree=foo failed with value 1
+---
+> git_pack
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog
+---
+> git_changelog name=foo since_tag=foo-1.2-1
+---
+> git_changelog name=foo until_tag=foo-1.2-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_cwd_name
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_name: Start by setting origin URL.
+git_cwd_name failed with value 1
+---
+> git_cwd_name name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_name name=foo append=foo-bar
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_name append=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_name: Start by setting origin URL.
+git_cwd_name append=foo failed with value 1
+---
+> git_cwd_name append=foo-bar
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_name: Start by setting origin URL.
+git_cwd_name append=foo-bar failed with value 1
+---
+> git_cwd_version
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_version name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_version lead=1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_version lead=0.1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_version follow=2
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_version lead=1 follow=2
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_version lead=x follow=x
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_cwd_version lead=1-1
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 failed with value 1
+---
+> git_cwd_version follow=2.0
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 failed with value 1
+---
+> git_cwd_version follow=2-2
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 failed with value 1
+---
+> git_cwd_version name=
+git_cwd_version: name cannot be empty.
+git_cwd_version name= failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_name: Start by setting origin URL.
+git_cwd_version: name cannot be empty.
+git_cwd_version name="$(git_cwd_name)" failed with value 1
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_cwd_vcs
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_vcs: Start by setting origin URL.
+git_cwd_vcs failed with value 1
+---
+> git_cwd_vcs subtree=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_vcs: Start by setting origin URL.
+git_cwd_vcs subtree=foo failed with value 1
+---
+> git_cwd_pack
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
+> git_dir_name
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_name failed with value 1
+---
+> git_dir_name name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_name name=foo append=foo-bar
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_name append=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_name append=foo failed with value 1
+---
+> git_dir_name append=foo-bar
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_name append=foo-bar failed with value 1
+---
+> git_dir_version
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_version name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_version lead=1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_version lead=0.1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_version follow=2
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_version lead=1 follow=2
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_version lead=x follow=x
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_dir_version lead=1-1
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 failed with value 1
+---
+> git_dir_version follow=2.0
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 failed with value 1
+---
+> git_dir_version follow=2-2
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 failed with value 1
+---
+> git_dir_version name=
+git_dir_version: name cannot be empty.
+git_dir_version name= failed with value 1
+---
+> git_dir_version name="$(git_dir_name)"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_version: name cannot be empty.
+git_dir_version name="$(git_dir_name)" failed with value 1
+---
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
+> git_dir_vcs
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs failed with value 1
+---
+> git_dir_vcs subtree=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs subtree=foo failed with value 1
+---
+> git_dir_pack
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
diff --git a/tests/preproc/test_uninited/log_git b/tests/preproc/test_uninited/log_git
deleted file mode 100644
index 5ef8e20..0000000
--- a/tests/preproc/test_uninited/log_git
+++ /dev/null
@@ -1,2 +0,0 @@
-git_name: Start by setting origin URL.
-git_name failed with value 1
diff --git a/tests/preproc/test_uninited/log_git_cwd b/tests/preproc/test_uninited/log_git_cwd
deleted file mode 100644
index 2f669a0..0000000
--- a/tests/preproc/test_uninited/log_git_cwd
+++ /dev/null
@@ -1,4 +0,0 @@
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_name: Start by setting origin URL.
-git_cwd_name failed with value 1
diff --git a/tests/preproc/test_uninited/log_git_dir b/tests/preproc/test_uninited/log_git_dir
deleted file mode 100644
index 8420d25..0000000
--- a/tests/preproc/test_uninited/log_git_dir
+++ /dev/null
@@ -1,4 +0,0 @@
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_name: Start by setting origin URL.
-git_dir_name failed with value 1
diff --git a/tests/preproc/test_uninited/output b/tests/preproc/test_uninited/output
new file mode 100644
index 0000000..d64fe60
--- /dev/null
+++ b/tests/preproc/test_uninited/output
@@ -0,0 +1,188 @@
+git_name: 
+git_name name=foo: foo
+git_name name=foo append=foo-bar: foo-foo-bar
+git_name append=foo: 
+git_name append=foo-bar: 
+
+git_version: 0.0
+git_version name=foo: 0.0
+git_version lead=1: 1.0
+git_version lead=0.1: 0.1.0
+git_version follow=2: 0.2
+git_version lead=1 follow=2: 1.2
+git_version lead=x follow=x: x.x
+git_version lead=1-1:  # invalid
+git_version follow=2.0:  # invalid
+git_version follow=2-2:  # invalid
+git_version name=:  # invalid
+
+git_version name="$(git_name)": 
+git_version echo 1.4: 1.4
+git_version echo -n 1; echo -n .; echo 4: 1.4
+git_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=2 latest_tag_version=1.4: 0.2
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=0.1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version latest_tag_version=0.1: 0.2
+git_bumped_version follow=2.0: 0.2.0 # invalid but works
+git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+
+git_vcs: 
+git_vcs subtree=foo: 
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: foo-foo-bar-x.x.tar.gz
+git_source_name name=foo: foo-x.x.tar.gz
+git_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog:
+
+
+git_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_cwd_name: 
+git_cwd_name name=foo: foo
+git_cwd_name name=foo append=foo-bar: foo-foo-bar
+git_cwd_name append=foo: 
+git_cwd_name append=foo-bar: 
+
+git_cwd_version: 0.0
+git_cwd_version name=foo: 0.0
+git_cwd_version lead=1: 1.0
+git_cwd_version lead=0.1: 0.1.0
+git_cwd_version follow=2: 0.2
+git_cwd_version lead=1 follow=2: 1.2
+git_cwd_version lead=x follow=x: x.x
+git_cwd_version lead=1-1:  # invalid
+git_cwd_version follow=2.0:  # invalid
+git_cwd_version follow=2-2:  # invalid
+git_cwd_version name=:  # invalid
+
+git_cwd_version name="$(git_name)": 
+git_cwd_version echo 1.4: 1.4
+git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+
+
+git_cwd_vcs: 
+git_cwd_vcs subtree=foo: 
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: foo-foo-bar-x.x.tar.gz
+git_cwd_source_name name=foo: foo-x.x.tar.gz
+git_cwd_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
+---
+
+git_dir_name: 
+git_dir_name name=foo: foo
+git_dir_name name=foo append=foo-bar: foo-foo-bar
+git_dir_name append=foo: 
+git_dir_name append=foo-bar: 
+
+git_dir_version: 0.0
+git_dir_version name=foo: 0.0
+git_dir_version lead=1: 1.0
+git_dir_version lead=0.1: 0.1.0
+git_dir_version follow=2: 0.2
+git_dir_version lead=1 follow=2: 1.2
+git_dir_version lead=x follow=x: x.x
+git_dir_version lead=1-1:  # invalid
+git_dir_version follow=2.0:  # invalid
+git_dir_version follow=2-2:  # invalid
+git_dir_version name=:  # invalid
+
+git_dir_version name="$(git_name)": 
+git_dir_version echo 1.4: 1.4
+git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
+git_dir_version date --date='@2147483647' %y%m%d: 380119
+
+
+git_dir_vcs: 
+git_dir_vcs subtree=foo: 
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: foo-foo-bar-x.x.tar.gz
+git_dir_source_name name=foo: foo-x.x.tar.gz
+git_dir_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
diff --git a/tests/preproc/test_uninited/run.sh b/tests/preproc/test_uninited/run.sh
index 0970118..68a4fec 100755
--- a/tests/preproc/test_uninited/run.sh
+++ b/tests/preproc/test_uninited/run.sh
@@ -1,16 +1,15 @@
-#!/bin/bash -x
+#!/bin/bash
 
 . ../lib.sh
 
-REPO=`mktemp -d`
+repo=`mktemp -d`
+output=`mktemp`
 
-../run_preproc.py --path $REPO --input ../input_git --output $REPO/output_git --dump-spec-only --break-on-error > $REPO/log_git
-../run_preproc.py --path $REPO --input ../input_git_dir --output $REPO/output_git_dir --dump-spec-only --break-on-error > $REPO/log_git_dir
-../run_preproc.py --path $REPO --input ../input_git_cwd --output $REPO/output_git_cwd --dump-spec-only --break-on-error > $REPO/log_git_cwd
+cp ../input $repo
 
-diff log_git $REPO/log_git || die
-diff log_git_dir $REPO/log_git_dir || die
-diff log_git_cwd $REPO/log_git_cwd || die
+touch output && cp output $output
 
-rm -r $REPO
-echo success.
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output

From fa486d367fe18989c5f4b66608078975d65cf2c6 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 82/104] 1 unittest and bugfix


---

diff --git a/rpkglib/utils.py b/rpkglib/utils.py
index 73ed98f..2ddc917 100644
--- a/rpkglib/utils.py
+++ b/rpkglib/utils.py
@@ -52,7 +52,7 @@ def find_source_zero(rpm_sources):
 
 def get_changelog_entry(commit_message):
     entry = '- ' + commit_message.split('\n')[0] if commit_message else ''
-    return '\n'.join(textwrap.wrap(re.sub('r(\s+)%([^%])', r'\1%%\2', entry), 80))
+    return '\n'.join(textwrap.wrap(re.sub(r'(\s+)%([^%])', r'\1%%\2', entry), 80))
 
 
 def run_command(cmd, shell=False, env=None, cwd=None):
diff --git a/tests/test_utils.py b/tests/test_utils.py
new file mode 100644
index 0000000..93fb5fd
--- /dev/null
+++ b/tests/test_utils.py
@@ -0,0 +1,30 @@
+import unittest
+import six
+
+import base
+from rpkglib import utils
+
+if six.PY3:
+    from unittest import mock
+    from unittest.mock import MagicMock
+else:
+    import mock
+    from mock import MagicMock
+
+class TestCommands(base.TestCase):
+    def setUp(self):
+        super(TestCommands, self).setUp()
+
+    def tearDown(self):
+        super(TestCommands, self).tearDown()
+
+    def test_get_changelog_entry(self):
+        commit_message = 'first line %changelog\nsecond_line'
+        changelog_entry = utils.get_changelog_entry(commit_message)
+        assert changelog_entry == '- first line %%changelog'
+
+        commit_message = 'first line %changelog'*10
+        changelog_entry = utils.get_changelog_entry(commit_message)
+        split_lines = changelog_entry.split()
+        for line in split_lines:
+            assert len(line) <= 80

From 6c8838d759385e5280f646bc9bb6b63dbea46ff4 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 83/104] add append param to git_name, apend and prepend exactly what user tell you to


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 988474a..6d0eab4 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -79,16 +79,10 @@ function log {
 ############## REPO FUNCTIONS ##############
 
 function git_name {
-    declare name= append= "$@"
-
-    if [ -n "$append" ]; then
-        appendix="-$append"
-    else
-        appendix=
-    fi
+    declare name= prepend= append= "$@"
 
     if [ -n "$name" ]; then
-        output "${name}${appendix}"
+        output "${prepend}${name}${append}"
         return
     fi
 
@@ -102,7 +96,7 @@ function git_name {
     url_last_part="$(basename "$url")"
     name="${url_last_part%.git}"
 
-    output "${name}${appendix}"
+    output "${prepend}${name}${append}"
 }
 
 function git_bumped_version {
@@ -115,7 +109,7 @@ function git_bumped_version {
 
     follow="$(echo "$latest_tag_version" | sed -E -n "s/^$lead\.([^.]*)$/\1/p")"
 
-    if [ -z "$follow" ] && [ $lead -ne 0 ]; then
+    if [ -z "$follow" ] && [ "$lead" -ne 0 ]; then
         echo -n "$lead.0"
         return
     fi
@@ -329,7 +323,7 @@ function git_changelog {
 ############## DIR FUNCTIONS ##############
 
 function git_dir_name {
-    git_name append="$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix | name_convert)" "$@"
+    git_name append="-$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix | name_convert)" "$@"
 }
 
 function git_dir_version {
@@ -363,7 +357,7 @@ function git_dir_changelog {
 ############## CURRENT WORKING DIR FUNCTIONS ##############
 
 function git_cwd_name {
-    git_name append="$(git -C "$(pwd)" rev-parse --show-prefix | name_convert)" "$@"
+    git_name append="-$(git -C "$(pwd)" rev-parse --show-prefix | name_convert)" "$@"
 }
 
 function git_cwd_version {

From b8c2667a76e94df8ed9cc76fb744a220bed05b47 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 84/104] test input update, prepare_input added into tests, fix for changelog date changing


---

diff --git a/tests/preproc/README b/tests/preproc/README
new file mode 100644
index 0000000..50ac882
--- /dev/null
+++ b/tests/preproc/README
@@ -0,0 +1,23 @@
+To run all the tests:
+$ run.sh
+
+To regenereate expected output and log for all tests:
+$ run.sh copy
+
+To run a particular test:
+$ cd test_<name> && run.sh
+
+To regenerate expected output and log for a particular test:
+$ cd test_<name> && run.sh copy
+
+Regenerating expected output and log is particularly useful
+when you update a test - either by updating its input or by
+updating its run.sh script. You should check that the log and
+output file you get really contain something which is expected.
+
+For instructions how to write a new test, just see run.sh
+script in any of the test_* subdirs. They mostly make use
+of generic_test function defined in ./lib.sh.
+
+./input file in this directory defines a basic set of macro
+invocations.
diff --git a/tests/preproc/input b/tests/preproc/input
index 7700322..c07e8df 100644
--- a/tests/preproc/input
+++ b/tests/preproc/input
@@ -1,185 +1,141 @@
-git_name: {{{ git_name }}}
-git_name name=foo: {{{ git_name name=foo }}}
-git_name name=foo append=foo-bar: {{{ git_name name=foo append=foo-bar }}}
-git_name append=foo: {{{ git_name append=foo }}}
-git_name append=foo-bar: {{{ git_name append=foo-bar }}}
-
-git_version: {{{ git_version }}}
-git_version name=foo: {{{ git_version name=foo }}}
-git_version lead=1: {{{ git_version lead=1 }}}
-git_version lead=0.1: {{{ git_version lead=0.1 }}}
-git_version follow=2: {{{ git_version follow=2 }}}
-git_version lead=1 follow=2: {{{ git_version lead=1 follow=2 }}}
-git_version lead=x follow=x: {{{ git_version lead=x follow=x }}}
-git_version lead=1-1: {{{ git_version lead=1-1 }}} # invalid
-git_version follow=2.0: {{{ git_version follow=2.0 }}} # invalid
-git_version follow=2-2: {{{ git_version follow=2-2 }}} # invalid
-git_version name=: {{{ git_version name= }}} # invalid
-
-git_version name="$(git_name)": {{{ git_version name="$(git_name)" }}}
-git_version echo 1.4: {{{ echo -n 1.4 }}}
-git_version echo -n 1; echo -n .; echo 4: {{{ echo -n 1; echo -n .; echo -n 4 }}}
-git_version date --date='@2147483647' +%y%m%d: {{{ date --date='@2147483647' +%y%m%d }}}
-
-git_bumped_version: {{{ git_bumped_version }}}
-git_bumped_version lead=1: {{{ git_bumped_version lead=1 }}}
-git_bumped_version follow=2: {{{ git_bumped_version follow=2 }}}
-git_bumped_version lead=1 follow=2: {{{ git_bumped_version lead=1 follow=2 }}}
-git_bumped_version lead=1 latest_tag_version=1.2: {{{ git_bumped_version lead=1 latest_tag_version=1.2 }}}
-git_bumped_version follow=2 latest_tag_version=1.4: {{{ git_bumped_version follow=2 latest_tag_version=1.4 }}}
-git_bumped_version latest_tag_version=1.2: {{{ git_bumped_version latest_tag_version=1.2 }}}
-git_bumped_version latest_tag_version=0.1.2: {{{ git_bumped_version latest_tag_version=0.1.2 }}}
-git_bumped_version latest_tag_version=1.x: {{{ git_bumped_version latest_tag_version=1.x }}}
-git_bumped_version latest_tag_version=0.1.x: {{{ git_bumped_version latest_tag_version=0.1.x }}}
-git_bumped_version latest_tag_version=0.1: {{{ git_bumped_version latest_tag_version=0.1 }}}
-git_bumped_version follow=2.0: {{{ git_bumped_version follow=2.0 }}} # invalid but works
-git_bumped_version latest_tag_version=1-2: {{{ git_bumped_version latest_tag_version=1-2 }}} # invalid but works
-
-git_vcs: {{{ git_vcs }}}
-git_vcs subtree=foo: {{{ git_vcs subtree=foo }}}
-
-git_pack: {{{ git_pack }}}
-git_pack dir_name=foo: {{{ git_pack dir_name=foo }}}
-git_pack dir_name=foo source_name=foo.tar.gz: {{{ git_pack dir_name=foo source_name=foo.tar.gz }}}
-git_pack path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-git_archive: {{{ git_archive }}}
-git_archive dir_name=foo: {{{ git_archive dir_name=foo }}}
-git_archive dir_name=foo source_name=foo.tar.gz: {{{ git_archive dir_name=foo source_name=foo.tar.gz }}}
-git_archive path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-git_source_name: {{{ git_source_name }}}
-git_source_name name=foo: {{{ git_source_name name=foo }}}
-git_source_name version=1.2: {{{ git_source_name version=1.2 }}}
-git_source_name name=foo version=1.2 format=tar: {{{ git_source_name name=foo version=1.2 format=tar }}}
-
-git_changelog:
-{{{ git_changelog }}}
-
-git_changelog name=foo since_tag=foo-1.2-1:
-{{{ git_changelog name=foo since_tag=foo-1.2-1 }}}
-
-git_changelog name=foo until_tag=foo-1.2-1:
-{{{ git_changelog name=foo until_tag=foo-1.2-1 }}}
-
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-{{{ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 }}}
-
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-{{{ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
-
----
-
-git_cwd_name: {{{ git_cwd_name }}}
-git_cwd_name name=foo: {{{ git_cwd_name name=foo }}}
-git_cwd_name name=foo append=foo-bar: {{{ git_cwd_name name=foo append=foo-bar }}}
-git_cwd_name append=foo: {{{ git_cwd_name append=foo }}}
-git_cwd_name append=foo-bar: {{{ git_cwd_name append=foo-bar }}}
-
-git_cwd_version: {{{ git_cwd_version }}}
-git_cwd_version name=foo: {{{ git_cwd_version name=foo }}}
-git_cwd_version lead=1: {{{ git_cwd_version lead=1 }}}
-git_cwd_version lead=0.1: {{{ git_cwd_version lead=0.1 }}}
-git_cwd_version follow=2: {{{ git_cwd_version follow=2 }}}
-git_cwd_version lead=1 follow=2: {{{ git_cwd_version lead=1 follow=2 }}}
-git_cwd_version lead=x follow=x: {{{ git_cwd_version lead=x follow=x }}}
-git_cwd_version lead=1-1: {{{ git_cwd_version lead=1-1 }}} # invalid
-git_cwd_version follow=2.0: {{{ git_cwd_version follow=2.0 }}} # invalid
-git_cwd_version follow=2-2: {{{ git_cwd_version follow=2-2 }}} # invalid
-git_cwd_version name=: {{{ git_cwd_version name= }}} # invalid
-
-git_cwd_version name="$(git_name)": {{{ git_cwd_version name="$(git_cwd_name)" }}}
-git_cwd_version echo 1.4: {{{ echo -n 1.4 }}}
-git_cwd_version echo -n 1; echo -n .; echo -n 4: {{{ echo -n 1; echo -n .; echo -n 4 }}}
-git_cwd_version date --date='@2147483647' +%y%m%d: {{{ date --date='@2147483647' +%y%m%d }}}
-
-git_cwd_vcs: {{{ git_cwd_vcs }}}
-git_cwd_vcs subtree=foo: {{{ git_cwd_vcs subtree=foo }}}
-
-git_cwd_pack: {{{ git_cwd_pack }}}
-git_cwd_pack dir_name=foo: {{{ git_cwd_pack dir_name=foo }}}
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: {{{ git_cwd_pack dir_name=foo source_name=foo.tar.gz }}}
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-git_cwd_archive: {{{ git_cwd_archive }}}
-git_cwd_archive dir_name=foo: {{{ git_cwd_archive dir_name=foo }}}
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: {{{ git_cwd_archive dir_name=foo source_name=foo.tar.gz }}}
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-git_cwd_source_name: {{{ git_cwd_source_name }}}
-git_cwd_source_name name=foo: {{{ git_cwd_source_name name=foo }}}
-git_cwd_source_name version=1.2: {{{ git_cwd_source_name version=1.2 }}}
-git_cwd_source_name name=foo version=1.2 format=tar: {{{ git_cwd_source_name name=foo version=1.2 format=tar }}}
-
-git_cwd_changelog:
-{{{ git_cwd_changelog }}}
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
-{{{ git_cwd_changelog name=foo since_tag=foo-1.2-1 }}}
-
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
-{{{ git_cwd_changelog name=foo until_tag=foo-1.2-1 }}}
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-{{{ git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 }}}
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-{{{ git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
-
----
-
-git_dir_name: {{{ git_dir_name }}}
-git_dir_name name=foo: {{{ git_dir_name name=foo }}}
-git_dir_name name=foo append=foo-bar: {{{ git_dir_name name=foo append=foo-bar }}}
-git_dir_name append=foo: {{{ git_dir_name append=foo }}}
-git_dir_name append=foo-bar: {{{ git_dir_name append=foo-bar }}}
-
-git_dir_version: {{{ git_dir_version }}}
-git_dir_version name=foo: {{{ git_dir_version name=foo }}}
-git_dir_version lead=1: {{{ git_dir_version lead=1 }}}
-git_dir_version lead=0.1: {{{ git_dir_version lead=0.1 }}}
-git_dir_version follow=2: {{{ git_dir_version follow=2 }}}
-git_dir_version lead=1 follow=2: {{{ git_dir_version lead=1 follow=2 }}}
-git_dir_version lead=x follow=x: {{{ git_dir_version lead=x follow=x }}}
-git_dir_version lead=1-1: {{{ git_dir_version lead=1-1 }}} # invalid
-git_dir_version follow=2.0: {{{ git_dir_version follow=2.0 }}} # invalid
-git_dir_version follow=2-2: {{{ git_dir_version follow=2-2 }}} # invalid
-git_dir_version name=: {{{ git_dir_version name= }}} # invalid
-
-git_dir_version name="$(git_name)": {{{ git_dir_version name="$(git_dir_name)" }}}
-git_dir_version echo 1.4: {{{ echo -n 1.4 }}}
-git_dir_version echo -n 1; echo -n .; echo -n 4: {{{ echo -n 1; echo -n .; echo -n 4 }}}
-git_dir_version date --date='@2147483647' %y%m%d: {{{ date --date='@2147483647' +%y%m%d }}}
-
-git_dir_vcs: {{{ git_dir_vcs }}}
-git_dir_vcs subtree=foo: {{{ git_dir_vcs subtree=foo }}}
-
-git_dir_pack: {{{ git_dir_pack }}}
-git_dir_pack dir_name=foo: {{{ git_dir_pack dir_name=foo }}}
-git_dir_pack dir_name=foo source_name=foo.tar.gz: {{{ git_dir_pack dir_name=foo source_name=foo.tar.gz }}}
-git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-git_dir_archive: {{{ git_dir_archive }}}
-git_dir_archive dir_name=foo: {{{ git_dir_archive dir_name=foo }}}
-git_dir_archive dir_name=foo source_name=foo.tar.gz: {{{ git_dir_archive dir_name=foo source_name=foo.tar.gz }}}
-git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: {{{ git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz }}}
-
-git_dir_source_name: {{{ git_dir_source_name }}}
-git_dir_source_name name=foo: {{{ git_dir_source_name name=foo }}}
-git_dir_source_name version=1.2: {{{ git_dir_source_name version=1.2 }}}
-git_dir_source_name name=foo version=1.2 format=tar: {{{ git_dir_source_name name=foo version=1.2 format=tar }}}
-
-git_dir_changelog:
-{{{ git_dir_changelog }}}
-
-git_dir_changelog name=foo since_tag=foo-1.2-1:
-{{{ git_dir_changelog name=foo since_tag=foo-1.2-1 }}}
-
-git_dir_changelog name=foo until_tag=foo-1.2-1:
-{{{ git_dir_changelog name=foo until_tag=foo-1.2-1 }}}
-
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-{{{ git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 }}}
-
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-{{{ git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 }}}
+git_name
+git_name name=foo
+git_name append=-baz
+git_name prepend=bar-
+git_name prepend=bar- append=-baz
+git_name name=foo prepend=bar- append=-baz
+
+git_version
+git_version name=foo
+git_version name=foo lead=1
+git_version lead=0
+git_version lead=1
+git_version lead=0.1
+git_version follow=1
+git_version lead=1 follow=2
+git_version lead=x follow=x
+git_version lead=1-1 # invalid
+git_version follow=2.0 # invalid
+git_version follow=2-2 # invalid
+git_version name= # invalid
+git_version name="$(git_name)"
+
+git_vcs
+git_vcs subtree=foo
+
+git_pack
+git_pack dir_name=foo
+git_pack dir_name=foo source_name=foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz
+
+git_archive
+git_archive dir_name=foo
+git_archive dir_name=foo source_name=foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz
+
+git_source_name
+git_source_name name=foo
+git_source_name version=1.2
+git_source_name name=foo version=1.2 format=tar
+
+git_changelog ::
+git_changelog name=foo since_tag=foo-1.2-1 ::
+git_changelog name=foo until_tag=foo-1.2-1 ::
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 ::
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 ::
+
+:::::::::::::::::::::
+
+git_dir_name
+git_dir_name name=foo
+git_dir_name append=-baz
+git_dir_name prepend=bar-
+git_dir_name prepend=bar- append=-baz
+git_dir_name name=foo prepend=bar- append=-baz
+
+git_dir_version
+git_dir_version name=foo
+git_dir_version name=foo lead=1
+git_dir_version lead=0
+git_dir_version lead=1
+git_dir_version lead=0.1
+git_dir_version follow=1
+git_dir_version lead=1 follow=2
+git_dir_version lead=x follow=x
+git_dir_version lead=1-1 # invalid
+git_dir_version follow=2.0 # invalid
+git_dir_version follow=2-2 # invalid
+git_dir_version name= # invalid
+git_dir_version name="$(git_name)"
+
+git_dir_vcs
+git_dir_vcs subtree=foo
+
+git_dir_pack
+git_dir_pack dir_name=foo
+git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+
+git_dir_archive
+git_dir_archive dir_name=foo
+git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+
+git_dir_source_name
+git_dir_source_name name=foo
+git_dir_source_name version=1.2
+git_dir_source_name name=foo version=1.2 format=tar
+
+git_dir_changelog ::
+git_dir_changelog name=foo since_tag=foo-1.2-1 ::
+git_dir_changelog name=foo until_tag=foo-1.2-1 ::
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 ::
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 ::
+
+:::::::::::::::::::::
+
+git_cwd_name
+git_cwd_name name=foo
+git_cwd_name append=-baz
+git_cwd_name prepend=bar-
+git_cwd_name prepend=bar- append=-baz
+git_cwd_name name=foo prepend=bar- append=-baz
+
+git_cwd_version
+git_cwd_version name=foo
+git_cwd_version name=foo lead=1
+git_cwd_version lead=0
+git_cwd_version lead=1
+git_cwd_version lead=0.1
+git_cwd_version follow=1
+git_cwd_version lead=1 follow=2
+git_cwd_version lead=x follow=x
+git_cwd_version lead=1-1 # invalid
+git_cwd_version follow=2.0 # invalid
+git_cwd_version follow=2-2 # invalid
+git_cwd_version name= # invalid
+git_cwd_version name="$(git_cwd_name)"
+
+git_cwd_vcs
+git_cwd_vcs subtree=foo
+
+git_cwd_pack
+git_cwd_pack dir_name=foo
+git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+
+git_cwd_archive
+git_cwd_archive dir_name=foo
+git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+
+git_cwd_source_name
+git_cwd_source_name name=foo
+git_cwd_source_name version=1.2
+git_cwd_source_name name=foo version=1.2 format=tar
+
+git_cwd_changelog ::
+git_cwd_changelog name=foo since_tag=foo-1.2-1 ::
+git_cwd_changelog name=foo until_tag=foo-1.2-1 ::
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 ::
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 ::
diff --git a/tests/preproc/lib.sh b/tests/preproc/lib.sh
index 5d1b3d6..20b7d1d 100644
--- a/tests/preproc/lib.sh
+++ b/tests/preproc/lib.sh
@@ -1,4 +1,4 @@
-export libdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+export libdir="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 
 . $libdir/../../rpkglib/preproc/lib.sh
   
@@ -8,7 +8,7 @@ function die {
 }
 
 function log_filter {
-    grep -Ev -e '^> (env|cwd):' -e '^git_pack: Wrote:'
+    grep -Ev -e '^> (env|cwd):' -e '^git_pack: Wrote: /tmp/'
 }
 
 function run {
@@ -27,29 +27,28 @@ function head_commit_sub {
     sed -Ei -e "s|(\.git\.[0-9]+)\.[a-zA-Z0-9]+|\1.$short_hash|" -e "s|#\w{40}:|#$full_hash:|" "$2"
 }
 
+function prepare_input {
+    cat "$1" | sed -Ee 's|^(.+) ::$|\1:\n{{{ \1 }}}\n|' | sed -Ee 's|^(.+) :$|\1:\n{{{ \1 }}}|' | sed -Ee 's|^(.*[^:}])$|\1: {{{ \1 }}}|' > "$2"
+}
+
 function generic_test {
-    declare opts= path= input= expected_output= expected_log= expected_sources= copy_only= "$@"
+    declare opts= path= input= expected_output= expected_log= custom_test= copy_only= "$@"
+
     local out="$(mktemp -d)"
 
     run "../preproc.py --path $path --input $input --output $out/output $opts | log_filter &> $out/log"
 
     if [ -n "$copy_only" ]; then
-        cp $out/log $out/output .
+        cp "$out/log" "$out/output" .
         echo copied.
-        rm -r $out
+        rm -r "$out"
         exit
     fi
 
     run "diff $expected_output $out/output || die"
     run "diff $expected_log $out/log || die"
+    run "$custom_test out=$out || die"
 
-    for source_name in $expected_sources; do
-        echo "Checking for presence of source $source_name."
-        if ! [ -f "$out/$source_name" ]; then
-            die
-        fi
-    done
-
-    rm -r $out
+    rm -r "$out"
     echo success.
 }
diff --git a/tests/preproc/run.sh b/tests/preproc/run.sh
index 8d5d743..e44dfdd 100755
--- a/tests/preproc/run.sh
+++ b/tests/preproc/run.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-export scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+export scriptdir="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 
 for dir in `ls -d $scriptdir/test_*/`; do
     echo "====================== $(basename ${dir}) ======================"
diff --git a/tests/preproc/test_bash/input b/tests/preproc/test_bash/input
new file mode 100644
index 0000000..2a126a1
--- /dev/null
+++ b/tests/preproc/test_bash/input
@@ -0,0 +1,3 @@
+echo -n 1.4
+echo -n 1; echo -n .; echo -n 4
+date --date='@2147483647' +%y%m%d
diff --git a/tests/preproc/test_bash/log b/tests/preproc/test_bash/log
new file mode 100644
index 0000000..fc11600
--- /dev/null
+++ b/tests/preproc/test_bash/log
@@ -0,0 +1,6 @@
+> echo -n 1.4
+---
+> echo -n 1; echo -n .; echo -n 4
+---
+> date --date='@2147483647' +%y%m%d
+---
diff --git a/tests/preproc/test_bash/output b/tests/preproc/test_bash/output
new file mode 100644
index 0000000..cf7a3d9
--- /dev/null
+++ b/tests/preproc/test_bash/output
@@ -0,0 +1,4 @@
+echo -n 1.4: 1.4
+echo -n 1; echo -n .; echo -n 4: 1.4
+date --date='@2147483647' +%y%m%d: 380119
+
diff --git a/tests/preproc/test_bash/run.sh b/tests/preproc/test_bash/run.sh
new file mode 100755
index 0000000..dea88ea
--- /dev/null
+++ b/tests/preproc/test_bash/run.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+prepare_input input $repo/input
+git init $repo
+
+touch output && cp output $output
+wtree_sub $repo $output
+
+generic_test opts='' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_bumped_version/input b/tests/preproc/test_bumped_version/input
new file mode 100644
index 0000000..4e74372
--- /dev/null
+++ b/tests/preproc/test_bumped_version/input
@@ -0,0 +1,11 @@
+git_bumped_version
+git_bumped_version lead=1
+git_bumped_version follow=2
+git_bumped_version lead=1 follow=2
+git_bumped_version lead=1 latest_tag_version=1.2
+git_bumped_version follow=1 latest_tag_version=1.4
+git_bumped_version latest_tag_version=1.2
+git_bumped_version latest_tag_version=1.x
+git_bumped_version latest_tag_version=0.1.x
+git_bumped_version follow=2.0 # invalid but allowed here
+git_bumped_version latest_tag_version=1-2 # invalid but allowed here
diff --git a/tests/preproc/test_bumped_version/log b/tests/preproc/test_bumped_version/log
new file mode 100644
index 0000000..28391b6
--- /dev/null
+++ b/tests/preproc/test_bumped_version/log
@@ -0,0 +1,22 @@
+> git_bumped_version
+---
+> git_bumped_version lead=1
+---
+> git_bumped_version follow=2
+---
+> git_bumped_version lead=1 follow=2
+---
+> git_bumped_version lead=1 latest_tag_version=1.2
+---
+> git_bumped_version follow=1 latest_tag_version=1.4
+---
+> git_bumped_version latest_tag_version=1.2
+---
+> git_bumped_version latest_tag_version=1.x
+---
+> git_bumped_version latest_tag_version=0.1.x
+---
+> git_bumped_version follow=2.0 # invalid but allowed here
+---
+> git_bumped_version latest_tag_version=1-2 # invalid but allowed here
+---
diff --git a/tests/preproc/test_bumped_version/output b/tests/preproc/test_bumped_version/output
new file mode 100644
index 0000000..17776b7
--- /dev/null
+++ b/tests/preproc/test_bumped_version/output
@@ -0,0 +1,11 @@
+git_bumped_version: 0.1
+git_bumped_version lead=1: 1.0
+git_bumped_version follow=2: 0.2
+git_bumped_version lead=1 follow=2: 1.2
+git_bumped_version lead=1 latest_tag_version=1.2: 1.3
+git_bumped_version follow=1 latest_tag_version=1.4: 0.1
+git_bumped_version latest_tag_version=1.2: 0.1
+git_bumped_version latest_tag_version=1.x: 0.1
+git_bumped_version latest_tag_version=0.1.x: 0.1
+git_bumped_version follow=2.0 # invalid but allowed here: 0.2.0
+git_bumped_version latest_tag_version=1-2 # invalid but allowed here: 0.1
diff --git a/tests/preproc/test_bumped_version/run.sh b/tests/preproc/test_bumped_version/run.sh
new file mode 100755
index 0000000..41d3147
--- /dev/null
+++ b/tests/preproc/test_bumped_version/run.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+prepare_input input $repo/input
+
+touch output && cp output $output
+
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_committed/log b/tests/preproc/test_committed/log
index e78c556..0e9bb1a 100644
--- a/tests/preproc/test_committed/log
+++ b/tests/preproc/test_committed/log
@@ -2,76 +2,50 @@
 ---
 > git_name name=foo
 ---
-> git_name name=foo append=foo-bar
+> git_name append=-baz
 ---
-> git_name append=foo
+> git_name prepend=bar-
 ---
-> git_name append=foo-bar
+> git_name prepend=bar- append=-baz
+---
+> git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
 ---
 > git_version name=foo
 ---
+> git_version name=foo lead=1
+---
+> git_version lead=0
+---
 > git_version lead=1
 ---
 > git_version lead=0.1
 ---
-> git_version follow=2
+> git_version follow=1
 ---
 > git_version lead=1 follow=2
 ---
 > git_version lead=x follow=x
 ---
-> git_version lead=1-1
+> git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 failed with value 1
+git_version lead=1-1 # invalid failed with value 1
 ---
-> git_version follow=2.0
+> git_version follow=2.0 # invalid
 git_version: follow cannot contain dots.
-git_version follow=2.0 failed with value 1
+git_version follow=2.0 # invalid failed with value 1
 ---
-> git_version follow=2-2
+> git_version follow=2-2 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 failed with value 1
+git_version follow=2-2 # invalid failed with value 1
 ---
-> git_version name=
+> git_version name= # invalid
 git_version: name cannot be empty.
-git_version name= failed with value 1
+git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
 > git_vcs
 ---
 > git_vcs subtree=foo
@@ -118,191 +92,191 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_cwd_name
+> git_dir_name
 ---
-> git_cwd_name name=foo
+> git_dir_name name=foo
 ---
-> git_cwd_name name=foo append=foo-bar
+> git_dir_name append=-baz
 ---
-> git_cwd_name append=foo
+> git_dir_name prepend=bar-
 ---
-> git_cwd_name append=foo-bar
+> git_dir_name prepend=bar- append=-baz
 ---
-> git_cwd_version
+> git_dir_name name=foo prepend=bar- append=-baz
 ---
-> git_cwd_version name=foo
+> git_dir_version
 ---
-> git_cwd_version lead=1
+> git_dir_version name=foo
 ---
-> git_cwd_version lead=0.1
+> git_dir_version name=foo lead=1
 ---
-> git_cwd_version follow=2
+> git_dir_version lead=0
 ---
-> git_cwd_version lead=1 follow=2
+> git_dir_version lead=1
 ---
-> git_cwd_version lead=x follow=x
+> git_dir_version lead=0.1
 ---
-> git_cwd_version lead=1-1
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 failed with value 1
+> git_dir_version follow=1
 ---
-> git_cwd_version follow=2.0
-git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 failed with value 1
+> git_dir_version lead=1 follow=2
 ---
-> git_cwd_version follow=2-2
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 failed with value 1
+> git_dir_version lead=x follow=x
 ---
-> git_cwd_version name=
-git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
 ---
-> git_cwd_version name="$(git_cwd_name)"
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_dir_version name="$(git_name)"
 ---
-> git_cwd_vcs
+> git_dir_vcs
 ---
-> git_cwd_vcs subtree=foo
+> git_dir_vcs subtree=foo
 ---
-> git_cwd_pack
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
+> git_dir_source_name
 ---
-> git_cwd_source_name name=foo
+> git_dir_source_name name=foo
 ---
-> git_cwd_source_name version=1.2
+> git_dir_source_name version=1.2
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_dir_changelog
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_dir_name
+> git_cwd_name
 ---
-> git_dir_name name=foo
+> git_cwd_name name=foo
 ---
-> git_dir_name name=foo append=foo-bar
+> git_cwd_name append=-baz
 ---
-> git_dir_name append=foo
+> git_cwd_name prepend=bar-
 ---
-> git_dir_name append=foo-bar
+> git_cwd_name prepend=bar- append=-baz
 ---
-> git_dir_version
+> git_cwd_name name=foo prepend=bar- append=-baz
 ---
-> git_dir_version name=foo
+> git_cwd_version
 ---
-> git_dir_version lead=1
+> git_cwd_version name=foo
 ---
-> git_dir_version lead=0.1
+> git_cwd_version name=foo lead=1
 ---
-> git_dir_version follow=2
+> git_cwd_version lead=0
 ---
-> git_dir_version lead=1 follow=2
+> git_cwd_version lead=1
 ---
-> git_dir_version lead=x follow=x
+> git_cwd_version lead=0.1
 ---
-> git_dir_version lead=1-1
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 failed with value 1
+> git_cwd_version follow=1
 ---
-> git_dir_version follow=2.0
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 failed with value 1
+> git_cwd_version lead=1 follow=2
 ---
-> git_dir_version follow=2-2
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 failed with value 1
+> git_cwd_version lead=x follow=x
 ---
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
+> git_cwd_version lead=1-1 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 # invalid failed with value 1
 ---
-> git_dir_version name="$(git_dir_name)"
+> git_cwd_version follow=2.0 # invalid
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_cwd_version follow=2-2 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_cwd_version name= # invalid
+git_cwd_version: name cannot be empty.
+git_cwd_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_cwd_version name="$(git_cwd_name)"
 ---
-> git_dir_vcs
+> git_cwd_vcs
 ---
-> git_dir_vcs subtree=foo
+> git_cwd_vcs subtree=foo
 ---
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
+> git_cwd_source_name
 ---
-> git_dir_source_name name=foo
+> git_cwd_source_name name=foo
 ---
-> git_dir_source_name version=1.2
+> git_cwd_source_name version=1.2
 ---
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_cwd_changelog
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
diff --git a/tests/preproc/test_committed/output b/tests/preproc/test_committed/output
index ad15071..39c2360 100644
--- a/tests/preproc/test_committed/output
+++ b/tests/preproc/test_committed/output
@@ -1,43 +1,27 @@
 git_name: test
 git_name name=foo: foo
-git_name name=foo append=foo-bar: foo-foo-bar
-git_name append=foo: test-foo
-git_name append=foo-bar: test-foo-bar
-
-git_version: 0.0.git.3.efdcaea
-git_version name=foo: 0.0.git.3.efdcaea
-git_version lead=1: 1.0.git.3.efdcaea
-git_version lead=0.1: 0.1.0.git.3.efdcaea
-git_version follow=2: 0.2.git.3.efdcaea
-git_version lead=1 follow=2: 1.2.git.3.efdcaea
-git_version lead=x follow=x: x.x.git.3.efdcaea
-git_version lead=1-1:  # invalid
-git_version follow=2.0:  # invalid
-git_version follow=2-2:  # invalid
-git_version name=:  # invalid
-
-git_version name="$(git_name)": 0.0.git.3.efdcaea
-git_version echo 1.4: 1.4
-git_version echo -n 1; echo -n .; echo 4: 1.4
-git_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_bumped_version: 0.1
-git_bumped_version lead=1: 1.0
-git_bumped_version follow=2: 0.2
-git_bumped_version lead=1 follow=2: 1.2
-git_bumped_version lead=1 latest_tag_version=1.2: 1.3
-git_bumped_version follow=2 latest_tag_version=1.4: 0.2
-git_bumped_version latest_tag_version=1.2: 0.1
-git_bumped_version latest_tag_version=0.1.2: 0.1
-git_bumped_version latest_tag_version=1.x: 0.1
-git_bumped_version latest_tag_version=0.1.x: 0.1
-git_bumped_version latest_tag_version=0.1: 0.2
-git_bumped_version follow=2.0: 0.2.0 # invalid but works
-git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
-
-git_vcs: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:foo
+git_name append=-baz: test-baz
+git_name prepend=bar-: bar-test
+git_name prepend=bar- append=-baz: bar-test-baz
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_version: 0.0.git.3.0ea5766
+git_version name=foo: 0.0.git.3.0ea5766
+git_version name=foo lead=1: 1.0.git.3.0ea5766
+git_version lead=0: 0.0.git.3.0ea5766
+git_version lead=1: 1.0.git.3.0ea5766
+git_version lead=0.1: 0.1.0.git.3.0ea5766
+git_version follow=1: 0.1.git.3.0ea5766
+git_version lead=1 follow=2: 1.2.git.3.0ea5766
+git_version lead=x follow=x: x.x.git.3.0ea5766
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
+git_version name="$(git_name)": 0.0.git.3.0ea5766
+
+git_vcs: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:foo
 
 git_pack: 
 git_pack dir_name=foo: 
@@ -49,9 +33,9 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: test-foo-bar-0.0.git.3.efdcaea.tar.gz
-git_source_name name=foo: foo-0.0.git.3.efdcaea.tar.gz
-git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name: bar-foo-baz-0.0.git.3.0ea5766.tar.gz
+git_source_name name=foo: foo-0.0.git.3.0ea5766.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_changelog:
@@ -69,120 +53,119 @@ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
 
-git_cwd_name: test
-git_cwd_name name=foo: foo
-git_cwd_name name=foo append=foo-bar: foo-foo-bar
-git_cwd_name append=foo: test-foo
-git_cwd_name append=foo-bar: test-foo-bar
+:::::::::::::::::::::
 
-git_cwd_version: 0.0.git.3.efdcaea
-git_cwd_version name=foo: 0.0.git.3.efdcaea
-git_cwd_version lead=1: 1.0.git.3.efdcaea
-git_cwd_version lead=0.1: 0.1.0.git.3.efdcaea
-git_cwd_version follow=2: 0.2.git.3.efdcaea
-git_cwd_version lead=1 follow=2: 1.2.git.3.efdcaea
-git_cwd_version lead=x follow=x: x.x.git.3.efdcaea
-git_cwd_version lead=1-1:  # invalid
-git_cwd_version follow=2.0:  # invalid
-git_cwd_version follow=2-2:  # invalid
-git_cwd_version name=:  # invalid
+git_dir_name: test-
+git_dir_name name=foo: foo-
+git_dir_name append=-baz: test-baz
+git_dir_name prepend=bar-: bar-test-
+git_dir_name prepend=bar- append=-baz: bar-test-baz
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version name="$(git_name)": 0.0.git.3.efdcaea
-git_cwd_version echo 1.4: 1.4
-git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+git_dir_version: 0.0.git.3.0ea5766
+git_dir_version name=foo: 0.0.git.3.0ea5766
+git_dir_version name=foo lead=1: 1.0.git.3.0ea5766
+git_dir_version lead=0: 0.0.git.3.0ea5766
+git_dir_version lead=1: 1.0.git.3.0ea5766
+git_dir_version lead=0.1: 0.1.0.git.3.0ea5766
+git_dir_version follow=1: 0.1.git.3.0ea5766
+git_dir_version lead=1 follow=2: 1.2.git.3.0ea5766
+git_dir_version lead=x follow=x: x.x.git.3.0ea5766
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
+git_dir_version name="$(git_name)": 0.0.git.3.0ea5766
 
+git_dir_vcs: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:foo
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:foo
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: test-foo-bar-0.0.git.3.efdcaea.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.3.efdcaea.tar.gz
-git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_source_name: bar-foo-baz-0.0.git.3.0ea5766.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.3.0ea5766.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_dir_changelog:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1:
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
 
-git_dir_name: test
-git_dir_name name=foo: foo
-git_dir_name name=foo append=foo-bar: foo-foo-bar
-git_dir_name append=foo: test-foo
-git_dir_name append=foo-bar: test-foo-bar
+:::::::::::::::::::::
 
-git_dir_version: 0.0.git.3.efdcaea
-git_dir_version name=foo: 0.0.git.3.efdcaea
-git_dir_version lead=1: 1.0.git.3.efdcaea
-git_dir_version lead=0.1: 0.1.0.git.3.efdcaea
-git_dir_version follow=2: 0.2.git.3.efdcaea
-git_dir_version lead=1 follow=2: 1.2.git.3.efdcaea
-git_dir_version lead=x follow=x: x.x.git.3.efdcaea
-git_dir_version lead=1-1:  # invalid
-git_dir_version follow=2.0:  # invalid
-git_dir_version follow=2-2:  # invalid
-git_dir_version name=:  # invalid
+git_cwd_name: test-
+git_cwd_name name=foo: foo-
+git_cwd_name append=-baz: test-baz
+git_cwd_name prepend=bar-: bar-test-
+git_cwd_name prepend=bar- append=-baz: bar-test-baz
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version name="$(git_name)": 0.0.git.3.efdcaea
-git_dir_version echo 1.4: 1.4
-git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_dir_version date --date='@2147483647' %y%m%d: 380119
+git_cwd_version: 0.0.git.3.0ea5766
+git_cwd_version name=foo: 0.0.git.3.0ea5766
+git_cwd_version name=foo lead=1: 1.0.git.3.0ea5766
+git_cwd_version lead=0: 0.0.git.3.0ea5766
+git_cwd_version lead=1: 1.0.git.3.0ea5766
+git_cwd_version lead=0.1: 0.1.0.git.3.0ea5766
+git_cwd_version follow=1: 0.1.git.3.0ea5766
+git_cwd_version lead=1 follow=2: 1.2.git.3.0ea5766
+git_cwd_version lead=x follow=x: x.x.git.3.0ea5766
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 0.0.git.3.0ea5766
 
+git_cwd_vcs: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:foo
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#efdcaea3dc1b8a1f0181bc59a2751eb5757025d7:foo
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
-git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
-git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.git.3.0ea5766.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.3.0ea5766.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_source_name: test-foo-bar-0.0.git.3.efdcaea.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.3.efdcaea.tar.gz
-git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_changelog:
 
-git_dir_changelog:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
 
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
diff --git a/tests/preproc/test_committed/run.sh b/tests/preproc/test_committed/run.sh
index 51d74bd..a8dca2a 100755
--- a/tests/preproc/test_committed/run.sh
+++ b/tests/preproc/test_committed/run.sh
@@ -5,7 +5,7 @@
 repo=`mktemp -d`
 output=`mktemp`
 
-cp ../input $repo
+prepare_input ../input $repo/input
 
 git init $repo
 git -C $repo remote add origin https://pagure.io/clime/test.git
diff --git a/tests/preproc/test_dirty/log b/tests/preproc/test_dirty/log
index e78c556..0e9bb1a 100644
--- a/tests/preproc/test_dirty/log
+++ b/tests/preproc/test_dirty/log
@@ -2,76 +2,50 @@
 ---
 > git_name name=foo
 ---
-> git_name name=foo append=foo-bar
+> git_name append=-baz
 ---
-> git_name append=foo
+> git_name prepend=bar-
 ---
-> git_name append=foo-bar
+> git_name prepend=bar- append=-baz
+---
+> git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
 ---
 > git_version name=foo
 ---
+> git_version name=foo lead=1
+---
+> git_version lead=0
+---
 > git_version lead=1
 ---
 > git_version lead=0.1
 ---
-> git_version follow=2
+> git_version follow=1
 ---
 > git_version lead=1 follow=2
 ---
 > git_version lead=x follow=x
 ---
-> git_version lead=1-1
+> git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 failed with value 1
+git_version lead=1-1 # invalid failed with value 1
 ---
-> git_version follow=2.0
+> git_version follow=2.0 # invalid
 git_version: follow cannot contain dots.
-git_version follow=2.0 failed with value 1
+git_version follow=2.0 # invalid failed with value 1
 ---
-> git_version follow=2-2
+> git_version follow=2-2 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 failed with value 1
+git_version follow=2-2 # invalid failed with value 1
 ---
-> git_version name=
+> git_version name= # invalid
 git_version: name cannot be empty.
-git_version name= failed with value 1
+git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
 > git_vcs
 ---
 > git_vcs subtree=foo
@@ -118,191 +92,191 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_cwd_name
+> git_dir_name
 ---
-> git_cwd_name name=foo
+> git_dir_name name=foo
 ---
-> git_cwd_name name=foo append=foo-bar
+> git_dir_name append=-baz
 ---
-> git_cwd_name append=foo
+> git_dir_name prepend=bar-
 ---
-> git_cwd_name append=foo-bar
+> git_dir_name prepend=bar- append=-baz
 ---
-> git_cwd_version
+> git_dir_name name=foo prepend=bar- append=-baz
 ---
-> git_cwd_version name=foo
+> git_dir_version
 ---
-> git_cwd_version lead=1
+> git_dir_version name=foo
 ---
-> git_cwd_version lead=0.1
+> git_dir_version name=foo lead=1
 ---
-> git_cwd_version follow=2
+> git_dir_version lead=0
 ---
-> git_cwd_version lead=1 follow=2
+> git_dir_version lead=1
 ---
-> git_cwd_version lead=x follow=x
+> git_dir_version lead=0.1
 ---
-> git_cwd_version lead=1-1
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 failed with value 1
+> git_dir_version follow=1
 ---
-> git_cwd_version follow=2.0
-git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 failed with value 1
+> git_dir_version lead=1 follow=2
 ---
-> git_cwd_version follow=2-2
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 failed with value 1
+> git_dir_version lead=x follow=x
 ---
-> git_cwd_version name=
-git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
 ---
-> git_cwd_version name="$(git_cwd_name)"
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_dir_version name="$(git_name)"
 ---
-> git_cwd_vcs
+> git_dir_vcs
 ---
-> git_cwd_vcs subtree=foo
+> git_dir_vcs subtree=foo
 ---
-> git_cwd_pack
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
+> git_dir_source_name
 ---
-> git_cwd_source_name name=foo
+> git_dir_source_name name=foo
 ---
-> git_cwd_source_name version=1.2
+> git_dir_source_name version=1.2
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_dir_changelog
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_dir_name
+> git_cwd_name
 ---
-> git_dir_name name=foo
+> git_cwd_name name=foo
 ---
-> git_dir_name name=foo append=foo-bar
+> git_cwd_name append=-baz
 ---
-> git_dir_name append=foo
+> git_cwd_name prepend=bar-
 ---
-> git_dir_name append=foo-bar
+> git_cwd_name prepend=bar- append=-baz
 ---
-> git_dir_version
+> git_cwd_name name=foo prepend=bar- append=-baz
 ---
-> git_dir_version name=foo
+> git_cwd_version
 ---
-> git_dir_version lead=1
+> git_cwd_version name=foo
 ---
-> git_dir_version lead=0.1
+> git_cwd_version name=foo lead=1
 ---
-> git_dir_version follow=2
+> git_cwd_version lead=0
 ---
-> git_dir_version lead=1 follow=2
+> git_cwd_version lead=1
 ---
-> git_dir_version lead=x follow=x
+> git_cwd_version lead=0.1
 ---
-> git_dir_version lead=1-1
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 failed with value 1
+> git_cwd_version follow=1
 ---
-> git_dir_version follow=2.0
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 failed with value 1
+> git_cwd_version lead=1 follow=2
 ---
-> git_dir_version follow=2-2
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 failed with value 1
+> git_cwd_version lead=x follow=x
 ---
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
+> git_cwd_version lead=1-1 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 # invalid failed with value 1
 ---
-> git_dir_version name="$(git_dir_name)"
+> git_cwd_version follow=2.0 # invalid
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_cwd_version follow=2-2 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_cwd_version name= # invalid
+git_cwd_version: name cannot be empty.
+git_cwd_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_cwd_version name="$(git_cwd_name)"
 ---
-> git_dir_vcs
+> git_cwd_vcs
 ---
-> git_dir_vcs subtree=foo
+> git_cwd_vcs subtree=foo
 ---
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
+> git_cwd_source_name
 ---
-> git_dir_source_name name=foo
+> git_cwd_source_name name=foo
 ---
-> git_dir_source_name version=1.2
+> git_cwd_source_name version=1.2
 ---
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_cwd_changelog
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
diff --git a/tests/preproc/test_dirty/output b/tests/preproc/test_dirty/output
index 0a4e179..065bb86 100644
--- a/tests/preproc/test_dirty/output
+++ b/tests/preproc/test_dirty/output
@@ -1,43 +1,27 @@
 git_name: test
 git_name name=foo: foo
-git_name name=foo append=foo-bar: foo-foo-bar
-git_name append=foo: test-foo
-git_name append=foo-bar: test-foo-bar
-
-git_version: 0.0.git.1.1aefe40.wtree.zfxvuf
-git_version name=foo: 0.0.git.1.1aefe40.wtree.zfxvuf
-git_version lead=1: 1.0.git.1.1aefe40.wtree.zfxvuf
-git_version lead=0.1: 0.1.0.git.1.1aefe40.wtree.zfxvuf
-git_version follow=2: 0.2.git.1.1aefe40.wtree.zfxvuf
-git_version lead=1 follow=2: 1.2.git.1.1aefe40.wtree.zfxvuf
-git_version lead=x follow=x: x.x.git.1.1aefe40.wtree.zfxvuf
-git_version lead=1-1:  # invalid
-git_version follow=2.0:  # invalid
-git_version follow=2-2:  # invalid
-git_version name=:  # invalid
-
-git_version name="$(git_name)": 0.0.git.1.1aefe40.wtree.zfxvuf
-git_version echo 1.4: 1.4
-git_version echo -n 1; echo -n .; echo 4: 1.4
-git_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_bumped_version: 0.1
-git_bumped_version lead=1: 1.0
-git_bumped_version follow=2: 0.2
-git_bumped_version lead=1 follow=2: 1.2
-git_bumped_version lead=1 latest_tag_version=1.2: 1.3
-git_bumped_version follow=2 latest_tag_version=1.4: 0.2
-git_bumped_version latest_tag_version=1.2: 0.1
-git_bumped_version latest_tag_version=0.1.2: 0.1
-git_bumped_version latest_tag_version=1.x: 0.1
-git_bumped_version latest_tag_version=0.1.x: 0.1
-git_bumped_version latest_tag_version=0.1: 0.2
-git_bumped_version follow=2.0: 0.2.0 # invalid but works
-git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
-
-git_vcs: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:foo
+git_name append=-baz: test-baz
+git_name prepend=bar-: bar-test
+git_name prepend=bar- append=-baz: bar-test-baz
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_version: 0.0.git.1.0326f80.wtree.zf1ilc
+git_version name=foo: 0.0.git.1.0326f80.wtree.zf1ilc
+git_version name=foo lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
+git_version lead=0: 0.0.git.1.0326f80.wtree.zf1ilc
+git_version lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
+git_version lead=0.1: 0.1.0.git.1.0326f80.wtree.zf1ilc
+git_version follow=1: 0.1.git.1.0326f80.wtree.zf1ilc
+git_version lead=1 follow=2: 1.2.git.1.0326f80.wtree.zf1ilc
+git_version lead=x follow=x: x.x.git.1.0326f80.wtree.zf1ilc
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
+git_version name="$(git_name)": 0.0.git.1.0326f80.wtree.zf1ilc
+
+git_vcs: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:foo
 
 git_pack: 
 git_pack dir_name=foo: 
@@ -49,9 +33,9 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: test-foo-bar-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
-git_source_name name=foo: foo-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
-git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name: bar-foo-baz-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_source_name name=foo: foo-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_changelog:
@@ -69,120 +53,119 @@ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
 
-git_cwd_name: test
-git_cwd_name name=foo: foo
-git_cwd_name name=foo append=foo-bar: foo-foo-bar
-git_cwd_name append=foo: test-foo
-git_cwd_name append=foo-bar: test-foo-bar
+:::::::::::::::::::::
 
-git_cwd_version: 0.0.git.1.1aefe40.wtree.zfxvuf
-git_cwd_version name=foo: 0.0.git.1.1aefe40.wtree.zfxvuf
-git_cwd_version lead=1: 1.0.git.1.1aefe40.wtree.zfxvuf
-git_cwd_version lead=0.1: 0.1.0.git.1.1aefe40.wtree.zfxvuf
-git_cwd_version follow=2: 0.2.git.1.1aefe40.wtree.zfxvuf
-git_cwd_version lead=1 follow=2: 1.2.git.1.1aefe40.wtree.zfxvuf
-git_cwd_version lead=x follow=x: x.x.git.1.1aefe40.wtree.zfxvuf
-git_cwd_version lead=1-1:  # invalid
-git_cwd_version follow=2.0:  # invalid
-git_cwd_version follow=2-2:  # invalid
-git_cwd_version name=:  # invalid
+git_dir_name: test-
+git_dir_name name=foo: foo-
+git_dir_name append=-baz: test-baz
+git_dir_name prepend=bar-: bar-test-
+git_dir_name prepend=bar- append=-baz: bar-test-baz
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version name="$(git_name)": 0.0.git.1.1aefe40.wtree.zfxvuf
-git_cwd_version echo 1.4: 1.4
-git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+git_dir_version: 0.0.git.1.0326f80.wtree.zf1ilc
+git_dir_version name=foo: 0.0.git.1.0326f80.wtree.zf1ilc
+git_dir_version name=foo lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
+git_dir_version lead=0: 0.0.git.1.0326f80.wtree.zf1ilc
+git_dir_version lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
+git_dir_version lead=0.1: 0.1.0.git.1.0326f80.wtree.zf1ilc
+git_dir_version follow=1: 0.1.git.1.0326f80.wtree.zf1ilc
+git_dir_version lead=1 follow=2: 1.2.git.1.0326f80.wtree.zf1ilc
+git_dir_version lead=x follow=x: x.x.git.1.0326f80.wtree.zf1ilc
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
+git_dir_version name="$(git_name)": 0.0.git.1.0326f80.wtree.zf1ilc
 
+git_dir_vcs: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:foo
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:foo
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: test-foo-bar-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
-git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_source_name: bar-foo-baz-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_dir_changelog:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1:
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
 
-git_dir_name: test
-git_dir_name name=foo: foo
-git_dir_name name=foo append=foo-bar: foo-foo-bar
-git_dir_name append=foo: test-foo
-git_dir_name append=foo-bar: test-foo-bar
+:::::::::::::::::::::
 
-git_dir_version: 0.0.git.1.1aefe40.wtree.zfxvuf
-git_dir_version name=foo: 0.0.git.1.1aefe40.wtree.zfxvuf
-git_dir_version lead=1: 1.0.git.1.1aefe40.wtree.zfxvuf
-git_dir_version lead=0.1: 0.1.0.git.1.1aefe40.wtree.zfxvuf
-git_dir_version follow=2: 0.2.git.1.1aefe40.wtree.zfxvuf
-git_dir_version lead=1 follow=2: 1.2.git.1.1aefe40.wtree.zfxvuf
-git_dir_version lead=x follow=x: x.x.git.1.1aefe40.wtree.zfxvuf
-git_dir_version lead=1-1:  # invalid
-git_dir_version follow=2.0:  # invalid
-git_dir_version follow=2-2:  # invalid
-git_dir_version name=:  # invalid
+git_cwd_name: test-
+git_cwd_name name=foo: foo-
+git_cwd_name append=-baz: test-baz
+git_cwd_name prepend=bar-: bar-test-
+git_cwd_name prepend=bar- append=-baz: bar-test-baz
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version name="$(git_name)": 0.0.git.1.1aefe40.wtree.zfxvuf
-git_dir_version echo 1.4: 1.4
-git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_dir_version date --date='@2147483647' %y%m%d: 380119
+git_cwd_version: 0.0.git.1.0326f80.wtree.zf1ilc
+git_cwd_version name=foo: 0.0.git.1.0326f80.wtree.zf1ilc
+git_cwd_version name=foo lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
+git_cwd_version lead=0: 0.0.git.1.0326f80.wtree.zf1ilc
+git_cwd_version lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
+git_cwd_version lead=0.1: 0.1.0.git.1.0326f80.wtree.zf1ilc
+git_cwd_version follow=1: 0.1.git.1.0326f80.wtree.zf1ilc
+git_cwd_version lead=1 follow=2: 1.2.git.1.0326f80.wtree.zf1ilc
+git_cwd_version lead=x follow=x: x.x.git.1.0326f80.wtree.zf1ilc
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 0.0.git.1.0326f80.wtree.zf1ilc
 
+git_cwd_vcs: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:foo
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#1aefe40a3e72e58ddba93389b4302460cefa613e:foo
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
-git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
-git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_source_name: test-foo-bar-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.1.1aefe40.wtree.zfxvuf.tar.gz
-git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_changelog:
 
-git_dir_changelog:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
 
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
diff --git a/tests/preproc/test_dirty/run.sh b/tests/preproc/test_dirty/run.sh
index c00a83e..d42a7d1 100755
--- a/tests/preproc/test_dirty/run.sh
+++ b/tests/preproc/test_dirty/run.sh
@@ -5,7 +5,7 @@
 repo=`mktemp -d`
 output=`mktemp`
 
-cp ../input $repo
+prepare_input ../input $repo/input
 
 git init $repo
 git -C $repo remote add origin https://pagure.io/clime/test.git
diff --git a/tests/preproc/test_inited/log b/tests/preproc/test_inited/log
index d84fcd1..57ddfd8 100644
--- a/tests/preproc/test_inited/log
+++ b/tests/preproc/test_inited/log
@@ -4,83 +4,59 @@ git_name failed with value 1
 ---
 > git_name name=foo
 ---
-> git_name name=foo append=foo-bar
+> git_name append=-baz
+git_name: Start by setting origin URL.
+git_name append=-baz failed with value 1
 ---
-> git_name append=foo
+> git_name prepend=bar-
 git_name: Start by setting origin URL.
-git_name append=foo failed with value 1
+git_name prepend=bar- failed with value 1
 ---
-> git_name append=foo-bar
+> git_name prepend=bar- append=-baz
 git_name: Start by setting origin URL.
-git_name append=foo-bar failed with value 1
+git_name prepend=bar- append=-baz failed with value 1
+---
+> git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
 ---
 > git_version name=foo
 ---
+> git_version name=foo lead=1
+---
+> git_version lead=0
+---
 > git_version lead=1
 ---
 > git_version lead=0.1
 ---
-> git_version follow=2
+> git_version follow=1
 ---
 > git_version lead=1 follow=2
 ---
 > git_version lead=x follow=x
 ---
-> git_version lead=1-1
+> git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 failed with value 1
+git_version lead=1-1 # invalid failed with value 1
 ---
-> git_version follow=2.0
+> git_version follow=2.0 # invalid
 git_version: follow cannot contain dots.
-git_version follow=2.0 failed with value 1
+git_version follow=2.0 # invalid failed with value 1
 ---
-> git_version follow=2-2
+> git_version follow=2-2 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 failed with value 1
+git_version follow=2-2 # invalid failed with value 1
 ---
-> git_version name=
+> git_version name= # invalid
 git_version: name cannot be empty.
-git_version name= failed with value 1
+git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
 git_name: Start by setting origin URL.
 git_version: name cannot be empty.
 git_version name="$(git_name)" failed with value 1
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
 > git_vcs
 git_vcs: Start by setting origin URL.
 git_vcs failed with value 1
@@ -131,63 +107,174 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
+> git_dir_name
+git_dir_name: Start by setting origin URL.
+git_dir_name failed with value 1
+---
+> git_dir_name name=foo
+---
+> git_dir_name append=-baz
+git_dir_name: Start by setting origin URL.
+git_dir_name append=-baz failed with value 1
+---
+> git_dir_name prepend=bar-
+git_dir_name: Start by setting origin URL.
+git_dir_name prepend=bar- failed with value 1
+---
+> git_dir_name prepend=bar- append=-baz
+git_dir_name: Start by setting origin URL.
+git_dir_name prepend=bar- append=-baz failed with value 1
+---
+> git_dir_name name=foo prepend=bar- append=-baz
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version name=foo lead=1
+---
+> git_dir_version lead=0
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=1
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
+---
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
+---
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
+---
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
+---
+> git_dir_version name="$(git_name)"
+git_name: Start by setting origin URL.
+git_dir_version: name cannot be empty.
+git_dir_version name="$(git_name)" failed with value 1
+---
+> git_dir_vcs
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs failed with value 1
+---
+> git_dir_vcs subtree=foo
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs subtree=foo failed with value 1
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+---
 > git_cwd_name
 git_cwd_name: Start by setting origin URL.
 git_cwd_name failed with value 1
 ---
 > git_cwd_name name=foo
 ---
-> git_cwd_name name=foo append=foo-bar
+> git_cwd_name append=-baz
+git_cwd_name: Start by setting origin URL.
+git_cwd_name append=-baz failed with value 1
 ---
-> git_cwd_name append=foo
+> git_cwd_name prepend=bar-
 git_cwd_name: Start by setting origin URL.
-git_cwd_name append=foo failed with value 1
+git_cwd_name prepend=bar- failed with value 1
 ---
-> git_cwd_name append=foo-bar
+> git_cwd_name prepend=bar- append=-baz
 git_cwd_name: Start by setting origin URL.
-git_cwd_name append=foo-bar failed with value 1
+git_cwd_name prepend=bar- append=-baz failed with value 1
+---
+> git_cwd_name name=foo prepend=bar- append=-baz
 ---
 > git_cwd_version
 ---
 > git_cwd_version name=foo
 ---
+> git_cwd_version name=foo lead=1
+---
+> git_cwd_version lead=0
+---
 > git_cwd_version lead=1
 ---
 > git_cwd_version lead=0.1
 ---
-> git_cwd_version follow=2
+> git_cwd_version follow=1
 ---
 > git_cwd_version lead=1 follow=2
 ---
 > git_cwd_version lead=x follow=x
 ---
-> git_cwd_version lead=1-1
+> git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 failed with value 1
+git_cwd_version lead=1-1 # invalid failed with value 1
 ---
-> git_cwd_version follow=2.0
+> git_cwd_version follow=2.0 # invalid
 git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 failed with value 1
+git_cwd_version follow=2.0 # invalid failed with value 1
 ---
-> git_cwd_version follow=2-2
+> git_cwd_version follow=2-2 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 failed with value 1
+git_cwd_version follow=2-2 # invalid failed with value 1
 ---
-> git_cwd_version name=
+> git_cwd_version name= # invalid
 git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
+git_cwd_version name= # invalid failed with value 1
 ---
 > git_cwd_version name="$(git_cwd_name)"
 git_cwd_name: Start by setting origin URL.
 git_cwd_version: name cannot be empty.
 git_cwd_version name="$(git_cwd_name)" failed with value 1
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
 > git_cwd_vcs
 git_cwd_vcs: Start by setting origin URL.
 git_cwd_vcs failed with value 1
@@ -238,110 +325,3 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_dir_name
-git_dir_name: Start by setting origin URL.
-git_dir_name failed with value 1
----
-> git_dir_name name=foo
----
-> git_dir_name name=foo append=foo-bar
----
-> git_dir_name append=foo
-git_dir_name: Start by setting origin URL.
-git_dir_name append=foo failed with value 1
----
-> git_dir_name append=foo-bar
-git_dir_name: Start by setting origin URL.
-git_dir_name append=foo-bar failed with value 1
----
-> git_dir_version
----
-> git_dir_version name=foo
----
-> git_dir_version lead=1
----
-> git_dir_version lead=0.1
----
-> git_dir_version follow=2
----
-> git_dir_version lead=1 follow=2
----
-> git_dir_version lead=x follow=x
----
-> git_dir_version lead=1-1
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 failed with value 1
----
-> git_dir_version follow=2.0
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 failed with value 1
----
-> git_dir_version follow=2-2
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 failed with value 1
----
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
----
-> git_dir_version name="$(git_dir_name)"
-git_dir_name: Start by setting origin URL.
-git_dir_version: name cannot be empty.
-git_dir_version name="$(git_dir_name)" failed with value 1
----
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_dir_vcs
-git_dir_vcs: Start by setting origin URL.
-git_dir_vcs failed with value 1
----
-> git_dir_vcs subtree=foo
-git_dir_vcs: Start by setting origin URL.
-git_dir_vcs subtree=foo failed with value 1
----
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_source_name
----
-> git_dir_source_name name=foo
----
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
----
-> git_dir_changelog
----
-> git_dir_changelog name=foo since_tag=foo-1.2-1
----
-> git_dir_changelog name=foo until_tag=foo-1.2-1
----
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
----
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
----
diff --git a/tests/preproc/test_inited/output b/tests/preproc/test_inited/output
index 358a6c9..54fae8e 100644
--- a/tests/preproc/test_inited/output
+++ b/tests/preproc/test_inited/output
@@ -1,40 +1,24 @@
 git_name: 
 git_name name=foo: foo
-git_name name=foo append=foo-bar: foo-foo-bar
-git_name append=foo: 
-git_name append=foo-bar: 
-
-git_version: 0.0.wtree.zfxvuh
-git_version name=foo: 0.0.wtree.zfxvuh
-git_version lead=1: 1.0.wtree.zfxvuh
-git_version lead=0.1: 0.1.0.wtree.zfxvuh
-git_version follow=2: 0.2.wtree.zfxvuh
-git_version lead=1 follow=2: 1.2.wtree.zfxvuh
-git_version lead=x follow=x: x.x.wtree.zfxvuh
-git_version lead=1-1:  # invalid
-git_version follow=2.0:  # invalid
-git_version follow=2-2:  # invalid
-git_version name=:  # invalid
-
+git_name append=-baz: 
+git_name prepend=bar-: 
+git_name prepend=bar- append=-baz: 
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_version: 0.0.wtree.zf1ile
+git_version name=foo: 0.0.wtree.zf1ile
+git_version name=foo lead=1: 1.0.wtree.zf1ile
+git_version lead=0: 0.0.wtree.zf1ile
+git_version lead=1: 1.0.wtree.zf1ile
+git_version lead=0.1: 0.1.0.wtree.zf1ile
+git_version follow=1: 0.1.wtree.zf1ile
+git_version lead=1 follow=2: 1.2.wtree.zf1ile
+git_version lead=x follow=x: x.x.wtree.zf1ile
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
 git_version name="$(git_name)": 
-git_version echo 1.4: 1.4
-git_version echo -n 1; echo -n .; echo 4: 1.4
-git_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_bumped_version: 0.1
-git_bumped_version lead=1: 1.0
-git_bumped_version follow=2: 0.2
-git_bumped_version lead=1 follow=2: 1.2
-git_bumped_version lead=1 latest_tag_version=1.2: 1.3
-git_bumped_version follow=2 latest_tag_version=1.4: 0.2
-git_bumped_version latest_tag_version=1.2: 0.1
-git_bumped_version latest_tag_version=0.1.2: 0.1
-git_bumped_version latest_tag_version=1.x: 0.1
-git_bumped_version latest_tag_version=0.1.x: 0.1
-git_bumped_version latest_tag_version=0.1: 0.2
-git_bumped_version follow=2.0: 0.2.0 # invalid but works
-git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
 
 git_vcs: 
 git_vcs subtree=foo: 
@@ -49,9 +33,9 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: foo-foo-bar-x.x.wtree.zfxvuh.tar.gz
-git_source_name name=foo: foo-x.x.wtree.zfxvuh.tar.gz
-git_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_source_name: bar-foo-baz-x.x.wtree.zf1ile.tar.gz
+git_source_name name=foo: foo-x.x.wtree.zf1ile.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_changelog:
@@ -69,90 +53,30 @@ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
-
-git_cwd_name: 
-git_cwd_name name=foo: foo
-git_cwd_name name=foo append=foo-bar: foo-foo-bar
-git_cwd_name append=foo: 
-git_cwd_name append=foo-bar: 
-
-git_cwd_version: 0.0.wtree.zfxvuh
-git_cwd_version name=foo: 0.0.wtree.zfxvuh
-git_cwd_version lead=1: 1.0.wtree.zfxvuh
-git_cwd_version lead=0.1: 0.1.0.wtree.zfxvuh
-git_cwd_version follow=2: 0.2.wtree.zfxvuh
-git_cwd_version lead=1 follow=2: 1.2.wtree.zfxvuh
-git_cwd_version lead=x follow=x: x.x.wtree.zfxvuh
-git_cwd_version lead=1-1:  # invalid
-git_cwd_version follow=2.0:  # invalid
-git_cwd_version follow=2-2:  # invalid
-git_cwd_version name=:  # invalid
-
-git_cwd_version name="$(git_name)": 
-git_cwd_version echo 1.4: 1.4
-git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_cwd_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_cwd_vcs: 
-git_cwd_vcs subtree=foo: 
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_cwd_source_name: foo-foo-bar-x.x.wtree.zfxvuh.tar.gz
-git_cwd_source_name name=foo: foo-x.x.wtree.zfxvuh.tar.gz
-git_cwd_source_name version=1.2: foo-foo-bar-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
-
-git_cwd_changelog:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
-
-
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-
-
----
+:::::::::::::::::::::
 
 git_dir_name: 
-git_dir_name name=foo: foo
-git_dir_name name=foo append=foo-bar: foo-foo-bar
-git_dir_name append=foo: 
-git_dir_name append=foo-bar: 
-
-git_dir_version: 0.0.wtree.zfxvuh
-git_dir_version name=foo: 0.0.wtree.zfxvuh
-git_dir_version lead=1: 1.0.wtree.zfxvuh
-git_dir_version lead=0.1: 0.1.0.wtree.zfxvuh
-git_dir_version follow=2: 0.2.wtree.zfxvuh
-git_dir_version lead=1 follow=2: 1.2.wtree.zfxvuh
-git_dir_version lead=x follow=x: x.x.wtree.zfxvuh
-git_dir_version lead=1-1:  # invalid
-git_dir_version follow=2.0:  # invalid
-git_dir_version follow=2-2:  # invalid
-git_dir_version name=:  # invalid
-
+git_dir_name name=foo: foo-
+git_dir_name append=-baz: 
+git_dir_name prepend=bar-: 
+git_dir_name prepend=bar- append=-baz: 
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_dir_version: 0.0.wtree.zf1ile
+git_dir_version name=foo: 0.0.wtree.zf1ile
+git_dir_version name=foo lead=1: 1.0.wtree.zf1ile
+git_dir_version lead=0: 0.0.wtree.zf1ile
+git_dir_version lead=1: 1.0.wtree.zf1ile
+git_dir_version lead=0.1: 0.1.0.wtree.zf1ile
+git_dir_version follow=1: 0.1.wtree.zf1ile
+git_dir_version lead=1 follow=2: 1.2.wtree.zf1ile
+git_dir_version lead=x follow=x: x.x.wtree.zf1ile
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
 git_dir_version name="$(git_name)": 
-git_dir_version echo 1.4: 1.4
-git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_dir_version date --date='@2147483647' %y%m%d: 380119
-
 
 git_dir_vcs: 
 git_dir_vcs subtree=foo: 
@@ -167,9 +91,9 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: foo-foo-bar-x.x.wtree.zfxvuh.tar.gz
-git_dir_source_name name=foo: foo-x.x.wtree.zfxvuh.tar.gz
-git_dir_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_dir_source_name: bar-foo-baz-x.x.wtree.zf1ile.tar.gz
+git_dir_source_name name=foo: foo-x.x.wtree.zf1ile.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_dir_changelog:
@@ -186,3 +110,62 @@ git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
 git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
+
+
+:::::::::::::::::::::
+
+git_cwd_name: 
+git_cwd_name name=foo: foo-
+git_cwd_name append=-baz: 
+git_cwd_name prepend=bar-: 
+git_cwd_name prepend=bar- append=-baz: 
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_cwd_version: 0.0.wtree.zf1ile
+git_cwd_version name=foo: 0.0.wtree.zf1ile
+git_cwd_version name=foo lead=1: 1.0.wtree.zf1ile
+git_cwd_version lead=0: 0.0.wtree.zf1ile
+git_cwd_version lead=1: 1.0.wtree.zf1ile
+git_cwd_version lead=0.1: 0.1.0.wtree.zf1ile
+git_cwd_version follow=1: 0.1.wtree.zf1ile
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf1ile
+git_cwd_version lead=x follow=x: x.x.wtree.zf1ile
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 
+
+git_cwd_vcs: 
+git_cwd_vcs subtree=foo: 
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: bar-foo-baz-x.x.wtree.zf1ile.tar.gz
+git_cwd_source_name name=foo: foo-x.x.wtree.zf1ile.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
diff --git a/tests/preproc/test_inited/run.sh b/tests/preproc/test_inited/run.sh
index eaddf19..3991b9c 100755
--- a/tests/preproc/test_inited/run.sh
+++ b/tests/preproc/test_inited/run.sh
@@ -5,7 +5,7 @@
 repo=`mktemp -d`
 output=`mktemp`
 
-cp ../input $repo
+prepare_input ../input $repo/input
 git init $repo
 
 touch output && cp output $output
diff --git a/tests/preproc/test_inited_origin_set/log b/tests/preproc/test_inited_origin_set/log
index e78c556..0e9bb1a 100644
--- a/tests/preproc/test_inited_origin_set/log
+++ b/tests/preproc/test_inited_origin_set/log
@@ -2,76 +2,50 @@
 ---
 > git_name name=foo
 ---
-> git_name name=foo append=foo-bar
+> git_name append=-baz
 ---
-> git_name append=foo
+> git_name prepend=bar-
 ---
-> git_name append=foo-bar
+> git_name prepend=bar- append=-baz
+---
+> git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
 ---
 > git_version name=foo
 ---
+> git_version name=foo lead=1
+---
+> git_version lead=0
+---
 > git_version lead=1
 ---
 > git_version lead=0.1
 ---
-> git_version follow=2
+> git_version follow=1
 ---
 > git_version lead=1 follow=2
 ---
 > git_version lead=x follow=x
 ---
-> git_version lead=1-1
+> git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 failed with value 1
+git_version lead=1-1 # invalid failed with value 1
 ---
-> git_version follow=2.0
+> git_version follow=2.0 # invalid
 git_version: follow cannot contain dots.
-git_version follow=2.0 failed with value 1
+git_version follow=2.0 # invalid failed with value 1
 ---
-> git_version follow=2-2
+> git_version follow=2-2 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 failed with value 1
+git_version follow=2-2 # invalid failed with value 1
 ---
-> git_version name=
+> git_version name= # invalid
 git_version: name cannot be empty.
-git_version name= failed with value 1
+git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
 > git_vcs
 ---
 > git_vcs subtree=foo
@@ -118,191 +92,191 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_cwd_name
+> git_dir_name
 ---
-> git_cwd_name name=foo
+> git_dir_name name=foo
 ---
-> git_cwd_name name=foo append=foo-bar
+> git_dir_name append=-baz
 ---
-> git_cwd_name append=foo
+> git_dir_name prepend=bar-
 ---
-> git_cwd_name append=foo-bar
+> git_dir_name prepend=bar- append=-baz
 ---
-> git_cwd_version
+> git_dir_name name=foo prepend=bar- append=-baz
 ---
-> git_cwd_version name=foo
+> git_dir_version
 ---
-> git_cwd_version lead=1
+> git_dir_version name=foo
 ---
-> git_cwd_version lead=0.1
+> git_dir_version name=foo lead=1
 ---
-> git_cwd_version follow=2
+> git_dir_version lead=0
 ---
-> git_cwd_version lead=1 follow=2
+> git_dir_version lead=1
 ---
-> git_cwd_version lead=x follow=x
+> git_dir_version lead=0.1
 ---
-> git_cwd_version lead=1-1
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 failed with value 1
+> git_dir_version follow=1
 ---
-> git_cwd_version follow=2.0
-git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 failed with value 1
+> git_dir_version lead=1 follow=2
 ---
-> git_cwd_version follow=2-2
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 failed with value 1
+> git_dir_version lead=x follow=x
 ---
-> git_cwd_version name=
-git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
 ---
-> git_cwd_version name="$(git_cwd_name)"
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_dir_version name="$(git_name)"
 ---
-> git_cwd_vcs
+> git_dir_vcs
 ---
-> git_cwd_vcs subtree=foo
+> git_dir_vcs subtree=foo
 ---
-> git_cwd_pack
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
+> git_dir_source_name
 ---
-> git_cwd_source_name name=foo
+> git_dir_source_name name=foo
 ---
-> git_cwd_source_name version=1.2
+> git_dir_source_name version=1.2
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_dir_changelog
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_dir_name
+> git_cwd_name
 ---
-> git_dir_name name=foo
+> git_cwd_name name=foo
 ---
-> git_dir_name name=foo append=foo-bar
+> git_cwd_name append=-baz
 ---
-> git_dir_name append=foo
+> git_cwd_name prepend=bar-
 ---
-> git_dir_name append=foo-bar
+> git_cwd_name prepend=bar- append=-baz
 ---
-> git_dir_version
+> git_cwd_name name=foo prepend=bar- append=-baz
 ---
-> git_dir_version name=foo
+> git_cwd_version
 ---
-> git_dir_version lead=1
+> git_cwd_version name=foo
 ---
-> git_dir_version lead=0.1
+> git_cwd_version name=foo lead=1
 ---
-> git_dir_version follow=2
+> git_cwd_version lead=0
 ---
-> git_dir_version lead=1 follow=2
+> git_cwd_version lead=1
 ---
-> git_dir_version lead=x follow=x
+> git_cwd_version lead=0.1
 ---
-> git_dir_version lead=1-1
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 failed with value 1
+> git_cwd_version follow=1
 ---
-> git_dir_version follow=2.0
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 failed with value 1
+> git_cwd_version lead=1 follow=2
 ---
-> git_dir_version follow=2-2
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 failed with value 1
+> git_cwd_version lead=x follow=x
 ---
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
+> git_cwd_version lead=1-1 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 # invalid failed with value 1
 ---
-> git_dir_version name="$(git_dir_name)"
+> git_cwd_version follow=2.0 # invalid
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_cwd_version follow=2-2 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_cwd_version name= # invalid
+git_cwd_version: name cannot be empty.
+git_cwd_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_cwd_version name="$(git_cwd_name)"
 ---
-> git_dir_vcs
+> git_cwd_vcs
 ---
-> git_dir_vcs subtree=foo
+> git_cwd_vcs subtree=foo
 ---
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
+> git_cwd_source_name
 ---
-> git_dir_source_name name=foo
+> git_cwd_source_name name=foo
 ---
-> git_dir_source_name version=1.2
+> git_cwd_source_name version=1.2
 ---
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_cwd_changelog
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
diff --git a/tests/preproc/test_inited_origin_set/output b/tests/preproc/test_inited_origin_set/output
index a4c8c83..ffa1d1f 100644
--- a/tests/preproc/test_inited_origin_set/output
+++ b/tests/preproc/test_inited_origin_set/output
@@ -1,40 +1,24 @@
 git_name: test
 git_name name=foo: foo
-git_name name=foo append=foo-bar: foo-foo-bar
-git_name append=foo: test-foo
-git_name append=foo-bar: test-foo-bar
-
-git_version: 0.0.wtree.zfxvuj
-git_version name=foo: 0.0.wtree.zfxvuj
-git_version lead=1: 1.0.wtree.zfxvuj
-git_version lead=0.1: 0.1.0.wtree.zfxvuj
-git_version follow=2: 0.2.wtree.zfxvuj
-git_version lead=1 follow=2: 1.2.wtree.zfxvuj
-git_version lead=x follow=x: x.x.wtree.zfxvuj
-git_version lead=1-1:  # invalid
-git_version follow=2.0:  # invalid
-git_version follow=2-2:  # invalid
-git_version name=:  # invalid
-
-git_version name="$(git_name)": 0.0.wtree.zfxvuj
-git_version echo 1.4: 1.4
-git_version echo -n 1; echo -n .; echo 4: 1.4
-git_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_bumped_version: 0.1
-git_bumped_version lead=1: 1.0
-git_bumped_version follow=2: 0.2
-git_bumped_version lead=1 follow=2: 1.2
-git_bumped_version lead=1 latest_tag_version=1.2: 1.3
-git_bumped_version follow=2 latest_tag_version=1.4: 0.2
-git_bumped_version latest_tag_version=1.2: 0.1
-git_bumped_version latest_tag_version=0.1.2: 0.1
-git_bumped_version latest_tag_version=1.x: 0.1
-git_bumped_version latest_tag_version=0.1.x: 0.1
-git_bumped_version latest_tag_version=0.1: 0.2
-git_bumped_version follow=2.0: 0.2.0 # invalid but works
-git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+git_name append=-baz: test-baz
+git_name prepend=bar-: bar-test
+git_name prepend=bar- append=-baz: bar-test-baz
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_version: 0.0.wtree.zf1ilg
+git_version name=foo: 0.0.wtree.zf1ilg
+git_version name=foo lead=1: 1.0.wtree.zf1ilg
+git_version lead=0: 0.0.wtree.zf1ilg
+git_version lead=1: 1.0.wtree.zf1ilg
+git_version lead=0.1: 0.1.0.wtree.zf1ilg
+git_version follow=1: 0.1.wtree.zf1ilg
+git_version lead=1 follow=2: 1.2.wtree.zf1ilg
+git_version lead=x follow=x: x.x.wtree.zf1ilg
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
+git_version name="$(git_name)": 0.0.wtree.zf1ilg
 
 git_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -49,9 +33,9 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: test-foo-bar-0.0.wtree.zfxvuj.tar.gz
-git_source_name name=foo: foo-0.0.wtree.zfxvuj.tar.gz
-git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name: bar-foo-baz-0.0.wtree.zf1ilg.tar.gz
+git_source_name name=foo: foo-0.0.wtree.zf1ilg.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_changelog:
@@ -69,120 +53,119 @@ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
 
-git_cwd_name: test
-git_cwd_name name=foo: foo
-git_cwd_name name=foo append=foo-bar: foo-foo-bar
-git_cwd_name append=foo: test-foo
-git_cwd_name append=foo-bar: test-foo-bar
+:::::::::::::::::::::
 
-git_cwd_version: 0.0.wtree.zfxvuj
-git_cwd_version name=foo: 0.0.wtree.zfxvuj
-git_cwd_version lead=1: 1.0.wtree.zfxvuj
-git_cwd_version lead=0.1: 0.1.0.wtree.zfxvuj
-git_cwd_version follow=2: 0.2.wtree.zfxvuj
-git_cwd_version lead=1 follow=2: 1.2.wtree.zfxvuj
-git_cwd_version lead=x follow=x: x.x.wtree.zfxvuj
-git_cwd_version lead=1-1:  # invalid
-git_cwd_version follow=2.0:  # invalid
-git_cwd_version follow=2-2:  # invalid
-git_cwd_version name=:  # invalid
+git_dir_name: test-
+git_dir_name name=foo: foo-
+git_dir_name append=-baz: test-baz
+git_dir_name prepend=bar-: bar-test-
+git_dir_name prepend=bar- append=-baz: bar-test-baz
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version name="$(git_name)": 0.0.wtree.zfxvuj
-git_cwd_version echo 1.4: 1.4
-git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+git_dir_version: 0.0.wtree.zf1ilg
+git_dir_version name=foo: 0.0.wtree.zf1ilg
+git_dir_version name=foo lead=1: 1.0.wtree.zf1ilg
+git_dir_version lead=0: 0.0.wtree.zf1ilg
+git_dir_version lead=1: 1.0.wtree.zf1ilg
+git_dir_version lead=0.1: 0.1.0.wtree.zf1ilg
+git_dir_version follow=1: 0.1.wtree.zf1ilg
+git_dir_version lead=1 follow=2: 1.2.wtree.zf1ilg
+git_dir_version lead=x follow=x: x.x.wtree.zf1ilg
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
+git_dir_version name="$(git_name)": 0.0.wtree.zf1ilg
 
+git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: test-foo-bar-0.0.wtree.zfxvuj.tar.gz
-git_cwd_source_name name=foo: foo-0.0.wtree.zfxvuj.tar.gz
-git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_source_name: bar-foo-baz-0.0.wtree.zf1ilg.tar.gz
+git_dir_source_name name=foo: foo-0.0.wtree.zf1ilg.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_dir_changelog:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1:
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
 
-git_dir_name: test
-git_dir_name name=foo: foo
-git_dir_name name=foo append=foo-bar: foo-foo-bar
-git_dir_name append=foo: test-foo
-git_dir_name append=foo-bar: test-foo-bar
+:::::::::::::::::::::
 
-git_dir_version: 0.0.wtree.zfxvuj
-git_dir_version name=foo: 0.0.wtree.zfxvuj
-git_dir_version lead=1: 1.0.wtree.zfxvuj
-git_dir_version lead=0.1: 0.1.0.wtree.zfxvuj
-git_dir_version follow=2: 0.2.wtree.zfxvuj
-git_dir_version lead=1 follow=2: 1.2.wtree.zfxvuj
-git_dir_version lead=x follow=x: x.x.wtree.zfxvuj
-git_dir_version lead=1-1:  # invalid
-git_dir_version follow=2.0:  # invalid
-git_dir_version follow=2-2:  # invalid
-git_dir_version name=:  # invalid
+git_cwd_name: test-
+git_cwd_name name=foo: foo-
+git_cwd_name append=-baz: test-baz
+git_cwd_name prepend=bar-: bar-test-
+git_cwd_name prepend=bar- append=-baz: bar-test-baz
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version name="$(git_name)": 0.0.wtree.zfxvuj
-git_dir_version echo 1.4: 1.4
-git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_dir_version date --date='@2147483647' %y%m%d: 380119
+git_cwd_version: 0.0.wtree.zf1ilg
+git_cwd_version name=foo: 0.0.wtree.zf1ilg
+git_cwd_version name=foo lead=1: 1.0.wtree.zf1ilg
+git_cwd_version lead=0: 0.0.wtree.zf1ilg
+git_cwd_version lead=1: 1.0.wtree.zf1ilg
+git_cwd_version lead=0.1: 0.1.0.wtree.zf1ilg
+git_cwd_version follow=1: 0.1.wtree.zf1ilg
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf1ilg
+git_cwd_version lead=x follow=x: x.x.wtree.zf1ilg
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf1ilg
 
+git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
-git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
-git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.wtree.zf1ilg.tar.gz
+git_cwd_source_name name=foo: foo-0.0.wtree.zf1ilg.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_source_name: test-foo-bar-0.0.wtree.zfxvuj.tar.gz
-git_dir_source_name name=foo: foo-0.0.wtree.zfxvuj.tar.gz
-git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_changelog:
 
-git_dir_changelog:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
 
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
diff --git a/tests/preproc/test_inited_origin_set/run.sh b/tests/preproc/test_inited_origin_set/run.sh
index 19a9cd9..05b64d8 100755
--- a/tests/preproc/test_inited_origin_set/run.sh
+++ b/tests/preproc/test_inited_origin_set/run.sh
@@ -5,7 +5,7 @@
 repo=`mktemp -d`
 output=`mktemp`
 
-cp ../input $repo
+prepare_input ../input $repo/input
 
 git init $repo
 git -C $repo remote add origin https://pagure.io/clime/test.git
diff --git a/tests/preproc/test_sources/run.sh b/tests/preproc/test_sources/run.sh
index f23008a..e295cc3 100755
--- a/tests/preproc/test_sources/run.sh
+++ b/tests/preproc/test_sources/run.sh
@@ -5,13 +5,23 @@
 repo=`mktemp -d`
 output=`mktemp`
 
-cp input $repo
+prepare_input input $repo/input
 git init $repo
 
 touch output && cp output $output
 wtree_sub $repo $output
 
-generic_test opts='' path=$repo input=$repo/input expected_output=$output expected_log=log expected_sources="foo.tar.gz" copy_only=$1
+function custom_test {
+    declare out= "$@"
+    local source_name="foo.tar.gz"
+
+    echo "Checking for presence of source $source_name."
+    if ! [ -f "$out/$source_name" ]; then
+        die
+    fi
+}
+
+generic_test opts='' path=$repo input=$repo/input expected_output=$output expected_log=log custom_test=custom_test copy_only=$1
 
 rm -rf $repo
 rm $output
diff --git a/tests/preproc/test_subdir/log b/tests/preproc/test_subdir/log
index e78c556..0e9bb1a 100644
--- a/tests/preproc/test_subdir/log
+++ b/tests/preproc/test_subdir/log
@@ -2,76 +2,50 @@
 ---
 > git_name name=foo
 ---
-> git_name name=foo append=foo-bar
+> git_name append=-baz
 ---
-> git_name append=foo
+> git_name prepend=bar-
 ---
-> git_name append=foo-bar
+> git_name prepend=bar- append=-baz
+---
+> git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
 ---
 > git_version name=foo
 ---
+> git_version name=foo lead=1
+---
+> git_version lead=0
+---
 > git_version lead=1
 ---
 > git_version lead=0.1
 ---
-> git_version follow=2
+> git_version follow=1
 ---
 > git_version lead=1 follow=2
 ---
 > git_version lead=x follow=x
 ---
-> git_version lead=1-1
+> git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 failed with value 1
+git_version lead=1-1 # invalid failed with value 1
 ---
-> git_version follow=2.0
+> git_version follow=2.0 # invalid
 git_version: follow cannot contain dots.
-git_version follow=2.0 failed with value 1
+git_version follow=2.0 # invalid failed with value 1
 ---
-> git_version follow=2-2
+> git_version follow=2-2 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 failed with value 1
+git_version follow=2-2 # invalid failed with value 1
 ---
-> git_version name=
+> git_version name= # invalid
 git_version: name cannot be empty.
-git_version name= failed with value 1
+git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
 > git_vcs
 ---
 > git_vcs subtree=foo
@@ -118,191 +92,191 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_cwd_name
+> git_dir_name
 ---
-> git_cwd_name name=foo
+> git_dir_name name=foo
 ---
-> git_cwd_name name=foo append=foo-bar
+> git_dir_name append=-baz
 ---
-> git_cwd_name append=foo
+> git_dir_name prepend=bar-
 ---
-> git_cwd_name append=foo-bar
+> git_dir_name prepend=bar- append=-baz
 ---
-> git_cwd_version
+> git_dir_name name=foo prepend=bar- append=-baz
 ---
-> git_cwd_version name=foo
+> git_dir_version
 ---
-> git_cwd_version lead=1
+> git_dir_version name=foo
 ---
-> git_cwd_version lead=0.1
+> git_dir_version name=foo lead=1
 ---
-> git_cwd_version follow=2
+> git_dir_version lead=0
 ---
-> git_cwd_version lead=1 follow=2
+> git_dir_version lead=1
 ---
-> git_cwd_version lead=x follow=x
+> git_dir_version lead=0.1
 ---
-> git_cwd_version lead=1-1
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 failed with value 1
+> git_dir_version follow=1
 ---
-> git_cwd_version follow=2.0
-git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 failed with value 1
+> git_dir_version lead=1 follow=2
 ---
-> git_cwd_version follow=2-2
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 failed with value 1
+> git_dir_version lead=x follow=x
 ---
-> git_cwd_version name=
-git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
 ---
-> git_cwd_version name="$(git_cwd_name)"
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_dir_version name="$(git_name)"
 ---
-> git_cwd_vcs
+> git_dir_vcs
 ---
-> git_cwd_vcs subtree=foo
+> git_dir_vcs subtree=foo
 ---
-> git_cwd_pack
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
+> git_dir_source_name
 ---
-> git_cwd_source_name name=foo
+> git_dir_source_name name=foo
 ---
-> git_cwd_source_name version=1.2
+> git_dir_source_name version=1.2
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_dir_changelog
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_dir_name
+> git_cwd_name
 ---
-> git_dir_name name=foo
+> git_cwd_name name=foo
 ---
-> git_dir_name name=foo append=foo-bar
+> git_cwd_name append=-baz
 ---
-> git_dir_name append=foo
+> git_cwd_name prepend=bar-
 ---
-> git_dir_name append=foo-bar
+> git_cwd_name prepend=bar- append=-baz
 ---
-> git_dir_version
+> git_cwd_name name=foo prepend=bar- append=-baz
 ---
-> git_dir_version name=foo
+> git_cwd_version
 ---
-> git_dir_version lead=1
+> git_cwd_version name=foo
 ---
-> git_dir_version lead=0.1
+> git_cwd_version name=foo lead=1
 ---
-> git_dir_version follow=2
+> git_cwd_version lead=0
 ---
-> git_dir_version lead=1 follow=2
+> git_cwd_version lead=1
 ---
-> git_dir_version lead=x follow=x
+> git_cwd_version lead=0.1
 ---
-> git_dir_version lead=1-1
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 failed with value 1
+> git_cwd_version follow=1
 ---
-> git_dir_version follow=2.0
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 failed with value 1
+> git_cwd_version lead=1 follow=2
 ---
-> git_dir_version follow=2-2
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 failed with value 1
+> git_cwd_version lead=x follow=x
 ---
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
+> git_cwd_version lead=1-1 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 # invalid failed with value 1
 ---
-> git_dir_version name="$(git_dir_name)"
+> git_cwd_version follow=2.0 # invalid
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_cwd_version follow=2-2 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_cwd_version name= # invalid
+git_cwd_version: name cannot be empty.
+git_cwd_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_cwd_version name="$(git_cwd_name)"
 ---
-> git_dir_vcs
+> git_cwd_vcs
 ---
-> git_dir_vcs subtree=foo
+> git_cwd_vcs subtree=foo
 ---
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
+> git_cwd_source_name
 ---
-> git_dir_source_name name=foo
+> git_cwd_source_name name=foo
 ---
-> git_dir_source_name version=1.2
+> git_cwd_source_name version=1.2
 ---
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_cwd_changelog
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
diff --git a/tests/preproc/test_subdir/output b/tests/preproc/test_subdir/output
index 70d9b87..9686478 100644
--- a/tests/preproc/test_subdir/output
+++ b/tests/preproc/test_subdir/output
@@ -1,40 +1,24 @@
 git_name: test
 git_name name=foo: foo
-git_name name=foo append=foo-bar: foo-foo-bar
-git_name append=foo: test-foo
-git_name append=foo-bar: test-foo-bar
-
-git_version: 0.0.wtree.zfxvum
-git_version name=foo: 0.0.wtree.zfxvum
-git_version lead=1: 1.0.wtree.zfxvum
-git_version lead=0.1: 0.1.0.wtree.zfxvum
-git_version follow=2: 0.2.wtree.zfxvum
-git_version lead=1 follow=2: 1.2.wtree.zfxvum
-git_version lead=x follow=x: x.x.wtree.zfxvum
-git_version lead=1-1:  # invalid
-git_version follow=2.0:  # invalid
-git_version follow=2-2:  # invalid
-git_version name=:  # invalid
-
-git_version name="$(git_name)": 0.0.wtree.zfxvum
-git_version echo 1.4: 1.4
-git_version echo -n 1; echo -n .; echo 4: 1.4
-git_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_bumped_version: 0.1
-git_bumped_version lead=1: 1.0
-git_bumped_version follow=2: 0.2
-git_bumped_version lead=1 follow=2: 1.2
-git_bumped_version lead=1 latest_tag_version=1.2: 1.3
-git_bumped_version follow=2 latest_tag_version=1.4: 0.2
-git_bumped_version latest_tag_version=1.2: 0.1
-git_bumped_version latest_tag_version=0.1.2: 0.1
-git_bumped_version latest_tag_version=1.x: 0.1
-git_bumped_version latest_tag_version=0.1.x: 0.1
-git_bumped_version latest_tag_version=0.1: 0.2
-git_bumped_version follow=2.0: 0.2.0 # invalid but works
-git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
+git_name append=-baz: test-baz
+git_name prepend=bar-: bar-test
+git_name prepend=bar- append=-baz: bar-test-baz
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_version: 0.0.wtree.zf1ilj
+git_version name=foo: 0.0.wtree.zf1ilj
+git_version name=foo lead=1: 1.0.wtree.zf1ilj
+git_version lead=0: 0.0.wtree.zf1ilj
+git_version lead=1: 1.0.wtree.zf1ilj
+git_version lead=0.1: 0.1.0.wtree.zf1ilj
+git_version follow=1: 0.1.wtree.zf1ilj
+git_version lead=1 follow=2: 1.2.wtree.zf1ilj
+git_version lead=x follow=x: x.x.wtree.zf1ilj
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
+git_version name="$(git_name)": 0.0.wtree.zf1ilj
 
 git_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -49,9 +33,9 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: test-foo-bar-0.0.wtree.zfxvum.tar.gz
-git_source_name name=foo: foo-0.0.wtree.zfxvum.tar.gz
-git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name: bar-foo-baz-0.0.wtree.zf1ilj.tar.gz
+git_source_name name=foo: foo-0.0.wtree.zf1ilj.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_changelog:
@@ -69,90 +53,30 @@ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
 
-git_cwd_name: test-subdir1
-git_cwd_name name=foo: foo-subdir1
-git_cwd_name name=foo append=foo-bar: foo-foo-bar
-git_cwd_name append=foo: test-foo
-git_cwd_name append=foo-bar: test-foo-bar
-
-git_cwd_version: 0.0.wtree.zfxvum
-git_cwd_version name=foo: 0.0.wtree.zfxvum
-git_cwd_version lead=1: 1.0.wtree.zfxvum
-git_cwd_version lead=0.1: 0.1.0.wtree.zfxvum
-git_cwd_version follow=2: 0.2.wtree.zfxvum
-git_cwd_version lead=1 follow=2: 1.2.wtree.zfxvum
-git_cwd_version lead=x follow=x: x.x.wtree.zfxvum
-git_cwd_version lead=1-1:  # invalid
-git_cwd_version follow=2.0:  # invalid
-git_cwd_version follow=2-2:  # invalid
-git_cwd_version name=:  # invalid
-
-git_cwd_version name="$(git_name)": 0.0.wtree.zfxvum
-git_cwd_version echo 1.4: 1.4
-git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_cwd_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir1/
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_cwd_source_name: test-foo-bar-0.0.wtree.zfxvum.tar.gz
-git_cwd_source_name name=foo: foo-0.0.wtree.zfxvum.tar.gz
-git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
-
-git_cwd_changelog:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
-
-
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-
-
----
+:::::::::::::::::::::
 
 git_dir_name: test-subdir2
 git_dir_name name=foo: foo-subdir2
-git_dir_name name=foo append=foo-bar: foo-foo-bar
-git_dir_name append=foo: test-foo
-git_dir_name append=foo-bar: test-foo-bar
-
-git_dir_version: 0.0.wtree.zfxvum
-git_dir_version name=foo: 0.0.wtree.zfxvum
-git_dir_version lead=1: 1.0.wtree.zfxvum
-git_dir_version lead=0.1: 0.1.0.wtree.zfxvum
-git_dir_version follow=2: 0.2.wtree.zfxvum
-git_dir_version lead=1 follow=2: 1.2.wtree.zfxvum
-git_dir_version lead=x follow=x: x.x.wtree.zfxvum
-git_dir_version lead=1-1:  # invalid
-git_dir_version follow=2.0:  # invalid
-git_dir_version follow=2-2:  # invalid
-git_dir_version name=:  # invalid
-
-git_dir_version name="$(git_name)": 0.0.wtree.zfxvum
-git_dir_version echo 1.4: 1.4
-git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_dir_version date --date='@2147483647' %y%m%d: 380119
-
+git_dir_name append=-baz: test-baz
+git_dir_name prepend=bar-: bar-test-subdir2
+git_dir_name prepend=bar- append=-baz: bar-test-baz
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_dir_version: 0.0.wtree.zf1ilj
+git_dir_version name=foo: 0.0.wtree.zf1ilj
+git_dir_version name=foo lead=1: 1.0.wtree.zf1ilj
+git_dir_version lead=0: 0.0.wtree.zf1ilj
+git_dir_version lead=1: 1.0.wtree.zf1ilj
+git_dir_version lead=0.1: 0.1.0.wtree.zf1ilj
+git_dir_version follow=1: 0.1.wtree.zf1ilj
+git_dir_version lead=1 follow=2: 1.2.wtree.zf1ilj
+git_dir_version lead=x follow=x: x.x.wtree.zf1ilj
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
+git_dir_version name="$(git_name)": 0.0.wtree.zf1ilj
 
 git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir2/
 git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -167,9 +91,9 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: test-foo-bar-0.0.wtree.zfxvum.tar.gz
-git_dir_source_name name=foo: foo-0.0.wtree.zfxvum.tar.gz
-git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_dir_source_name: bar-foo-baz-0.0.wtree.zf1ilj.tar.gz
+git_dir_source_name name=foo: foo-0.0.wtree.zf1ilj.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_dir_changelog:
@@ -186,3 +110,62 @@ git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
 git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
+
+
+:::::::::::::::::::::
+
+git_cwd_name: test-subdir1
+git_cwd_name name=foo: foo-subdir1
+git_cwd_name append=-baz: test-baz
+git_cwd_name prepend=bar-: bar-test-subdir1
+git_cwd_name prepend=bar- append=-baz: bar-test-baz
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_cwd_version: 0.0.wtree.zf1ilj
+git_cwd_version name=foo: 0.0.wtree.zf1ilj
+git_cwd_version name=foo lead=1: 1.0.wtree.zf1ilj
+git_cwd_version lead=0: 0.0.wtree.zf1ilj
+git_cwd_version lead=1: 1.0.wtree.zf1ilj
+git_cwd_version lead=0.1: 0.1.0.wtree.zf1ilj
+git_cwd_version follow=1: 0.1.wtree.zf1ilj
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf1ilj
+git_cwd_version lead=x follow=x: x.x.wtree.zf1ilj
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf1ilj
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir1/
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: bar-foo-baz-0.0.wtree.zf1ilj.tar.gz
+git_cwd_source_name name=foo: foo-0.0.wtree.zf1ilj.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
diff --git a/tests/preproc/test_subdir/run.sh b/tests/preproc/test_subdir/run.sh
index 9374763..4c8baa1 100755
--- a/tests/preproc/test_subdir/run.sh
+++ b/tests/preproc/test_subdir/run.sh
@@ -6,7 +6,7 @@ repo=`mktemp -d`
 output=`mktemp`
 
 mkdir $repo/subdir1 $repo/subdir2
-cp ../input $repo/subdir2/
+prepare_input ../input $repo/subdir2/input
 
 git init $repo
 git -C $repo remote add origin https://pagure.io/clime/test.git
diff --git a/tests/preproc/test_tagged/log b/tests/preproc/test_tagged/log
index e78c556..0e9bb1a 100644
--- a/tests/preproc/test_tagged/log
+++ b/tests/preproc/test_tagged/log
@@ -2,76 +2,50 @@
 ---
 > git_name name=foo
 ---
-> git_name name=foo append=foo-bar
+> git_name append=-baz
 ---
-> git_name append=foo
+> git_name prepend=bar-
 ---
-> git_name append=foo-bar
+> git_name prepend=bar- append=-baz
+---
+> git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
 ---
 > git_version name=foo
 ---
+> git_version name=foo lead=1
+---
+> git_version lead=0
+---
 > git_version lead=1
 ---
 > git_version lead=0.1
 ---
-> git_version follow=2
+> git_version follow=1
 ---
 > git_version lead=1 follow=2
 ---
 > git_version lead=x follow=x
 ---
-> git_version lead=1-1
+> git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 failed with value 1
+git_version lead=1-1 # invalid failed with value 1
 ---
-> git_version follow=2.0
+> git_version follow=2.0 # invalid
 git_version: follow cannot contain dots.
-git_version follow=2.0 failed with value 1
+git_version follow=2.0 # invalid failed with value 1
 ---
-> git_version follow=2-2
+> git_version follow=2-2 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 failed with value 1
+git_version follow=2-2 # invalid failed with value 1
 ---
-> git_version name=
+> git_version name= # invalid
 git_version: name cannot be empty.
-git_version name= failed with value 1
+git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
 > git_vcs
 ---
 > git_vcs subtree=foo
@@ -118,191 +92,191 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_cwd_name
+> git_dir_name
 ---
-> git_cwd_name name=foo
+> git_dir_name name=foo
 ---
-> git_cwd_name name=foo append=foo-bar
+> git_dir_name append=-baz
 ---
-> git_cwd_name append=foo
+> git_dir_name prepend=bar-
 ---
-> git_cwd_name append=foo-bar
+> git_dir_name prepend=bar- append=-baz
 ---
-> git_cwd_version
+> git_dir_name name=foo prepend=bar- append=-baz
 ---
-> git_cwd_version name=foo
+> git_dir_version
 ---
-> git_cwd_version lead=1
+> git_dir_version name=foo
 ---
-> git_cwd_version lead=0.1
+> git_dir_version name=foo lead=1
 ---
-> git_cwd_version follow=2
+> git_dir_version lead=0
 ---
-> git_cwd_version lead=1 follow=2
+> git_dir_version lead=1
 ---
-> git_cwd_version lead=x follow=x
+> git_dir_version lead=0.1
 ---
-> git_cwd_version lead=1-1
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 failed with value 1
+> git_dir_version follow=1
 ---
-> git_cwd_version follow=2.0
-git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 failed with value 1
+> git_dir_version lead=1 follow=2
 ---
-> git_cwd_version follow=2-2
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 failed with value 1
+> git_dir_version lead=x follow=x
 ---
-> git_cwd_version name=
-git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
 ---
-> git_cwd_version name="$(git_cwd_name)"
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_dir_version name="$(git_name)"
 ---
-> git_cwd_vcs
+> git_dir_vcs
 ---
-> git_cwd_vcs subtree=foo
+> git_dir_vcs subtree=foo
 ---
-> git_cwd_pack
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
+> git_dir_source_name
 ---
-> git_cwd_source_name name=foo
+> git_dir_source_name name=foo
 ---
-> git_cwd_source_name version=1.2
+> git_dir_source_name version=1.2
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_dir_changelog
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_dir_name
+> git_cwd_name
 ---
-> git_dir_name name=foo
+> git_cwd_name name=foo
 ---
-> git_dir_name name=foo append=foo-bar
+> git_cwd_name append=-baz
 ---
-> git_dir_name append=foo
+> git_cwd_name prepend=bar-
 ---
-> git_dir_name append=foo-bar
+> git_cwd_name prepend=bar- append=-baz
 ---
-> git_dir_version
+> git_cwd_name name=foo prepend=bar- append=-baz
 ---
-> git_dir_version name=foo
+> git_cwd_version
 ---
-> git_dir_version lead=1
+> git_cwd_version name=foo
 ---
-> git_dir_version lead=0.1
+> git_cwd_version name=foo lead=1
 ---
-> git_dir_version follow=2
+> git_cwd_version lead=0
 ---
-> git_dir_version lead=1 follow=2
+> git_cwd_version lead=1
 ---
-> git_dir_version lead=x follow=x
+> git_cwd_version lead=0.1
 ---
-> git_dir_version lead=1-1
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 failed with value 1
+> git_cwd_version follow=1
 ---
-> git_dir_version follow=2.0
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 failed with value 1
+> git_cwd_version lead=1 follow=2
 ---
-> git_dir_version follow=2-2
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 failed with value 1
+> git_cwd_version lead=x follow=x
 ---
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
+> git_cwd_version lead=1-1 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 # invalid failed with value 1
 ---
-> git_dir_version name="$(git_dir_name)"
+> git_cwd_version follow=2.0 # invalid
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_cwd_version follow=2-2 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_cwd_version name= # invalid
+git_cwd_version: name cannot be empty.
+git_cwd_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_cwd_version name="$(git_cwd_name)"
 ---
-> git_dir_vcs
+> git_cwd_vcs
 ---
-> git_dir_vcs subtree=foo
+> git_cwd_vcs subtree=foo
 ---
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
+> git_cwd_source_name
 ---
-> git_dir_source_name name=foo
+> git_cwd_source_name name=foo
 ---
-> git_dir_source_name version=1.2
+> git_cwd_source_name version=1.2
 ---
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_cwd_changelog
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
diff --git a/tests/preproc/test_tagged/output b/tests/preproc/test_tagged/output
index 0a54d80..8c581f1 100644
--- a/tests/preproc/test_tagged/output
+++ b/tests/preproc/test_tagged/output
@@ -1,43 +1,27 @@
 git_name: test
 git_name name=foo: foo
-git_name name=foo append=foo-bar: foo-foo-bar
-git_name append=foo: test-foo
-git_name append=foo-bar: test-foo-bar
+git_name append=-baz: test-baz
+git_name prepend=bar-: bar-test
+git_name prepend=bar- append=-baz: bar-test-baz
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.git.1.be51f06
+git_version: 0.0.git.1.e76bf76
 git_version name=foo: 0.0
-git_version lead=1: 1.0.git.1.be51f06
-git_version lead=0.1: 0.1.0.git.1.be51f06
-git_version follow=2: 0.2.git.1.be51f06
-git_version lead=1 follow=2: 1.2.git.1.be51f06
-git_version lead=x follow=x: x.x.git.1.be51f06
-git_version lead=1-1:  # invalid
-git_version follow=2.0:  # invalid
-git_version follow=2-2:  # invalid
-git_version name=:  # invalid
-
-git_version name="$(git_name)": 0.0.git.1.be51f06
-git_version echo 1.4: 1.4
-git_version echo -n 1; echo -n .; echo 4: 1.4
-git_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_bumped_version: 0.1
-git_bumped_version lead=1: 1.0
-git_bumped_version follow=2: 0.2
-git_bumped_version lead=1 follow=2: 1.2
-git_bumped_version lead=1 latest_tag_version=1.2: 1.3
-git_bumped_version follow=2 latest_tag_version=1.4: 0.2
-git_bumped_version latest_tag_version=1.2: 0.1
-git_bumped_version latest_tag_version=0.1.2: 0.1
-git_bumped_version latest_tag_version=1.x: 0.1
-git_bumped_version latest_tag_version=0.1.x: 0.1
-git_bumped_version latest_tag_version=0.1: 0.2
-git_bumped_version follow=2.0: 0.2.0 # invalid but works
-git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
-
-git_vcs: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:foo
+git_version name=foo lead=1: 1.5
+git_version lead=0: 0.0.git.1.e76bf76
+git_version lead=1: 1.0.git.1.e76bf76
+git_version lead=0.1: 0.1.0.git.1.e76bf76
+git_version follow=1: 0.1.git.1.e76bf76
+git_version lead=1 follow=2: 1.2.git.1.e76bf76
+git_version lead=x follow=x: x.x.git.1.e76bf76
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
+git_version name="$(git_name)": 0.0.git.1.e76bf76
+
+git_vcs: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:foo
 
 git_pack: 
 git_pack dir_name=foo: 
@@ -49,278 +33,238 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: test-foo-bar-0.0.git.1.be51f06.tar.gz
-git_source_name name=foo: foo-0.0.git.1.be51f06.tar.gz
-git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name: bar-foo-baz-0.0.git.1.e76bf76.tar.gz
+git_source_name name=foo: foo-0.0.git.1.e76bf76.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_changelog:
 
 
 git_changelog name=foo since_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.5-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.5-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long because we need to test git changelog
+family of macros and changelong body wrapping.
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
 git_changelog name=foo until_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.1-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.1-1
+- message
 
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long because we need to test git changelog
+family of macros and changelong body wrapping.
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.4-1
-- message that should be very long
-because we need to test git changelog
-family of macros and changelong body
-wrapping.
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.4-1
+- message
 
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.3-1
-- message that should be very long
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long
 because we need to test git changelog
 family of macros and changelong body
 wrapping.
 
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.2-1
-- message that should be very long
-because we need to test git changelog
-family of macros and changelong body
-wrapping.
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.2-1
+- message
 
----
 
-git_cwd_name: test
-git_cwd_name name=foo: foo
-git_cwd_name name=foo append=foo-bar: foo-foo-bar
-git_cwd_name append=foo: test-foo
-git_cwd_name append=foo-bar: test-foo-bar
-
-git_cwd_version: 0.0.git.1.be51f06
-git_cwd_version name=foo: 0.0
-git_cwd_version lead=1: 1.0.git.1.be51f06
-git_cwd_version lead=0.1: 0.1.0.git.1.be51f06
-git_cwd_version follow=2: 0.2.git.1.be51f06
-git_cwd_version lead=1 follow=2: 1.2.git.1.be51f06
-git_cwd_version lead=x follow=x: x.x.git.1.be51f06
-git_cwd_version lead=1-1:  # invalid
-git_cwd_version follow=2.0:  # invalid
-git_cwd_version follow=2-2:  # invalid
-git_cwd_version name=:  # invalid
-
-git_cwd_version name="$(git_name)": 0.0.git.1.be51f06
-git_cwd_version echo 1.4: 1.4
-git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+:::::::::::::::::::::
 
+git_dir_name: test-
+git_dir_name name=foo: foo-
+git_dir_name append=-baz: test-baz
+git_dir_name prepend=bar-: bar-test-
+git_dir_name prepend=bar- append=-baz: bar-test-baz
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:foo
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_version: 0.0.git.1.e76bf76
+git_dir_version name=foo: 0.0
+git_dir_version name=foo lead=1: 1.5
+git_dir_version lead=0: 0.0.git.1.e76bf76
+git_dir_version lead=1: 1.0.git.1.e76bf76
+git_dir_version lead=0.1: 0.1.0.git.1.e76bf76
+git_dir_version follow=1: 0.1.git.1.e76bf76
+git_dir_version lead=1 follow=2: 1.2.git.1.e76bf76
+git_dir_version lead=x follow=x: x.x.git.1.e76bf76
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
+git_dir_version name="$(git_name)": 0.0.git.1.e76bf76
+
+git_dir_vcs: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:foo
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: test-foo-bar-0.0.git.1.be51f06.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.1.be51f06.tar.gz
-git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_changelog:
+git_dir_source_name: bar-foo-baz-0.0.git.1.e76bf76.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.1.e76bf76.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
+git_dir_changelog:
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.5-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.5-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long because we need to test git changelog
+family of macros and changelong body wrapping.
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.1-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+git_dir_changelog name=foo until_tag=foo-1.2-1:
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.1-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long because we need to test git changelog
+family of macros and changelong body wrapping.
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.4-1
-- message that should be very long
-because we need to test git changelog
-family of macros and changelong body
-wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.3-1
-- message that should be very long
-because we need to test git changelog
-family of macros and changelong body
-wrapping.
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.4-1
+- message
 
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.2-1
-- message that should be very long
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long
 because we need to test git changelog
 family of macros and changelong body
 wrapping.
 
----
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.2-1
+- message
 
-git_dir_name: test
-git_dir_name name=foo: foo
-git_dir_name name=foo append=foo-bar: foo-foo-bar
-git_dir_name append=foo: test-foo
-git_dir_name append=foo-bar: test-foo-bar
 
-git_dir_version: 0.0.git.1.be51f06
-git_dir_version name=foo: 0.0
-git_dir_version lead=1: 1.0.git.1.be51f06
-git_dir_version lead=0.1: 0.1.0.git.1.be51f06
-git_dir_version follow=2: 0.2.git.1.be51f06
-git_dir_version lead=1 follow=2: 1.2.git.1.be51f06
-git_dir_version lead=x follow=x: x.x.git.1.be51f06
-git_dir_version lead=1-1:  # invalid
-git_dir_version follow=2.0:  # invalid
-git_dir_version follow=2-2:  # invalid
-git_dir_version name=:  # invalid
+:::::::::::::::::::::
 
-git_dir_version name="$(git_name)": 0.0.git.1.be51f06
-git_dir_version echo 1.4: 1.4
-git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_dir_version date --date='@2147483647' %y%m%d: 380119
+git_cwd_name: test-
+git_cwd_name name=foo: foo-
+git_cwd_name append=-baz: test-baz
+git_cwd_name prepend=bar-: bar-test-
+git_cwd_name prepend=bar- append=-baz: bar-test-baz
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
+git_cwd_version: 0.0.git.1.e76bf76
+git_cwd_version name=foo: 0.0
+git_cwd_version name=foo lead=1: 1.5
+git_cwd_version lead=0: 0.0.git.1.e76bf76
+git_cwd_version lead=1: 1.0.git.1.e76bf76
+git_cwd_version lead=0.1: 0.1.0.git.1.e76bf76
+git_cwd_version follow=1: 0.1.git.1.e76bf76
+git_cwd_version lead=1 follow=2: 1.2.git.1.e76bf76
+git_cwd_version lead=x follow=x: x.x.git.1.e76bf76
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 0.0.git.1.e76bf76
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:foo
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#be51f06b05e241e54eaf8ccbeb29aba2ce1a44c9:foo
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
-git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
-git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.git.1.e76bf76.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.1.e76bf76.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_source_name: test-foo-bar-0.0.git.1.be51f06.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.1.be51f06.tar.gz
-git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_changelog:
 
-git_dir_changelog:
 
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.5-1
+- message
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.5-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long because we need to test git changelog
+family of macros and changelong body wrapping.
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.1-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.1-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+- message
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.4-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long because we need to test git changelog
+family of macros and changelong body wrapping.
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.3-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+- message
 
-* Thu Mar 15 2018 clime <clime@redhat.com> 1.2-1
-- message that should be very long because we need to test git changelog family
-of macros and changelong body wrapping.
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.4-1
+- message
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.4-1
-- message that should be very long
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.3-1
+- message that should be %%very long
 because we need to test git changelog
 family of macros and changelong body
 wrapping.
 
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.3-1
-- message that should be very long
-because we need to test git changelog
-family of macros and changelong body
-wrapping.
+* 2018 Sat Mar 17 clime <clime@redhat.com> 1.2-1
+- message
 
-* 2018 Thu Mar 15 clime <clime@redhat.com> 1.2-1
-- message that should be very long
-because we need to test git changelog
-family of macros and changelong body
-wrapping.
diff --git a/tests/preproc/test_tagged/run.sh b/tests/preproc/test_tagged/run.sh
index d26e476..f953307 100755
--- a/tests/preproc/test_tagged/run.sh
+++ b/tests/preproc/test_tagged/run.sh
@@ -5,17 +5,17 @@
 repo=`mktemp -d`
 output=`mktemp`
 
-cp ../input $repo
+prepare_input ../input $repo/input
 
 git init $repo
 git -C $repo remote add origin https://pagure.io/clime/test.git
 git -C $repo add -A
 git -C $repo commit -a -m 'inital_commit'
-git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.1-1
-git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.2-1
-git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.3-1
-git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.4-1
-git -C $repo tag -a -m 'subject' -m '- message that should be very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.5-1
+git -C $repo tag -a -m 'subject' -m '- message' foo-1.1-1
+git -C $repo tag -a -m 'subject' -m '- message' foo-1.2-1
+git -C $repo tag -a -m 'subject' -m '- message that should be %very long because we need to test git changelog family of macros and changelong body wrapping.' foo-1.3-1
+git -C $repo tag -a -m 'subject' -m '- message' foo-1.4-1
+git -C $repo tag -a -m 'subject' -m '- message' foo-1.5-1
 
 touch output && cp output $output
 wtree_sub $repo $output
diff --git a/tests/preproc/test_tagged_commited/log b/tests/preproc/test_tagged_commited/log
index e78c556..0e9bb1a 100644
--- a/tests/preproc/test_tagged_commited/log
+++ b/tests/preproc/test_tagged_commited/log
@@ -2,76 +2,50 @@
 ---
 > git_name name=foo
 ---
-> git_name name=foo append=foo-bar
+> git_name append=-baz
 ---
-> git_name append=foo
+> git_name prepend=bar-
 ---
-> git_name append=foo-bar
+> git_name prepend=bar- append=-baz
+---
+> git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
 ---
 > git_version name=foo
 ---
+> git_version name=foo lead=1
+---
+> git_version lead=0
+---
 > git_version lead=1
 ---
 > git_version lead=0.1
 ---
-> git_version follow=2
+> git_version follow=1
 ---
 > git_version lead=1 follow=2
 ---
 > git_version lead=x follow=x
 ---
-> git_version lead=1-1
+> git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 failed with value 1
+git_version lead=1-1 # invalid failed with value 1
 ---
-> git_version follow=2.0
+> git_version follow=2.0 # invalid
 git_version: follow cannot contain dots.
-git_version follow=2.0 failed with value 1
+git_version follow=2.0 # invalid failed with value 1
 ---
-> git_version follow=2-2
+> git_version follow=2-2 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 failed with value 1
+git_version follow=2-2 # invalid failed with value 1
 ---
-> git_version name=
+> git_version name= # invalid
 git_version: name cannot be empty.
-git_version name= failed with value 1
+git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
 > git_vcs
 ---
 > git_vcs subtree=foo
@@ -118,191 +92,191 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_cwd_name
+> git_dir_name
 ---
-> git_cwd_name name=foo
+> git_dir_name name=foo
 ---
-> git_cwd_name name=foo append=foo-bar
+> git_dir_name append=-baz
 ---
-> git_cwd_name append=foo
+> git_dir_name prepend=bar-
 ---
-> git_cwd_name append=foo-bar
+> git_dir_name prepend=bar- append=-baz
 ---
-> git_cwd_version
+> git_dir_name name=foo prepend=bar- append=-baz
 ---
-> git_cwd_version name=foo
+> git_dir_version
 ---
-> git_cwd_version lead=1
+> git_dir_version name=foo
 ---
-> git_cwd_version lead=0.1
+> git_dir_version name=foo lead=1
 ---
-> git_cwd_version follow=2
+> git_dir_version lead=0
 ---
-> git_cwd_version lead=1 follow=2
+> git_dir_version lead=1
 ---
-> git_cwd_version lead=x follow=x
+> git_dir_version lead=0.1
 ---
-> git_cwd_version lead=1-1
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 failed with value 1
+> git_dir_version follow=1
 ---
-> git_cwd_version follow=2.0
-git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 failed with value 1
+> git_dir_version lead=1 follow=2
 ---
-> git_cwd_version follow=2-2
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 failed with value 1
+> git_dir_version lead=x follow=x
 ---
-> git_cwd_version name=
-git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
 ---
-> git_cwd_version name="$(git_cwd_name)"
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_dir_version name="$(git_name)"
 ---
-> git_cwd_vcs
+> git_dir_vcs
 ---
-> git_cwd_vcs subtree=foo
+> git_dir_vcs subtree=foo
 ---
-> git_cwd_pack
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
+> git_dir_source_name
 ---
-> git_cwd_source_name name=foo
+> git_dir_source_name name=foo
 ---
-> git_cwd_source_name version=1.2
+> git_dir_source_name version=1.2
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_dir_changelog
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_dir_name
+> git_cwd_name
 ---
-> git_dir_name name=foo
+> git_cwd_name name=foo
 ---
-> git_dir_name name=foo append=foo-bar
+> git_cwd_name append=-baz
 ---
-> git_dir_name append=foo
+> git_cwd_name prepend=bar-
 ---
-> git_dir_name append=foo-bar
+> git_cwd_name prepend=bar- append=-baz
 ---
-> git_dir_version
+> git_cwd_name name=foo prepend=bar- append=-baz
 ---
-> git_dir_version name=foo
+> git_cwd_version
 ---
-> git_dir_version lead=1
+> git_cwd_version name=foo
 ---
-> git_dir_version lead=0.1
+> git_cwd_version name=foo lead=1
 ---
-> git_dir_version follow=2
+> git_cwd_version lead=0
 ---
-> git_dir_version lead=1 follow=2
+> git_cwd_version lead=1
 ---
-> git_dir_version lead=x follow=x
+> git_cwd_version lead=0.1
 ---
-> git_dir_version lead=1-1
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 failed with value 1
+> git_cwd_version follow=1
 ---
-> git_dir_version follow=2.0
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 failed with value 1
+> git_cwd_version lead=1 follow=2
 ---
-> git_dir_version follow=2-2
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 failed with value 1
+> git_cwd_version lead=x follow=x
 ---
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
+> git_cwd_version lead=1-1 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 # invalid failed with value 1
 ---
-> git_dir_version name="$(git_dir_name)"
+> git_cwd_version follow=2.0 # invalid
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1.4
+> git_cwd_version follow=2-2 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_cwd_version name= # invalid
+git_cwd_version: name cannot be empty.
+git_cwd_version name= # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_cwd_version name="$(git_cwd_name)"
 ---
-> git_dir_vcs
+> git_cwd_vcs
 ---
-> git_dir_vcs subtree=foo
+> git_cwd_vcs subtree=foo
 ---
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
+> git_cwd_source_name
 ---
-> git_dir_source_name name=foo
+> git_cwd_source_name name=foo
 ---
-> git_dir_source_name version=1.2
+> git_cwd_source_name version=1.2
 ---
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_cwd_changelog
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
diff --git a/tests/preproc/test_tagged_commited/output b/tests/preproc/test_tagged_commited/output
index 763716d..6049835 100644
--- a/tests/preproc/test_tagged_commited/output
+++ b/tests/preproc/test_tagged_commited/output
@@ -1,43 +1,27 @@
 git_name: test
 git_name name=foo: foo
-git_name name=foo append=foo-bar: foo-foo-bar
-git_name append=foo: test-foo
-git_name append=foo-bar: test-foo-bar
-
-git_version: 0.0.git.2.4e08997
-git_version name=foo: 0.1.git.1.4e08997
-git_version lead=1: 1.0.git.2.4e08997
-git_version lead=0.1: 0.1.0.git.2.4e08997
-git_version follow=2: 0.2.git.2.4e08997
-git_version lead=1 follow=2: 1.2.git.2.4e08997
-git_version lead=x follow=x: x.x.git.2.4e08997
-git_version lead=1-1:  # invalid
-git_version follow=2.0:  # invalid
-git_version follow=2-2:  # invalid
-git_version name=:  # invalid
-
-git_version name="$(git_name)": 0.0.git.2.4e08997
-git_version echo 1.4: 1.4
-git_version echo -n 1; echo -n .; echo 4: 1.4
-git_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_bumped_version: 0.1
-git_bumped_version lead=1: 1.0
-git_bumped_version follow=2: 0.2
-git_bumped_version lead=1 follow=2: 1.2
-git_bumped_version lead=1 latest_tag_version=1.2: 1.3
-git_bumped_version follow=2 latest_tag_version=1.4: 0.2
-git_bumped_version latest_tag_version=1.2: 0.1
-git_bumped_version latest_tag_version=0.1.2: 0.1
-git_bumped_version latest_tag_version=1.x: 0.1
-git_bumped_version latest_tag_version=0.1.x: 0.1
-git_bumped_version latest_tag_version=0.1: 0.2
-git_bumped_version follow=2.0: 0.2.0 # invalid but works
-git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
-
-git_vcs: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:foo
+git_name append=-baz: test-baz
+git_name prepend=bar-: bar-test
+git_name prepend=bar- append=-baz: bar-test-baz
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_version: 0.0.git.2.fb775f4
+git_version name=foo: 0.1.git.1.fb775f4
+git_version name=foo lead=1: 1.0.git.1.fb775f4
+git_version lead=0: 0.0.git.2.fb775f4
+git_version lead=1: 1.0.git.2.fb775f4
+git_version lead=0.1: 0.1.0.git.2.fb775f4
+git_version follow=1: 0.1.git.2.fb775f4
+git_version lead=1 follow=2: 1.2.git.2.fb775f4
+git_version lead=x follow=x: x.x.git.2.fb775f4
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
+git_version name="$(git_name)": 0.0.git.2.fb775f4
+
+git_vcs: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:foo
 
 git_pack: 
 git_pack dir_name=foo: 
@@ -49,16 +33,16 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: test-foo-bar-0.0.git.2.4e08997.tar.gz
-git_source_name name=foo: foo-0.0.git.2.4e08997.tar.gz
-git_source_name version=1.2: test-foo-bar-1.2.tar.gz
+git_source_name: bar-foo-baz-0.0.git.2.fb775f4.tar.gz
+git_source_name name=foo: foo-0.0.git.2.fb775f4.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_changelog:
 
 
 git_changelog name=foo since_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 0.1-1
+* Sat Mar 17 2018 clime <clime@redhat.com> 0.1-1
 - message.
 
 git_changelog name=foo until_tag=foo-1.2-1:
@@ -70,122 +54,121 @@ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
 
-git_cwd_name: test
-git_cwd_name name=foo: foo
-git_cwd_name name=foo append=foo-bar: foo-foo-bar
-git_cwd_name append=foo: test-foo
-git_cwd_name append=foo-bar: test-foo-bar
+:::::::::::::::::::::
 
-git_cwd_version: 0.0.git.2.4e08997
-git_cwd_version name=foo: 0.1.git.1.4e08997
-git_cwd_version lead=1: 1.0.git.2.4e08997
-git_cwd_version lead=0.1: 0.1.0.git.2.4e08997
-git_cwd_version follow=2: 0.2.git.2.4e08997
-git_cwd_version lead=1 follow=2: 1.2.git.2.4e08997
-git_cwd_version lead=x follow=x: x.x.git.2.4e08997
-git_cwd_version lead=1-1:  # invalid
-git_cwd_version follow=2.0:  # invalid
-git_cwd_version follow=2-2:  # invalid
-git_cwd_version name=:  # invalid
+git_dir_name: test-
+git_dir_name name=foo: foo-
+git_dir_name append=-baz: test-baz
+git_dir_name prepend=bar-: bar-test-
+git_dir_name prepend=bar- append=-baz: bar-test-baz
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version name="$(git_name)": 0.0.git.2.4e08997
-git_cwd_version echo 1.4: 1.4
-git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_cwd_version date --date='@2147483647' +%y%m%d: 380119
+git_dir_version: 0.0.git.2.fb775f4
+git_dir_version name=foo: 0.1.git.1.fb775f4
+git_dir_version name=foo lead=1: 1.0.git.1.fb775f4
+git_dir_version lead=0: 0.0.git.2.fb775f4
+git_dir_version lead=1: 1.0.git.2.fb775f4
+git_dir_version lead=0.1: 0.1.0.git.2.fb775f4
+git_dir_version follow=1: 0.1.git.2.fb775f4
+git_dir_version lead=1 follow=2: 1.2.git.2.fb775f4
+git_dir_version lead=x follow=x: x.x.git.2.fb775f4
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
+git_dir_version name="$(git_name)": 0.0.git.2.fb775f4
 
+git_dir_vcs: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:foo
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:foo
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: test-foo-bar-0.0.git.2.4e08997.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.2.4e08997.tar.gz
-git_cwd_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_source_name: bar-foo-baz-0.0.git.2.fb775f4.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.2.fb775f4.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_dir_changelog:
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 0.1-1
+git_dir_changelog name=foo since_tag=foo-1.2-1:
+* Sat Mar 17 2018 clime <clime@redhat.com> 0.1-1
 - message.
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
-
+git_dir_changelog name=foo until_tag=foo-1.2-1:
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
----
 
-git_dir_name: test
-git_dir_name name=foo: foo
-git_dir_name name=foo append=foo-bar: foo-foo-bar
-git_dir_name append=foo: test-foo
-git_dir_name append=foo-bar: test-foo-bar
 
-git_dir_version: 0.0.git.2.4e08997
-git_dir_version name=foo: 0.1.git.1.4e08997
-git_dir_version lead=1: 1.0.git.2.4e08997
-git_dir_version lead=0.1: 0.1.0.git.2.4e08997
-git_dir_version follow=2: 0.2.git.2.4e08997
-git_dir_version lead=1 follow=2: 1.2.git.2.4e08997
-git_dir_version lead=x follow=x: x.x.git.2.4e08997
-git_dir_version lead=1-1:  # invalid
-git_dir_version follow=2.0:  # invalid
-git_dir_version follow=2-2:  # invalid
-git_dir_version name=:  # invalid
+:::::::::::::::::::::
 
-git_dir_version name="$(git_name)": 0.0.git.2.4e08997
-git_dir_version echo 1.4: 1.4
-git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_dir_version date --date='@2147483647' %y%m%d: 380119
+git_cwd_name: test-
+git_cwd_name name=foo: foo-
+git_cwd_name append=-baz: test-baz
+git_cwd_name prepend=bar-: bar-test-
+git_cwd_name prepend=bar- append=-baz: bar-test-baz
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
+git_cwd_version: 0.0.git.2.fb775f4
+git_cwd_version name=foo: 0.1.git.1.fb775f4
+git_cwd_version name=foo lead=1: 1.0.git.1.fb775f4
+git_cwd_version lead=0: 0.0.git.2.fb775f4
+git_cwd_version lead=1: 1.0.git.2.fb775f4
+git_cwd_version lead=0.1: 0.1.0.git.2.fb775f4
+git_cwd_version follow=1: 0.1.git.2.fb775f4
+git_cwd_version lead=1 follow=2: 1.2.git.2.fb775f4
+git_cwd_version lead=x follow=x: x.x.git.2.fb775f4
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 0.0.git.2.fb775f4
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#4e08997289f38ed3f97dac1201d552b8079cb774:foo
+git_cwd_vcs: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:foo
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
-git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
-git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: test-foo-bar-0.0.git.2.4e08997.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.2.4e08997.tar.gz
-git_dir_source_name version=1.2: test-foo-bar-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_source_name: bar-foo-baz-0.0.git.2.fb775f4.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.2.fb775f4.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_changelog:
+git_cwd_changelog:
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
-* Thu Mar 15 2018 clime <clime@redhat.com> 0.1-1
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+* Sat Mar 17 2018 clime <clime@redhat.com> 0.1-1
 - message.
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
 
diff --git a/tests/preproc/test_tagged_commited/run.sh b/tests/preproc/test_tagged_commited/run.sh
index e9e56c1..8957f6e 100755
--- a/tests/preproc/test_tagged_commited/run.sh
+++ b/tests/preproc/test_tagged_commited/run.sh
@@ -5,7 +5,7 @@
 repo=`mktemp -d`
 output=`mktemp`
 
-cp ../input $repo
+prepare_input ../input $repo/input
 
 git init $repo
 git -C $repo remote add origin https://pagure.io/clime/test.git
diff --git a/tests/preproc/test_uninited/log b/tests/preproc/test_uninited/log
index c1effec..e0ff85a 100644
--- a/tests/preproc/test_uninited/log
+++ b/tests/preproc/test_uninited/log
@@ -4,15 +4,19 @@ git_name failed with value 1
 ---
 > git_name name=foo
 ---
-> git_name name=foo append=foo-bar
+> git_name append=-baz
+git_name: Start by setting origin URL.
+git_name append=-baz failed with value 1
 ---
-> git_name append=foo
+> git_name prepend=bar-
 git_name: Start by setting origin URL.
-git_name append=foo failed with value 1
+git_name prepend=bar- failed with value 1
 ---
-> git_name append=foo-bar
+> git_name prepend=bar- append=-baz
 git_name: Start by setting origin URL.
-git_name append=foo-bar failed with value 1
+git_name prepend=bar- append=-baz failed with value 1
+---
+> git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
 fatal: Not a git repository (or any parent up to mount point /)
@@ -22,6 +26,14 @@ Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
+> git_version name=foo lead=1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
+> git_version lead=0
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+---
 > git_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
@@ -30,7 +42,7 @@ Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_version follow=2
+> git_version follow=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
@@ -42,59 +54,27 @@ Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_version lead=1-1
+> git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 failed with value 1
+git_version lead=1-1 # invalid failed with value 1
 ---
-> git_version follow=2.0
+> git_version follow=2.0 # invalid
 git_version: follow cannot contain dots.
-git_version follow=2.0 failed with value 1
+git_version follow=2.0 # invalid failed with value 1
 ---
-> git_version follow=2-2
+> git_version follow=2-2 # invalid
 git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 failed with value 1
+git_version follow=2-2 # invalid failed with value 1
 ---
-> git_version name=
+> git_version name= # invalid
 git_version: name cannot be empty.
-git_version name= failed with value 1
+git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
 git_name: Start by setting origin URL.
 git_version: name cannot be empty.
 git_version name="$(git_name)" failed with value 1
 ---
-> echo -n 1.4
----
-> echo -n 1; echo -n .; echo -n 4
----
-> date --date='@2147483647' +%y%m%d
----
-> git_bumped_version
----
-> git_bumped_version lead=1
----
-> git_bumped_version follow=2
----
-> git_bumped_version lead=1 follow=2
----
-> git_bumped_version lead=1 latest_tag_version=1.2
----
-> git_bumped_version follow=2 latest_tag_version=1.4
----
-> git_bumped_version latest_tag_version=1.2
----
-> git_bumped_version latest_tag_version=0.1.2
----
-> git_bumped_version latest_tag_version=1.x
----
-> git_bumped_version latest_tag_version=0.1.x
----
-> git_bumped_version latest_tag_version=0.1
----
-> git_bumped_version follow=2.0
----
-> git_bumped_version latest_tag_version=1-2
----
 > git_vcs
 git_vcs: Start by setting origin URL.
 git_vcs failed with value 1
@@ -161,309 +141,323 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_cwd_name
+> git_dir_name
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_name: Start by setting origin URL.
-git_cwd_name failed with value 1
+git_dir_name: Start by setting origin URL.
+git_dir_name failed with value 1
 ---
-> git_cwd_name name=foo
+> git_dir_name name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_name name=foo append=foo-bar
+> git_dir_name append=-baz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_dir_name: Start by setting origin URL.
+git_dir_name append=-baz failed with value 1
 ---
-> git_cwd_name append=foo
+> git_dir_name prepend=bar-
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_name: Start by setting origin URL.
-git_cwd_name append=foo failed with value 1
+git_dir_name: Start by setting origin URL.
+git_dir_name prepend=bar- failed with value 1
 ---
-> git_cwd_name append=foo-bar
+> git_dir_name prepend=bar- append=-baz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_name: Start by setting origin URL.
-git_cwd_name append=foo-bar failed with value 1
+git_dir_name: Start by setting origin URL.
+git_dir_name prepend=bar- append=-baz failed with value 1
 ---
-> git_cwd_version
+> git_dir_name name=foo prepend=bar- append=-baz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version name=foo
+> git_dir_version
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version lead=1
+> git_dir_version name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version lead=0.1
+> git_dir_version name=foo lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version follow=2
+> git_dir_version lead=0
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version lead=1 follow=2
+> git_dir_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version lead=x follow=x
+> git_dir_version lead=0.1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version lead=1-1
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 failed with value 1
----
-> git_cwd_version follow=2.0
-git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 failed with value 1
----
-> git_cwd_version follow=2-2
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 failed with value 1
+> git_dir_version follow=1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version name=
-git_cwd_version: name cannot be empty.
-git_cwd_version name= failed with value 1
+> git_dir_version lead=1 follow=2
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_version name="$(git_cwd_name)"
+> git_dir_version lead=x follow=x
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_name: Start by setting origin URL.
-git_cwd_version: name cannot be empty.
-git_cwd_version name="$(git_cwd_name)" failed with value 1
 ---
-> echo -n 1.4
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
+---
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
 ---
-> git_cwd_vcs
+> git_dir_version name="$(git_name)"
+git_name: Start by setting origin URL.
+git_dir_version: name cannot be empty.
+git_dir_version name="$(git_name)" failed with value 1
+---
+> git_dir_vcs
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_vcs: Start by setting origin URL.
-git_cwd_vcs failed with value 1
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs failed with value 1
 ---
-> git_cwd_vcs subtree=foo
+> git_dir_vcs subtree=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_vcs: Start by setting origin URL.
-git_cwd_vcs subtree=foo failed with value 1
+git_dir_vcs: Start by setting origin URL.
+git_dir_vcs subtree=foo failed with value 1
 ---
-> git_cwd_pack
+> git_dir_pack
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_pack: OUTDIR is not set. No action taken.
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo
+> git_dir_pack dir_name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_pack: OUTDIR is not set. No action taken.
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_pack: OUTDIR is not set. No action taken.
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_pack: OUTDIR is not set. No action taken.
+git_dir_pack: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive
+> git_dir_archive
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_archive: OUTDIR is not set. No action taken.
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo
+> git_dir_archive dir_name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_archive: OUTDIR is not set. No action taken.
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_archive: OUTDIR is not set. No action taken.
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_cwd_archive: OUTDIR is not set. No action taken.
+git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
+> git_dir_source_name
 ---
-> git_cwd_source_name name=foo
+> git_dir_source_name name=foo
 ---
-> git_cwd_source_name version=1.2
+> git_dir_source_name version=1.2
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_dir_changelog
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
-> git_dir_name
+> git_cwd_name
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_name: Start by setting origin URL.
-git_dir_name failed with value 1
+git_cwd_name: Start by setting origin URL.
+git_cwd_name failed with value 1
 ---
-> git_dir_name name=foo
+> git_cwd_name name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_name name=foo append=foo-bar
+> git_cwd_name append=-baz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_name: Start by setting origin URL.
+git_cwd_name append=-baz failed with value 1
 ---
-> git_dir_name append=foo
+> git_cwd_name prepend=bar-
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_name: Start by setting origin URL.
-git_dir_name append=foo failed with value 1
+git_cwd_name: Start by setting origin URL.
+git_cwd_name prepend=bar- failed with value 1
 ---
-> git_dir_name append=foo-bar
+> git_cwd_name prepend=bar- append=-baz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_name: Start by setting origin URL.
-git_dir_name append=foo-bar failed with value 1
+git_cwd_name: Start by setting origin URL.
+git_cwd_name prepend=bar- append=-baz failed with value 1
 ---
-> git_dir_version
+> git_cwd_name name=foo prepend=bar- append=-baz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version name=foo
+> git_cwd_version
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version lead=1
+> git_cwd_version name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version lead=0.1
+> git_cwd_version name=foo lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version follow=2
+> git_cwd_version lead=0
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version lead=1 follow=2
+> git_cwd_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version lead=x follow=x
+> git_cwd_version lead=0.1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version lead=1-1
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 failed with value 1
----
-> git_dir_version follow=2.0
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 failed with value 1
----
-> git_dir_version follow=2-2
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 failed with value 1
+> git_cwd_version follow=1
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version name=
-git_dir_version: name cannot be empty.
-git_dir_version name= failed with value 1
+> git_cwd_version lead=1 follow=2
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_version name="$(git_dir_name)"
+> git_cwd_version lead=x follow=x
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_name: Start by setting origin URL.
-git_dir_version: name cannot be empty.
-git_dir_version name="$(git_dir_name)" failed with value 1
 ---
-> echo -n 1.4
+> git_cwd_version lead=1-1 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 # invalid failed with value 1
+---
+> git_cwd_version follow=2.0 # invalid
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 # invalid failed with value 1
 ---
-> echo -n 1; echo -n .; echo -n 4
+> git_cwd_version follow=2-2 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 # invalid failed with value 1
 ---
-> date --date='@2147483647' +%y%m%d
+> git_cwd_version name= # invalid
+git_cwd_version: name cannot be empty.
+git_cwd_version name= # invalid failed with value 1
 ---
-> git_dir_vcs
+> git_cwd_version name="$(git_cwd_name)"
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_vcs: Start by setting origin URL.
-git_dir_vcs failed with value 1
+git_cwd_name: Start by setting origin URL.
+git_cwd_version: name cannot be empty.
+git_cwd_version name="$(git_cwd_name)" failed with value 1
 ---
-> git_dir_vcs subtree=foo
+> git_cwd_vcs
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_vcs: Start by setting origin URL.
-git_dir_vcs subtree=foo failed with value 1
+git_cwd_vcs: Start by setting origin URL.
+git_cwd_vcs failed with value 1
 ---
-> git_dir_pack
+> git_cwd_vcs subtree=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_pack: OUTDIR is not set. No action taken.
+git_cwd_vcs: Start by setting origin URL.
+git_cwd_vcs subtree=foo failed with value 1
 ---
-> git_dir_pack dir_name=foo
+> git_cwd_pack
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_pack: OUTDIR is not set. No action taken.
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
+> git_cwd_pack dir_name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_pack: OUTDIR is not set. No action taken.
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_pack: OUTDIR is not set. No action taken.
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_archive: OUTDIR is not set. No action taken.
+git_cwd_pack: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo
+> git_cwd_archive
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_archive: OUTDIR is not set. No action taken.
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
+> git_cwd_archive dir_name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_archive: OUTDIR is not set. No action taken.
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-git_dir_archive: OUTDIR is not set. No action taken.
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name name=foo
+> git_cwd_source_name
 ---
-> git_dir_source_name version=1.2
+> git_cwd_source_name name=foo
 ---
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_cwd_source_name version=1.2
 ---
-> git_dir_changelog
+> git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
 ---
diff --git a/tests/preproc/test_uninited/output b/tests/preproc/test_uninited/output
index d64fe60..a8ccfb0 100644
--- a/tests/preproc/test_uninited/output
+++ b/tests/preproc/test_uninited/output
@@ -1,40 +1,24 @@
 git_name: 
 git_name name=foo: foo
-git_name name=foo append=foo-bar: foo-foo-bar
-git_name append=foo: 
-git_name append=foo-bar: 
+git_name append=-baz: 
+git_name prepend=bar-: 
+git_name prepend=bar- append=-baz: 
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
 git_version: 0.0
 git_version name=foo: 0.0
+git_version name=foo lead=1: 1.0
+git_version lead=0: 0.0
 git_version lead=1: 1.0
 git_version lead=0.1: 0.1.0
-git_version follow=2: 0.2
+git_version follow=1: 0.1
 git_version lead=1 follow=2: 1.2
 git_version lead=x follow=x: x.x
-git_version lead=1-1:  # invalid
-git_version follow=2.0:  # invalid
-git_version follow=2-2:  # invalid
-git_version name=:  # invalid
-
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
 git_version name="$(git_name)": 
-git_version echo 1.4: 1.4
-git_version echo -n 1; echo -n .; echo 4: 1.4
-git_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_bumped_version: 0.1
-git_bumped_version lead=1: 1.0
-git_bumped_version follow=2: 0.2
-git_bumped_version lead=1 follow=2: 1.2
-git_bumped_version lead=1 latest_tag_version=1.2: 1.3
-git_bumped_version follow=2 latest_tag_version=1.4: 0.2
-git_bumped_version latest_tag_version=1.2: 0.1
-git_bumped_version latest_tag_version=0.1.2: 0.1
-git_bumped_version latest_tag_version=1.x: 0.1
-git_bumped_version latest_tag_version=0.1.x: 0.1
-git_bumped_version latest_tag_version=0.1: 0.2
-git_bumped_version follow=2.0: 0.2.0 # invalid but works
-git_bumped_version latest_tag_version=1-2: 0.1 # invalid but works
 
 git_vcs: 
 git_vcs subtree=foo: 
@@ -49,9 +33,9 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: foo-foo-bar-x.x.tar.gz
+git_source_name: bar-foo-baz-x.x.tar.gz
 git_source_name name=foo: foo-x.x.tar.gz
-git_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_changelog:
@@ -69,90 +53,30 @@ git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
 
----
-
-git_cwd_name: 
-git_cwd_name name=foo: foo
-git_cwd_name name=foo append=foo-bar: foo-foo-bar
-git_cwd_name append=foo: 
-git_cwd_name append=foo-bar: 
-
-git_cwd_version: 0.0
-git_cwd_version name=foo: 0.0
-git_cwd_version lead=1: 1.0
-git_cwd_version lead=0.1: 0.1.0
-git_cwd_version follow=2: 0.2
-git_cwd_version lead=1 follow=2: 1.2
-git_cwd_version lead=x follow=x: x.x
-git_cwd_version lead=1-1:  # invalid
-git_cwd_version follow=2.0:  # invalid
-git_cwd_version follow=2-2:  # invalid
-git_cwd_version name=:  # invalid
-
-git_cwd_version name="$(git_name)": 
-git_cwd_version echo 1.4: 1.4
-git_cwd_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_cwd_version date --date='@2147483647' +%y%m%d: 380119
-
-
-git_cwd_vcs: 
-git_cwd_vcs subtree=foo: 
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_cwd_source_name: foo-foo-bar-x.x.tar.gz
-git_cwd_source_name name=foo: foo-x.x.tar.gz
-git_cwd_source_name version=1.2: foo-foo-bar-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
-
-git_cwd_changelog:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
-
-
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-
-
----
+:::::::::::::::::::::
 
 git_dir_name: 
-git_dir_name name=foo: foo
-git_dir_name name=foo append=foo-bar: foo-foo-bar
-git_dir_name append=foo: 
-git_dir_name append=foo-bar: 
+git_dir_name name=foo: foo-
+git_dir_name append=-baz: 
+git_dir_name prepend=bar-: 
+git_dir_name prepend=bar- append=-baz: 
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
 git_dir_version: 0.0
 git_dir_version name=foo: 0.0
+git_dir_version name=foo lead=1: 1.0
+git_dir_version lead=0: 0.0
 git_dir_version lead=1: 1.0
 git_dir_version lead=0.1: 0.1.0
-git_dir_version follow=2: 0.2
+git_dir_version follow=1: 0.1
 git_dir_version lead=1 follow=2: 1.2
 git_dir_version lead=x follow=x: x.x
-git_dir_version lead=1-1:  # invalid
-git_dir_version follow=2.0:  # invalid
-git_dir_version follow=2-2:  # invalid
-git_dir_version name=:  # invalid
-
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
 git_dir_version name="$(git_name)": 
-git_dir_version echo 1.4: 1.4
-git_dir_version echo -n 1; echo -n .; echo -n 4: 1.4
-git_dir_version date --date='@2147483647' %y%m%d: 380119
-
 
 git_dir_vcs: 
 git_dir_vcs subtree=foo: 
@@ -167,9 +91,9 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: foo-foo-bar-x.x.tar.gz
+git_dir_source_name: bar-foo-baz-x.x.tar.gz
 git_dir_source_name name=foo: foo-x.x.tar.gz
-git_dir_source_name version=1.2: foo-foo-bar-1.2.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
 git_dir_changelog:
@@ -186,3 +110,62 @@ git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
 
 git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
 
+
+
+:::::::::::::::::::::
+
+git_cwd_name: 
+git_cwd_name name=foo: foo-
+git_cwd_name append=-baz: 
+git_cwd_name prepend=bar-: 
+git_cwd_name prepend=bar- append=-baz: 
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_cwd_version: 0.0
+git_cwd_version name=foo: 0.0
+git_cwd_version name=foo lead=1: 1.0
+git_cwd_version lead=0: 0.0
+git_cwd_version lead=1: 1.0
+git_cwd_version lead=0.1: 0.1.0
+git_cwd_version follow=1: 0.1
+git_cwd_version lead=1 follow=2: 1.2
+git_cwd_version lead=x follow=x: x.x
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 
+
+git_cwd_vcs: 
+git_cwd_vcs subtree=foo: 
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: bar-foo-baz-x.x.tar.gz
+git_cwd_source_name name=foo: foo-x.x.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+
+
diff --git a/tests/preproc/test_uninited/run.sh b/tests/preproc/test_uninited/run.sh
index 68a4fec..e2e483f 100755
--- a/tests/preproc/test_uninited/run.sh
+++ b/tests/preproc/test_uninited/run.sh
@@ -5,7 +5,7 @@
 repo=`mktemp -d`
 output=`mktemp`
 
-cp ../input $repo
+prepare_input ../input $repo/input
 
 touch output && cp output $output
 

From 9c08f6edd47a43e88adca16b859de8888b0ef05b Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 85/104] fix dirty condition in git_archive, the previous relied on an existing tag


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 6d0eab4..60ce027 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -248,7 +248,7 @@ function git_archive {
         return 1
     fi
 
-    if git describe --dirty | grep -q '^.*-dirty$'; then
+    if [ "$(git status --porcelain)" ]; then
         log_error "Your working tree is dirty. Commit first."
         return 2
     fi

From 792509cac04d7278619337d642c7163cd7a23e82 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 86/104] make release in tag a required thing so that we can reliably parse out package name


---

diff --git a/rpkglib/__init__.py b/rpkglib/__init__.py
index 226e71b..4e8e30c 100644
--- a/rpkglib/__init__.py
+++ b/rpkglib/__init__.py
@@ -356,9 +356,11 @@ class Commands(pyrpkg.Commands):
         or reference a message file.
 
         Runs the tag command and returns nothing
-
         """
-        if tagname in self.repo.tags:
+        if not re.match(r'^.*-[^-]+-[^-]+$', tagname) and not force:
+            raise rpkgError("Tag {} does not have n-v-r format.".format(tagname))
+
+        if tagname in self.repo.tags and not force:
             raise rpkgError("Tag {} already exists.".format(tagname))
 
         if not message and not file:
@@ -380,15 +382,22 @@ class Commands(pyrpkg.Commands):
         self.version_bump = False
         self.load_spec()
 
-    def get_tag_message(self, tagname):
+    def get_tag_message(self, new_tagname):
         tag_pattern = '{}*'.format(self.module_name)
 
-        tag_names = self.repo.git.tag(
-            '--list', '--sort=taggerdate:unix', tag_pattern,
+        tagnames = self.repo.git.tag(
+            '--list', '--sort=-taggerdate:unix', tag_pattern,
             '--merged').split()
 
-        if tag_names:
-            rev_list_expr = '{}..HEAD'.format(tag_names[-1])
+        last_matching_tagname = None
+        for tagname in tagnames:
+            expr = r'^{}-[^-]+-[^-]+$'.format(self.module_name)
+            if re.match(expr, tagname):
+                last_matching_tagname = tagname
+                break
+
+        if last_matching_tagname:
+            rev_list_expr = '{}..HEAD'.format(last_matching_tagname)
         else:
             rev_list_expr = 'HEAD'
 
@@ -400,7 +409,7 @@ class Commands(pyrpkg.Commands):
 
         help_text = ("#\n"
         "# Write a changelog for tag:\n"
-        "#   " + tagname + "\n"
+        "#   " + new_tagname + "\n"
         "# Lines starting with '#' will be ignored.\n")
 
         body = utils.edit(editor, entries, help_text)
diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 60ce027..523b373 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -37,6 +37,10 @@ function name_convert {
     sed -e 's|/|-|g' -e 's|-$||'
 }
 
+function filter_tags {
+    grep -E "^$1-[^-]+-[^-]+$"
+}
+
 function output {
     __cached["${FUNCNAME[1]}"]="$*"
     echo -n "${__cached[${FUNCNAME[1]}]}"
@@ -141,11 +145,11 @@ function git_version {
         return 1
     fi
     
-    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name*" --merged 2> /dev/null)
+    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name*" --merged | filter_tags "$name" 2> /dev/null)
 
     if [ ${#tags[@]} -gt 0 ]; then
         latest_tag="${tags[-1]}"
-        latest_tag_version="$(echo $latest_tag | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1/p")"
+        latest_tag_version="$(echo $latest_tag | sed -E -n "s/^$name-([^-]+)-[^-]+$/\1/p")"
     else
         latest_tag=
         latest_tag_version=
@@ -281,7 +285,7 @@ function git_setup_macro {
 function git_changelog {
     declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" body_wrap=80 "$@"
 
-    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name*" --merged 2> /dev/null)
+    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name*" --merged | filter_tags "$name" 2> /dev/null)
 
     if [ -n "$header_date_format" ]; then
         header_date_format_suffix=":format:$header_date_format"
@@ -303,7 +307,7 @@ function git_changelog {
             continue
         fi
 
-        verrel="$(echo "$tag" | sed -E -n "s/^$name-([^-]+)(-[^-]+)?$/\1\2/p")"
+        verrel="$(echo "$tag" | sed -E -n "s/^$name-([^-]+)(-[^-]+)$/\1\2/p")"
         header="$(LC_ALL="$header_locale" git tag -l "$tag" --format="* %(taggerdate$header_date_format_suffix) %(taggername) %(taggeremail)") $verrel"
         if [ -n "$changelog" ]; then
             changelog="$changelog"$'\n\n'

From 7b189fbd320b10748806a28e045852f3b56e25ea Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 87/104] finish test_sources_subdir, do not output changelog date


---

diff --git a/tests/preproc/input b/tests/preproc/input
index c07e8df..79039f1 100644
--- a/tests/preproc/input
+++ b/tests/preproc/input
@@ -38,11 +38,11 @@ git_source_name name=foo
 git_source_name version=1.2
 git_source_name name=foo version=1.2 format=tar
 
-git_changelog ::
-git_changelog name=foo since_tag=foo-1.2-1 ::
-git_changelog name=foo until_tag=foo-1.2-1 ::
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 ::
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 ::
+git_changelog header_date_format="@@@" ::
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@" ::
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@" ::
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@" ::
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42 ::
 
 :::::::::::::::::::::
 
@@ -86,11 +86,11 @@ git_dir_source_name name=foo
 git_dir_source_name version=1.2
 git_dir_source_name name=foo version=1.2 format=tar
 
-git_dir_changelog ::
-git_dir_changelog name=foo since_tag=foo-1.2-1 ::
-git_dir_changelog name=foo until_tag=foo-1.2-1 ::
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 ::
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 ::
+git_dir_changelog header_date_format="@@@" ::
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@" ::
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@" ::
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@" ::
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42 ::
 
 :::::::::::::::::::::
 
@@ -134,8 +134,8 @@ git_cwd_source_name name=foo
 git_cwd_source_name version=1.2
 git_cwd_source_name name=foo version=1.2 format=tar
 
-git_cwd_changelog ::
-git_cwd_changelog name=foo since_tag=foo-1.2-1 ::
-git_cwd_changelog name=foo until_tag=foo-1.2-1 ::
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 ::
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42 ::
+git_cwd_changelog header_date_format="@@@" ::
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@" ::
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@" ::
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@" ::
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42 ::
diff --git a/tests/preproc/lib.sh b/tests/preproc/lib.sh
index 20b7d1d..42c03de 100644
--- a/tests/preproc/lib.sh
+++ b/tests/preproc/lib.sh
@@ -8,7 +8,7 @@ function die {
 }
 
 function log_filter {
-    grep -Ev -e '^> (env|cwd):' -e '^git_pack: Wrote: /tmp/'
+    grep -Ev -e '^> (env|cwd):' -e 'Wrote: /tmp/'
 }
 
 function run {
diff --git a/tests/preproc/test_committed/log b/tests/preproc/test_committed/log
index 0e9bb1a..9989773 100644
--- a/tests/preproc/test_committed/log
+++ b/tests/preproc/test_committed/log
@@ -82,15 +82,15 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_source_name name=foo version=1.2 format=tar
 ---
-> git_changelog
+> git_changelog header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1
+> git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_changelog name=foo until_tag=foo-1.2-1
+> git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
 > git_dir_name
 ---
@@ -176,15 +176,15 @@ git_dir_archive: OUTDIR is not set. No action taken.
 ---
 > git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_dir_changelog header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
 > git_cwd_name
 ---
@@ -270,13 +270,13 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 ---
 > git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_cwd_changelog header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
diff --git a/tests/preproc/test_committed/output b/tests/preproc/test_committed/output
index 39c2360..cfccf53 100644
--- a/tests/preproc/test_committed/output
+++ b/tests/preproc/test_committed/output
@@ -5,23 +5,23 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.git.3.0ea5766
-git_version name=foo: 0.0.git.3.0ea5766
-git_version name=foo lead=1: 1.0.git.3.0ea5766
-git_version lead=0: 0.0.git.3.0ea5766
-git_version lead=1: 1.0.git.3.0ea5766
-git_version lead=0.1: 0.1.0.git.3.0ea5766
-git_version follow=1: 0.1.git.3.0ea5766
-git_version lead=1 follow=2: 1.2.git.3.0ea5766
-git_version lead=x follow=x: x.x.git.3.0ea5766
+git_version: 0.0.git.3.afae168
+git_version name=foo: 0.0.git.3.afae168
+git_version name=foo lead=1: 1.0.git.3.afae168
+git_version lead=0: 0.0.git.3.afae168
+git_version lead=1: 1.0.git.3.afae168
+git_version lead=0.1: 0.1.0.git.3.afae168
+git_version follow=1: 0.1.git.3.afae168
+git_version lead=1 follow=2: 1.2.git.3.afae168
+git_version lead=x follow=x: x.x.git.3.afae168
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.git.3.0ea5766
+git_version name="$(git_name)": 0.0.git.3.afae168
 
-git_vcs: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:foo
+git_vcs: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:foo
 
 git_pack: 
 git_pack dir_name=foo: 
@@ -33,24 +33,24 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.git.3.0ea5766.tar.gz
-git_source_name name=foo: foo-0.0.git.3.0ea5766.tar.gz
+git_source_name: bar-foo-baz-0.0.git.3.afae168.tar.gz
+git_source_name name=foo: foo-0.0.git.3.afae168.tar.gz
 git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_changelog:
+git_changelog header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1:
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo until_tag=foo-1.2-1:
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -63,23 +63,23 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.git.3.0ea5766
-git_dir_version name=foo: 0.0.git.3.0ea5766
-git_dir_version name=foo lead=1: 1.0.git.3.0ea5766
-git_dir_version lead=0: 0.0.git.3.0ea5766
-git_dir_version lead=1: 1.0.git.3.0ea5766
-git_dir_version lead=0.1: 0.1.0.git.3.0ea5766
-git_dir_version follow=1: 0.1.git.3.0ea5766
-git_dir_version lead=1 follow=2: 1.2.git.3.0ea5766
-git_dir_version lead=x follow=x: x.x.git.3.0ea5766
+git_dir_version: 0.0.git.3.afae168
+git_dir_version name=foo: 0.0.git.3.afae168
+git_dir_version name=foo lead=1: 1.0.git.3.afae168
+git_dir_version lead=0: 0.0.git.3.afae168
+git_dir_version lead=1: 1.0.git.3.afae168
+git_dir_version lead=0.1: 0.1.0.git.3.afae168
+git_dir_version follow=1: 0.1.git.3.afae168
+git_dir_version lead=1 follow=2: 1.2.git.3.afae168
+git_dir_version lead=x follow=x: x.x.git.3.afae168
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.git.3.0ea5766
+git_dir_version name="$(git_name)": 0.0.git.3.afae168
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:foo
+git_dir_vcs: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:foo
 
 git_dir_pack: foo-1.2.tar
 git_dir_pack dir_name=foo: foo-1.2.tar
@@ -91,24 +91,24 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.git.3.0ea5766.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.3.0ea5766.tar.gz
+git_dir_source_name: bar-foo-baz-0.0.git.3.afae168.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.3.afae168.tar.gz
 git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_changelog:
+git_dir_changelog header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -121,23 +121,23 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.git.3.0ea5766
-git_cwd_version name=foo: 0.0.git.3.0ea5766
-git_cwd_version name=foo lead=1: 1.0.git.3.0ea5766
-git_cwd_version lead=0: 0.0.git.3.0ea5766
-git_cwd_version lead=1: 1.0.git.3.0ea5766
-git_cwd_version lead=0.1: 0.1.0.git.3.0ea5766
-git_cwd_version follow=1: 0.1.git.3.0ea5766
-git_cwd_version lead=1 follow=2: 1.2.git.3.0ea5766
-git_cwd_version lead=x follow=x: x.x.git.3.0ea5766
+git_cwd_version: 0.0.git.3.afae168
+git_cwd_version name=foo: 0.0.git.3.afae168
+git_cwd_version name=foo lead=1: 1.0.git.3.afae168
+git_cwd_version lead=0: 0.0.git.3.afae168
+git_cwd_version lead=1: 1.0.git.3.afae168
+git_cwd_version lead=0.1: 0.1.0.git.3.afae168
+git_cwd_version follow=1: 0.1.git.3.afae168
+git_cwd_version lead=1 follow=2: 1.2.git.3.afae168
+git_cwd_version lead=x follow=x: x.x.git.3.afae168
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.git.3.0ea5766
+git_cwd_version name="$(git_cwd_name)": 0.0.git.3.afae168
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#0ea5766d1e93c38a6b5a503417f5ae5d252af2c2:foo
+git_cwd_vcs: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:foo
 
 git_cwd_pack: foo-1.2.tar
 git_cwd_pack dir_name=foo: foo-1.2.tar
@@ -149,23 +149,23 @@ git_cwd_archive dir_name=foo: foo-1.2.tar
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.git.3.0ea5766.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.3.0ea5766.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.git.3.afae168.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.3.afae168.tar.gz
 git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_cwd_changelog header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
diff --git a/tests/preproc/test_dirty/log b/tests/preproc/test_dirty/log
index 0e9bb1a..9989773 100644
--- a/tests/preproc/test_dirty/log
+++ b/tests/preproc/test_dirty/log
@@ -82,15 +82,15 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_source_name name=foo version=1.2 format=tar
 ---
-> git_changelog
+> git_changelog header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1
+> git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_changelog name=foo until_tag=foo-1.2-1
+> git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
 > git_dir_name
 ---
@@ -176,15 +176,15 @@ git_dir_archive: OUTDIR is not set. No action taken.
 ---
 > git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_dir_changelog header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
 > git_cwd_name
 ---
@@ -270,13 +270,13 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 ---
 > git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_cwd_changelog header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
diff --git a/tests/preproc/test_dirty/output b/tests/preproc/test_dirty/output
index 065bb86..f413891 100644
--- a/tests/preproc/test_dirty/output
+++ b/tests/preproc/test_dirty/output
@@ -5,23 +5,23 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.git.1.0326f80.wtree.zf1ilc
-git_version name=foo: 0.0.git.1.0326f80.wtree.zf1ilc
-git_version name=foo lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
-git_version lead=0: 0.0.git.1.0326f80.wtree.zf1ilc
-git_version lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
-git_version lead=0.1: 0.1.0.git.1.0326f80.wtree.zf1ilc
-git_version follow=1: 0.1.git.1.0326f80.wtree.zf1ilc
-git_version lead=1 follow=2: 1.2.git.1.0326f80.wtree.zf1ilc
-git_version lead=x follow=x: x.x.git.1.0326f80.wtree.zf1ilc
+git_version: 0.0.git.1.d41b65e.wtree.zf20p5
+git_version name=foo: 0.0.git.1.d41b65e.wtree.zf20p5
+git_version name=foo lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
+git_version lead=0: 0.0.git.1.d41b65e.wtree.zf20p5
+git_version lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
+git_version lead=0.1: 0.1.0.git.1.d41b65e.wtree.zf20p5
+git_version follow=1: 0.1.git.1.d41b65e.wtree.zf20p5
+git_version lead=1 follow=2: 1.2.git.1.d41b65e.wtree.zf20p5
+git_version lead=x follow=x: x.x.git.1.d41b65e.wtree.zf20p5
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.git.1.0326f80.wtree.zf1ilc
+git_version name="$(git_name)": 0.0.git.1.d41b65e.wtree.zf20p5
 
-git_vcs: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:foo
+git_vcs: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:foo
 
 git_pack: 
 git_pack dir_name=foo: 
@@ -33,24 +33,24 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
-git_source_name name=foo: foo-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_source_name: bar-foo-baz-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
+git_source_name name=foo: foo-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
 git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_changelog:
+git_changelog header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1:
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo until_tag=foo-1.2-1:
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -63,23 +63,23 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.git.1.0326f80.wtree.zf1ilc
-git_dir_version name=foo: 0.0.git.1.0326f80.wtree.zf1ilc
-git_dir_version name=foo lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
-git_dir_version lead=0: 0.0.git.1.0326f80.wtree.zf1ilc
-git_dir_version lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
-git_dir_version lead=0.1: 0.1.0.git.1.0326f80.wtree.zf1ilc
-git_dir_version follow=1: 0.1.git.1.0326f80.wtree.zf1ilc
-git_dir_version lead=1 follow=2: 1.2.git.1.0326f80.wtree.zf1ilc
-git_dir_version lead=x follow=x: x.x.git.1.0326f80.wtree.zf1ilc
+git_dir_version: 0.0.git.1.d41b65e.wtree.zf20p5
+git_dir_version name=foo: 0.0.git.1.d41b65e.wtree.zf20p5
+git_dir_version name=foo lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
+git_dir_version lead=0: 0.0.git.1.d41b65e.wtree.zf20p5
+git_dir_version lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
+git_dir_version lead=0.1: 0.1.0.git.1.d41b65e.wtree.zf20p5
+git_dir_version follow=1: 0.1.git.1.d41b65e.wtree.zf20p5
+git_dir_version lead=1 follow=2: 1.2.git.1.d41b65e.wtree.zf20p5
+git_dir_version lead=x follow=x: x.x.git.1.d41b65e.wtree.zf20p5
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.git.1.0326f80.wtree.zf1ilc
+git_dir_version name="$(git_name)": 0.0.git.1.d41b65e.wtree.zf20p5
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:foo
+git_dir_vcs: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:foo
 
 git_dir_pack: foo-1.2.tar
 git_dir_pack dir_name=foo: foo-1.2.tar
@@ -91,24 +91,24 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_dir_source_name: bar-foo-baz-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
 git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_changelog:
+git_dir_changelog header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -121,23 +121,23 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.git.1.0326f80.wtree.zf1ilc
-git_cwd_version name=foo: 0.0.git.1.0326f80.wtree.zf1ilc
-git_cwd_version name=foo lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
-git_cwd_version lead=0: 0.0.git.1.0326f80.wtree.zf1ilc
-git_cwd_version lead=1: 1.0.git.1.0326f80.wtree.zf1ilc
-git_cwd_version lead=0.1: 0.1.0.git.1.0326f80.wtree.zf1ilc
-git_cwd_version follow=1: 0.1.git.1.0326f80.wtree.zf1ilc
-git_cwd_version lead=1 follow=2: 1.2.git.1.0326f80.wtree.zf1ilc
-git_cwd_version lead=x follow=x: x.x.git.1.0326f80.wtree.zf1ilc
+git_cwd_version: 0.0.git.1.d41b65e.wtree.zf20p5
+git_cwd_version name=foo: 0.0.git.1.d41b65e.wtree.zf20p5
+git_cwd_version name=foo lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
+git_cwd_version lead=0: 0.0.git.1.d41b65e.wtree.zf20p5
+git_cwd_version lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
+git_cwd_version lead=0.1: 0.1.0.git.1.d41b65e.wtree.zf20p5
+git_cwd_version follow=1: 0.1.git.1.d41b65e.wtree.zf20p5
+git_cwd_version lead=1 follow=2: 1.2.git.1.d41b65e.wtree.zf20p5
+git_cwd_version lead=x follow=x: x.x.git.1.d41b65e.wtree.zf20p5
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.git.1.0326f80.wtree.zf1ilc
+git_cwd_version name="$(git_cwd_name)": 0.0.git.1.d41b65e.wtree.zf20p5
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#0326f805e71ad4528d00b72ba555256aeb622284:foo
+git_cwd_vcs: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:foo
 
 git_cwd_pack: foo-1.2.tar
 git_cwd_pack dir_name=foo: foo-1.2.tar
@@ -149,23 +149,23 @@ git_cwd_archive dir_name=foo: foo-1.2.tar
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.1.0326f80.wtree.zf1ilc.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
 git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_cwd_changelog header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
diff --git a/tests/preproc/test_inited/log b/tests/preproc/test_inited/log
index 57ddfd8..124c8f6 100644
--- a/tests/preproc/test_inited/log
+++ b/tests/preproc/test_inited/log
@@ -19,22 +19,31 @@ git_name prepend=bar- append=-baz failed with value 1
 > git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
+fatal: malformed object name HEAD
 ---
 > git_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
@@ -97,15 +106,20 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_source_name name=foo version=1.2 format=tar
 ---
-> git_changelog
+> git_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1
+> git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo until_tag=foo-1.2-1
+> git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
 > git_dir_name
 git_dir_name: Start by setting origin URL.
@@ -128,22 +142,31 @@ git_dir_name prepend=bar- append=-baz failed with value 1
 > git_dir_name name=foo prepend=bar- append=-baz
 ---
 > git_dir_version
+fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_dir_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1-1 # invalid
 git_dir_version: lead and follow cannot contain dashes.
@@ -206,15 +229,20 @@ git_dir_archive: OUTDIR is not set. No action taken.
 ---
 > git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_dir_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
 > git_cwd_name
 git_cwd_name: Start by setting origin URL.
@@ -237,22 +265,31 @@ git_cwd_name prepend=bar- append=-baz failed with value 1
 > git_cwd_name name=foo prepend=bar- append=-baz
 ---
 > git_cwd_version
+fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
@@ -315,13 +352,18 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 ---
 > git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_cwd_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
diff --git a/tests/preproc/test_inited/output b/tests/preproc/test_inited/output
index 54fae8e..4d99b64 100644
--- a/tests/preproc/test_inited/output
+++ b/tests/preproc/test_inited/output
@@ -5,15 +5,15 @@ git_name prepend=bar-:
 git_name prepend=bar- append=-baz: 
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.wtree.zf1ile
-git_version name=foo: 0.0.wtree.zf1ile
-git_version name=foo lead=1: 1.0.wtree.zf1ile
-git_version lead=0: 0.0.wtree.zf1ile
-git_version lead=1: 1.0.wtree.zf1ile
-git_version lead=0.1: 0.1.0.wtree.zf1ile
-git_version follow=1: 0.1.wtree.zf1ile
-git_version lead=1 follow=2: 1.2.wtree.zf1ile
-git_version lead=x follow=x: x.x.wtree.zf1ile
+git_version: 0.0.wtree.zf20p7
+git_version name=foo: 0.0.wtree.zf20p7
+git_version name=foo lead=1: 1.0.wtree.zf20p7
+git_version lead=0: 0.0.wtree.zf20p7
+git_version lead=1: 1.0.wtree.zf20p7
+git_version lead=0.1: 0.1.0.wtree.zf20p7
+git_version follow=1: 0.1.wtree.zf20p7
+git_version lead=1 follow=2: 1.2.wtree.zf20p7
+git_version lead=x follow=x: x.x.wtree.zf20p7
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
@@ -33,24 +33,24 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-x.x.wtree.zf1ile.tar.gz
-git_source_name name=foo: foo-x.x.wtree.zf1ile.tar.gz
+git_source_name: bar-foo-baz-x.x.wtree.zf20p7.tar.gz
+git_source_name name=foo: foo-x.x.wtree.zf20p7.tar.gz
 git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_changelog:
+git_changelog header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1:
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo until_tag=foo-1.2-1:
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -63,15 +63,15 @@ git_dir_name prepend=bar-:
 git_dir_name prepend=bar- append=-baz: 
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.wtree.zf1ile
-git_dir_version name=foo: 0.0.wtree.zf1ile
-git_dir_version name=foo lead=1: 1.0.wtree.zf1ile
-git_dir_version lead=0: 0.0.wtree.zf1ile
-git_dir_version lead=1: 1.0.wtree.zf1ile
-git_dir_version lead=0.1: 0.1.0.wtree.zf1ile
-git_dir_version follow=1: 0.1.wtree.zf1ile
-git_dir_version lead=1 follow=2: 1.2.wtree.zf1ile
-git_dir_version lead=x follow=x: x.x.wtree.zf1ile
+git_dir_version: 0.0.wtree.zf20p7
+git_dir_version name=foo: 0.0.wtree.zf20p7
+git_dir_version name=foo lead=1: 1.0.wtree.zf20p7
+git_dir_version lead=0: 0.0.wtree.zf20p7
+git_dir_version lead=1: 1.0.wtree.zf20p7
+git_dir_version lead=0.1: 0.1.0.wtree.zf20p7
+git_dir_version follow=1: 0.1.wtree.zf20p7
+git_dir_version lead=1 follow=2: 1.2.wtree.zf20p7
+git_dir_version lead=x follow=x: x.x.wtree.zf20p7
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
@@ -91,24 +91,24 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-x.x.wtree.zf1ile.tar.gz
-git_dir_source_name name=foo: foo-x.x.wtree.zf1ile.tar.gz
+git_dir_source_name: bar-foo-baz-x.x.wtree.zf20p7.tar.gz
+git_dir_source_name name=foo: foo-x.x.wtree.zf20p7.tar.gz
 git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_changelog:
+git_dir_changelog header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -121,15 +121,15 @@ git_cwd_name prepend=bar-:
 git_cwd_name prepend=bar- append=-baz: 
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.wtree.zf1ile
-git_cwd_version name=foo: 0.0.wtree.zf1ile
-git_cwd_version name=foo lead=1: 1.0.wtree.zf1ile
-git_cwd_version lead=0: 0.0.wtree.zf1ile
-git_cwd_version lead=1: 1.0.wtree.zf1ile
-git_cwd_version lead=0.1: 0.1.0.wtree.zf1ile
-git_cwd_version follow=1: 0.1.wtree.zf1ile
-git_cwd_version lead=1 follow=2: 1.2.wtree.zf1ile
-git_cwd_version lead=x follow=x: x.x.wtree.zf1ile
+git_cwd_version: 0.0.wtree.zf20p7
+git_cwd_version name=foo: 0.0.wtree.zf20p7
+git_cwd_version name=foo lead=1: 1.0.wtree.zf20p7
+git_cwd_version lead=0: 0.0.wtree.zf20p7
+git_cwd_version lead=1: 1.0.wtree.zf20p7
+git_cwd_version lead=0.1: 0.1.0.wtree.zf20p7
+git_cwd_version follow=1: 0.1.wtree.zf20p7
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf20p7
+git_cwd_version lead=x follow=x: x.x.wtree.zf20p7
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
@@ -149,23 +149,23 @@ git_cwd_archive dir_name=foo: foo-1.2.tar
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-x.x.wtree.zf1ile.tar.gz
-git_cwd_source_name name=foo: foo-x.x.wtree.zf1ile.tar.gz
+git_cwd_source_name: bar-foo-baz-x.x.wtree.zf20p7.tar.gz
+git_cwd_source_name name=foo: foo-x.x.wtree.zf20p7.tar.gz
 git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_cwd_changelog header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
diff --git a/tests/preproc/test_inited_origin_set/log b/tests/preproc/test_inited_origin_set/log
index 0e9bb1a..0c3b6e9 100644
--- a/tests/preproc/test_inited_origin_set/log
+++ b/tests/preproc/test_inited_origin_set/log
@@ -11,22 +11,31 @@
 > git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
+fatal: malformed object name HEAD
 ---
 > git_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
@@ -45,6 +54,7 @@ git_version: name cannot be empty.
 git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
+fatal: malformed object name HEAD
 ---
 > git_vcs
 ---
@@ -82,15 +92,20 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_source_name name=foo version=1.2 format=tar
 ---
-> git_changelog
+> git_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1
+> git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo until_tag=foo-1.2-1
+> git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
 > git_dir_name
 ---
@@ -105,22 +120,31 @@ git_archive: OUTDIR is not set. No action taken.
 > git_dir_name name=foo prepend=bar- append=-baz
 ---
 > git_dir_version
+fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_dir_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1-1 # invalid
 git_dir_version: lead and follow cannot contain dashes.
@@ -139,6 +163,7 @@ git_dir_version: name cannot be empty.
 git_dir_version name= # invalid failed with value 1
 ---
 > git_dir_version name="$(git_name)"
+fatal: malformed object name HEAD
 ---
 > git_dir_vcs
 ---
@@ -176,15 +201,20 @@ git_dir_archive: OUTDIR is not set. No action taken.
 ---
 > git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_dir_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
 > git_cwd_name
 ---
@@ -199,22 +229,31 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_cwd_name name=foo prepend=bar- append=-baz
 ---
 > git_cwd_version
+fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
@@ -233,6 +272,7 @@ git_cwd_version: name cannot be empty.
 git_cwd_version name= # invalid failed with value 1
 ---
 > git_cwd_version name="$(git_cwd_name)"
+fatal: malformed object name HEAD
 ---
 > git_cwd_vcs
 ---
@@ -270,13 +310,18 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 ---
 > git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_cwd_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
diff --git a/tests/preproc/test_inited_origin_set/output b/tests/preproc/test_inited_origin_set/output
index ffa1d1f..278bf6b 100644
--- a/tests/preproc/test_inited_origin_set/output
+++ b/tests/preproc/test_inited_origin_set/output
@@ -5,20 +5,20 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.wtree.zf1ilg
-git_version name=foo: 0.0.wtree.zf1ilg
-git_version name=foo lead=1: 1.0.wtree.zf1ilg
-git_version lead=0: 0.0.wtree.zf1ilg
-git_version lead=1: 1.0.wtree.zf1ilg
-git_version lead=0.1: 0.1.0.wtree.zf1ilg
-git_version follow=1: 0.1.wtree.zf1ilg
-git_version lead=1 follow=2: 1.2.wtree.zf1ilg
-git_version lead=x follow=x: x.x.wtree.zf1ilg
+git_version: 0.0.wtree.zf20p9
+git_version name=foo: 0.0.wtree.zf20p9
+git_version name=foo lead=1: 1.0.wtree.zf20p9
+git_version lead=0: 0.0.wtree.zf20p9
+git_version lead=1: 1.0.wtree.zf20p9
+git_version lead=0.1: 0.1.0.wtree.zf20p9
+git_version follow=1: 0.1.wtree.zf20p9
+git_version lead=1 follow=2: 1.2.wtree.zf20p9
+git_version lead=x follow=x: x.x.wtree.zf20p9
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.wtree.zf1ilg
+git_version name="$(git_name)": 0.0.wtree.zf20p9
 
 git_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -33,24 +33,24 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.wtree.zf1ilg.tar.gz
-git_source_name name=foo: foo-0.0.wtree.zf1ilg.tar.gz
+git_source_name: bar-foo-baz-0.0.wtree.zf20p9.tar.gz
+git_source_name name=foo: foo-0.0.wtree.zf20p9.tar.gz
 git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_changelog:
+git_changelog header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1:
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo until_tag=foo-1.2-1:
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -63,20 +63,20 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.wtree.zf1ilg
-git_dir_version name=foo: 0.0.wtree.zf1ilg
-git_dir_version name=foo lead=1: 1.0.wtree.zf1ilg
-git_dir_version lead=0: 0.0.wtree.zf1ilg
-git_dir_version lead=1: 1.0.wtree.zf1ilg
-git_dir_version lead=0.1: 0.1.0.wtree.zf1ilg
-git_dir_version follow=1: 0.1.wtree.zf1ilg
-git_dir_version lead=1 follow=2: 1.2.wtree.zf1ilg
-git_dir_version lead=x follow=x: x.x.wtree.zf1ilg
+git_dir_version: 0.0.wtree.zf20p9
+git_dir_version name=foo: 0.0.wtree.zf20p9
+git_dir_version name=foo lead=1: 1.0.wtree.zf20p9
+git_dir_version lead=0: 0.0.wtree.zf20p9
+git_dir_version lead=1: 1.0.wtree.zf20p9
+git_dir_version lead=0.1: 0.1.0.wtree.zf20p9
+git_dir_version follow=1: 0.1.wtree.zf20p9
+git_dir_version lead=1 follow=2: 1.2.wtree.zf20p9
+git_dir_version lead=x follow=x: x.x.wtree.zf20p9
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.wtree.zf1ilg
+git_dir_version name="$(git_name)": 0.0.wtree.zf20p9
 
 git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -91,24 +91,24 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.wtree.zf1ilg.tar.gz
-git_dir_source_name name=foo: foo-0.0.wtree.zf1ilg.tar.gz
+git_dir_source_name: bar-foo-baz-0.0.wtree.zf20p9.tar.gz
+git_dir_source_name name=foo: foo-0.0.wtree.zf20p9.tar.gz
 git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_changelog:
+git_dir_changelog header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -121,20 +121,20 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.wtree.zf1ilg
-git_cwd_version name=foo: 0.0.wtree.zf1ilg
-git_cwd_version name=foo lead=1: 1.0.wtree.zf1ilg
-git_cwd_version lead=0: 0.0.wtree.zf1ilg
-git_cwd_version lead=1: 1.0.wtree.zf1ilg
-git_cwd_version lead=0.1: 0.1.0.wtree.zf1ilg
-git_cwd_version follow=1: 0.1.wtree.zf1ilg
-git_cwd_version lead=1 follow=2: 1.2.wtree.zf1ilg
-git_cwd_version lead=x follow=x: x.x.wtree.zf1ilg
+git_cwd_version: 0.0.wtree.zf20p9
+git_cwd_version name=foo: 0.0.wtree.zf20p9
+git_cwd_version name=foo lead=1: 1.0.wtree.zf20p9
+git_cwd_version lead=0: 0.0.wtree.zf20p9
+git_cwd_version lead=1: 1.0.wtree.zf20p9
+git_cwd_version lead=0.1: 0.1.0.wtree.zf20p9
+git_cwd_version follow=1: 0.1.wtree.zf20p9
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf20p9
+git_cwd_version lead=x follow=x: x.x.wtree.zf20p9
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf1ilg
+git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf20p9
 
 git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -149,23 +149,23 @@ git_cwd_archive dir_name=foo: foo-1.2.tar
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.wtree.zf1ilg.tar.gz
-git_cwd_source_name name=foo: foo-0.0.wtree.zf1ilg.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.wtree.zf20p9.tar.gz
+git_cwd_source_name name=foo: foo-0.0.wtree.zf20p9.tar.gz
 git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_cwd_changelog header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
diff --git a/tests/preproc/test_sources/input b/tests/preproc/test_sources/input
index df366bb..bce89c2 100644
--- a/tests/preproc/test_sources/input
+++ b/tests/preproc/test_sources/input
@@ -1,2 +1,2 @@
-git_pack dir_name=foo source_name=foo.tar.gz: {{{ git_pack dir_name=foo source_name=foo.tar.gz }}}
-git_archive dir_name=foo source_name=foo.tar.gz: {{{ git_archive dir_name=foo source_name=foo.tar.gz }}}
+git_pack dir_name=foo source_name=foo.tar.gz
+git_archive dir_name=bar source_name=bar.tar.gz
diff --git a/tests/preproc/test_sources/log b/tests/preproc/test_sources/log
index ccf47ce..8371d80 100644
--- a/tests/preproc/test_sources/log
+++ b/tests/preproc/test_sources/log
@@ -1,6 +1,6 @@
 > git_pack dir_name=foo source_name=foo.tar.gz
 ---
-> git_archive dir_name=foo source_name=foo.tar.gz
+> git_archive dir_name=bar source_name=bar.tar.gz
 git_archive: No commits yet. Cannot archive the content.
-git_archive dir_name=foo source_name=foo.tar.gz failed with value 1
+git_archive dir_name=bar source_name=bar.tar.gz failed with value 1
 ---
diff --git a/tests/preproc/test_sources/output b/tests/preproc/test_sources/output
index 071b182..aadd726 100644
--- a/tests/preproc/test_sources/output
+++ b/tests/preproc/test_sources/output
@@ -1,2 +1,2 @@
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_archive dir_name=foo source_name=foo.tar.gz: 
+git_archive dir_name=bar source_name=bar.tar.gz: 
diff --git a/tests/preproc/test_sources/run.sh b/tests/preproc/test_sources/run.sh
index e295cc3..6db9861 100755
--- a/tests/preproc/test_sources/run.sh
+++ b/tests/preproc/test_sources/run.sh
@@ -9,16 +9,16 @@ prepare_input input $repo/input
 git init $repo
 
 touch output && cp output $output
-wtree_sub $repo $output
+
+echo 1 > $repo/cookie
 
 function custom_test {
     declare out= "$@"
-    local source_name="foo.tar.gz"
+    local source_name=foo.tar.gz
+    local dir_name=foo
 
-    echo "Checking for presence of source $source_name."
-    if ! [ -f "$out/$source_name" ]; then
-        die
-    fi
+    run "tar -C $out -xf $out/$source_name || die"
+    run "diff $out/$dir_name/cookie $repo/cookie || die"
 }
 
 generic_test opts='' path=$repo input=$repo/input expected_output=$output expected_log=log custom_test=custom_test copy_only=$1
diff --git a/tests/preproc/test_sources_committed/input b/tests/preproc/test_sources_committed/input
new file mode 100644
index 0000000..bce89c2
--- /dev/null
+++ b/tests/preproc/test_sources_committed/input
@@ -0,0 +1,2 @@
+git_pack dir_name=foo source_name=foo.tar.gz
+git_archive dir_name=bar source_name=bar.tar.gz
diff --git a/tests/preproc/test_sources_committed/log b/tests/preproc/test_sources_committed/log
new file mode 100644
index 0000000..fc626e7
--- /dev/null
+++ b/tests/preproc/test_sources_committed/log
@@ -0,0 +1,4 @@
+> git_pack dir_name=foo source_name=foo.tar.gz
+---
+> git_archive dir_name=bar source_name=bar.tar.gz
+---
diff --git a/tests/preproc/test_sources_committed/output b/tests/preproc/test_sources_committed/output
new file mode 100644
index 0000000..f32f325
--- /dev/null
+++ b/tests/preproc/test_sources_committed/output
@@ -0,0 +1,2 @@
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive dir_name=bar source_name=bar.tar.gz: bar.tar.gz
diff --git a/tests/preproc/test_sources_committed/run.sh b/tests/preproc/test_sources_committed/run.sh
new file mode 100755
index 0000000..0cc6ea0
--- /dev/null
+++ b/tests/preproc/test_sources_committed/run.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+prepare_input input $repo/input
+echo 1 > $repo/cookie
+
+git init $repo
+git -C $repo add -A
+git -C $repo commit -m 'commit 1'
+
+touch output && cp output $output
+
+function custom_test {
+    declare out= "$@"
+    local source_name1=foo.tar.gz
+    local source_name2=bar.tar.gz
+    local dir_name1=foo
+    local dir_name2=bar
+
+    run "tar -C $out -xf $out/$source_name1 || die"
+    run "diff $out/$dir_name1/cookie $repo/cookie || die"
+
+    run "tar -C $out -xf $out/$source_name2 || die"
+    run "diff $out/$dir_name2/cookie $repo/cookie || die"
+}
+
+generic_test opts='' path=$repo input=$repo/input expected_output=$output expected_log=log custom_test=custom_test copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_sources_subdir/input b/tests/preproc/test_sources_subdir/input
new file mode 100644
index 0000000..7d7c167
--- /dev/null
+++ b/tests/preproc/test_sources_subdir/input
@@ -0,0 +1,26 @@
+git_dir_name # cache
+git_dir_version # cache
+
+git_dir_pack source_name=foo_dir_nodirname.tar.gz
+git_dir_archive source_name=bar_dir_nodirname.tar.gz
+
+git_dir_pack dir_name=foo_dir source_name=foo_dir.tar.gz
+git_dir_archive dir_name=bar_dir source_name=bar_dir.tar.gz
+
+git_cwd_name # cache
+git_cwd_version # cache
+
+git_cwd_pack source_name=foo_cwd_nodirname.tar.gz
+git_cwd_archive source_name=bar_cwd_nodirname.tar.gz
+
+git_cwd_pack dir_name=foo_cwd source_name=foo_cwd.tar.gz
+git_cwd_archive dir_name=bar_cwd source_name=bar_cwd.tar.gz
+
+git_name # cache
+git_version # cache
+
+git_pack path=$(git rev-parse --show-toplevel)/subdir3 source_name=subdir3_foo_nodirname.tar.gz
+git_archive path=$(git rev-parse --show-toplevel)/subdir3 source_name=subdir3_bar_nodirname.tar.gz
+
+git_pack path=$(git rev-parse --show-toplevel)/subdir3 dir_name=subdir3_foo source_name=subdir3_foo.tar.gz
+git_archive path=$(git rev-parse --show-toplevel)/subdir3 dir_name=subdir3_bar source_name=subdir3_bar.tar.gz
diff --git a/tests/preproc/test_sources_subdir/log b/tests/preproc/test_sources_subdir/log
new file mode 100644
index 0000000..8d47dd5
--- /dev/null
+++ b/tests/preproc/test_sources_subdir/log
@@ -0,0 +1,36 @@
+> git_dir_name # cache
+---
+> git_dir_version # cache
+---
+> git_dir_pack source_name=foo_dir_nodirname.tar.gz
+---
+> git_dir_archive source_name=bar_dir_nodirname.tar.gz
+---
+> git_dir_pack dir_name=foo_dir source_name=foo_dir.tar.gz
+---
+> git_dir_archive dir_name=bar_dir source_name=bar_dir.tar.gz
+---
+> git_cwd_name # cache
+---
+> git_cwd_version # cache
+---
+> git_cwd_pack source_name=foo_cwd_nodirname.tar.gz
+---
+> git_cwd_archive source_name=bar_cwd_nodirname.tar.gz
+---
+> git_cwd_pack dir_name=foo_cwd source_name=foo_cwd.tar.gz
+---
+> git_cwd_archive dir_name=bar_cwd source_name=bar_cwd.tar.gz
+---
+> git_name # cache
+---
+> git_version # cache
+---
+> git_pack path=$(git rev-parse --show-toplevel)/subdir3 source_name=subdir3_foo_nodirname.tar.gz
+---
+> git_archive path=$(git rev-parse --show-toplevel)/subdir3 source_name=subdir3_bar_nodirname.tar.gz
+---
+> git_pack path=$(git rev-parse --show-toplevel)/subdir3 dir_name=subdir3_foo source_name=subdir3_foo.tar.gz
+---
+> git_archive path=$(git rev-parse --show-toplevel)/subdir3 dir_name=subdir3_bar source_name=subdir3_bar.tar.gz
+---
diff --git a/tests/preproc/test_sources_subdir/output b/tests/preproc/test_sources_subdir/output
new file mode 100644
index 0000000..acaf5d5
--- /dev/null
+++ b/tests/preproc/test_sources_subdir/output
@@ -0,0 +1,26 @@
+git_dir_name # cache: test-subdir2
+git_dir_version # cache: 0.4
+
+git_dir_pack source_name=foo_dir_nodirname.tar.gz: foo_dir_nodirname.tar.gz
+git_dir_archive source_name=bar_dir_nodirname.tar.gz: bar_dir_nodirname.tar.gz
+
+git_dir_pack dir_name=foo_dir source_name=foo_dir.tar.gz: foo_dir.tar.gz
+git_dir_archive dir_name=bar_dir source_name=bar_dir.tar.gz: bar_dir.tar.gz
+
+git_cwd_name # cache: test-subdir1
+git_cwd_version # cache: 0.4
+
+git_cwd_pack source_name=foo_cwd_nodirname.tar.gz: foo_cwd_nodirname.tar.gz
+git_cwd_archive source_name=bar_cwd_nodirname.tar.gz: bar_cwd_nodirname.tar.gz
+
+git_cwd_pack dir_name=foo_cwd source_name=foo_cwd.tar.gz: foo_cwd.tar.gz
+git_cwd_archive dir_name=bar_cwd source_name=bar_cwd.tar.gz: bar_cwd.tar.gz
+
+git_name # cache: test
+git_version # cache: 0.4
+
+git_pack path=$(git rev-parse --show-toplevel)/subdir3 source_name=subdir3_foo_nodirname.tar.gz: subdir3_foo_nodirname.tar.gz
+git_archive path=$(git rev-parse --show-toplevel)/subdir3 source_name=subdir3_bar_nodirname.tar.gz: subdir3_bar_nodirname.tar.gz
+
+git_pack path=$(git rev-parse --show-toplevel)/subdir3 dir_name=subdir3_foo source_name=subdir3_foo.tar.gz: subdir3_foo.tar.gz
+git_archive path=$(git rev-parse --show-toplevel)/subdir3 dir_name=subdir3_bar source_name=subdir3_bar.tar.gz: subdir3_bar.tar.gz
diff --git a/tests/preproc/test_sources_subdir/run.sh b/tests/preproc/test_sources_subdir/run.sh
new file mode 100755
index 0000000..e6e83e7
--- /dev/null
+++ b/tests/preproc/test_sources_subdir/run.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+mkdir $repo/subdir1 $repo/subdir2 $repo/subdir3
+prepare_input input $repo/subdir2/input
+echo 1 > $repo/subdir1/cookie
+echo 2 > $repo/subdir3/cookie
+echo 3 > $repo/subdir2/cookie
+
+git init $repo
+git -C $repo remote add origin https://pagure.io/clime/test.git
+git -C $repo add -A
+git -C $repo commit -m 'commit 1'
+git -C $repo tag -a -m 'tag message' test-0.4-1
+git -C $repo tag -a -m 'tag message' test-subdir1-0.4-1
+git -C $repo tag -a -m 'tag message' test-subdir2-0.4-1
+git -C $repo tag -a -m 'tag message' test-subdir3-0.4-1
+
+touch output && cp output $output
+
+function custom_test {
+    declare out= "$@"
+    run "tar -C $out -xf $out/foo_dir_nodirname.tar.gz || die"
+    run "diff $out/test-subdir2-0.4/cookie $repo/subdir2/cookie || die"
+
+    run "tar -C $out -xf $out/bar_dir_nodirname.tar.gz || die"
+    run "diff $out/test-subdir2-0.4/cookie $repo/subdir2/cookie || die"
+
+    run "tar -C $out -xf $out/foo_dir.tar.gz || die"
+    run "diff $out/foo_dir/cookie $repo/subdir2/cookie || die"
+
+    run "tar -C $out -xf $out/bar_dir.tar.gz || die"
+    run "diff $out/bar_dir/cookie $repo/subdir2/cookie || die"
+
+    run "tar -C $out -xf $out/foo_cwd_nodirname.tar.gz || die"
+    run "diff $out/test-subdir1-0.4/cookie $repo/subdir1/cookie || die"
+
+    run "tar -C $out -xf $out/bar_cwd_nodirname.tar.gz || die"
+    run "diff $out/test-subdir1-0.4/cookie $repo/subdir1/cookie || die"
+
+    run "tar -C $out -xf $out/foo_cwd.tar.gz || die"
+    run "diff $out/foo_cwd/cookie $repo/subdir1/cookie || die"
+
+    run "tar -C $out -xf $out/bar_cwd.tar.gz || die"
+    run "diff $out/bar_cwd/cookie $repo/subdir1/cookie || die"
+
+    run "tar -C $out -xf $out/subdir3_foo_nodirname.tar.gz || die"
+    run "diff $out/test-0.4/cookie $repo/subdir3/cookie || die"
+
+    run "tar -C $out -xf $out/subdir3_foo_nodirname.tar.gz || die"
+    run "diff $out/test-0.4/cookie $repo/subdir3/cookie || die"
+
+    run "tar -C $out -xf $out/subdir3_foo.tar.gz || die"
+    run "diff $out/subdir3_foo/cookie $repo/subdir3/cookie || die"
+
+    run "tar -C $out -xf $out/subdir3_bar.tar.gz || die"
+    run "diff $out/subdir3_bar/cookie $repo/subdir3/cookie || die"
+}
+
+generic_test opts='' path=$repo/subdir1 input=$repo/subdir2/input expected_output=$output expected_log=log custom_test=custom_test copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_subdir/log b/tests/preproc/test_subdir/log
index 0e9bb1a..0c3b6e9 100644
--- a/tests/preproc/test_subdir/log
+++ b/tests/preproc/test_subdir/log
@@ -11,22 +11,31 @@
 > git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
+fatal: malformed object name HEAD
 ---
 > git_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
@@ -45,6 +54,7 @@ git_version: name cannot be empty.
 git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
+fatal: malformed object name HEAD
 ---
 > git_vcs
 ---
@@ -82,15 +92,20 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_source_name name=foo version=1.2 format=tar
 ---
-> git_changelog
+> git_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1
+> git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo until_tag=foo-1.2-1
+> git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
 > git_dir_name
 ---
@@ -105,22 +120,31 @@ git_archive: OUTDIR is not set. No action taken.
 > git_dir_name name=foo prepend=bar- append=-baz
 ---
 > git_dir_version
+fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_dir_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1-1 # invalid
 git_dir_version: lead and follow cannot contain dashes.
@@ -139,6 +163,7 @@ git_dir_version: name cannot be empty.
 git_dir_version name= # invalid failed with value 1
 ---
 > git_dir_version name="$(git_name)"
+fatal: malformed object name HEAD
 ---
 > git_dir_vcs
 ---
@@ -176,15 +201,20 @@ git_dir_archive: OUTDIR is not set. No action taken.
 ---
 > git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_dir_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
 > git_cwd_name
 ---
@@ -199,22 +229,31 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_cwd_name name=foo prepend=bar- append=-baz
 ---
 > git_cwd_version
+fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo
+fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo lead=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0.1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version follow=1
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1 follow=2
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=x follow=x
+fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
@@ -233,6 +272,7 @@ git_cwd_version: name cannot be empty.
 git_cwd_version name= # invalid failed with value 1
 ---
 > git_cwd_version name="$(git_cwd_name)"
+fatal: malformed object name HEAD
 ---
 > git_cwd_vcs
 ---
@@ -270,13 +310,18 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 ---
 > git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_cwd_changelog header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: malformed object name HEAD
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: malformed object name HEAD
 ---
diff --git a/tests/preproc/test_subdir/output b/tests/preproc/test_subdir/output
index 9686478..9d3ffaa 100644
--- a/tests/preproc/test_subdir/output
+++ b/tests/preproc/test_subdir/output
@@ -5,20 +5,20 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.wtree.zf1ilj
-git_version name=foo: 0.0.wtree.zf1ilj
-git_version name=foo lead=1: 1.0.wtree.zf1ilj
-git_version lead=0: 0.0.wtree.zf1ilj
-git_version lead=1: 1.0.wtree.zf1ilj
-git_version lead=0.1: 0.1.0.wtree.zf1ilj
-git_version follow=1: 0.1.wtree.zf1ilj
-git_version lead=1 follow=2: 1.2.wtree.zf1ilj
-git_version lead=x follow=x: x.x.wtree.zf1ilj
+git_version: 0.0.wtree.zf20qd
+git_version name=foo: 0.0.wtree.zf20qd
+git_version name=foo lead=1: 1.0.wtree.zf20qd
+git_version lead=0: 0.0.wtree.zf20qd
+git_version lead=1: 1.0.wtree.zf20qd
+git_version lead=0.1: 0.1.0.wtree.zf20qd
+git_version follow=1: 0.1.wtree.zf20qd
+git_version lead=1 follow=2: 1.2.wtree.zf20qd
+git_version lead=x follow=x: x.x.wtree.zf20qd
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.wtree.zf1ilj
+git_version name="$(git_name)": 0.0.wtree.zf20qd
 
 git_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -33,24 +33,24 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.wtree.zf1ilj.tar.gz
-git_source_name name=foo: foo-0.0.wtree.zf1ilj.tar.gz
+git_source_name: bar-foo-baz-0.0.wtree.zf20qd.tar.gz
+git_source_name name=foo: foo-0.0.wtree.zf20qd.tar.gz
 git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_changelog:
+git_changelog header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1:
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo until_tag=foo-1.2-1:
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -63,20 +63,20 @@ git_dir_name prepend=bar-: bar-test-subdir2
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.wtree.zf1ilj
-git_dir_version name=foo: 0.0.wtree.zf1ilj
-git_dir_version name=foo lead=1: 1.0.wtree.zf1ilj
-git_dir_version lead=0: 0.0.wtree.zf1ilj
-git_dir_version lead=1: 1.0.wtree.zf1ilj
-git_dir_version lead=0.1: 0.1.0.wtree.zf1ilj
-git_dir_version follow=1: 0.1.wtree.zf1ilj
-git_dir_version lead=1 follow=2: 1.2.wtree.zf1ilj
-git_dir_version lead=x follow=x: x.x.wtree.zf1ilj
+git_dir_version: 0.0.wtree.zf20qd
+git_dir_version name=foo: 0.0.wtree.zf20qd
+git_dir_version name=foo lead=1: 1.0.wtree.zf20qd
+git_dir_version lead=0: 0.0.wtree.zf20qd
+git_dir_version lead=1: 1.0.wtree.zf20qd
+git_dir_version lead=0.1: 0.1.0.wtree.zf20qd
+git_dir_version follow=1: 0.1.wtree.zf20qd
+git_dir_version lead=1 follow=2: 1.2.wtree.zf20qd
+git_dir_version lead=x follow=x: x.x.wtree.zf20qd
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.wtree.zf1ilj
+git_dir_version name="$(git_name)": 0.0.wtree.zf20qd
 
 git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir2/
 git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -91,24 +91,24 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.wtree.zf1ilj.tar.gz
-git_dir_source_name name=foo: foo-0.0.wtree.zf1ilj.tar.gz
+git_dir_source_name: bar-foo-baz-0.0.wtree.zf20qd.tar.gz
+git_dir_source_name name=foo: foo-0.0.wtree.zf20qd.tar.gz
 git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_changelog:
+git_dir_changelog header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -121,20 +121,20 @@ git_cwd_name prepend=bar-: bar-test-subdir1
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.wtree.zf1ilj
-git_cwd_version name=foo: 0.0.wtree.zf1ilj
-git_cwd_version name=foo lead=1: 1.0.wtree.zf1ilj
-git_cwd_version lead=0: 0.0.wtree.zf1ilj
-git_cwd_version lead=1: 1.0.wtree.zf1ilj
-git_cwd_version lead=0.1: 0.1.0.wtree.zf1ilj
-git_cwd_version follow=1: 0.1.wtree.zf1ilj
-git_cwd_version lead=1 follow=2: 1.2.wtree.zf1ilj
-git_cwd_version lead=x follow=x: x.x.wtree.zf1ilj
+git_cwd_version: 0.0.wtree.zf20qd
+git_cwd_version name=foo: 0.0.wtree.zf20qd
+git_cwd_version name=foo lead=1: 1.0.wtree.zf20qd
+git_cwd_version lead=0: 0.0.wtree.zf20qd
+git_cwd_version lead=1: 1.0.wtree.zf20qd
+git_cwd_version lead=0.1: 0.1.0.wtree.zf20qd
+git_cwd_version follow=1: 0.1.wtree.zf20qd
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf20qd
+git_cwd_version lead=x follow=x: x.x.wtree.zf20qd
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf1ilj
+git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf20qd
 
 git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir1/
 git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
@@ -149,23 +149,23 @@ git_cwd_archive dir_name=foo: foo-1.2.tar
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.wtree.zf1ilj.tar.gz
-git_cwd_source_name name=foo: foo-0.0.wtree.zf1ilj.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.wtree.zf20qd.tar.gz
+git_cwd_source_name name=foo: foo-0.0.wtree.zf20qd.tar.gz
 git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_cwd_changelog header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
diff --git a/tests/preproc/test_tagged/log b/tests/preproc/test_tagged/log
index 0e9bb1a..9989773 100644
--- a/tests/preproc/test_tagged/log
+++ b/tests/preproc/test_tagged/log
@@ -82,15 +82,15 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_source_name name=foo version=1.2 format=tar
 ---
-> git_changelog
+> git_changelog header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1
+> git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_changelog name=foo until_tag=foo-1.2-1
+> git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
 > git_dir_name
 ---
@@ -176,15 +176,15 @@ git_dir_archive: OUTDIR is not set. No action taken.
 ---
 > git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_dir_changelog header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
 > git_cwd_name
 ---
@@ -270,13 +270,13 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 ---
 > git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_cwd_changelog header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
 ---
diff --git a/tests/preproc/test_tagged/output b/tests/preproc/test_tagged/output
index 8c581f1..9d076a0 100644
--- a/tests/preproc/test_tagged/output
+++ b/tests/preproc/test_tagged/output
@@ -5,23 +5,23 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.git.1.e76bf76
+git_version: 0.0.git.1.2dec15c
 git_version name=foo: 0.0
 git_version name=foo lead=1: 1.5
-git_version lead=0: 0.0.git.1.e76bf76
-git_version lead=1: 1.0.git.1.e76bf76
-git_version lead=0.1: 0.1.0.git.1.e76bf76
-git_version follow=1: 0.1.git.1.e76bf76
-git_version lead=1 follow=2: 1.2.git.1.e76bf76
-git_version lead=x follow=x: x.x.git.1.e76bf76
+git_version lead=0: 0.0.git.1.2dec15c
+git_version lead=1: 1.0.git.1.2dec15c
+git_version lead=0.1: 0.1.0.git.1.2dec15c
+git_version follow=1: 0.1.git.1.2dec15c
+git_version lead=1 follow=2: 1.2.git.1.2dec15c
+git_version lead=x follow=x: x.x.git.1.2dec15c
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.git.1.e76bf76
+git_version name="$(git_name)": 0.0.git.1.2dec15c
 
-git_vcs: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:foo
+git_vcs: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:foo
 
 git_pack: 
 git_pack dir_name=foo: 
@@ -33,57 +33,57 @@ git_archive dir_name=foo:
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.git.1.e76bf76.tar.gz
-git_source_name name=foo: foo-0.0.git.1.e76bf76.tar.gz
+git_source_name: bar-foo-baz-0.0.git.1.2dec15c.tar.gz
+git_source_name name=foo: foo-0.0.git.1.2dec15c.tar.gz
 git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_changelog:
+git_changelog header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.5-1
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.5-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long because we need to test git changelog
 family of macros and changelong body wrapping.
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-git_changelog name=foo until_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.1-1
+* @@@ clime <clime@redhat.com> 1.1-1
 - message
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long because we need to test git changelog
 family of macros and changelong body wrapping.
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.4-1
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long
 because we need to test git changelog
 family of macros and changelong body
 wrapping.
 
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
 
@@ -96,23 +96,23 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.git.1.e76bf76
+git_dir_version: 0.0.git.1.2dec15c
 git_dir_version name=foo: 0.0
 git_dir_version name=foo lead=1: 1.5
-git_dir_version lead=0: 0.0.git.1.e76bf76
-git_dir_version lead=1: 1.0.git.1.e76bf76
-git_dir_version lead=0.1: 0.1.0.git.1.e76bf76
-git_dir_version follow=1: 0.1.git.1.e76bf76
-git_dir_version lead=1 follow=2: 1.2.git.1.e76bf76
-git_dir_version lead=x follow=x: x.x.git.1.e76bf76
+git_dir_version lead=0: 0.0.git.1.2dec15c
+git_dir_version lead=1: 1.0.git.1.2dec15c
+git_dir_version lead=0.1: 0.1.0.git.1.2dec15c
+git_dir_version follow=1: 0.1.git.1.2dec15c
+git_dir_version lead=1 follow=2: 1.2.git.1.2dec15c
+git_dir_version lead=x follow=x: x.x.git.1.2dec15c
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.git.1.e76bf76
+git_dir_version name="$(git_name)": 0.0.git.1.2dec15c
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:foo
+git_dir_vcs: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:foo
 
 git_dir_pack: foo-1.2.tar
 git_dir_pack dir_name=foo: foo-1.2.tar
@@ -124,57 +124,57 @@ git_dir_archive dir_name=foo: foo-1.2.tar
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.git.1.e76bf76.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.1.e76bf76.tar.gz
+git_dir_source_name: bar-foo-baz-0.0.git.1.2dec15c.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.1.2dec15c.tar.gz
 git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_changelog:
+git_dir_changelog header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.5-1
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.5-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long because we need to test git changelog
 family of macros and changelong body wrapping.
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.1-1
+* @@@ clime <clime@redhat.com> 1.1-1
 - message
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long because we need to test git changelog
 family of macros and changelong body wrapping.
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.4-1
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long
 because we need to test git changelog
 family of macros and changelong body
 wrapping.
 
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
 
@@ -187,23 +187,23 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.git.1.e76bf76
+git_cwd_version: 0.0.git.1.2dec15c
 git_cwd_version name=foo: 0.0
 git_cwd_version name=foo lead=1: 1.5
-git_cwd_version lead=0: 0.0.git.1.e76bf76
-git_cwd_version lead=1: 1.0.git.1.e76bf76
-git_cwd_version lead=0.1: 0.1.0.git.1.e76bf76
-git_cwd_version follow=1: 0.1.git.1.e76bf76
-git_cwd_version lead=1 follow=2: 1.2.git.1.e76bf76
-git_cwd_version lead=x follow=x: x.x.git.1.e76bf76
+git_cwd_version lead=0: 0.0.git.1.2dec15c
+git_cwd_version lead=1: 1.0.git.1.2dec15c
+git_cwd_version lead=0.1: 0.1.0.git.1.2dec15c
+git_cwd_version follow=1: 0.1.git.1.2dec15c
+git_cwd_version lead=1 follow=2: 1.2.git.1.2dec15c
+git_cwd_version lead=x follow=x: x.x.git.1.2dec15c
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.git.1.e76bf76
+git_cwd_version name="$(git_cwd_name)": 0.0.git.1.2dec15c
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#e76bf76658517bd1e741efae439ffd6f927674f3:foo
+git_cwd_vcs: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:foo
 
 git_cwd_pack: foo-1.2.tar
 git_cwd_pack dir_name=foo: foo-1.2.tar
@@ -215,56 +215,56 @@ git_cwd_archive dir_name=foo: foo-1.2.tar
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.git.1.e76bf76.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.1.e76bf76.tar.gz
+git_cwd_source_name: bar-foo-baz-0.0.git.1.2dec15c.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.1.2dec15c.tar.gz
 git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_cwd_changelog header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.5-1
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.5-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long because we need to test git changelog
 family of macros and changelong body wrapping.
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.1-1
+* @@@ clime <clime@redhat.com> 1.1-1
 - message
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.4-1
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long because we need to test git changelog
 family of macros and changelong body wrapping.
 
-* Sat Mar 17 2018 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.4-1
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
+* @@@ clime <clime@redhat.com> 1.4-1
 - message
 
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.3-1
+* @@@ clime <clime@redhat.com> 1.3-1
 - message that should be %%very long
 because we need to test git changelog
 family of macros and changelong body
 wrapping.
 
-* 2018 Sat Mar 17 clime <clime@redhat.com> 1.2-1
+* @@@ clime <clime@redhat.com> 1.2-1
 - message
 
diff --git a/tests/preproc/test_tagged_commited/log b/tests/preproc/test_tagged_commited/log
deleted file mode 100644
index 0e9bb1a..0000000
--- a/tests/preproc/test_tagged_commited/log
+++ /dev/null
@@ -1,282 +0,0 @@
-> git_name
----
-> git_name name=foo
----
-> git_name append=-baz
----
-> git_name prepend=bar-
----
-> git_name prepend=bar- append=-baz
----
-> git_name name=foo prepend=bar- append=-baz
----
-> git_version
----
-> git_version name=foo
----
-> git_version name=foo lead=1
----
-> git_version lead=0
----
-> git_version lead=1
----
-> git_version lead=0.1
----
-> git_version follow=1
----
-> git_version lead=1 follow=2
----
-> git_version lead=x follow=x
----
-> git_version lead=1-1 # invalid
-git_version: lead and follow cannot contain dashes.
-git_version lead=1-1 # invalid failed with value 1
----
-> git_version follow=2.0 # invalid
-git_version: follow cannot contain dots.
-git_version follow=2.0 # invalid failed with value 1
----
-> git_version follow=2-2 # invalid
-git_version: lead and follow cannot contain dashes.
-git_version follow=2-2 # invalid failed with value 1
----
-> git_version name= # invalid
-git_version: name cannot be empty.
-git_version name= # invalid failed with value 1
----
-> git_version name="$(git_name)"
----
-> git_vcs
----
-> git_vcs subtree=foo
----
-> git_pack
-git_pack: OUTDIR is not set. No action taken.
----
-> git_pack dir_name=foo
-git_pack: OUTDIR is not set. No action taken.
----
-> git_pack dir_name=foo source_name=foo.tar.gz
-git_pack: OUTDIR is not set. No action taken.
----
-> git_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_pack: OUTDIR is not set. No action taken.
----
-> git_archive
-git_archive: OUTDIR is not set. No action taken.
----
-> git_archive dir_name=foo
-git_archive: OUTDIR is not set. No action taken.
----
-> git_archive dir_name=foo source_name=foo.tar.gz
-git_archive: OUTDIR is not set. No action taken.
----
-> git_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_archive: OUTDIR is not set. No action taken.
----
-> git_source_name
----
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
----
-> git_changelog
----
-> git_changelog name=foo since_tag=foo-1.2-1
----
-> git_changelog name=foo until_tag=foo-1.2-1
----
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
----
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
----
-> git_dir_name
----
-> git_dir_name name=foo
----
-> git_dir_name append=-baz
----
-> git_dir_name prepend=bar-
----
-> git_dir_name prepend=bar- append=-baz
----
-> git_dir_name name=foo prepend=bar- append=-baz
----
-> git_dir_version
----
-> git_dir_version name=foo
----
-> git_dir_version name=foo lead=1
----
-> git_dir_version lead=0
----
-> git_dir_version lead=1
----
-> git_dir_version lead=0.1
----
-> git_dir_version follow=1
----
-> git_dir_version lead=1 follow=2
----
-> git_dir_version lead=x follow=x
----
-> git_dir_version lead=1-1 # invalid
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version lead=1-1 # invalid failed with value 1
----
-> git_dir_version follow=2.0 # invalid
-git_dir_version: follow cannot contain dots.
-git_dir_version follow=2.0 # invalid failed with value 1
----
-> git_dir_version follow=2-2 # invalid
-git_dir_version: lead and follow cannot contain dashes.
-git_dir_version follow=2-2 # invalid failed with value 1
----
-> git_dir_version name= # invalid
-git_dir_version: name cannot be empty.
-git_dir_version name= # invalid failed with value 1
----
-> git_dir_version name="$(git_name)"
----
-> git_dir_vcs
----
-> git_dir_vcs subtree=foo
----
-> git_dir_pack
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack dir_name=foo
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack dir_name=foo source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_pack: OUTDIR is not set. No action taken.
----
-> git_dir_archive
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive dir_name=foo
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive dir_name=foo source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_dir_archive: OUTDIR is not set. No action taken.
----
-> git_dir_source_name
----
-> git_dir_source_name name=foo
----
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
----
-> git_dir_changelog
----
-> git_dir_changelog name=foo since_tag=foo-1.2-1
----
-> git_dir_changelog name=foo until_tag=foo-1.2-1
----
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
----
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
----
-> git_cwd_name
----
-> git_cwd_name name=foo
----
-> git_cwd_name append=-baz
----
-> git_cwd_name prepend=bar-
----
-> git_cwd_name prepend=bar- append=-baz
----
-> git_cwd_name name=foo prepend=bar- append=-baz
----
-> git_cwd_version
----
-> git_cwd_version name=foo
----
-> git_cwd_version name=foo lead=1
----
-> git_cwd_version lead=0
----
-> git_cwd_version lead=1
----
-> git_cwd_version lead=0.1
----
-> git_cwd_version follow=1
----
-> git_cwd_version lead=1 follow=2
----
-> git_cwd_version lead=x follow=x
----
-> git_cwd_version lead=1-1 # invalid
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version lead=1-1 # invalid failed with value 1
----
-> git_cwd_version follow=2.0 # invalid
-git_cwd_version: follow cannot contain dots.
-git_cwd_version follow=2.0 # invalid failed with value 1
----
-> git_cwd_version follow=2-2 # invalid
-git_cwd_version: lead and follow cannot contain dashes.
-git_cwd_version follow=2-2 # invalid failed with value 1
----
-> git_cwd_version name= # invalid
-git_cwd_version: name cannot be empty.
-git_cwd_version name= # invalid failed with value 1
----
-> git_cwd_version name="$(git_cwd_name)"
----
-> git_cwd_vcs
----
-> git_cwd_vcs subtree=foo
----
-> git_cwd_pack
-git_cwd_pack: OUTDIR is not set. No action taken.
----
-> git_cwd_pack dir_name=foo
-git_cwd_pack: OUTDIR is not set. No action taken.
----
-> git_cwd_pack dir_name=foo source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
----
-> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_pack: OUTDIR is not set. No action taken.
----
-> git_cwd_archive
-git_cwd_archive: OUTDIR is not set. No action taken.
----
-> git_cwd_archive dir_name=foo
-git_cwd_archive: OUTDIR is not set. No action taken.
----
-> git_cwd_archive dir_name=foo source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
----
-> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
-git_cwd_archive: OUTDIR is not set. No action taken.
----
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
----
-> git_cwd_source_name name=foo version=1.2 format=tar
----
-> git_cwd_changelog
----
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
----
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
----
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
----
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
----
diff --git a/tests/preproc/test_tagged_commited/output b/tests/preproc/test_tagged_commited/output
deleted file mode 100644
index 6049835..0000000
--- a/tests/preproc/test_tagged_commited/output
+++ /dev/null
@@ -1,174 +0,0 @@
-git_name: test
-git_name name=foo: foo
-git_name append=-baz: test-baz
-git_name prepend=bar-: bar-test
-git_name prepend=bar- append=-baz: bar-test-baz
-git_name name=foo prepend=bar- append=-baz: bar-foo-baz
-
-git_version: 0.0.git.2.fb775f4
-git_version name=foo: 0.1.git.1.fb775f4
-git_version name=foo lead=1: 1.0.git.1.fb775f4
-git_version lead=0: 0.0.git.2.fb775f4
-git_version lead=1: 1.0.git.2.fb775f4
-git_version lead=0.1: 0.1.0.git.2.fb775f4
-git_version follow=1: 0.1.git.2.fb775f4
-git_version lead=1 follow=2: 1.2.git.2.fb775f4
-git_version lead=x follow=x: x.x.git.2.fb775f4
-git_version lead=1-1 # invalid: 
-git_version follow=2.0 # invalid: 
-git_version follow=2-2 # invalid: 
-git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.git.2.fb775f4
-
-git_vcs: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:foo
-
-git_pack: 
-git_pack dir_name=foo: 
-git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_archive: 
-git_archive dir_name=foo: 
-git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_source_name: bar-foo-baz-0.0.git.2.fb775f4.tar.gz
-git_source_name name=foo: foo-0.0.git.2.fb775f4.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
-
-git_changelog:
-
-
-git_changelog name=foo since_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 0.1-1
-- message.
-
-git_changelog name=foo until_tag=foo-1.2-1:
-
-
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-
-
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-
-
-
-:::::::::::::::::::::
-
-git_dir_name: test-
-git_dir_name name=foo: foo-
-git_dir_name append=-baz: test-baz
-git_dir_name prepend=bar-: bar-test-
-git_dir_name prepend=bar- append=-baz: bar-test-baz
-git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
-
-git_dir_version: 0.0.git.2.fb775f4
-git_dir_version name=foo: 0.1.git.1.fb775f4
-git_dir_version name=foo lead=1: 1.0.git.1.fb775f4
-git_dir_version lead=0: 0.0.git.2.fb775f4
-git_dir_version lead=1: 1.0.git.2.fb775f4
-git_dir_version lead=0.1: 0.1.0.git.2.fb775f4
-git_dir_version follow=1: 0.1.git.2.fb775f4
-git_dir_version lead=1 follow=2: 1.2.git.2.fb775f4
-git_dir_version lead=x follow=x: x.x.git.2.fb775f4
-git_dir_version lead=1-1 # invalid: 
-git_dir_version follow=2.0 # invalid: 
-git_dir_version follow=2-2 # invalid: 
-git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.git.2.fb775f4
-
-git_dir_vcs: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:foo
-
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
-git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
-git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_dir_source_name: bar-foo-baz-0.0.git.2.fb775f4.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.2.fb775f4.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
-
-git_dir_changelog:
-
-
-git_dir_changelog name=foo since_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 0.1-1
-- message.
-
-git_dir_changelog name=foo until_tag=foo-1.2-1:
-
-
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-
-
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-
-
-
-:::::::::::::::::::::
-
-git_cwd_name: test-
-git_cwd_name name=foo: foo-
-git_cwd_name append=-baz: test-baz
-git_cwd_name prepend=bar-: bar-test-
-git_cwd_name prepend=bar- append=-baz: bar-test-baz
-git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
-
-git_cwd_version: 0.0.git.2.fb775f4
-git_cwd_version name=foo: 0.1.git.1.fb775f4
-git_cwd_version name=foo lead=1: 1.0.git.1.fb775f4
-git_cwd_version lead=0: 0.0.git.2.fb775f4
-git_cwd_version lead=1: 1.0.git.2.fb775f4
-git_cwd_version lead=0.1: 0.1.0.git.2.fb775f4
-git_cwd_version follow=1: 0.1.git.2.fb775f4
-git_cwd_version lead=1 follow=2: 1.2.git.2.fb775f4
-git_cwd_version lead=x follow=x: x.x.git.2.fb775f4
-git_cwd_version lead=1-1 # invalid: 
-git_cwd_version follow=2.0 # invalid: 
-git_cwd_version follow=2-2 # invalid: 
-git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.git.2.fb775f4
-
-git_cwd_vcs: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#fb775f4bd876b9db323abe6068fdee4bb8b45e4b:foo
-
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
-git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
-git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
-git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
-
-git_cwd_source_name: bar-foo-baz-0.0.git.2.fb775f4.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.2.fb775f4.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
-
-git_cwd_changelog:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
-* Sat Mar 17 2018 clime <clime@redhat.com> 0.1-1
-- message.
-
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
-
-
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
-
-
diff --git a/tests/preproc/test_tagged_commited/run.sh b/tests/preproc/test_tagged_commited/run.sh
deleted file mode 100755
index 8957f6e..0000000
--- a/tests/preproc/test_tagged_commited/run.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-
-. ../lib.sh
-
-repo=`mktemp -d`
-output=`mktemp`
-
-prepare_input ../input $repo/input
-
-git init $repo
-git -C $repo remote add origin https://pagure.io/clime/test.git
-git -C $repo add -A
-git -C $repo commit -a -m 'inital_commit'
-git -C $repo tag -a -m 'subject' -m '- message.' foo-0.1-1
-touch $repo/foo
-git -C $repo add foo
-git -C $repo commit -m 'commit after tag'
-
-touch output && cp output $output
-wtree_sub $repo $output
-head_commit_sub $repo $output
-
-generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
-
-rm -rf $repo
-rm $output
diff --git a/tests/preproc/test_tagged_committed/log b/tests/preproc/test_tagged_committed/log
new file mode 100644
index 0000000..9989773
--- /dev/null
+++ b/tests/preproc/test_tagged_committed/log
@@ -0,0 +1,282 @@
+> git_name
+---
+> git_name name=foo
+---
+> git_name append=-baz
+---
+> git_name prepend=bar-
+---
+> git_name prepend=bar- append=-baz
+---
+> git_name name=foo prepend=bar- append=-baz
+---
+> git_version
+---
+> git_version name=foo
+---
+> git_version name=foo lead=1
+---
+> git_version lead=0
+---
+> git_version lead=1
+---
+> git_version lead=0.1
+---
+> git_version follow=1
+---
+> git_version lead=1 follow=2
+---
+> git_version lead=x follow=x
+---
+> git_version lead=1-1 # invalid
+git_version: lead and follow cannot contain dashes.
+git_version lead=1-1 # invalid failed with value 1
+---
+> git_version follow=2.0 # invalid
+git_version: follow cannot contain dots.
+git_version follow=2.0 # invalid failed with value 1
+---
+> git_version follow=2-2 # invalid
+git_version: lead and follow cannot contain dashes.
+git_version follow=2-2 # invalid failed with value 1
+---
+> git_version name= # invalid
+git_version: name cannot be empty.
+git_version name= # invalid failed with value 1
+---
+> git_version name="$(git_name)"
+---
+> git_vcs
+---
+> git_vcs subtree=foo
+---
+> git_pack
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack dir_name=foo source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_pack: OUTDIR is not set. No action taken.
+---
+> git_archive
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive dir_name=foo source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_archive: OUTDIR is not set. No action taken.
+---
+> git_source_name
+---
+> git_source_name name=foo
+---
+> git_source_name version=1.2
+---
+> git_source_name name=foo version=1.2 format=tar
+---
+> git_changelog header_date_format="@@@"
+---
+> git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+---
+> git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+---
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+---
+> git_dir_name
+---
+> git_dir_name name=foo
+---
+> git_dir_name append=-baz
+---
+> git_dir_name prepend=bar-
+---
+> git_dir_name prepend=bar- append=-baz
+---
+> git_dir_name name=foo prepend=bar- append=-baz
+---
+> git_dir_version
+---
+> git_dir_version name=foo
+---
+> git_dir_version name=foo lead=1
+---
+> git_dir_version lead=0
+---
+> git_dir_version lead=1
+---
+> git_dir_version lead=0.1
+---
+> git_dir_version follow=1
+---
+> git_dir_version lead=1 follow=2
+---
+> git_dir_version lead=x follow=x
+---
+> git_dir_version lead=1-1 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version lead=1-1 # invalid failed with value 1
+---
+> git_dir_version follow=2.0 # invalid
+git_dir_version: follow cannot contain dots.
+git_dir_version follow=2.0 # invalid failed with value 1
+---
+> git_dir_version follow=2-2 # invalid
+git_dir_version: lead and follow cannot contain dashes.
+git_dir_version follow=2-2 # invalid failed with value 1
+---
+> git_dir_version name= # invalid
+git_dir_version: name cannot be empty.
+git_dir_version name= # invalid failed with value 1
+---
+> git_dir_version name="$(git_name)"
+---
+> git_dir_vcs
+---
+> git_dir_vcs subtree=foo
+---
+> git_dir_pack
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack dir_name=foo source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_pack: OUTDIR is not set. No action taken.
+---
+> git_dir_archive
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive dir_name=foo source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_dir_archive: OUTDIR is not set. No action taken.
+---
+> git_dir_source_name
+---
+> git_dir_source_name name=foo
+---
+> git_dir_source_name version=1.2
+---
+> git_dir_source_name name=foo version=1.2 format=tar
+---
+> git_dir_changelog header_date_format="@@@"
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+---
+> git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+---
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+---
+> git_cwd_name
+---
+> git_cwd_name name=foo
+---
+> git_cwd_name append=-baz
+---
+> git_cwd_name prepend=bar-
+---
+> git_cwd_name prepend=bar- append=-baz
+---
+> git_cwd_name name=foo prepend=bar- append=-baz
+---
+> git_cwd_version
+---
+> git_cwd_version name=foo
+---
+> git_cwd_version name=foo lead=1
+---
+> git_cwd_version lead=0
+---
+> git_cwd_version lead=1
+---
+> git_cwd_version lead=0.1
+---
+> git_cwd_version follow=1
+---
+> git_cwd_version lead=1 follow=2
+---
+> git_cwd_version lead=x follow=x
+---
+> git_cwd_version lead=1-1 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version lead=1-1 # invalid failed with value 1
+---
+> git_cwd_version follow=2.0 # invalid
+git_cwd_version: follow cannot contain dots.
+git_cwd_version follow=2.0 # invalid failed with value 1
+---
+> git_cwd_version follow=2-2 # invalid
+git_cwd_version: lead and follow cannot contain dashes.
+git_cwd_version follow=2-2 # invalid failed with value 1
+---
+> git_cwd_version name= # invalid
+git_cwd_version: name cannot be empty.
+git_cwd_version name= # invalid failed with value 1
+---
+> git_cwd_version name="$(git_cwd_name)"
+---
+> git_cwd_vcs
+---
+> git_cwd_vcs subtree=foo
+---
+> git_cwd_pack
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack dir_name=foo source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_pack: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive dir_name=foo source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
+git_cwd_archive: OUTDIR is not set. No action taken.
+---
+> git_cwd_source_name
+---
+> git_cwd_source_name name=foo
+---
+> git_cwd_source_name version=1.2
+---
+> git_cwd_source_name name=foo version=1.2 format=tar
+---
+> git_cwd_changelog header_date_format="@@@"
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+---
+> git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+---
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+---
diff --git a/tests/preproc/test_tagged_committed/output b/tests/preproc/test_tagged_committed/output
new file mode 100644
index 0000000..f945d0a
--- /dev/null
+++ b/tests/preproc/test_tagged_committed/output
@@ -0,0 +1,174 @@
+git_name: test
+git_name name=foo: foo
+git_name append=-baz: test-baz
+git_name prepend=bar-: bar-test
+git_name prepend=bar- append=-baz: bar-test-baz
+git_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_version: 0.0.git.2.763bb86
+git_version name=foo: 0.1.git.1.763bb86
+git_version name=foo lead=1: 1.0.git.1.763bb86
+git_version lead=0: 0.0.git.2.763bb86
+git_version lead=1: 1.0.git.2.763bb86
+git_version lead=0.1: 0.1.0.git.2.763bb86
+git_version follow=1: 0.1.git.2.763bb86
+git_version lead=1 follow=2: 1.2.git.2.763bb86
+git_version lead=x follow=x: x.x.git.2.763bb86
+git_version lead=1-1 # invalid: 
+git_version follow=2.0 # invalid: 
+git_version follow=2-2 # invalid: 
+git_version name= # invalid: 
+git_version name="$(git_name)": 0.0.git.2.763bb86
+
+git_vcs: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:foo
+
+git_pack: 
+git_pack dir_name=foo: 
+git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_archive: 
+git_archive dir_name=foo: 
+git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_source_name: bar-foo-baz-0.0.git.2.763bb86.tar.gz
+git_source_name name=foo: foo-0.0.git.2.763bb86.tar.gz
+git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_changelog header_date_format="@@@":
+
+
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 0.1-1
+- message.
+
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
+
+
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
+
+
+
+:::::::::::::::::::::
+
+git_dir_name: test-
+git_dir_name name=foo: foo-
+git_dir_name append=-baz: test-baz
+git_dir_name prepend=bar-: bar-test-
+git_dir_name prepend=bar- append=-baz: bar-test-baz
+git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_dir_version: 0.0.git.2.763bb86
+git_dir_version name=foo: 0.1.git.1.763bb86
+git_dir_version name=foo lead=1: 1.0.git.1.763bb86
+git_dir_version lead=0: 0.0.git.2.763bb86
+git_dir_version lead=1: 1.0.git.2.763bb86
+git_dir_version lead=0.1: 0.1.0.git.2.763bb86
+git_dir_version follow=1: 0.1.git.2.763bb86
+git_dir_version lead=1 follow=2: 1.2.git.2.763bb86
+git_dir_version lead=x follow=x: x.x.git.2.763bb86
+git_dir_version lead=1-1 # invalid: 
+git_dir_version follow=2.0 # invalid: 
+git_dir_version follow=2-2 # invalid: 
+git_dir_version name= # invalid: 
+git_dir_version name="$(git_name)": 0.0.git.2.763bb86
+
+git_dir_vcs: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:foo
+
+git_dir_pack: foo-1.2.tar
+git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_archive: foo-1.2.tar
+git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_dir_source_name: bar-foo-baz-0.0.git.2.763bb86.tar.gz
+git_dir_source_name name=foo: foo-0.0.git.2.763bb86.tar.gz
+git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_dir_changelog header_date_format="@@@":
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 0.1-1
+- message.
+
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
+
+
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
+
+
+
+:::::::::::::::::::::
+
+git_cwd_name: test-
+git_cwd_name name=foo: foo-
+git_cwd_name append=-baz: test-baz
+git_cwd_name prepend=bar-: bar-test-
+git_cwd_name prepend=bar- append=-baz: bar-test-baz
+git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
+
+git_cwd_version: 0.0.git.2.763bb86
+git_cwd_version name=foo: 0.1.git.1.763bb86
+git_cwd_version name=foo lead=1: 1.0.git.1.763bb86
+git_cwd_version lead=0: 0.0.git.2.763bb86
+git_cwd_version lead=1: 1.0.git.2.763bb86
+git_cwd_version lead=0.1: 0.1.0.git.2.763bb86
+git_cwd_version follow=1: 0.1.git.2.763bb86
+git_cwd_version lead=1 follow=2: 1.2.git.2.763bb86
+git_cwd_version lead=x follow=x: x.x.git.2.763bb86
+git_cwd_version lead=1-1 # invalid: 
+git_cwd_version follow=2.0 # invalid: 
+git_cwd_version follow=2-2 # invalid: 
+git_cwd_version name= # invalid: 
+git_cwd_version name="$(git_cwd_name)": 0.0.git.2.763bb86
+
+git_cwd_vcs: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:foo
+
+git_cwd_pack: foo-1.2.tar
+git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_archive: foo-1.2.tar
+git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
+git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
+
+git_cwd_source_name: bar-foo-baz-0.0.git.2.763bb86.tar.gz
+git_cwd_source_name name=foo: foo-0.0.git.2.763bb86.tar.gz
+git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
+git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+
+git_cwd_changelog header_date_format="@@@":
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
+* @@@ clime <clime@redhat.com> 0.1-1
+- message.
+
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
+
+
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
+
+
diff --git a/tests/preproc/test_tagged_committed/run.sh b/tests/preproc/test_tagged_committed/run.sh
new file mode 100755
index 0000000..8957f6e
--- /dev/null
+++ b/tests/preproc/test_tagged_committed/run.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+. ../lib.sh
+
+repo=`mktemp -d`
+output=`mktemp`
+
+prepare_input ../input $repo/input
+
+git init $repo
+git -C $repo remote add origin https://pagure.io/clime/test.git
+git -C $repo add -A
+git -C $repo commit -a -m 'inital_commit'
+git -C $repo tag -a -m 'subject' -m '- message.' foo-0.1-1
+touch $repo/foo
+git -C $repo add foo
+git -C $repo commit -m 'commit after tag'
+
+touch output && cp output $output
+wtree_sub $repo $output
+head_commit_sub $repo $output
+
+generic_test opts='--dump-spec-only' path=$repo input=$repo/input expected_output=$output expected_log=log copy_only=$1
+
+rm -rf $repo
+rm $output
diff --git a/tests/preproc/test_uninited/log b/tests/preproc/test_uninited/log
index e0ff85a..63984b8 100644
--- a/tests/preproc/test_uninited/log
+++ b/tests/preproc/test_uninited/log
@@ -21,38 +21,56 @@ git_name prepend=bar- append=-baz failed with value 1
 > git_version
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version name=foo lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=0
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=0.1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version follow=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=1 follow=2
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=x follow=x
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
@@ -131,15 +149,25 @@ git_archive: OUTDIR is not set. No action taken.
 ---
 > git_source_name name=foo version=1.2 format=tar
 ---
-> git_changelog
+> git_changelog header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_changelog name=foo since_tag=foo-1.2-1
+> git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_changelog name=foo until_tag=foo-1.2-1
+> git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_name
 fatal: Not a git repository (or any parent up to mount point /)
@@ -176,38 +204,56 @@ Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 > git_dir_version
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version name=foo lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=0
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=0.1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version follow=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=1 follow=2
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=x follow=x
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=1-1 # invalid
 git_dir_version: lead and follow cannot contain dashes.
@@ -290,15 +336,25 @@ git_dir_archive: OUTDIR is not set. No action taken.
 ---
 > git_dir_source_name name=foo version=1.2 format=tar
 ---
-> git_dir_changelog
+> git_dir_changelog header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_changelog name=foo until_tag=foo-1.2-1
+> git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_name
 fatal: Not a git repository (or any parent up to mount point /)
@@ -335,38 +391,56 @@ Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 > git_cwd_version
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version name=foo lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=0
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=0.1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version follow=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=1 follow=2
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=x follow=x
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
@@ -451,13 +525,23 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 ---
 > git_cwd_source_name name=foo version=1.2 format=tar
 ---
-> git_cwd_changelog
+> git_cwd_changelog header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_changelog name=foo until_tag=foo-1.2-1
+> git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
-> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42
+> git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
+fatal: Not a git repository (or any parent up to mount point /)
+Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
diff --git a/tests/preproc/test_uninited/output b/tests/preproc/test_uninited/output
index a8ccfb0..e2bf04f 100644
--- a/tests/preproc/test_uninited/output
+++ b/tests/preproc/test_uninited/output
@@ -38,19 +38,19 @@ git_source_name name=foo: foo-x.x.tar.gz
 git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_changelog:
+git_changelog header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1:
+git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo until_tag=foo-1.2-1:
+git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -96,19 +96,19 @@ git_dir_source_name name=foo: foo-x.x.tar.gz
 git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_dir_changelog:
+git_dir_changelog header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo until_tag=foo-1.2-1:
+git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 
 
@@ -154,18 +154,18 @@ git_cwd_source_name name=foo: foo-x.x.tar.gz
 git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
 git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
 
-git_cwd_changelog:
+git_cwd_changelog header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo until_tag=foo-1.2-1:
+git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@":
 
 
-git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="%Y %a %b %d" body_wrap=42:
+git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42:
 
 

From 774b8058723854efe242e705ec53dda45dee7a1e Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 88/104] no source_name macros, alias (cached git_name)-(cached git_version)


---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 523b373..58d8aa5 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -80,6 +80,10 @@ function log {
     fi > /dev/stderr
 }
 
+function cached_name_version {
+    echo -n "$(cached git_name)-$(cached git_version)"
+}
+
 ############## REPO FUNCTIONS ##############
 
 function git_name {
@@ -215,7 +219,7 @@ function git_vcs {
 }
 
 function git_pack {
-    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
+    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached_name_version)" source_name="$(cached_name_version).tar.gz" "$@"
 
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
@@ -239,7 +243,7 @@ function git_pack {
 }
 
 function git_archive {
-    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached git_name)-$(cached git_version)" source_name="$(cached git_source_name)" "$@"
+    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached_name_version)" source_name="$(cached_name_version).tar.gz" "$@"
 
     if [ -z "$OUTDIR" ]; then
         log_debug "OUTDIR is not set. No action taken."
@@ -272,13 +276,8 @@ function git_archive {
     output "$source_name"
 }
 
-function git_source_name {
-    declare name="$(cached git_name)" version="$(cached git_version)" format=tar.gz "$@"
-    output "$name-$version.$format"
-}
-
 function git_setup_macro {
-    declare dir_name="$(cached git_name)-$(cached git_version)" "$@"
+    declare dir_name="$(cached_name_version)" "$@"
     output "%setup -q -n $dir_name"
 }
 
@@ -346,10 +345,6 @@ function git_dir_archive {
     git_archive path="$(dirname "$INPUT_PATH")" "$@"
 }
 
-function git_dir_source_name {
-    git_source_name "$@"
-}
-
 function git_dir_setup_macro {
     git_setup_macro "$@"
 }
@@ -380,10 +375,6 @@ function git_cwd_archive {
     git_archive path="$(pwd)" "$@"
 }
 
-function git_cwd_source_name {
-    git_source_name "$@"
-}
-
 function git_cwd_setup_macro {
     git_setup_macro "$@"
 }

From f2e4b55996bdb7624b4ed8de14bd8dbddb6e56a1 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 89/104] fix position of 2> /dev/null when fetching tags


* on repo with no commit, we are otherwise getting fatal: malformed object name HEAD

---

diff --git a/rpkglib/preproc/lib.sh b/rpkglib/preproc/lib.sh
index 58d8aa5..cecd3d0 100644
--- a/rpkglib/preproc/lib.sh
+++ b/rpkglib/preproc/lib.sh
@@ -149,7 +149,7 @@ function git_version {
         return 1
     fi
     
-    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name*" --merged | filter_tags "$name" 2> /dev/null)
+    mapfile -t tags < <(git tag --list --sort=taggerdate:unix "$name*" --merged 2> /dev/null | filter_tags "$name")
 
     if [ ${#tags[@]} -gt 0 ]; then
         latest_tag="${tags[-1]}"
@@ -284,7 +284,7 @@ function git_setup_macro {
 function git_changelog {
     declare name="$(cached git_name)" since_tag= until_tag= header_locale=POSIX header_date_format="%a %b %d %Y" body_wrap=80 "$@"
 
-    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name*" --merged | filter_tags "$name" 2> /dev/null)
+    mapfile -t tags < <(git tag --list --sort=-taggerdate:unix "$name*" --merged 2> /dev/null | filter_tags "$name")
 
     if [ -n "$header_date_format" ]; then
         header_date_format_suffix=":format:$header_date_format"

From f77e6962c63a413cfd2ee855f4c6542e91043e55 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:48:27 +0000
Subject: [PATCH 90/104] drop source_name tests (method does not exist), add setup_macro tests, regenerate


---

diff --git a/tests/preproc/input b/tests/preproc/input
index 79039f1..17f606a 100644
--- a/tests/preproc/input
+++ b/tests/preproc/input
@@ -33,10 +33,8 @@ git_archive dir_name=foo
 git_archive dir_name=foo source_name=foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz
 
-git_source_name
-git_source_name name=foo
-git_source_name version=1.2
-git_source_name name=foo version=1.2 format=tar
+git_setup_macro
+git_setup_macro dir_name=foo
 
 git_changelog header_date_format="@@@" ::
 git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@" ::
@@ -81,10 +79,8 @@ git_dir_archive dir_name=foo
 git_dir_archive dir_name=foo source_name=foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 
-git_dir_source_name
-git_dir_source_name name=foo
-git_dir_source_name version=1.2
-git_dir_source_name name=foo version=1.2 format=tar
+git_dir_setup_macro
+git_dir_setup_macro dir_name=foo
 
 git_dir_changelog header_date_format="@@@" ::
 git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@" ::
@@ -129,10 +125,8 @@ git_cwd_archive dir_name=foo
 git_cwd_archive dir_name=foo source_name=foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
 
-git_cwd_source_name
-git_cwd_source_name name=foo
-git_cwd_source_name version=1.2
-git_cwd_source_name name=foo version=1.2 format=tar
+git_cwd_setup_macro
+git_cwd_setup_macro dir_name=foo
 
 git_cwd_changelog header_date_format="@@@" ::
 git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@" ::
diff --git a/tests/preproc/test_committed/log b/tests/preproc/test_committed/log
index 9989773..8b63298 100644
--- a/tests/preproc/test_committed/log
+++ b/tests/preproc/test_committed/log
@@ -74,13 +74,9 @@ git_archive: OUTDIR is not set. No action taken.
 > git_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_archive: OUTDIR is not set. No action taken.
 ---
-> git_source_name
+> git_setup_macro
 ---
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
+> git_setup_macro dir_name=foo
 ---
 > git_changelog header_date_format="@@@"
 ---
@@ -168,13 +164,9 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
----
-> git_dir_source_name name=foo
+> git_dir_setup_macro
 ---
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_dir_setup_macro dir_name=foo
 ---
 > git_dir_changelog header_date_format="@@@"
 ---
@@ -262,13 +254,9 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 > git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
+> git_cwd_setup_macro
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_cwd_setup_macro dir_name=foo
 ---
 > git_cwd_changelog header_date_format="@@@"
 ---
diff --git a/tests/preproc/test_committed/output b/tests/preproc/test_committed/output
index cfccf53..625e304 100644
--- a/tests/preproc/test_committed/output
+++ b/tests/preproc/test_committed/output
@@ -5,38 +5,36 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.git.3.afae168
-git_version name=foo: 0.0.git.3.afae168
-git_version name=foo lead=1: 1.0.git.3.afae168
-git_version lead=0: 0.0.git.3.afae168
-git_version lead=1: 1.0.git.3.afae168
-git_version lead=0.1: 0.1.0.git.3.afae168
-git_version follow=1: 0.1.git.3.afae168
-git_version lead=1 follow=2: 1.2.git.3.afae168
-git_version lead=x follow=x: x.x.git.3.afae168
+git_version: 0.0.git.3.3a65415
+git_version name=foo: 0.0.git.3.3a65415
+git_version name=foo lead=1: 1.0.git.3.3a65415
+git_version lead=0: 0.0.git.3.3a65415
+git_version lead=1: 1.0.git.3.3a65415
+git_version lead=0.1: 0.1.0.git.3.3a65415
+git_version follow=1: 0.1.git.3.3a65415
+git_version lead=1 follow=2: 1.2.git.3.3a65415
+git_version lead=x follow=x: x.x.git.3.3a65415
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.git.3.afae168
+git_version name="$(git_name)": 0.0.git.3.3a65415
 
-git_vcs: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:foo
+git_vcs: git+https://pagure.io/clime/test.git#3a654158d0451b7e7a079e33cd71e06d65b4da15:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#3a654158d0451b7e7a079e33cd71e06d65b4da15:foo
 
-git_pack: 
-git_pack dir_name=foo: 
+git_pack: bar-foo-baz-0.0.git.3.3a65415.tar.gz
+git_pack dir_name=foo: bar-foo-baz-0.0.git.3.3a65415.tar.gz
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_archive: 
-git_archive dir_name=foo: 
+git_archive: bar-foo-baz-0.0.git.3.3a65415.tar.gz
+git_archive dir_name=foo: bar-foo-baz-0.0.git.3.3a65415.tar.gz
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.git.3.afae168.tar.gz
-git_source_name name=foo: foo-0.0.git.3.afae168.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_setup_macro: %setup -q -n bar-foo-baz-0.0.git.3.3a65415
+git_setup_macro dir_name=foo: %setup -q -n foo
 
 git_changelog header_date_format="@@@":
 
@@ -63,38 +61,36 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.git.3.afae168
-git_dir_version name=foo: 0.0.git.3.afae168
-git_dir_version name=foo lead=1: 1.0.git.3.afae168
-git_dir_version lead=0: 0.0.git.3.afae168
-git_dir_version lead=1: 1.0.git.3.afae168
-git_dir_version lead=0.1: 0.1.0.git.3.afae168
-git_dir_version follow=1: 0.1.git.3.afae168
-git_dir_version lead=1 follow=2: 1.2.git.3.afae168
-git_dir_version lead=x follow=x: x.x.git.3.afae168
+git_dir_version: 0.0.git.3.3a65415
+git_dir_version name=foo: 0.0.git.3.3a65415
+git_dir_version name=foo lead=1: 1.0.git.3.3a65415
+git_dir_version lead=0: 0.0.git.3.3a65415
+git_dir_version lead=1: 1.0.git.3.3a65415
+git_dir_version lead=0.1: 0.1.0.git.3.3a65415
+git_dir_version follow=1: 0.1.git.3.3a65415
+git_dir_version lead=1 follow=2: 1.2.git.3.3a65415
+git_dir_version lead=x follow=x: x.x.git.3.3a65415
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.git.3.afae168
+git_dir_version name="$(git_name)": 0.0.git.3.3a65415
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:foo
+git_dir_vcs: git+https://pagure.io/clime/test.git#3a654158d0451b7e7a079e33cd71e06d65b4da15:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#3a654158d0451b7e7a079e33cd71e06d65b4da15:foo
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack: bar-foo-baz-0.0.git.3.3a65415.tar.gz
+git_dir_pack dir_name=foo: bar-foo-baz-0.0.git.3.3a65415.tar.gz
 git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive: bar-foo-baz-0.0.git.3.3a65415.tar.gz
+git_dir_archive dir_name=foo: bar-foo-baz-0.0.git.3.3a65415.tar.gz
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.git.3.afae168.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.3.afae168.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_setup_macro: %setup -q -n bar-foo-baz-0.0.git.3.3a65415
+git_dir_setup_macro dir_name=foo: %setup -q -n foo
 
 git_dir_changelog header_date_format="@@@":
 
@@ -121,38 +117,36 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.git.3.afae168
-git_cwd_version name=foo: 0.0.git.3.afae168
-git_cwd_version name=foo lead=1: 1.0.git.3.afae168
-git_cwd_version lead=0: 0.0.git.3.afae168
-git_cwd_version lead=1: 1.0.git.3.afae168
-git_cwd_version lead=0.1: 0.1.0.git.3.afae168
-git_cwd_version follow=1: 0.1.git.3.afae168
-git_cwd_version lead=1 follow=2: 1.2.git.3.afae168
-git_cwd_version lead=x follow=x: x.x.git.3.afae168
+git_cwd_version: 0.0.git.3.3a65415
+git_cwd_version name=foo: 0.0.git.3.3a65415
+git_cwd_version name=foo lead=1: 1.0.git.3.3a65415
+git_cwd_version lead=0: 0.0.git.3.3a65415
+git_cwd_version lead=1: 1.0.git.3.3a65415
+git_cwd_version lead=0.1: 0.1.0.git.3.3a65415
+git_cwd_version follow=1: 0.1.git.3.3a65415
+git_cwd_version lead=1 follow=2: 1.2.git.3.3a65415
+git_cwd_version lead=x follow=x: x.x.git.3.3a65415
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.git.3.afae168
+git_cwd_version name="$(git_cwd_name)": 0.0.git.3.3a65415
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#afae168434e47a7e437e17ae0a7958d081f546c8:foo
+git_cwd_vcs: git+https://pagure.io/clime/test.git#3a654158d0451b7e7a079e33cd71e06d65b4da15:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#3a654158d0451b7e7a079e33cd71e06d65b4da15:foo
 
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack: bar-foo-baz-0.0.git.3.3a65415.tar.gz
+git_cwd_pack dir_name=foo: bar-foo-baz-0.0.git.3.3a65415.tar.gz
 git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive: bar-foo-baz-0.0.git.3.3a65415.tar.gz
+git_cwd_archive dir_name=foo: bar-foo-baz-0.0.git.3.3a65415.tar.gz
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.git.3.afae168.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.3.afae168.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_setup_macro: %setup -q -n bar-foo-baz-0.0.git.3.3a65415
+git_cwd_setup_macro dir_name=foo: %setup -q -n foo
 
 git_cwd_changelog header_date_format="@@@":
 
diff --git a/tests/preproc/test_dirty/log b/tests/preproc/test_dirty/log
index 9989773..8b63298 100644
--- a/tests/preproc/test_dirty/log
+++ b/tests/preproc/test_dirty/log
@@ -74,13 +74,9 @@ git_archive: OUTDIR is not set. No action taken.
 > git_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_archive: OUTDIR is not set. No action taken.
 ---
-> git_source_name
+> git_setup_macro
 ---
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
+> git_setup_macro dir_name=foo
 ---
 > git_changelog header_date_format="@@@"
 ---
@@ -168,13 +164,9 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
----
-> git_dir_source_name name=foo
+> git_dir_setup_macro
 ---
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_dir_setup_macro dir_name=foo
 ---
 > git_dir_changelog header_date_format="@@@"
 ---
@@ -262,13 +254,9 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 > git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
+> git_cwd_setup_macro
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_cwd_setup_macro dir_name=foo
 ---
 > git_cwd_changelog header_date_format="@@@"
 ---
diff --git a/tests/preproc/test_dirty/output b/tests/preproc/test_dirty/output
index f413891..ff421c1 100644
--- a/tests/preproc/test_dirty/output
+++ b/tests/preproc/test_dirty/output
@@ -5,38 +5,36 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.git.1.d41b65e.wtree.zf20p5
-git_version name=foo: 0.0.git.1.d41b65e.wtree.zf20p5
-git_version name=foo lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
-git_version lead=0: 0.0.git.1.d41b65e.wtree.zf20p5
-git_version lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
-git_version lead=0.1: 0.1.0.git.1.d41b65e.wtree.zf20p5
-git_version follow=1: 0.1.git.1.d41b65e.wtree.zf20p5
-git_version lead=1 follow=2: 1.2.git.1.d41b65e.wtree.zf20p5
-git_version lead=x follow=x: x.x.git.1.d41b65e.wtree.zf20p5
+git_version: 0.0.git.1.658a6b9.wtree.zf25ry
+git_version name=foo: 0.0.git.1.658a6b9.wtree.zf25ry
+git_version name=foo lead=1: 1.0.git.1.658a6b9.wtree.zf25ry
+git_version lead=0: 0.0.git.1.658a6b9.wtree.zf25ry
+git_version lead=1: 1.0.git.1.658a6b9.wtree.zf25ry
+git_version lead=0.1: 0.1.0.git.1.658a6b9.wtree.zf25ry
+git_version follow=1: 0.1.git.1.658a6b9.wtree.zf25ry
+git_version lead=1 follow=2: 1.2.git.1.658a6b9.wtree.zf25ry
+git_version lead=x follow=x: x.x.git.1.658a6b9.wtree.zf25ry
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.git.1.d41b65e.wtree.zf20p5
+git_version name="$(git_name)": 0.0.git.1.658a6b9.wtree.zf25ry
 
-git_vcs: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:foo
+git_vcs: git+https://pagure.io/clime/test.git#658a6b9173503d2e90f57a848d44e8c4da2558d1:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#658a6b9173503d2e90f57a848d44e8c4da2558d1:foo
 
-git_pack: 
-git_pack dir_name=foo: 
+git_pack: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
+git_pack dir_name=foo: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_archive: 
-git_archive dir_name=foo: 
+git_archive: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
+git_archive dir_name=foo: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
-git_source_name name=foo: foo-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_setup_macro: %setup -q -n bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry
+git_setup_macro dir_name=foo: %setup -q -n foo
 
 git_changelog header_date_format="@@@":
 
@@ -63,38 +61,36 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.git.1.d41b65e.wtree.zf20p5
-git_dir_version name=foo: 0.0.git.1.d41b65e.wtree.zf20p5
-git_dir_version name=foo lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
-git_dir_version lead=0: 0.0.git.1.d41b65e.wtree.zf20p5
-git_dir_version lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
-git_dir_version lead=0.1: 0.1.0.git.1.d41b65e.wtree.zf20p5
-git_dir_version follow=1: 0.1.git.1.d41b65e.wtree.zf20p5
-git_dir_version lead=1 follow=2: 1.2.git.1.d41b65e.wtree.zf20p5
-git_dir_version lead=x follow=x: x.x.git.1.d41b65e.wtree.zf20p5
+git_dir_version: 0.0.git.1.658a6b9.wtree.zf25ry
+git_dir_version name=foo: 0.0.git.1.658a6b9.wtree.zf25ry
+git_dir_version name=foo lead=1: 1.0.git.1.658a6b9.wtree.zf25ry
+git_dir_version lead=0: 0.0.git.1.658a6b9.wtree.zf25ry
+git_dir_version lead=1: 1.0.git.1.658a6b9.wtree.zf25ry
+git_dir_version lead=0.1: 0.1.0.git.1.658a6b9.wtree.zf25ry
+git_dir_version follow=1: 0.1.git.1.658a6b9.wtree.zf25ry
+git_dir_version lead=1 follow=2: 1.2.git.1.658a6b9.wtree.zf25ry
+git_dir_version lead=x follow=x: x.x.git.1.658a6b9.wtree.zf25ry
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.git.1.d41b65e.wtree.zf20p5
+git_dir_version name="$(git_name)": 0.0.git.1.658a6b9.wtree.zf25ry
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:foo
+git_dir_vcs: git+https://pagure.io/clime/test.git#658a6b9173503d2e90f57a848d44e8c4da2558d1:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#658a6b9173503d2e90f57a848d44e8c4da2558d1:foo
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
+git_dir_pack dir_name=foo: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
 git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
+git_dir_archive dir_name=foo: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_setup_macro: %setup -q -n bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry
+git_dir_setup_macro dir_name=foo: %setup -q -n foo
 
 git_dir_changelog header_date_format="@@@":
 
@@ -121,38 +117,36 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.git.1.d41b65e.wtree.zf20p5
-git_cwd_version name=foo: 0.0.git.1.d41b65e.wtree.zf20p5
-git_cwd_version name=foo lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
-git_cwd_version lead=0: 0.0.git.1.d41b65e.wtree.zf20p5
-git_cwd_version lead=1: 1.0.git.1.d41b65e.wtree.zf20p5
-git_cwd_version lead=0.1: 0.1.0.git.1.d41b65e.wtree.zf20p5
-git_cwd_version follow=1: 0.1.git.1.d41b65e.wtree.zf20p5
-git_cwd_version lead=1 follow=2: 1.2.git.1.d41b65e.wtree.zf20p5
-git_cwd_version lead=x follow=x: x.x.git.1.d41b65e.wtree.zf20p5
+git_cwd_version: 0.0.git.1.658a6b9.wtree.zf25ry
+git_cwd_version name=foo: 0.0.git.1.658a6b9.wtree.zf25ry
+git_cwd_version name=foo lead=1: 1.0.git.1.658a6b9.wtree.zf25ry
+git_cwd_version lead=0: 0.0.git.1.658a6b9.wtree.zf25ry
+git_cwd_version lead=1: 1.0.git.1.658a6b9.wtree.zf25ry
+git_cwd_version lead=0.1: 0.1.0.git.1.658a6b9.wtree.zf25ry
+git_cwd_version follow=1: 0.1.git.1.658a6b9.wtree.zf25ry
+git_cwd_version lead=1 follow=2: 1.2.git.1.658a6b9.wtree.zf25ry
+git_cwd_version lead=x follow=x: x.x.git.1.658a6b9.wtree.zf25ry
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.git.1.d41b65e.wtree.zf20p5
+git_cwd_version name="$(git_cwd_name)": 0.0.git.1.658a6b9.wtree.zf25ry
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#d41b65efa0e91e90d7a2e4c4220fcc9f65001611:foo
+git_cwd_vcs: git+https://pagure.io/clime/test.git#658a6b9173503d2e90f57a848d44e8c4da2558d1:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#658a6b9173503d2e90f57a848d44e8c4da2558d1:foo
 
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
+git_cwd_pack dir_name=foo: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
 git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
+git_cwd_archive dir_name=foo: bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry.tar.gz
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.1.d41b65e.wtree.zf20p5.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_setup_macro: %setup -q -n bar-foo-baz-0.0.git.1.658a6b9.wtree.zf25ry
+git_cwd_setup_macro dir_name=foo: %setup -q -n foo
 
 git_cwd_changelog header_date_format="@@@":
 
diff --git a/tests/preproc/test_inited/log b/tests/preproc/test_inited/log
index 124c8f6..b47978a 100644
--- a/tests/preproc/test_inited/log
+++ b/tests/preproc/test_inited/log
@@ -19,31 +19,22 @@ git_name prepend=bar- append=-baz failed with value 1
 > git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
-fatal: malformed object name HEAD
 ---
 > git_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
@@ -98,28 +89,19 @@ git_archive: OUTDIR is not set. No action taken.
 > git_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_archive: OUTDIR is not set. No action taken.
 ---
-> git_source_name
+> git_setup_macro
 ---
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
+> git_setup_macro dir_name=foo
 ---
 > git_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
 > git_dir_name
 git_dir_name: Start by setting origin URL.
@@ -142,31 +124,22 @@ git_dir_name prepend=bar- append=-baz failed with value 1
 > git_dir_name name=foo prepend=bar- append=-baz
 ---
 > git_dir_version
-fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_dir_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1-1 # invalid
 git_dir_version: lead and follow cannot contain dashes.
@@ -221,28 +194,19 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
----
-> git_dir_source_name name=foo
+> git_dir_setup_macro
 ---
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_dir_setup_macro dir_name=foo
 ---
 > git_dir_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
 > git_cwd_name
 git_cwd_name: Start by setting origin URL.
@@ -265,31 +229,22 @@ git_cwd_name prepend=bar- append=-baz failed with value 1
 > git_cwd_name name=foo prepend=bar- append=-baz
 ---
 > git_cwd_version
-fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
@@ -344,26 +299,17 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 > git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
+> git_cwd_setup_macro
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_cwd_setup_macro dir_name=foo
 ---
 > git_cwd_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
diff --git a/tests/preproc/test_inited/output b/tests/preproc/test_inited/output
index 4d99b64..daec387 100644
--- a/tests/preproc/test_inited/output
+++ b/tests/preproc/test_inited/output
@@ -5,15 +5,15 @@ git_name prepend=bar-:
 git_name prepend=bar- append=-baz: 
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.wtree.zf20p7
-git_version name=foo: 0.0.wtree.zf20p7
-git_version name=foo lead=1: 1.0.wtree.zf20p7
-git_version lead=0: 0.0.wtree.zf20p7
-git_version lead=1: 1.0.wtree.zf20p7
-git_version lead=0.1: 0.1.0.wtree.zf20p7
-git_version follow=1: 0.1.wtree.zf20p7
-git_version lead=1 follow=2: 1.2.wtree.zf20p7
-git_version lead=x follow=x: x.x.wtree.zf20p7
+git_version: 0.0.wtree.zf25r0
+git_version name=foo: 0.0.wtree.zf25r0
+git_version name=foo lead=1: 1.0.wtree.zf25r0
+git_version lead=0: 0.0.wtree.zf25r0
+git_version lead=1: 1.0.wtree.zf25r0
+git_version lead=0.1: 0.1.0.wtree.zf25r0
+git_version follow=1: 0.1.wtree.zf25r0
+git_version lead=1 follow=2: 1.2.wtree.zf25r0
+git_version lead=x follow=x: x.x.wtree.zf25r0
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
@@ -23,20 +23,18 @@ git_version name="$(git_name)":
 git_vcs: 
 git_vcs subtree=foo: 
 
-git_pack: 
-git_pack dir_name=foo: 
+git_pack: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
+git_pack dir_name=foo: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_archive: 
-git_archive dir_name=foo: 
+git_archive: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
+git_archive dir_name=foo: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-x.x.wtree.zf20p7.tar.gz
-git_source_name name=foo: foo-x.x.wtree.zf20p7.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_setup_macro: %setup -q -n bar-foo-baz-x.x.wtree.zf25r0
+git_setup_macro dir_name=foo: %setup -q -n foo
 
 git_changelog header_date_format="@@@":
 
@@ -63,15 +61,15 @@ git_dir_name prepend=bar-:
 git_dir_name prepend=bar- append=-baz: 
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.wtree.zf20p7
-git_dir_version name=foo: 0.0.wtree.zf20p7
-git_dir_version name=foo lead=1: 1.0.wtree.zf20p7
-git_dir_version lead=0: 0.0.wtree.zf20p7
-git_dir_version lead=1: 1.0.wtree.zf20p7
-git_dir_version lead=0.1: 0.1.0.wtree.zf20p7
-git_dir_version follow=1: 0.1.wtree.zf20p7
-git_dir_version lead=1 follow=2: 1.2.wtree.zf20p7
-git_dir_version lead=x follow=x: x.x.wtree.zf20p7
+git_dir_version: 0.0.wtree.zf25r0
+git_dir_version name=foo: 0.0.wtree.zf25r0
+git_dir_version name=foo lead=1: 1.0.wtree.zf25r0
+git_dir_version lead=0: 0.0.wtree.zf25r0
+git_dir_version lead=1: 1.0.wtree.zf25r0
+git_dir_version lead=0.1: 0.1.0.wtree.zf25r0
+git_dir_version follow=1: 0.1.wtree.zf25r0
+git_dir_version lead=1 follow=2: 1.2.wtree.zf25r0
+git_dir_version lead=x follow=x: x.x.wtree.zf25r0
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
@@ -81,20 +79,18 @@ git_dir_version name="$(git_name)":
 git_dir_vcs: 
 git_dir_vcs subtree=foo: 
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
+git_dir_pack dir_name=foo: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
 git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
+git_dir_archive dir_name=foo: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-x.x.wtree.zf20p7.tar.gz
-git_dir_source_name name=foo: foo-x.x.wtree.zf20p7.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_setup_macro: %setup -q -n bar-foo-baz-x.x.wtree.zf25r0
+git_dir_setup_macro dir_name=foo: %setup -q -n foo
 
 git_dir_changelog header_date_format="@@@":
 
@@ -121,15 +117,15 @@ git_cwd_name prepend=bar-:
 git_cwd_name prepend=bar- append=-baz: 
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.wtree.zf20p7
-git_cwd_version name=foo: 0.0.wtree.zf20p7
-git_cwd_version name=foo lead=1: 1.0.wtree.zf20p7
-git_cwd_version lead=0: 0.0.wtree.zf20p7
-git_cwd_version lead=1: 1.0.wtree.zf20p7
-git_cwd_version lead=0.1: 0.1.0.wtree.zf20p7
-git_cwd_version follow=1: 0.1.wtree.zf20p7
-git_cwd_version lead=1 follow=2: 1.2.wtree.zf20p7
-git_cwd_version lead=x follow=x: x.x.wtree.zf20p7
+git_cwd_version: 0.0.wtree.zf25r0
+git_cwd_version name=foo: 0.0.wtree.zf25r0
+git_cwd_version name=foo lead=1: 1.0.wtree.zf25r0
+git_cwd_version lead=0: 0.0.wtree.zf25r0
+git_cwd_version lead=1: 1.0.wtree.zf25r0
+git_cwd_version lead=0.1: 0.1.0.wtree.zf25r0
+git_cwd_version follow=1: 0.1.wtree.zf25r0
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf25r0
+git_cwd_version lead=x follow=x: x.x.wtree.zf25r0
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
@@ -139,20 +135,18 @@ git_cwd_version name="$(git_cwd_name)":
 git_cwd_vcs: 
 git_cwd_vcs subtree=foo: 
 
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
+git_cwd_pack dir_name=foo: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
 git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
+git_cwd_archive dir_name=foo: bar-foo-baz-x.x.wtree.zf25r0.tar.gz
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-x.x.wtree.zf20p7.tar.gz
-git_cwd_source_name name=foo: foo-x.x.wtree.zf20p7.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_setup_macro: %setup -q -n bar-foo-baz-x.x.wtree.zf25r0
+git_cwd_setup_macro dir_name=foo: %setup -q -n foo
 
 git_cwd_changelog header_date_format="@@@":
 
diff --git a/tests/preproc/test_inited_origin_set/log b/tests/preproc/test_inited_origin_set/log
index 0c3b6e9..8b63298 100644
--- a/tests/preproc/test_inited_origin_set/log
+++ b/tests/preproc/test_inited_origin_set/log
@@ -11,31 +11,22 @@
 > git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
-fatal: malformed object name HEAD
 ---
 > git_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
@@ -54,7 +45,6 @@ git_version: name cannot be empty.
 git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
-fatal: malformed object name HEAD
 ---
 > git_vcs
 ---
@@ -84,28 +74,19 @@ git_archive: OUTDIR is not set. No action taken.
 > git_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_archive: OUTDIR is not set. No action taken.
 ---
-> git_source_name
+> git_setup_macro
 ---
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
+> git_setup_macro dir_name=foo
 ---
 > git_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
 > git_dir_name
 ---
@@ -120,31 +101,22 @@ fatal: malformed object name HEAD
 > git_dir_name name=foo prepend=bar- append=-baz
 ---
 > git_dir_version
-fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_dir_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1-1 # invalid
 git_dir_version: lead and follow cannot contain dashes.
@@ -163,7 +135,6 @@ git_dir_version: name cannot be empty.
 git_dir_version name= # invalid failed with value 1
 ---
 > git_dir_version name="$(git_name)"
-fatal: malformed object name HEAD
 ---
 > git_dir_vcs
 ---
@@ -193,28 +164,19 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
----
-> git_dir_source_name name=foo
+> git_dir_setup_macro
 ---
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_dir_setup_macro dir_name=foo
 ---
 > git_dir_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
 > git_cwd_name
 ---
@@ -229,31 +191,22 @@ fatal: malformed object name HEAD
 > git_cwd_name name=foo prepend=bar- append=-baz
 ---
 > git_cwd_version
-fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
@@ -272,7 +225,6 @@ git_cwd_version: name cannot be empty.
 git_cwd_version name= # invalid failed with value 1
 ---
 > git_cwd_version name="$(git_cwd_name)"
-fatal: malformed object name HEAD
 ---
 > git_cwd_vcs
 ---
@@ -302,26 +254,17 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 > git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
+> git_cwd_setup_macro
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_cwd_setup_macro dir_name=foo
 ---
 > git_cwd_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
diff --git a/tests/preproc/test_inited_origin_set/output b/tests/preproc/test_inited_origin_set/output
index 278bf6b..55ea95f 100644
--- a/tests/preproc/test_inited_origin_set/output
+++ b/tests/preproc/test_inited_origin_set/output
@@ -5,38 +5,36 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.wtree.zf20p9
-git_version name=foo: 0.0.wtree.zf20p9
-git_version name=foo lead=1: 1.0.wtree.zf20p9
-git_version lead=0: 0.0.wtree.zf20p9
-git_version lead=1: 1.0.wtree.zf20p9
-git_version lead=0.1: 0.1.0.wtree.zf20p9
-git_version follow=1: 0.1.wtree.zf20p9
-git_version lead=1 follow=2: 1.2.wtree.zf20p9
-git_version lead=x follow=x: x.x.wtree.zf20p9
+git_version: 0.0.wtree.zf25r2
+git_version name=foo: 0.0.wtree.zf25r2
+git_version name=foo lead=1: 1.0.wtree.zf25r2
+git_version lead=0: 0.0.wtree.zf25r2
+git_version lead=1: 1.0.wtree.zf25r2
+git_version lead=0.1: 0.1.0.wtree.zf25r2
+git_version follow=1: 0.1.wtree.zf25r2
+git_version lead=1 follow=2: 1.2.wtree.zf25r2
+git_version lead=x follow=x: x.x.wtree.zf25r2
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.wtree.zf20p9
+git_version name="$(git_name)": 0.0.wtree.zf25r2
 
 git_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
 
-git_pack: 
-git_pack dir_name=foo: 
+git_pack: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
+git_pack dir_name=foo: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_archive: 
-git_archive dir_name=foo: 
+git_archive: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
+git_archive dir_name=foo: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.wtree.zf20p9.tar.gz
-git_source_name name=foo: foo-0.0.wtree.zf20p9.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_setup_macro: %setup -q -n bar-foo-baz-0.0.wtree.zf25r2
+git_setup_macro dir_name=foo: %setup -q -n foo
 
 git_changelog header_date_format="@@@":
 
@@ -63,38 +61,36 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.wtree.zf20p9
-git_dir_version name=foo: 0.0.wtree.zf20p9
-git_dir_version name=foo lead=1: 1.0.wtree.zf20p9
-git_dir_version lead=0: 0.0.wtree.zf20p9
-git_dir_version lead=1: 1.0.wtree.zf20p9
-git_dir_version lead=0.1: 0.1.0.wtree.zf20p9
-git_dir_version follow=1: 0.1.wtree.zf20p9
-git_dir_version lead=1 follow=2: 1.2.wtree.zf20p9
-git_dir_version lead=x follow=x: x.x.wtree.zf20p9
+git_dir_version: 0.0.wtree.zf25r2
+git_dir_version name=foo: 0.0.wtree.zf25r2
+git_dir_version name=foo lead=1: 1.0.wtree.zf25r2
+git_dir_version lead=0: 0.0.wtree.zf25r2
+git_dir_version lead=1: 1.0.wtree.zf25r2
+git_dir_version lead=0.1: 0.1.0.wtree.zf25r2
+git_dir_version follow=1: 0.1.wtree.zf25r2
+git_dir_version lead=1 follow=2: 1.2.wtree.zf25r2
+git_dir_version lead=x follow=x: x.x.wtree.zf25r2
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.wtree.zf20p9
+git_dir_version name="$(git_name)": 0.0.wtree.zf25r2
 
 git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
+git_dir_pack dir_name=foo: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
 git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
+git_dir_archive dir_name=foo: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.wtree.zf20p9.tar.gz
-git_dir_source_name name=foo: foo-0.0.wtree.zf20p9.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_setup_macro: %setup -q -n bar-foo-baz-0.0.wtree.zf25r2
+git_dir_setup_macro dir_name=foo: %setup -q -n foo
 
 git_dir_changelog header_date_format="@@@":
 
@@ -121,38 +117,36 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.wtree.zf20p9
-git_cwd_version name=foo: 0.0.wtree.zf20p9
-git_cwd_version name=foo lead=1: 1.0.wtree.zf20p9
-git_cwd_version lead=0: 0.0.wtree.zf20p9
-git_cwd_version lead=1: 1.0.wtree.zf20p9
-git_cwd_version lead=0.1: 0.1.0.wtree.zf20p9
-git_cwd_version follow=1: 0.1.wtree.zf20p9
-git_cwd_version lead=1 follow=2: 1.2.wtree.zf20p9
-git_cwd_version lead=x follow=x: x.x.wtree.zf20p9
+git_cwd_version: 0.0.wtree.zf25r2
+git_cwd_version name=foo: 0.0.wtree.zf25r2
+git_cwd_version name=foo lead=1: 1.0.wtree.zf25r2
+git_cwd_version lead=0: 0.0.wtree.zf25r2
+git_cwd_version lead=1: 1.0.wtree.zf25r2
+git_cwd_version lead=0.1: 0.1.0.wtree.zf25r2
+git_cwd_version follow=1: 0.1.wtree.zf25r2
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf25r2
+git_cwd_version lead=x follow=x: x.x.wtree.zf25r2
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf20p9
+git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf25r2
 
 git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
 
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
+git_cwd_pack dir_name=foo: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
 git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
+git_cwd_archive dir_name=foo: bar-foo-baz-0.0.wtree.zf25r2.tar.gz
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.wtree.zf20p9.tar.gz
-git_cwd_source_name name=foo: foo-0.0.wtree.zf20p9.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_setup_macro: %setup -q -n bar-foo-baz-0.0.wtree.zf25r2
+git_cwd_setup_macro dir_name=foo: %setup -q -n foo
 
 git_cwd_changelog header_date_format="@@@":
 
diff --git a/tests/preproc/test_subdir/log b/tests/preproc/test_subdir/log
index 0c3b6e9..8b63298 100644
--- a/tests/preproc/test_subdir/log
+++ b/tests/preproc/test_subdir/log
@@ -11,31 +11,22 @@
 > git_name name=foo prepend=bar- append=-baz
 ---
 > git_version
-fatal: malformed object name HEAD
 ---
 > git_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
@@ -54,7 +45,6 @@ git_version: name cannot be empty.
 git_version name= # invalid failed with value 1
 ---
 > git_version name="$(git_name)"
-fatal: malformed object name HEAD
 ---
 > git_vcs
 ---
@@ -84,28 +74,19 @@ git_archive: OUTDIR is not set. No action taken.
 > git_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_archive: OUTDIR is not set. No action taken.
 ---
-> git_source_name
+> git_setup_macro
 ---
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
+> git_setup_macro dir_name=foo
 ---
 > git_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
 > git_dir_name
 ---
@@ -120,31 +101,22 @@ fatal: malformed object name HEAD
 > git_dir_name name=foo prepend=bar- append=-baz
 ---
 > git_dir_version
-fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_dir_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_dir_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_dir_version lead=1-1 # invalid
 git_dir_version: lead and follow cannot contain dashes.
@@ -163,7 +135,6 @@ git_dir_version: name cannot be empty.
 git_dir_version name= # invalid failed with value 1
 ---
 > git_dir_version name="$(git_name)"
-fatal: malformed object name HEAD
 ---
 > git_dir_vcs
 ---
@@ -193,28 +164,19 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
----
-> git_dir_source_name name=foo
+> git_dir_setup_macro
 ---
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_dir_setup_macro dir_name=foo
 ---
 > git_dir_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
 > git_cwd_name
 ---
@@ -229,31 +191,22 @@ fatal: malformed object name HEAD
 > git_cwd_name name=foo prepend=bar- append=-baz
 ---
 > git_cwd_version
-fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo
-fatal: malformed object name HEAD
 ---
 > git_cwd_version name=foo lead=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=0.1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version follow=1
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1 follow=2
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=x follow=x
-fatal: malformed object name HEAD
 ---
 > git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
@@ -272,7 +225,6 @@ git_cwd_version: name cannot be empty.
 git_cwd_version name= # invalid failed with value 1
 ---
 > git_cwd_version name="$(git_cwd_name)"
-fatal: malformed object name HEAD
 ---
 > git_cwd_vcs
 ---
@@ -302,26 +254,17 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 > git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
+> git_cwd_setup_macro
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_cwd_setup_macro dir_name=foo
 ---
 > git_cwd_changelog header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: malformed object name HEAD
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: malformed object name HEAD
 ---
diff --git a/tests/preproc/test_subdir/output b/tests/preproc/test_subdir/output
index 9d3ffaa..8433973 100644
--- a/tests/preproc/test_subdir/output
+++ b/tests/preproc/test_subdir/output
@@ -5,38 +5,36 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.wtree.zf20qd
-git_version name=foo: 0.0.wtree.zf20qd
-git_version name=foo lead=1: 1.0.wtree.zf20qd
-git_version lead=0: 0.0.wtree.zf20qd
-git_version lead=1: 1.0.wtree.zf20qd
-git_version lead=0.1: 0.1.0.wtree.zf20qd
-git_version follow=1: 0.1.wtree.zf20qd
-git_version lead=1 follow=2: 1.2.wtree.zf20qd
-git_version lead=x follow=x: x.x.wtree.zf20qd
+git_version: 0.0.wtree.zf25r6
+git_version name=foo: 0.0.wtree.zf25r6
+git_version name=foo lead=1: 1.0.wtree.zf25r6
+git_version lead=0: 0.0.wtree.zf25r6
+git_version lead=1: 1.0.wtree.zf25r6
+git_version lead=0.1: 0.1.0.wtree.zf25r6
+git_version follow=1: 0.1.wtree.zf25r6
+git_version lead=1 follow=2: 1.2.wtree.zf25r6
+git_version lead=x follow=x: x.x.wtree.zf25r6
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.wtree.zf20qd
+git_version name="$(git_name)": 0.0.wtree.zf25r6
 
 git_vcs: git+https://pagure.io/clime/test.git#HEAD:
 git_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
 
-git_pack: 
-git_pack dir_name=foo: 
+git_pack: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
+git_pack dir_name=foo: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_archive: 
-git_archive dir_name=foo: 
+git_archive: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
+git_archive dir_name=foo: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.wtree.zf20qd.tar.gz
-git_source_name name=foo: foo-0.0.wtree.zf20qd.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_setup_macro: %setup -q -n bar-foo-baz-0.0.wtree.zf25r6
+git_setup_macro dir_name=foo: %setup -q -n foo
 
 git_changelog header_date_format="@@@":
 
@@ -63,38 +61,36 @@ git_dir_name prepend=bar-: bar-test-subdir2
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.wtree.zf20qd
-git_dir_version name=foo: 0.0.wtree.zf20qd
-git_dir_version name=foo lead=1: 1.0.wtree.zf20qd
-git_dir_version lead=0: 0.0.wtree.zf20qd
-git_dir_version lead=1: 1.0.wtree.zf20qd
-git_dir_version lead=0.1: 0.1.0.wtree.zf20qd
-git_dir_version follow=1: 0.1.wtree.zf20qd
-git_dir_version lead=1 follow=2: 1.2.wtree.zf20qd
-git_dir_version lead=x follow=x: x.x.wtree.zf20qd
+git_dir_version: 0.0.wtree.zf25r6
+git_dir_version name=foo: 0.0.wtree.zf25r6
+git_dir_version name=foo lead=1: 1.0.wtree.zf25r6
+git_dir_version lead=0: 0.0.wtree.zf25r6
+git_dir_version lead=1: 1.0.wtree.zf25r6
+git_dir_version lead=0.1: 0.1.0.wtree.zf25r6
+git_dir_version follow=1: 0.1.wtree.zf25r6
+git_dir_version lead=1 follow=2: 1.2.wtree.zf25r6
+git_dir_version lead=x follow=x: x.x.wtree.zf25r6
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.wtree.zf20qd
+git_dir_version name="$(git_name)": 0.0.wtree.zf25r6
 
 git_dir_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir2/
 git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
+git_dir_pack dir_name=foo: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
 git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
+git_dir_archive dir_name=foo: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.wtree.zf20qd.tar.gz
-git_dir_source_name name=foo: foo-0.0.wtree.zf20qd.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_setup_macro: %setup -q -n bar-foo-baz-0.0.wtree.zf25r6
+git_dir_setup_macro dir_name=foo: %setup -q -n foo
 
 git_dir_changelog header_date_format="@@@":
 
@@ -121,38 +117,36 @@ git_cwd_name prepend=bar-: bar-test-subdir1
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.wtree.zf20qd
-git_cwd_version name=foo: 0.0.wtree.zf20qd
-git_cwd_version name=foo lead=1: 1.0.wtree.zf20qd
-git_cwd_version lead=0: 0.0.wtree.zf20qd
-git_cwd_version lead=1: 1.0.wtree.zf20qd
-git_cwd_version lead=0.1: 0.1.0.wtree.zf20qd
-git_cwd_version follow=1: 0.1.wtree.zf20qd
-git_cwd_version lead=1 follow=2: 1.2.wtree.zf20qd
-git_cwd_version lead=x follow=x: x.x.wtree.zf20qd
+git_cwd_version: 0.0.wtree.zf25r6
+git_cwd_version name=foo: 0.0.wtree.zf25r6
+git_cwd_version name=foo lead=1: 1.0.wtree.zf25r6
+git_cwd_version lead=0: 0.0.wtree.zf25r6
+git_cwd_version lead=1: 1.0.wtree.zf25r6
+git_cwd_version lead=0.1: 0.1.0.wtree.zf25r6
+git_cwd_version follow=1: 0.1.wtree.zf25r6
+git_cwd_version lead=1 follow=2: 1.2.wtree.zf25r6
+git_cwd_version lead=x follow=x: x.x.wtree.zf25r6
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf20qd
+git_cwd_version name="$(git_cwd_name)": 0.0.wtree.zf25r6
 
 git_cwd_vcs: git+https://pagure.io/clime/test.git#HEAD:subdir1/
 git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#HEAD:foo
 
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
+git_cwd_pack dir_name=foo: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
 git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
+git_cwd_archive dir_name=foo: bar-foo-baz-0.0.wtree.zf25r6.tar.gz
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.wtree.zf20qd.tar.gz
-git_cwd_source_name name=foo: foo-0.0.wtree.zf20qd.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_setup_macro: %setup -q -n bar-foo-baz-0.0.wtree.zf25r6
+git_cwd_setup_macro dir_name=foo: %setup -q -n foo
 
 git_cwd_changelog header_date_format="@@@":
 
diff --git a/tests/preproc/test_subdir/run.sh b/tests/preproc/test_subdir/run.sh
index 4c8baa1..5d32b5e 100755
--- a/tests/preproc/test_subdir/run.sh
+++ b/tests/preproc/test_subdir/run.sh
@@ -16,5 +16,6 @@ wtree_sub $repo $output
 
 generic_test opts='--dump-spec-only' path=$repo/subdir1 input=$repo/subdir2/input expected_output=$output expected_log=log copy_only=$1
 
-rm -rf $repo
+echo $repo
+#rm -rf $repo
 rm $output
diff --git a/tests/preproc/test_tagged/log b/tests/preproc/test_tagged/log
index 9989773..8b63298 100644
--- a/tests/preproc/test_tagged/log
+++ b/tests/preproc/test_tagged/log
@@ -74,13 +74,9 @@ git_archive: OUTDIR is not set. No action taken.
 > git_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_archive: OUTDIR is not set. No action taken.
 ---
-> git_source_name
+> git_setup_macro
 ---
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
+> git_setup_macro dir_name=foo
 ---
 > git_changelog header_date_format="@@@"
 ---
@@ -168,13 +164,9 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
----
-> git_dir_source_name name=foo
+> git_dir_setup_macro
 ---
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_dir_setup_macro dir_name=foo
 ---
 > git_dir_changelog header_date_format="@@@"
 ---
@@ -262,13 +254,9 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 > git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
+> git_cwd_setup_macro
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_cwd_setup_macro dir_name=foo
 ---
 > git_cwd_changelog header_date_format="@@@"
 ---
diff --git a/tests/preproc/test_tagged/output b/tests/preproc/test_tagged/output
index 9d076a0..d61ae56 100644
--- a/tests/preproc/test_tagged/output
+++ b/tests/preproc/test_tagged/output
@@ -5,38 +5,36 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.git.1.2dec15c
+git_version: 0.0.git.1.26c899e
 git_version name=foo: 0.0
 git_version name=foo lead=1: 1.5
-git_version lead=0: 0.0.git.1.2dec15c
-git_version lead=1: 1.0.git.1.2dec15c
-git_version lead=0.1: 0.1.0.git.1.2dec15c
-git_version follow=1: 0.1.git.1.2dec15c
-git_version lead=1 follow=2: 1.2.git.1.2dec15c
-git_version lead=x follow=x: x.x.git.1.2dec15c
+git_version lead=0: 0.0.git.1.26c899e
+git_version lead=1: 1.0.git.1.26c899e
+git_version lead=0.1: 0.1.0.git.1.26c899e
+git_version follow=1: 0.1.git.1.26c899e
+git_version lead=1 follow=2: 1.2.git.1.26c899e
+git_version lead=x follow=x: x.x.git.1.26c899e
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.git.1.2dec15c
+git_version name="$(git_name)": 0.0.git.1.26c899e
 
-git_vcs: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:foo
+git_vcs: git+https://pagure.io/clime/test.git#26c899e51c3051157a77e8b8505786e2af49855e:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#26c899e51c3051157a77e8b8505786e2af49855e:foo
 
-git_pack: 
-git_pack dir_name=foo: 
+git_pack: bar-foo-baz-0.0.git.1.26c899e.tar.gz
+git_pack dir_name=foo: bar-foo-baz-0.0.git.1.26c899e.tar.gz
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_archive: 
-git_archive dir_name=foo: 
+git_archive: bar-foo-baz-0.0.git.1.26c899e.tar.gz
+git_archive dir_name=foo: bar-foo-baz-0.0.git.1.26c899e.tar.gz
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.git.1.2dec15c.tar.gz
-git_source_name name=foo: foo-0.0.git.1.2dec15c.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_setup_macro: %setup -q -n bar-foo-baz-0.0.git.1.26c899e
+git_setup_macro dir_name=foo: %setup -q -n foo
 
 git_changelog header_date_format="@@@":
 
@@ -96,38 +94,36 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.git.1.2dec15c
+git_dir_version: 0.0.git.1.26c899e
 git_dir_version name=foo: 0.0
 git_dir_version name=foo lead=1: 1.5
-git_dir_version lead=0: 0.0.git.1.2dec15c
-git_dir_version lead=1: 1.0.git.1.2dec15c
-git_dir_version lead=0.1: 0.1.0.git.1.2dec15c
-git_dir_version follow=1: 0.1.git.1.2dec15c
-git_dir_version lead=1 follow=2: 1.2.git.1.2dec15c
-git_dir_version lead=x follow=x: x.x.git.1.2dec15c
+git_dir_version lead=0: 0.0.git.1.26c899e
+git_dir_version lead=1: 1.0.git.1.26c899e
+git_dir_version lead=0.1: 0.1.0.git.1.26c899e
+git_dir_version follow=1: 0.1.git.1.26c899e
+git_dir_version lead=1 follow=2: 1.2.git.1.26c899e
+git_dir_version lead=x follow=x: x.x.git.1.26c899e
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.git.1.2dec15c
+git_dir_version name="$(git_name)": 0.0.git.1.26c899e
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:foo
+git_dir_vcs: git+https://pagure.io/clime/test.git#26c899e51c3051157a77e8b8505786e2af49855e:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#26c899e51c3051157a77e8b8505786e2af49855e:foo
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack: bar-foo-baz-0.0.git.1.26c899e.tar.gz
+git_dir_pack dir_name=foo: bar-foo-baz-0.0.git.1.26c899e.tar.gz
 git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive: bar-foo-baz-0.0.git.1.26c899e.tar.gz
+git_dir_archive dir_name=foo: bar-foo-baz-0.0.git.1.26c899e.tar.gz
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.git.1.2dec15c.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.1.2dec15c.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_setup_macro: %setup -q -n bar-foo-baz-0.0.git.1.26c899e
+git_dir_setup_macro dir_name=foo: %setup -q -n foo
 
 git_dir_changelog header_date_format="@@@":
 
@@ -187,38 +183,36 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.git.1.2dec15c
+git_cwd_version: 0.0.git.1.26c899e
 git_cwd_version name=foo: 0.0
 git_cwd_version name=foo lead=1: 1.5
-git_cwd_version lead=0: 0.0.git.1.2dec15c
-git_cwd_version lead=1: 1.0.git.1.2dec15c
-git_cwd_version lead=0.1: 0.1.0.git.1.2dec15c
-git_cwd_version follow=1: 0.1.git.1.2dec15c
-git_cwd_version lead=1 follow=2: 1.2.git.1.2dec15c
-git_cwd_version lead=x follow=x: x.x.git.1.2dec15c
+git_cwd_version lead=0: 0.0.git.1.26c899e
+git_cwd_version lead=1: 1.0.git.1.26c899e
+git_cwd_version lead=0.1: 0.1.0.git.1.26c899e
+git_cwd_version follow=1: 0.1.git.1.26c899e
+git_cwd_version lead=1 follow=2: 1.2.git.1.26c899e
+git_cwd_version lead=x follow=x: x.x.git.1.26c899e
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.git.1.2dec15c
+git_cwd_version name="$(git_cwd_name)": 0.0.git.1.26c899e
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#2dec15c80c3c0a048d85eb891f274add3d929b5c:foo
+git_cwd_vcs: git+https://pagure.io/clime/test.git#26c899e51c3051157a77e8b8505786e2af49855e:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#26c899e51c3051157a77e8b8505786e2af49855e:foo
 
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack: bar-foo-baz-0.0.git.1.26c899e.tar.gz
+git_cwd_pack dir_name=foo: bar-foo-baz-0.0.git.1.26c899e.tar.gz
 git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive: bar-foo-baz-0.0.git.1.26c899e.tar.gz
+git_cwd_archive dir_name=foo: bar-foo-baz-0.0.git.1.26c899e.tar.gz
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.git.1.2dec15c.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.1.2dec15c.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_setup_macro: %setup -q -n bar-foo-baz-0.0.git.1.26c899e
+git_cwd_setup_macro dir_name=foo: %setup -q -n foo
 
 git_cwd_changelog header_date_format="@@@":
 
diff --git a/tests/preproc/test_tagged_committed/log b/tests/preproc/test_tagged_committed/log
index 9989773..8b63298 100644
--- a/tests/preproc/test_tagged_committed/log
+++ b/tests/preproc/test_tagged_committed/log
@@ -74,13 +74,9 @@ git_archive: OUTDIR is not set. No action taken.
 > git_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_archive: OUTDIR is not set. No action taken.
 ---
-> git_source_name
+> git_setup_macro
 ---
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
+> git_setup_macro dir_name=foo
 ---
 > git_changelog header_date_format="@@@"
 ---
@@ -168,13 +164,9 @@ git_dir_archive: OUTDIR is not set. No action taken.
 > git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
----
-> git_dir_source_name name=foo
+> git_dir_setup_macro
 ---
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_dir_setup_macro dir_name=foo
 ---
 > git_dir_changelog header_date_format="@@@"
 ---
@@ -262,13 +254,9 @@ git_cwd_archive: OUTDIR is not set. No action taken.
 > git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz
 git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
----
-> git_cwd_source_name version=1.2
+> git_cwd_setup_macro
 ---
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_cwd_setup_macro dir_name=foo
 ---
 > git_cwd_changelog header_date_format="@@@"
 ---
diff --git a/tests/preproc/test_tagged_committed/output b/tests/preproc/test_tagged_committed/output
index f945d0a..3891586 100644
--- a/tests/preproc/test_tagged_committed/output
+++ b/tests/preproc/test_tagged_committed/output
@@ -5,38 +5,36 @@ git_name prepend=bar-: bar-test
 git_name prepend=bar- append=-baz: bar-test-baz
 git_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_version: 0.0.git.2.763bb86
-git_version name=foo: 0.1.git.1.763bb86
-git_version name=foo lead=1: 1.0.git.1.763bb86
-git_version lead=0: 0.0.git.2.763bb86
-git_version lead=1: 1.0.git.2.763bb86
-git_version lead=0.1: 0.1.0.git.2.763bb86
-git_version follow=1: 0.1.git.2.763bb86
-git_version lead=1 follow=2: 1.2.git.2.763bb86
-git_version lead=x follow=x: x.x.git.2.763bb86
+git_version: 0.0.git.2.d518d5b
+git_version name=foo: 0.1.git.1.d518d5b
+git_version name=foo lead=1: 1.0.git.1.d518d5b
+git_version lead=0: 0.0.git.2.d518d5b
+git_version lead=1: 1.0.git.2.d518d5b
+git_version lead=0.1: 0.1.0.git.2.d518d5b
+git_version follow=1: 0.1.git.2.d518d5b
+git_version lead=1 follow=2: 1.2.git.2.d518d5b
+git_version lead=x follow=x: x.x.git.2.d518d5b
 git_version lead=1-1 # invalid: 
 git_version follow=2.0 # invalid: 
 git_version follow=2-2 # invalid: 
 git_version name= # invalid: 
-git_version name="$(git_name)": 0.0.git.2.763bb86
+git_version name="$(git_name)": 0.0.git.2.d518d5b
 
-git_vcs: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:
-git_vcs subtree=foo: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:foo
+git_vcs: git+https://pagure.io/clime/test.git#d518d5b21db87e1e5b81794c0eea98348c4dd0e0:
+git_vcs subtree=foo: git+https://pagure.io/clime/test.git#d518d5b21db87e1e5b81794c0eea98348c4dd0e0:foo
 
-git_pack: 
-git_pack dir_name=foo: 
+git_pack: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
+git_pack dir_name=foo: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_archive: 
-git_archive dir_name=foo: 
+git_archive: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
+git_archive dir_name=foo: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-0.0.git.2.763bb86.tar.gz
-git_source_name name=foo: foo-0.0.git.2.763bb86.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_setup_macro: %setup -q -n bar-foo-baz-0.0.git.2.d518d5b
+git_setup_macro dir_name=foo: %setup -q -n foo
 
 git_changelog header_date_format="@@@":
 
@@ -64,38 +62,36 @@ git_dir_name prepend=bar-: bar-test-
 git_dir_name prepend=bar- append=-baz: bar-test-baz
 git_dir_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_dir_version: 0.0.git.2.763bb86
-git_dir_version name=foo: 0.1.git.1.763bb86
-git_dir_version name=foo lead=1: 1.0.git.1.763bb86
-git_dir_version lead=0: 0.0.git.2.763bb86
-git_dir_version lead=1: 1.0.git.2.763bb86
-git_dir_version lead=0.1: 0.1.0.git.2.763bb86
-git_dir_version follow=1: 0.1.git.2.763bb86
-git_dir_version lead=1 follow=2: 1.2.git.2.763bb86
-git_dir_version lead=x follow=x: x.x.git.2.763bb86
+git_dir_version: 0.0.git.2.d518d5b
+git_dir_version name=foo: 0.1.git.1.d518d5b
+git_dir_version name=foo lead=1: 1.0.git.1.d518d5b
+git_dir_version lead=0: 0.0.git.2.d518d5b
+git_dir_version lead=1: 1.0.git.2.d518d5b
+git_dir_version lead=0.1: 0.1.0.git.2.d518d5b
+git_dir_version follow=1: 0.1.git.2.d518d5b
+git_dir_version lead=1 follow=2: 1.2.git.2.d518d5b
+git_dir_version lead=x follow=x: x.x.git.2.d518d5b
 git_dir_version lead=1-1 # invalid: 
 git_dir_version follow=2.0 # invalid: 
 git_dir_version follow=2-2 # invalid: 
 git_dir_version name= # invalid: 
-git_dir_version name="$(git_name)": 0.0.git.2.763bb86
+git_dir_version name="$(git_name)": 0.0.git.2.d518d5b
 
-git_dir_vcs: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:
-git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:foo
+git_dir_vcs: git+https://pagure.io/clime/test.git#d518d5b21db87e1e5b81794c0eea98348c4dd0e0:
+git_dir_vcs subtree=foo: git+https://pagure.io/clime/test.git#d518d5b21db87e1e5b81794c0eea98348c4dd0e0:foo
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
+git_dir_pack dir_name=foo: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
 git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
+git_dir_archive dir_name=foo: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-0.0.git.2.763bb86.tar.gz
-git_dir_source_name name=foo: foo-0.0.git.2.763bb86.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_setup_macro: %setup -q -n bar-foo-baz-0.0.git.2.d518d5b
+git_dir_setup_macro dir_name=foo: %setup -q -n foo
 
 git_dir_changelog header_date_format="@@@":
 
@@ -123,38 +119,36 @@ git_cwd_name prepend=bar-: bar-test-
 git_cwd_name prepend=bar- append=-baz: bar-test-baz
 git_cwd_name name=foo prepend=bar- append=-baz: bar-foo-baz
 
-git_cwd_version: 0.0.git.2.763bb86
-git_cwd_version name=foo: 0.1.git.1.763bb86
-git_cwd_version name=foo lead=1: 1.0.git.1.763bb86
-git_cwd_version lead=0: 0.0.git.2.763bb86
-git_cwd_version lead=1: 1.0.git.2.763bb86
-git_cwd_version lead=0.1: 0.1.0.git.2.763bb86
-git_cwd_version follow=1: 0.1.git.2.763bb86
-git_cwd_version lead=1 follow=2: 1.2.git.2.763bb86
-git_cwd_version lead=x follow=x: x.x.git.2.763bb86
+git_cwd_version: 0.0.git.2.d518d5b
+git_cwd_version name=foo: 0.1.git.1.d518d5b
+git_cwd_version name=foo lead=1: 1.0.git.1.d518d5b
+git_cwd_version lead=0: 0.0.git.2.d518d5b
+git_cwd_version lead=1: 1.0.git.2.d518d5b
+git_cwd_version lead=0.1: 0.1.0.git.2.d518d5b
+git_cwd_version follow=1: 0.1.git.2.d518d5b
+git_cwd_version lead=1 follow=2: 1.2.git.2.d518d5b
+git_cwd_version lead=x follow=x: x.x.git.2.d518d5b
 git_cwd_version lead=1-1 # invalid: 
 git_cwd_version follow=2.0 # invalid: 
 git_cwd_version follow=2-2 # invalid: 
 git_cwd_version name= # invalid: 
-git_cwd_version name="$(git_cwd_name)": 0.0.git.2.763bb86
+git_cwd_version name="$(git_cwd_name)": 0.0.git.2.d518d5b
 
-git_cwd_vcs: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:
-git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#763bb86b67dd31d9f06197a3655d8b3041132de0:foo
+git_cwd_vcs: git+https://pagure.io/clime/test.git#d518d5b21db87e1e5b81794c0eea98348c4dd0e0:
+git_cwd_vcs subtree=foo: git+https://pagure.io/clime/test.git#d518d5b21db87e1e5b81794c0eea98348c4dd0e0:foo
 
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
+git_cwd_pack dir_name=foo: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
 git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
+git_cwd_archive dir_name=foo: bar-foo-baz-0.0.git.2.d518d5b.tar.gz
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-0.0.git.2.763bb86.tar.gz
-git_cwd_source_name name=foo: foo-0.0.git.2.763bb86.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_setup_macro: %setup -q -n bar-foo-baz-0.0.git.2.d518d5b
+git_cwd_setup_macro dir_name=foo: %setup -q -n foo
 
 git_cwd_changelog header_date_format="@@@":
 
diff --git a/tests/preproc/test_uninited/log b/tests/preproc/test_uninited/log
index 63984b8..f1126e3 100644
--- a/tests/preproc/test_uninited/log
+++ b/tests/preproc/test_uninited/log
@@ -21,56 +21,38 @@ git_name prepend=bar- append=-baz failed with value 1
 > git_version
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version name=foo lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=0
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=0.1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version follow=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=1 follow=2
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=x follow=x
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_version lead=1-1 # invalid
 git_version: lead and follow cannot contain dashes.
@@ -141,33 +123,19 @@ fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 git_archive: OUTDIR is not set. No action taken.
 ---
-> git_source_name
+> git_setup_macro
 ---
-> git_source_name name=foo
----
-> git_source_name version=1.2
----
-> git_source_name name=foo version=1.2 format=tar
+> git_setup_macro dir_name=foo
 ---
 > git_changelog header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_name
 fatal: Not a git repository (or any parent up to mount point /)
@@ -204,56 +172,38 @@ Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 > git_dir_version
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version name=foo lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=0
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=0.1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version follow=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=1 follow=2
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=x follow=x
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_version lead=1-1 # invalid
 git_dir_version: lead and follow cannot contain dashes.
@@ -328,33 +278,19 @@ fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 git_dir_archive: OUTDIR is not set. No action taken.
 ---
-> git_dir_source_name
+> git_dir_setup_macro
 ---
-> git_dir_source_name name=foo
----
-> git_dir_source_name version=1.2
----
-> git_dir_source_name name=foo version=1.2 format=tar
+> git_dir_setup_macro dir_name=foo
 ---
 > git_dir_changelog header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_dir_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_name
 fatal: Not a git repository (or any parent up to mount point /)
@@ -391,56 +327,38 @@ Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 > git_cwd_version
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version name=foo
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version name=foo lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=0
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=0.1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version follow=1
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=1 follow=2
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=x follow=x
 fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_version lead=1-1 # invalid
 git_cwd_version: lead and follow cannot contain dashes.
@@ -517,31 +435,17 @@ fatal: Not a git repository (or any parent up to mount point /)
 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 git_cwd_archive: OUTDIR is not set. No action taken.
 ---
-> git_cwd_source_name
----
-> git_cwd_source_name name=foo
+> git_cwd_setup_macro
 ---
-> git_cwd_source_name version=1.2
----
-> git_cwd_source_name name=foo version=1.2 format=tar
+> git_cwd_setup_macro dir_name=foo
 ---
 > git_cwd_changelog header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_changelog name=foo until_tag=foo-1.2-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_date_format="@@@"
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
 > git_cwd_changelog name=foo since_tag=foo-1.2-1 until_tag=foo-1.4-1 header_locale=POSIX header_date_format="@@@" body_wrap=42
-fatal: Not a git repository (or any parent up to mount point /)
-Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 ---
diff --git a/tests/preproc/test_uninited/output b/tests/preproc/test_uninited/output
index e2bf04f..852beb1 100644
--- a/tests/preproc/test_uninited/output
+++ b/tests/preproc/test_uninited/output
@@ -23,20 +23,18 @@ git_version name="$(git_name)":
 git_vcs: 
 git_vcs subtree=foo: 
 
-git_pack: 
-git_pack dir_name=foo: 
+git_pack: bar-foo-baz-x.x.tar.gz
+git_pack dir_name=foo: bar-foo-baz-x.x.tar.gz
 git_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_archive: 
-git_archive dir_name=foo: 
+git_archive: bar-foo-baz-x.x.tar.gz
+git_archive dir_name=foo: bar-foo-baz-x.x.tar.gz
 git_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_source_name: bar-foo-baz-x.x.tar.gz
-git_source_name name=foo: foo-x.x.tar.gz
-git_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_setup_macro: %setup -q -n bar-foo-baz-x.x
+git_setup_macro dir_name=foo: %setup -q -n foo
 
 git_changelog header_date_format="@@@":
 
@@ -81,20 +79,18 @@ git_dir_version name="$(git_name)":
 git_dir_vcs: 
 git_dir_vcs subtree=foo: 
 
-git_dir_pack: foo-1.2.tar
-git_dir_pack dir_name=foo: foo-1.2.tar
+git_dir_pack: bar-foo-baz-x.x.tar.gz
+git_dir_pack dir_name=foo: bar-foo-baz-x.x.tar.gz
 git_dir_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_archive: foo-1.2.tar
-git_dir_archive dir_name=foo: foo-1.2.tar
+git_dir_archive: bar-foo-baz-x.x.tar.gz
+git_dir_archive dir_name=foo: bar-foo-baz-x.x.tar.gz
 git_dir_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_dir_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_dir_source_name: bar-foo-baz-x.x.tar.gz
-git_dir_source_name name=foo: foo-x.x.tar.gz
-git_dir_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_dir_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_dir_setup_macro: %setup -q -n bar-foo-baz-x.x
+git_dir_setup_macro dir_name=foo: %setup -q -n foo
 
 git_dir_changelog header_date_format="@@@":
 
@@ -139,20 +135,18 @@ git_cwd_version name="$(git_cwd_name)":
 git_cwd_vcs: 
 git_cwd_vcs subtree=foo: 
 
-git_cwd_pack: foo-1.2.tar
-git_cwd_pack dir_name=foo: foo-1.2.tar
+git_cwd_pack: bar-foo-baz-x.x.tar.gz
+git_cwd_pack dir_name=foo: bar-foo-baz-x.x.tar.gz
 git_cwd_pack dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_pack path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_archive: foo-1.2.tar
-git_cwd_archive dir_name=foo: foo-1.2.tar
+git_cwd_archive: bar-foo-baz-x.x.tar.gz
+git_cwd_archive dir_name=foo: bar-foo-baz-x.x.tar.gz
 git_cwd_archive dir_name=foo source_name=foo.tar.gz: foo.tar.gz
 git_cwd_archive path=foo dir_name=bar source_name=foo.tar.gz: foo.tar.gz
 
-git_cwd_source_name: bar-foo-baz-x.x.tar.gz
-git_cwd_source_name name=foo: foo-x.x.tar.gz
-git_cwd_source_name version=1.2: bar-foo-baz-1.2.tar.gz
-git_cwd_source_name name=foo version=1.2 format=tar: foo-1.2.tar
+git_cwd_setup_macro: %setup -q -n bar-foo-baz-x.x
+git_cwd_setup_macro dir_name=foo: %setup -q -n foo
 
 git_cwd_changelog header_date_format="@@@":
 

From e9d299ce032ed3646dc4bc2190e635b4a55bf37f Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:49:20 +0000
Subject: [PATCH 91/104] rename to rpkg-util, remove unused templates, add template examples


---

diff --git a/examples/simple-template-cwd.spec.rpkg b/examples/simple-template-cwd.spec.rpkg
new file mode 100644
index 0000000..3d80195
--- /dev/null
+++ b/examples/simple-template-cwd.spec.rpkg
@@ -0,0 +1,35 @@
+# vim: syntax=spec
+
+# git_cwd_* macros work with the current
+# working directory by default (you can
+# override the working directory with
+# `rpkg --path`).
+#
+# For example, git_cwd_name will take
+# repository origin URL basename and
+# appends to it path (after slash to
+# dash substitution) from the repository
+# root to the current working directory.
+#
+# git_cwd_pack macro will pack the content
+# of the current working directory and
+# outputs filename to be used as Source0.
+
+Name:       {{{ git_cwd_name }}}
+Version:    {{{ git_cwd_version }}}
+Release:    1%{?dist}
+Summary:    This is a test package.
+
+License:    GPLv2+
+URL:        https://someurl.org
+
+Source0:    {{{ git_cwd_pack }}}
+
+%description
+This is a test package.
+
+%prep
+{{{ git_cwd_setup_macro }}}
+
+%changelog
+{{{ git_cwd_changelog }}}
diff --git a/examples/simple-template-dir.spec.rpkg b/examples/simple-template-dir.spec.rpkg
new file mode 100644
index 0000000..27a0035
--- /dev/null
+++ b/examples/simple-template-dir.spec.rpkg
@@ -0,0 +1,33 @@
+# vim: syntax=spec
+
+# git_dir_* macros work with the directory
+# where the input spec file template is placed.
+#
+# For example, git_dir_name will take
+# repository origin URL basename and
+# appends to it path (after slash to
+# dash substitution) from the repository
+# root to the spec file's directory.
+#
+# git_dir_pack macro will pack the content
+# of the that directory and outputs filename
+# to be used as Source0.
+
+Name:       {{{ git_dir_name }}}
+Version:    {{{ git_dir_version }}}
+Release:    1%{?dist}
+Summary:    This is a test package.
+
+License:    GPLv2+
+URL:        https://someurl.org
+
+Source0:    {{{ git_dir_pack }}}
+
+%description
+This is a test package.
+
+%prep
+{{{ git_dir_setup_macro }}}
+
+%changelog
+{{{ git_dir_changelog }}}
diff --git a/examples/simple-template.spec.rpkg b/examples/simple-template.spec.rpkg
new file mode 100644
index 0000000..00784a4
--- /dev/null
+++ b/examples/simple-template.spec.rpkg
@@ -0,0 +1,62 @@
+# vim: syntax=spec
+
+# This example shows the basic usage
+# of rpkg macros. Without any parameters,
+# these macros work on repository level
+# and use globally available repository
+# information.
+#
+# For example, git_name will, by default,
+# read repository origin URL basename and
+# outputs it to stdout. The outputted value
+# then replaces the {{{ git_name }}} invocation.
+#
+# git_pack macro will take the whole repository
+# content, packs it into a gzipped tarball and
+# outputs its filename.
+#
+# By specifying certain parameters (see
+# section SPEC TEMPATES in rpkg man pages),
+# you can influence the behavior of those
+# macros to basically any extent.
+#
+# For example, {{{ git_pack path=subdir }}}
+# will pack content of the "subdir"
+# directory in the current working directory
+# instead of packing the whole repository.
+#
+# If you want to pack a directory called
+# "subdir" under a repository root (and not
+# under the current working directory as
+# in the previous example), you can use this:
+#
+# {{{ git_pack path="$(git rev-parse --show-toplevel)/subdir" }}}
+#
+# There is also git_archive macro which is
+# very similar to git_pack (and even has
+# the  same parameters) but uses `git archive`
+# for packing instead of tar.
+#
+# If you use {{{ git_archive }}}, all your
+# changes need to be committed before you
+# can build the source tarball, for example
+# by calling `rpkg srpm`.
+
+Name:       {{{ git_name }}}
+Version:    {{{ git_version }}}
+Release:    1%{?dist}
+Summary:    This is a test package.
+
+License:    GPLv2+
+URL:        https://someurl.org
+
+Source0:    {{{ git_pack }}}
+
+%description
+This is a test package.
+
+%prep
+{{{ git_setup_macro }}}
+
+%changelog
+{{{ git_changelog }}}
diff --git a/rpkg-client.spec b/rpkg-client.spec
deleted file mode 100644
index 9727594..0000000
--- a/rpkg-client.spec
+++ /dev/null
@@ -1,159 +0,0 @@
-Name: rpkg-client
-Version: 0.14
-Release: 1%{?dist}
-Summary: RPM packaging utility
-License: GPLv2+
-URL: https://pagure.io/rpkg-client.git
-
-# How to obtain the sources
-# git clone https://pagure.io/rpkg-client.git
-# cd rpkg-client
-# tito build --tgz
-Source0: %{name}-%{version}.tar.gz
-
-BuildArch: noarch
-
-%description
-This package contains the rpkg utility. We are putting
-the actual 'rpkg' package into a subpackage because there already
-exists package https://src.fedoraproject.org/rpms/rpkg. That package,
-however, does not actually produce rpkg rpm whereas rpkg-client does.
-
-%package -n rpkg
-Summary: RPM packaging utitility
-BuildArch: noarch
-
-BuildRequires: python2
-BuildRequires: python2-setuptools
-BuildRequires: python2-devel
-BuildRequires: python2-rpkg
-BuildRequires: python2-mock
-BuildRequires: python-munch
-
-%if 0%{?rhel}
-BuildRequires: pytest
-BuildRequires: pyparsing
-BuildRequires: python-configparser
-%else
-BuildRequires: python2-pytest
-BuildRequires: python2-pyparsing
-BuildRequires: python2-configparser
-%endif
-
-Requires: python2-rpkg
-
-%if 0%{?rhel}
-Requires: pyparsing
-Requires: python-configparser
-%else
-Requires: python2-pyparsing
-Requires: python2-configparser
-%endif
-
-%description -n rpkg
-This is an RPM packaging utility based on python-rpkg library.
-It works with both DistGit and standard Git repositories and
-it handles packed directory content as well as unpacked content.
-
-%prep
-%setup -q
-
-%check
-./run_tests.sh
-
-%build
-%py2_build
-%{__python2} man/rpkg_man_page.py > rpkg.1
-
-%install
-%py2_install
-install -d %{buildroot}%{_mandir}/man1
-install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1
-
-install -d %{buildroot}%{_sysconfdir}
-install -d %{buildroot}%{_datarootdir}/bash-completion/completions
-
-cp -a rpkg.conf %{buildroot}%{_sysconfdir}/
-cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
-
-%files -n rpkg
-%license LICENSE
-%{python2_sitelib}/*
-
-%config(noreplace) %{_sysconfdir}/rpkg.conf
-%{_datadir}/bash-completion/completions/rpkg.bash
-
-%{_bindir}/rpkg
-%{_mandir}/*/*
-
-%changelog
-* Sun Feb 18 2018 clime <clime@redhat.com> 0.14-1
-- fix error when redownloading sources
-- do not invoke parent's module_name in load_ns_module_name
-- fix python builddeps naming
-
-* Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
-- add LICENSE to ignored file regex
-
-* Mon Oct 23 2017 clime <clime@redhat.com> 0.12-1
-- respect hashtype from the sources file if any
-
-* Fri Oct 20 2017 clime <clime@redhat.com> 0.11-1
-- set default distgit target to src.fedoraproject.org
-- fix downloading sources for any-length-namespace
-  modules
-- make the whole lookaside url template explict in
-  the config file
-- rename 'rpkg' config section to 'distgit'
-- update in command descriptions
-
-* Wed Oct 18 2017 clime <clime@redhat.com> 0.10-1
-- possibility to give directory to --spec
-- also take --spec in account for rpmdefines
-
-* Mon Oct 16 2017 clime <clime@redhat.com> 0.9-1
-- update spec descriptions
-- added is-packed subcommand
-- try reading ~/.config/rpkg before /etc/rpkg
-- add unittests
-- for source downloading, try both url formats
-  with/without hashtype
-- add make-source subcommand
-- patch srpm to generate Source0 if unpacked content
-- override load_ns_module_name to work with any length
-  namespaces
-- added --spec for srpm, make-source, and copr-build
-- fixed tagging not to include host dist tag
-- docs update
-- make all config values optional
-
-* Thu Jul 27 2017 clime <clime@redhat.com> 0.8-1
-- fix man pages to only include actually provided part of pyrpkg functionality
-- add rpkglib to provide functional interface
-- change summary of wrapper package
-
-* Wed Jul 26 2017 clime <clime@redhat.com> 0.7-1
-- use %%py2_build and %%py2_install macros
-- explicitly invoke python2 for doc generation
-- remove no longer needed $BUILDROOT removal in %%install clause
-- add missing BuildRequires on python-setuptools
-
-* Fri Jul 07 2017 clime <clime@redhat.com> 0.6-1
-- fix build error
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.5-1
-- remove Requires bash-completion
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.4-1
-- move config file to /etc/rpkg.conf
-- add Requires bash-completion
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.3-1
-- remove some directories from %%files in .spec
-- add (for now) short README.md
-
-* Tue Jun 20 2017 clime <clime@redhat.com> 0.2-1
-- new rpkg-client package built with tito
-
-* Mon Jun 12 2017 clime <clime@redhat.com> 0.1-1
-- Initial version
diff --git a/rpkg-client.spec.rpkg b/rpkg-client.spec.rpkg
deleted file mode 100644
index 47766f7..0000000
--- a/rpkg-client.spec.rpkg
+++ /dev/null
@@ -1,158 +0,0 @@
-# vim: syntax=spec
-Name: {{{ git_name name=rpkg-client }}}
-Version: {{{ git_version lead=1 }}}
-Release: 1%{?dist}
-Summary: RPM packaging utitility
-License: GPLv2+
-URL: https://pagure.io/rpkg-client.git
-VCS: {{{ git_vcs }}}
-
-# How to obtain the sources
-# git clone https://pagure.io/rpkg-client.git
-# cd rpkg-client
-# tito build --tgz
-Source0: {{{ git_pack }}}
-
-BuildArch: noarch
-
-%description
-This package contains the rpkg utility. We are putting
-the actual 'rpkg' package into a subpackage because there already
-exists package https://src.fedoraproject.org/rpms/rpkg. That package,
-however, does not actually produce rpkg rpm whereas rpkg-client does.
-
-%package -n rpkg
-Summary: RPM packaging utitility
-BuildArch: noarch
-
-BuildRequires: python
-BuildRequires: python-setuptools
-BuildRequires: python-devel
-BuildRequires: python2-rpkg
-BuildRequires: python2-mock
-BuildRequires: python-munch
-
-%if 0%{?rhel}
-BuildRequires: pytest
-BuildRequires: pyparsing
-BuildRequires: python-configparser
-%else
-BuildRequires: python2-pytest
-BuildRequires: python2-pyparsing
-BuildRequires: python2-configparser
-%endif
-
-Requires: python2-rpkg
-
-%if 0%{?rhel}
-Requires: pyparsing
-Requires: python-configparser
-%else
-Requires: python2-pyparsing
-Requires: python2-configparser
-%endif
-
-%description -n rpkg
-This is an RPM packaging utility based on python-rpkg library.
-It works with both DistGit and standard Git repositories and
-it handles packed directory content as well as unpacked content.
-
-%prep
-%setup -q
-
-%check
-./run_tests.sh
-
-%build
-%py2_build
-%{__python2} doc/rpkg_man_page.py > rpkg.1
-
-%install
-%py2_install
-install -d %{buildroot}%{_mandir}/man1
-install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1
-
-install -d %{buildroot}%{_sysconfdir}
-install -d %{buildroot}%{_datarootdir}/bash-completion/completions
-
-cp -a rpkg.conf %{buildroot}%{_sysconfdir}/
-cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
-
-%files -n rpkg
-%license LICENSE
-%{python2_sitelib}/*
-
-%config(noreplace) %{_sysconfdir}/rpkg.conf
-%{_datadir}/bash-completion/completions/rpkg.bash
-
-%{_bindir}/rpkg
-%{_mandir}/*/*
-
-%changelog
-{{{ git_changelog }}}
-
-* Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
-- add LICENSE to ignored file regex
-
-* Mon Oct 23 2017 clime <clime@redhat.com> 0.12-1
-- respect hashtype from the sources file if any
-
-* Fri Oct 20 2017 clime <clime@redhat.com> 0.11-1
-- set default distgit target to src.fedoraproject.org
-- fix downloading sources for any-length-namespace
-  modules
-- make the whole lookaside url template explict in
-  the config file
-- rename 'rpkg' config section to 'distgit'
-- update in command descriptions
-
-* Wed Oct 18 2017 clime <clime@redhat.com> 0.10-1
-- possibility to give directory to --spec
-- also take --spec in account for rpmdefines
-
-* Mon Oct 16 2017 clime <clime@redhat.com> 0.9-1
-- update spec descriptions
-- added is-packed subcommand
-- try reading ~/.config/rpkg before /etc/rpkg
-- add unittests
-- for source downloading, try both url formats
-  with/without hashtype
-- add make-source subcommand
-- patch srpm to generate Source0 if unpacked content
-- override load_ns_module_name to work with any length
-  namespaces
-- added --spec for srpm, make-source, and copr-build
-- fixed tagging not to include host dist tag
-- docs update
-- make all config values optional
-
-* Thu Jul 27 2017 clime <clime@redhat.com> 0.8-1
-- fix man pages to only include actually provided part of pyrpkg functionality
-- add rpkglib to provide functional interface
-- change summary of wrapper package
-
-* Wed Jul 26 2017 clime <clime@redhat.com> 0.7-1
-- use %%py2_build and %%py2_install macros
-- explicitly invoke python2 for doc generation
-- remove no longer needed $BUILDROOT removal in %%install clause
-- add missing BuildRequires on python-setuptools
-
-* Fri Jul 07 2017 clime <clime@redhat.com> 0.6-1
-- fix build error
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.5-1
-- remove Requires bash-completion
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.4-1
-- move config file to /etc/rpkg.conf
-- add Requires bash-completion
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.3-1
-- remove some directories from %%files in .spec
-- add (for now) short README.md
-
-* Tue Jun 20 2017 clime <clime@redhat.com> 0.2-1
-- new rpkg-client package built with tito
-
-* Mon Jun 12 2017 clime <clime@redhat.com> 0.1-1
-- Initial version
diff --git a/rpkg-client.spec.rpkg.cwd b/rpkg-client.spec.rpkg.cwd
deleted file mode 100644
index a96bc13..0000000
--- a/rpkg-client.spec.rpkg.cwd
+++ /dev/null
@@ -1,158 +0,0 @@
-# vim: syntax=spec
-Name: {{{ git_cwd_name }}}
-Version: {{{ git_cwd_version lead=1 }}}
-Release: 1%{?dist}
-Summary: RPM packaging utitility
-License: GPLv2+
-URL: https://pagure.io/rpkg-client.git
-VCS: {{{ git_cwd_vcs }}}
-
-# How to obtain the sources
-# git clone https://pagure.io/rpkg-client.git
-# cd rpkg-client
-# tito build --tgz
-Source0: {{{ git_cwd_archive }}}
-
-BuildArch: noarch
-
-%description
-This package contains the rpkg utility. We are putting
-the actual 'rpkg' package into a subpackage because there already
-exists package https://src.fedoraproject.org/rpms/rpkg. That package,
-however, does not actually produce rpkg rpm whereas rpkg-client does.
-
-%package -n rpkg
-Summary: RPM packaging utitility
-BuildArch: noarch
-
-BuildRequires: python
-BuildRequires: python-setuptools
-BuildRequires: python-devel
-BuildRequires: python2-rpkg
-BuildRequires: python2-mock
-BuildRequires: python-munch
-
-%if 0%{?rhel}
-BuildRequires: pytest
-BuildRequires: pyparsing
-BuildRequires: python-configparser
-%else
-BuildRequires: python2-pytest
-BuildRequires: python2-pyparsing
-BuildRequires: python2-configparser
-%endif
-
-Requires: python2-rpkg
-
-%if 0%{?rhel}
-Requires: pyparsing
-Requires: python-configparser
-%else
-Requires: python2-pyparsing
-Requires: python2-configparser
-%endif
-
-%description -n rpkg
-This is an RPM packaging utility based on python-rpkg library.
-It works with both DistGit and standard Git repositories and
-it handles packed directory content as well as unpacked content.
-
-%prep
-%setup -q
-
-%check
-./run_tests.sh
-
-%build
-%py2_build
-%{__python2} doc/rpkg_man_page.py > rpkg.1
-
-%install
-%py2_install
-install -d %{buildroot}%{_mandir}/man1
-install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1
-
-install -d %{buildroot}%{_sysconfdir}
-install -d %{buildroot}%{_datarootdir}/bash-completion/completions
-
-cp -a rpkg.conf %{buildroot}%{_sysconfdir}/
-cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
-
-%files -n rpkg
-%license LICENSE
-%{python2_sitelib}/*
-
-%config(noreplace) %{_sysconfdir}/rpkg.conf
-%{_datadir}/bash-completion/completions/rpkg.bash
-
-%{_bindir}/rpkg
-%{_mandir}/*/*
-
-%changelog
-{{{ git_cwd_changelog }}}
-
-* Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
-- add LICENSE to ignored file regex
-
-* Mon Oct 23 2017 clime <clime@redhat.com> 0.12-1
-- respect hashtype from the sources file if any
-
-* Fri Oct 20 2017 clime <clime@redhat.com> 0.11-1
-- set default distgit target to src.fedoraproject.org
-- fix downloading sources for any-length-namespace
-  modules
-- make the whole lookaside url template explict in
-  the config file
-- rename 'rpkg' config section to 'distgit'
-- update in command descriptions
-
-* Wed Oct 18 2017 clime <clime@redhat.com> 0.10-1
-- possibility to give directory to --spec
-- also take --spec in account for rpmdefines
-
-* Mon Oct 16 2017 clime <clime@redhat.com> 0.9-1
-- update spec descriptions
-- added is-packed subcommand
-- try reading ~/.config/rpkg before /etc/rpkg
-- add unittests
-- for source downloading, try both url formats
-  with/without hashtype
-- add make-source subcommand
-- patch srpm to generate Source0 if unpacked content
-- override load_ns_module_name to work with any length
-  namespaces
-- added --spec for srpm, make-source, and copr-build
-- fixed tagging not to include host dist tag
-- docs update
-- make all config values optional
-
-* Thu Jul 27 2017 clime <clime@redhat.com> 0.8-1
-- fix man pages to only include actually provided part of pyrpkg functionality
-- add rpkglib to provide functional interface
-- change summary of wrapper package
-
-* Wed Jul 26 2017 clime <clime@redhat.com> 0.7-1
-- use %%py2_build and %%py2_install macros
-- explicitly invoke python2 for doc generation
-- remove no longer needed $BUILDROOT removal in %%install clause
-- add missing BuildRequires on python-setuptools
-
-* Fri Jul 07 2017 clime <clime@redhat.com> 0.6-1
-- fix build error
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.5-1
-- remove Requires bash-completion
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.4-1
-- move config file to /etc/rpkg.conf
-- add Requires bash-completion
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.3-1
-- remove some directories from %%files in .spec
-- add (for now) short README.md
-
-* Tue Jun 20 2017 clime <clime@redhat.com> 0.2-1
-- new rpkg-client package built with tito
-
-* Mon Jun 12 2017 clime <clime@redhat.com> 0.1-1
-- Initial version
diff --git a/rpkg-client.spec.rpkg.dir b/rpkg-client.spec.rpkg.dir
deleted file mode 100644
index 2d64745..0000000
--- a/rpkg-client.spec.rpkg.dir
+++ /dev/null
@@ -1,158 +0,0 @@
-# vim: syntax=spec
-Name: {{{ git_dir_name }}}
-Version: {{{ git_dir_version lead=1 }}}
-Release: 1%{?dist}
-Summary: RPM packaging utitility
-License: GPLv2+
-URL: https://pagure.io/rpkg-client.git
-VCS: {{{ git_dir_vcs }}}
-
-# How to obtain the sources
-# git clone https://pagure.io/rpkg-client.git
-# cd rpkg-client
-# tito build --tgz
-Source0: {{{ git_dir_pack }}}
-
-BuildArch: noarch
-
-%description
-This package contains the rpkg utility. We are putting
-the actual 'rpkg' package into a subpackage because there already
-exists package https://src.fedoraproject.org/rpms/rpkg. That package,
-however, does not actually produce rpkg rpm whereas rpkg-client does.
-
-%package -n rpkg
-Summary: RPM packaging utitility
-BuildArch: noarch
-
-BuildRequires: python
-BuildRequires: python-setuptools
-BuildRequires: python-devel
-BuildRequires: python2-rpkg
-BuildRequires: python2-mock
-BuildRequires: python-munch
-
-%if 0%{?rhel}
-BuildRequires: pytest
-BuildRequires: pyparsing
-BuildRequires: python-configparser
-%else
-BuildRequires: python2-pytest
-BuildRequires: python2-pyparsing
-BuildRequires: python2-configparser
-%endif
-
-Requires: python2-rpkg
-
-%if 0%{?rhel}
-Requires: pyparsing
-Requires: python-configparser
-%else
-Requires: python2-pyparsing
-Requires: python2-configparser
-%endif
-
-%description -n rpkg
-This is an RPM packaging utility based on python-rpkg library.
-It works with both DistGit and standard Git repositories and
-it handles packed directory content as well as unpacked content.
-
-%prep
-{{{ git_dir_setup_macro }}}
-
-%check
-./run_tests.sh
-
-%build
-%py2_build
-%{__python2} doc/rpkg_man_page.py > rpkg.1
-
-%install
-%py2_install
-install -d %{buildroot}%{_mandir}/man1
-install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1
-
-install -d %{buildroot}%{_sysconfdir}
-install -d %{buildroot}%{_datarootdir}/bash-completion/completions
-
-cp -a rpkg.conf %{buildroot}%{_sysconfdir}/
-cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
-
-%files -n rpkg
-%license LICENSE
-%{python2_sitelib}/*
-
-%config(noreplace) %{_sysconfdir}/rpkg.conf
-%{_datadir}/bash-completion/completions/rpkg.bash
-
-%{_bindir}/rpkg
-%{_mandir}/*/*
-
-%changelog
-{{{ git_dir_changelog }}}
-
-* Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
-- add LICENSE to ignored file regex
-
-* Mon Oct 23 2017 clime <clime@redhat.com> 0.12-1
-- respect hashtype from the sources file if any
-
-* Fri Oct 20 2017 clime <clime@redhat.com> 0.11-1
-- set default distgit target to src.fedoraproject.org
-- fix downloading sources for any-length-namespace
-  modules
-- make the whole lookaside url template explict in
-  the config file
-- rename 'rpkg' config section to 'distgit'
-- update in command descriptions
-
-* Wed Oct 18 2017 clime <clime@redhat.com> 0.10-1
-- possibility to give directory to --spec
-- also take --spec in account for rpmdefines
-
-* Mon Oct 16 2017 clime <clime@redhat.com> 0.9-1
-- update spec descriptions
-- added is-packed subcommand
-- try reading ~/.config/rpkg before /etc/rpkg
-- add unittests
-- for source downloading, try both url formats
-  with/without hashtype
-- add make-source subcommand
-- patch srpm to generate Source0 if unpacked content
-- override load_ns_module_name to work with any length
-  namespaces
-- added --spec for srpm, make-source, and copr-build
-- fixed tagging not to include host dist tag
-- docs update
-- make all config values optional
-
-* Thu Jul 27 2017 clime <clime@redhat.com> 0.8-1
-- fix man pages to only include actually provided part of pyrpkg functionality
-- add rpkglib to provide functional interface
-- change summary of wrapper package
-
-* Wed Jul 26 2017 clime <clime@redhat.com> 0.7-1
-- use %%py2_build and %%py2_install macros
-- explicitly invoke python2 for doc generation
-- remove no longer needed $BUILDROOT removal in %%install clause
-- add missing BuildRequires on python-setuptools
-
-* Fri Jul 07 2017 clime <clime@redhat.com> 0.6-1
-- fix build error
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.5-1
-- remove Requires bash-completion
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.4-1
-- move config file to /etc/rpkg.conf
-- add Requires bash-completion
-
-* Tue Jun 27 2017 clime <clime@redhat.com> 0.3-1
-- remove some directories from %%files in .spec
-- add (for now) short README.md
-
-* Tue Jun 20 2017 clime <clime@redhat.com> 0.2-1
-- new rpkg-client package built with tito
-
-* Mon Jun 12 2017 clime <clime@redhat.com> 0.1-1
-- Initial version
diff --git a/rpkg-util.spec.rpkg b/rpkg-util.spec.rpkg
new file mode 100644
index 0000000..9cda3f4
--- /dev/null
+++ b/rpkg-util.spec.rpkg
@@ -0,0 +1,158 @@
+# vim: syntax=spec
+Name: {{{ git_name }}}
+Version: {{{ git_version lead=1 }}}
+Release: 1%{?dist}
+Summary: RPM packaging utility
+License: GPLv2+
+URL: https://pagure.io/rpkg-util.git
+VCS: {{{ git_vcs }}}
+Source0: {{{ git_pack }}}
+
+BuildArch: noarch
+
+%description
+This package contains the rpkg utility. We are putting
+the actual 'rpkg' package into a subpackage because there already
+exists package https://src.fedoraproject.org/rpms/rpkg. That package,
+however, does not actually produce rpkg rpm whereas rpkg-client does.
+
+%package -n rpkg
+Summary: RPM packaging utitility
+BuildArch: noarch
+
+BuildRequires: python2
+BuildRequires: python2-setuptools
+BuildRequires: python2-devel
+BuildRequires: python2-rpkg
+BuildRequires: python2-mock
+BuildRequires: python-munch
+
+%if 0%{?rhel}
+BuildRequires: pytest
+BuildRequires: pyparsing
+BuildRequires: python-configparser
+%else
+BuildRequires: python2-pytest
+BuildRequires: python2-pyparsing
+BuildRequires: python2-configparser
+%endif
+
+Requires: python2-rpkg
+
+%if 0%{?rhel}
+Requires: pyparsing
+Requires: python-configparser
+%else
+Requires: python2-pyparsing
+Requires: python2-configparser
+%endif
+
+%description -n rpkg
+This is an RPM packaging utility based on python-rpkg library.
+It works with both DistGit and standard Git repositories and
+it handles packed directory content as well as unpacked content.
+
+%prep
+%setup -q
+
+%check
+./run_tests.sh
+
+%build
+%py2_build
+%{__python2} man/rpkg_man_page.py > rpkg.1
+
+%install
+%py2_install
+install -d %{buildroot}%{_mandir}/man1
+install -p -m 0644 rpkg.1 %{buildroot}%{_mandir}/man1
+
+install -d %{buildroot}%{_sysconfdir}
+install -d %{buildroot}%{_datarootdir}/bash-completion/completions
+
+cp -a rpkg.conf %{buildroot}%{_sysconfdir}/
+cp -a rpkg.bash %{buildroot}%{_datarootdir}/bash-completion/completions/
+
+%files -n rpkg
+%license LICENSE
+%{python2_sitelib}/*
+
+%config(noreplace) %{_sysconfdir}/rpkg.conf
+%{_datadir}/bash-completion/completions/rpkg.bash
+
+%{_bindir}/rpkg
+%{_mandir}/*/*
+
+%changelog
+{{{ git_changelog }}}
+
+* Sun Feb 18 2018 clime <clime@redhat.com> 0.14-1
+- fix error when redownloading sources
+- do not invoke parent's module_name in load_ns_module_name
+- fix python builddeps naming
+
+* Mon Dec 04 2017 clime <clime@redhat.com> 0.13-1
+- add LICENSE to ignored file regex
+
+* Mon Oct 23 2017 clime <clime@redhat.com> 0.12-1
+- respect hashtype from the sources file if any
+
+* Fri Oct 20 2017 clime <clime@redhat.com> 0.11-1
+- set default distgit target to src.fedoraproject.org
+- fix downloading sources for any-length-namespace
+  modules
+- make the whole lookaside url template explict in
+  the config file
+- rename 'rpkg' config section to 'distgit'
+- update in command descriptions
+
+* Wed Oct 18 2017 clime <clime@redhat.com> 0.10-1
+- possibility to give directory to --spec
+- also take --spec in account for rpmdefines
+
+* Mon Oct 16 2017 clime <clime@redhat.com> 0.9-1
+- update spec descriptions
+- added is-packed subcommand
+- try reading ~/.config/rpkg before /etc/rpkg
+- add unittests
+- for source downloading, try both url formats
+  with/without hashtype
+- add make-source subcommand
+- patch srpm to generate Source0 if unpacked content
+- override load_ns_module_name to work with any length
+  namespaces
+- added --spec for srpm, make-source, and copr-build
+- fixed tagging not to include host dist tag
+- docs update
+- make all config values optional
+
+* Thu Jul 27 2017 clime <clime@redhat.com> 0.8-1
+- fix man pages to only include actually provided part of pyrpkg functionality
+- add rpkglib to provide functional interface
+- change summary of wrapper package
+
+* Wed Jul 26 2017 clime <clime@redhat.com> 0.7-1
+- use %%py2_build and %%py2_install macros
+- explicitly invoke python2 for doc generation
+- remove no longer needed $BUILDROOT removal in %%install clause
+- add missing BuildRequires on python-setuptools
+
+* Fri Jul 07 2017 clime <clime@redhat.com> 0.6-1
+- fix build error
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.5-1
+- remove Requires bash-completion
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.4-1
+- move config file to /etc/rpkg.conf
+- add Requires bash-completion
+
+* Tue Jun 27 2017 clime <clime@redhat.com> 0.3-1
+- remove some directories from %%files in .spec
+- add (for now) short README.md
+
+* Tue Jun 20 2017 clime <clime@redhat.com> 0.2-1
+- new rpkg-client package built with tito
+
+* Mon Jun 12 2017 clime <clime@redhat.com> 0.1-1
+- Initial version

From a8655fc5bdc036e96064098ca1c5c91abbd5ecf5 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 18 2018 21:49:20 +0000
Subject: [PATCH 92/104] change default auto_pack value to False


---

diff --git a/rpkg.conf b/rpkg.conf
index c599700..8a43b74 100644
--- a/rpkg.conf
+++ b/rpkg.conf
@@ -1,7 +1,7 @@
 [rpkg]
 preprocess_spec = True
 # auto-packing is deprecated:
-auto_pack = True
+auto_pack = False
 
 [dist-git]
 lookaside = https://src.fedoraproject.org/repo/pkgs/%(ns1)s/%(pkg)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s

From e75828e3a8bf72fbc278e6db056d0f0fe9bab4af Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 19 2018 09:32:50 +0000
Subject: [PATCH 93/104] extend examples with more description


---

diff --git a/examples/simple-template-cwd.spec.rpkg b/examples/simple-template-cwd.spec.rpkg
index 3d80195..4ce0c68 100644
--- a/examples/simple-template-cwd.spec.rpkg
+++ b/examples/simple-template-cwd.spec.rpkg
@@ -3,17 +3,32 @@
 # git_cwd_* macros work with the current
 # working directory by default (you can
 # override the working directory with
-# `rpkg --path`).
+# `rpkg --path` switch).
 #
 # For example, git_cwd_name will take
 # repository origin URL basename and
-# appends to it path (after slash to
+# appends to it the path (after slash to
 # dash substitution) from the repository
 # root to the current working directory.
 #
 # git_cwd_pack macro will pack the content
 # of the current working directory and
 # outputs filename to be used as Source0.
+#
+# Note that git_cwd_* macros are just
+# tiny wrappers over the base git
+# macro calls (see simple-example.spec.rpkg)
+#
+# They exists just to save you some typing
+# and you can think of them as aliases.
+#
+# The underlying git macros do all the job
+# and are the ones being cached.
+#
+# For example, calling git_cwd_name is
+# equivalent to calling:
+#
+# git_name append="-$(git -C "$(pwd)" rev-parse --show-prefix | name_convert)"
 
 Name:       {{{ git_cwd_name }}}
 Version:    {{{ git_cwd_version }}}
diff --git a/examples/simple-template-dir.spec.rpkg b/examples/simple-template-dir.spec.rpkg
index 27a0035..940ae5b 100644
--- a/examples/simple-template-dir.spec.rpkg
+++ b/examples/simple-template-dir.spec.rpkg
@@ -5,13 +5,31 @@
 #
 # For example, git_dir_name will take
 # repository origin URL basename and
-# appends to it path (after slash to
+# appends to it the path (after slash to
 # dash substitution) from the repository
 # root to the spec file's directory.
 #
 # git_dir_pack macro will pack the content
-# of the that directory and outputs filename
-# to be used as Source0.
+# of that directory and outputs filename
+# to be assigned as Source0.
+#
+# Note that git_dir_* macros are just
+# tiny wrappers over the base git
+# macro calls (see simple-example.spec.rpkg)
+#
+# They exists just to save you some typing
+# and you can think of them as aliases.
+#
+# The underlying git macros do all the job
+# and are the ones being cached.
+#
+# For example, calling git_dir_name is
+# equivalent to calling:
+#
+# git_name append="-$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix | name_convert)"
+#
+# INPUT_PATH is an environment variable
+# storing path to the input spec file.
 
 Name:       {{{ git_dir_name }}}
 Version:    {{{ git_dir_version }}}
diff --git a/examples/simple-template.spec.rpkg b/examples/simple-template.spec.rpkg
index 00784a4..52138d6 100644
--- a/examples/simple-template.spec.rpkg
+++ b/examples/simple-template.spec.rpkg
@@ -8,15 +8,15 @@
 #
 # For example, git_name will, by default,
 # read repository origin URL basename and
-# outputs it to stdout. The outputted value
+# outputs it to stdout. The output value
 # then replaces the {{{ git_name }}} invocation.
 #
 # git_pack macro will take the whole repository
-# content, packs it into a gzipped tarball and
+# content, packs it into a gzipped tarball, and
 # outputs its filename.
 #
 # By specifying certain parameters (see
-# section SPEC TEMPATES in rpkg man pages),
+# section SPEC TEMPLATES in rpkg man pages),
 # you can influence the behavior of those
 # macros to basically any extent.
 #
@@ -28,7 +28,7 @@
 # If you want to pack a directory called
 # "subdir" under a repository root (and not
 # under the current working directory as
-# in the previous example), you can use this:
+# in the previous example), you can use:
 #
 # {{{ git_pack path="$(git rev-parse --show-toplevel)/subdir" }}}
 #
@@ -41,6 +41,72 @@
 # changes need to be committed before you
 # can build the source tarball, for example
 # by calling `rpkg srpm`.
+#
+# Note that both git_archive and git_pack
+# macros derive the name of the resulting
+# tarball and also the name of the top
+# directory in the tarball from the previous
+# invocations of git_name and git_version macros.
+#
+# For example:
+#
+# Name:    {{{ git_name }}}
+# Version: {{{ git_version }}}
+# Source0: {{{ git_pack }}}
+#
+# If the first two lines get resolved to:
+#
+# Name:    test
+# Version: 1.0
+#
+# Then the third line gets resolved to:
+#
+# Source0: test-1.0.tar.gz
+#
+# The top directory in the created tarball
+# will be named test-1.0.
+#
+# If you parametrize the git_name and git_version
+# calls to give you other than default values (see
+# SPEC TEMPLATES sections in rpkg man pages):
+#
+# Name:    {{{ git_name name=foo }}}
+# Version: {{{ git_version lead=1 follow=3 }}}
+# Source0: {{{ git_pack }}}
+#
+# Then the git_pack macro will adjust its results
+# according to that. The previous three lines
+# will be resolved as:
+#
+# Name:    foo
+# Version: 1.3
+# Source0: foo-1.3.tar.gz
+#
+# Output of every git macro call is cached and
+# other macros are made to take those cached values
+# into account by default. If you look at the definion
+# of git_pack macro, you will see it:
+#
+# function git_pack {
+#    declare path="$(git rev-parse --show-toplevel)" dir_name="$(cached_name_version)" source_name="$(cached_name_version).tar.gz" "$@"
+#    ...
+# }
+#
+# You can override the default parameter values:
+#
+# Source0: {{{ git_pack dir_name=foo source_name=bar.tar.gz }}}
+#
+# This will always give you:
+#
+# Source0: bar.tar.gz
+#
+# and the top directory in the bar.tar.gz tarball will be named foo.
+#
+# You can experiment with it on this spec file by calling:
+#
+# rpkg spec --spec simple-template.spec.rpkg
+#
+# from command line.
 
 Name:       {{{ git_name }}}
 Version:    {{{ git_version }}}

From 30d625d06e43e5cf4fef5bb62b70bcd54a0e4ac6 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 19 2018 09:51:20 +0000
Subject: [PATCH 94/104] example typo fixes


---

diff --git a/examples/simple-template-cwd.spec.rpkg b/examples/simple-template-cwd.spec.rpkg
index 4ce0c68..8a1a3ac 100644
--- a/examples/simple-template-cwd.spec.rpkg
+++ b/examples/simple-template-cwd.spec.rpkg
@@ -20,7 +20,7 @@
 # macro calls (see simple-example.spec.rpkg)
 #
 # They exists just to save you some typing
-# and you can think of them as aliases.
+# and you can think of them only as aliases.
 #
 # The underlying git macros do all the job
 # and are the ones being cached.
diff --git a/examples/simple-template-dir.spec.rpkg b/examples/simple-template-dir.spec.rpkg
index 940ae5b..ca27822 100644
--- a/examples/simple-template-dir.spec.rpkg
+++ b/examples/simple-template-dir.spec.rpkg
@@ -18,7 +18,7 @@
 # macro calls (see simple-example.spec.rpkg)
 #
 # They exists just to save you some typing
-# and you can think of them as aliases.
+# and you can think of them only as aliases.
 #
 # The underlying git macros do all the job
 # and are the ones being cached.
diff --git a/examples/simple-template.spec.rpkg b/examples/simple-template.spec.rpkg
index 52138d6..266e646 100644
--- a/examples/simple-template.spec.rpkg
+++ b/examples/simple-template.spec.rpkg
@@ -26,7 +26,7 @@
 # instead of packing the whole repository.
 #
 # If you want to pack a directory called
-# "subdir" under a repository root (and not
+# "subdir" under the repository root (and not
 # under the current working directory as
 # in the previous example), you can use:
 #
@@ -34,7 +34,7 @@
 #
 # There is also git_archive macro which is
 # very similar to git_pack (and even has
-# the  same parameters) but uses `git archive`
+# the same parameters) but uses `git archive`
 # for packing instead of tar.
 #
 # If you use {{{ git_archive }}}, all your
@@ -68,7 +68,7 @@
 #
 # If you parametrize the git_name and git_version
 # calls to give you other than default values (see
-# SPEC TEMPLATES sections in rpkg man pages):
+# SPEC TEMPLATES section in rpkg man pages):
 #
 # Name:    {{{ git_name name=foo }}}
 # Version: {{{ git_version lead=1 follow=3 }}}
@@ -92,7 +92,7 @@
 #    ...
 # }
 #
-# You can override the default parameter values:
+# Of course, you can override the default parameter values:
 #
 # Source0: {{{ git_pack dir_name=foo source_name=bar.tar.gz }}}
 #
@@ -100,9 +100,9 @@
 #
 # Source0: bar.tar.gz
 #
-# and the top directory in the bar.tar.gz tarball will be named foo.
+# not matter what and the top directory in the bar.tar.gz tarball will be named foo.
 #
-# You can experiment with it on this spec file by calling:
+# You can experiment on this spec file by executing:
 #
 # rpkg spec --spec simple-template.spec.rpkg
 #

From 79a83aa98f75c56dedc20e65eb66a9ccf0d6176c Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 19 2018 15:28:14 +0000
Subject: [PATCH 95/104] add two tag tests and make_srpm on plain dir test with auto_pack off


---

diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index c93742c..88f1d4b 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -19,6 +19,7 @@ class rpkgClient(cliClient):
         if not os.path.isdir(DEFAULT_OUTDIR):
             os.makedirs(DEFAULT_OUTDIR)
 
+        self.auto_pack = config['rpkg'].getboolean('auto_pack', False)
         super(rpkgClient, self).__init__(config, name)
 
     def setup_argparser(self):
@@ -173,7 +174,7 @@ class rpkgClient(cliClient):
 
     def srpm(self):
         self.cmd.sources()
-        if self.config['rpkg'].getboolean('auto_pack', False):
+        if self.auto_pack:
             try:
                 self.cmd.make_source()
             except NotUnpackedException:
diff --git a/run_tests.sh b/run_tests.sh
index 363eee0..4a8233e 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -1,2 +1,5 @@
-#!/bin/sh
-PYTHONPATH=.:$PYTHONPATH python2 -m pytest tests -s $@
+#!/bin/bash
+
+path="${1:-tests}"
+
+PYTHONPATH=.:$PYTHONPATH python2 -m pytest -s $path
diff --git a/tests/base.py b/tests/base.py
index e21b7ea..6f0e3b1 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -3,6 +3,7 @@ import unittest
 import shutil
 import rpm
 import tempfile
+from rpkglib import utils
 
 from spec_templates import SPEC_TEMPLATE
 
@@ -13,15 +14,19 @@ class TestCase(unittest.TestCase):
     def tearDown(self):
         shutil.rmtree(self.tmpdir)
 
-    def dump_spec(self, template, pkgname='testpkg', subdir=None, **kwargs):
-        spec_content = template.substitute(kwargs, pkgname=pkgname)
+    def dump_spec(self, template, pkgname='testpkg', subdir=None, version="1",
+                  release="1", source0='source0.tar.gz', **kwargs):
+
+        spec_content = template.substitute(
+            kwargs, pkgname=pkgname, version=version,
+            release=release, source0=source0)
+
         if subdir:
             dirpath = os.path.join(self.tmpdir, subdir)
             os.makedirs(dirpath)
         else:
             dirpath = self.tmpdir
-        spec_path = os.path.join(
-            dirpath, '{}.spec'.format(pkgname))
+        spec_path = os.path.join(dirpath, '{}.spec'.format(pkgname))
         spec_file = open(spec_path, 'w')
         spec_file.write(spec_content)
         spec_file.close()
@@ -49,3 +54,15 @@ class TestCase(unittest.TestCase):
     def make_unpacked_content(self):
         spec_path = self.dump_spec(SPEC_TEMPLATE, source0='source0.tar.gz')
         self.touch_file('foobar.py')
+
+    def init_repo_with_commit(self):
+        cmds = (
+            ['git', 'init'],
+            ['touch', 'README'],
+            ['git', 'add', '-A'],
+            ['git', 'config', 'user.name', 'tester'],
+            ['git', 'config', 'user.email', 'tester@example.com'],
+            ['git', 'commit', '-m', '"Add README"'],
+        )
+        for cmd in cmds:
+            utils.run_command(cmd, cwd=self.tmpdir)
diff --git a/tests/spec_templates.py b/tests/spec_templates.py
index da3de2a..a79c0d4 100644
--- a/tests/spec_templates.py
+++ b/tests/spec_templates.py
@@ -2,8 +2,8 @@ from string import Template
 
 SPEC_TEMPLATE = Template("""
 Name:       $pkgname
-Version:    1
-Release:    1
+Version:    $version
+Release:    $release
 Summary:    This is a test package.
 
 License:    GPLv2+
@@ -15,8 +15,8 @@ Source0:    $source0
 
 SPEC_WITH_PATCH_TEMPLATE = Template("""
 Name:       $pkgname
-Version:    1
-Release:    1
+Version:    $version
+Release:    $release
 Summary:    This is a test package.
 
 License:    GPLv2+
@@ -30,8 +30,8 @@ Patch0:     $patch0
 
 INVALID_SPEC_TEMPLATE = Template("""
 Name:       $pkgname
-Version:    1
-Release:    1
+Version:    $version
+Release:    $release
 Summary:    This is a test package.
 
 License:    GPLv2+
@@ -40,8 +40,8 @@ URL:        https://someurl.org
 
 NO_SOURCE_ZERO_SPEC_TEMPLATE = Template("""
 Name:       $pkgname
-Version:    1
-Release:    1
+Version:    $version
+Release:    $release
 Summary:    This is a test package.
 
 License:    GPLv2+
diff --git a/tests/test_cli.py b/tests/test_cli.py
index e8a5615..2541605 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 import unittest
 import rpkglib
 import six
@@ -40,10 +42,10 @@ class TestCli(base.TestCase):
         config_file.write(RPKG_CONFIG)
         config_file.close()
 
-        config = configparser.SafeConfigParser()
-        config.read(self.config_path)
+        self.config = configparser.SafeConfigParser()
+        self.config.read(self.config_path)
 
-        self.client = rpkgClient(config, name='rpkg')
+        self.client = rpkgClient(self.config, name='rpkg')
         self.client.do_imports('rpkglib')
         self.client.args = munch.Munch(user='user', q='q', path=self.tmpdir, outdir=self.tmpdir, module_name=None, debug=False, v=False)
 
@@ -145,3 +147,51 @@ class TestCli(base.TestCase):
         self.assertItemsEqual(
             os.listdir(path),
             dircontent+['testpkg1.spec', 'testpkg1-1-1.src.rpm'])
+
+    def test_make_srpm_on_plain_dir_no_autopack(self):
+        client = rpkgClient(self.config, name='rpkg')
+        client.do_imports('rpkglib')
+        client.args = munch.Munch(user='user', q='q', path=self.tmpdir, outdir=self.tmpdir, module_name=None, debug=False, v=False)
+        client.auto_pack = False
+
+        spec1_path = self.dump_spec(
+            SPEC_TEMPLATE, pkgname='testpkg1', source0='source0.tar.gz')
+        self.touch_file('source0.tar.gz')
+        dircontent = os.listdir(self.tmpdir)
+
+        self.client.args.spec = spec1_path
+        self.client.srpm()
+        self.assertItemsEqual(
+            os.listdir(self.tmpdir),
+            dircontent+['testpkg1-1-1.src.rpm'])
+
+    @mock.patch('rpkglib.Commands.add_tag')
+    def test_tag(self, mock_add_tag):
+        self.dump_spec(
+            SPEC_TEMPLATE, pkgname='testpkg1', version='1', release='4')
+
+        self.client.args.update({
+            'list': None,
+            'tag': None,
+            'delete': None,
+            'file': None,
+            'clog': None,
+            'force': False,
+            'message': 'message',
+        })
+
+        self.client.tag()
+        mock_add_tag.assert_called_with('testpkg1-1-4', False, 'message', None)
+
+        spec2_path = self.dump_spec(
+            SPEC_TEMPLATE, pkgname='testpkg2', version='x', release='x')
+
+        # reload everything
+        self.client.cmd.set_specloc(spec2_path)
+        self.client.cmd.load_repo_spec()
+        self.client.cmd.load_spec()
+        self.client.cmd.load_nameverrel()
+        self.client.cmd.load_nvr()
+
+        self.client.tag()
+        mock_add_tag.assert_called_with('testpkg2-x-x', False, 'message', None)
diff --git a/tests/test_cmd.py b/tests/test_cmd.py
index a2b6fbe..0a5b287 100644
--- a/tests/test_cmd.py
+++ b/tests/test_cmd.py
@@ -3,21 +3,26 @@ import os
 import tarfile
 import six
 import git
-
 import base
 import rpkglib
+
 from rpkglib.exceptions import NotUnpackedException, RpmSpecParseException,\
         NoSourceZeroException
 from rpkglib.utils import find_source_zero
+
 from spec_templates import SPEC_TEMPLATE, SPEC_WITH_PATCH_TEMPLATE,\
         INVALID_SPEC_TEMPLATE, NO_SOURCE_ZERO_SPEC_TEMPLATE
 
+from pyrpkg.errors import rpkgError
+
 if six.PY3:
     from unittest import mock
     from unittest.mock import MagicMock
+    from io import StringIO
 else:
     import mock
     from mock import MagicMock
+    from cStringIO import StringIO
 
 class TestCommands(base.TestCase):
     def setUp(self):
@@ -203,3 +208,19 @@ class TestCommands(base.TestCase):
         self.touch_file('patch.txt')
         with self.assertRaises(NoSourceZeroException):
             self.cmd.make_source()
+
+    @mock.patch('sys.stdout', new_callable=StringIO)
+    def test_add_tag(self, mock_stdout):
+        with self.assertRaises(rpkgError) as err:
+            self.cmd.add_tag('foo-bar')
+
+        assert str(err.exception) == 'Tag foo-bar does not have n-v-r format.'
+
+        spec_path = self.dump_spec(
+            SPEC_TEMPLATE, pkgname='testpkg1', version='1', release='4')
+
+        self.init_repo_with_commit()
+        self.cmd.add_tag(self.cmd.nvr, message='message')
+
+        self.cmd.list_tag()
+        assert mock_stdout.getvalue() == 'testpkg1-1-4\n'

From 52d135196f078290fcba7792455a4de7cc849f5a Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 19 2018 15:58:01 +0000
Subject: [PATCH 96/104] update doc/index.rst


---

diff --git a/doc/index.rst b/doc/index.rst
index 1881c93..5b65850 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -13,7 +13,7 @@ rpkg is an rpm packaging utility that you can use to maintain your application s
 It is designed to work on top of Git repositories but it can also handle just any plain
 directory content. It will allow you to easily transform raw sources into an rpm source
 package that you can build (also by using rpkg) in a public build system, which will
-produce rpm(s) that any user can install into their system and start using.
+produce packages that any user can easily install into their system and start using.
 
 
 Content
@@ -58,7 +58,8 @@ If you would like to install `rpkg` directly from the upstream sources, run:
 
     $ git clone https://pagure.io/rpkg-util
     $ cd rpkg-util
-    $ sudo rpkg local -i
+    $ rpkg local
+    $ sudo dnf -C install /tmp/rpkg/noarch/rpkg*.noarch.rpm
 
 But the easier way to always get the latest, greatest `rpkg` is:
 

From 8010cbe4bbca2300acd360c8611eb70284b1767e Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 19 2018 15:58:19 +0000
Subject: [PATCH 97/104] fix setup.py and fix man pages generation


---

diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 88f1d4b..68b7bcb 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -19,7 +19,11 @@ class rpkgClient(cliClient):
         if not os.path.isdir(DEFAULT_OUTDIR):
             os.makedirs(DEFAULT_OUTDIR)
 
-        self.auto_pack = config['rpkg'].getboolean('auto_pack', False)
+        if config:
+            self.auto_pack = config['rpkg'].getboolean('auto_pack', False)
+        else:
+            self.auto_pack = False
+
         super(rpkgClient, self).__init__(config, name)
 
     def setup_argparser(self):
diff --git a/setup.py b/setup.py
index 15e2acc..cd19740 100755
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,11 @@
 #!/usr/bin/env python3
 
 import rpm
+import subprocess
 from setuptools import setup, find_packages
 
-spec_file = rpm.ts().parseSpec('rpkg-client.spec')
+subprocess.call(['rpkg', 'spec'])
+spec_file = rpm.ts().parseSpec('/tmp/rpkg/rpkg-client.spec')
 
 setup(
     name=spec_file.sourceHeader.name.decode("utf-8"),

From 560d29faf2321a60f0fb51fe928fd0786e46b428 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 19 2018 22:39:16 +0000
Subject: [PATCH 98/104] update tutorial and index.rst


---

diff --git a/doc/index.rst b/doc/index.rst
index 5b65850..a5b0f71 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -4,7 +4,7 @@ rpkg utility
 * *If you are looking for an easy way to make installation packages out of your application sources...*
 * *If you want to make free and open-source software out there easily available to end users...*
 * *If you like configurability without limits...*
-        
+
 
 Preview
 -------
@@ -13,7 +13,7 @@ rpkg is an rpm packaging utility that you can use to maintain your application s
 It is designed to work on top of Git repositories but it can also handle just any plain
 directory content. It will allow you to easily transform raw sources into an rpm source
 package that you can build (also by using rpkg) in a public build system, which will
-produce packages that any user can easily install into their system and start using.
+produce packages that any user can install into their system and start using.
 
 
 Content
diff --git a/doc/tutorials.rst b/doc/tutorials.rst
index d80512c..84dc3f0 100644
--- a/doc/tutorials.rst
+++ b/doc/tutorials.rst
@@ -17,6 +17,7 @@ To setup the test environment, run the following commands:
     Version:    {{{ git_version }}}
     Release:    1%{?dist}
     Summary:    This is a test package.
+    VCS:        {{{ git_vcs }}}
 
     License:    GPLv2+
     URL:        https://someurl.org
@@ -34,21 +35,22 @@ To setup the test environment, run the following commands:
     EOF
     git init
 
+
 Those commands will create a local git repository called `test-project`
 containing our first spec template called ``simple-template.spec.rpkg``.
 
-We can now try to invoke `rpkg` to generate a real spec file from the template:
+We can now try to invoke ``rpkg`` to generate a real spec file from the template:
 
 ::
 
     $ rpkg spec
     git_name: Start by setting origin URL.
-    subcmd ['git_name'] failed with value 1
+    git_name failed with value 1
 
 ...well, not so fast :).
 
-Remote origin URL needs to be setup first and that's because
-the ``git_name`` macro determines the value of package name from the "origin" URL.
+Remote origin URL needs to be setup first and that's because the ``git_name``
+macro determines the value of package name from that URL.
 
 We can set it up by running:
 
@@ -57,7 +59,7 @@ We can set it up by running:
     git remote add origin ssh://git@pagure.io/test-project.git
 
 Note that we don't really need `pagure.io/test-project.git` project
-to exist publicly at this point. Only the "origin" needs to be set.
+to exist publicly at this point. Only the "origin" variable needs to be set.
 
 Let's try again:
 
@@ -72,28 +74,39 @@ Voilà!
 
     $ cat /tmp/rpkg/simple-template.spec
     Name:       test-project
-    Version:    0.0
+    Version:    0.0.wtree.zf4r62
     Release:    1%{?dist}
     Summary:    This is a test package.
+    VCS:        git+ssh://git@pagure.io/test-project.git#HEAD:
 
     License:    GPLv2+
     URL:        https://someurl.org
 
-    Source: test-project-0.0.tar.gz
+    Source: test-project-0.0.wtree.zf4r62.tar.gz
 
     %description
     This is a test package.
 
     %prep
-    %setup -q -n test-project-0.0
+    %setup -q -n test-project-0.0.wtree.zf4r62
 
     %changelog
 
+You can see that the version in the resulting spec file is ``0.0`` followed
+by a curious ``.wtree.zf4r62`` suffix. The fact that the suffix is present means
+that our working tree is dirty. The ``zf4r62`` substring encodes the time of
+the latest uncommitted file status change.
+
+You can also notice that the same suffix is present in the ``Source`` filename
+as well as in the parameter given to ``%setup -n`` macro. That's because the output
+of ``git_version`` is remembered and the subsequent rpkg macro invocations
+may use it as part of their own output value.
 
-You can see that the version in the resulting spec file is "0.0" 
-for a freshly initialized project. 
+The ``.wtree.*`` suffix will disappear once we make our first commit (see below).
+The version will stay at ``0.0``, however, and it will be incremented later to
+``0.1`` when we make our first tag.
 
-Now let's make the first commit in our test project and see what happens.
+Now let's make the first commit in our test project and see what happens:
 
 ::
 
@@ -105,7 +118,7 @@ Viewing the commit:
 ::
 
     $ git log --oneline
-    647071e (HEAD -> master) first commit
+    dadef2a (HEAD -> master) first commit
 
 Regenerating the spec file:
 
@@ -113,40 +126,55 @@ Regenerating the spec file:
 
     rpkg spec
 
-and finally getting:
+Finally getting:
 
 ::
 
-    $ cat /tmp/rpkg/simple-template.spec
     Name:       test-project
-    Version:    0.0.git.1.647071e
+    Version:    0.0.git.1.dadef2a
     Release:    1%{?dist}
     Summary:    This is a test package.
+    VCS:        git+ssh://git@pagure.io/test-project.git#dadef2a8b9554e94797a7336261192e02d5d9351:
 
     License:    GPLv2+
     URL:        https://someurl.org
 
-    Source: test-project-0.0.git.1.647071e.tar.gz
+    Source: test-project-0.0.git.1.dadef2a.tar.gz
 
     %description
     This is a test package.
 
     %prep
-    %setup -q -n test-project-0.0.git.1.647071e
+    %setup -q -n test-project-0.0.git.1.dadef2a
 
     %changelog
 
 
-You can see that a dynamically generated suffix based on the latest commit hash
-was appended to ``Version:``, ``Source:``, and to the value of ``%setup -n`` parameter. 
-This becomes useful when we actually want to build a source package by using the spec file.
-Thanks to the ``git_version`` macro, each source package version corresponds to 
-a particular commit in the source repository history.
+You can see that the ``.wtree.*`` suffix was replaced by ``.git.1.dadef2a``.
+This suffix is based on the latest commit in the currently checked out branch.
+The number ``1`` is given by number of commits from the latest git tag created
+for our ``test-project`` package or from the repository initialization if no
+such tag exists yet (our case).
 
-Now let's examine how commit tagging works with ``rpkg`` because commit tagging
-becomes actually very handy when your application reaches a certain stable (feature-complete)
-state that you would like to share with people. We will need to assume that we have already
-reached that state after just the first commit in our test-project :) (which is very rare).
+The ``dadef2a`` part is the first seven characters of the full commit hash and you can
+use this short hash to checkout the commit:
+
+::
+
+    git checkout dadef2a
+
+This is not useful at the moment because we have just made the commit and we have it checked
+out already in our repository but it becomes useful when you build a source rpm from the
+generated spec file.
+
+That's because the value in the spec file's version field gets propagated into the built srpm name,
+which means that if you store that srpm somewhere and you will later come back to it, you will
+know from which commit it was built and what it contains consequently.
+
+Now let's examine how tagging works with ``rpkg`` because tagging becomes actually very handy
+when your application reaches a certain stable (feature-complete) state that you would like
+to share with people. We will need to assume that we have already reached that state after
+just the first commit in our test-project :) (which is very rare).
 
 ::
 
@@ -164,26 +192,38 @@ First thing that happens is that an editor window pops up where you can edit a t
 
 
 The intial content of the tag message gets populated from the first lines
-of all commit messages since the last tag. Because we didn't have any existing
+of all commit messages since the last tag. Because we don't have any existing
 tag before this one, commit messages since the repository initialization are
-collected and used to populate the initial content.
+collected and used to populate the initial message content.
 
 You can keep this pre-generated tag message as it is, edit it in any way,
 or just delete it and write your own stuff but note that this message
-consitutes the basic information about your application release (and what
+constitutes the basic information about our application release (and what
 have changed since the previous realease), so it is quite important.
 
-After you are finally satisfied with your message, you can save 
+After you are finally satisfied with your message, you can save
 the content and close the editor. The new tag will be generated:
 
 ::
 
     $ rpkg tag
+    Wrote: /tmp/rpkg/simple-template.spec
     Created tag: test-project-0.1-1
     Wrote: /tmp/rpkg/simple-template.spec
 
-Note that a new spec was automatically regenerated from our spec template after the
-tag was created. Let's view it:
+You might wonder about the two lines ``Wrote: /tmp/rpkg/simple-template.spec``.
+The first line is there because the tag name is derived from the `Name:`, `Version:`,
+and `Release:` field values in the generated spec file.
+
+`EXPERT INFO:`
+
+When tagging takes place, ``rpkg`` sets a special variable ``VERSION_BUMP``
+into the spec preprocessing environment. ``git_version`` macro is aware of this variable
+and if it is set, an incremented version value is generated. This incremented value
+then gets carried over into the tag name together with the package name and release.
+
+When the tag is finally created, the spec is regenerated to get the latest tag
+changelog into it as well. Let's view that final spec file:
 
 ::
 
@@ -192,6 +232,7 @@ tag was created. Let's view it:
     Version:    0.1
     Release:    1%{?dist}
     Summary:    This is a test package.
+    VCS:        git+ssh://git@pagure.io/test-project.git#dadef2a8b9554e94797a7336261192e02d5d9351:
 
     License:    GPLv2+
     URL:        https://someurl.org
@@ -208,44 +249,40 @@ tag was created. Let's view it:
     * Wed Mar 07 2018 clime <clime@redhat.com> 0.1-1
     - first commit
 
-You can see that the dynamic version suffix has
-not been generated into the ``Version:`` field this time.
-This happens every time the currently checked out commit
-is tagged.
-
-The reason is that tagged commits can be identified just
-by the version "base" because that base gets carried over
-into the tag name (together with package name and release).
-Knowing a tag name, we can easily get back to a particular
-commit (and the tag name can be easily obtained from
-a source package name - we will see that later).
-
-Version substrings in ``Source:`` field and in the
-``%setup`` macro has been, of course, adjusted as well.
-
-And finally, the changelog has been also automatically
-generated for us based on the currently existing tags
-and their content. Note that the changelog contains the 
-exact tag message we were previously editing in the editor 
-window :).
-
-If you prefer to edit your changelog messages
-directly in the spec file instead of having them
-generated from tags, you can. Just do
-not use the ``git_changelog`` macro and instead do
-your edits directly in the spec file template.
-
-You can also configure the ``git_changelog`` macro
-to generate changelog entries only since a certain
-point in history by specifying its ``since_tag`` parameter
-(e.g. ``git_changelog since_tag=test-project-0.1-1``).
-
-There are plenty of parameters also for the other
-macros to give you that same freedom you experience
-when you are dealing with just plain spec files.
-For example, you can increment the lead version number
-(the first number in the version string) by setting ``lead``
-parameter of ``git_version``:
+You can see that no dynamic version suffix has been generated into the
+``Version:`` field this time.  This happens every time the currently
+checked out commit is a tagged one.
+
+The reason is that if you know a tag name, you can just
+directly pass it to ``git checkout``:
+
+::
+
+    $ git checkout test-project-0.1
+
+and you will get back to the respective commit for which
+the tag was created.
+
+You can also see that the changelog has been automatically generated
+for us based on the currently existing tags and their content.
+
+If you don't like this and you prefer editing your changelog messages
+directly in the source spec file instead of having them generated from tags,
+no problem. Just don't use the ``git_changelog`` macro and instead do your
+edits directly in the spec file template. Any normal text (not enclosed in
+``{{{``, ``}}}`` brace triplets) will be copied verbatim into the resulting
+spec file.
+
+If you like the ``git_changelog`` macro but you don't have every single
+changelog message stored in a tag, you can configure it to generate
+changelog entries only since a certain point in history by specifying its
+``since_tag`` parameter (e.g. ``git_changelog since_tag=test-project-0.1-1``).
+
+There are plenty of parameters also for the other macros to give you that
+same freedom you experience when you are dealing with just plain spec files.
+
+For example, you can increment the major version number (the first number in
+the version string) by setting ``lead`` parameter of ``git_version``:
 
 ::
 
@@ -254,6 +291,18 @@ parameter of ``git_version``:
     Release:    1%{?dist}
     ...
 
+For our project this will now generate something like:
+
+::
+
+    Name:       test-project
+    Version:    1.0.wtree.zf4657
+    Release:    1%{?dist}
+    ...
+
+The ``.wtree.*`` suffix is telling us that our working tree
+is dirty again after adding ``lead=1`` and not commiting yet.
+
 Read more about the macros and their parameters here.
 
 And of course, you can fallback to using the plain spec
@@ -261,48 +310,51 @@ files (without any rpkg macros) at any time, although
 you will lose the advantage of the certain spec parts
 being generated automatically for you.
 
-But so far we have only seen generating spec from
-template but what if you want to generate the whole
-source package that you would like to build and
-and distribute afterwards.
+So far, we have only seen generating spec from a template
+but what if we want to generate a whole source package.
 
-You can do that with ``rpkg srpm``:
+We can do that with ``rpkg srpm``:
 
 ::
 
     $ rpkg srpm
-    git_pack: Wrote: /tmp/rpkg/test-project-0.1.tar.gz
+    git_pack: Wrote: /tmp/rpkg/test-project-1.0.wtree.zf4657.tar.gz
     Wrote: /tmp/rpkg/simple-template.spec
-    Wrote: /tmp/rpkg/test-project-0.1-1.fc27.src.rpm
+    Wrote: /tmp/rpkg/test-project-1.0.wtree.zf4657-1.fc27.src.rpm
+
+Now, actually we don't usually want to build an srpm from a dirty
+tree because srpm is something, which eventually gets built into
+a final installable rpm package.
 
-If you call ``rpkg srpm`` now, three files are created.
-The generated spec (you can see the relevant log 
-message on the second line). The tarball that packs
-all your application sources (first line). And the source rpm
-that bundles the generated spec file and the sources
-and can be used for building an rpm installation
-package (third line).
+It should be always possible to track that rpm package back to a
+particular commit in a git history, so that you can look at the
+exact sources it was built from. This becomes impossible if we build
+an srpm from a dirty tree. It might be still useful for local development,
+however.
 
-You can also just generate the spec and the tarball
-only by ``rpkg spec --sources`` command. If you call it
-now, rpkg will tell you the tarball already exists
-so it does not need to be regenerated:
+So let's reset to the latest commit (which is also a tagged one) and
+continue from there:
 
 ::
 
-    $ rpkg spec --sources
-    git_pack: Source file already exists. No action taken.
+    $ git reset --hard test-project-0.1-1
+    HEAD is now at dadef2a first commit
+    $ rpkg srpm
+    git_pack: Wrote: /tmp/rpkg/test-project-0.1.tar.gz
     Wrote: /tmp/rpkg/simple-template.spec
+    Wrote: /tmp/rpkg/test-project-0.1-1.fc27.src.rpm
 
-If you want the tarball to be generated even though it 
-already exists, you can delete it from ``/tmp/rpkg`` 
-(default output dir) before continuing.
+Three files were created. The spec (you can see the relevant
+log message on the second line). The tarball that packs all our application
+sources for the current commit (on the first line). And the source rpm that
+bundles the generated spec file and the tarball and can be used for building
+an rpm installation package (the third line).
 
-::
+Note that the names of the tarball and of the source srpm match the tag name
+of the currently checked out commit as they should.
 
-    rm /tmp/rpkg/test-project-0.1.tar.gz
-
-Then you can call:
+You can generate just a spec and a tarball with ``rpkg spec --sources``
+command:
 
 ::
 
@@ -310,16 +362,18 @@ Then you can call:
     git_pack: Wrote: /tmp/rpkg/test-project-0.1.tar.gz
     Wrote: /tmp/rpkg/simple-template.spec
 
-...and the gzipped tarball will be generated.
+In the previous examples, we could see that ``git_pack`` macro
+generates the source tarball only when needed (e.g. when calling
+``rpkg srpm``) or when explicitly asked to do it (``rpkg spec --sources``).
+
+This is a useful optimization.
 
-In the previous examples, you could see that ``git_pack``
-macro generates the source tarball only when needed
-(e.g. when calling ``rpkg srpm``) or when explicitly asked 
-to (``rpkg spec --sources``). This is a useful optimization.
-By the way, ``git_archive`` macro (which uses ``git archive`` 
-command instead of ``tar`` to do the job) behaves the same way.
+By the way, there is also ``git_archive`` rpkg macro (which uses
+``git archive`` command instead of ``tar`` to do the packing), which behaves
+the same way in this regard. With this macro, however, all your changes
+need to be committed before you can generate a tarball or a source rpm.
 
-In this tutorial, we have seen:
+In this tutorial, we have learned:
 
 - how to create a simple spec file template
 - how to generate a real rpm spec from the template

From f75bf46c3bbadbfc27e65754cc9d2733c384ac85 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 19 2018 23:28:05 +0000
Subject: [PATCH 99/104] bb .tito


---

diff --git a/.tito/packages/.readme b/.tito/packages/.readme
deleted file mode 100644
index b9411e2..0000000
--- a/.tito/packages/.readme
+++ /dev/null
@@ -1,3 +0,0 @@
-the .tito/packages directory contains metadata files
-named after their packages. Each file has the latest tagged
-version and the project's relative directory.
diff --git a/.tito/packages/rpkg-client b/.tito/packages/rpkg-client
deleted file mode 100644
index 5085848..0000000
--- a/.tito/packages/rpkg-client
+++ /dev/null
@@ -1 +0,0 @@
-0.8-1 ./
diff --git a/.tito/tito.props b/.tito/tito.props
deleted file mode 100644
index eab3f19..0000000
--- a/.tito/tito.props
+++ /dev/null
@@ -1,5 +0,0 @@
-[buildconfig]
-builder = tito.builder.Builder
-tagger = tito.tagger.VersionTagger
-changelog_do_not_remove_cherrypick = 0
-changelog_format = %s (%ae)

From f14c5e0c7d4acc206e60384b7df1da3afb29684c Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 19 2018 23:51:21 +0000
Subject: [PATCH 100/104] update man pages


---

diff --git a/man/rpkg_man_page.py b/man/rpkg_man_page.py
index 68ce5f1..c947f92 100644
--- a/man/rpkg_man_page.py
+++ b/man/rpkg_man_page.py
@@ -20,7 +20,7 @@ man_header = """\
 .\\" man page for rpkg
 .TH rpkg 1 "%(today)s" "" "rpm\\-packager"
 .SH "NAME"
-rpkg \\- RPM Packaging utility
+rpkg \\- RPM packaging utility
 .SH "SYNOPSIS"
 .B "rpkg"
 [
@@ -42,52 +42,56 @@ rpkg \\- RPM Packaging utility
 .B "\\-\\-help"
 .SH "DESCRIPTION"
 .B "rpkg"
-is a script to maintain RPM package content. It is designed to work with expanded sources as well
-as with tarballs and patches. Note that you should trust the .spec files you work with because
-many operations (like `rpkg srpm`, `rpkg lint`, or `rpkg is-packed`) involve parsing the spec file,
-which brings along evalution of any shell or lua scriplets.
+is a script to manage spec-enriched Git repositories - meaning any repository which contains
+an rpm spec file describing properties of an rpm package. It is designed to work with expanded
+sources as well as with tarballs and patches. Note that you should trust the .spec files
+you work with because many operations (like `rpkg srpm`, `rpkg lint`) involve parsing the
+spec file, which brings along evalution of any shell or lua scriplets present in it.
 """
 
 man_footer = """\
 .SH "EXAMPLES"
 
-    $ cd prep-example
-    $ ls .
-    doc  LICENSE  README.md  rpkg  rpkg.bash  rpkg-client.spec  rpkg.conf  rpkglib  run_tests.sh  setup.py  tests
-    $ rpkg prep
-    error: File rpkg-client/rpkg-client-0.8.tar.gz: No such file or directory
-    $ rpkg make-source
-    Wrote: rpkg-client/rpkg-client-0.8.tar.gz
+    Run %prep phase of an rpm build:
+
     $ rpkg prep
-    Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.bd5cCF
+    Wrote: /tmp/rpkg/rpkg-util.spec
+    Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.4iFciz
     + umask 022
-    ...
-    $ rpkg clean
+    + cd /tmp/rpkg/
+    + cd /tmp/rpkg
+    + rm -rf rpkg-util-1.0.git.122.e59a5b11
+    + /usr/bin/gzip -dc /tmp/rpkg/rpkg-util-1.0.git.122.e59a5b11.tar.gz
+    + /usr/bin/tar -xof -
+    + STATUS=0
+    + '[' 0 -ne 0 ']'
+    + cd rpkg-util-1.0.git.122.e59a5b11
+    + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+    + exit 0
+
+    For the following command, you need to have a project in COPR created. See quick tutorial at
+
+    https://docs.pagure.org/copr.copr/user_documentation.html#quick-start
+
+    on how to do it.
+
+    $ rpkg copr-build @releng/rpkg-util
+    git_pack: Wrote: /tmp/rpkg/rpkg-util-1.0.git.122.e59a5b11.tar.gz
+    Wrote: /tmp/rpkg/rpkg-util.spec
+    Wrote: /tmp/rpkg/rpkg-util-1.0.git.122.e59a5b11-1.fc27.src.rpm
+    Uploading package /tmp/rpkg/rpkg-util-1.0.git.122.e59a5b11-1.fc27.src.rpm
+    100% |################################| 57kB 339kB/s eta 0:00:00
+    Build was added to rpkg-util:
+      https://copr.fedorainfracloud.org/coprs/build/724892/
+    Created builds: 724892
+    Watching build(s): (this may be safely interrupted)
+      15:50:12 Build 724892: importing ...
 
-    In this example, we run prep phase of rpmbuild process in an originally unpacked directory. At first we get
-    an error about the tarball not being present. We first need to run `rpkg make-source` manually to create it
-    (which makes the working directory content "packed" by the way). Then `rpkg prep` can be successfully executed.
-    The following applies also to `rpkg local` and `rpkg install`. In the end, the generated tarball can be removed
-    with `rpkg clean` if the working directory is a Git repo.
-
-    $ cd unpacked-copr-build-example
-    $ ls .
-    doc  LICENSE  README.md  rpkg  rpkg.bash  rpkg-client.spec  rpkg.conf  rpkglib  run_tests.sh  setup.py  tests
-    $ rpkg copr-build user/project
-    Wrote: copr-build-example/rpkg-client-0.8.tar.gz
-    Wrote: copr-build-example/rpkg-client-0.8-1.fc25.src.rpm
-    Uploading package rpkg-client-0.8-1.fc25.src.rpm
-    100% |################################| 49kB 263kB/s eta 0:00:00
-    Build was added to example:
-      https://copr.fedorainfracloud.org/coprs/build/625402/
-    Created builds: 625402
-    ...
-
-    This example illustrates launching a COPR build directly from an unpacked (expanded) content.
-    SRPM is first build and then sent to COPR with copr-cli tool.
 
 .SH "PACKED VS UNPACKED"
 
+NOTE: This article related to deprecated auto_pack feature. You can safely ignore it.
+
 While it is quite intuitive what is packed content (.spec + tarballs + patches)
 and what is unpacked content (.spec + original application source files), it
 might be useful to know how exactly rpkg differentiates between these two.
@@ -157,8 +161,8 @@ works.
     we have run `git init .` and `git remote add ...`.
 
 .SH "SEE ALSO"
-.UR "https://pagure.io/rpkg-client/"
-.BR "https://pagure.io/rpkg-client/"
+.UR "https://pagure.io/rpkg-util/"
+.BR "https://pagure.io/rpkg-util/"
 """
 
 

From d8eb00625143712c244a209688a00295e777161a Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 20 2018 11:45:24 +0000
Subject: [PATCH 101/104] small doc tweak


---

diff --git a/doc/tutorials.rst b/doc/tutorials.rst
index 84dc3f0..8b8660d 100644
--- a/doc/tutorials.rst
+++ b/doc/tutorials.rst
@@ -17,10 +17,10 @@ To setup the test environment, run the following commands:
     Version:    {{{ git_version }}}
     Release:    1%{?dist}
     Summary:    This is a test package.
-    VCS:        {{{ git_vcs }}}
 
     License:    GPLv2+
     URL:        https://someurl.org
+    VCS:        {{{ git_vcs }}}
 
     Source: {{{ git_pack }}}
 
@@ -77,10 +77,10 @@ Voilà!
     Version:    0.0.wtree.zf4r62
     Release:    1%{?dist}
     Summary:    This is a test package.
-    VCS:        git+ssh://git@pagure.io/test-project.git#HEAD:
 
     License:    GPLv2+
     URL:        https://someurl.org
+    VCS:        git+ssh://git@pagure.io/test-project.git#HEAD:
 
     Source: test-project-0.0.wtree.zf4r62.tar.gz
 
@@ -134,10 +134,10 @@ Finally getting:
     Version:    0.0.git.1.dadef2a
     Release:    1%{?dist}
     Summary:    This is a test package.
-    VCS:        git+ssh://git@pagure.io/test-project.git#dadef2a8b9554e94797a7336261192e02d5d9351:
 
     License:    GPLv2+
     URL:        https://someurl.org
+    VCS:        git+ssh://git@pagure.io/test-project.git#dadef2a8b9554e94797a7336261192e02d5d9351:
 
     Source: test-project-0.0.git.1.dadef2a.tar.gz
 
@@ -232,10 +232,10 @@ changelog into it as well. Let's view that final spec file:
     Version:    0.1
     Release:    1%{?dist}
     Summary:    This is a test package.
-    VCS:        git+ssh://git@pagure.io/test-project.git#dadef2a8b9554e94797a7336261192e02d5d9351:
 
     License:    GPLv2+
     URL:        https://someurl.org
+    VCS:        git+ssh://git@pagure.io/test-project.git#dadef2a8b9554e94797a7336261192e02d5d9351:
 
     Source: test-project-0.1.tar.gz
 

From 2ff256f0585f7fa53f967d9dcedf8e8566c602d1 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 20 2018 11:45:33 +0000
Subject: [PATCH 102/104] add spec template description into man pages


---

diff --git a/man/rpkg_man_page.py b/man/rpkg_man_page.py
index c947f92..c3c1f37 100644
--- a/man/rpkg_man_page.py
+++ b/man/rpkg_man_page.py
@@ -42,17 +42,38 @@ rpkg \\- RPM packaging utility
 .B "\\-\\-help"
 .SH "DESCRIPTION"
 .B "rpkg"
-is a script to manage spec-enriched Git repositories - meaning any repository which contains
-an rpm spec file describing properties of an rpm package. It is designed to work with expanded
-sources as well as with tarballs and patches. Note that you should trust the .spec files
-you work with because many operations (like `rpkg srpm`, `rpkg lint`) involve parsing the
-spec file, which brings along evalution of any shell or lua scriplets present in it.
+is a script to manage spec-enriched Git repositories - meaning any repositories which contain
+an rpm spec file. It is designed to work with expanded application sources as well as with standard DistGit
+tarballs and patches. Note that you should trust the .spec files you work with because many operations
+(like `rpkg srpm` or `rpkg lint`) involve parsing the spec file, which brings along evaluation
+of any shell or lua scriplets present in it.
 """
 
 man_footer = """\
+.SH "CONFIGURATION"
+
+rpkg reads configuration options from the following files in this order:
+
+    /etc/rpkg.conf, ~/.config/rpkg, ./rpkg.conf
+
+Configuration found in ./rpkg.conf has the highest priority.
+
+.SS "EXAMPLE CONFIGURATION"
+
+    [rpkg]
+    preprocess_spec = True
+    # auto-packing is deprecated:
+    auto_pack = False
+
+    [dist-git]
+    lookaside = https://src.fedoraproject.org/repo/pkgs/%(ns1)s/%(pkg)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s
+    lookaside_cgi = https://src.fedoraproject.org/repo/pkgs/upload.cgi
+    gitbaseurl = ssh://%(user)s@pkgs.fedoraproject.org/%(module)s
+    anongiturl = https://src.fedoraproject.org/%(module)s
+
 .SH "EXAMPLES"
 
-    Run %prep phase of an rpm build:
+Run %prep phase of an rpm build:
 
     $ rpkg prep
     Wrote: /tmp/rpkg/rpkg-util.spec
@@ -69,11 +90,11 @@ man_footer = """\
     + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
     + exit 0
 
-    For the following command, you need to have a project in COPR created. See quick tutorial at
+For the following command, you need to have a project in COPR created. See quick tutorial at
 
-    https://docs.pagure.org/copr.copr/user_documentation.html#quick-start
+https://docs.pagure.org/copr.copr/user_documentation.html#quick-start
 
-    on how to do it.
+on how to do it.
 
     $ rpkg copr-build @releng/rpkg-util
     git_pack: Wrote: /tmp/rpkg/rpkg-util-1.0.git.122.e59a5b11.tar.gz
@@ -87,10 +108,297 @@ man_footer = """\
     Watching build(s): (this may be safely interrupted)
       15:50:12 Build 724892: importing ...
 
+Here you can see a simple operation of generation spec file from a template:
+
+    $ rpkg spec
+    git_pack: Wrote: /tmp/rpkg/rpkg-util.spec
+
+.SH "SPEC TEMPLATES"
+
+Apart from being useful as a means to handle unpacked as well as packed content,
+they also make it possible to generate certain parts of your spec file automatically
+from a Git repository where your spec file is located. You need to have "spec_preprocess"
+configuration option set to True in rpkg config to use this functionality.
+
+.SS "BASIC EXAMPLE"
+
+    Name:       {{{ git_name }}}
+    Version:    {{{ git_version }}}
+    Release:    1%{?dist}
+    Summary:    This is a test package.
+
+    License:    GPLv2+
+    URL:        https://someurl.org
+    VCS:        {{{ git_vcs }}}
+
+    Source:     {{{ git_pack }}}
+
+    %description
+    This is a test package.
+
+    %prep
+    {{{ git_setup_macro }}}
+
+    %changelog
+    {{{ git_changelog }}}
+
+Having a spec template like this in your project (instead of just a plain spec file)
+allows you to build source and rpm packages automatically following git history of your project.
+
+.SS "MACRO REFERENCE"
+
+.TP
+
+BASE GIT MACROS
+
+Without any parameters, these macros work on repository level and use globally available repository information.
+Output of every git macro call is cached and other macros are made to take those cached values into account by default.
+You can see that a macro uses a cached value as a default input parameter value by looking at its function header definition and searching for the `cached` keyword.
+
+E.g.
+
+    git_version [name="$(cached git_name)"] [lead=0] [follow=]
+
+Default value for name in this definition is derived from the cached output of the
+previously invoked `git_name` macro. If `git_name` macro has not been invoked
+or if its output was an empty string, the default value for the `name=` parameter
+above will be also an empty string.
+
+Note that $(cached_name_version) in the function header definitions below
+is an alias for "$(cached git_name)-$(cached git_version)".
+
+.B git_name [name=] [prepend=] [append=]
+
+Without any parameters, output the "origin" URL basename with .git suffix stripped.
+
+    Optional arguments:
+        name     the base name to be output
+        prepend  string to be prepended to the base name
+        append   string to be appended to the base name
+
+.B git_version [name="$(cached git_name)"] [lead=0] [follow=]
+
+Output version of a subpackage given by ${name}. The version
+is a string constructed of the following parts:
+
+    "${lead}.${follow}${commit_count_appendix}${wtree_appendix}"
+
+${lead} is a mandatory argument of the macro. By default it is set
+to zero.
+
+${follow} (if not specified) is obtained from the follow part of
+the latest tag made for the subpackage given by ${name}.
+
+${commit_count_appendix} is generated only if the current commit
+is not tagged for the given subpackage and it is composed of the
+following parts
+
+    .git.<commit_count>.<latest_commit_short_hash>
+
+Commit count is a number of commits from the latest tag on the
+given subpackage.
+
+${wtree_appendix} is generated only if the currently checked
+out working tree is dirty. It is composed of the following parts:
+
+    .wtree.<encoded_latest_file_status_change>
+
+    Optional arguments:
+        name     name of a subpackage
+        lead     major version substring
+        follow   minor version substring, dynamically generated if not specified
+
+    Environment variables:
+        VERSION_BUMP: if set to a non-empty value, the following procedure is applied
+        to get the version string:
+
+        If $follow is specified by user explicitly, return $lead.$follow.
+
+        Otherwise, extract $follow from the latest tag as the last version component (after the last dot)
+        and return $lead.$follow+1. If $follow is not a number, throw an error (manual setting of follow
+        is needed).
+
+        rpkg sets the VERSION_BUMP variable into the preprocessing environment during
+        execution of `rpkg tag` subcommand. Otherwise, it is unset.
+
+.B git_vcs [subtree=]
+
+Output pseudo repository URL pointing the currently checked out tree.
+
+Example output: git+ssh://git@pagure.io/test-project.git#dadef2a8b9554e94797a7336261192e02d5d9351:
+
+    Optional arguments:
+        subtree     path to a subtree to generate the URL for
+
+.B git_pack [path="$(git rev-parse --show-toplevel)"] [dir_name="$(cached_name_version)"] [source_name="$(cached_name_version).tar.gz"]
+
+Pack the whole working tree content into a gzipped source tarball and output $source_name, which is a filename of the created tarball.
+Uses `tar caf --exclude-vcs --exclude-vcs-ignores` to do the job.
+
+    Optional arguments:
+        path         path to a specific subdirectory to be packed
+        dir_name     top-level directory name in the created tarball
+        source_name  filename of the created source tarball
+
+    Enviroment variables:
+        OUTDIR: if empty, git_pack will not generate any sources, only outputs the source filename
+
+        rpkg sets OUTDIR, only if the tarball is actually needed to be generated. It does not set it
+        when `rpkg spec` is called (without any additional arguments).
+
+.B git_archive [path="$(git rev-parse --show-toplevel)"] [dir_name="$(cached_name_version)"] [source_name="$(cached_name_version).tar.gz"]
+
+Pack the whole working tree content into a gzipped source tarball and output $source_name, which is a filename of the created tarball.
+Uses `git archive` to do the job. Note that this macro will refuse to generate a tarball if your working tree is dirty.
+
+    Optional arguments:
+        path         path to a specific subdirectory to be packed
+        dir_name     top-level directory name in the created tarball
+        source_name  filename of the created source tarball
+
+    Enviroment variables:
+        OUTDIR: if empty, git_pack will not generate any sources, only outputs the source filename
+
+        rpkg sets OUTDIR, only if the tarball is actually needed to be generated. It does not set it
+        when `rpkg spec` is called (without any additional arguments).
+
+.B git_setup_macro [dir_name="$(cached_name_version)"]
+
+Output %setup rpm macro for the given top-level source-tarball directory.
+
+    Optional arguments:
+        dir_name     name of the top-level directory in the source-tarball
+
+.B git_changelog [name="$(cached git_name)"] [since_tag=] [until_tag=] [header_locale=POSIX] [header_date_format="%a %b %d %Y"] [body_wrap=80]
+
+Output rpm spec changelog as generated from tag messages for the subpackage given by ${name}.
+
+    Optional arguments:
+        name                name of the subpackage to generate the ehangelog for
+        since_tag           start the changelog records with this tag
+        until_tag           end the changelog records with this tag
+        header_locale       locale to be used when changelog record date is being generated
+        header_date_format  date format to be used in the changelog record headers
+        body_wrap           maximum allowed line length for changelog body
+
+When `rpkg tag` is called, it allows you to specify a tag message. This is the message
+that will be used as a changelog record body.
+
+.TP
+
+GIT_DIR MACROS
+
+These macros operate on a directory level. In particular, on a directory where the input spec file template is located. They are basically
+aliases to the GIT BASE MACROS with some input values set specifically for the directory-level operation. The input spec template location is
+given by INPUT_PATH environment variable set by rpkg. You can influence it from the command line by explicitly specifying --spec <template_path>
+argument for rpkg subcommands that support it.
+
+Below you can see to what the GIT DIR macros expand. In some cases, the macro is a direct alias to the underlying git base macro.
+
+.B git_dir_name
+
+    git_name append="-$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix | name_convert)"
+
+    Outputs repository origin URL basename appended with the path (after slash to dash substitution) from the repository
+    root to the spec file's directory.
+
+.B git_dir_version
+
+    git_version
+
+.B git_dir_vcs
+
+    git_vcs subtree="$(git -C "$(dirname "$INPUT_PATH")" rev-parse --show-prefix)"
+
+    Outputs VCS pseudo URL pointing to the spec file's subdirectory.
+
+.B git_dir_pack
+
+    git_pack path="$(dirname "$INPUT_PATH")"
+
+    Packs spec file's subdirectory by using `tar`.
+
+.B git_dir_archive
+
+    git_archive path="$(dirname "$INPUT_PATH")"
+
+    Packs spec file's subdirectory by using `git archive`.
+
+.B git_dir_setup_macro
+
+    git_setup_macro
+
+.B git_dir_changelog
+
+    git_changelog
+
+.TP
+
+GIT_CWD MACROS
+
+These macros operate on a directory level. In particular, on a rpkg's working directory. Again, they are
+aliases to the GIT BASE MACROS with some input values set specifically for the directory-level operation.
+
+You can influence the rpkg's working dir from the command line by explicitly specifying its --path argument.
+
+Below you can see to what the GIT_CWD macros expand. In some cases, the macro is a direct alias for the underlying git base macro.
+
+.B git_cwd_name
+
+    git_name append="-$(git -C "$(pwd)" rev-parse --show-prefix | name_convert)"
+
+    Outputs repository origin URL basename appended with the rpkg's working directory path (after slash to dash substitution).
+
+.B git_cwd_version
+
+    git_version
+
+.B git_cwd_vcs
+
+    git_vcs subtree="$(git -C "$(pwd)" rev-parse --show-prefix)"
+
+    Outputs VCS pseudo URL pointing to the rpkg's working directory.
+
+.B git_cwd_pack
+
+    git_pack path="$(pwd)"
+
+    Packs rpkg's working directory by using `tar`.
+
+.B git_cwd_archive
+
+    git_archive path="$(pwd)"
+
+    Packs rpkg's working directory by using `git archive`.
+
+.B git_cwd_setup_macro
+
+    git_setup_macro
+
+.B git_cwd_changelog
+
+    git_changelog
+
+.SH USER-DEFINED MACROS
+
+You can define your own macros (basically just bash functions) by putting them
+into rpkg.macros file in rpkg's working directory. You can even override the
+default macros provided by rpkg.
+
+.SH AUTO-PACKING (DEPRECATED)
+
+Auto-packing works only if auto_pack configuration option is set to True and
+only if the content you are working with is not packed (see `rpkg is-packed`).
+
+When invoking `rpkg srpm` on an unpacked content, rpkg will download external sources
+(if any) and then it will generate a tarball from the whole content of the working
+directory named according to Source0 definition present in the associated .spec file.
+This tarball and the .spec file are then passed to rpmbuild to generate the resulting
+srpm.
 
 .SH "PACKED VS UNPACKED"
 
-NOTE: This article related to deprecated auto_pack feature. You can safely ignore it.
+NOTE: This article relates to deprecated auto_pack feature. You can safely ignore it.
 
 While it is quite intuitive what is packed content (.spec + tarballs + patches)
 and what is unpacked content (.spec + original application source files), it
@@ -235,8 +543,6 @@ def generate(parser, subparsers):
 
     for command in k:
         cmdparser = choices[command]
-        if not cmdparser.add_help:
-            continue
         usage = cmdparser.format_usage()
         usage = strip_usage(usage)
         usage = ''.join(usage.split('\n'))
@@ -249,8 +555,6 @@ def generate(parser, subparsers):
     man_file.write('.SH "COMMAND REFERENCE"\n')
     for command in k:
         cmdparser = choices[command]
-        if not cmdparser.add_help:
-            continue
 
         man_file.write('.SS "%s"\n' % cmdparser.prog)
 
diff --git a/rpkglib/cli.py b/rpkglib/cli.py
index 68b7bcb..b77d9cb 100644
--- a/rpkglib/cli.py
+++ b/rpkglib/cli.py
@@ -226,7 +226,7 @@ class rpkgClient(cliClient):
             'content of the current working directory '
             'after downloading any external sources. '
             'The content must be of unpacked type.',
-            description='Puts content of the current '
+            description='Deprecated. Puts content of the current '
             'working directory into a gzip-compressed archive named '
             'according to Source0 filename as specfied in the .spec file. '
             'The content must be of unpacked type, otherwise no action is taken. '
@@ -260,7 +260,7 @@ class rpkgClient(cliClient):
         """Determine whether the package content is packed or not"""
         is_packed_parser = self.subparsers.add_parser(
             name='is-packed', help='Deprecated. Tell user whether content is packed',
-            description='Determine whether the package content '
+            description='Deprecated. Determine whether the package content '
             'in the working directory is packed or unpacked '
             'and print that information to the screen.')
         is_packed_parser.set_defaults(command=self.is_packed)

From 394ad3f11dd9f51215bbfa2d57dd621d929f0a85 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 20 2018 11:50:19 +0000
Subject: [PATCH 103/104] fix typo


---

diff --git a/rpkg-util.spec.rpkg b/rpkg-util.spec.rpkg
index 9cda3f4..0a4404c 100644
--- a/rpkg-util.spec.rpkg
+++ b/rpkg-util.spec.rpkg
@@ -17,7 +17,7 @@ exists package https://src.fedoraproject.org/rpms/rpkg. That package,
 however, does not actually produce rpkg rpm whereas rpkg-client does.
 
 %package -n rpkg
-Summary: RPM packaging utitility
+Summary: RPM packaging utility
 BuildArch: noarch
 
 BuildRequires: python2

From 273d0d3e7855e516c5ca2b223cb4f17834843708 Mon Sep 17 00:00:00 2001
From: clime <clime@redhat.com>
Date: Mar 20 2018 12:04:54 +0000
Subject: [PATCH 104/104] fix setup.py


---

diff --git a/setup.py b/setup.py
index cd19740..b152a38 100755
--- a/setup.py
+++ b/setup.py
@@ -4,17 +4,14 @@ import rpm
 import subprocess
 from setuptools import setup, find_packages
 
-subprocess.call(['rpkg', 'spec'])
-spec_file = rpm.ts().parseSpec('/tmp/rpkg/rpkg-client.spec')
-
 setup(
-    name=spec_file.sourceHeader.name.decode("utf-8"),
-    version=spec_file.sourceHeader.version.decode("utf-8"),
-    description=spec_file.sourceHeader.summary.decode("utf-8"),
-    long_description=spec_file.sourceHeader.description.decode("utf-8"),
+    name="rpkg",
+    version="1.0",
+    description="RPM packaging utility",
+    long_description="A tool to manage spec-enriched Git repositories.",
     author='clime',
     author_email='clime@redhat.com',
-    download_url='https://pagure.io/rpkg-client.git',
+    download_url='https://pagure.io/rpkg-util.git',
     license='GPLv2+',
     classifiers=[
         "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",

