Commit Graph

412 Commits

Author SHA1 Message Date
Jakub Narebski
7f718e8b46 gitweb: Add charset info to "raw" output of 'text/plain' blobs
Earlier "blob_plain" view sent "charset=utf-8" only when gitweb
guessed the content type to be text by reading from it, and not when
the MIME type was obtained from /etc/mime.types, or when gitweb
couldn't guess mimetype and used $default_blob_plain_mimetype.

This fixes the bug by always add charset info from
$default_text_plain_charset (if it is defined) to "raw" (a=blob_plain)
output for 'text/plain' blobs.

Generating information for Content-Type: header got separated into
blob_contenttype() subroutine; adding charset info in a special case
was removed from blob_mimetype(), which now should return mimetype
only.

While at it cleanup code a bit: put subroutine parameter
initialization first, make error message more robust (when $file_name
is not defined) if more cryptic, remove unnecessary '"' around
variable ("$var" -> $var).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-04 15:05:01 -07:00
Jakub Narebski
f70dda250e gitweb: Fix "next" link on bottom of page
Fix search form generation to not modify $cgi->param(...)'s.

In git_header_html() we used to use $cgi->hidden(-name => "a") etc. to
generate hidden fields; unfortunately to use this form it is required
to modify $cgi->param("a") etc., which makes href(-replay,...) use
wrong replay values.  This for example made the "next" link on the
bottom of the page has a=search instead of a=$action, and thus fails to
get you to the next page.

Because in CGI the value of a hidden field is "sticky", there is no
way to modify it short of modifying $cgi->param(...).  Therefore it
got replaced by generating <input type="hidden" ...> element [semi]
directly.

Alternate solution would be for href(-replay,...) to use values saved
in global variables, such as $action etc., instead of (re)reading them
from $cgi->param($symbol).

The bad link was reported by Kai Blin through
  http://bugs.debian.org/481902

Reported-by: Kai Blin <kai.blin@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Tested-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-02 20:36:02 -07:00
Junio C Hamano
b71ce7f3f1 Merge 1.5.5.3 in 2008-05-27 22:34:19 -07:00
Lea Wiemann
1f684dc01c gitweb: only display "next" links in logs if there is a next page
There was a bug in the implementation of the "next" links in
format_paging_nav (for log and shortlog), which caused the next links
to always be displayed, even if there is no next page.  This fixes it.

Signed-off-by: Lea Wiemann <LeWiemann@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-27 22:27:30 -07:00
Anders Waldenborg
dee2775a29 gitweb: Convert string to internal form before chopping in chop_str
Fix chop_str not to cut in middle of utf8 multibyte chars. Without
this fix at least author name in short log may cut in middle of a
multibyte char. When the result comes to esc_html to_utf8 is called
again, which doesn't find valid utf8 and decodes using
$fallback_encoding making it even worse.

This also have the nice side effect that it actually tries to show the
first 10 _characters_, not the number of characters that happened to fit
into 10 bytes.

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-22 23:03:43 -07:00
Jakub Narebski
3562198b7d gitweb: Use feed link according to current view
Michael G. Noll said in comments to the "Switching my code repository from
Subversion (SVN) to git" article (http://tinyurl.com/37v67l) in his "My
digital moleskine" blog, that one of the things he is missing in gitweb
from SVN::Web is an RSS feed with news/information of the current view
(including RSS feed for single file or directory).

This is not exactly true, as since refactoring feed generation in af6feeb
(gitweb: Refactor feed generation, make output prettier, add Atom feed,
2006-11-19), gitweb can generate feeds (RSS or Atom) for history of a
given branch, history limited to a given directory, or history of a given
file.  Nevertheless this required handcrafting the URL to get wanted RSS
feed.

This commit makes gitweb select feed links in the HTML header and in
page footer depending on current view (action).  It is more elaborate,
and I guess more correct, than simple patch adding $hash ('h')
parameter to *all* URLs, including feed links, by Jean-Baptiste Quenot

  Subject: [PATCH] gitweb: Add hash parameter in feed URL when a hash
           is specified in the current request
  Message-ID: <ae63f8b50803211138y6355fd11pa64cda50a1f53011@mail.gmail.com>

