gitweb.git
abspath: convert absolute_path() to strbufRené Scharfe Mon, 28 Jul 2014 18:33:55 +0000 (20:33 +0200)

abspath: convert absolute_path() to strbuf

Move most of the code of absolute_path() into the new function
strbuf_add_absolute_path() and in the process transform it to use
struct strbuf and xgetcwd() instead of a PATH_MAX-sized buffer,
which can be too small on some file systems.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use xgetcwd() to set $GIT_DIRRené Scharfe Mon, 28 Jul 2014 18:31:57 +0000 (20:31 +0200)

use xgetcwd() to set $GIT_DIR

Instead of dying of a segmentation fault if getcwd() returns NULL, use
xgetcwd() to make sure to write a useful error message and then exit
in an orderly fashion.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

use xgetcwd() to get the current directory or dieRené Scharfe Mon, 28 Jul 2014 18:30:39 +0000 (20:30 +0200)

use xgetcwd() to get the current directory or die

Convert several calls of getcwd() and die() to use xgetcwd() instead.
This way we get rid of fixed-size buffers (which can be too small
depending on the used file system) and gain consistent error messages.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

wrapper: add xgetcwd()René Scharfe Mon, 28 Jul 2014 18:29:50 +0000 (20:29 +0200)

wrapper: add xgetcwd()

Add the helper function xgetcwd(), which returns the current directory
or dies. The returned string has to be free()d after use.

Helped-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

abspath: convert real_path_internal() to strbufRené Scharfe Mon, 28 Jul 2014 18:28:30 +0000 (20:28 +0200)

abspath: convert real_path_internal() to strbuf

Use strbuf instead of fixed-sized buffers in real_path() in order to
avoid the size limitations of the latter.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

abspath: use strbuf_getcwd() to remember original worki... René Scharfe Mon, 28 Jul 2014 18:27:34 +0000 (20:27 +0200)

abspath: use strbuf_getcwd() to remember original working directory

Store the original working directory in a strbuf instead of in a
fixed-sized buffer, in order to be able to handle longer paths.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

setup: convert setup_git_directory_gently_1 et al.... René Scharfe Mon, 28 Jul 2014 18:26:40 +0000 (20:26 +0200)

setup: convert setup_git_directory_gently_1 et al. to strbuf

Convert setup_git_directory_gently_1() and its helper functions
setup_explicit_git_dir(), setup_discovered_git_dir() and
setup_bare_git_dir() to use a struct strbuf to hold the current working
directory. Replacing the PATH_MAX-sized buffer used before removes a
path length limition on some file systems. The functions are converted
all in one go because they all read and write the variable cwd.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

unix-sockets: use strbuf_getcwd()René Scharfe Mon, 28 Jul 2014 18:25:40 +0000 (20:25 +0200)

unix-sockets: use strbuf_getcwd()

Instead of using a PATH_MAX-sized buffer, which can be too small on some
file systems, use strbuf_getcwd(), which handles any path getcwd()
returns. Also preserve the errno set by strbuf_getcwd() instead of
setting it to ENAMETOOLONG; that way a more appropriate error message
can be shown based on the actual reason for failing.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

strbuf: add strbuf_getcwd()René Scharfe Mon, 28 Jul 2014 18:24:29 +0000 (20:24 +0200)

strbuf: add strbuf_getcwd()

Add strbuf_getcwd(), which puts the current working directory into a
strbuf. Because it doesn't use a fixed-size buffer it supports
arbitrarily long paths, provided the platform's getcwd() does as well.
At least on Linux and FreeBSD it handles paths longer than PATH_MAX
just fine.

Suggested-by: Karsten Blees <karsten.blees@gmail.com>
Helped-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git 2.0.2 v2.0.2Junio C Hamano Wed, 16 Jul 2014 18:19:56 +0000 (11:19 -0700)

Git 2.0.2

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

Merge branch 'jc/fix-clone-single-starting-at-a-tag... Junio C Hamano Wed, 16 Jul 2014 18:17:36 +0000 (11:17 -0700)

Merge branch 'jc/fix-clone-single-starting-at-a-tag' into maint

"git clone -b brefs/tags/bar" would have mistakenly thought we were
following a single tag, even though it was a name of the branch,
because it incorrectly used strstr().

* jc/fix-clone-single-starting-at-a-tag:
builtin/clone.c: detect a clone starting at a tag correctly

Merge branch 'jk/pretty-G-format-fixes' into maintJunio C Hamano Wed, 16 Jul 2014 18:17:21 +0000 (11:17 -0700)

Merge branch 'jk/pretty-G-format-fixes' into maint

"%G" (nothing after G) is an invalid pretty format specifier, but
the parser did not notice it as garbage.

* jk/pretty-G-format-fixes:
move "%G" format test from t7510 to t6006
pretty: avoid reading past end-of-string with "%G"
t7510: check %G* pretty-format output
t7510: test a commit signed by an unknown key
t7510: use consistent &&-chains in loop
t7510: stop referring to master in later tests

Merge branch 'rs/fix-alt-odb-path-comparison' into... Junio C Hamano Wed, 16 Jul 2014 18:17:08 +0000 (11:17 -0700)

Merge branch 'rs/fix-alt-odb-path-comparison' into maint

Code to avoid adding the same alternate object store twice was
subtly broken for a long time, but nobody seems to have noticed.

* rs/fix-alt-odb-path-comparison:
sha1_file: avoid overrunning alternate object base string

Merge branch 'jk/commit-buffer-length' into maintJunio C Hamano Wed, 16 Jul 2014 18:16:38 +0000 (11:16 -0700)

Merge branch 'jk/commit-buffer-length' into maint

A handful of code paths had to read the commit object more than
once when showing header fields that are usually not parsed. The
internal data structure to keep track of the contents of the commit
object has been updated to reduce the need for this double-reading,
and to allow the caller find the length of the object.

* jk/commit-buffer-length:
reuse cached commit buffer when parsing signatures
commit: record buffer length in cache
commit: convert commit->buffer to a slab
commit-slab: provide a static initializer
use get_commit_buffer everywhere
convert logmsg_reencode to get_commit_buffer
use get_commit_buffer to avoid duplicate code
use get_cached_commit_buffer where appropriate
provide helpers to access the commit buffer
provide a helper to set the commit buffer
provide a helper to free commit buffer
sequencer: use logmsg_reencode in get_message
logmsg_reencode: return const buffer
do not create "struct commit" with xcalloc
commit: push commit_index update into alloc_commit_node
alloc: include any-object allocations in alloc_report
replace dangerous uses of strbuf_attach
commit_tree: take a pointer/len pair rather than a const strbuf

