I have a bare repo that developers push their hotfix branches to from their local repo on Windows. When the branch is pushed I trigger a hook to build their changes on Linux. This is easy to do if I create a working-tree for the branch. However, the repo contains 10's of thousands of files and having each developer's hotfix branch create a working-tree for all objects when they are only committing a change to a few is a huge time-sink and drain on the file system.
Is there a way to let the developers push to the bare repo and then in a hook extract only the changed sources to a directory structure so I can have an efficient build process?
Ideas?
Example developer_a pushes his HF1 branch that was branched off the Dev branch back to the remote bare repo on the Linux build server.
In the hook if I perform a "git diff" of the HF1 and the dev branch I can see the list of files that were changed.
diff-tree -r --no-commit-id --name-only HF1..dev
/APP/SOURCE/Program1.cbl
Any attempt to use that file on the above command fails because the working tree does not exist.
I'd like to generate this diff and then extract directly from the repo the files listed in the diff to a target directory.
That sounds like what Git is already doing natively when it checks out a branch in a working tree already set to a given commit.
If your building working tree is at a certain commit, the hook can trigger a git checkout of the new SHA1 pushed: the working tree will detect changes and updates itself (through a git checkout triggered by the post-receive hook) to update only what is needed.