If $hash ('h') or $hash_base ('hb') parameter is a branch name
(i.e. it starts with 'refs/heads/'; all generated URLs use this form
to discriminate between tags and heads), it is used in feed URLs; if
$file_name ('f') is defined, it is used in feed URLs.  Feed title is
set according to the kind of web feed: it is either 'log' for generic
feed, 'log of <branch>', 'history of <filename>' for generic history
(using implicit or explicit HEAD, i.e. current branch) or 'history of
<filename> on <branch>'.

There are special cases: 'heads' and 'forks' views should use OPML
providing list of available feeds; 'tags' probably also should use
OPML; there is no web feed equivalent to 'search' view.  Currently all
those cases fallback to (show) default feed.  Such feed link uses
"generic" class, and is shown in slightly lighter color for
distinction.

Currently feed can have but one starting point, and does not support
negative (exclude) commit arguments.  Therefore for now for *diff
views it is chosen that feed follow the "to" part: to-name, to-commit
for 'blobdiff', 'treediff' and 'commitdiff' views.

Generating parameters for href() for feed link was separated
(refactored) into get_feed_info() subroutine.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-26 17:48:48 -07:00
Junio C Hamano
bdb87afb4b Merge branch 'maint'
* maint:
  post-receive-email: fix accidental removal of a trailing space in signature line
  Escape project names before creating pathinfo URLs
  Escape project name in regexp
  bash: Add completion for git diff --base --ours --theirs
  diff-options.txt: document the new "--dirstat" option
2008-04-22 00:10:20 -07:00
martin f. krafft
85d17a123b Escape project names before creating pathinfo URLs
If a project name contains special URL characters like +, gitweb's links
break in subtle ways. The solution is to pass the project name through
esc_url() and using the return value.

Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-21 23:30:55 -07:00
martin f. krafft
bbd4c307fc Escape project name in regexp
The project name, when used in a regular expression, needs to be quoted
properly, so that stuff like '++' in the project name does not cause
Perl to barf.

Related info: http://bugs.debian.org/476076
This is a bug in Perl's CGI.pm, but fixing that exposed a similar bug in
gitweb.perl

Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-21 23:30:11 -07:00
Junio C Hamano
d9f39d9838 Merge branch 'maint'
* maint:
  gitweb: Fix 'history' view for deleted files with history
  Document that WebDAV doesn't need git on the server, and works over SSL
  git-remote: reject adding remotes with invalid names
  am: POSIX portability fix
