configure.ac: link with -liconv for locale_charset()

On e.g. FreeBSD 10.x, the following situation is common:
- there's iconv implementation in libc, which has no locale_charset()
  function
- there's GNU libiconv installed from Ports Collection

Git build process
- detects that iconv is in libc and thus -liconv is not needed for it
- detects locale_charset in -liconv, but for some reason doesn't add it
  to CHARSET_LIB (as it would do with -lcharset if locale_charset() was
  found there instead of -liconv)
- git doesn't build due to unresolved external locale_charset()

Fix this by adding -liconv to CHARSET_LIB if locale_charset() is
detected in this library.

Signed-off-by: Dmitry Marakasov <amdmi3@amdmi3.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-terminal: make TTY a lazy prerequisite

When lib-terminal.sh is sourced by a test script, we
immediately set up the TTY prerequisite. We do so inside a
test_expect_success, because that nicely isolates any
generated output.

However, this early test can interfere with a script that
later wants to skip all tests (e.g., t5541 then goes on to
set up the httpd server, and wants to skip_all if that
fails). TAP output doesn't let us skip everything after we
have already run at least one test.

We could fix this by reordering the inclusion of
lib-terminal.sh in t5541 to go after the httpd setup.  That
solves this case, but we might eventually hit a case with
circular dependencies, where either lib-*.sh include might
want to skip_all after the other has run a test.  So
instead, let's just remove the ordering constraint entirely
by doing the setup inside a test_lazy_prereq construct,
rather than in a regular test.  We never cared about the
test outcome anyway (it was written to always succeed).

Note that in addition to setting up the prerequisite, the
current test also defines test_terminal. Since we can't
affect the environment from a lazy_prereq, we have to hoist
that out. We previously depended on it _not_ being defined
when the TTY prereq isn't set as a way to ensure that tests
properly declare their dependency on TTY. However, we still
cover the case (see the in-code comment for details).

Reported-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rebase -i: do not "echo" random user-supplied strings

In some places we "echo" a string that comes from a commit log
message, which may have a backslash sequence that is interpreted by
the command (POSIX.1 allows this), most notably "dash"'s built-in
'echo'.

A commit message which contains the string '\n' (or ends with the
string '\c') may result in a garbage line in the todo list of an
interactive rebase which causes the rebase to fail.

To reproduce the behavior (with dash as /bin/sh):

  mkdir test && cd test && git init
  echo 1 >foo && git add foo
  git commit -m"this commit message ends with '\n'"
  echo 2 >foo && git commit -a --fixup HEAD
  git rebase -i --autosquash --root

Now the editor opens with garbage in line 3 which has to be
removed or the rebase fails.

Signed-off-by: Uwe Storbeck <uwe@ibr.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-objects: show progress for reused packfiles

When the "--all-progress" option is in effect, pack-objects
shows a progress report for the "writing" phase. If the
repository has bitmaps and we are reusing a packfile, the
user sees no progress update until the whole packfile is
sent.  Since this is typically the bulk of what is being
written, it can look like git hangs during this phase, even
though the transfer is proceeding.

This generally only happens with "git push" from a
repository with bitmaps. We do not use "--all-progress" for
fetch (since the result is going to index-pack on the
client, which takes care of progress reporting). And for
regular repacks to disk, we do not reuse packfiles.

We already have the progress meter setup during
write_reused_pack; we just need to call display_progress
whiel we are writing out the pack. The progress meter is
attached to our output descriptor, so it automatically
handles the throughput measurements.

However, we need to update the object count as we go, since
that is what feeds the percentage we show. We aren't
actually parsing the packfile as we send it, so we have no
idea how many objects we have sent; we only know that at the
end of N bytes, we will have sent M objects. So we cheat a
little and assume each object is M/N bytes (i.e., the mean
of the objects we are sending). While this isn't strictly
true, it actually produces a more pleasing progress meter
for the user, as it moves smoothly and predictably (and
nobody really cares about the object count; they care about
the percentage, and the object count is a proxy for that).

One alternative would be to actually show two progress
meters: one for the reused pack, and one for the rest of the
objects. That would more closely reflect the data we have
(the first would be measured in bytes, and the second
measured in objects). But it would also be more complex and
annoying to the user; rather than seeing one progress meter
counting up to 100%, they would finish one meter, then start
another one at zero.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-objects: show reused packfile objects in "Counting objects"

When we are sending a pack for push or fetch, we may reuse a
chunk of packfile without even parsing it. The progress
meter then looks like this:

  Reusing existing pack: 3440489, done.
  Counting objects: 3, done.

