gitweb.git
read_in_full: always report errorsJeff King Thu, 26 May 2011 16:30:27 +0000 (12:30 -0400)

read_in_full: always report errors

The read_in_full function repeatedly calls read() to fill a
buffer. If the first read() returns an error, we notify the
caller by returning the error. However, if we read some data
and then get an error on a subsequent read, we simply return
the amount of data that we did read, and the caller is
unaware of the error.

This makes the tradeoff that seeing the partial data is more
important than the fact that an error occurred. In practice,
this is generally not the case; we care more if an error
occurred, and should throw away any partial data.

I audited the current callers. In most cases, this will make
no difference at all, as they do:

if (read_in_full(fd, buf, size) != size)
error("short read");

However, it will help in a few cases:

1. In sha1_file.c:index_stream, we would fail to notice
errors in the incoming stream.

2. When reading symbolic refs in resolve_ref, we would
fail to notice errors and potentially use a truncated
ref name.

3. In various places, we will get much better error
messages. For example, callers of safe_read would
erroneously print "the remote end hung up unexpectedly"
instead of showing the read error.

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

remote: allow "-t" with fetch mirrorsJeff King Thu, 26 May 2011 15:11:00 +0000 (11:11 -0400)

remote: allow "-t" with fetch mirrors

Commit 13fc2c1 (remote: disallow some nonsensical option
combinations, 2011-03-30) made it impossible to use "remote
add -t foo --mirror". The argument was that specifying
specific branches is useless because:

1. Push mirrors do not want a refspec at all.

2. The point of fetch mirroring is to use a broad refspec
like "refs/*", but using "-t" overrides that.

Point (1) is valid; "-t" with push mirrors is useless. But
point (2) ignored another side effect of using --mirror: it
fetches the refs directly into the refs/ namespace as they
are found upstream, instead of placing them in a
separate-remote layout.

So 13fc2c1 was overly constrictive, and disallowed
reasonable specific-branch mirroring, like:

git remote add -t heads/foo -t heads/bar --mirror=fetch

which makes the local "foo" and "bar" branches direct
mirrors of the remote, but does not fetch anything else.

This patch restores the original behavior, but only for
fetch mirrors.

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

read_gitfile_gently: use ssize_t to hold read resultJeff King Thu, 26 May 2011 16:28:44 +0000 (12:28 -0400)

read_gitfile_gently: use ssize_t to hold read result

Otherwise, a negative error return becomes a very large read
value. We catch this in practice because we compare the
expected and actual numbers of bytes (and you are not likely
to be reading (size_t)-1 bytes), but this makes the
correctness a little more obvious.

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

remove tests of always-false conditionJim Meyering Thu, 26 May 2011 13:58:16 +0000 (15:58 +0200)

remove tests of always-false condition

* fsck.c (fsck_error_function): Don't test obj->sha1 == 0.
It can never be true, since that sha1 member is an array.
* transport.c (set_upstreams): Likewise for ref->new_sha1.

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

plug a DIR buffer leak in rerere.cJim Meyering Thu, 26 May 2011 13:55:50 +0000 (15:55 +0200)

plug a DIR buffer leak in rerere.c

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

rerere.c: diagnose a corrupt MERGE_RR when hitting... Jim Meyering Thu, 26 May 2011 13:54:18 +0000 (15:54 +0200)

rerere.c: diagnose a corrupt MERGE_RR when hitting EOF between TAB and '\0'

If we reach EOF after the SHA1-then-TAB, yet before the NUL that
terminates each file name, we would fill the file name buffer with \255
bytes resulting from the repeatedly-failing fgetc (returns EOF/-1) and
ultimately complain about "filename too long", because no NUL was
encountered.

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

Update 1.7.6 draft release notesJunio C Hamano Thu, 26 May 2011 17:41:33 +0000 (10:41 -0700)

Update 1.7.6 draft release notes

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

Merge branch 'jn/userdiff-perl-updates'Junio C Hamano Thu, 26 May 2011 17:32:25 +0000 (10:32 -0700)

Merge branch 'jn/userdiff-perl-updates'

* jn/userdiff-perl-updates:
userdiff/perl: tighten BEGIN/END block pattern to reject here-doc delimiters
tests: make test_expect_code quieter on success
userdiff/perl: catch sub with brace on second line
userdiff/perl: match full line of POD headers
userdiff/perl: anchor "sub" and "package" patterns on the left
t4018 (funcname patterns): minor cleanups
t4018 (funcname patterns): make configuration easier to track
t4018 (funcname patterns): make .gitattributes state easier to track

Merge branch 'rg/no-gecos-in-pwent'Junio C Hamano Thu, 26 May 2011 17:32:19 +0000 (10:32 -0700)

Merge branch 'rg/no-gecos-in-pwent'

* rg/no-gecos-in-pwent:
ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd

Conflicts:
Makefile

Merge branch 'jk/fetch-mark-complete-optimization'Junio C Hamano Thu, 26 May 2011 17:32:11 +0000 (10:32 -0700)

Merge branch 'jk/fetch-mark-complete-optimization'

* jk/fetch-mark-complete-optimization:
fetch: avoid repeated commits in mark_complete

Merge branch 'jn/gitweb-js'Junio C Hamano Thu, 26 May 2011 17:31:57 +0000 (10:31 -0700)

Merge branch 'jn/gitweb-js'

* jn/gitweb-js:
gitweb: Make JavaScript ability to adjust timezones configurable
gitweb.js: Add UI for selecting common timezone to display dates
gitweb: JavaScript ability to adjust time based on timezone
gitweb: Unify the way long timestamp is displayed
gitweb: Refactor generating of long dates into format_timestamp_html
gitweb.js: Provide getElementsByClassName method (if it not exists)
gitweb.js: Introduce code to handle cookies from JavaScript
gitweb.js: Extract and improve datetime handling
gitweb.js: Provide default values for padding in padLeftStr and padLeft
gitweb.js: Update and improve comments in JavaScript files
gitweb: Split JavaScript for maintability, combining on build

Merge branch 'jn/ctags-more'Junio C Hamano Thu, 26 May 2011 17:31:53 +0000 (10:31 -0700)

Merge branch 'jn/ctags-more'

* jn/ctags-more:
gitweb: Optional grouping of projects by category
gitweb: Modularized git_get_project_description to be more generic
gitweb: Split git_project_list_body in two functions

Merge branch 'jc/require-work-tree-exists'Junio C Hamano Thu, 26 May 2011 17:31:47 +0000 (10:31 -0700)