Merge branch 'bc/fix-rebase-merge-skip' into maintJunio C Hamano Wed, 16 Jul 2014 18:16:16 +0000 (11:16 -0700)

Merge branch 'bc/fix-rebase-merge-skip' into maint

During "git rebase --merge", a conflicted patch could not be
skipped with "--skip" if the next one also conflicted.

* bc/fix-rebase-merge-skip:
rebase--merge: fix --skip with two conflicts in a row

Merge branch 'maint-1.9' into maintJunio C Hamano Wed, 16 Jul 2014 18:11:06 +0000 (11:11 -0700)

Merge branch 'maint-1.9' into maint

* maint-1.9:
annotate: use argv_array

Merge branch 'maint-1.8.5' into maint-1.9Junio C Hamano Wed, 16 Jul 2014 18:10:30 +0000 (11:10 -0700)

Merge branch 'maint-1.8.5' into maint-1.9

* maint-1.8.5:
annotate: use argv_array
t7300: repair filesystem permissions with test_when_finished
enums: remove trailing ',' after last item in enum

annotate: use argv_arrayRené Scharfe Wed, 16 Jul 2014 08:51:33 +0000 (10:51 +0200)

annotate: use argv_array

Simplify the code and get rid of some magic constants by using
argv_array to build the argument list for cmd_blame. Be lazy and let
the OS release our allocated memory, as before.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Start preparing for 2.0.2Junio C Hamano Thu, 10 Jul 2014 18:15:10 +0000 (11:15 -0700)

Start preparing for 2.0.2

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

Merge branch 'pb/trim-trailing-spaces' into maintJunio C Hamano Thu, 10 Jul 2014 18:10:52 +0000 (11:10 -0700)

Merge branch 'pb/trim-trailing-spaces' into maint

* pb/trim-trailing-spaces:
t0008: do not depend on 'echo' handling backslashes specially
dir.c:trim_trailing_spaces(): fix for " \ " sequence

Merge branch 'jk/repack-pack-keep-objects' into maintJunio C Hamano Thu, 10 Jul 2014 18:10:05 +0000 (11:10 -0700)

Merge branch 'jk/repack-pack-keep-objects' into maint

* jk/repack-pack-keep-objects:
repack: s/write_bitmap/&s/ in code
repack: respect pack.writebitmaps
repack: do not accidentally pack kept objects by default

Merge branch 'mc/doc-submodule-sync-recurse' into maintJunio C Hamano Thu, 10 Jul 2014 18:08:31 +0000 (11:08 -0700)

Merge branch 'mc/doc-submodule-sync-recurse' into maint

* mc/doc-submodule-sync-recurse:
submodule: document "sync --recursive"

Merge branch 'maint-1.8.5' into maintJunio C Hamano Wed, 2 Jul 2014 19:51:50 +0000 (12:51 -0700)

Merge branch 'maint-1.8.5' into maint

* maint-1.8.5:
t7300: repair filesystem permissions with test_when_finished
enums: remove trailing ',' after last item in enum

t7300: repair filesystem permissions with test_when_fin... Jeff King Wed, 2 Jul 2014 18:44:30 +0000 (14:44 -0400)

t7300: repair filesystem permissions with test_when_finished

We create a directory that cannot be removed, confirm that
it cannot be removed, and then fix it like:

chmod 0 foo &&
test_must_fail git clean -d -f &&
chmod 755 foo

If the middle step fails but leaves the directory (e.g., the
bug is that clean does not notice the failure), this
pollutes the test repo with an unremovable directory. Not
only does this cause further tests to fail, but it means
that "rm -rf" fails on the whole trash directory, and the
user has to intervene manually to even re-run the test script.

We can bump the "chmod 755" recovery to a test_when_finished
block to be sure that it always runs.

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

enums: remove trailing ',' after last item in enumRonnie Sahlberg Wed, 2 Jul 2014 18:24:05 +0000 (11:24 -0700)

enums: remove trailing ',' after last item in enum

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_file: avoid overrunning alternate object base... René Scharfe Tue, 1 Jul 2014 18:00:01 +0000 (20:00 +0200)

sha1_file: avoid overrunning alternate object base string

While checking if a new alternate object database is a duplicate make
sure that old and new base paths have the same length before comparing
them with memcmp. This avoids overrunning the buffer of the existing
entry if the new one is longer and it stops rejecting foobar/ after
foo/ was already added.

Signed-off-by: Rene Scharfe <ls.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

move "%G" format test from t7510 to t6006Jeff King Wed, 25 Jun 2014 21:42:17 +0000 (17:42 -0400)

move "%G" format test from t7510 to t6006

The final test in t7510 checks that "--format" placeholders
that look similar to GPG placeholders (but that we don't
actually understand) are passed through. That test was
placed in t7510, since the other GPG placeholder tests are
there. However, it does not have a GPG prerequisite, because
it is not actually checking any signed commits.

This causes the test to erroneously fail when gpg is not
installed on a system, however. Not because we need signed
commits, but because we need _any_ commit to run "git log".
If we don't have gpg installed, t7510 doesn't create any
commits at all.

We can fix this by moving the test into t6006. This is
arguably a better place anyway, because it is where we test
most of the other placeholders (we do not test GPG
placeholders there because of the infrastructure needed to
make signed commits).

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

Git 2.0.1 v2.0.1Junio C Hamano Wed, 25 Jun 2014 19:21:11 +0000 (12:21 -0700)

Git 2.0.1

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

Merge branch 'na/no-http-test-in-the-middle' into maintJunio C Hamano Wed, 25 Jun 2014 18:50:13 +0000 (11:50 -0700)

Merge branch 'na/no-http-test-in-the-middle' into maint

The mode to run tests with HTTP server tests disabled was broken.

* na/no-http-test-in-the-middle:
t5538: move http push tests out to t5542

Merge branch 'jl/status-added-submodule-is-never-ignore... Junio C Hamano Wed, 25 Jun 2014 18:50:03 +0000 (11:50 -0700)

Merge branch 'jl/status-added-submodule-is-never-ignored' into maint

"git status" (and "git commit") behaved as if changes in a modified
submodule are not there if submodule.*.ignore configuration is set,
which was misleading. The configuration is only to unclutter diff
output during the course of development, and should not to hide
changes in the "status" output to cause the users forget to commit
them.

* jl/status-added-submodule-is-never-ignored:
commit -m: commit staged submodules regardless of ignore config
status/commit: show staged submodules regardless of ignore config

Merge branch 'ym/fix-opportunistic-index-update-race... Junio C Hamano Wed, 25 Jun 2014 18:49:48 +0000 (11:49 -0700)

