aiaiai: add git-find-base utility for finding base commit from mbox
This patch adds a helper utility for git, git-find-base which works by
checking the index information provided by git-diff's output. It works
by parsing the mbox for diff lines, and extracting the index line. This
is the shortblob of the file in git's database that this patch
originally applied to.
The general flow of this perl tool is:
1) Extract all the files and base blob indexes that the patch modifies,
using a regular expression.
2) Run git log with all arguments directly passed through
3) For each commit returned by git log, check the ls-tree output for the
modified file. If any of them fail to match, then this patch cannot
apply cleanly to the commit.
4) print the sha1sum of the first commit which passes the check blobs
test.
This tool can be used to automatically determine if a commit can be
applied cleanly to a branch, and even detect which commit it should be
applied to. Various options passed to the log can change how much
detection it does.
If a patch series is applied, it will check each modification of a file,
and ensure that it could apply in sequence generating the final result.
This allows finding the first commit at which a series will apply. If a
series is not self-consistent, then git-find-base will fail to supply
the base commit, and may output errors regarding the nature of the
inconsistency.
The primary intention for this tool will be an example hook for aiaiai
which automatically detects which project a patch was originally based
on.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>