Makefile: make mandir, htmldir and infodir absolute

This matches the use of the variables with the same names in autotools,
reducing the potential for user surprise.

Using relative paths in these variables also causes issues if they are
exported from the Makefile, as discussed in commit c09d62f (Makefile: do
not export mandir/htmldir/infodir, 2013-02-12).

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
name-hash.c: fix endless loop with core.ignorecase=true

With core.ignorecase=true, name-hash.c builds a case insensitive index of
all tracked directories. Currently, the existing cache entry structures are
added multiple times to the same hashtable (with different name lengths and
hash codes). However, there's only one dir_next pointer, which gets
completely messed up in case of hash collisions. In the worst case, this
causes an endless loop if ce == ce->dir_next (see t7062).

Use a separate hashtable and separate structures for the directory index
so that each directory entry has its own next pointer. Use reference
counting to track which directory entry contains files.

There are only slight changes to the name-hash.c API:
- new free_name_hash() used by read_cache.c::discard_index()
- remove_name_hash() takes an additional index_state parameter
- index_name_exists() for a directory (trailing '/') may return a cache
  entry that has been removed (CE_UNHASHED). This is not a problem as the
  return value is only used to check if the directory exists (dir.c) or to
  normalize casing of directory names (read-cache.c).

Getting rid of cache_entry.dir_next reduces memory consumption, especially
with core.ignorecase=false (which doesn't use that member at all).

With core.ignorecase=true, building the directory index is slightly faster
as we add / check the parent directory first (instead of going through all
directory levels for each file in the index). E.g. with WebKit (~200k
files, ~7k dirs), time spent in lazy_init_name_hash is reduced from 176ms
to 130ms.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
describe: --match=<pattern> must limit the refs even when used with --all

The logic to limit the refs used for describing with a matching pattern
with --match=<pattern> parameter was implemented incorrectly when --all
is in effect.  It just demoted a ref that did not match the pattern to
lower priority---if there aren't other refs with higher priority
that describe the given commit, such an unmatching ref was still used.

When --match is used, reject refs that do not match the given
criteria, so that with or without --all, the output will only use
refs that match the pattern.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
submodule: add 'deinit' command

With "git submodule init" the user is able to tell git he cares about one
or more submodules and wants to have it populated on the next call to "git
submodule update". But currently there is no easy way he could tell git he
does not care about a submodule anymore and wants to get rid of his local
work tree (except he knows a lot about submodule internals and removes the
"submodule.$name.url" setting from .git/config together with the work tree
himself).

Help those users by providing a 'deinit' command. This removes the
whole submodule.<name> section from .git/config (either for the given
submodule(s) or for all those which have been initialized if '.' is used)
together with their work tree. Fail if the current work tree contains
modifications (unless forced), but don't complain when either the work
tree is already removed or no settings are found in .git/config.

Add tests and link the man pages of "git submodule deinit" and "git rm"
to assist the user in deciding whether removing or unregistering the
submodule is the right thing to do for him. Also add the deinit subcommand
to the completion list.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
match_push_refs(): nobody sets src->peer_ref anymore

In ancient times, we used to disallow the same source ref to be
pushed to more than one places, e.g. "git push there master:master
master:naster" was disallowed.  We later lifted this restriction
with db27ee63929f (send-pack: allow the same source to be pushed
more than once., 2005-08-06) and there no longer is anybody that
sets peer_ref for the source side of the ref list in the push
codepath since then.

Remove one leftover no-op in a loop that iterates over the source
side of ref list (i.e. our local ref) to see if it can/should be
sent to a matching destination ref while skipping ones that is
marked with peer_ref (which will never exist, so we do not skip
anything).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Fix `make install` when configured with autoconf

Commit d8cf908c (config.mak.in: remove unused definitions) removed

    exec_prefix = @exec_prefix@

from config.mak.in, because nobody directly used ${exec_prefix}, but
overlooked that other autoconf definitions could indirectly expand that
variable.

For example the following snippet from config.mak.in

    prefix = @prefix@
    bindir = @bindir@
    gitexecdir = @libexecdir@/git-core
    datarootdir = @datarootdir@
    template_dir = @datadir@/git-core/templates
    sysconfdir = @sysconfdir@

is expanded to

    prefix = /home/kirr/local/git
    bindir = ${exec_prefix}/bin                             <-- HERE
    gitexecdir = ${exec_prefix}/libexec/git-core            <--
    datarootdir = ${prefix}/share
    template_dir = ${datarootdir}/git-core/templates
    sysconfdir = ${prefix}/etc

on my system, after `configure --prefix=$HOME/local/git`

and withot exec_prefix being defined there I get an error on
install:

    install -d -m 755 '/bin'
    install -d -m 755 '/libexec/git-core'
    install: cannot create directory `/libexec': Permission denied
    Makefile:2292: recipe for target `install' failed

Fix it.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reflog: fix typo in "reflog expire" clean-up codepath

In "reflog expire" we were not clearing the REACHABLE bit from
objects reachable from the tip of refs we marked earlier.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/remove-export-from-config-mak-in' into next

* jc/remove-export-from-config-mak-in:
  Fix `make install` when configured with autoconf
Merge branch 'mp/complete-paths' into next

* mp/complete-paths:
  git-completion.zsh: define __gitcomp_file compatibility function
Merge branch 'jk/common-make-variables-export-safety' into next

Make the three variables safer to be exported to submakes by
ensuring that they are full paths so that they can be used as
installation location.

* jk/common-make-variables-export-safety:
  Makefile: make mandir, htmldir and infodir absolute
Merge branch 'jc/describe' into next

The "--match=<pattern>" option of "git describe", when used with
"--all" to allow refs that are not annotated tags to be used as a
base of description, did not restrict the output from the command
to those that match the given pattern.

We may want to have a looser matching that does not restrict to tags,
but that can be done as a follow-up topic; this step is purely a bugfix.

* jc/describe:
  describe: --match=<pattern> must limit the refs even when used with --all
Merge branch 'kb/name-hash' into next

The code to keep track of what directory names are known to Git on
platforms with case insensitive filesystems can get confused upon
a hash collision between these pathnames and looped forever.

* kb/name-hash:
  name-hash.c: fix endless loop with core.ignorecase=true
Merge branch 'jl/submodule-deinit' into next

There was no Porcelain way to say "I no longer am interested in
this submodule", once you express your interest in a submodule with
"submodule init".  "submodule deinit" is the way to do so.

* jl/submodule-deinit:
  submodule: add 'deinit' command
tests: make sure rename pretty print works

Add basic use cases and corner cases tests for
"git diff -M --summary/stat".

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'ap/maint-diff-rename-avoid-overlap' into next

* ap/maint-diff-rename-avoid-overlap:
  tests: make sure rename pretty print works
add: Clarify documentation of -A and -u

The documentation of '-A' and '-u' is very confusing for someone who
doesn't already know what they do.  Describe them with fewer words and
clearer parallelism to each other and to the behavior of plain 'add'.

Also mention the default <pathspec> for '-A' as well as '-u', because
it applies to both.

Signed-off-by: Greg Price <price@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/nobody-sets-src-peer-ref' into next

Dead code removal.

* jc/nobody-sets-src-peer-ref:
  match_push_refs(): nobody sets src->peer_ref anymore
Merge branch 'jc/maint-reflog-expire-clean-mark-typofix' into next

* jc/maint-reflog-expire-clean-mark-typofix:
  reflog: fix typo in "reflog expire" clean-up codepath
Sync with 1.8.2-rc3

* master:
  Git 1.8.2-rc3
  gitweb/README: remove reference to git.kernel.org
  l10n: zh_CN.po: translate 1 new message
  l10n: de.po: translate 1 new message
  l10n: vi.po: Update translation (2009t0f0u)
  l10n: Update Swedish translation (2009t0f0u)
  l10n: git.pot: v1.8.2 round 4 (1 changed)
bundle: Fix "verify" output if history is complete

A more informative message for "complete" bundles was added in commit
8c3710fd3011 (tweak "bundle verify" of a complete history, 2012-06-04).

However, the prerequisites ref list is currently read *after* we
check if it equals zero, which means we never actually use the
number of prerequisite refs to decide when to print the newly
introduced message.  The code incorrectly uses the number of
references recorded in the bundle instead.

Signed-off-by: Lukas Fleischer <git@cryptocrack.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>