Merge branch 'jc/require-work-tree-exists'

* jc/require-work-tree-exists:
require-work-tree wants more than what its name says

Sync with 1.7.5.3Junio C Hamano Thu, 26 May 2011 17:30:28 +0000 (10:30 -0700)

Sync with 1.7.5.3

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

Git 1.7.5.3 v1.7.5.3Junio C Hamano Thu, 26 May 2011 16:45:29 +0000 (09:45 -0700)

Git 1.7.5.3

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

Merge branch 'maint-1.7.4' into maintJunio C Hamano Thu, 26 May 2011 17:29:24 +0000 (10:29 -0700)

Merge branch 'maint-1.7.4' into maint

* maint-1.7.4:

Merge branch 'jk/git-connection-deadlock-fix' into... Junio C Hamano Thu, 26 May 2011 17:28:10 +0000 (10:28 -0700)

Merge branch 'jk/git-connection-deadlock-fix' into maint-1.7.4

* jk/git-connection-deadlock-fix:
test core.gitproxy configuration
send-pack: avoid deadlock on git:// push with failed pack-objects
connect: let callers know if connection is a socket
connect: treat generic proxy processes like ssh processes

Conflicts:
connect.c

Merge branch 'js/maint-send-pack-stateless-rpc-deadlock... Junio C Hamano Thu, 26 May 2011 17:27:55 +0000 (10:27 -0700)

Merge branch 'js/maint-send-pack-stateless-rpc-deadlock-fix' into maint-1.7.4

* js/maint-send-pack-stateless-rpc-deadlock-fix:
sideband_demux(): fix decl-after-stmt
send-pack: unbreak push over stateless rpc
send-pack: avoid deadlock when pack-object dies early

Merge branch 'jk/maint-upload-pack-shallow' into maint... Junio C Hamano Thu, 26 May 2011 17:27:29 +0000 (10:27 -0700)

Merge branch 'jk/maint-upload-pack-shallow' into maint-1.7.4

* jk/maint-upload-pack-shallow:
upload-pack: start pack-objects before async rev-list

Merge branch 'jm/maint-diff-words-with-sbe' into maintJunio C Hamano Thu, 26 May 2011 16:43:00 +0000 (09:43 -0700)

Merge branch 'jm/maint-diff-words-with-sbe' into maint

* jm/maint-diff-words-with-sbe:
do not read beyond end of malloc'd buffer

Merge branch 'kk/maint-prefix-in-config-mak' into maintJunio C Hamano Thu, 26 May 2011 16:42:12 +0000 (09:42 -0700)

Merge branch 'kk/maint-prefix-in-config-mak' into maint

* kk/maint-prefix-in-config-mak:
Honor $(prefix) set in config.mak* when defining ETC_GIT*
Revert "Honor $(prefix) set in config.mak* when defining ETC_GIT* and sysconfdir"
Honor $(prefix) set in config.mak* when defining ETC_GIT* and sysconfdir

Merge branch 'mg/diff-uiconfig-doc' into maintJunio C Hamano Thu, 26 May 2011 16:41:11 +0000 (09:41 -0700)

Merge branch 'mg/diff-uiconfig-doc' into maint

* mg/diff-uiconfig-doc:
config.txt,diff-options.txt: porcelain vs. plumbing for color.diff

Merge branch 'ft/gitweb-tar-with-gzip-n' into maintJunio C Hamano Thu, 26 May 2011 16:40:50 +0000 (09:40 -0700)

Merge branch 'ft/gitweb-tar-with-gzip-n' into maint

* ft/gitweb-tar-with-gzip-n:
gitweb: supply '-n' to gzip for identical output

Merge branch 'ss/doc-svn' into maintJunio C Hamano Thu, 26 May 2011 16:39:40 +0000 (09:39 -0700)

Merge branch 'ss/doc-svn' into maint

* ss/doc-svn:
remove noise and inaccuracies from git-svn docs

Merge branch 'jn/format-patch-doc' into maintJunio C Hamano Thu, 26 May 2011 16:39:33 +0000 (09:39 -0700)

Merge branch 'jn/format-patch-doc' into maint

* jn/format-patch-doc:
Documentation/format-patch: suggest Toggle Word Wrap add-on for Thunderbird
Documentation: publicize hints for sending patches with GMail
Documentation: publicize KMail hints for sending patches inline
Documentation: hints for sending patches inline with Thunderbird
Documentation: explain how to check for patch corruption

Merge branch 'jc/maint-pathspec-stdin-and-cmdline'... Junio C Hamano Thu, 26 May 2011 16:38:44 +0000 (09:38 -0700)

Merge branch 'jc/maint-pathspec-stdin-and-cmdline' into maint

* jc/maint-pathspec-stdin-and-cmdline:
setup_revisions(): take pathspec from command line and --stdin correctly

Merge branch 'jk/cherry-pick-root-with-resolve' into... Junio C Hamano Thu, 26 May 2011 16:37:41 +0000 (09:37 -0700)

Merge branch 'jk/cherry-pick-root-with-resolve' into maint

* jk/cherry-pick-root-with-resolve:
t3503: test cherry picking and reverting root commits
revert: allow reverting a root commit
cherry-pick: handle root commits with external strategies

Merge branch 'rg/copy-gecos-username' into maintJunio C Hamano Thu, 26 May 2011 16:37:04 +0000 (09:37 -0700)

Merge branch 'rg/copy-gecos-username' into maint

* rg/copy-gecos-username:
copy_gecos: fix not adding nlen to len when processing "&"

Merge branch 'fc/completion-zsh' into maintJunio C Hamano Thu, 26 May 2011 16:36:33 +0000 (09:36 -0700)

Merge branch 'fc/completion-zsh' into maint

* fc/completion-zsh:
git-completion: fix regression in zsh support

Merge branch 'jk/git-connection-deadlock-fix' into... Junio C Hamano Thu, 26 May 2011 16:33:25 +0000 (09:33 -0700)

Merge branch 'jk/git-connection-deadlock-fix' into maint

* jk/git-connection-deadlock-fix:
test core.gitproxy configuration
send-pack: avoid deadlock on git:// push with failed pack-objects
connect: let callers know if connection is a socket
connect: treat generic proxy processes like ssh processes

Conflicts:
connect.c

Merge branch 'js/maint-send-pack-stateless-rpc-deadlock... Junio C Hamano Thu, 26 May 2011 16:32:14 +0000 (09:32 -0700)

Merge branch 'js/maint-send-pack-stateless-rpc-deadlock-fix' into maint

