Re: A shortcoming of the git repo format
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Apr 27, 2005, 19:15 UTC
- Message-ID
- <Pine.LNX.4.58.0504271212460.18901@ppc970.osdl.org>
- In-Reply-To
- <20050427183239.GE19011@redhat.com>
On Wed, 27 Apr 2005, Dave Jones wrote:
Show 6 quoted lines
> > That actually broke one of my first git scripts when one of the > changelog texts started a line with 'tree '. I hacked around it > by making my script only grep in the 'head -n4' lines, but this > seems somewhat fragile having to make assumptions that the field > I want to see is in the first 4 lines.
It's not an assumption.
IT'S THE LAW.
The speed of light is not "an assumption". It is.
The tree is in the first line of a commit. You don't even need to parse it, you do
tree=$(cat-file commit $head | sed 's/tree //;q')
and that's it. No parsing.
Git doesn't guess. Git knows.
Linus