Makefile: extract perl-related rules to make them available from other dirs

The final goal is to make it easy to write Git commands in perl in the
contrib/ directory. It is currently possible to do so, but without the
benefits of Git's Makefile: adapt first line with $(PERL_PATH),
hardcode the path to Git.pm, ...

We make the perl-related part of the Makefile available from directories
other than the toplevel so that:

* Developers can include it, to avoid code duplication

* Users can get a consistent behavior of "make install"

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
perl.mak: introduce $(GIT_ROOT_DIR) to allow inclusion from other directories

perl.mak uses relative path, which is OK when called from the toplevel,
but won't be anymore if one includes it from elsewhere. It is now
possible to include the file using:

GIT_ROOT_DIR=<whatever>
include $(GIT_ROOT_DIR)/perl.mak

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Use __VA_ARGS__ for all of error's arguments

QNX 6.3.2 uses GCC 2.95.3 by default, and GCC 2.95.3 doesn't remove the
comma if the error macro's variable argument is left out.

Instead of testing for a sufficiently recent version of GCC, make
__VA_ARGS__ match all of the arguments.

Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile: make script-related rules usable from subdirectories

Git's Makefile provides a few nice features for script build and
installation (substitute the first line with the right path, hardcode the
path to Git library, ...).

The Makefile already knows how to process files outside the toplevel
directory with e.g.

  make SCRIPT_PERL=path/to/file.perl path/to/file

but we can make it simpler for callers by exposing build, install and
clean rules as .PHONY targets.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-remote-mediawiki: use toplevel's Makefile

This makes the Makefile simpler, while providing more features, and more
consistency (the exact same rules with the exact same configuration as
Git official commands are applied with the new version).

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
user-manual: Update for receive.denyCurrentBranch=refuse

acd2a45 (Refuse updating the current branch in a non-bare repository
via push, 2009-02-11) changed the default to refuse such a push, but
it forgot to update the docs.

7d182f5 (Documentation: receive.denyCurrentBranch defaults to
'refuse', 2010-03-17) updated Documentation/config.txt, but forgot to
update the user manual.

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
user-manual: Rewrite git-gc section for automatic packing

This should have happened back in 2007, when `git gc` learned about
auto:

  commit e9831e83e063844b90cf9e525d0003715dd8b395
  Author: Junio C Hamano <gitster@pobox.com>
  Date:   Mon Sep 17 00:39:52 2007 -0700

    git-gc --auto: add documentation.

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-count-objects.txt: describe each line in -v output

The current description requires a bit of guessing (what clause
corresponds to what printed line?) and lacks information, such as
the unit of size and size-pack.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
count-objects: report garbage files in pack directory too

prepare_packed_git_one() is modified to allow count-objects to hook a
report function to so we don't need to duplicate the pack searching
logic in count-objects.c. When report_pack_garbage is NULL, the
overhead is insignificant.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-mergetool: print filename when it contains %

If git-mergetool was invoked with files with a percent sign (%) in
their names, it would print an error.  For example, if you were
calling mergetool on a file called "%2F":

    printf: %2F: invalid directive

Do not pass random string to printf as if it were a valid format.
Use format string "%s" and pass the string as data to be formatted
instead.

Signed-off-by: Asheesh Laroia <asheesh@asheesh.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
count-objects: report how much disk space taken by garbage files

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch: show rebase/bisect info when possible instead of "(no branch)"

This prints more helpful info when HEAD is detached: is it detached
because of bisect or rebase? What is the original branch name in those
cases?

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Add utf8_fprintf helper that returns correct number of columns

Since command usages can be translated, they may include utf-8
encoded strings, and the output in console may not align well any
more. This is because strlen() is different from strwidth() on utf-8
strings.

A wrapper utf8_fprintf() can help to return the correct number of
columns required.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Reviewed-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-bisect.txt: clarify that reset finishes bisect

"reset" can be easily misunderstood as resetting a bisect session to its
start without finishing it. Clarify that it actually finishes the bisect
session.

Reported-by: Andreas Mohr <andi@lisas.de>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Move Git::SVN::get_tz to Git::get_tz_offset

This function has utility outside of the SVN module for any routine
that needs the equivalent of GNU strftime's %z formatting option.
Move it to the top-level Git.pm so that non-SVN modules don't need to
import the SVN module to use it.

The rename makes the purpose of the function clearer.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
perl/Git.pm: fix get_tz_offset to properly handle DST boundary cases

When passed a local time that was on the boundary of a DST change,
get_tz_offset returned a GMT offset that was incorrect (off by one
hour).  This is because the time was converted to GMT and then back to
a time stamp via timelocal() which cannot disambiguate boundary cases
as noted in its documentation.

Modify this algorithm, using an approach suggested in

  http://article.gmane.org/gmane.comp.version-control.git/213871

to first convert the timestamp in question to two broken down forms
with localtime() and gmtime(), and then compute what timestamps
these two broken down forms would represent in GMT (i.e. a timezone
that does not have DST issues) by applying timegm() on them.  The
difference between the resulting timestamps is the timezone offset.

This avoids the ambigious conversion and allows a correct time to be
returned on every occassion.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cvsimport: format commit timestamp ourselves without using strftime

Some implementations of strftime(3) lack support for "%z".  Also
there is no need for %s in git-cvsimport as the supplied time is
already in seconds since the epoch.

For %z, use the function get_tz_offset provided by Git.pm instead.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/remove-treesame-parent-in-simplify-merges' into jch

The --simplify-merges logic did not cull irrelevant parents from a
merge that is otherwise not interesting with respect to the paths
we are following.

This touches a fairly core part of the revision traversal
infrastructure; even though I think this change is correct, please
report immediately if you find any unintended side effect.

Will cook in 'next'.

* jc/remove-treesame-parent-in-simplify-merges:
  simplify-merges: drop merge from irrelevant side branch

Conflicts:
	revision.c
Merge branch 'sp/smart-http-content-type-check' into jch

The smart HTTP clients forgot to verify the content-type that comes
back from the server side to make sure that the request is being
handled properly.

* sp/smart-http-content-type-check:
  http_request: reset "type" strbuf before adding
  t5551: fix expected error output
  Verify Content-Type from smart HTTP servers
Merge branch 'dg/subtree-fixes' into jch

contrib/subtree updates, but here are only the ones that looked
ready to be merged to 'next'.  For the remainder, they will have
another day.

Will merge to 'next'.

* dg/subtree-fixes:
  contrib/subtree: make the manual directory if needed
  contrib/subtree: honor DESTDIR
  contrib/subtree: fix synopsis
  contrib/subtree: better error handling for 'subtree add'
  contrib/subtree: use %B for split subject/body
  contrib/subtree: remove test number comments