* js/maint-send-pack-stateless-rpc-deadlock-fix:
sideband_demux(): fix decl-after-stmt
send-pack: unbreak push over stateless rpc
send-pack: avoid deadlock when pack-object dies early

compat/fnmatch/fnmatch.c: give a fall-back definition... Junio C Hamano Thu, 26 May 2011 16:25:47 +0000 (09:25 -0700)

compat/fnmatch/fnmatch.c: give a fall-back definition for NULL

Somebody tried to compile fnmatch.c compatibility file on Interix and got
an error because no header included in the file on that platform defined
NULL. It usually comes from stddef.h and indirectly from other headers
like string.h, unistd.h, stdio.h, stdlib.h, etc., but with the way we
compile this file from our Makefile, inclusion of the header files that
are expected to define NULL in fnmatch.c do not happen because they are
protected with "#ifdef STDC_HEADERS", etc. which we do not pass.

As the least-impact workaround, give a fall-back definition when none of
the headers define NULL.

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

Merge branch 'svn-fe-maint' of git://repo.or.cz/git... Junio C Hamano Thu, 26 May 2011 15:52:11 +0000 (08:52 -0700)

Merge branch 'svn-fe-maint' of git://repo.or.cz/git/jrn into maint

* 'svn-fe-maint' of git://repo.or.cz/git/jrn:
Revert "t0081 (line-buffer): add buffering tests"

Merge branch 'jc/bigfile'Junio C Hamano Wed, 25 May 2011 23:23:26 +0000 (16:23 -0700)

Merge branch 'jc/bigfile'

* jc/bigfile:
Bigfile: teach "git add" to send a large file straight to a pack
index_fd(): split into two helper functions
index_fd(): turn write_object and format_check arguments into one flag

Merge branch 'js/log-abbrev-commit-config'Junio C Hamano Wed, 25 May 2011 23:23:22 +0000 (16:23 -0700)

Merge branch 'js/log-abbrev-commit-config'

* js/log-abbrev-commit-config:
Add log.abbrevCommit config variable
"git log -h": typofix misspelled 'suppress'

Merge branch 'maint'Junio C Hamano Wed, 25 May 2011 22:25:44 +0000 (15:25 -0700)

Merge branch 'maint'

* maint:
init/clone: remove short option -L and document --separate-git-dir

Teach read-tree the -n|--dry-run optionJens Lehmann Wed, 25 May 2011 20:10:41 +0000 (22:10 +0200)

Teach read-tree the -n|--dry-run option

The option can be used to check if read-tree with the same set of other
options like "-m" and "-u" would succeed without actually changing either
the index or the working tree.

The relevant tests in the t10?? range were extended to do a read-tree -n
before the real read-tree to make sure neither the index nor any local
files were changed with -n and the same exit code as without -n is
returned. The helper functions added for that purpose reside in the new
t/lib-read-tree.sh file.

The only exception is #13 in t1004 ("unlinking an un-unlink-able
symlink"). As this is an issue of wrong directory permissions it is not
detected with -n.

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

unpack-trees: add the dry_run flag to unpack_trees_optionsJens Lehmann Wed, 25 May 2011 20:07:51 +0000 (22:07 +0200)

unpack-trees: add the dry_run flag to unpack_trees_options

Until now there was no way to test if unpack_trees() with update=1 would
succeed without really updating the work tree. The reason for that is that
setting update to 0 does skip the tests for new files and deactivates the
sparse handling, thereby making that unsuitable as a dry run.

Add the new dry_run flag to struct unpack_trees_options unpack_trees().
Setting that together with the update flag will check if the work tree
update would be successful without doing it for real.

The only class of problems that is not detected at the moment are file
system conditions like ENOSPC or missing permissions. Also the index
entries of updated files are not as they would be after a real checkout
because lstat() isn't run as the files aren't updated for real.

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

userformat_find_requirements(): find requirement for... Junio C Hamano Wed, 25 May 2011 19:23:44 +0000 (12:23 -0700)

userformat_find_requirements(): find requirement for the correct format

This function was introduced in 5b16360 (pretty: Initialize notes if %N is
used, 2010-04-13) to check what kind of information the "log --format=..."
user format string wants. The function can be passed a NULL instead of a
format string to ask it to check user_format variable kept by an earlier
call to save_user_format().

But it unconditionally checked user_format and not the string it was
given. The only caller introduced by the change passes NULL, which
kept the bug unnoticed, until a new GCC noticed that there is an
assignment to fmt that is never used.

Noticed-by: Chris Wilson's compiler
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Jeff King <peff@peff.net>

gitweb: Refactor reading and parsing config file into... Jakub Narebski Wed, 25 May 2011 16:35:26 +0000 (18:35 +0200)

gitweb: Refactor reading and parsing config file into read_config_file

Beside being obvious reduction of duplicated code, this is enables us
to easily call site-wide config file in per-installation config file.

The actual update to documentation is left for next commit, because of
possible exclusive alternative (possible other next commit) of always
reading system-wide config file and relying on per-instalation config
file overriding system-wide defaults.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Acked-by: John 'Warthog9' Hawley <warthog9@kernel.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sh-18n: quell "unused variable" warningMichael J Gruber Wed, 25 May 2011 09:55:43 +0000 (11:55 +0200)

sh-18n: quell "unused variable" warning

show_variables is set but never used. Comment it out rather than remove it so
that the relation with upstream remains clear.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

init/clone: remove short option -L and document --separ... Nguyen Thai Ngoc Duy Tue, 24 May 2011 16:40:32 +0000 (23:40 +0700)

init/clone: remove short option -L and document --separate-git-dir

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

handle_options(): do not miscount how many arguments... Junio C Hamano Tue, 24 May 2011 22:50:35 +0000 (18:50 -0400)

handle_options(): do not miscount how many arguments were used

The handle_options() function advances the base of the argument array and
returns the number of arguments it used. The caller in handle_alias()
wants to reallocate the argv array it passes to this function, and
attempts to do so by subtracting the returned value to compensate for the
change handle_options() makes to the new_argv.

But handle_options() did not correctly count when "-c <config=value>" is
given, causing a wrong pointer to be passed to realloc().

Fix it by saving the original argv at the beginning of handle_options(),
and return the difference between the final value of argv, which will
relieve the places that move the array pointer from the additional burden
of keeping track of "handled" counter.

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

config: always parse GIT_CONFIG_PARAMETERS during git_c... Jeff King Tue, 24 May 2011 22:49:55 +0000 (18:49 -0400)

