{"thread":{"id":"16377","subject":"git tree browsing in redmine","startedAt":"2008-11-18T04:34:25Z","lastAt":"2008-11-18T10:06:19Z","messageCount":3,"participants":["Burt Culver","Andreas Ericsson","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"96072","messageId":"b8f2e1780811172034w6828ddc8n62cf85b5fa366e22@mail.gmail.com","threadId":"16377","inReplyTo":null,"subject":"git tree browsing in redmine","fromName":"Burt Culver","fromEmail":"burt@fishpond.co.nz","sentAt":"2008-11-18T04:34:25Z","receivedAt":"2008-11-18T04:34:25Z","isPatch":false,"sender":{"key":"burt@fishpond.co.nz","avatar":null},"body":"Hi,\n\nI'm trying to find some ideas for a better way to implement browsing\nof a git repository within the redmine application.\n\nMy top level directory in my git repository has 300 files. Redmine\nwants to display each file name, its most recent revision, and the\ncomment for that revision. Currently it does a git log -1 on each file\nto find the latest revision.  Is there a quicker way of doing this for\na whole directory?  git log runs from .2 seconds to 3 seconds\ndepending on the file on my server.\n\nHere is the open issue at redmine.org which has more details:\nhttp://www.redmine.org/issues/show/1435\n\nA fix for this would help a whole bunch of redmine / git users including myself.\n\n-- \nRegards,\n\nBurt Culver\nFishpond.co.nz & Fishpond.com.au\nNew Zealand & Australias Biggest Bookstore\n"},{"id":"96076","messageId":"49227679.7010709@op5.se","threadId":"16377","inReplyTo":"b8f2e1780811172034w6828ddc8n62cf85b5fa366e22@mail.gmail.com","subject":"Re: git tree browsing in redmine","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-11-18T08:02:01Z","receivedAt":"2008-11-18T08:02:01Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Burt Culver wrote:\n> Hi,\n> \n> I'm trying to find some ideas for a better way to implement browsing\n> of a git repository within the redmine application.\n> \n> My top level directory in my git repository has 300 files. Redmine\n> wants to display each file name, its most recent revision, and the\n> comment for that revision. Currently it does a git log -1 on each file\n> to find the latest revision.  Is there a quicker way of doing this for\n> a whole directory?\n\nNot yet, but if you clone libgit2 and start helping out on that, things\nlike this will become fairly trivial to do in a single pass instead of,\nas redmine does it today, using one call to \"git log\" for every file in\nthe directory (which is just insane).\n\nYou should be aware that git is fully snapshot based though, while svn\nis file-revision based (a bunch of file-revisions make up a \"changeset\"),\nso it's fundamentally easy to get the file-revisions for a particular\nchangeset in svn and fundamentally hard to get it in git.\n\n>  git log runs from .2 seconds to 3 seconds\n> depending on the file on my server.\n> \n\nThat's because the command used by redmine (\"git log <cruft> -1 -- $path\")\nstops as soon as it finds the first commit that touches the path. Some\npaths haven't been touched in a long time, so more revisions have to\nbe loaded, parsed, analyzed and discarded before the correct one is\nfound.\n\n> Here is the open issue at redmine.org which has more details:\n> http://www.redmine.org/issues/show/1435\n> \n> A fix for this would help a whole bunch of redmine / git users including myself.\n> \n\nI have no idea what redmine is, but one solution for them would be to\nrun \"git log --pretty=fuller -p $branch\" and then parse the diffs to get\nthe latest commit that touched all files (in one go). This would be\nslightly slower for small repos (where it shouldn't matter anyway), but\ntime should increase linearly with the number of commits in the repository.\nIt's almost certainly required to be able to turn this feature off, btw,\nas it won't work at all for super-huge repositories (think kde or OO.org).\n\nYou should also make sure to have your repository properly packed. Run\n\"git gc\" on it every once in a while.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"96079","messageId":"m3ej19l57c.fsf@localhost.localdomain","threadId":"16377","inReplyTo":"b8f2e1780811172034w6828ddc8n62cf85b5fa366e22@mail.gmail.com","subject":"Re: git tree browsing in redmine","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-11-18T10:06:19Z","receivedAt":"2008-11-18T10:06:19Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Burt Culver\" <burt@fishpond.co.nz> writes:\n\n> I'm trying to find some ideas for a better way to implement browsing\n> of a git repository within the redmine application.\n> \n> My top level directory in my git repository has 300 files. Redmine\n> wants to display each file name, its most recent revision, and the\n> comment for that revision. Currently it does a git log -1 on each file\n> to find the latest revision.  Is there a quicker way of doing this for\n> a whole directory?  git log runs from .2 seconds to 3 seconds\n> depending on the file on my server.\n> \n> Here is the open issue at redmine.org which has more details:\n> http://www.redmine.org/issues/show/1435\n> \n> A fix for this would help a whole bunch of redmine / git users\n> including myself.\n\nFirst, while it might be common and cheap view (information) for\nSubversion, it is not the case for Git.  Git is whole project snapshot\nbased, not per-file snapshot based, or patch based.  Take a look at\none of git web interfaces: gitweb, or cgit, or ViewGit to see how\nrepository browsing is implemented there: it is log-like view, then\ntree, not tree, then history of files.  Note also that for example\nhistory of two files is more than union of histories of individual\nfiles (history simplification, including merge simplification).\n\nSecond, I tried to implement such view (which I named 'tree blame'\nview, because it looks a bit like blame/annotate, but for\ndirectories/trees) for gitweb.  You can view my attempts in\n'gitweb/tree_blame' branch of my git fork:\n\n  http://repo.or.cz/w/git/jnareb-git.git?a=shortlog;h=refs/heads/gitweb/tree_blame\n\nBut I think the correct solution, if you decide that you absolutely\nneed so unnatural (and I think not that useful) view, would be to\nimplement such view in git core, allowing 'git blame' to work for\ntrees (directories).  You would probably need to implement also some\nkind of '--porcelain' output for script/Redmine.\n\nOr as suggested add your work to libgit2 library, and make use of it\nin Redmine...\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}