Merge branch 'ym/fix-opportunistic-index-update-race' into maint

"git status", even though it is a read-only operation, tries to
update the index with refreshed lstat(2) info to optimize future
accesses to the working tree opportunistically, but this could
race with a "read-write" operation that modify the index while it
is running. Detect such a race and avoid overwriting the index.

* ym/fix-opportunistic-index-update-race:
read-cache.c: verify index file before we opportunistically update it
wrapper.c: add xpread() similar to xread()

Merge branch 'mk/show-s-no-extra-blank-line-for-merges... Junio C Hamano Wed, 25 Jun 2014 18:49:39 +0000 (11:49 -0700)

Merge branch 'mk/show-s-no-extra-blank-line-for-merges' into maint

"git show -s" (i.e. show log message only) used to incorrectly emit
an extra blank line after a merge commit.

* mk/show-s-no-extra-blank-line-for-merges:
git-show: fix 'git show -s' to not add extra terminator after merge commit

Merge branch 'rr/rebase-autostash-fix' into maintJunio C Hamano Wed, 25 Jun 2014 18:49:31 +0000 (11:49 -0700)

Merge branch 'rr/rebase-autostash-fix' into maint

The autostash mode of "git rebase -i" did not restore the dirty
working tree state if the user aborted the interactive rebase by
emptying the insn sheet.

* rr/rebase-autostash-fix:
rebase -i: test "Nothing to do" case with autostash
rebase -i: handle "Nothing to do" case with autostash

Merge branch 'jc/shortlog-ref-exclude' into maintJunio C Hamano Wed, 25 Jun 2014 18:49:10 +0000 (11:49 -0700)

Merge branch 'jc/shortlog-ref-exclude' into maint

"git log --exclude=<glob> --all | git shortlog" worked as expected,
but "git shortlog --exclude=<glob> --all", which is supposed to be
identical to the above pipeline, was not accepted at the command
line argument parser level.

* jc/shortlog-ref-exclude:
shortlog: allow --exclude=<glob> to be passed

Merge branch 'jl/remote-rm-prune' into maintJunio C Hamano Wed, 25 Jun 2014 18:49:01 +0000 (11:49 -0700)

Merge branch 'jl/remote-rm-prune' into maint

"git remote rm" and "git remote prune" can involve removing many
refs at once, which is not a very efficient thing to do when very
many refs exist in the packed-refs file.

* jl/remote-rm-prune:
remote prune: optimize "dangling symref" check/warning
remote: repack packed-refs once when deleting multiple refs
remote rm: delete remote configuration as the last

Merge branch 'fc/rerere-conflict-style' into maintJunio C Hamano Wed, 25 Jun 2014 18:48:54 +0000 (11:48 -0700)

Merge branch 'fc/rerere-conflict-style' into maint

"git rerere forget" did not work well when merge.conflictstyle
was set to a non-default value.

* fc/rerere-conflict-style:
rerere: fix for merge.conflictstyle

Merge branch 'rs/pack-objects-no-unnecessary-realloc... Junio C Hamano Wed, 25 Jun 2014 18:48:42 +0000 (11:48 -0700)

Merge branch 'rs/pack-objects-no-unnecessary-realloc' into maint

"git pack-objects" unnecessarily copied the previous contents when
extending the hashtable, even though it will populate the table
from scratch anyway.

* rs/pack-objects-no-unnecessary-realloc:
pack-objects: use free()+xcalloc() instead of xrealloc()+memset()

Merge branch 'dt/merge-recursive-case-insensitive'... Junio C Hamano Wed, 25 Jun 2014 18:48:34 +0000 (11:48 -0700)

Merge branch 'dt/merge-recursive-case-insensitive' into maint

On a case insensitive filesystem, merge-recursive incorrectly
deleted the file that is to be renamed to a name that is the same
except for case differences.

* dt/merge-recursive-case-insensitive:
mv: allow renaming to fix case on case insensitive filesystems
merge-recursive.c: fix case-changing merge bug

Merge branch 'rs/mailinfo-header-cmp' into maintJunio C Hamano Wed, 25 Jun 2014 18:48:23 +0000 (11:48 -0700)

Merge branch 'rs/mailinfo-header-cmp' into maint

"git mailinfo" used to read beyond the end of header string while
parsing an incoming e-mail message to extract the patch.

* rs/mailinfo-header-cmp:
mailinfo: use strcmp() for string comparison

Merge branch 'jk/index-pack-report-missing' into maintJunio C Hamano Wed, 25 Jun 2014 18:48:13 +0000 (11:48 -0700)

Merge branch 'jk/index-pack-report-missing' into maint

The error reporting from "git index-pack" has been improved to
distinguish missing objects from type errors.

* jk/index-pack-report-missing:
index-pack: distinguish missing objects from type errors

Merge branch 'nd/index-pack-one-fd-per-thread' into... Junio C Hamano Wed, 25 Jun 2014 18:47:58 +0000 (11:47 -0700)

Merge branch 'nd/index-pack-one-fd-per-thread' into maint

We used to disable threaded "git index-pack" on platforms without
thread-safe pread(); use a different workaround for such
platforms to allow threaded "git index-pack".

* nd/index-pack-one-fd-per-thread:
index-pack: work around thread-unsafe pread()

Merge branch 'sk/spawn-less-case-insensitively-from... Junio C Hamano Wed, 25 Jun 2014 18:47:49 +0000 (11:47 -0700)

Merge branch 'sk/spawn-less-case-insensitively-from-grep-O-i' into maint

"git grep -O" to show the lines that hit in the pager did not work
well with case insensitive search. We now spawn "less" with its
"-I" option when it is used as the pager (which is the default).

* sk/spawn-less-case-insensitively-from-grep-O-i:
git grep -O -i: if the pager is 'less', pass the '-I' option

Merge branch 'nd/daemonize-gc' into maintJunio C Hamano Wed, 25 Jun 2014 18:47:36 +0000 (11:47 -0700)

Merge branch 'nd/daemonize-gc' into maint

"git gc --auto" was recently changed to run in the background to
give control back early to the end-user sitting in front of the
terminal, but it forgot that housekeeping involving reflogs should
be done without other processes competing for accesses to the refs.

* nd/daemonize-gc:
gc --auto: do not lock refs in the background

Merge branch 'jk/diff-follow-must-take-one-pathspec... Junio C Hamano Wed, 25 Jun 2014 18:47:23 +0000 (11:47 -0700)

Merge branch 'jk/diff-follow-must-take-one-pathspec' into maint

"git format-patch" did not enforce the rule that the "--follow"
option from the log/diff family of commands must be used with
exactly one pathspec.