config: always parse GIT_CONFIG_PARAMETERS during git_config

Previously we parsed GIT_CONFIG_PARAMETERS lazily into a
linked list, and then checked that list during future
invocations of git_config. However, that ignores the fact
that the environment variable could change during our run
(e.g., because we parse more "-c" as part of an alias).

Instead, let's just re-parse the environment variable each
time. It's generally not very big, and it's no more work
than parsing the config files, anyway.

As a bonus, we can ditch all of the linked list storage code
entirely, making the code much simpler.

The test unfortunately still does not pass because of an
unrelated bug in handle_options.

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

git_config: don't peek at global config_parametersJeff King Tue, 24 May 2011 22:49:45 +0000 (18:49 -0400)

git_config: don't peek at global config_parameters

The config_parameters list in config.c is an implementation
detail of git_config_from_parameters; instead, that function
should tell us whether it found anything.

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

config: make environment parsing routines staticJeff King Tue, 24 May 2011 22:49:36 +0000 (18:49 -0400)

config: make environment parsing routines static

Nobody outside of git_config_from_parameters should need
to use the GIT_CONFIG_PARAMETERS parsing functions, so let's
make them private.

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

doc: discuss textconv versus external diff driversJeff King Tue, 24 May 2011 19:45:27 +0000 (15:45 -0400)

doc: discuss textconv versus external diff drivers

We already talk about how to use each one and how they work,
but it is a reasonable question to wonder why one might use
one over the other.

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

require-work-tree wants more than what its name saysJunio C Hamano Thu, 5 May 2011 02:11:18 +0000 (19:11 -0700)

require-work-tree wants more than what its name says

Somebody tried "git pull" from a random place completely outside the work
tree, while exporting GIT_DIR and GIT_WORK_TREE that are set to correct
places, e.g.

GIT_WORK_TREE=$HOME/git.git
GIT_DIR=$GIT_WORK_TREE/.git
export GIT_WORK_TREE GIT_DIR
cd /tmp
git pull

At the beginning of git-pull, we check "require-work-tree" and then
"cd-to-toplevel". I _think_ the original intention when I wrote the
command was "we MUST have a work tree, our $(cwd) might not be at the
top-level directory of it", and no stronger than that. That check is a
very sensible thing to do before doing cd-to-toplevel. We check that the
place we would want to go exists, and then go there.

But the implementation of require_work_tree we have today is quite
different. I don't have energy to dig the history, but currently it says:

test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
die "fatal: $0 cannot be used without a working tree."

Which is completely bogus. Even though we may happen to be just outside
of it right now, we may have a working tree that we can cd_to_toplevel
back to.

Add a function "require_work_tree_exists" that implements the check
this function originally intended (this is so that third-party scripts
that rely on the current behaviour do not have to get broken).

For now, update _no_ in-tree scripts, not even "git pull", as nobody on
the list seems to really care about the above corner case workflow that
triggered this. Scripts can be updated after vetting that they do want the
"we want to make sure the place we are going to go actually exists"
semantics.

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

gitweb: Make JavaScript ability to adjust timezones... Jakub Narebski Thu, 28 Apr 2011 19:04:11 +0000 (21:04 +0200)

gitweb: Make JavaScript ability to adjust timezones configurable

Configure JavaScript-based ability to select common timezone for git
dates via %feature mechanism, namely 'javascript-timezone' feature.

The following settings are configurable:
* default timezone (defaults to 'local' i.e. browser timezone);
this also can function as a way to disable this ability,
by setting it to false-ish value (undef or '')
* name of cookie to store user's choice of timezone
* class name to mark dates

NOTE: This is a bit of abuse of %feature system, which can store only
sequence of values, rather than dictionary (hash); usually but not
always only a single value is used.

Based-on-code-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Helped-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb.js: Add UI for selecting common timezone to... John 'Warthog9' Hawley Thu, 28 Apr 2011 19:04:10 +0000 (21:04 +0200)

gitweb.js: Add UI for selecting common timezone to display dates

This will modify HTML, add CSS rules and add DOM event handlers so
that clicking on any date (the common part, not the localtime part)
will display a drop down menu to choose the timezone to change to.

Currently menu displays only the following timezones:

utc
local
-1200
-1100
...
+1100
+1200
+1300
+1400

In timezone selection menu each timezone is +1hr to the previous. The
code is capable of handling fractional timezones, but those have not
been added to the menu.

All changes are saved to a cookie, so page changes and closing /
reopening browser retains the last known timezone setting used.

[jn: Changed from innerHTML to DOM, moved to event delegation for
onclick to trigger menu, added close button and cookie refreshing]

Helped-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: JavaScript ability to adjust time based on... John 'Warthog9' Hawley Thu, 28 Apr 2011 19:04:09 +0000 (21:04 +0200)

gitweb: JavaScript ability to adjust time based on timezone

This patch is based on Kevin Cernekee's <cernekee@gmail.com>
patch series entitled "gitweb: introduce localtime feature". While
Kevin's patch changed the server side output so that the timezone
was output from gitweb itself, this has a number of drawbacks, in
particular with respect to gitweb-caching.

This patch takes the same basic goal, display the appropriate times in
a given common timezone, and implements it in JavaScript. This
requires adding / using a new class, "datetime", to be able to find
elements to be adjusted from JavaScript. Appropriate dates are
wrapped in a span with this class.

Timezone to be used can be retrieved from "gitweb_tz" cookie, though
currently there is no way to set / manipulate this cookie from gitweb;
this is left for later commit.

Valid timezones, currently, are: "utc", "local" (which means that
timezone is taken from browser), and "+/-ZZZZ" numeric timezone as in
RFC-2822. Default timezone is "local" (currently not configurable,
left for later commit).

Fallback (should JavaScript not be enabled) is to treat dates as they
have been and display them, only, in UTC.

Pages affected:
* 'summary' view, "last change" field (commit time from latest change)
* 'log' view, author time
* 'commit' and 'commitdiff' views, author/committer time
* 'tag' view, tagger time

Based-on-code-from: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: Unify the way long timestamp is displayedJakub Narebski Thu, 28 Apr 2011 19:04:08 +0000 (21:04 +0200)

gitweb: Unify the way long timestamp is displayed

format_timestamp_html loses its "-localtime => 1" option, and now
always print the local time (in author/comitter/tagger local
timezone), with "atnight" warning if needed.

This means that both 'summary' and 'log' views now display localtime.
In the case of 'log' view this can be thought as an improvement, as
now one can easily see which commits in a series are made "atnight"
and should be examined closer.

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

