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

Re: git tree browsing in redmine

From
Andreas Ericsson <ae@op5.se>
Date
Nov 18, 2008, 08:02 UTC
Message-ID
<49227679.7010709@op5.se>
In-Reply-To
<b8f2e1780811172034w6828ddc8n62cf85b5fa366e22@mail.gmail.com>
Burt Culver wrote:
Show 10 quoted lines
> Hi,
> 
> I'm trying to find some ideas for a better way to implement browsing
> of a git repository within the redmine application.
> 
> My top level directory in my git repository has 300 files. Redmine
> wants to display each file name, its most recent revision, and the
> comment for that revision. Currently it does a git log -1 on each file
> to find the latest revision.  Is there a quicker way of doing this for
> a whole directory?

Not yet, but if you clone libgit2 and start helping out on that, things like this will become fairly trivial to do in a single pass instead of, as redmine does it today, using one call to "git log" for every file in the directory (which is just insane).

You should be aware that git is fully snapshot based though, while svn is file-revision based (a bunch of file-revisions make up a "changeset"), so it's fundamentally easy to get the file-revisions for a particular changeset in svn and fundamentally hard to get it in git.

>  git log runs from .2 seconds to 3 seconds
> depending on the file on my server.
> 

That's because the command used by redmine ("git log <cruft> -1 -- $path") stops as soon as it finds the first commit that touches the path. Some paths haven't been touched in a long time, so more revisions have to be loaded, parsed, analyzed and discarded before the correct one is found.

Show 5 quoted lines
> Here is the open issue at redmine.org which has more details:
> http://www.redmine.org/issues/show/1435
> 
> A fix for this would help a whole bunch of redmine / git users including myself.
> 

I have no idea what redmine is, but one solution for them would be to run "git log --pretty=fuller -p $branch" and then parse the diffs to get the latest commit that touched all files (in one go). This would be slightly slower for small repos (where it shouldn't matter anyway), but time should increase linearly with the number of commits in the repository. It's almost certainly required to be able to turn this feature off, btw, as it won't work at all for super-huge repositories (think kde or OO.org).

You should also make sure to have your repository properly packed. Run "git gc" on it every once in a while.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Previous: Burt CulverNext: Jakub Narebski
Message 2 of 3 in “git tree browsing in redmine”
  1. Burt CulverNov 18, 2008
  2. Andreas EricssonNov 18, 2008
  3. Jakub NarebskiNov 18, 2008

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.