* jk/diff-follow-must-take-one-pathspec:
move "--follow needs one pathspec" rule to diff_setup_done

Merge branch 'jk/diff-files-assume-unchanged' into... Junio C Hamano Wed, 25 Jun 2014 18:47:09 +0000 (11:47 -0700)

Merge branch 'jk/diff-files-assume-unchanged' into maint

"git diff --find-copies-harder" sometimes pretended as if the mode
bits have changed for paths that are marked with assume-unchanged
bit.

* jk/diff-files-assume-unchanged:
run_diff_files: do not look at uninitialized stat data

Merge branch 'jk/commit-C-pick-empty' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:54 +0000 (11:46 -0700)

Merge branch 'jk/commit-C-pick-empty' into maint

"git commit --allow-empty-message -C $commit" did not work when the
commit did not have any log message.

* jk/commit-C-pick-empty:
commit: do not complain of empty messages from -C

Merge branch 'bc/blame-crlf-test' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:44 +0000 (11:46 -0700)

Merge branch 'bc/blame-crlf-test' into maint

"git blame" assigned the blame to the copy in the working-tree if
the repository is set to core.autocrlf=input and the file used CRLF
line endings.

* bc/blame-crlf-test:
blame: correctly handle files regardless of autocrlf

Merge branch 'jx/blame-align-relative-time' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:34 +0000 (11:46 -0700)

Merge branch 'jx/blame-align-relative-time' into maint

"git blame" miscounted number of columns needed to show localized
timestamps, resulting in jaggy left-side-edge of the source code
lines in its output.

* jx/blame-align-relative-time:
blame: dynamic blame_date_width for different locales
blame: fix broken time_buf paddings in relative timestamp

Merge branch 'jc/apply-ignore-whitespace' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:23 +0000 (11:46 -0700)

Merge branch 'jc/apply-ignore-whitespace' into maint

"--ignore-space-change" option of "git apply" ignored the spaces
at the beginning of line too aggressively, which is inconsistent
with the option of the same name "diff" and "git diff" have.

* jc/apply-ignore-whitespace:
apply --ignore-space-change: lines with and without leading whitespaces do not match

Merge branch 'jk/complete-merge-pull' into maintJunio C Hamano Wed, 25 Jun 2014 18:46:12 +0000 (11:46 -0700)

Merge branch 'jk/complete-merge-pull' into maint

The completion scripts (in contrib/) did not know about quite a few
options that are common between "git merge" and "git pull", and a
couple of options unique to "git merge".

* jk/complete-merge-pull:
completion: add missing options for git-merge
completion: add a note that merge options are shared

Merge branch 'ow/config-mailmap-pathname' into maintJunio C Hamano Wed, 25 Jun 2014 18:45:55 +0000 (11:45 -0700)

Merge branch 'ow/config-mailmap-pathname' into maint

The "mailmap.file" configuration option did not support the tilde
expansion (i.e. ~user/path and ~/path).

* ow/config-mailmap-pathname:
config: respect '~' and '~user' in mailmap.file

Merge branch 'as/pretty-truncate' into maintJunio C Hamano Wed, 25 Jun 2014 18:45:31 +0000 (11:45 -0700)

Merge branch 'as/pretty-truncate' into maint

The "%<(10,trunc)%s" pretty format specifier in the log family of
commands is used to truncate the string to a given length (e.g. 10
in the example) with padding to column-align the output, but did
not take into account that number of bytes and number of display
columns are different.

* as/pretty-truncate:
pretty.c: format string with truncate respects logOutputEncoding
t4205, t6006: add tests that fail with i18n.logOutputEncoding set
t4205 (log-pretty-format): use `tformat` rather than `format`
t4041, t4205, t6006, t7102: don't hardcode tested encoding value
t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs

Merge branch 'jc/revision-dash-count-parsing' into... Junio C Hamano Wed, 25 Jun 2014 18:44:53 +0000 (11:44 -0700)

Merge branch 'jc/revision-dash-count-parsing' into maint

"git log -2master" is a common typo that shows two commits starting
from whichever random branch that is not 'master' that happens to
be checked out currently.

* jc/revision-dash-count-parsing:
revision: parse "git log -<count>" more carefully

Merge branch 'jk/report-fail-to-read-objects-better... Junio C Hamano Wed, 25 Jun 2014 18:43:57 +0000 (11:43 -0700)

Merge branch 'jk/report-fail-to-read-objects-better' into maint

Reworded the error message given upon a failure to open an existing
loose object file due to e.g. permission issues; it was reported as
the object being corrupt, but that is not quite true.

* jk/report-fail-to-read-objects-better:
open_sha1_file: report "most interesting" errno

Merge branch 'mn/sideband-no-ansi' into maintJunio C Hamano Wed, 25 Jun 2014 18:43:43 +0000 (11:43 -0700)

Merge branch 'mn/sideband-no-ansi' into maint

Tools that read diagnostic output in our standard error stream do
not want to see terminal control sequence (e.g. erase-to-eol).
Detect them by checking if the standard error stream is connected
to a tty.

* mn/sideband-no-ansi:
sideband.c: do not use ANSI control sequence on non-terminal

Merge branch 'je/pager-do-not-recurse' into maintJunio C Hamano Wed, 25 Jun 2014 18:43:07 +0000 (11:43 -0700)

Merge branch 'je/pager-do-not-recurse' into maint

We used to unconditionally disable the pager in the pager process
we spawn to feed out output, but that prevented people who want to
run "less" within "less" from doing so.

* je/pager-do-not-recurse:
pager: do allow spawning pager recursively

builtin/clone.c: detect a clone starting at a tag correctlyJunio C Hamano Mon, 23 Jun 2014 21:27:36 +0000 (14:27 -0700)

builtin/clone.c: detect a clone starting at a tag correctly

31b808a0 (clone --single: limit the fetch refspec to fetched branch,
2012-09-20) tried to see if the given "branch" to follow is actually
a tag at the remote repository by checking with "refs/tags/" but it
incorrectly used strstr(3); it is actively wrong to treat a "branch"
"refs/heads/refs/tags/foo" and use the logic for the "refs/tags/"
ref hierarchy. What the code really wanted to do is to see if it
starts with "refs/tags/".

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

pretty: avoid reading past end-of-string with "%G"Jeff King Tue, 17 Jun 2014 00:07:07 +0000 (20:07 -0400)

pretty: avoid reading past end-of-string with "%G"

If the user asks for --format=%G with nothing else, we
correctly realize that "%G" is not a valid placeholder (it
should be "%G?", "%GK", etc). But we still tell the
strbuf_expand code that we consumed 2 characters, causing it
to jump over the trailing NUL and output garbage.

