summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorbrian m. carlson <bk2204@github.com>2020-03-16 18:05:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-03-16 18:37:02 (GMT)
commitab90ecae992e44e3e8303f143ad858608acabcf5 (patch)
tree70956e3f2cd7b14b35bc0ef26c72475b27550bea /diff.c
parenta8604766de8136d78944053aadd74a8c1c87aea9 (diff)
downloadgit-ab90ecae992e44e3e8303f143ad858608acabcf5.zip
git-ab90ecae992e44e3e8303f143ad858608acabcf5.tar.gz
git-ab90ecae992e44e3e8303f143ad858608acabcf5.tar.bz2
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>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index f2cfbf2..12761c8 100644
--- a/diff.c
+++ b/diff.c
@@ -4071,7 +4071,7 @@ static void prep_temp_blob(struct index_state *istate,
if (!temp->tempfile)
die_errno("unable to create temp-file");
if (convert_to_working_tree(istate, path,
- (const char *)blob, (size_t)size, &buf)) {
+ (const char *)blob, (size_t)size, &buf, NULL)) {
blob = buf.buf;
size = buf.len;
}