gitweb.git
git-instaweb: Check that correct config file exists... Jakub Narebski Thu, 23 Jun 2011 21:01:03 +0000 (23:01 +0200)

git-instaweb: Check that correct config file exists for (re)start

Currently start/restart does not generate any configuration files for
spawning a new instance. This means that

$ git instaweb --http=<server> --start

might pick up stale 'httpd.conf' file for a different web server
(e.g. for default lighttpd when requesting apache2).

This commit changes that, and makes git-instaweb generate web server
config file and/or gitweb config file if don't exists.

This required naming config files after the name of web server
(alternate solution would be to somehow mark for which web server was
config file generated).

Note that web servers that embed configuration in server script file,
namely webrick and plackup, and which delete "$conf" in their *_conf
function, would have their config (server script) always regenerated.

Note: this commit introduces a bit of code repetition (but only a few
lines).

Reported-by: Gurjeet Singh <singh.gurjeet@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>

git-instaweb: Move all actions at the end of scriptJakub Narebski Thu, 23 Jun 2011 20:59:26 +0000 (22:59 +0200)

git-instaweb: Move all actions at the end of script

As a nice side-effect now the order of parameters does not matter:

$ git instaweb --httpd=apache2 --start

is now (after this patch) the same as

$ git instaweb --start --httpd=apache2

Before this commit --start, --stop, --restart (and their subcommand
versions start, stop, restart) exited immediately.

This is preparatory work for making start/restart check that correct
configuration is set up; this change was required to have access in
start_httpd to requested web browser etc.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>

git-instaweb: Use $conf, not $fqgitdir/gitweb/httpd... Jakub Narebski Thu, 23 Jun 2011 19:56:37 +0000 (21:56 +0200)

git-instaweb: Use $conf, not $fqgitdir/gitweb/httpd.conf

Don't repeat yourself: use "$conf" instead of its [current] contents,
namely "$fqgitdir/gitweb/httpd.conf".

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>

git-instaweb: Extract configuring web server into confi... Jakub Narebski Thu, 23 Jun 2011 19:55:00 +0000 (21:55 +0200)

git-instaweb: Extract configuring web server into configure_httpd

This is preparatory work for making start/restart check that
git-instaweb set up correct configuration, and generate it if it is
missing.

Pure refactoring, no functional changes.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>

submodule add: always initialize .git/config entryJens Lehmann Sat, 25 Jun 2011 23:26:02 +0000 (01:26 +0200)

submodule add: always initialize .git/config entry

When "git submodule add $path" is run to add a subdirectory $path to the
superproject, and $path is already the top of the working tree of the
submodule repository, the command created submodule.$path.url entry in the
configuration file in the superproject. However, when adding a repository
$URL that is outside the respository of the superproject to $path that
does not exist (yet) with "git submodule add $URL $path", the command
forgot to set it up.

The user is expressing the interest in the submodule and wants to keep a
checkout, the "submodule add" command should consistently set up the
submodule.$path.url entry in either case.

As a result "git submodule init" can't simply skip the initialization of
those submodules for which it finds an url entry in the git./config
anymore. That lead to problems when adding a submodule (which now sets the
url), add the "update" setting to .gitmodules and expect init to copy that
into .git/config like it is done in t7406. So change init to only then
copy the "url" and "update" entries when they don't exist yet in the
.git/config and do nothing otherwise.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule sync: do not auto-vivify uninteresting submoduleJunio C Hamano Sat, 25 Jun 2011 20:41:25 +0000 (22:41 +0200)

submodule sync: do not auto-vivify uninteresting submodule

Earlier 33f072f (submodule sync: Update "submodule.<name>.url" for empty
directories, 2010-10-08) attempted to fix a bug where "git submodule sync"
command does not update the URL if the current superproject does not have
a checkout of the submodule.

However, it did so by unconditionally registering submodule.$name.url to
every submodule in the project, even the ones that the user has never
showed interest in at all by running 'git submodule init' command. This
caused subsequent 'git submodule update' to start cloning/updating submodules
that are not interesting to the user at all.

Update the code so that the URL is updated from the .gitmodules file only
for submodules that already have submodule.$name.url entries, i.e. the
ones the user has showed interested in having a checkout.

Acked-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: Add --include-untracked option to stash and... David Caldwell Sat, 25 Jun 2011 00:56:06 +0000 (17:56 -0700)

stash: Add --include-untracked option to stash and remove all untracked files

The --include-untracked option acts like the normal "git stash save" but
also adds all untracked files in the working directory to the stash and then
calls "git clean --force --quiet" to restore the working directory to a
pristine state.

This is useful for projects that need to run release scripts. With this
option, the release scripts can be from the main working directory so one
does not have to maintain a "clean" directory in parallel just for
releasing. Basically the work-flow becomes:

$ git tag release-1.0
$ git stash --include-untracked
$ make release
$ git clean -f
$ git stash pop

