Skip to content

gitweb: Dealing with being on unborn branch

Jakub Narebski git 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 5 repliesIn review
  2. v11 patch 1 replySuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3gitweb: Deal with HEAD pointing to unborn branch in "heads" viewgitweb/gitweb.perl t/t9500-gitweb-standalone-no-errors.sh+11 -25 replies
2/3gitweb: Harden parse_commit and parse_commitsgitweb/gitweb.perl+6 -10 replies
3/3gitweb: Silence stderr in parse_commit*() subroutinesgitweb/gitweb.perl+6 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

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

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(-)
Signature · 1 line
1.7.9