This also fixes the case where "%GX" would be consumed (and
produce no output). In other cases, we pass unrecognized
placeholders through to the final string.

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

t7510: check %G* pretty-format outputJeff King Tue, 17 Jun 2014 00:06:24 +0000 (20:06 -0400)

t7510: check %G* pretty-format output

We do not check these along with the other pretty-format
placeholders in t6006, because we need signed commits to
make them interesting. t7510 has such commits, and can
easily exercise them in addition to the regular
--show-signature code path.

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

t7510: test a commit signed by an unknown keyJeff King Tue, 17 Jun 2014 00:05:54 +0000 (20:05 -0400)

t7510: test a commit signed by an unknown key

We tested both good and bad signatures, but not ones made
correctly but with a key for which we have no trust.

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

t7510: use consistent &&-chains in loopMichael J Gruber Tue, 17 Jun 2014 00:03:43 +0000 (20:03 -0400)

t7510: use consistent &&-chains in loop

We check multiple commits in a loop. Because we want to
break out of the loop if any single iteration fails, we use
a subshell/exit like:

(
for i in $stuff
do
do-something $i || exit 1
done
)

However, we are inconsistent in our loop body. Some commands
get their own "|| exit 1", and others try to chain to the
next command with "&&", like:

X &&
Y || exit 1
Z || exit 1

This is a little hard to read and follow, because X and Y
are treated differently for no good reason. But much worse,
the second loop follows a similar pattern and gets it wrong.
"Y" is expected to fail, so we use "&& exit 1", giving us:

X &&
Y && exit 1
Z || exit 1

That gets the test for X wrong (we do not exit unless both X
fails and Y unexpectedly succeeds, but we would want to exit
if _either_ is wrong). We can write this clearly and
correctly by consistently using "&&", followed by a single
"|| exit 1", and negating Y with "!" (as we would in a
normal &&-chain). Like:

X &&
! Y &&
Z || exit 1

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

t7510: stop referring to master in later testsJeff King Mon, 16 Jun 2014 23:59:59 +0000 (19:59 -0400)

t7510: stop referring to master in later tests

Our setup creates a sequence of commits, each with its own
tag. However, we sometimes refer to "seventh-signed" as
"master". This works, since it is at the tip of the created
branch, but is brittle if new tests need to add more
commits. Let's use its tag name to be unambiguous.

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

rebase--merge: fix --skip with two conflicts in a rowbrian m. carlson Mon, 16 Jun 2014 00:01:25 +0000 (00:01 +0000)

rebase--merge: fix --skip with two conflicts in a row

If git rebase --merge encountered a conflict, --skip would not work if the
next commit also conflicted. The msgnum file would never be updated with
the new patch number, so no patch would actually be skipped, resulting in an
inescapable loop.

Update the msgnum file's value as the first thing in call_merge. This also
avoids an "Already applied" message when skipping a commit. There is no
visible change for the other contexts in which call_merge is invoked, as the
msgnum file's value remains unchanged in those situations.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: document "sync --recursive"Matthew Chen Fri, 13 Jun 2014 17:40:50 +0000 (13:40 -0400)

submodule: document "sync --recursive"

The "git submodule sync" command supports the --recursive flag, but
the documentation does not mention this. That flag is useful, for
example when a remote is changed in a submodule of a submodule.

Signed-off-by: Matthew Chen <charlesmchen@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t0008: do not depend on 'echo' handling backslashes... Junio C Hamano Fri, 13 Jun 2014 20:23:58 +0000 (13:23 -0700)

t0008: do not depend on 'echo' handling backslashes specially

The original used to pass with /bin/dash but not with /bin/bash set
to $SHELL_PATH. The former turns "\\" into "\", but the latter does
not.

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

reuse cached commit buffer when parsing signaturesJeff King Fri, 13 Jun 2014 06:32:11 +0000 (02:32 -0400)

reuse cached commit buffer when parsing signatures

When we call show_signature or show_mergetag, we read the
commit object fresh via read_sha1_file and reparse its
headers. However, in most cases we already have the object
data available, attached to the "struct commit". This is
partially laziness in dealing with the memory allocation
issues, but partially defensive programming, in that we
would always want to verify a clean version of the buffer
(not one that might have been munged by other users of the
commit).

However, we do not currently ever munge the commit buffer,
and not using the already-available buffer carries a fairly
big performance penalty when we are looking at a large
number of commits. Here are timings on linux.git:

[baseline, no signatures]
$ time git log >/dev/null
real 0m4.902s
user 0m4.784s
sys 0m0.120s

[before]
$ time git log --show-signature >/dev/null
real 0m14.735s
user 0m9.964s
sys 0m0.944s

[after]
$ time git log --show-signature >/dev/null
real 0m9.981s
user 0m5.260s
sys 0m0.936s

Note that our user CPU time drops almost in half, close to
the non-signature case, but we do still spend more
wall-clock and system time, presumably from dealing with
gpg.

An alternative to this is to note that most commits do not
have signatures (less than 1% in this repo), yet we pay the
re-parsing cost for every commit just to find out if it has
a mergetag or signature. If we checked that when parsing the
commit initially, we could avoid re-examining most commits
later on. Even if we did pursue that direction, however,
this would still speed up the cases where we _do_ have
signatures. So it's probably worth doing either way.

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

commit: record buffer length in cacheJeff King Tue, 10 Jun 2014 21:44:13 +0000 (17:44 -0400)

commit: record buffer length in cache

Most callsites which use the commit buffer try to use the
cached version attached to the commit, rather than
re-reading from disk. Unfortunately, that interface provides
only a pointer to the NUL-terminated buffer, with no
indication of the original length.

For the most part, this doesn't matter. People do not put
NULs in their commit messages, and the log code is happy to
treat it all as a NUL-terminated string. However, some code
paths do care. For example, when checking signatures, we
want to be very careful that we verify all the bytes to
avoid malicious trickery.

This patch just adds an optional "size" out-pointer to
get_commit_buffer and friends. The existing callers all pass
NULL (there did not seem to be any obvious sites where we
could avoid an immediate strlen() call, though perhaps with
some further refactoring we could).

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

commit: convert commit->buffer to a slabJeff King Tue, 10 Jun 2014 21:43:02 +0000 (17:43 -0400)

commit: convert commit->buffer to a slab

This will make it easier to manage the buffer cache
independently of the "struct commit" objects. It also
shrinks "struct commit" by one pointer, which may be
helpful.

Unfortunately it does not reduce the max memory size of
something like "rev-list", because rev-list uses
get_cached_commit_buffer() to decide not to show each
commit's output (and due to the design of slab_at, accessing
the slab requires us to extend it, allocating exactly the
same number of buffer pointers we dropped from the commit
structs).

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