The first line shows that we are reusing a large chunk of
objects, and then we further count any objects not included
in the reused portion with an actual traversal.

These are all implementation details that the user does not
need to care about. Instead, we can show the reused objects
in the normal "counting..." progress meter (which will
simply go much faster than normal), and then continue to add
to it as we traverse.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-objects: turn off bitmaps when skipping objects

The pack bitmap format requires that we have a single bit
for each object in the pack, and that each object's bitmap
represents its complete set of reachable objects. Therefore
we have no way to represent the bitmap of an object which
references objects outside the pack.

We notice this problem while generating the bitmaps, as we
try to find the offset of a particular object and realize
that we do not have it. In this case we die, and neither the
bitmap nor the pack is generated. This is correct, but
perhaps a little unfriendly. If you have bitmaps turned on
in the config, many repacks will fail which would otherwise
succeed. E.g., incremental repacks, repacks with "-l" when
you have alternates, ".keep" files.

Instead, this patch notices early that we are omitting some
objects from the pack and turns off bitmaps (with a
warning). Note that this is not strictly correct, as it's
possible that the object being omitted is not reachable from
any other object in the pack. In practice, this is almost
never the case, and there are two advantages to doing it
this way:

  1. The code is much simpler, as we do not have to cleanly
     abort the bitmap-generation process midway through.

  2. We do not waste time partially generating bitmaps only
     to find out that some object deep in the history is not
     being packed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
index-pack: report error using the correct variable

We feed a string pointer that is potentially NULL to die() when
showing the message.  Don't.

Noticed-by: Nguyễn Thái Ngọc Duy  <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/merge-strategies: avoid hyphenated commands

Replace git-pull and git-merge with the corresponding un-hyphenated
versions. While at it, use ` to mark it up instead of '.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
subtree: initialize "prefix" variable

We parse the "--prefix" command-line option into the
"$prefix" shell variable. However, if we do not see such an
option, the variable is left with whatever value it had in
the environment. We should initialize it to a known value,
like we do for other variables.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
test-lib.sh: do not "echo" caller-supplied strings

In some places we "echo" a string that is supplied by the calling
test script and may contain backslash sequences. The echo command
of some shells, most notably "dash", interprets these backslash
sequences (POSIX.1 allows this) which may scramble the test
output.

Signed-off-by: Uwe Storbeck <uwe@ibr.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add: use struct argv_array in run_add_interactive()

run_add_interactive() in builtin/add.c manually computes array bounds
and allocates a static args array to build the add--interactive command
line, which is error-prone. Use the argv-array helper functions instead.

Signed-off-by: Fabian Ruch <bafain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-no-index: rename read_directory()

In the next patch, we will replace a manual checking of "." or ".."
with a call to is_dot_or_dotdot() defined in dir.h.  The private
function read_directory() defined in this file will conflict with
the global function declared there when we do so.

As a preparatory step, rename the private read_directory() to avoid
the name collision.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Brian Bourn <ba.bourn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-no-index: replace manual "."/".." check with is_dot_or_dotdot()

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Brian Bourn <ba.bourn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t5510: Do not use $(pwd) when fetching / pushing / pulling via rsync

On MINGW, "pwd" is defined as "pwd -W" in test-lib.sh. This usually is the
right thing, but the absolute Windows path with a colon confuses rsync. We
could use $PWD in this case to work around the issue, but in fact there is
no need to use an absolute path in the first place, so get rid of it.

This was discovered in the context of the mingwGitDevEnv project and only
did not surface before with msysgit because the latter does not ship
rsync.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/gitk: document the location of the configulation file

User config file location complies with the XDG base directory
specification while supporting the traditional $HOME/.gitk as a
fallback.

Signed-off-by: Astril Hayato <astrilhayato@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jk/lib-terminal-lazy' into next

The test helper lib-terminal always run an actual test_expect_* when
included, which screwed up with the use of skil-all that may have to
be done later.

* jk/lib-terminal-lazy:
  t/lib-terminal: make TTY a lazy prerequisite
Merge branch 'ah/doc-gitk-config' into next

* ah/doc-gitk-config:
  Documentation/gitk: document the location of the configulation file
Merge branch 'fr/add-interactive-argv-array' into next

* fr/add-interactive-argv-array:
  add: use struct argv_array in run_add_interactive()
Merge branch 'jk/pack-bitmap' into next

* jk/pack-bitmap:
  pack-objects: turn off bitmaps when skipping objects
Merge branch 'jk/pack-bitmap-progress' into next

* jk/pack-bitmap-progress:
  pack-objects: show reused packfile objects in "Counting objects"
  pack-objects: show progress for reused packfiles