gitweb: Refactor generating of long dates into format_t... Jakub Narebski Thu, 28 Apr 2011 19:04:07 +0000 (21:04 +0200)

gitweb: Refactor generating of long dates into format_timestamp_html

It is pure refactoring and doesn't change gitweb output, though this
could potentially affect 'summary', 'log', and 'commit'-like views
('commit', 'commitdiff', 'tag').

Remove print_local_time and format_local_time, as their use is now
replaced (indirectly) by using format_timestamp_html.

While at it improve whitespace formatting.

Inspired-by-code-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb.js: Provide getElementsByClassName method (if... Jakub Narebski Thu, 28 Apr 2011 19:04:06 +0000 (21:04 +0200)

gitweb.js: Provide getElementsByClassName method (if it not exists)

The code is simplified and does not support full specification of
native getElementsByClassName method, but implements just subset that
would be enough for gitweb, supporting only single class name.

Signed-off-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb.js: Introduce code to handle cookies from JavaScriptJakub Narebski Thu, 28 Apr 2011 19:04:05 +0000 (21:04 +0200)

gitweb.js: Introduce code to handle cookies from JavaScript

Introduced gitweb/static/js/cookies.js file provides functions for
setting, getting and deleting cookies.

Code taken from subsection "Cookies in JavaScript" of "Professional
JavaScript for Web Developers" by Nicholas C. Zakas and from cookie
plugin for jQuery (dual licensed under the MIT and GPL licenses).

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

gitweb.js: Extract and improve datetime handlingJakub Narebski Thu, 28 Apr 2011 19:04:04 +0000 (21:04 +0200)

gitweb.js: Extract and improve datetime handling

Move formatDateISOLocal(epoch, timezone) function (and also helper
timezoneOffset(timezoneInfo) function it requires) from common-lib.js to
datetime.js

Add new functions:
* localTimezoneOffset - to get browser timezone offset in seconds
* localTimezoneInfo - to get browser timezone in '(+|-)HHMM' format
* formatTimezoneInfo - turn offset in hours and minutes into '(+|-)HHMM'
* parseRFC2822Date - to parse RFC-2822 dates that gitweb uses into epoch
* formatDateRFC2882 - like formatDateISOLocal, only RFC-2822 format

All those functions are meant to be used in future commit
'gitweb: javascript ability to adjust time based on timezone'

An alternative would be to use e.g. Datejs (http://www.datejs.com)
library, or JavaScript framework that has date formatting (perhaps as
a plugin).

While at it escape '-' in character class inside tzRe regexp, as
recommended by JSLint (http://www.jslint.com).

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

gitweb.js: Provide default values for padding in padLef... Jakub Narebski Thu, 28 Apr 2011 19:04:03 +0000 (21:04 +0200)

gitweb.js: Provide default values for padding in padLeftStr and padLeft

This means that one can use padLeft(4, 2) and it would be equivalent
to runing padLeft(4, 2, '0'), and it would return '04' i.e. '4' padded
with '0' to width 2, to be used e.g. in formatting date and time.

This should make those functions easier to use. Current code doesn't
yet make use of this feature.

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

gitweb.js: Update and improve comments in JavaScript... Jakub Narebski Thu, 28 Apr 2011 19:04:02 +0000 (21:04 +0200)

gitweb.js: Update and improve comments in JavaScript files

This consists of adding a few extra explanation, fixing descriptions
of functions to match names of parameters in code, adding a few
separators, and fixing spelling -- while at it spell 'neighbor' using
American spelling (and not as 'neighbour').

This is post-split cleanup.

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

gitweb: Split JavaScript for maintability, combining... Jakub Narebski Thu, 28 Apr 2011 19:04:01 +0000 (21:04 +0200)

gitweb: Split JavaScript for maintability, combining on build

Split originally single gitweb.js file into smaller files, each
dealing with single issue / area of responsibility. This move should
make gitweb's JavaScript code easier to maintain.

For better webapp performance it is recommended[1][2][3] to combine
JavaScript files. Do it during build time (in gitweb/Makefile), by
straight concatenation of files into gitweb.js file (which is now
ignored as being generated). This means that there are no changes to
gitweb script itself - it still uses gitweb.js or gitweb.min.js, but
now generated.

[1]: http://developer.yahoo.com/performance/rules.html
"Minimize HTTP Requests" section
[2]: http://code.google.com/speed/articles/include-scripts-properly.html
"1. Combine external JavaScript files"
[3]: http://javascript-reference.info/speed-up-your-javascript-load-time.htm
"Combine Your Files" section.

See also new gitweb/static/js/README file.

Inspired-by-patch-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-grep: Update tests (mainly for -P)Michał Kiedrowicz Sun, 22 May 2011 11:37:28 +0000 (13:37 +0200)

git-grep: Update tests (mainly for -P)

Add few more tests for "-P/--perl-regexp" option of "git grep".

While at it, add some generic tests for grep.extendedRegexp config option,
for detecting invalid regexep and check if "last one wins" rule works for
selecting regexp type.

Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

userdiff/perl: tighten BEGIN/END block pattern to rejec... Jonathan Nieder Sun, 22 May 2011 17:29:32 +0000 (12:29 -0500)

userdiff/perl: tighten BEGIN/END block pattern to reject here-doc delimiters

A naive method of treating BEGIN/END blocks with a brace on the second
line as diff/grep funcname context involves also matching unrelated
lines that consist of all-caps letters:

sub foo {
print <<'EOF'
text goes here
...
EOF
... rest of foo ...
}

That's not so great, because it means that "git diff" and "git grep
--show-function" would write "=EOF" or "@@ EOF" as context instead of
a more useful reminder like "@@ sub foo {".

To avoid this, tighten the pattern to only match the special block
names that perl accepts (namely BEGIN, END, INIT, CHECK, UNITCHECK,
AUTOLOAD, and DESTROY). The list is taken from perl's toke.c.

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

Update 1.7.6 draft release notesJunio C Hamano Mon, 23 May 2011 17:54:54 +0000 (10:54 -0700)

Update 1.7.6 draft release notes

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

Merge branch 'tr/add-i-no-escape'Junio C Hamano Mon, 23 May 2011 17:50:06 +0000 (10:50 -0700)

Merge branch 'tr/add-i-no-escape'

* tr/add-i-no-escape:
add -i: ignore terminal escape sequences

Merge branch 'jm/maint-diff-words-with-sbe'Junio C Hamano Mon, 23 May 2011 17:27:42 +0000 (10:27 -0700)

Merge branch 'jm/maint-diff-words-with-sbe'

* jm/maint-diff-words-with-sbe:
do not read beyond end of malloc'd buffer

Merge branch 'js/mingw-shutdown'Junio C Hamano Mon, 23 May 2011 17:27:12 +0000 (10:27 -0700)

Merge branch 'js/mingw-shutdown'

* js/mingw-shutdown:
Windows: add a wrapper for the shutdown() system call

Merge branch 'ms/ls-remote-exit-with-status'Junio C Hamano Mon, 23 May 2011 17:27:08 +0000 (10:27 -0700)

Merge branch 'ms/ls-remote-exit-with-status'

* ms/ls-remote-exit-with-status:
ls-remote: the --exit-code option reports "no matching refs"

Merge branch 'mg/config-symbolic-constants'Junio C Hamano Mon, 23 May 2011 16:59:05 +0000 (09:59 -0700)

Merge branch 'mg/config-symbolic-constants'

* mg/config-symbolic-constants:
config: Give error message when not changing a multivar
config: define and document exit codes

Merge branch 'ab/i18n-scripts-basic'Junio C Hamano Mon, 23 May 2011 16:58:45 +0000 (09:58 -0700)

Merge branch 'ab/i18n-scripts-basic'

* ab/i18n-scripts-basic:
Makefile: add xgettext target for *.sh files
git-sh-i18n.sh: add GIT_GETTEXT_POISON support
git-sh-i18n.sh: add no-op gettext() and eval_gettext() wrappers
git-sh-i18n--envsubst: our own envsubst(1) for eval_gettext()

Merge branch 'jc/magic-pathspec'Junio C Hamano Mon, 23 May 2011 16:58:35 +0000 (09:58 -0700)

Merge branch 'jc/magic-pathspec'

* jc/magic-pathspec:
setup.c: Fix some "symbol not declared" sparse warnings
t3703: Skip tests using directory name ":" on Windows
revision.c: leave a note for "a lone :" enhancement
t3703, t4208: add test cases for magic pathspec
rev/path disambiguation: further restrict "misspelled index entry" diag
fix overslow :/no-such-string-ever-existed diagnostics
fix overstrict :<path> diagnosis
grep: use get_pathspec() correctly
pathspec: drop "lone : means no pathspec" from get_pathspec()
Revert "magic pathspec: add ":(icase)path" to match case insensitively"
magic pathspec: add ":(icase)path" to match case insensitively
magic pathspec: futureproof shorthand form
magic pathspec: add tentative ":/path/from/top/level" pathspec support

Merge branch 'jk/blame-line-porcelain'Junio C Hamano Mon, 23 May 2011 16:58:31 +0000 (09:58 -0700)

Merge branch 'jk/blame-line-porcelain'

* jk/blame-line-porcelain:
blame: add --line-porcelain output format
blame: refactor porcelain output
add tests for various blame formats

tests: make test_expect_code quieter on successJonathan Nieder Sat, 21 May 2011 19:40:32 +0000 (14:40 -0500)

tests: make test_expect_code quieter on success

A command exiting with the expected status is not particularly
notable.

While the indication of progress might be useful when tracking down
where in a test a failure has happened, the same applies to most other
test helpers, which are quiet about success, so this single helper's
output stands out in an unpleasant way. An alternative method for
showing progress information might to invent a --progress option that
runs tests with "set -x", or until that is available, to run tests
using commands like

prove -v -j2 --shuffle --exec='sh -x' t2202-add-addremove.sh

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

userdiff/perl: catch sub with brace on second lineJonathan Nieder Sat, 21 May 2011 19:38:26 +0000 (14:38 -0500)

userdiff/perl: catch sub with brace on second line

Accept

sub foo
{
}

as an alternative to a more common style that introduces perl
functions with a brace on the first line (and likewise for BEGIN/END
blocks). The new regex is a little hairy to avoid matching

# forward declaration
sub foo;

while continuing to match "sub foo($;@) {" and

sub foo { # This routine is interesting;
# in fact, the lines below explain how...

While at it, pay attention to Perl 5.14's "package foo {" syntax as an
alternative to the traditional "package foo;".

Requested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

userdiff/perl: match full line of POD headersJonathan Nieder Sat, 21 May 2011 19:35:51 +0000 (14:35 -0500)

userdiff/perl: match full line of POD headers

The builtin perl userdiff driver is not greedy enough about catching
POD header lines. Capture the whole line, so instead of just
declaring that we are in some "@@ =head1" section, diff/grep output
can explain that the enclosing section is about "@@ =head1 OPTIONS".

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

userdiff/perl: anchor "sub" and "package" patterns... Jonathan Nieder Sat, 21 May 2011 19:29:01 +0000 (14:29 -0500)

userdiff/perl: anchor "sub" and "package" patterns on the left

The userdiff funcname mechanism has no concept of nested scopes ---
instead, "git diff" and "git grep --show-function" simply label the
diff header with the most recent matching line. Unfortunately that
means text following a subroutine in a POD section:

=head1 DESCRIPTION

You might use this facility like so:

sub example {
foo;
}

Now, having said that, let's say more about the facility.
Blah blah blah ... etc etc.

gets the subroutine name instead of the POD header in its diff/grep
funcname header, making it harder to get oriented when reading a
diff without enough context.

The fix is simple: anchor the funcname syntax to the left margin so
nested subroutines and packages like this won't get picked up. (The
builtin C++ funcname pattern already does the same thing.) This means
the userdiff driver will misparse the idiom

{
my $static;
sub foo {
... use $static ...
}
}

but I think that's worth it; we can revisit this later if the userdiff
mechanism learns to keep track of the beginning and end of nested
scopes.

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t4018 (funcname patterns): minor cleanupsJonathan Nieder Sat, 21 May 2011 19:25:14 +0000 (14:25 -0500)

t4018 (funcname patterns): minor cleanups

Introduce a test_expect_funcname function to make a diff and apply a
regexp anchored on the left to the function name it writes, avoiding
some repetition.

Omit the space after >, <<, and < operators for consistency with
other scripts. Quote the <<here document delimiter and $ signs in
quotes so readers don't have to worry about the effect of shell
metacharacters.

Remove some unnecessary blank lines.

Run "git diff" as a separate command instead of as upstream of a pipe
that checks its output, so the exit status can be tested. In
particular, this way if "git diff" starts segfaulting the test harness
will notice.

Allow "error:" as a synonym for "fatal:" when checking error messages,
since whether a command uses die() or "return error()" is a small
implementation detail.

Anchor some more regexes on the right.

None of the above is very important on its own; the point is just to
make the script a little easier to read and the code less scary to
modify.

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

t4018 (funcname patterns): make configuration easier... Jonathan Nieder Sat, 21 May 2011 19:22:28 +0000 (14:22 -0500)

t4018 (funcname patterns): make configuration easier to track

Introduce a "test_config" function to set a configuration variable
for use by a single test (automatically unsetting it when the
assertion finishes). If this function is used consistently, the
configuration used in a test_expect_success block can be read at the
beginning of that block instead of requiring reading all the tests
that come before. So it becomes a little easier to add new tests or
rearrange existing ones without fear of breaking configuration.

In particular, the test of alternation in xfuncname patterns also
checks that xfuncname takes precedence over funcname variable as a
sort of side-effect, since the latter leaks in from previous tests.
In the new syntax, the test has to say explicitly what variables it is
using, making the test clearer and a future regression in coverage
from carelessly editing the script less likely.

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

t4018 (funcname patterns): make .gitattributes state... Jonathan Nieder Sat, 21 May 2011 19:11:33 +0000 (14:11 -0500)

t4018 (funcname patterns): make .gitattributes state easier to track

Most, but not all, tests in this script rely on attributes declaring
that files with a .java extension should use the "java" driver:

*.java diff=java

Split out a "set up" test to put such a .gitattributes in place after
the tests that do not want it have run, to make it more likely that
individual tests other than this setup test can be safely modified,
rearranged, or skipped. Presumably this setup code will learn to
request other drivers for other extensions in the same place when the
test suite learns to exercise other diff drivers.

Similarly, make sure that early test assertions that do not use these
default attributes set up .gitattributes appropriately for themselves,
so tests that run before can be modified with less risk of breaking
something.

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

Merge branch 'maint'Junio C Hamano Sat, 21 May 2011 01:50:29 +0000 (18:50 -0700)

Merge branch 'maint'

* maint:
git-svn: Fix git svn log --show-commit

do not read beyond end of malloc'd bufferJim Meyering Fri, 20 May 2011 17:20:12 +0000 (19:20 +0200)

do not read beyond end of malloc'd buffer

With diff.suppress-blank-empty=true, "git diff --word-diff" would
output data that had been read from uninitialized heap memory.
The problem was that fn_out_consume did not account for the
possibility of a line with length 1, i.e., the empty context line
that diff.suppress-blank-empty=true converts from " \n" to "\n".
Since it assumed there would always be a prefix character (the space),
it decremented "len" unconditionally, thus passing len=0 to emit_line,
which would then blindly call emit_line_0 with len=-1 which would
pass that value on to fwrite as SIZE_MAX. Boom.

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

git-svn: Fix git svn log --show-commitMichael J Gruber Fri, 20 May 2011 11:16:34 +0000 (13:16 +0200)

git-svn: Fix git svn log --show-commit

git svn log --show-commit had no tests and, consequently, no attention
by the author of

b1b4755 (git-log: put space after commit mark, 2011-03-10)

who kept git svn log working only without --show-commit.

Introduce a test and fix it.

Reported-by: Bernt Hansen <bernt@norang.ca>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Update draft release notes to 1.7.6Junio C Hamano Fri, 20 May 2011 03:50:07 +0000 (20:50 -0700)

Update draft release notes to 1.7.6

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

Merge branch 'jc/maint-1.7.4-pathspec-stdin-and-cmdline'Junio C Hamano Fri, 20 May 2011 04:02:14 +0000 (21:02 -0700)

Merge branch 'jc/maint-1.7.4-pathspec-stdin-and-cmdline'

* jc/maint-1.7.4-pathspec-stdin-and-cmdline:

Merge branch 'rg/copy-gecos-username'Junio C Hamano Fri, 20 May 2011 03:37:21 +0000 (20:37 -0700)

Merge branch 'rg/copy-gecos-username'

* rg/copy-gecos-username:
copy_gecos: fix not adding nlen to len when processing "&"

Merge branch 'jl/submodule-conflicted-gitmodules'Junio C Hamano Fri, 20 May 2011 03:37:21 +0000 (20:37 -0700)

Merge branch 'jl/submodule-conflicted-gitmodules'

* jl/submodule-conflicted-gitmodules:
Submodules: Don't parse .gitmodules when it contains, merge conflicts
test that git status works with merge conflict in, .gitmodules

Merge branch 'jc/replacing'Junio C Hamano Fri, 20 May 2011 03:37:21 +0000 (20:37 -0700)

Merge branch 'jc/replacing'

* jc/replacing:
read_sha1_file(): allow selective bypassing of replacement mechanism
inline lookup_replace_object() calls
read_sha1_file(): get rid of read_sha1_file_repl() madness
t6050: make sure we test not just commit replacement
Declare lookup_replace_object() in cache.h, not in commit.h

Conflicts:
environment.c

Merge branch 'nd/sparse-co-fix'Junio C Hamano Fri, 20 May 2011 03:37:21 +0000 (20:37 -0700)

Merge branch 'nd/sparse-co-fix'

* nd/sparse-co-fix:
sparse checkout: do not eagerly decide the fate for whole directory
t1011: fix sparse-checkout initialization and add new file

Merge branch 'ld/p4-preserve-user-names'Junio C Hamano Fri, 20 May 2011 03:37:20 +0000 (20:37 -0700)

Merge branch 'ld/p4-preserve-user-names'

* ld/p4-preserve-user-names:
git-p4: warn if git authorship won't be retained
git-p4: small improvements to user-preservation
git-p4: add option to preserve user names

Merge branch 'ms/tagname-does-not-begin-with-dash'Junio C Hamano Fri, 20 May 2011 03:37:20 +0000 (20:37 -0700)

Merge branch 'ms/tagname-does-not-begin-with-dash'

* ms/tagname-does-not-begin-with-dash:
tag: disallow '-' as tag name

Merge branch 'jk/git-connection-deadlock-fix'Junio C Hamano Fri, 20 May 2011 03:37:20 +0000 (20:37 -0700)

Merge branch 'jk/git-connection-deadlock-fix'

* jk/git-connection-deadlock-fix:
test core.gitproxy configuration
send-pack: avoid deadlock on git:// push with failed pack-objects
connect: let callers know if connection is a socket
connect: treat generic proxy processes like ssh processes

Conflicts:
connect.c

Merge branch 'js/maint-send-pack-stateless-rpc-deadlock... Junio C Hamano Fri, 20 May 2011 03:37:19 +0000 (20:37 -0700)

Merge branch 'js/maint-send-pack-stateless-rpc-deadlock-fix'

* js/maint-send-pack-stateless-rpc-deadlock-fix:
sideband_demux(): fix decl-after-stmt

Merge branch 'jk/cherry-pick-root-with-resolve'Junio C Hamano Fri, 20 May 2011 03:37:19 +0000 (20:37 -0700)

Merge branch 'jk/cherry-pick-root-with-resolve'

* jk/cherry-pick-root-with-resolve:
t3503: test cherry picking and reverting root commits
revert: allow reverting a root commit
cherry-pick: handle root commits with external strategies

Merge branch 'jc/maint-pathspec-stdin-and-cmdline'Junio C Hamano Fri, 20 May 2011 03:37:18 +0000 (20:37 -0700)

Merge branch 'jc/maint-pathspec-stdin-and-cmdline'

* jc/maint-pathspec-stdin-and-cmdline:
setup_revisions(): take pathspec from command line and --stdin correctly

Conflicts:
revision.c

Merge 1.7.5.2 inJunio C Hamano Fri, 20 May 2011 03:37:08 +0000 (20:37 -0700)

Merge 1.7.5.2 in

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

Revert "Merge branch 'en/merge-recursive'"Junio C Hamano Fri, 20 May 2011 03:17:44 +0000 (20:17 -0700)

Revert "Merge branch 'en/merge-recursive'"

As the band-aid to merge-recursive seems to regress complex merges in an
unpleasant way. The merge-recursive implementation needs to be rewritten
in such a way that it resolves renames and D/F conflicts entirely in-core
and not to touch working tree at all while doing so. But in the meantime,
this reverts commit ac9666f84 that merged the topic in its entirety.

Git 1.7.5.2 v1.7.5.2Junio C Hamano Fri, 20 May 2011 03:30:44 +0000 (20:30 -0700)

Git 1.7.5.2

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

receive-pack: eliminate duplicate .have refsJeff King Thu, 19 May 2011 21:34:46 +0000 (17:34 -0400)

receive-pack: eliminate duplicate .have refs

When receiving a push, we advertise ref tips from any
alternate repositories, in case that helps the client send a
smaller pack. Since these refs don't actually exist in the
destination repository, we don't transmit the real ref
names, but instead use the pseudo-ref ".have".

If your alternate has a large number of duplicate refs (for
example, because it is aggregating objects from many related
repositories, some of which will have the same tags and
branch tips), then we will send each ".have $sha1" line
multiple times. This is a pointless waste of bandwidth, as
we are simply repeating the same fact to the client over and
over.

This patch eliminates duplicate .have refs early on. It does
so efficiently by sorting the complete list and skipping
duplicates. This has the side effect of re-ordering the
.have lines by ascending sha1; this isn't a problem, though,
as the original order was meaningless.

There is a similar .have system in fetch-pack, but it
does not suffer from the same problem. For each alternate
ref we consider in fetch-pack, we actually open the object
and mark it with the SEEN flag, so duplicates are
automatically culled.

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

bisect: refactor sha1_array into a generic sha1 listJeff King Thu, 19 May 2011 21:34:33 +0000 (17:34 -0400)

bisect: refactor sha1_array into a generic sha1 list

This is a generally useful abstraction, so let's let others
make use of it. The refactoring is more or less a straight
copy; however, functions and struct members have had their
names changed to match string_list, which is the most
similar data structure.

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

refactor refs_from_alternate_cb to allow passing extra... Jeff King Thu, 19 May 2011 21:33:17 +0000 (17:33 -0400)

refactor refs_from_alternate_cb to allow passing extra data

The foreach_alt_odb function triggers a callback for each
alternate object db we have, with room for a single void
pointer as data. Currently, we always call refs_from_alternate_cb
as the callback function, and then pass another callback (to
receive each ref individually) as the void pointer.

This has two problems:

1. C technically forbids stuffing a function pointer into
a "void *". In practice, this probably doesn't matter
on any architectures git runs on, but it never hurts to
follow the letter of the law.

2. There is no room for an extra data pointer. Indeed, the
alternate_ref_fn that refs_from_alternate_cb calls
takes a void* for data, but we always pass it NULL.

Instead, let's properly stuff our function pointer into a
data struct, which also leaves room for an extra
caller-supplied data pointer. And to keep things simple for
existing callers, let's make a for_each_alternate_ref
function that takes care of creating the extra struct.

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

Makefile: sort TEST_PROGRAMS listJeff King Thu, 19 May 2011 21:24:24 +0000 (17:24 -0400)

Makefile: sort TEST_PROGRAMS list

We usually keep these lists in sorted order, but the last
few entries were just tacked on the end.

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

fetch: avoid repeated commits in mark_completeJeff King Thu, 19 May 2011 20:48:51 +0000 (16:48 -0400)

fetch: avoid repeated commits in mark_complete

We add every local ref to a list so that we can mark them
and all of their ancestors back to a certain cutoff point.
However, if some refs point to the same commit, we will end
up adding them to the list many times.

Furthermore, since commit_lists are stored as linked lists,
we must do an O(n) traversal of the list in order to find
the right place to insert each commit. This makes building
the list O(n^2) in the number of refs.

For normal repositories, this isn't a big deal. We have a
few hundreds refs at most, and most of them are unique. But
consider an "alternates" repo that serves as an object
database for many other similar repos. For reachability, it
needs to keep a copy of the refs in each child repo. This
means it may have a large number of refs, many of which
point to the same commits.

By noting commits we have already added to the list, we can
shrink the size of "n" in such a repo to the number of
unique commits, which is on the order of what a normal repo
would contain (it's actually more than a normal repo, since child repos
may have branches at different states, but in practice it tends
to be much smaller than the list with duplicates).

Here are the results on one particular giant repo
(containing objects for all Rails forks on GitHub):

$ git for-each-ref | wc -l
112514

[before]
$ git fetch --no-tags ../remote.git
63.52user 0.12system 1:03.68elapsed 99%CPU (0avgtext+0avgdata 137648maxresident)k
1856inputs+48outputs (11major+19603minor)pagefaults 0swaps

$ git fetch --no-tags ../remote.git
6.15user 0.08system 0:06.25elapsed 99%CPU (0avgtext+0avgdata 123856maxresident)k
0inputs+40outputs (0major+18872minor)pagefaults 0swaps

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