commit-slab: provide a static initializerJeff King Tue, 10 Jun 2014 21:42:51 +0000 (17:42 -0400)

commit-slab: provide a static initializer

Callers currently must use init_foo_slab() at runtime before
accessing a slab. For global slabs, it's much nicer if we
can initialize them in BSS, so that each user does not have
to add code to check-and-initialize.

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

use get_commit_buffer everywhereJeff King Tue, 10 Jun 2014 21:41:51 +0000 (17:41 -0400)

use get_commit_buffer everywhere

Each of these sites assumes that commit->buffer is valid.
Since they would segfault if this was not the case, they are
likely to be correct in practice. However, we can
future-proof them by using get_commit_buffer.

And as a side effect, we abstract away the final bare uses
of commit->buffer.

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

convert logmsg_reencode to get_commit_bufferJeff King Tue, 10 Jun 2014 21:41:39 +0000 (17:41 -0400)

convert logmsg_reencode to get_commit_buffer

Like the callsites in the previous commit, logmsg_reencode
already falls back to read_sha1_file when necessary.
However, I split its conversion out into its own commit
because it's a bit more complex.

We return either:

1. The original commit->buffer

2. A newly allocated buffer from read_sha1_file

3. A reencoded buffer (based on either 1 or 2 above).

while trying to do as few extra reads/allocations as
possible. Callers currently free the result with
logmsg_free, but we can simplify this by pointing them
straight to unuse_commit_buffer. This is a slight layering
violation, in that we may be passing a buffer from (3).
However, since the end result is to free() anything except
(1), which is unlikely to change, and because this makes the
interface much simpler, it's a reasonable bending of the
rules.

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

use get_commit_buffer to avoid duplicate codeJeff King Tue, 10 Jun 2014 21:41:02 +0000 (17:41 -0400)

use get_commit_buffer to avoid duplicate code

For both of these sites, we already do the "fallback to
read_sha1_file" trick. But we can shorten the code by just
using get_commit_buffer.

Note that the error cases are slightly different when
read_sha1_file fails. get_commit_buffer will die() if the
object cannot be loaded, or is a non-commit.

For get_sha1_oneline, this will almost certainly never
happen, as we will have just called parse_object (and if it
does, it's probably worth complaining about).

For record_author_date, the new behavior is probably better;
we notify the user of the error instead of silently ignoring
it. And because it's used only for sorting by author-date,
somebody examining a corrupt repo can fallback to the
regular traversal order.

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

use get_cached_commit_buffer where appropriateJeff King Tue, 10 Jun 2014 21:40:46 +0000 (17:40 -0400)

use get_cached_commit_buffer where appropriate

Some call sites check commit->buffer to see whether we have
a cached buffer, and if so, do some work with it. In the
long run we may want to switch these code paths to make
their decision on a different boolean flag (because checking
the cache may get a little more expensive in the future).
But for now, we can easily support them by converting the
calls to use get_cached_commit_buffer.

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

provide helpers to access the commit bufferJeff King Tue, 10 Jun 2014 21:40:39 +0000 (17:40 -0400)

provide helpers to access the commit buffer

Many sites look at commit->buffer to get more detailed
information than what is in the parsed commit struct.
However, we sometimes drop commit->buffer to save memory,
in which case the caller would need to read the object
afresh. Some callers do this (leading to duplicated code),
and others do not (which opens the possibility of a segfault
if somebody else frees the buffer).

Let's provide a pair of helpers, "get" and "unuse", that let
callers easily get the buffer. They will use the cached
buffer when possible, and otherwise load from disk using
read_sha1_file.

Note that we also need to add a "get_cached" variant which
returns NULL when we do not have a cached buffer. At first
glance this seems to defeat the purpose of "get", which is
to always provide a return value. However, some log code
paths actually use the NULL-ness of commit->buffer as a
boolean flag to decide whether to try printing the
commit. At least for now, we want to continue supporting
that use.

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

provide a helper to set the commit bufferJeff King Tue, 10 Jun 2014 21:40:14 +0000 (17:40 -0400)

provide a helper to set the commit buffer

Right now this is just a one-liner, but abstracting it will
make it easier to change later.

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

provide a helper to free commit bufferJeff King Thu, 12 Jun 2014 22:05:37 +0000 (18:05 -0400)

provide a helper to free commit buffer

This converts two lines into one at each caller. But more
importantly, it abstracts the concept of freeing the buffer,
which will make it easier to change later.

Note that we also need to provide a "detach" mechanism for a
tricky case in index-pack. We are passed a buffer for the
object generated by processing the incoming pack. If we are
not using --strict, we just calculate the sha1 on that
buffer and return, leaving the caller to free it. But if we
are using --strict, we actually attach that buffer to an
object, pass the object to the fsck functions, and then
detach the buffer from the object again (so that the caller
can free it as usual). In this case, we don't want to free
the buffer ourselves, but just make sure it is no longer
associated with the commit.

Note that we are making the assumption here that the
attach/detach process does not impact the buffer at all
(e.g., it is never reallocated or modified). That holds true
now, and we have no plans to change that. However, as we
abstract the commit_buffer code, this dependency becomes
less obvious. So when we detach, let's also make sure that
we get back the same buffer that we gave to the
commit_buffer code.

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

Merge branch 'jc/rev-parse-argh-dashed-multi-words... Junio C Hamano Thu, 12 Jun 2014 19:17:57 +0000 (12:17 -0700)

Merge branch 'jc/rev-parse-argh-dashed-multi-words' into maint

* jc/rev-parse-argh-dashed-multi-words:
update-index: fix segfault with missing --cacheinfo argument

pull: do not abuse 'break' inside a shell 'case'Jacek Konieczny Wed, 11 Jun 2014 08:47:45 +0000 (10:47 +0200)

pull: do not abuse 'break' inside a shell 'case'

It is not C. The code would break under mksh when 'pull.ff' is set:

$ git pull
/usr/lib/git-core/git-pull[67]: break: can't break
Already up-to-date.

Signed-off-by: Jacek Konieczny <jajcus@jajcus.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sequencer: use logmsg_reencode in get_messageJeff King Tue, 10 Jun 2014 21:39:35 +0000 (17:39 -0400)

sequencer: use logmsg_reencode in get_message

This simplifies the code, as logmsg_reencode handles the
reencoding for us in a single call. It also means we learn
logmsg_reencode's trick of pulling the buffer from disk when
commit->buffer is NULL (we currently just silently return!).
It is doubtful this matters in practice, though, as
sequencer operations would not generally turn off
save_commit_buffer.

Note that we may be fixing a bug here. The existing code
does:

if (same_encoding(to, from))
reencode_string(buf, to, from);

That probably should have been "!same_encoding".

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

logmsg_reencode: return const bufferJeff King Tue, 10 Jun 2014 21:39:30 +0000 (17:39 -0400)

logmsg_reencode: return const buffer

The return value from logmsg_reencode may be either a newly
allocated buffer or a pointer to the existing commit->buffer.
We would not want the caller to accidentally free() or
modify the latter, so let's mark it as const. We can cast
away the constness in logmsg_free, but only once we have
determined that it is a free-able buffer.

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

do not create "struct commit" with xcallocJeff King Tue, 10 Jun 2014 21:39:11 +0000 (17:39 -0400)

do not create "struct commit" with xcalloc

In both blame and merge-recursive, we sometimes create a
"fake" commit struct for convenience (e.g., to represent the
HEAD state as if we would commit it). By allocating
ourselves rather than using alloc_commit_node, we do not
properly set the "index" field of the commit. This can
produce subtle bugs if we then use commit-slab on the
resulting commit, as we will share the "0" index with
another commit.

We can fix this by using alloc_commit_node() to allocate.
Note that we cannot free the result, as it is part of our
commit allocator. However, both cases were already leaking
the allocated commit anyway, so there's nothing to fix up.

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

commit: push commit_index update into alloc_commit_nodeJeff King Tue, 10 Jun 2014 21:39:04 +0000 (17:39 -0400)

commit: push commit_index update into alloc_commit_node

Whenever we create a commit object via lookup_commit, we
give it a unique index to be used with the commit-slab API.
The theory is that any "struct commit" we create would
follow this code path, so any such struct would get an
index. However, callers could use alloc_commit_node()
directly (and get multiple commits with index 0).

Let's push the indexing into alloc_commit_node so that it's
hard for callers to get it wrong.

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

alloc: include any-object allocations in alloc_reportJeff King Tue, 10 Jun 2014 21:38:47 +0000 (17:38 -0400)

alloc: include any-object allocations in alloc_report

When 2c1cbec (Use proper object allocators for unknown
object nodes too, 2007-04-16), added a special "any_object"
allocator, it never taught alloc_report to report on it. To
do so we need to add an extra type argument to the REPORT
macro, as that commit did for DEFINE_ALLOCATOR.

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

replace dangerous uses of strbuf_attachJeff King Tue, 10 Jun 2014 21:38:38 +0000 (17:38 -0400)

replace dangerous uses of strbuf_attach

It is not a good idea to strbuf_attach an arbitrary pointer
just because a function you are calling wants a strbuf.
Attaching implies a transfer of memory ownership; if anyone
were to modify or release the resulting strbuf, we would
free() the pointer, leading to possible problems:

1. Other users of the original pointer might access freed
memory.

2. The pointer might not be the start of a malloc'd
area, so calling free() on it in the first place would
be wrong.

In the two cases modified here, we are fortunate that nobody
touches the strbuf once it is attached, but it is an
accident waiting to happen. Since the previous commit,
commit_tree and friends take a pointer/buf pair, so we can
just do away with the strbufs entirely.

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

commit_tree: take a pointer/len pair rather than a... Jeff King Tue, 10 Jun 2014 21:36:52 +0000 (17:36 -0400)

commit_tree: take a pointer/len pair rather than a const strbuf

While strbufs are pretty common throughout our code, it is
more flexible for functions to take a pointer/len pair than
a strbuf. It's easy to turn a strbuf into such a pair (by
dereferencing its members), but less easy to go the other
way (you can strbuf_attach, but that has implications about
memory ownership).

