]> git.ipfire.org Git - thirdparty/git.git/commit - apply.c
convert: permit passing additional metadata to filter processes
authorbrian m. carlson <bk2204@github.com>
Mon, 16 Mar 2020 18:05:02 +0000 (18:05 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Mar 2020 18:37:02 +0000 (11:37 -0700)
commitab90ecae992e44e3e8303f143ad858608acabcf5
tree70956e3f2cd7b14b35bc0ef26c72475b27550bea
parenta8604766de8136d78944053aadd74a8c1c87aea9
convert: permit passing additional metadata to filter processes

There are a variety of situations where a filter process can make use of
some additional metadata.  For example, some people find the ident
filter too limiting and would like to include the commit or the branch
in their smudged files.  This information isn't available during
checkout as HEAD hasn't been updated at that point, and it wouldn't be
available in archives either.

Let's add a way to pass this metadata down to the filter.  We pass the
blob we're operating on, the treeish (preferring the commit over the
tree if one exists), and the ref we're operating on.  Note that we won't
pass this information in all cases, such as when renormalizing or when
we're performing diffs, since it doesn't make sense in those cases.

The data we currently get from the filter process looks like the
following:

  command=smudge
  pathname=git.c
  0000

With this change, we'll get data more like this:

  command=smudge
  pathname=git.c
  refname=refs/tags/v2.25.1
  treeish=c522f061d551c9bb8684a7c3859b2ece4499b56b
  blob=7be7ad34bd053884ec48923706e70c81719a8660
  0000

There are a couple things to note about this approach.  For operations
like checkout, treeish will always be a commit, since we cannot check
out individual trees, but for other operations, like archive, we can end
up operating on only a particular tree, so we'll provide only a tree as
the treeish.  Similar comments apply for refname, since there are a
variety of cases in which we won't have a ref.

This commit wires up the code to print this information, but doesn't
pass any of it at this point.  In a future commit, we'll have various
code paths pass the actual useful data down.

Signed-off-by: brian m. carlson <bk2204@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
archive.c
builtin/cat-file.c
convert.c
convert.h
diff.c
entry.c
merge-recursive.c