Re: [TopGit PATCH] pre-commit: check .top* files in the to-be-commited tree
- From
Bert Wesarg <bert.wesarg@googlemail.com>
- Date
- Jun 4, 2009, 21:29 UTC
- Message-ID
- <36ca99e90906041429o32dcc093sccaa2fba21fddd10@mail.gmail.com>
- In-Reply-To
- <20090604052716.GA24414@pengutronix.de>
2009/6/4 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hi Bert,
Hi Uwe,
Show 11 quoted lines
> > On Tue, Jun 02, 2009 at 10:40:38PM +0200, Bert Wesarg wrote: >> We currently check fo these files only in the working tree. But we should check >> what would be commited. We use write-tree to be able to utilize ls-tree and >> check the result. > <nitpick> I prefer not speaking about "us" in the commit log. Better > use passive voice. </nitpick> So what about: > > The pre-commit hook used to check that the working copy has the .top* > files. Instead of that assert that the tree that is about to be > commited has these files.
Yes, thats right, Your message is nice, you can use it for the commit.
Show 10 quoted lines
> >> +# I suspect this can't fail, but who knows >> +tree=$(git write-tree) || >> + die "Can't write tree" > Actually you don't need to write the tree. You can use: > > git cat-file -t :0:.topdeps > -> blob > > git cat-file blob :0:.topdeps | grep .
Hmm, not very nice:
$ git init Initialized empty Git repository in /home/bertw/tmp/has-file/.git/ $ touch .topdeps $ git add .topdeps $ git commit -m.topdeps [master (root-commit) 8193982] .topdeps 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 .topdeps $ git rm .topdeps rm '.topdeps' $ git cat-file -t :0:.topdeps fatal: Not a valid object name :0:.topdeps $ echo $? 128 $ git cat-file blob :0:.topdeps | grep . fatal: Not a valid object name :0:.topdeps $ echo $? 1
My proposal:
$ git ls-tree --long "$(git write-tree)" .topdeps $ echo $? 0
Here I know, that all git commands don't die(), they all succeed. The .topdeps file, I'm looking for, is not in the tree, i.e. empty output.
Bert
> Best regards > Uwe