git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: which git commands is correponding to "svnlook diff -t" and "svnlook log -t"?

From
JHJan Hudec <bulb@ucw.cz>
Date
Nov 11, 2010, 08:47 UTC
Message-ID
<20101111084723.GD30870@efreet.light.src>
In-Reply-To
<30111518.post@talk.nabble.com>
On Tue, Nov 02, 2010 at 00:03:31 -0700, samilkarahan wrote:
> I have developed pre-commit hook, but it only run for svn hook. 
> 
> I want to run it for git hook,But I don't know git well like svn ,so 

Git works fundamentally differently from subversion. It's not possible to give you good advice unless you explain what you want to do in the hook.

Where subversion has one commit operation to create the changeset and publish it, git has two operations. Commit to create it and push to publish it. Each comes with it's own set of hooks. Moreover the operations are done on different repositories, so they run hooks from different places!

Commit has 'pre-commit', 'prepare-commit-msg', 'commit-msg' and 'post-commit' run on the developers local repositories, where they must be manually installed and can be easily disabled (with --no-verify option to commit). The prepare-commit-msg gives you some extra flexibility in that you can prepare template of the commit message here.

Push has 'pre-receive', 'update', 'post-receive' and 'post-update' run on the central repository and there is no way around them. It is, however, kind of late. The commits are already done, perhaps even for quite a long time, so if they are rejected, developers will have to go back and amend them.

Remember, that multiple commits will be pushed at once, so you have to inspect all of them (git log $oldsha..$newsha), not just the latest.

> I haven't found corresponding git command to svn commands which are "svnlook
> diff -t"

Depends on which git hook you want that in. And that depends on what you want to do. For pre-commit hook, it's 'git diff --cached', for pre-receive or update hook you get the commit ID and inspect it with 'git log' and 'git show'.

> and "svnlook log -t".

Again, depends on which git hook you want that in. And that depends on what you want to do. For pre-commit hook there is none, since it's called *before* the message is created. For commit-msg hook you get name of file with the message as argument (and you can edit it from there). For pre-receive hook or update hook you use 'git log' and 'git show' again.

> is there anybody know these git commands??

Everybody knows them plus they are quite obvious from the documentation (man git-hooks) and the samples (installed by 'git init' in every repository). But nobody knows the subversion commands and there is no simple mapping anyway.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Previous: Mathias Lafeldt
Message 4 of 4 in “which git commands is correponding to "svnlook diff -t" and "svnlook log -t"?”
  1. samilkarahanNov 2, 2010
  2. Matthieu MoyNov 2, 2010
  3. Mathias LafeldtNov 2, 2010
  4. Jan HudecNov 11, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.