This patch teaches commit_tree (and its associated callers
and sub-functions) to take such a pair for the commit
message rather than a strbuf. This makes passing the buffer
around slightly more verbose, but means we can get rid of
some dangerous strbuf_attach calls in the next patch.

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

repack: s/write_bitmap/&s/ in codeJeff King Tue, 10 Jun 2014 20:10:07 +0000 (16:10 -0400)

repack: s/write_bitmap/&s/ in code

The config name is "writeBitmaps", so the internal variable
missing the plural is unnecessarily confusing to write.

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

repack: respect pack.writebitmapsJeff King Tue, 10 Jun 2014 20:09:23 +0000 (16:09 -0400)

repack: respect pack.writebitmaps

The config option to turn on bitmaps is read all the way
down in the plumbing of pack-objects. This makes it hard for
other options in the porcelain of repack to make decisions
based on the bitmap setting. For example,
repack.packKeptObjects tries to kick in by default only when
bitmaps are turned on. But it can't do so reliably because
it doesn't yet know whether we are using bitmaps.

This patch teaches repack to respect pack.writebitmaps. It
means we pass a redundant command-line flag to pack-objects,
but that's OK; it shouldn't affect the outcome.

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

repack: do not accidentally pack kept objects by defaultJeff King Tue, 10 Jun 2014 20:08:38 +0000 (16:08 -0400)

repack: do not accidentally pack kept objects by default

Commit ee34a2b (repack: add `repack.packKeptObjects` config
var, 2014-03-03) added a flag which could duplicate kept
objects, but did not mean to turn it on by default. Instead,
the option is tied by default to the decision to write
bitmaps, like:

if (pack_kept_objects < 0)
pack_kept_objects = write_bitmap;

after which we expect pack_kept_objects to be a boolean 0 or
1. However, that assignment neglects that write_bitmap is
_also_ a tri-state with "-1" as the default, and with
neither option given, we accidentally turn the option on.

This patch is the minimal fix to restore the desired
behavior for the default state. Further patches will fix the
more complicated cases.

Note the update to t7700. It failed to turn on bitmaps,
meaning we were actually confirming the wrong behavior!

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

revision: parse "git log -<count>" more carefullyJunio C Hamano Fri, 6 Jun 2014 22:33:25 +0000 (15:33 -0700)

revision: parse "git log -<count>" more carefully

This mistyped command line simply ignores "master" and ends up
showing two commits from the current HEAD:

$ git log -2master

because we feed "2master" to atoi() without making sure that the
whole string is parsed as an integer.

Use the strtol_i() helper function instead.

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

shortlog: allow --exclude=<glob> to be passedJunio C Hamano Fri, 30 May 2014 19:57:25 +0000 (12:57 -0700)

shortlog: allow --exclude=<glob> to be passed

These two commands are supposed to be equivalent:

$ git log --exclude=refs/notes/\* --all --no-merges --since=2.days |
git shortlog
$ git shortlog --exclude=refs/notes/\* --all --no-merges --since=2.days

