I'm looking for a feature or existing library within git to allow be to do some pretty unorthodox behavior described below.
Let's say you have a current working directory that has git initialized.
/project
/.git
A subprojects
folder with the folders alpha
and beta
within it are added, each having they're own initialized state. Two files alpha.txt
and beta.txt
are added to the root. Each is hard linked into their respective subproject folder.
Here's the commands used:
project$ touch alpha.txt
project$ touch beta.txt
project$ mkdir ./subprojects/alpha
project$ cd ./subprojects/alpha
subprojects/alpha$ git init
subprojects/alpha$ cd ../../
project$ mkdir ./subprojects/beta
project$ cd ./subprojects/beta
subprojects/beta$ git init
subprojects/beta$ cd ../../
project$ ln alpha.txt ./subprojects/alpha/alpha.txt
project$ ln beta.txt ./subprojects/beta/beta.txt
Here's a tree of the current working directory:
/project
/.git
/subprojects
/alpha
/.git
/alpha.txt
/beta
/.git
/beta.txt
/alpha.txt
/beta.txt
A commit is made on the root using these commands:
project$ git add -A
project$ git commit -m "init root"
The contents of the root alpha.txt
are changed and git status
is run you see this.
modified: alpha.txt
modified: subprojects/alpha/alpha.txt
You can see because both files are linked that when one is changed both are modified, this is good.
This is where the functionality I'd like comes into play. I'd like it so that when a root commit is made and when the contents of a subproject are modified, the subproject consumes that commit in it's local git instance.
So in the case where I modify alpha.txt
after init, I run the following:
project$ git add -A
project$ git commit -m "edited alpha"
Now when I run the following git log
within the root.
project$ git log --pretty=oneline
50144ab7da5466327038357bbc4f5adec85ed1d2 edited alpha
6f3f77763653f37e089fc0fe4c3ae6846f807855 init root
Currently the subpackages alpha
and beta
have never been committed to. So when a git log
is run it response with the following:
project/subproject/alpha$ git log --pretty=oneline
fatal: bad default revision 'HEAD'
The behavior I'd at this point in the timeline is that alphas
log read this:
project/subproject/alpha$ git log --pretty=oneline
50144ab7da5466327038357bbc4f5adec85ed1d2 edited alpha
6f3f77763653f37e089fc0fe4c3ae6846f807855 init root
And beta
's read this:
project/subproject/beta$ git log --pretty=oneline
6f3f77763653f37e089fc0fe4c3ae6846f807855 init root
The logic behind this is that because the at the time of the parent project
repositories commit the files within the subproject
were edited, and because we're using linking we can attribute it to the same commit
message as the parent.
Any thoughts on this how to do this? Is this clear?