"git stash" alone is not enough in this case--it leaves untracked files
lying around that might mess up a release process that expects everything to
be very clean or might let a release succeed that should actually fail (due
to a new source file being created that hasn't been committed yet).

Signed-off-by: David Caldwell <david@porkrind.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 1.7.6 v1.7.6Junio C Hamano Sun, 26 Jun 2011 19:41:16 +0000 (12:41 -0700)

Git 1.7.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'maint'Junio C Hamano Sun, 26 Jun 2011 19:09:11 +0000 (12:09 -0700)

Merge branch 'maint'

* maint:
completion: replace core.abbrevguard to core.abbrev

Merge branch 'maint-1.7.4' into maintJunio C Hamano Fri, 24 Jun 2011 16:40:02 +0000 (09:40 -0700)

Merge branch 'maint-1.7.4' into maint

* maint-1.7.4:
completion: replace core.abbrevguard to core.abbrev

completion: replace core.abbrevguard to core.abbrevNamhyung Kim Fri, 24 Jun 2011 06:17:42 +0000 (15:17 +0900)

completion: replace core.abbrevguard to core.abbrev

The core.abbrevguard config variable had removed and
now core.abbrev has been used instead. Teach it.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

glossary: clarify description of HEADJunio C Hamano Thu, 23 Jun 2011 16:48:49 +0000 (09:48 -0700)

glossary: clarify description of HEAD

HEAD on a branch does reference a commit via the branch ref it refers to.
The main difference of a detached HEAD is that it _directly_ refers to
a commit. Clarify this.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

glossary: update description of head and refJunio C Hamano Thu, 23 Jun 2011 16:47:28 +0000 (09:47 -0700)

glossary: update description of head and ref

Reword them to avoid sounding as if loose refs are the only ones in the world.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

glossary: update description of "tag"Junio C Hamano Thu, 23 Jun 2011 16:38:48 +0000 (09:38 -0700)

glossary: update description of "tag"

It is an unimportant implementation detail that ref namespaces are
implemented as subdirectories of $GIT_DIR/refs. What is more important
is that tags are in refs/tags hierarchy in the ref namespace.

Also note that a tag can point at an object of arbitrary type, not limited
to commit.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

git.txt: de-emphasize the implementation detail of... Junio C Hamano Thu, 23 Jun 2011 16:35:10 +0000 (09:35 -0700)

git.txt: de-emphasize the implementation detail of a ref

It is an unimportant implementation detail that branches and tags are
stored somewhere under $GIT_DIR/refs directory, or the name of the commit
that will become the parent of the next commit is stored in $GIT_DIR/HEAD.

What is more important is that branches live in refs/heads and tags live
in refs/tags hierarchy in the ref namespace, and HEAD means the tip of the
current branch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

check-ref-format doc: de-emphasize the implementation... Junio C Hamano Thu, 23 Jun 2011 16:31:19 +0000 (09:31 -0700)

check-ref-format doc: de-emphasize the implementation detail of a ref

It is an unimportant implementation detail that branches and tags are
stored somewhere under $GIT_DIR/refs directory. What is more important
is that branches live in refs/heads and tags live in refs/tags hierarchy
in the ref namespace.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote.txt: avoid sounding as if loose refs are... Junio C Hamano Thu, 23 Jun 2011 15:33:05 +0000 (08:33 -0700)

git-remote.txt: avoid sounding as if loose refs are the only ones in the world

It was correct to say "The file $GIT_DIR/refs/heads/master stores the
commit object name at the tip of the master branch" in the older days,
but not anymore, as refs can be packed into $GIT_DIR/packed-refs file.

Update the document to talk in terms of a more abstract concept "ref" and
"symbolic ref" where we are not describing the underlying implementation
detail.

This on purpose leaves two instances of $GIT_DIR/ in the git-remote
documentation; they do talk about $GIT_DIR/remotes/ and $GIT_DIR/branches/
file hierarchy that used to be the place to store configuration around
remotes before the configuration mechanism took them over.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote.txt: fix wrong remote refspecNamhyung Kim Thu, 23 Jun 2011 08:12:04 +0000 (17:12 +0900)

git-remote.txt: fix wrong remote refspec

$GIT_DIR/remotes/<name>/<branch> should be
$GIT_DIR/refs/remotes/<name>/<branch>.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 1.7.6-rc3 v1.7.6-rc3Junio C Hamano Wed, 22 Jun 2011 23:13:16 +0000 (16:13 -0700)

Git 1.7.6-rc3

Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: Refactor git_header_htmlJakub Narebski Wed, 22 Jun 2011 11:50:46 +0000 (13:50 +0200)

gitweb: Refactor git_header_html

Extract the following parts into separate subroutines:

* finding correct MIME content type for HTML pages (text/html or
application/xhtml+xml?) into get_content_type_html()
* printing <link ...> elements in HTML head into print_header_links()
* printing navigation "breadcrumbs" for given action into
print_nav_breadcrumbs()
* printing search form into print_search_form()

This reduces git_header_html to two pages long (53 lines), making gitweb
code easier to read.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'maint'Junio C Hamano Wed, 22 Jun 2011 21:01:18 +0000 (14:01 -0700)

Merge branch 'maint'

* maint:
Documentation: git diff --check respects core.whitespace

Makefile: Track changes to LDFLAGS and relink when... Fredrik Kuivinen Wed, 22 Jun 2011 10:50:56 +0000 (12:50 +0200)

Makefile: Track changes to LDFLAGS and relink when necessary

Some profiling tools (e.g., google-perftools and mutrace) work by
linking in a new library into the executables. When using these tools
it is convenient to only relink instead of doing a full make clean;
make cycle.

This change complements the auto-detection of changes to CFLAGS that
we already have. Tracking of more variables that affect the build can
be added when the need arise.

Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: Make git_search_* subroutines render whole... Jakub Narebski Wed, 22 Jun 2011 15:28:55 +0000 (17:28 +0200)

gitweb: Make git_search_* subroutines render whole pages

Move git_header_html() and git_footer_html() invocation from git_search()
to individual git_search_* subroutines.

While at it, reorganize search-related code a bit, moving invoking of git
commands before any output is generated.

This has the following advantages:

* gitweb now shows an error page if there was unknown search type
(evaluate_and_validate_params checks only that it looks sanely);
remember that we shouldn't call die_error after any output.

* git_search_message is now safe agains die_error in parse_commits
(though this is very unlikely).

* gitweb now can check errors while invoking git commands and show
error page (again, quite unlikely).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: Clean up code in git_search_* subroutinesJakub Narebski Wed, 22 Jun 2011 15:28:54 +0000 (17:28 +0200)

gitweb: Clean up code in git_search_* subroutines

Replace sequence of

$foo .= "bar";
$foo .= "baz";

with

$foo .= "bar" .
"baz";

Use href(-replay=>1, -page=>undef) for first page of a multipl-page view.

Wrap some lines to reduce their length. Some lines still have more than 80
characters, but lines are shorter now.

No functional changes intended.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: Split body of git_search into subroutinesJakub Narebski Wed, 22 Jun 2011 15:28:53 +0000 (17:28 +0200)

gitweb: Split body of git_search into subroutines

Create separate subroutines for handling each of aspects of searching
the repository:

* git_search_message ('commit', 'author', 'committer')
* git_search_changes ('pickaxe')
* git_search_content_of_files ('grep')

Almost pure code movement (and unindent), which you can check e.g. via

$ git blame -w --date=short -C -C HEAD^..HEAD -- gitweb/gitweb.perl |
grep -C 3 -e '^[^^]' | less -S

No functional changes intended.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: Check permissions first in git_searchJakub Narebski Wed, 22 Jun 2011 15:28:52 +0000 (17:28 +0200)

gitweb: Check permissions first in git_search

Check first if relevant features: 'search', 'pickaxe', 'grep', as
appropriate, are enabled before doing anything else in git_search.
This should make git_search code more clear.

While at it, expand a bit error message (e.g. 'Pickaxe' ->
'Pickaxe search').

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation: git diff --check respects core.whitespaceChristof Krüger Wed, 22 Jun 2011 15:33:02 +0000 (17:33 +0200)

Documentation: git diff --check respects core.whitespace

Fix documentation on "git diff --check" by adopting the description from
"git apply --whitespace".

Signed-off-by: Christof Krüger <git@christof-krueger.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

clone: accept config options on the command lineJeff King Thu, 9 Jun 2011 20:56:19 +0000 (16:56 -0400)

clone: accept config options on the command line

Clone does all of init, "remote add", fetch, and checkout
without giving the user a chance to intervene and set any
configuration. This patch allows you to set config options
in the newly created repository after the clone, but before
we do any other operations.

In many cases, this is a minor convenience over something
like:

git clone git://...
git config core.whatever true

But in some cases, it can bring extra efficiency by changing
how the fetch or checkout work. For example, setting
line-ending config before the checkout avoids having to
re-checkout all of the contents with the correct line
endings.

It also provides a mechanism for passing information to remote
helpers during a clone; the helpers may read the git config
to influence how they operate.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: make git_config_parse_parameter a public functionJeff King Thu, 9 Jun 2011 15:56:42 +0000 (11:56 -0400)

config: make git_config_parse_parameter a public function

We use this internally to parse "git -c core.foo=bar", but
the general format of "key=value" is useful for other
places.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote: use new OPT_STRING_LISTJeff King Thu, 9 Jun 2011 15:55:59 +0000 (11:55 -0400)

remote: use new OPT_STRING_LIST

This saves us having our own callback function.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parse-options: add OPT_STRING_LIST helperJeff King Thu, 9 Jun 2011 15:55:23 +0000 (11:55 -0400)

parse-options: add OPT_STRING_LIST helper

This just adds repeated invocations of an option to a list
of strings. Using the "--no-<var>" form will reset the list
to empty.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: use strbuf_split_str instead of a temporary... Jeff King Thu, 9 Jun 2011 15:55:09 +0000 (11:55 -0400)

config: use strbuf_split_str instead of a temporary strbuf

This saves an allocation and copy, and also fixes a minor
memory leak.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

strbuf: allow strbuf_split to work on non-strbufsJeff King Thu, 9 Jun 2011 15:54:58 +0000 (11:54 -0400)

strbuf: allow strbuf_split to work on non-strbufs

The strbuf_split function takes a strbuf as input, and
outputs a list of strbufs. However, there is no reason that
the input has to be a strbuf, and not an arbitrary buffer.

This patch adds strbuf_split_buf for a length-delimited
buffer, and strbuf_split_str for NUL-terminated strings.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: avoid segfault when parsing command-line configJeff King Thu, 9 Jun 2011 15:52:43 +0000 (11:52 -0400)

config: avoid segfault when parsing command-line config

We already check for an empty key on the left side of an
equals, but we would segfault if there was no content at
all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: die on error in command-line configJeff King Thu, 9 Jun 2011 15:52:32 +0000 (11:52 -0400)

config: die on error in command-line config

The error handling for git_config is somewhat confusing. We
collect errors from running git_config_from_file on the
various config files and carefully pass them back up. But
the two odd things are:

1. We actually die on most errors in git_config_from_file.
In fact, the only error we actually pass back up is if
fopen() fails on the file.

2. Most callers of git_config do not check the error
return at all, but will continue if git_config reports
an error.

When the code for "git -c core.foo=bar" was added, it
dutifully passed errors up the call stack, only for them to
be eventually ignored. This makes it inconsistent with the
file-parsing code, which will die when it sees malformed
config. And it's somewhat unsafe, because it means an error
in parsing a typo like:

git -c clean.requireforce=ture clean

will continue the command, ignoring the config the user
tried to give.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fix "git -c" parsing of values with equals signsJeff King Thu, 9 Jun 2011 15:51:36 +0000 (11:51 -0400)

fix "git -c" parsing of values with equals signs

If you do something like:

git -c core.foo="value with = in it" ...

we would split your option on "=" into three fields and
throw away the third one. With this patch we correctly take
everything after the first "=" as the value (keys cannot
have an equals sign in them, so the parsing is unambiguous).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

strbuf_split: add a max parameterJeff King Thu, 9 Jun 2011 15:51:22 +0000 (11:51 -0400)

strbuf_split: add a max parameter

Sometimes when splitting, you only want a limited number of
fields, and for the final field to contain "everything
else", even if it includes the delimiter.

This patch introduces strbuf_split_max, which provides a
"max number of fields" parameter; it behaves similarly to
perl's "split" with a 3rd field.

The existing 2-argument form of strbuf_split is retained for
compatibility and ease-of-use.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

upload-archive: allow user to turn off filtersJeff King Wed, 22 Jun 2011 03:17:35 +0000 (23:17 -0400)

upload-archive: allow user to turn off filters

Some tar filters may be very expensive to run, so sites do
not want to expose them via upload-archive. This patch lets
users configure tar.<filter>.remote to turn them off.

By default, gzip filters are left on, as they are about as
expensive as creating zip archives.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive: provide builtin .tar.gz filterJeff King Wed, 22 Jun 2011 01:27:35 +0000 (21:27 -0400)

archive: provide builtin .tar.gz filter

This works exactly as if the user had configured it via:

[tar "tgz"]
command = gzip -cn
[tar "tar.gz"]
command = gzip -cn

but since it is so common, it's convenient to have it
builtin without the user needing to do anything.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive: implement configurable tar filtersJeff King Wed, 22 Jun 2011 01:26:31 +0000 (21:26 -0400)

archive: implement configurable tar filters

It's common to pipe the tar output produce by "git archive"
through gzip or some other compressor. Locally, this can
easily be done by using a shell pipe. When requesting a
remote archive, though, it cannot be done through the
upload-archive interface.

This patch allows configurable tar filters, so that one
could define a "tar.gz" format that automatically pipes tar
output through gzip.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive: refactor file extension format-guessingJeff King Wed, 22 Jun 2011 01:25:25 +0000 (21:25 -0400)

archive: refactor file extension format-guessing

Git-archive will guess a format from the output filename if
no format is explicitly given. The current function just
hardcodes "zip" to the zip format, and leaves everything
else NULL (which will default to tar). Since we are about
to add user-specified formats, we need to be more flexible.
The new rule is "if a filename ends with a dot and the name
of a format, it matches that format". For the existing "tar"
and "zip" formats, this is identical to the current
behavior. For new user-specified formats, this will do what
the user expects if they name their formats appropriately.

Because we will eventually start matching arbitrary
user-specified extensions that may include dots, the strrchr
search for the final dot is not sufficient. We need to do an
actual suffix match with each extension.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive: move file extension format-guessing lowerJeff King Wed, 22 Jun 2011 01:24:48 +0000 (21:24 -0400)

archive: move file extension format-guessing lower

The process for guessing an archive output format based on
the filename is something like this:

a. parse --output in cmd_archive; check the filename
against a static set of mapping heuristics (right now
it just matches ".zip" for zip files).

b. if found, stick a fake "--format=zip" at the beginning
of the arguments list (if the user did specify a
--format manually, the later option will override our
fake one)

c. if it's a remote call, ship the arguments to the remote
(including the fake), which will call write_archive on
their end

d. if it's local, ship the arguments to write_archive
locally

There are two problems:

1. The set of mappings is static and at too high a level.
The write_archive level is going to check config for
user-defined formats, some of which will specify
extensions. We need to delay lookup until those are
parsed, so we can match against them.

2. For a remote archive call, our set of mappings (or
formats) may not match the remote side's. This is OK in
practice right now, because all versions of git
understand "zip" and "tar". But as new formats are
added, there is going to be a mismatch between what the
client can do and what the remote server can do.

To fix (1), this patch refactors the location guessing to
happen at the write_archive level, instead of the
cmd_archive level. So instead of sticking a fake --format
field in the argv list, we actually pass a "name hint" down
the callchain; this hint is used at the appropriate time to
guess the format (if one hasn't been given already).

This patch leaves (2) unfixed. The name_hint is converted to
a "--format" option as before, and passed to the remote.
This means the local side's idea of how extensions map to
formats will take precedence.

Another option would be to pass the name hint to the remote
side and let the remote choose. This isn't a good idea for
two reasons:

1. There's no room in the protocol for passing that
information. We can pass a new argument, but older
versions of git on the server will choke on it.

2. Letting the remote side decide creates a silent
inconsistency in user experience. Consider the case
that the locally installed git knows about the "tar.gz"
format, but a remote server doesn't.

Running "git archive -o foo.tar.gz" will use the tar.gz
format. If we use --remote, and the local side chooses
the format, then we send "--format=tar.gz" to the
remote, which will complain about the unknown format.
But if we let the remote side choose the format, then
it will realize that it doesn't know about "tar.gz" and
output uncompressed tar without even issuing a warning.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive: pass archiver struct to write_archive callbackJeff King Wed, 22 Jun 2011 01:24:07 +0000 (21:24 -0400)

archive: pass archiver struct to write_archive callback

The current archivers are very static; when you are in the
write_tar_archive function, you know you are writing a tar.
However, to facilitate runtime-configurable archivers
that will share a common write function we need to tell the
function which archiver was used.

As a convenience, we also provide an opaque data pointer in
the archiver struct so that individual archivers can put
something useful there when they register themselves.
Technically they could just use the "name" field to look in
an internal map of names to data, but this is much simpler.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive: refactor list of archive formatsJeff King Wed, 22 Jun 2011 01:23:33 +0000 (21:23 -0400)

archive: refactor list of archive formats

Most of the tar and zip code was nicely split out into two
abstracted files which knew only about their specific
formats. The entry point to this code was a single "write
archive" function.

However, as these basic formats grow more complex (e.g., by
handling multiple file extensions and format names), a
static list of the entry point functions won't be enough.
Instead, let's provide a way for the tar and zip code to
tell the main archive code what they support by registering
archiver names and functions.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive-tar: don't reload default config optionsJeff King Wed, 22 Jun 2011 01:22:20 +0000 (21:22 -0400)

archive-tar: don't reload default config options

We load our own tar-specific config, and then chain to
git_default_config. This is pointless, as our caller should
already have loaded the default config. It also introduces a
needless inconsistency with the zip archiver, which does not
look at the config files at all (and therefore relies on the
caller to have loaded config).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'maint'Junio C Hamano Tue, 21 Jun 2011 21:56:59 +0000 (14:56 -0700)

Merge branch 'maint'

* maint:
gitweb: 'pickaxe' and 'grep' features requires 'search' to be enabled

gitweb: 'pickaxe' and 'grep' features requires 'search... Jakub Narebski Tue, 21 Jun 2011 06:41:16 +0000 (08:41 +0200)

gitweb: 'pickaxe' and 'grep' features requires 'search' to be enabled

Both 'pickaxe' (searching changes) and 'grep' (searching files)
require basic 'search' feature to be enabled to work. Enabling
e.g. only 'pickaxe' won't work.

Add a comment about this.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Add explanation of the profile feedback build to the... Andi Kleen Mon, 20 Jun 2011 22:41:01 +0000 (15:41 -0700)

Add explanation of the profile feedback build to the README

Also explains that the are additional warnings.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'mk/grep-pcre'Junio C Hamano Mon, 20 Jun 2011 21:49:44 +0000 (14:49 -0700)

Merge branch 'mk/grep-pcre'

* mk/grep-pcre:
t7810: avoid unportable use of "echo"

t7810: avoid unportable use of "echo"Junio C Hamano Mon, 20 Jun 2011 21:49:34 +0000 (14:49 -0700)

t7810: avoid unportable use of "echo"

Michael J Gruber noticed that under /bin/dash this test failed
(as is expected -- \n in the string can be interpreted by the
command), while it passed with bash. We probably could work it
around by using backquote in front of it, but it is safer and
more readable to avoid "echo" altogether in a case like this.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

plug a few coverity-spotted leaksJim Meyering Mon, 20 Jun 2011 07:40:06 +0000 (09:40 +0200)

plug a few coverity-spotted leaks

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Add profile feedback build to gitAndi Kleen Sun, 19 Jun 2011 01:07:05 +0000 (18:07 -0700)

Add profile feedback build to git

Add a gcc profile feedback build option "profile-all" to the main
Makefile. It simply runs the test suite to generate feedback data and the
recompiles the main executables with that. The basic structure is similar
to the existing gcov code.

gcc is often able to generate better code with profile feedback data. The
training load also doesn't need to be too similar to the actual load, it
still gives benefits.

The test suite run is unfortunately quite long. It would be good to find a
suitable subset that runs faster and still gives reasonable feedback.

For now the test suite runs single threaded (I had some trouble running
the test suite with -jX)

I tested it with git gc and git blame kernel/sched.c on a Linux kernel
tree. For gc I get about 2.7% improvement in wall clock time by using the
feedback build, for blame about 2.4%. That's not gigantic, but not shabby
either for a very small patch.

If anyone has any favourite CPU intensive git benchmarks feel free to try
them too.

I hope distributors will switch to use a feedback build in their packages.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

cygwin: trust executable bit by defaultJunio C Hamano Mon, 20 Jun 2011 19:31:59 +0000 (12:31 -0700)

cygwin: trust executable bit by default

Earlier 7974843 (compat/cygwin.c: make runtime detection of lstat/stat
lessor impact, 2008-10-23) fixed the low-level "do we use cygwin specific
hacks for stat/lstat?" logic not to call into git_default_config() from
random codepaths that are typically very late in the program, to prevent
the call from potentially overwriting other variables that are initialized
from the configuration.

However, it forgot that on Cygwin, trust-executable-bit should default to
true.

Noticed by J6t, confirmed by Ramsay Jones, and the brown paper bag is on
Gitster's head.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch: Also fetch submodules in subdirectories in on... Jens Lehmann Mon, 20 Jun 2011 18:18:03 +0000 (20:18 +0200)

fetch: Also fetch submodules in subdirectories in on-demand mode

When on-demand mode was active examining the new commits just fetched in
the superproject (to check if they record commits for submodules which are
not downloaded yet) wasn't done recursively. Because of that fetch did not
recursively fetch submodules living in subdirectories even when it should
have.

Fix that by adding the RECURSIVE flag to the diff_options used to check
the new commits and avoid future regressions in this area by moving a
submodule in t5526 into a subdirectory.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tag: accept multiple patterns for --listJeff King Mon, 20 Jun 2011 16:59:28 +0000 (12:59 -0400)

tag: accept multiple patterns for --list

Until now, "git tag -l foo* bar*" would silently ignore the
second argument, showing only refs starting with "foo". It's
not just unfriendly not to take a second pattern; we
actually generated subtly wrong results (from the user's
perspective) because some of the requested tags were
omitted.

This patch allows an arbitrary number of patterns on the
command line; if any of them matches, the ref is shown.

While we're tweaking the documentation, let's also make it
clear that the pattern is fnmatch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Add option to disable NORETURNJunio C Hamano Sun, 19 Jun 2011 01:07:03 +0000 (18:07 -0700)

Add option to disable NORETURN

Due to a bug in gcc 4.6+ it can crash when doing profile feedback
with a noreturn function pointer

(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)

This adds a Makefile variable to disable noreturns.

[Patch by Junio, description by Andi Kleen]

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'di/no-no-existant'Junio C Hamano Sun, 19 Jun 2011 23:01:54 +0000 (16:01 -0700)

Merge branch 'di/no-no-existant'

* di/no-no-existant:
Fix typo: existant->existent

Merge branch 'maint'Junio C Hamano Sun, 19 Jun 2011 23:01:51 +0000 (16:01 -0700)

Merge branch 'maint'

* maint:
builtin/gc.c: add missing newline in message

builtin/gc.c: add missing newline in messageAndreas Schwab Sun, 19 Jun 2011 08:03:26 +0000 (10:03 +0200)

builtin/gc.c: add missing newline in message

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase -i -p: include non-first-parent commits in todo... Andrew Wong Sat, 18 Jun 2011 22:12:01 +0000 (18:12 -0400)

rebase -i -p: include non-first-parent commits in todo list

Consider this graph:

D---E (topic, HEAD)
/ /
A---B---C (master)
\
F (topic2)

and the following three commands:
1. git rebase -i -p A
2. git rebase -i -p --onto F A
3. git rebase -i -p B

Currently, (1) and (2) will pick B, D, C, and E onto A and F,
respectively. However, (3) will only pick D and E onto B, but not C,
which is inconsistent with (1) and (2). As a result, we cannot modify C
during the interactive-rebase.

The current behavior also creates a bug if we do:
4. git rebase -i -p C

In (4), E is never picked. And since interactive-rebase resets "HEAD"
to "onto" before picking any commits, D and E are lost after the
interactive-rebase.

This patch fixes the inconsistency and bug by ensuring that all children
of upstream are always picked. This essentially reverts the commit:
d80d6bc146232d81f1bb4bc58e5d89263fd228d4

When compiling the todo list, commits reachable from "upstream" should
never be skipped under any conditions. Otherwise, we lose the ability
to modify them like (3), and create a bug like (4).

Two of the tests contain a scenario like (3). Since the new behavior
added more commits for picking, these tests need to be updated to
account for the additional pick lines. A new test has also been added
for (4).

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tests: link shell libraries into valgrind directoryJeff King Fri, 17 Jun 2011 20:36:32 +0000 (16:36 -0400)

tests: link shell libraries into valgrind directory

When we run tests under valgrind, we symlink anything
executable that starts with git-* or test-* into a special
valgrind bin directory, and then make that our
GIT_EXEC_PATH.

However, shell libraries like git-sh-setup do not have the
executable bit marked, and did not get symlinked. This
means that any test looking for shell libraries in our
exec-path would fail to find them, even though that is a
fine thing to do when testing against a regular git build
(or in a git install, for that matter).

t2300 demonstrated this problem. The fix is to symlink these
shell libraries directly into the valgrind directory.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/Makefile: pass test opts to valgrind target properlyJeff King Fri, 17 Jun 2011 08:29:57 +0000 (04:29 -0400)

t/Makefile: pass test opts to valgrind target properly

The valgrind target just reinvokes make with GIT_TEST_OPTS
set to "--valgrind". However, it does this using an
environment variable, which means GIT_TEST_OPTS in your
config.mak would override it, and "make valgrind" would
simply run the test suite without valgrind on.

Instead, we should pass GIT_TEST_OPTS on the command-line,
overriding what's in config.mak, and take care to append to
whatever the user has there already.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'ab/i18n-scripts-basic'Junio C Hamano Fri, 17 Jun 2011 18:40:32 +0000 (11:40 -0700)

Merge branch 'ab/i18n-scripts-basic'

* ab/i18n-scripts-basic:
sh-i18n--envsubst.c: do not #include getopt.h

sh-i18n--envsubst.c: do not #include getopt.hBrandon Casey Fri, 17 Jun 2011 18:19:26 +0000 (11:19 -0700)

sh-i18n--envsubst.c: do not #include getopt.h

The getopt.h header file is not used. It's inclusion is left over from the
original version of this source. Additionally, getopt.h does not exist on
all platforms (SunOS 5.7) and will cause a compilation failure. So, let's
remove it.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config.c: Make git_config() work correctly when called... Ramsay Jones Thu, 16 Jun 2011 20:24:51 +0000 (21:24 +0100)

config.c: Make git_config() work correctly when called recursively

On Cygwin, this fixes a test failure in t3301-notes.sh (test 98,
"git notes copy --for-rewrite (disabled)").

The test failure is caused by a recursive call to git_config() which
has the effect of skipping to the end-of-file while processing the
"notes.rewriteref" config variable. Thus, any config variables that
appear after "notes.rewriteref" are simply ignored by git_config().
Also, we note that the original FILE handle is leaked as a result
of the recursive call.

The recursive call to git_config() is due to the "schizophrenic stat"
functions on cygwin, where one of two different implementations of
the l/stat functions is selected lazily, depending on some config
variables.

In this case, the init_copy_notes_for_rewrite() function calls
git_config() with the notes_rewrite_config() callback function.
This callback, while processing the "notes.rewriteref" variable,
in turn calls string_list_add_refs_by_glob() to process the
associated ref value. This eventually leads to a call to the
get_ref_dir() function, which in turn calls stat(). On cygwin,
the stat() macro leads to an indirect call to cygwin_stat_stub()
which, via init_stat(), then calls git_config() in order to
determine which l/stat implementation to bind to.

In order to solve this problem, we modify git_config() so that the
global state variables used by the config reading code is packaged
up and managed on a local state stack.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t1301-*.sh: Fix the 'forced modes' test on cygwinRamsay Jones Thu, 16 Jun 2011 20:23:14 +0000 (21:23 +0100)

t1301-*.sh: Fix the 'forced modes' test on cygwin

The 'forced modes' test fails on cygwin because the post-update
hook loses it's executable bit when copied from the templates
directory by git-init. The template loses it's executable bit
because the lstat() function resolves to the "native Win32 API"
implementation.

This call to lstat() happens after git-init has set the "git_dir"
(so has_git_dir() returns true), but before the configuration has
been fully initialised. At this point git_config() does not find
any config files to parse and returns 0. Unfortunately, the code
used to determine the cygwin l/stat() function bindings did not
check the return from git_config() and assumed that the config
was complete and accessible once "git_dir" was set.

In order to fix the test, we simply change the binding code to
test the return value from git_config(), to ensure that it actually
had config values to read, before determining the requested binding.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

help.c: Fix detection of custom merge strategy on cygwinRamsay Jones Thu, 16 Jun 2011 20:22:16 +0000 (21:22 +0100)

help.c: Fix detection of custom merge strategy on cygwin

Test t7606-merge-custom.sh fails on cygwin when git-merge fails
with an "Could not find merge strategy 'theirs'" error, despite
the test correctly preparing an (executable) git-merge-theirs
script.

The cause of the failure is the mis-detection of the executable
status of the script, by the is_executable() function, while the
load_command_list() function is searching the path for additional
merge strategy programs.

Note that the l/stat() "functions" on cygwin are somewhat
schizophrenic (see commits adbc0b6, 7faee6b and 7974843), and
their behaviour depends on the timing of various git setup and
config function calls. In particular, until the "git_dir" has
been set (have_git_dir() returns true), the real cygwin (POSIX
emulating) l/stat() functions are called. Once "git_dir" has
been set, the "native Win32 API" implementations of l/stat()
may, or may not, be called depending on the setting of the
core.filemode and core.ignorecygwinfstricks config variables.

We also note that, since commit c869753, core.filemode is forced
to false, even on NTFS, by git-init and git-clone. A user (or a
test) can, of course, reset core.filemode to true explicitly if
the filesystem supports it (and he doesn't use any problematic
windows software). The test-suite currently runs all tests on
cygwin with core.filemode set to false.

Given the above, we see that the built-in merge strategies are
correctly detected as executable, since they are checked for
before "git_dir" is set, whereas all custom merge strategies are
not, since they are checked for after "git_dir" is set.

In order to fix the mis-detection problem, we change the code in
is_executable() to re-use the conditional WIN32 code section,
which actually looks at the content of the file to determine if
the file is executable. On cygwin we also make the additional
code conditional on the executable bit of the file mode returned
by the initial stat() call. (only the real cygwin function would
set the executable bit in the file mode.)

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Fix typo: existant->existentDmitry Ivankov Thu, 16 Jun 2011 13:42:48 +0000 (19:42 +0600)

Fix typo: existant->existent

refs.c had a error message "Trying to write ref with nonexistant object".
And no tests relied on the wrong spelling.
Also typo was present in some test scripts internals, these tests still pass.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 1.7.6-rc2 v1.7.6-rc2Junio C Hamano Thu, 16 Jun 2011 16:21:36 +0000 (09:21 -0700)

Git 1.7.6-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive: reorder option parsing and config readingJeff King Wed, 15 Jun 2011 22:31:28 +0000 (18:31 -0400)

archive: reorder option parsing and config reading

The archive command does three things during its
initialization phase:

1. parse command-line options

2. setup the git directory

3. read config

During phase (1), if we see any options that do not require
a git directory (like "--list"), we handle them immediately
and exit, making it safe to abort step (2) if we are not in
a git directory.

Step (3) must come after step (2), since the git directory
may influence configuration. However, this leaves no
possibility of configuration from step (3) impacting the
command-line options in step (1) (which is useful, for
example, for supporting user-configurable output formats).

Instead, let's reorder this to:

1. setup the git directory, if it exists

2. read config

3. parse command-line options

4. if we are not in a git repository, die

This should have the same external behavior, but puts
configuration before command-line parsing.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/gitweb-lib.sh: skip gitweb tests when perl dependenci... Junio C Hamano Wed, 15 Jun 2011 16:54:15 +0000 (09:54 -0700)

t/gitweb-lib.sh: skip gitweb tests when perl dependencies are not met

Linus noticed that we go ahead testing gitweb and fail miserably on a
box with Perl but not perl-CGI library. We already have a code to detect
lack of Perl and refrain from testing gitweb in t/gitweb-lib.sh (by the
way, shouldn't it be called t/lib-gitweb.sh?), so let's extend it
to cover this case as well.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Update the Interix default build configuration.Markus Duft Wed, 15 Jun 2011 11:34:18 +0000 (13:34 +0200)

Update the Interix default build configuration.

Currently, on Interix, libsuacomp is required for building (see [1]).

Since suacomp provides poll() and inttypes.h for all interix versions,
remove NO_*=YesPlease that are no longer necessary.

Interix versions 3 and 5 miss struct sockaddr_storage, so make git
avoid using it.

Same for FNMATCH_CASEFOLD, which does not exist for Interix 3 and 5.

[1] http://news.gmane.org/find-root.php?message_id=%3c4DDF4440.4040405%40gentoo.org%3e

Signed-off-by: Markus Duft <mduft@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: allow space as delimiter in mime.typesLudwig Nussel Wed, 15 Jun 2011 06:10:08 +0000 (08:10 +0200)

gitweb: allow space as delimiter in mime.types

in openSUSE /etc/mime.types has only spaces. I don't know if there's
a canonical reference that says that only tabs are allowed. Mutt at
least also accepts spaces. So make gitweb more liberal too.

Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-submodule.sh: clarify the "should we die now" logicJunio C Hamano Mon, 13 Jun 2011 19:17:52 +0000 (12:17 -0700)

git-submodule.sh: clarify the "should we die now" logic

Earlier the decision to stop or continue was made on the $action variable
that was set by inspecting $update_module variable. The former is a
redundant variable and will be removed in another topic.

Decide upon inspecting $update_module if a failure should cascade up to
cause us immediately stop, and use a variable that means just that, to
clarify the logic.

Incidentally this also makes the merge with the other topic slightly
easier and cleaner to understand.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule update: continue when a checkout failsFredrik Gustafsson Mon, 13 Jun 2011 17:15:26 +0000 (19:15 +0200)

submodule update: continue when a checkout fails

"git submodule update" stops at the first error and gives control
back to the user. Only after the user fixes the problematic
submodule and runs "git submodule update" again, the second error
is found. And the user needs to repeat until all the problems are
found and fixed one by one. This is tedious.

Instead, the command can remember which submodules it had trouble with,
continue updating the ones it can, and report which ones had errors at
the end. The user can run "git submodule update", find all the ones that
need minor fixing (e.g. working tree was dirty) to fix them in a single
pass. Then another "git submodule update" can be run to update all.

Note that the problematic submodules are skipped only when they are to
be integrated with a safer value of submodule.<name>.update option,
namely "checkout". Fixing a failure in a submodule that uses "rebase" or
"merge" may need an involved conflict resolution by the user, and
leaving too many submodules in states that need resolution would not
reduce the mental burden on the user.

Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
Mentored-by: Jens Lehmann <Jens.Lehmann@web.de>
Mentored-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-sh-setup: add die_with_statusFredrik Gustafsson Thu, 9 Jun 2011 07:47:02 +0000 (09:47 +0200)

git-sh-setup: add die_with_status

This behaves similar to "die" but can exit with status different from the
usual 1.

Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
Mentored-by: Jens Lehmann <Jens.Lehmann@web.de>
Mentored-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

default core.clockskew variable to one dayJeff King Sat, 11 Jun 2011 19:04:10 +0000 (19:04 +0000)

default core.clockskew variable to one day

This is the slop value used by name-rev, so presumably is a
reasonable default.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

limit "contains" traversals based on commit timestampJeff King Sat, 11 Jun 2011 19:04:09 +0000 (19:04 +0000)

limit "contains" traversals based on commit timestamp

When looking for commits that contain other commits (e.g.,
via "git tag --contains"), we can end up traversing useless
portions of the graph. For example, if I am looking for a
tag that contains a commit made last week, there is not much
point in traversing portions of the history graph made five
years ago.

This optimization can provide massive speedups. For example,
doing "git tag --contains HEAD~200" in the linux-2.6
repository goes from:

real 0m5.302s
user 0m5.116s
sys 0m0.184s

to:

real 0m0.030s
user 0m0.020s
sys 0m0.008s

The downside is that we will no longer find some answers in
the face of extreme clock skew, as we will stop the
traversal early when seeing commits skewed too far into the
past.

Name-rev already implements a similar optimization, using a
"slop" of one day to allow for a certain amount of clock
skew in commit timestamps. This patch introduces a
"core.clockskew" variable, which allows specifying the
allowable amount of clock skew in seconds. For safety, it
defaults to "none", causing a full traversal (i.e., no
change in behavior from previous versions).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tag: speed up --contains calculationJeff King Sat, 11 Jun 2011 19:04:08 +0000 (19:04 +0000)

tag: speed up --contains calculation

When we want to know if commit A contains commit B (or any
one of a set of commits, B through Z), we generally
calculate the merge bases and see if B is a merge base of A
(or for a set, if any of the commits B through Z have that
property).

When we are going to check a series of commits A1 through An
to see whether each contains B (e.g., because we are
deciding which tags to show with "git tag --contains"), we
do a series of merge base calculations. This can be very
expensive, as we repeat a lot of traversal work.

Instead, let's leverage the fact that we are going to use
the same --contains list for each tag, and mark areas of the
commit graph is definitely containing those commits, or
definitely not containing those commits. Later tags can then
stop traversing as soon as they see a previously calculated
answer.

This sped up "git tag --contains HEAD~200" in the linux-2.6
repository from:

real 0m15.417s
user 0m15.197s
sys 0m0.220s

to:

real 0m5.329s
user 0m5.144s
sys 0m0.184s

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

zlib: allow feeding more than 4GB in one goJunio C Hamano Fri, 10 Jun 2011 19:15:17 +0000 (12:15 -0700)

zlib: allow feeding more than 4GB in one go

Update zlib_post_call() that adjusts the wrapper's notion of avail_in and
avail_out to what came back from zlib, so that the callers can feed
buffers larger than than 4GB to the API.

When underlying inflate/deflate stopped processing because we fed a buffer
larger than 4GB limit, detect that case, update the state variables, and
let the zlib function work another round.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

zlib: zlib can only process 4GB at a timeJunio C Hamano Fri, 10 Jun 2011 18:52:15 +0000 (11:52 -0700)

zlib: zlib can only process 4GB at a time

The size of objects we read from the repository and data we try to put
into the repository are represented in "unsigned long", so that on larger
architectures we can handle objects that weigh more than 4GB.

But the interface defined in zlib.h to communicate with inflate/deflate
limits avail_in (how many bytes of input are we calling zlib with) and
avail_out (how many bytes of output from zlib are we ready to accept)
fields effectively to 4GB by defining their type to be uInt.

In many places in our code, we allocate a large buffer (e.g. mmap'ing a
large loose object file) and tell zlib its size by assigning the size to
avail_in field of the stream, but that will truncate the high octets of
the real size. The worst part of this story is that we often pass around
z_stream (the state object used by zlib) to keep track of the number of
used bytes in input/output buffer by inspecting these two fields, which
practically limits our callchain to the same 4GB limit.

Wrap z_stream in another structure git_zstream that can express avail_in
and avail_out in unsigned long. For now, just die() when the caller gives
a size that cannot be given to a single zlib call. In later patches in the
series, we would make git_inflate() and git_deflate() internally loop to
give callers an illusion that our "improved" version of zlib interface can
operate on a buffer larger than 4GB in one go.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

zlib: wrap deflateBound() tooJunio C Hamano Fri, 10 Jun 2011 18:18:17 +0000 (11:18 -0700)

zlib: wrap deflateBound() too

Signed-off-by: Junio C Hamano <gitster@pobox.com>

zlib: wrap deflate side of the APIJunio C Hamano Fri, 10 Jun 2011 17:55:10 +0000 (10:55 -0700)

zlib: wrap deflate side of the API

Wrap deflateInit, deflate, and deflateEnd for everybody, and the sole use
of deflateInit2 in remote-curl.c to tell the library to use gzip header
and trailer in git_deflate_init_gzip().

There is only one caller that cares about the status from deflateEnd().
Introduce git_deflate_end_gently() to let that sole caller retrieve the
status and act on it (i.e. die) for now, but we would probably want to
make inflate_end/deflate_end die when they ran out of memory and get
rid of the _gently() kind.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

zlib: wrap inflateInit2 used to accept only for gzip... Junio C Hamano Fri, 10 Jun 2011 17:45:29 +0000 (10:45 -0700)

zlib: wrap inflateInit2 used to accept only for gzip format

http-backend.c uses inflateInit2() to tell the library that it wants to
accept only gzip format. Wrap it in a helper function so that readers do
not have to wonder what the magic numbers 15 and 16 are for.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

zlib: wrap remaining calls to direct inflate/inflateEndJunio C Hamano Fri, 10 Jun 2011 17:39:27 +0000 (10:39 -0700)

zlib: wrap remaining calls to direct inflate/inflateEnd

Two callsites in http-backend.c to inflate() and inflateEnd()
were not using git_ prefixed versions. After this, running

$ find all objects -print | xargs nm -ugo | grep inflate

shows only zlib.c makes direct calls to zlib for inflate operation,
except for a singlecall to inflateInit2 in http-backend.c

Signed-off-by: Junio C Hamano <gitster@pobox.com>

zlib wrapper: refactor error message formatterJunio C Hamano Fri, 10 Jun 2011 17:31:34 +0000 (10:31 -0700)

zlib wrapper: refactor error message formatter

Before refactoring the main part of the wrappers, first move the
logic to convert error status that come back from zlib to string
to a helper function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: do not misparse nonnumeric content tag files... Jonathan Nieder Thu, 9 Jun 2011 07:08:57 +0000 (02:08 -0500)

gitweb: do not misparse nonnumeric content tag files that contain a digit

v1.7.6-rc0~27^2~4 (gitweb: Change the way "content tags" ('ctags') are
handled, 2011-04-29) tried to make gitweb's tag cloud feature more
intuitive for webmasters by checking whether the ctags/<label> under
a project's .git dir contains a number (representing the strength of
association to <label>) before treating it as one.

With that change, after putting '$feature{'ctags'}{'default'} = [1];'
in your $GITWEB_CONFIG, you could do

echo Linux >.git/ctags/linux

and gitweb would treat that as a request to tag the current repository
with the Linux tag, instead of the previous behavior of writing an
error page embedded in the projects list that triggers error messages
from Chromium and Firefox about malformed XML.

Unfortunately the pattern (\d+) used to match numbers is too loose,
and the "XML declaration allowed only at the start of the document"
error can still be experienced if you write "Linux-2.6" in place of
"Linux" in the example above. Fix it by tightening the pattern to
^\d+$.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 1.7.6-rc1 v1.7.6-rc1Junio C Hamano Thu, 9 Jun 2011 01:29:48 +0000 (18:29 -0700)

Git 1.7.6-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'maint'Junio C Hamano Thu, 9 Jun 2011 01:13:39 +0000 (18:13 -0700)

Merge branch 'maint'

* maint:
fetch: do not leak a refspec

Document the underlying protocol used by shallow reposi... Alex Neronskiy Wed, 8 Jun 2011 22:11:51 +0000 (15:11 -0700)

Document the underlying protocol used by shallow repositories and --depth commands.

Explain the exchange that occurs between a client and server when
the client is requesting shallow history and/or is already using
a shallow repository.

Signed-off-by: Alex Neronskiy <zakmagnus@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Fix documentation of fetch-pack that implies that the... Alex Neronskiy Wed, 8 Jun 2011 22:11:50 +0000 (15:11 -0700)

Fix documentation of fetch-pack that implies that the client can disconnect after sending wants.

Specify conditions under which the client can terminate the connection
early. Previously, an unintended behavior was possible which could
confuse servers.

Based-on-patch-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Alex Neronskiy <zakmagnus@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch: do not leak a refspecJim Meyering Wed, 8 Jun 2011 20:06:33 +0000 (22:06 +0200)

fetch: do not leak a refspec

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file.c: "legacy" is really the current formatJunio C Hamano Wed, 8 Jun 2011 18:29:01 +0000 (11:29 -0700)

sha1_file.c: "legacy" is really the current format

Every time I look at the read-loose-object codepath, legacy_loose_object()
function makes my brain go through mental contortion. When we were playing
with the experimental loose object format, it may have made sense to call
the traditional format "legacy", in the hope that the experimental one
will some day replace it to become official, but it never happened.

This renames the function (and negates its return value) to detect if we
are looking at the experimental format, and move the code around in its
caller which used to do "if we are looing at legacy, do this special case,
otherwise the normal case is this". The codepath to read from the loose
objects in experimental format is the "unlikely" case.

Someday after Git 2.0, we should drop the support of this format.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

verify_dotfile(): do not assume '/' is the path seperatorTheo Niessink Wed, 8 Jun 2011 12:04:41 +0000 (14:04 +0200)

verify_dotfile(): do not assume '/' is the path seperator

verify_dotfile() currently assumes that the path seperator is '/', but on
Windows it can also be '\\', so use is_dir_sep() instead.

Signed-off-by: Theo Niessink <theo@taletn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

verify_path(): simplify check at the directory boundaryJunio C Hamano Tue, 7 Jun 2011 03:49:06 +0000 (20:49 -0700)

verify_path(): simplify check at the directory boundary

We simply want to say "At a directory boundary, be careful with a name
that begins with a dot, forbid a name that ends with the boundary
character or has duplicated bounadry characters".

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'jc/magic-pathspec'Junio C Hamano Tue, 7 Jun 2011 15:32:42 +0000 (08:32 -0700)

Merge branch 'jc/magic-pathspec'

* jc/magic-pathspec:
t3703: skip more tests using colons in file names on Windows

t3703: skip more tests using colons in file names on... Alex Riesen Tue, 7 Jun 2011 09:49:44 +0000 (11:49 +0200)

t3703: skip more tests using colons in file names on Windows

Use the same test and prerequisite as introduced in similar
fix in 650af7ae8bdf92bd92df2.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule add: clean up duplicated codeJens Lehmann Mon, 6 Jun 2011 19:58:43 +0000 (21:58 +0200)

submodule add: clean up duplicated code

In cmd_add() the switch statement used to resolve a relative url was
present twice. Remove the second one and use the realrepo variable set
by the first one (lines 194 ff.) instead.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule add: allow relative repository path even... Jens Lehmann Mon, 6 Jun 2011 19:58:04 +0000 (21:58 +0200)

submodule add: allow relative repository path even when no url is set

Adding a submodule with a relative repository path did only succeed when
the superproject's default remote was set. But when that is unset, the
superproject is its own authoritative upstream, so lets use its working
directory as upstream instead.

This allows users to set up a new superpoject where the submodules urls
are configured relative to the superproject's upstream while its default
remote can be configured later.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule add: test failure when url is not configured... Jens Lehmann Mon, 6 Jun 2011 19:57:01 +0000 (21:57 +0200)

submodule add: test failure when url is not configured in superproject

This documents the current behavior (submodule add with the url set in the
superproject is already tested in t7403, t7406, t7407 and t7506).

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>