However, the latter does not understand the ref-exclusion command
line option, even though other options understood by "log", such as
"--all" and "--no-merges", are understood.

This was because e7b432c5 (revision: introduce --exclude=<glob> to
tame wildcards, 2013-08-30) did not wire the new option fully to the
machinery. A new option understood by handle_revision_pseudo_opt()
must be told to handle_revision_opt() as well.

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

update-index: fix segfault with missing --cacheinfo... Jeff King Wed, 4 Jun 2014 07:11:11 +0000 (03:11 -0400)

update-index: fix segfault with missing --cacheinfo argument

Running "git update-index --cacheinfo" without any further
arguments results in a segfault rather than an error
message. Commit ec160ae (update-index: teach --cacheinfo a
new syntax "mode,sha1,path", 2014-03-23) added code to
examine the format of the argument, but forgot to handle the
NULL case.

Returning an error from the parser is enough, since we then
treat it as an old-style "--cacheinfo <mode> <sha1> <path>",
and complain that we have less than 3 arguments to read.

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

dir.c:trim_trailing_spaces(): fix for " \ " sequencePasha Bolokhov Mon, 2 Jun 2014 22:36:56 +0000 (15:36 -0700)

dir.c:trim_trailing_spaces(): fix for " \ " sequence

Discard the unnecessary 'nr_spaces' variable, remove 'strlen()' and
improve the 'if' structure. Switch to pointers instead of integers
to control the loop.

Slightly more rare occurrences of 'text \ ' with a backslash
in between spaces are handled correctly. Namely, the code in
7e2e4b37 (dir: ignore trailing spaces in exclude patterns, 2014-02-09)
does not reset 'last_space' when a backslash is encountered and the above
line stays intact as a result.

Add a test at the end of t/t0008-ignores.sh to exhibit this behavior.

Signed-off-by: Pasha Bolokhov <pasha.bolokhov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pack-objects: use free()+xcalloc() instead of xrealloc... René Scharfe Sun, 1 Jun 2014 11:07:21 +0000 (13:07 +0200)

pack-objects: use free()+xcalloc() instead of xrealloc()+memset()

Whenever the hash table becomes too small then its size is increased,
the original part (and the added space) is zerod out using memset(),
and the table is rebuilt from scratch.

Simplify this proceess by returning the old memory using free() and
allocating the new buffer using xcalloc(), which already clears the
buffer for us. That way we avoid copying the old hash table contents
needlessly inside xrealloc().

While at it, use the first array member with sizeof instead of a
specific type. The old code used uint32_t and int, while index is
actually an array of int32_t. Their sizes are the same basically
everywhere, so it's not actually a problem, but the new code is
cleaner and doesn't have to be touched should the type be changed.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

mailinfo: use strcmp() for string comparisonRené Scharfe Sun, 1 Jun 2014 09:00:40 +0000 (11:00 +0200)

mailinfo: use strcmp() for string comparison

The array header is defined as:

static const char *header[MAX_HDR_PARSED] = {
"From","Subject","Date",
};

When looking for the index of a specfic string in that array, simply
use strcmp() instead of memcmp(). This avoids running over the end of
the string (e.g. with memcmp("Subject", "From", 7)) and gets rid of
magic string length constants.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sideband.c: do not use ANSI control sequence on non... Michael Naumov Wed, 28 May 2014 03:12:15 +0000 (03:12 +0000)

sideband.c: do not use ANSI control sequence on non-terminal

Diagnostic messages received on the sideband #2 from the server side
are sent to the standard error with ANSI terminal control sequence
"\033[K" that erases to the end of line appended at the end of each
line.

However, some programs (e.g. GitExtensions for Windows) read and
interpret and/or show the message without understanding the terminal
control sequences, resulting them to be shown to their end users.
To help these programs, squelch the control sequence when the
standard error stream is not being sent to a tty.

NOTE: I considered to cover the case that a pager has already been
started. But decided that is probably not worth worrying about here,
though, as we shouldn't be using a pager for commands that do network
communications (and if we do, omitting the magic line-clearing signal
is probably a sane thing to do).

Thanks-to: Erik Faye-Lund <kusmabite@gmail.com>
Thanks-to: Jeff King <peff@peff.net>
Signed-off-by: Michael Naumov <mnaoumov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t5538: move http push tests out to t5542Nick Alcock Fri, 30 May 2014 17:36:21 +0000 (13:36 -0400)

t5538: move http push tests out to t5542

As 0232852b, but for the push tests instead: this avoids a start_httpd
in the middle of the file, which fails under GIT_TEST_HTTPD=false.

Note that we have to munge the test in a few ways while
moving it:

1. We drop the `test -z "$GIT_TEST_HTTPD"` check; this is
too simplistic since 83d842d, and we should let
lib-httpd.sh handle it.

2. We have to port over some of the old setup from t5538.

3. In the final test, we no longer expect the extra commit
"1" built on top of "4". This was a side effect from an
earlier test in t5538 which was not ported over.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sync with 1.9.4Junio C Hamano Fri, 30 May 2014 17:57:52 +0000 (10:57 -0700)

Sync with 1.9.4

Git 1.9.4 v1.9.4Junio C Hamano Wed, 28 May 2014 22:50:22 +0000 (15:50 -0700)

Git 1.9.4

This is expected to be the final maintenance release for 1.9 series,
merging the remaining fixes that are relevant and are already in 2.0.

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

t5537: re-drop http testsJeff King Fri, 30 May 2014 01:34:19 +0000 (21:34 -0400)

t5537: re-drop http tests

These were originally removed by 0232852 (t5537: move
http tests out to t5539, 2014-02-13). However, they were
accidentally re-added in 1ddb4d7 (Merge branch
'nd/upload-pack-shallow', 2014-03-21).

This looks like an error in manual conflict resolution.
Here's what happened:

1. v1.9.0 shipped with the http tests in t5537.

2. We realized that this caused problems, and built
0232852 on top to move the tests to their own file.
This fix made it into v1.9.1.

3. We later had another fix in nd/upload-pack-shallow that
also touched t5537. It was built directly on v1.9.0.

When we merged nd/upload-pack-shallow to master, we got a
conflict; it was built on a version with the http tests, but
we had since removed them. The correct resolution was to
drop the http tests and keep the new ones, but instead we
kept everything.

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

Merge branch 'rh/prompt-pcmode-avoid-eval-on-refname... Junio C Hamano Wed, 28 May 2014 22:46:36 +0000 (15:46 -0700)

Merge branch 'rh/prompt-pcmode-avoid-eval-on-refname' into maint

* rh/prompt-pcmode-avoid-eval-on-refname:
git-prompt.sh: don't assume the shell expands the value of PS1