Sparse checkout with `git resource`

I want to checkout a single folder from my git repo (i.e. an sparse checkout), but I didn’t find an option to do it with with the git resource.
So I’m thinking of modifying the resource’s source code to add this option, but first I wanted to confirm there is not already a way this can be accomplished.

I also found this other topic, and the fact this person didn’t get an answer makes me think there is no solution at the moment, so the feature is required.

Why we need this?

Sometimes we need only a file or small directory that lies in a big repository. Doing a shallow clone (depth=1) doesn’t solve the problem because it still clones all of the files in the tip of the branch.

The way we accomplish this with plain git is by issuing these commands:

git init <my_repo>
cd <my_repo>
git remote add origin <my_repos_url>
git config core.sparsecheckout true
echo “my_directory/*” >> .git/info/sparse-checkout
git pull --depth=1 origin master

Notice we cannot use a git resource here as we need to modify the .git/info/sparse-checkout file before the clone/pull is made.

Other possible solutions

There is are 2 workarounds I can think of, each one with its own problems:

We can use git archive in an execute resource. Git archive can be told to download only a single file or a single directory, and then we can uncompress the archive on the fly:

   git archive --remote=<repo_url> HEAD:<path/to/directory> filename | tar -x

The problem with that solution is that each time chef-client runs it will download the file/directory again, and adding a creates in the execute resource doesn’t help because then we won’t notice when the file/directory has changed in the remote repository. This new problem can be solved by having an additional execute resource that first executes git to query the latest version of the branch and then notifies a third git archive to download the files again, but then we need 2 execute resources for doing what we may expect to accomplish with a single git resource.

So my question is, am I overly complicating things and there is another way of doing this or indeed it would be useful to modify the git resource?