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

[PATCHv2 0/3] gitweb: Dealing with being on unborn branch

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 15, 2012, 15:36 UTC
Message-ID
<1329320203-20272-1-git-send-email-jnareb@gmail.com>

This is resend (as series) of patches that were sent first time individually in "Fwd: Git-web error" thread sent to git mailing list by rajesh boyapati:

  http://thread.gmane.org/gmane.comp.version-control.git/189228

Unfortunately the thread is heavily fragmented in GMane interface, because Rajesh responses were not sent to git mailing list.

The problem that original poster seen was caused by the fact that:

rb> For my git projects on gerrit, our main branch name is "base". rb> We don't have any code on "master" branch. [...] rb> [...] the HEAD file is pointing to "ref: refs/heads/master". rb> So, I think that's the reason for errors.

Some of errors might appear in the way Rajesh sees them because gitweb in this case is deployed from Gerrit (Git-based review board, in Java); at least I couldn't reproduce some of errors in exactly the same way as presented.

Note that there is no problem if repository is totally empty, without any valid branch. The problem is when HEAD doesn't point to the valid commit object, but there are other commits and branches.

Anyway beside not using 'master' branch, but not renaming it / repointing HEAD, such situation might happen when you have just created an orphan branch, but haven't made any commits on it yet.

Table of contents:
~~~~~~~~~~~~~~~~~~
* [PATCHv2 1/3] gitweb: Deal with HEAD pointing to unborn branch
  in "heads" view

This fixes a real issue, and is a true fix (for current way of generating "heads" view). Note that there is "heads" excerpt in "summary" view.

* [PATCHv2/RFC 2/3] gitweb: Harden parse_commit and parse_commits

Just add an early exit in the case of invalid parameters. Though if caller is passing undefined value for commit identifier, it would probably not deal correctly with parse_commit() returning undef, though it should deal correctly with parse_commits() returning empty list.

More of band-aid than a real fix.
* [RFC/PATCHv2 3/3] gitweb: Silence stderr in parse_commit*()
  subroutines

This adds an overhead of forking a shell, and possibility of code injection if our quote_command() is incorrect... and actually does not fix issue for the original poster, and is not a problem for ordinary (non-Gerrit) gitweb.

Shortlog:
~~~~~~~~~
Jakub Narebski (3):
  gitweb: Deal with HEAD pointing to unborn branch in "heads" view
  gitweb: Harden parse_commit and parse_commits
  gitweb: Silence stderr in parse_commit*() subroutines
Diffstat:
~~~~~~~~~
 gitweb/gitweb.perl                     |   21 ++++++++++++++-------
 t/t9500-gitweb-standalone-no-errors.sh |    9 +++++++++
 2 files changed, 23 insertions(+), 7 deletions(-)
-- 
1.7.9
Next: Jakub Narebski
Message 1 of 9 in “[PATCHv2 0/3] gitweb: Dealing with being on unborn branch”
  1. Jakub NarebskiFeb 15, 2012
  2. 1/3 gitweb: Deal with HEAD pointing to unborn branch in "heads" viewJakub Narebski, Feb 15, 2012
  3. Junio C HamanoFeb 16, 2012
  4. Jakub NarebskiFeb 16, 2012
  5. Junio C HamanoFeb 16, 2012
  6. Jakub NarebskiFeb 17, 2012
  7. Junio C HamanoFeb 17, 2012
  8. 2/3 gitweb: Harden parse_commit and parse_commitsJakub Narebski, Feb 15, 2012
  9. 3/3 gitweb: Silence stderr in parse_commit*() subroutinesJakub Narebski, Feb 15, 2012

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.