2008-04-18 22:58:32 -07:00
Jakub Narebski
5634cf2476 gitweb: Fix 'history' view for deleted files with history
When asked for history of a file which is not present in given branch
("HEAD", i.e. current branch, or given by transient $hash_hase ('hb')
parameter), but is present deeper in the history (meaning that "git
rev-list --full-history $hash_base -- $file_name" is not empty), and
there is no $hash ('h') parameter set for a file, gitweb would spew
multiple of "Use of uninitialized value" warnings, and some links
would be missing.  This commit fixes this bug.

This bug occurs in the rare cases when "git log -- <path>" is empty
and "git log --full-history -- <path>" is not, or to be more exact in
the cases when full-history starts later than given branch.  It can
happen if you are using handcrafted gitwb URL, or if you follow
generic 'history' link or bookmark for a file which got deleted.

Gitweb tried to get file type ('tree', or 'blob', or even 'commit')
from the commit we start searching from (where the file was not
present), and not among found commits.  This was the cause of "Use of
uninitialized value" warnings.

This commit also add tests for such situation to t9500 test.

While we are it, return HTTP error if there is _no_ history; it means
that file or directory was not found (for given branch).  Also error
out if type of item could not be found: it should not happen now, but
better be sure.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-18 22:10:38 -07:00
Junio C Hamano
018465d998 Merge branch 'gp/gitweb'
* gp/gitweb:
  gitweb: fallback to system-wide config file (fixup)
  gitweb: fallback to system-wide config file if default config does not exist
2008-04-09 00:44:48 -07:00
Jakub Narebski
4ed4a34716 Revert "gitweb: Add 'status_str' to parse_difftree_raw_line output"
This reverts commit 6aa6f92fda.

It caused is_deleted() subroutine to output warnings when dealing with
old, legacy gitweb blobdiff URLs without either 'hb' or 'hpb'
parameters.

This fixes http://bugs.debian.org/469083

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-05 16:30:49 -07:00
Gerrit Pape
17a8b25005 gitweb: fallback to system-wide config file if default config does not exist
From a distribution point of view, configuration files for applications
should reside in /etc/.  On the other hand it's convenient for multiple
instances of gitweb (e.g. virtual web servers on a single machine) to have
a per-instance configuration file, just as gitweb currently supports
through the file gitweb_config.perl next to the cgi.

To support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as
a system-wide configuration file which will be used as a fallback if the
config file sprecified throug GITWEB_CONFIG does not exist.

See also
 http://bugs.debian.org/450592

Signed-off-by: Gerrit Pape <pape@smarden.org>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-27 13:55:10 -07:00
Jakub Narebski
c582abae46 gitweb: Fix and simplify pickaxe search
Instead of using "git-rev-list | git-diff-tree" pipeline for pickaxe
search, use git-log with appropriate options.  Besides reducing number
of forks by one, this allows to use list form of open, which in turn
allow to not worry about quoting arguments and to avoid forking shell.

The options to git-log were chosen to reduce required changes in
pickaxe git command output parsing; gitweb still parses returned
commits one by one.

Parsing "pickaxe" output is simplified: git_search now reuses
parse_difftree_raw_line and writes affected files as they arrive using
the fact that commit name goes always before [raw] diff.

While at it long bug of pickaxe search was fixed, namely that the last
commit found by pickaxe search was never shown.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-05 13:38:34 -08:00
Jakub Narebski
6dfbb304be gitweb: Mark first match when searching commit messages
Due to greediness of a pattern, gitweb used to mark (show) last match
in line, if there are more than one match in line. Now it shows first.
Showing all matches in a line would require further work.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-02 15:26:31 -08:00
Petr Baudis
0e55991987 gitweb: Clearly distinguish regexp / exact match searches
This patch does a couple of things:

* Makes commit/author/committer search case insensitive

  To be consistent with the grep search; I see no convincing
  reason for the search to be case sensitive, and you might
  get in trouble especially with contributors e.g. from Japan
  or France where they sometimes like to uppercase their last
  name.

* Makes grep search by default search for fixed strings.

* Introduces 're' checkbox that enables POSIX extended regexp searches

  This works for all the search types. The idea comes from Jakub.

It does not make much sense (and is not easy at all) to untangle most
of these changes from each other, thus they all go in a single patch.

[jn: Cherry-picked from Pasky's http://repo.or.cz/git/gitweb.git]

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-27 13:24:08 -08:00
Jakub Narebski
0270cd0eea gitweb: Simplify fixed string search
Use '--fixed-strings' option to git-rev-list to simplify and improve
searching commit messages (commit search).  It allows to search for
example for "don't" successfully from gitweb.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-27 13:22:11 -08:00
Jakub Narebski
311e552e76 gitweb: Change parse_commits signature to allow for multiple options
Change order of parameters in parse_commits() to have $filename
before @args (extra options), to allow for multiple extra options,
for example both '--grep=<pattern>' and '--fixed-strings'.

Change all callers to follow new calling convention.

Originally by Petr Baudis, in http://repo.or.cz/git/gitweb.git:

    b98f0a7c gitweb: Clearly distinguish regexp / exact match searches

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-27 13:21:32 -08:00
Jakub Narebski
b8d97d07fd gitweb: Better cutting matched string and its context
Improve look of commit search output ('search' view) by better cutting
of matched string and its context in match info, as suggested by Junio.
For example, if you are looking for "very long search string" in the
following line:

    Could somebody test this with very long search string, and see how

you would now see:

    ...this with <<very long ... string>>, and see...

instead of:

    Could som... <<very long search...>>, and see...

(where <<something>> denotes emphasized / colored fragment; matched
fragment to be more exact).

For this feature, support for fourth [optional] parameter to chop_str
subroutine was added.  This fourth parameter is used to denote where
to cut string to make it shorter.  chop_str can now cut at the
beginning (from the _left_ side of the string), in the middle
(_center_ of the string), or at the end (from the _right_ side of
the string); cutting from right is the default:

  chop_str(somestring, len, slop, 'left')    ->  ' ...string'
  chop_str(somestring, len, slop, 'center')  ->  'som ... ing'
  chop_str(somestring, len, slop, 'right')   ->  'somestr... '

If you want to use default slop (default additional length), use undef
as value for third parameter to chop_str.

While at it, return from chop_str early if given string is so short
that chop_str couldn't shorten it.  Simplify also regexp used by
chop_str.  Make ellipsis (dots) stick to shortened fragment for
cutting at ends, to better see which part got shortened.

Simplify passing all arguments to chop_str in chop_and_escape_str
subroutine. This was needed to pass additional options to chop_str.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-25 22:20:18 -08:00
Jakub Narebski
9d561ad324 gitweb: Fix bugs in git_search_grep_body: it's length(), not len()
Use int(<expr>/2) to get integer value for a substring length.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-23 14:22:01 -08:00
Junio C Hamano
be8b906381 gitweb: Better chopping in commit search results
When searching commit messages (commit search), if matched string is
too long, the generated HTML was munged leading to an ill-formed XHTML
document.

Now gitweb chop leading, trailing and matched parts, HTML escapes
those parts, then composes and marks up match info.  HTML output is
never chopped.  Limiting matched info to 80 columns (with slop) is now
done by dividing remaining characters after chopping match equally to
leading and trailing part, not by chopping composed and HTML marked
output.

Noticed-by: Jean-Baptiste Quenot <jbq@caraldi.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-22 10:06:58 -08:00
Jakub Narebski
afa9b620f9 gitweb: Fix bug in href(..., -replay=>1) when using 'pathinfo' form
URLs generated by href(..., -replay=>1) (which includes 'next page'
links and alternate view links) didn't set project info correctly
when current page URL is in pathinfo form.

This resulted in broken links such like:

  http://www.example.com/w/ARRAY(0x85a5318)?a=shortlog;pg=1

if the 'pathinfo' feature was used, or

  http://www.example.com/w/?a=shortlog;pg=1

if it wasn't, instead of correct:

  http://www.example.com/w/project.git?a=shortlog;pg=1

This was caused by the fact that href() always replays params in the
arrayref form, were they multivalued or singlevalued, and the code
dealing with 'pathinfo' feature couldn't deal with $params{'project'}
being arrayref.

Setting $params{'project'} is moved before replaying params; this
ensures that 'project' parameter is processed correctly.

Noticed-by: Peter Oberndorfer <kumbayo84@arcor.de>
Noticed-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-19 21:30:44 -08:00
Junio C Hamano
a8f6b201aa Merge branch 'br/gitweb'
* br/gitweb:
  gitweb: Use the config file to set repository owner's name.
2008-02-17 19:31:18 -08:00
Jakub Narebski
c84c483ffd gitweb: Add new option -nohtml to quot_xxx subroutines
Add support for new option -nohtml to quot_cec and quot_upr
subroutines, to have output not wrapped in HTML tags.  This makes
those subroutines suitable to quoting attributes values, and for plain
text output quoting.  Currently this API is not used yet.

While at it fix whitespace, and use ';' as delimiter, not separator.

The option to not wrap quot_cec output in HTML tag were proposed
originally in patch:
  "Don't open a XML tag while another one is already open"
  Message-ID: <20080216191628.GK30676@schiele.dyndns.org>
by Robert Schiele.  Originally the parameter was named '-notag', was
also supportted by esc_html (but not esc_path) which passed it down to
quot_cec.  Mentioned patch was meant to fix the bug Martin Koegler
reported in his mail
  "Invalid html output repo.or.cz (alt-git.git)"
  Message-ID: <20080216130037.GA14571@auto.tuwien.ac.at>
which was fixed in different way (do not use esc_html to escape and
quote HTML attributes).

Signed-off-by: Robert Schiele <rschiele@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-17 19:31:11 -08:00
Jakub Narebski
850b90a51d gitweb: Fix displaying unchopped argument in chop_and_escape_str
Do not use esc_html to escape [title] _attribute_ of a HTML element,
and quote unprintable characters.  Replace unprintable characters by
'?' and use CGI method to generate HTML element and do the escaping.

This caused bug noticed by Martin Koegler,
  Message-ID: <20080216130037.GA14571@auto.tuwien.ac.at>
that for bad commit encoding in author name, the title attribute (here
to show full, not shortened name) had embedded HTML code in it, result
of quoting unprintable characters the gitweb/HTML way. This of course
broke the HTML, causing page being not displayed in XML validating web
browsers.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-17 19:29:16 -08:00
Bruno Ribas
b59012ef4e gitweb: Use the config file to set repository owner's name.
Now gitweb checks if gitweb.owner exists before trying to get filesystem's
owner.

Allow to use configuration variable gitweb.owner set the repository owner,
it checks the gitweb.owner, if not set it uses filesystem directory's owner.

Useful when we don't want to maintain project list file, and all
repository directories have to have the same owner (for example when the
same SSH account is shared for all projects, using ssh_acl to control
access instead).

Signed-off-by: Bruno Ribas <ribas@c3sl.ufpr.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-09 23:37:03 -08:00
Bruno Ribas
201945eeb3 gitweb: Make use of the $git_dir variable at sub git_get_project_url_list
Signed-off-by: Bruno Ribas <ribas@c3sl.ufpr.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-08 01:26:27 -08:00
Florian La Roche
e62a641de1 gitweb: Make feed entries point to commitdiff view
Change feeds entries (feeds items) from pointing (linking) to 'commit'
view to pointing to 'commitdiff' view.

First, feed entries have whatchanged-like list of files which were
modified in a commit, so 'commitdiff' view more naturally reflects
feed entry (is more naturally alternate / extended version of a feed
item). Second, this way the patches are shown directly and code review
is done more easily via watching feeds.

[jn: Rewritten commit message]

Signed-off-by: Florian La Roche <laroche@redhat.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-06 13:50:25 -08:00
Bruno Ribas
c1dcf7ebf2 gitweb: Make use of the $git_dir variable at sub git_get_project_description
Signed-off-by: Bruno Ribas <ribas@c3sl.ufpr.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-29 23:55:18 -08:00
Yasushi SHOJI
7720224ceb gitweb: Convert generated contents to utf8 in commitdiff_plain
If the commit message, or commit author contains non-ascii, it must be
converted from Perl internal representation to utf-8, to follow what
got declared in HTTP header.  Use to_utf8() to do the conversion.

This necessarily replaces here-doc with "print" statements.

Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com>
Acked-by: İsmail Dönmez <ismail@pardus.org.tr>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-29 21:23:57 -08:00
Jakub Narebski
d76a585d83 gitweb: fix whitespace in config_to_multi (indent with tab)
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-20 19:07:24 -08:00
Petr Baudis
bc8b95ae4a gitweb: Make config_to_multi return [] instead of [undef]
This is important for the list of clone urls, where if there are
no per-repository clone URL configured, the default base URLs
are never used for URL construction without this patch.

Add tests for different ways of setting project URLs, just in case.
Note that those tests in current form wouldn't detect breakage fixed
by this patch, as it only checks for errors and not for expected
output.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16 11:56:27 -08:00
Jakub Narebski
dfa7c7d221 gitweb: Teach "a=blob" action to be more lenient about blob/file mime type
Since 930cf7dd7c 'blob' action knows the
file type; if the file type is not "text/*" or one of common network
image formats/mimetypes (gif, png, jpeg) then the action "blob"
defaulted to "blob_plain".  This caused the problem if mimetypes file
was not well suited for web, for example returning "application/x-sh"
for "*.sh" shell scripts, instead of "text/plain" (or other "text/*").

Now "blob" action defaults to "blob_plain" ('raw' view) only if file
is of type which is neither "text/*" nor "image/{gif,png,jpeg}"
AND it is binary file.  Otherwise it assumes that it can be displayed
either in <img> tag ("image/*" mimetype), or can be displayed line by
line (otherwise).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16 11:56:26 -08:00
Jakub Narebski
bf901f8e74 gitweb: disambiguate heads and tags withs the same name
Avoid wrong disambiguation that would link logs/trees of tags and
heads which share the same name to the same page, leading to
a disambiguation that would prefer the tag, thus making it impossible
to access the corresponding head log and tree without hacking the url
by hand.

It does it by using full refname (with 'refs/heads/' or 'refs/tags/'
prefix) instead of shortened one in the URLs in 'heads' and 'tags'
tables.  This makes URLs (and refs) provided by gitweb unambiguous.

Signed-off-by: Guillaume Seguin <guillaume@segu.in>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-16 11:56:26 -08:00
İsmail Dönmez
e5d3de5c45 gitweb: use Perl built-in utf8 function for UTF-8 decoding.
Signed-off-by: İsmail Dönmez <ismail@pardus.org.tr>
Tested-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-04 14:43:21 -08:00
Denis Cheng
f1fe8f5c1e gitweb: the commitdiff is very commonly used, it's needed on search page, too
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-02 02:32:36 -08:00
Jakub Narebski
9d06674570 gitweb: Put project README in div.readme, fix its padding
Put (optional) projects README on "summary" page in <div> element
using "readme" class.  This allow to style it using CSS.

Add padding to project's README to make it line out with the rest
of the page.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
2007-11-20 13:16:15 -08:00
Jakub Narebski
591ebf6595 gitweb: Style all tables using CSS
Remove all cellspacing="0" attributes from tables in gitweb,
replacing it by CSS rule.  Add CSS classes for all tables.

While at it, change class(es) of table for commit message and commit
authorship search from "grep" to "commit_search"; similarly,
"grep_search" class is now used for table with results of grep (files)
search.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
2007-11-20 13:16:15 -08:00
Junio C Hamano
82527cf33e Merge branch 'maint'
* maint:
  fix index-pack with packs >4GB containing deltas on 32-bit machines
  git-hash-object should honor config variables
  gitweb: correct month in date display for atom feeds
2007-11-11 15:00:05 -08:00
Vincent Zanotti
a62d6d84c6 gitweb: correct month in date display for atom feeds
Signed-off-by: Vincent Zanotti <vincent.zanotti@m4x.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-10 12:47:16 -08:00
Jakub Narebski
0e121a2cd4 gitweb: Use config file for repository description and URLs
Allow to use configuration variable gitweb.description for repository
description if there is no $GIT_DIR/description file, and multivalued
configuration variable gitweb.url for URLs of a project (to clone or
fetch from) if there is no $GIT_DIR/cloneurl file.

While repository description is shown in the projects list page, so it
is better to use file and not config variable for performance, it is I
think better to use gitweb.url for URLs (as it is shown only on
project summary page).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-02 18:27:36 -07:00
Jakub Narebski
b201927ac8 gitweb: Read repo config using 'git config -z -l'
Change git_get_project_config to run git-config only once per
repository, without changing its signature (its calling convention).
This means for example that it returns 'true' or 'false' when called
with second argument '--bool', and not true or false value.

Instead of calling 'git config [<type>] --get gitweb.<key>' once for
each config variable, call 'git config -z -l' only once, parsing and
saving its output to %config variable.  This makes possible to add new
per repository configuration without paying cost of forking once per
variable checked.  We can now allow repository description and
repository URLs to be stored in config file without badly affecting
gitweb performance.

For now only configuration variables for 'gitweb' section are stored.

Multiple values for single configuration variable are stored as
anonymous array reference; configuration variable with no value is
stored as undef.

Converting configuration variable values to boolean or integer value
are done in Perl.  Results differ from git-config in the fact that no
conversion error is ever raised.  For boolean values no value, 'true'
(any case) and 'false' (any case) are considered true, numbers are
true if not zero; all other values (even invalid for bool) are
considered false.  For integer values value suffix of 'k', 'm', or 'g'
following decimal number will cause the value to be multiplied by
1024, 1048576, or 1073741824; other values are returned as-is, only
whitespace stripped.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-02 18:27:35 -07:00
Jakub Narebski
a3823e5ad7 gitweb: Use href(-replay=>1, action=>...) to generate alternate views
Use href(action=>..., -replay=>1) to generate links to alternate views
of current page in the $formats_nav (bottom) part of page_nav
navigation bar.  This form is used only when all parameters are
repeated, and when the replay form is shorter.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-02 01:30:35 -07:00
Jakub Narebski
7afd77bfc1 gitweb: Use href(-replay=>1, page=>...) to generate pagination links
Use href(-replay=>1, page=>$page-1) and href(-replay=>1, page=>$page+1)
to generate previous page and next page links.

Generate next page link only once.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-02 01:30:35 -07:00
Jakub Narebski
1cad283a71 gitweb: Easier adding/changing parameters to current URL
Add boolean option '-replay' to href() subroutine, which is used to
generate links in gitweb.  This option "replays" current URL,
overriding it with provided parameters.  It means that current value
of each CGI parameter is used unless otherwise provided.

This change is meant to make it easier to generate links which differ
from current page URL only by one parameter, for example the same view
but sorted by different column:
  href(-replay=>1, order=>"age")
or view which differs by some option, e.g. in log views
  href(-replay=>1, extra_options=>"--no-merges")
or alternate view of the same object, e.g. in the 'blob' view
  href(-replay=>1, action=>"blob_plain")

Actual use of this functionality is left for later.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-02 01:30:35 -07:00
Jakub Narebski
6aa6f92fda gitweb: Add 'status_str' to parse_difftree_raw_line output
Add 'status_str' to diffinfo output, which stores status (also for
merge commit) as a string.  This allows for easy checking if there is
given status among all for merge commit, e.g.
  $diffinfo->{'status_str'} =~ /D/;

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-01 17:34:50 -07:00
Jakub Narebski
9d30145663 gitweb: Always set 'from_file' and 'to_file' in parse_difftree_raw_line
Always set 'from_file' and 'to_file' keys when parsing raw diff output
format line, even if filename didn't change (file was not renamed).
This allows for simpler code.

Previously, you would have written:

  $diffinfo->{'from_file'} || $diffinfo->{'file'}

but now you can just use

  $diffinfo->{'from_file'}

as 'from_file' is always defined.

While at it, replace (for merge commits)

  $diffinfo->{'from_file'}[$i] || $diffinfo->{'to_file'}

by

  defined $diffinfo->{'from_file'}[$i] ?
          $diffinfo->{'from_file'}[$i] :
          $diffinfo->{'to_file'};

to have no problems with file named '0'.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-01 17:34:41 -07:00
Junio C Hamano
6beb66968d Merge branch 'jn/web' into HEAD
* jn/web:
  gitweb: Fix and simplify "split patch" detection
2007-10-30 21:37:58 -07:00
Jakub Narebski
0cec6db5cf gitweb: Fix and simplify "split patch" detection
There are some cases when one line from "raw" git-diff output (raw
format) corresponds to more than one patch in the patchset git-diff
output; we call this situation "split patch". Old code misdetected
subsequent patches (for different files) with the same pre-image and
post-image as fragments of "split patch", leading to mislabeled
from-file/to-file diff header etc.

Old code used pre-image and post-image SHA-1 identifier ('from_id' and
'to_id') to check if current patch corresponds to old raw diff format
line, to find if one difftree raw line coresponds to more than one
patch in the patch format.  Now we use post-image filename for that.
This assumes that post-image filename alone can be used to identify
difftree raw line.  In the case this changes (which is unlikely
considering current diff engine) we can add 'from_id' and 'to_id'
to detect "patch splitting" together with 'to_file'.

Because old code got pre-image and post-image SHA-1 identifier for the
patch from the "index" line in extended diff header, diff header had
to be buffered.  New code takes post-image filename from "git diff"
header, which is first line of a patch; this allows to simplify
git_patchset_body code.  A side effect of resigning diff header
buffering is that there is always "diff extended_header" div, even
if extended diff header is empty.

Alternate solution would be to check when git splits patches, and do
not check if parsed info from current patch corresponds to current or
next raw diff format output line.  Git splits patches only for 'T'
(typechange) status filepair, and there always two patches
corresponding to one raw diff line.  It was not used because it would
tie gitweb code to minute details of git diff output.

While at it, use newly introduced parsed_difftree_line wrapper
subroutine in git_difftree_body.

Noticed-by: Yann Dirson <ydirson@altern.org>
Diagnosed-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-29 21:21:51 -07:00