Git-subtree for cookbook management?

Dear Chefs,

the git subtree command was featured on Hacker News today as it was just
merged into git master.

On the surface, it looks like it might be a good tool for managing the
cookbooks that you are actively working on. As discussed at least in other
forums, librarian-chef is an excellent way to “vendor” the cookbooks that
you took from external sources and do not actively work on yourself.
However, librarian is not intended to manage cookbooks you actively work
on. Git subtree might be a good tool for doing this. Anyone have any
experience working w/ it?


http://help.github.com/subtree-merge/

On Fri, May 4, 2012 at 12:43 PM, Bryan Berry bryan.berry@gmail.com wrote:

Dear Chefs,

the git subtree command was featured on Hacker News today as it was just
merged into git master.

On the surface, it looks like it might be a good tool for managing the
cookbooks that you are actively working on. As discussed at least in other
forums, librarian-chef is an excellent way to "vendor" the cookbooks that
you took from external sources and do not actively work on yourself.
However, librarian is not intended to manage cookbooks you actively work on.
Git subtree might be a good tool for doing this. Anyone have any experience
working w/ it?

I did use it time ago (when it wasn't yet into Git master) for split
cookbooks from the old Opscode's Github repo for cookbooks. It made
the work a lot easier.
I'm actually not very fan of Librarian, but I don't really see how
git-subtree is different/better of git-submodules for working on
cookbook development.
Could you explain where you see the difference?

Thanks for the info, btw :slight_smile:

--
Juanje

That’s great to hear it’s been merged into git because it seems to be much
more useful and flexible than submodules. I’ve even used it a little to
extract some of my cookbooks from a chef-repo.

The second link you gave however is not related to the same project. It is
related to “subtree merge” which is different. The recently merged
"subtree" command’s README indicates that it should not be confused with
"submodules" or the “subtree merge” strategies.

I may misunderstand Librarian’s intended use but I’m very pleased with it’s
ability to handle cookbooks I modify whether they are personal cookbooks or
vendor cookbooks. I use Librarian’s “:path” parameter to include cookbooks
I’m working on. I use Librarian’s “:git” parameter to include unmodified
personal or vendor cookbooks from a git server (typically github). Once
I’m done working on a cookbook I typically commit and push it to a git
server at which point I tell Librarian to pull it using “:git” instead of
":path". This makes it very easy and flexible for me to keep cookbooks
decoupled and separate from my git managed chef-repo. You can see an
example of my Librarian Cheffile here [1]. As you can see in the comments
I have separated my original cookbooks from modified vendor cookbooks and
unmodified vendor cookbooks.

[1] https://github.com/jeremiahsnapp/chef-repo/blob/example/Cheffile

Sorry, my last email mentioned git subtree’s README but I was wrong.
Please refer to it’s git-subtree.txt [1] file instead.

An article mentioning git subtree [2] mentions that a downside is having to
explicitly split changes to a sub-project out of the parent project.

“The downside is that all of your subproject files are present in the
parent repository, which means you’re giving up some of the reason for
originally splitting up your project repositories: having one canonical
repository for a given set of shared code. If someone makes a change to a
subproject, they can merge it with other changes locally, but they’d have
to explicitly split that change back out of their project if they wanted to
share it with projects.”

In fact that point is also made in git-subtree.txt [1].

“If the standalone library gets updated, you can automatically merge the
changes into your project; if you update the library inside your project,
you can “split” the changes back out again and merge them back into the
library project.”

[1] https://github.com/apenwarr/git-subtree/blob/master/git-subtree.txt
[2]
http://codingkilledthecat.wordpress.com/2012/04/28/why-your-company-shouldnt-use-git-submodules/

apparently, I have misunderstood the :path attribute until now, thanks for
clarifying Jeremiah!

On Fri, May 4, 2012 at 2:53 PM, Jeremiah Snapp jeremiah.snapp@gmail.comwrote:

That's great to hear it's been merged into git because it seems to be much
more useful and flexible than submodules. I've even used it a little to
extract some of my cookbooks from a chef-repo.

The second link you gave however is not related to the same project. It
is related to "subtree merge" which is different. The recently merged
"subtree" command's README indicates that it should not be confused with
"submodules" or the "subtree merge" strategies.

I may misunderstand Librarian's intended use but I'm very pleased with
it's ability to handle cookbooks I modify whether they are personal
cookbooks or vendor cookbooks. I use Librarian's ":path" parameter to
include cookbooks I'm working on. I use Librarian's ":git" parameter to
include unmodified personal or vendor cookbooks from a git server
(typically github). Once I'm done working on a cookbook I typically commit
and push it to a git server at which point I tell Librarian to pull it
using ":git" instead of ":path". This makes it very easy and flexible for
me to keep cookbooks decoupled and separate from my git managed chef-repo.
You can see an example of my Librarian Cheffile here [1]. As you can see
in the comments I have separated my original cookbooks from modified vendor
cookbooks and unmodified vendor cookbooks.

[1] chef-repo/Cheffile at example · jeremiahsnapp/chef-repo · GitHub