git
11 years agol10n: de.po: Fix a typo
Wieland Hoffmann [Wed, 5 Jun 2013 20:59:44 +0000 (22:59 +0200)] 
l10n: de.po: Fix a typo

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
11 years agofetch: work around "transport-take-over" hack
Junio C Hamano [Wed, 7 Aug 2013 22:47:18 +0000 (15:47 -0700)] 
fetch: work around "transport-take-over" hack

A Git-aware "connect" transport allows the "transport_take_over" to
redirect generic transport requests like fetch(), push_refs() and
get_refs_list() to the native Git transport handling methods.  The
take-over process replaces transport->data with a fake data that
these method implementations understand.

While this hack works OK for a single request, it breaks when the
transport needs to make more than one requests.  transport->data
that used to hold necessary information for the specific helper to
work correctly is destroyed during the take-over process.

One codepath that this matters is "git fetch" in auto-follow mode;
when it does not get all the tags that ought to point at the history
it got (which can be determined by looking at the peeled tags in the
initial advertisement) from the primary transfer, it internally
makes a second request to complete the fetch.  Because "take-over"
hack has already destroyed the data necessary to talk to the
transport helper by the time this happens, the second request cannot
make a request to the helper to make another connection to fetch
these additional tags.

Mark such a transport as "cannot_reuse", and use a separate
transport to perform the backfill fetch in order to work around
this breakage.

Note that this problem does not manifest itself when running t5802,
because our upload-pack gives you all the necessary auto-followed
tags during the primary transfer.  You would need to step through
"git fetch" in a debugger, stop immediately after the primary
transfer finishes and writes these auto-followed tags, remove the
tag references and repack/prune the repository to convince the
"find-non-local-tags" procedure that the primary transfer failed to
give us all the necessary tags, and then let it continue, in order
to trigger the bug in the secondary transfer this patch fixes.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agofetch: refactor code that fetches leftover tags
Junio C Hamano [Wed, 7 Aug 2013 22:14:45 +0000 (15:14 -0700)] 
fetch: refactor code that fetches leftover tags

Usually the upload-pack process running on the other side will give
us all the reachable tags we need during the primary object transfer
in do_fetch().  If that does not happen (e.g. the other side may be
running a third-party implementation of upload-pack), we will run
another fetch to pick up leftover tags that we know point at the
commits reachable from our updated tips.

Separate out the code to run this second fetch into a helper
function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agofetch: refactor code that prepares a transport
Junio C Hamano [Wed, 7 Aug 2013 21:43:20 +0000 (14:43 -0700)] 
fetch: refactor code that prepares a transport

Make a helper function prepare_transport() that returns a transport
to talk to a given remote.

The set_option() helper that used to always affect the file-scope
global "gtransport" now takes a transport as its parameter.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agofetch: rename file-scope global "transport" to "gtransport"
Junio C Hamano [Wed, 7 Aug 2013 22:38:45 +0000 (15:38 -0700)] 
fetch: rename file-scope global "transport" to "gtransport"

Although many functions in this file take a "struct transport" as a
parameter, "fetch_one()" assigns to the global singleton instance
which is a file-scope static, in order to allow a parameterless
signal handler unlock_pack() to access it.

Rename the variable to gtransport to make sure these uses stand out.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot5802: add test for connect helper
Junio C Hamano [Wed, 7 Aug 2013 15:18:10 +0000 (08:18 -0700)] 
t5802: add test for connect helper

This is an attempt to reproduce a problem reported for a third-party
custom "connect" remote helper.  The conjecture is that sometimes
"git fetch" wants to make two connections (one for the primary
transfer with 'follow-tags' option set, and then after noticing that
some tags are not packed because the primary transfer did not have
to send any commit that is pointed by them, another to explicitly
ask for the missing tags), and their "connect" helper is not called
in the second request, breaking the "fetch" as a whole.

Unfortunately this test script does not trigger the alleged failure
and happily passes when talking to upload-pack from git-core (see
patch 5/5 for details).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agodie_with_status: use "printf '%s\n'", not "echo"
Matthieu Moy [Wed, 7 Aug 2013 09:26:05 +0000 (11:26 +0200)] 
die_with_status: use "printf '%s\n'", not "echo"

Some implementations of 'echo' (e.g. dash's built-in) interpret
backslash sequences in their arguments.

This triggered at least one bug: the error message of "rebase -i" was
turning \t in commit messages into actual tabulations. There may be
others.

Using "printf '%s\n'" instead avoids this bad behavior, and is the form
used by the "say" function.

Noticed-by: David Kastrup <dak@gnu.org>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agorevert: use the OPT_CMDMODE for parsing, reducing code
Stefan Beller [Sat, 3 Aug 2013 11:51:26 +0000 (13:51 +0200)] 
revert: use the OPT_CMDMODE for parsing, reducing code

The revert command comes with their own implementation of checking
for exclusiveness of parameters.
Now that the OPT_CMDMODE is in place, we can also rely on that macro
instead of cooking that solution for each command itself.

This commit also replaces OPT_BOOLEAN, which was deprecated by b04ba2bb
(parse-options: deprecate OPT_BOOLEAN, 2011-09-27). Instead OPT_BOOL is
used.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agocheckout-index: fix negations of even numbers of -n
Stefan Beller [Sat, 3 Aug 2013 11:51:25 +0000 (13:51 +0200)] 
checkout-index: fix negations of even numbers of -n

The --no-create was parsed with OPT_BOOLEAN, which has a counting up
logic implemented. Since b04ba2bb (parse-options: deprecate OPT_BOOLEAN,
2011-09-27) the OPT_BOOLEAN is deprecated and is only a define:
/* Deprecated synonym */
#define OPTION_BOOLEAN OPTION_COUNTUP

However the variable not_new, which can be counted up by giving
--no-create multiple times, is used to set a bit in the struct checkout
bitfield (defined in cache.h:969, declared at builtin/checkout-index.c:19):

state.not_new = not_new;

When assigning a value other than 0 or 1 to a bit, all leading digits but
the last are ignored and only the last bit is used for setting the bit
variable.

Hence the following:
# in git.git:
$ git status
# working directory clean
rm COPYING
$ git status
# deleted:    COPYING
$ git checkout-index -a -n
$ git status
# deleted:    COPYING
# which is expected as we're telling git to not restore or create
# files, however:
$ git checkout-index -a -n -n
$ git status
# working directory clean, COPYING is restored again!
# That's the bug, we're fixing here.

By restraining the variable not_new to a value being definitely 0 or 1
by the macro OPT_BOOL the bug is fixed.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoconfig parsing options: allow one flag multiple times
Stefan Beller [Sat, 3 Aug 2013 11:51:24 +0000 (13:51 +0200)] 
config parsing options: allow one flag multiple times

This task emerged from b04ba2bb (parse-options: deprecate OPT_BOOLEAN,
2011-09-27).

This commit introduces a change for the users, after this patch
you can pass one of the config level flags multiple times:
Before:
$ git config --global --global --list
error: only one config file at a time.
usage: ...

Afterwards this will work. This is due to the following check in the code:
if (use_global_config + use_system_config + use_local_config +
    !!given_config_file + !!given_config_blob > 1) {
error("only one config file at a time.");
usage_with_options(builtin_config_usage, builtin_config_options);
}

With OPT_BOOL instead of OPT_BOOLEAN the variables use_global_config,
use_system_config, use_local_config will only have the value 0 if the
command line option was not passed or 1 no matter how often the
respective command line option was passed.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agohash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUP
Stefan Beller [Sat, 3 Aug 2013 11:51:23 +0000 (13:51 +0200)] 
hash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUP

This task emerged from b04ba2bb (parse-options: deprecate OPT_BOOLEAN,
2011-09-27). hash-object is a plumbing layer command, so better
not change the input/output behavior for now.

Unfortunately we have these lines relying on the count up mechanism of
OPT_BOOLEAN:

if (hashstdin > 1)
errstr = "Multiple --stdin arguments are not supported";

Using OPT_BOOL will make "git hash-object --stdin --stdin" the same
as "git hash-object --stdin", resulting in just one object, which
will surprise users with an expectation to see two objects hashed.

Because it is not good to silently succeed and give an unexpected
result, even when the expectation is unrealistic, we use COUNTUP to
explicitly catch such an error.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agobranch, commit, name-rev: ease up boolean conditions
Stefan Beller [Wed, 7 Aug 2013 07:32:25 +0000 (09:32 +0200)] 
branch, commit, name-rev: ease up boolean conditions

Now that the variables are set by OPT_BOOL, which makes sure
to have the values being 0 or 1 after parsing, we do not need
the double negation to map any other value to 1 for integer
variables.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoline-range: reject -L line numbers less than 1
Eric Sunshine [Tue, 6 Aug 2013 13:59:49 +0000 (09:59 -0400)] 
line-range: reject -L line numbers less than 1

Since inception, git-blame -L has been documented as accepting 1-based
line numbers. When handed a line number less than 1, -L's behavior is
undocumented and undefined; it's also nonsensical and should be
diagnosed as an error. Do so.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot8001/t8002: blame: add tests of -L line numbers less than 1
Eric Sunshine [Tue, 6 Aug 2013 13:59:48 +0000 (09:59 -0400)] 
t8001/t8002: blame: add tests of -L line numbers less than 1

git-blame -L is documented as accepting 1-based line numbers. When
handed a line number less than 1, -L's behavior is undocumented and
undefined; it's also nonsensical and should be rejected but is
nevertheless accepted. Demonstrate this shortcoming.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoline-range: teach -L^:RE to search from start of file
Eric Sunshine [Tue, 6 Aug 2013 13:59:47 +0000 (09:59 -0400)] 
line-range: teach -L^:RE to search from start of file

The -L:RE option of blame/log searches from the end of the previous -L
range, if any. Add new notation -L^:RE to override this behavior and
search from start of file.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoline-range: teach -L:RE to search from end of previous -L range
Eric Sunshine [Tue, 6 Aug 2013 13:59:46 +0000 (09:59 -0400)] 
line-range: teach -L:RE to search from end of previous -L range

For consistency with -L/RE/, teach -L:RE to search relative to the end
of the previous -L range, if any.

The new behavior invalidates one test in t4211 which assumes that -L:RE
begins searching at start of file. This test will be resurrected in a
follow-up patch which teaches -L:RE how to override the default relative
search behavior.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoline-range: teach -L^/RE/ to search from start of file
Eric Sunshine [Tue, 6 Aug 2013 13:59:45 +0000 (09:59 -0400)] 
line-range: teach -L^/RE/ to search from start of file

The -L/RE/ option of blame/log searches from the end of the previous -L
range, if any. Add new notation -L^/RE/ to override this behavior and
search from start of file.

The new ^/RE/ syntax is valid only as the <start> argument of
-L<start>,<end>. The <end> argument, as usual, is relative to <start>.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoline-range-format.txt: document -L/RE/ relative search
Eric Sunshine [Tue, 6 Aug 2013 13:59:44 +0000 (09:59 -0400)] 
line-range-format.txt: document -L/RE/ relative search

Option -L/RE/ of blame/log now searches relative to the previous -L
range, if any. Document this.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agolog: teach -L/RE/ to search from end of previous -L range
Eric Sunshine [Tue, 6 Aug 2013 13:59:43 +0000 (09:59 -0400)] 
log: teach -L/RE/ to search from end of previous -L range

This is complicated slightly by having to remember the previous -L range
for each file specified via -L<range>:file.

The existing implementation coalesces ranges for each file as each -L is
parsed which makes it impossible to refer back to the previous -L range
for any particular file. Re-implement to instead store each file's set
of -L ranges verbatim, and then coalesce the ranges in a post-processing
step.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoblame: teach -L/RE/ to search from end of previous -L range
Eric Sunshine [Tue, 6 Aug 2013 13:59:42 +0000 (09:59 -0400)] 
blame: teach -L/RE/ to search from end of previous -L range

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoline-range: teach -L/RE/ to search relative to anchor point
Eric Sunshine [Tue, 6 Aug 2013 13:59:41 +0000 (09:59 -0400)] 
line-range: teach -L/RE/ to search relative to anchor point

Range specification -L/RE/ for blame/log unconditionally begins
searching at line one. Mailing list discussion [1] suggests that, in the
presence of multiple -L options, -L/RE/ should search relative to the
endpoint of the previous -L range, if any.

Teach the parsing machinery underlying blame's and log's -L options to
accept a start point for -L/RE/ searches. Follow-up patches will upgrade
blame and log to take advantage of this ability.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/229755/focus=229966

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoblame: document multiple -L support
Eric Sunshine [Tue, 6 Aug 2013 13:59:40 +0000 (09:59 -0400)] 
blame: document multiple -L support

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot8001/t8002: blame: add tests of multiple -L options
Eric Sunshine [Tue, 6 Aug 2013 13:59:39 +0000 (09:59 -0400)] 
t8001/t8002: blame: add tests of multiple -L options

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoblame: accept multiple -L ranges
Eric Sunshine [Tue, 6 Aug 2013 13:59:38 +0000 (09:59 -0400)] 
blame: accept multiple -L ranges

git-blame accepts only a single -L option or none. Clients requiring
blame information for multiple disjoint ranges are therefore forced
either to invoke git-blame multiple times, once for each range, or only
once with no -L option to cover the entire file, both of which can be
costly.  Teach git-blame to accept multiple -L ranges.  Overlapping and
out-of-order ranges are accepted.

In this patch, the X in -LX,Y is absolute (for instance, /RE/ patterns
search from line 1), and Y is relative to X. Follow-up patches provide
more flexibility over how X is anchored.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoblame: inline one-line function into its lone caller
Eric Sunshine [Tue, 6 Aug 2013 13:59:37 +0000 (09:59 -0400)] 
blame: inline one-line function into its lone caller

As of 25ed3412 (Refactor parse_loc; 2013-03-28),
blame.c:prepare_blame_range() became effectively a one-line function
which merely passes its arguments along to another function. This
indirection does not bring clarity to the code. Simplify by inlining
prepare_blame_range() into its lone caller.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agorange-set: publish API for re-use by git-blame -L
Eric Sunshine [Tue, 6 Aug 2013 13:59:36 +0000 (09:59 -0400)] 
range-set: publish API for re-use by git-blame -L

git-blame is slated to accept multiple -L ranges.  git-log already
accepts multiple -L's but its implementation of range-set, which
organizes and normalizes -L ranges, is private.  Publish the small
subset of range-set API which is needed for git-blame multiple -L
support.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoline-range-format.txt: clarify -L:regex usage form
Eric Sunshine [Tue, 6 Aug 2013 13:59:35 +0000 (09:59 -0400)] 
line-range-format.txt: clarify -L:regex usage form

blame/log documentation describes -L option as:

  -L<start>,<end>
  -L:<regex>

  <start> and <end> can take one of these forms:

    * number
    * /regex/
    * +offset or -offset
    * :regex

which is incorrect and confusing since :regex is not one of the valid
forms of <start> or <end>; in fact, it must be -L's lone argument.

Clarify by discussing :<regex> at the same indentation level as "<start>
and <end>...":

  -L<start>,<end>
  -L:<regex>

  <start> and <end> can take one of these forms:

    * number
    * /regex/
    * +offset or -offset

  If :<regex> is given in place of <start> and <end> ...

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agogit-log.txt: place each -L option variation on its own line
Eric Sunshine [Tue, 6 Aug 2013 13:59:34 +0000 (09:59 -0400)] 
git-log.txt: place each -L option variation on its own line

Standard practice in Git documentation is for each variation of an
option (such as: -p / --porcelain) to be placed on its own line in the
OPTIONS table. The -L option does not follow suit. It cuddles "-L
<start>,<end>:<file>" and "-L :<regex>:<file>", separated by a comma.
This is inconsistent and potentially confusing since the comma
separating them is typeset the same as the comma in "<start>,<end>". Fix
this by placing each variation on its own line.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agorm: delete .gitmodules entry of submodules removed from the work tree
Jens Lehmann [Tue, 6 Aug 2013 19:15:25 +0000 (21:15 +0200)] 
rm: delete .gitmodules entry of submodules removed from the work tree

Currently using "git rm" on a submodule removes the submodule's work tree
from that of the superproject and the gitlink from the index. But the
submodule's section in .gitmodules is left untouched, which is a leftover
of the now removed submodule and might irritate users (as opposed to the
setting in .git/config, this must stay as a reminder that the user showed
interest in this submodule so it will be repopulated later when an older
commit is checked out).

Let "git rm" help the user by not only removing the submodule from the
work tree but by also removing the "submodule.<submodule name>" section
from the .gitmodules file and stage both. This doesn't happen when the
"--cached" option is used, as it would modify the work tree. This also
silently does nothing when no .gitmodules file is found and only issues a
warning when it doesn't have a section for this submodule. This is because
the user might just use plain gitlinks without the .gitmodules file or has
already removed the section by hand before issuing the "git rm" command
(in which case the warning reminds him that rm would have done that for
him). Only when .gitmodules is found and contains merge conflicts the rm
command will fail and tell the user to resolve the conflict before trying
again.

Also extend the man page to inform the user about this new feature. While
at it promote the submodule sub-section to a chapter as it made not much
sense under "REMOVING FILES THAT HAVE DISAPPEARED FROM THE FILESYSTEM".

In t7610 three uses of "git rm submod" had to be replaced with "git rm
--cached submod" because that test expects .gitmodules and the work tree
to stay untouched. Also in t7400 the tests for the remaining settings in
the .gitmodules file had to be changed to assert that these settings are
missing.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agomv: update the path entry in .gitmodules for moved submodules
Jens Lehmann [Tue, 6 Aug 2013 19:15:11 +0000 (21:15 +0200)] 
mv: update the path entry in .gitmodules for moved submodules

Currently using "git mv" on a submodule moves the submodule's work tree in
that of the superproject. But the submodule's path setting in .gitmodules
is left untouched, which is now inconsistent with the work tree and makes
git commands that rely on the proper path -> name mapping (like status and
diff) behave strangely.

Let "git mv" help here by not only moving the submodule's work tree but
also updating the "submodule.<submodule name>.path" setting from the
.gitmodules file and stage both. This doesn't happen when no .gitmodules
file is found and only issues a warning when it doesn't have a section for
this submodule. This is because the user might just use plain gitlinks
without the .gitmodules file or has already updated the path setting by
hand before issuing the "git mv" command (in which case the warning
reminds him that mv would have done that for him). Only when .gitmodules
is found and contains merge conflicts the mv command will fail and tell
the user to resolve the conflict before trying again.

Also extend the man page to inform the user about this new feature.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot0070: test that git_mkstemps correctly checks return value of open()
Dale R. Worley [Sat, 3 Aug 2013 00:27:23 +0000 (20:27 -0400)] 
t0070: test that git_mkstemps correctly checks return value of open()

Signed-off-by: Dale R. Worley <worley@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agol10n: Update Swedish translation (2135t0f0u)
Peter Krefting [Tue, 6 Aug 2013 11:41:48 +0000 (12:41 +0100)] 
l10n: Update Swedish translation (2135t0f0u)

Fix some incorrect translations in existing messages while at it.

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
11 years agol10n: zh_CN.po: translate 5 messages (2135t0f0u)
Jiang Xin [Tue, 6 Aug 2013 06:49:18 +0000 (14:49 +0800)] 
l10n: zh_CN.po: translate 5 messages (2135t0f0u)

Translate 5 new messages came from git.pot update in b8ecf23
(l10n: git.pot: v1.8.4 round 2 (5 new, 3 removed)).

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
11 years agol10n: vi.po(2135t): v1.8.4 round 2
Tran Ngoc Quan [Tue, 6 Aug 2013 07:34:48 +0000 (14:34 +0700)] 
l10n: vi.po(2135t): v1.8.4 round 2

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
11 years agol10n: git.pot: v1.8.4 round 2 (5 new, 3 removed)
Jiang Xin [Tue, 6 Aug 2013 06:13:23 +0000 (14:13 +0800)] 
l10n: git.pot: v1.8.4 round 2 (5 new, 3 removed)

Generate po/git.pot from v1.8.4-rc1-21-gfb56570 for git v1.8.4
l10n round 2.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
11 years agoconfig: "git config --get-urlmatch" parses section.<url>.key
Junio C Hamano [Wed, 31 Jul 2013 18:14:59 +0000 (11:14 -0700)] 
config: "git config --get-urlmatch" parses section.<url>.key

Using the same urlmatch_config_entry() infrastructure, add a new
mode "--get-urlmatch" to the "git config" command, to learn values
for the "virtual" two-level variables customized for the specific
URL.

    git config [--<type>] --get-urlmatch <section>[.<key>] <url>

With <section>.<key> fully specified, the configuration data for
<section>.<urlpattern>.<key> for <urlpattern> that best matches the
given <url> is sought (and if not found, <section>.<key> is used)
and reported.  For example, with this configuration:

    [http]
        sslVerify
    [http "https://weak.example.com"]
        cookieFile = /tmp/cookie.txt
        sslVerify = false

You would get

    $ git config --bool --get-urlmatch http.sslVerify https://good.example.com
    true
    $ git config --bool --get-urlmatch http.sslVerify https://weak.example.com
    false

With only <section> specified, you can get a list of all variables
in the section with their values that apply to the given URL.  E.g

    $ git config --get-urlmatch http https://weak.example.com
    http.cookiefile /tmp/cookie.txt
    http.sslverify false

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agobuiltin/config: refactor collect_config()
Junio C Hamano [Mon, 29 Jul 2013 21:23:16 +0000 (14:23 -0700)] 
builtin/config: refactor collect_config()

In order to reuse the logic to format the configuration value while
honouring the requested type, split this function into two.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoconfig: parse http.<url>.<variable> using urlmatch
Kyle J. McKay [Mon, 5 Aug 2013 20:20:36 +0000 (13:20 -0700)] 
config: parse http.<url>.<variable> using urlmatch

Use the urlmatch_config_entry() to wrap the underlying
http_options() two-level variable parser in order to set
http.<variable> to the value with the most specific URL in the
configuration.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoSync with maint to grab trivial doc fixes
Junio C Hamano [Mon, 5 Aug 2013 20:00:20 +0000 (13:00 -0700)] 
Sync with maint to grab trivial doc fixes

* maint:
  fix typo in documentation of git-svn
  Documentation/rev-list-options: add missing word in --*-parents
  log doc: the argument to --encoding is not optional

11 years agoblame: reject empty ranges -L,+0 and -L,-0
Eric Sunshine [Wed, 31 Jul 2013 08:15:45 +0000 (04:15 -0400)] 
blame: reject empty ranges -L,+0 and -L,-0

Empty ranges -L,+0 and -L,-0 are nonsensical in the context of blame yet
they are accepted (in fact, both are interpreted as -L1,Y where Y is
end-of-file). Report them as invalid.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot8001/t8002: blame: demonstrate acceptance of bogus -L,+0 and -L,-0
Eric Sunshine [Wed, 31 Jul 2013 08:15:44 +0000 (04:15 -0400)] 
t8001/t8002: blame: demonstrate acceptance of bogus -L,+0 and -L,-0

Empty ranges -L,+0 and -L,-0 are nonsensical in the context of blame yet
they are accepted. They should be errors. Demonstrate this shortcoming.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoblame: reject empty ranges -LX,+0 and -LX,-0
Eric Sunshine [Wed, 31 Jul 2013 08:15:43 +0000 (04:15 -0400)] 
blame: reject empty ranges -LX,+0 and -LX,-0

Empty ranges -LX,+0 and -LX,-0 are nonsensical in the context of blame
yet they are accepted (in fact, both are interpreted as -LX,+2).  Report
them as invalid.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot8001/t8002: blame: demonstrate acceptance of bogus -LX,+0 and -LX,-0
Eric Sunshine [Wed, 31 Jul 2013 08:15:42 +0000 (04:15 -0400)] 
t8001/t8002: blame: demonstrate acceptance of bogus -LX,+0 and -LX,-0

Empty ranges -LX,+0 and -LX,-0 are nonsensical in the context of blame
yet they are accepted. They should be errors. Demonstrate this
shortcoming.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agolog: fix -L bounds checking bug
Eric Sunshine [Wed, 31 Jul 2013 08:15:41 +0000 (04:15 -0400)] 
log: fix -L bounds checking bug

When 12da1d1f added -L support to git-log, a broken bounds check was
copied from git-blame -L which incorrectly allows -LX to extend one line
past end of file without reporting an error.  Instead, it generates an
empty range.  Fix this bug.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot4211: retire soon-to-be unimplementable tests
Eric Sunshine [Wed, 31 Jul 2013 08:15:40 +0000 (04:15 -0400)] 
t4211: retire soon-to-be unimplementable tests

58960978 and 99780b0a added tests which demonstrated bugs (crashes) in
range-set and line-log when handed empty ranges specified via "log
-LX:file" where X is one greater than the last line of the file.  After
these tests were added, it was realized that the ability to specify an
empty range is a loophole due to a bug in -L bounds checking. That bug
is slated to be fixed in a subsequent patch.

Unfortunately, the closure of this loophole makes it impossible to
continue checking range-set and line-log behavior with regard to empty
ranges since there is no other way to specify empty ranges via the
command-line.  APIs of both facilities are private (file static) so
there likewise is no way to test their behaviors programmatically.
Consequently, retire these two tests.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot4211: log: demonstrate -L bounds checking bug
Eric Sunshine [Wed, 31 Jul 2013 08:15:39 +0000 (04:15 -0400)] 
t4211: log: demonstrate -L bounds checking bug

A bounds checking bug allows the X in -LX to extend one line past the
end of file. For example, given a file with 5 lines, -L6 is accepted as
valid. Demonstrate this problem.

While here, also add tests to check that the remaining cases of X and Y
in -LX,Y are handled correctly at and in the vicinity of end-of-file.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoblame: fix -L bounds checking bug
Eric Sunshine [Wed, 31 Jul 2013 08:15:38 +0000 (04:15 -0400)] 
blame: fix -L bounds checking bug

Since inception, -LX,Y has correctly reported an out-of-range error when
Y is beyond end of file, however, X was not checked, and an out-of-range
X would cause a crash.  92f9e273 (blame: prevent a segv when -L given
start > EOF; 2010-02-08) attempted to rectify this shortcoming but has
its own off-by-one error which allows X to extend one line past end of
file.  For example, given a file with 5 lines:

  git blame -L5 foo  # OK, blames line 5
  git blame -L6 foo  # accepted, no error, no output, huh?
  git blame -L7 foo  # error "fatal: file foo has only 5 lines"

Fix this bug.

In order to avoid regressing "blame foo" when foo is an empty file, the
fix is slightly more complicated than changing '<' to '<='.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot8001/t8002: blame: add empty file & partial-line tests
Eric Sunshine [Wed, 31 Jul 2013 08:15:37 +0000 (04:15 -0400)] 
t8001/t8002: blame: add empty file & partial-line tests

Add boundary case tests, with and without -L, for empty file; file with
one partial line; file with one full line.

The empty file test without -L is of particular interest. Historically,
this case has been supported (empty blame output) and this test protects
against regression by a subsequent patch fixing an off-by-one bug which
incorrectly accepts -LX where X is one past end-of-file.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot8001/t8002: blame: demonstrate -L bounds checking bug
Eric Sunshine [Wed, 31 Jul 2013 08:15:36 +0000 (04:15 -0400)] 
t8001/t8002: blame: demonstrate -L bounds checking bug

A bounds checking bug allows the X in -LX to extend one line past the
end of file. For example, given a file with 5 lines, -L6 is accepted as
valid. Demonstrate this problem.

While here, also add tests to check that the remaining cases of X and Y
in -LX,Y are handled correctly at and in the vicinity of end-of-file.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot8001/t8002: blame: decompose overly-large test
Eric Sunshine [Wed, 31 Jul 2013 08:15:35 +0000 (04:15 -0400)] 
t8001/t8002: blame: decompose overly-large test

Checking all bogus -L syntax forms in a single test makes it difficult
to identify the offender when one case fails. Decompose this
conglomerate test in order to check each bad syntax case separately.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agocheckout: remove superfluous local variable
Stefan Beller [Sat, 3 Aug 2013 11:51:21 +0000 (13:51 +0200)] 
checkout: remove superfluous local variable

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agolog, format-patch: parsing uses OPT__QUIET
Stefan Beller [Sat, 3 Aug 2013 11:51:20 +0000 (13:51 +0200)] 
log, format-patch: parsing uses OPT__QUIET

This patch allows users to use the short form -q on
log and format-patch, which was non possible before.

Also the documentation of format-patch mentions -q now.

The documentation of log doesn't even talk about --quiet, so I'll leave
that for more experienced git contributors. ;)
It doesn't seem to change the default behavior, but in combination
with --stat for example it suppresses the actual stats.
however the only relevant code in log is
if (quiet)
rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT;

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoReplace deprecated OPT_BOOLEAN by OPT_BOOL
Stefan Beller [Sat, 3 Aug 2013 11:51:19 +0000 (13:51 +0200)] 
Replace deprecated OPT_BOOLEAN by OPT_BOOL

This task emerged from b04ba2bb (parse-options: deprecate OPT_BOOLEAN,
2011-09-27). All occurrences of the respective variables have
been reviewed and none of them relied on the counting up mechanism,
but all of them were using the variable as a true boolean.

This patch does not change semantics of any command intentionally.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoRemove deprecated OPTION_BOOLEAN for parsing arguments
Stefan Beller [Sat, 3 Aug 2013 11:51:18 +0000 (13:51 +0200)] 
Remove deprecated OPTION_BOOLEAN for parsing arguments

As of b04ba2bb4 OPTION_BOOLEAN was deprecated.
This commit removes all occurrences of OPTION_BOOLEAN.
In b04ba2bb4 Junio suggested to replace it with either
OPTION_SET_INT or OPTION_COUNTUP instead. However a pattern, which
occurred often with the OPTION_BOOLEAN was a hidden boolean parameter.
So I defined OPT_HIDDEN_BOOL as an additional possible parse option
in parse-options.h to make life easy.

The OPT_HIDDEN_BOOL was used in checkout, clone, commit, show-ref.
The only exception, where there was need to fiddle with OPTION_SET_INT
was log and notes. However in these two files there is also a pattern,
so we could think of introducing OPT_NONEG_BOOL.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot5551: Remove header from curl cookie file
Brian Gernhardt [Mon, 5 Aug 2013 15:59:24 +0000 (11:59 -0400)] 
t5551: Remove header from curl cookie file

The URL included in the header appears to vary from curl version to
curl version.  Since we only care about the final few lines, only test
them.  However, make sure the blank line after the header is still
included to make sure there are no extra cookie lines.

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoOS X: Fix redeclaration of die warning
Brian Gernhardt [Mon, 5 Aug 2013 15:59:23 +0000 (11:59 -0400)] 
OS X: Fix redeclaration of die warning

compat/apple-common-crypto.h uses die() in one of its macros, but was
included in git-compat-util.h before the definition of die.

Fix by simply moving the relevant block after the die/error/warning
declarations.

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMakefile: Fix APPLE_COMMON_CRYPTO with BLK_SHA1
Brian Gernhardt [Mon, 5 Aug 2013 15:59:22 +0000 (11:59 -0400)] 
Makefile: Fix APPLE_COMMON_CRYPTO with BLK_SHA1

It used to be that APPLE_COMMON_CRYPTO did nothing when BLK_SHA1 was
set.  But APPLE_COMMON_CRYPTO is now used for more than just SHA1 (see
3ef2bca) so make sure that the appropriate libraries are always set.

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'es/blame-L-breakage'
Junio C Hamano [Mon, 5 Aug 2013 17:44:39 +0000 (10:44 -0700)] 
Merge branch 'es/blame-L-breakage'

* es/blame-L-breakage:
  t8001, t8002: fix "blame -L :literal" test on NetBSD

11 years agot8001, t8002: fix "blame -L :literal" test on NetBSD
René Scharfe [Mon, 5 Aug 2013 15:21:17 +0000 (17:21 +0200)] 
t8001, t8002: fix "blame -L :literal" test on NetBSD

Sub-test 42 of t8001 and t8002 ("blame -L :literal") fails on NetBSD
with the following verbose output:

git annotate  -L:main hello.c
Author F (expected 4, attributed 3) bad
Author G (expected 1, attributed 1) good

This is not caused by different behaviour of git blame or annotate on
that platform, but by different test input, in turn caused by a sed
command that forgets to add a newline on NetBSD.  Here's the diff of the
commit that adds "goodbye" to hello.c, for Linux:

@@ -1,4 +1,5 @@
 int main(int argc, const char *argv[])
 {
puts("hello");
+ puts("goodbye");
 }

We see that it adds an extra TAB, but that's not a problem.  Here's the
same on NetBSD:

@@ -1,4 +1,4 @@
 int main(int argc, const char *argv[])
 {
puts("hello");
-}
+ puts("goodbye");}

It also adds an extra TAB, but it is missing the newline character
after the semicolon.

The following patch gets rid of the extra TAB at the beginning, but
more importantly adds the missing newline at the end in a (hopefully)
portable way, mentioned in http://sed.sourceforge.net/sedfaq4.html.
The diff becomes this, on both Linux and NetBSD:

@@ -1,4 +1,5 @@
 int main(int argc, const char *argv[])
 {
puts("hello");
+ puts("goodbye");
 }

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge git://github.com/git-l10n/git-po
Junio C Hamano [Mon, 5 Aug 2013 17:38:23 +0000 (10:38 -0700)] 
Merge git://github.com/git-l10n/git-po

* git://github.com/git-l10n/git-po:
  l10n: zh_CN.po: translate 99 messages (2133t0f0u)
  l10n: vi.po (2133t)
  l10n: git.pot: v1.8.4 round 1 (99 new, 46 removed)

11 years agohooks/post-receive-email: set declared encoding to utf-8
Gerrit Pape [Thu, 11 Dec 2008 20:27:21 +0000 (20:27 +0000)] 
hooks/post-receive-email: set declared encoding to utf-8

Some email clients (e.g., claws-mail) display the message body
incorrectly when the charset is not defined explicitly in a
Content-Type header.  "git log" generates logs in UTF-8 encoding by
default, so add a Content-Type header declaring that encoding to
the emails the post-receive-email example hook sends.

[jn: also setting the Content-Transfer-Encoding so MTAs know what
 kind of mangling might be needed when sending to a non 8-bit clean
 SMTP host]

Requested-by: Alexander Gerasiov <gq@debian.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agohooks/post-receive-email: force log messages in UTF-8
Jonathan Nieder [Fri, 2 Aug 2013 23:23:38 +0000 (16:23 -0700)] 
hooks/post-receive-email: force log messages in UTF-8

Git commands write commit messages in UTF-8 by default, but that
default can be overridden by the [i18n] commitEncoding and
logOutputEncoding settings.  With such a setting, the emails written
by the post-receive-email hook use a mixture of encodings:

 1. Log messages use the configured log output encoding, which is
    meant to be whatever encoding works best with local terminals
    (and does not have much to do with what encoding should be used
    for email)

 2. Filenames are left as is: on Linux, usually UTF-8, and in the Mingw
    port (which uses Unicode filesystem APIs), always UTF-8

 3. The "This is an automated email" preface uses a project description
    from .git/description, which is typically in UTF-8 to support
    gitweb.

So (1) is configurable, and (2) and (3) are unconfigurable and
typically UTF-8.  Override the log output encoding to always use UTF-8
when writing the email to get the best chance of a comprehensible
single-encoding email.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agohooks/post-receive-email: use plumbing instead of git log/show
Jonathan Nieder [Fri, 2 Aug 2013 23:22:08 +0000 (16:22 -0700)] 
hooks/post-receive-email: use plumbing instead of git log/show

This way the hook doesn't have to keep being tweaked as porcelain
learns new features like color and pagination.

While at it, replace the "git rev-list | git shortlog" idiom with
plain "git shortlog" for simplicity.

Except for depending less on the value of settings like '[log]
abbrevCommit', no change in output intended.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'sb/mailmap-updates'
Junio C Hamano [Mon, 5 Aug 2013 17:11:14 +0000 (10:11 -0700)] 
Merge branch 'sb/mailmap-updates'

* sb/mailmap-updates:
  .mailmap: Multiple addresses of Michael S. Tsirkin

11 years agoMerge branch 'dn/test-reject-utf-16'
Junio C Hamano [Mon, 5 Aug 2013 17:11:10 +0000 (10:11 -0700)] 
Merge branch 'dn/test-reject-utf-16'

* dn/test-reject-utf-16:
  t3900: test rejecting log message with NULs correctly
  Add missing test file for UTF-16.

11 years agoMerge branch 'bc/commit-invalid-utf8'
Junio C Hamano [Mon, 5 Aug 2013 17:11:04 +0000 (10:11 -0700)] 
Merge branch 'bc/commit-invalid-utf8'

* bc/commit-invalid-utf8:
  commit: typofix for xxFFF[EF] check

11 years agocommit: typofix for xxFFF[EF] check
Junio C Hamano [Mon, 5 Aug 2013 16:52:28 +0000 (09:52 -0700)] 
commit: typofix for xxFFF[EF] check

We wanted to catch all codepoints that ends with FFFE and FFFF,
not with 0FFFE and 0FFFF.

Noticed and corrected by Peter Krefting.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agot3900: test rejecting log message with NULs correctly
Junio C Hamano [Mon, 5 Aug 2013 16:47:11 +0000 (09:47 -0700)] 
t3900: test rejecting log message with NULs correctly

It is not like that our longer term desire is to someday start
accept log messages with NULs in them, so it is wrong to mark a test
that demonstrates "git commit" that correctly fails given such an
input as "expect-failure".  "git commit" should fail today, and it
should fail the same way in the future given a message with NUL in it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoAdd missing test file for UTF-16.
Brian M. Carlson [Sat, 3 Aug 2013 17:26:31 +0000 (17:26 +0000)] 
Add missing test file for UTF-16.

The test file that the UTF-16 rejection test looks for is missing, but this went
unnoticed because the test is expected to fail anyway; as a consequence, the
test fails because the file containing the commit message is missing, and not
because the test file contains a NUL byte.  Fix this by including a sample text
file containing a commit message encoded in UTF-16.

Signed-off-by: Brian M. Carlson <sandals@crustytoothpaste.net>
Tested-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agofix typo in documentation of git-svn
Felix Gruber [Sat, 3 Aug 2013 14:37:15 +0000 (16:37 +0200)] 
fix typo in documentation of git-svn

Signed-off-by: Felix Gruber <felgru@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agocat-file: only split on whitespace when %(rest) is used
Jeff King [Fri, 2 Aug 2013 11:59:07 +0000 (04:59 -0700)] 
cat-file: only split on whitespace when %(rest) is used

Commit c334b87b (cat-file: split --batch input lines on whitespace,
2013-07-11) taught `cat-file --batch-check` to split input lines on
the first whitespace, and stash everything after the first token
into the %(rest) output format element.  It claimed:

   Object names cannot contain spaces, so any input with
   spaces would have resulted in a "missing" line.

But that is not correct.  Refs, object sha1s, and various peeling
suffixes cannot contain spaces, but some object names can. In
particular:

  1. Tree paths like "[<tree>]:path with whitespace"

  2. Reflog specifications like "@{2 days ago}"

  3. Commit searches like "rev^{/grep me}" or ":/grep me"

To remain backwards compatible, we cannot split on whitespace by
default, hence we will ship 1.8.4 with the commit reverted.

Resurrect its attempt but in a weaker form; only do the splitting
when "%(rest)" is used in the output format. Since that element did
not exist at all before c334b87, old scripts cannot be affected.

The existence of object names with spaces does mean that you
cannot reliably do:

  echo ":path with space and other data" |
  git cat-file --batch-check="%(objectname) %(rest)"

as it would split the path and feed only ":path" to get_sha1. But
that command is nonsensical. If you wanted to see "and other data"
in "%(rest)", git cannot possibly know where the filename ends and
the "rest" begins.

It might be more robust to have something like "-z" to separate the
input elements. But this patch is still a reasonable step before
having that.  It makes the easy cases easy; people who do not care
about %(rest) do not have to consider it, and the %(rest) code
handles the spaces and newlines of "rev-list --objects" correctly.

Hard cases remain hard but possible (if you might get whitespace in
your input, you do not get to use %(rest) and must split and join
the output yourself using more flexible tools). And most
importantly, it does not preclude us from having different splitting
rules later if a "-z" (or similar) option is added.  So we can make
the hard cases easier later, if we choose to.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoDocumentation/rev-list-options: add missing word in --*-parents
Torstein Hegge [Fri, 2 Aug 2013 18:40:07 +0000 (20:40 +0200)] 
Documentation/rev-list-options: add missing word in --*-parents

A commit has "parent commits" or "parents", not "commits".

Signed-off-by: Torstein Hegge <hegge@resisty.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years ago.mailmap: Multiple addresses of Michael S. Tsirkin
Stefan Beller [Sat, 3 Aug 2013 11:54:03 +0000 (13:54 +0200)] 
.mailmap: Multiple addresses of Michael S. Tsirkin

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agolog: use true parents for diff when walking reflogs
Thomas Rast [Sat, 3 Aug 2013 10:36:15 +0000 (12:36 +0200)] 
log: use true parents for diff when walking reflogs

The reflog walking logic (git log -g) replaces the true parent list
with the preceding commit in the reflog.  This results in bogus commit
diffs when combined with options such as -p; the diff is against the
reflog predecessor, not the parent of the commit.

Save the true parents on the side, extending the functions from the
previous commit.  The diff logic picks them up and uses them to show
the correct diffs.

We do have to be somewhat careful about repeated calling of
save_parents(), since the reflog may list a commit more than once.  We
now store (commit_list*)-1 to distinguish the "not saved yet" and
"root commit" cases.  This lets us preserve an empty parent list even
if save_parents() is repeatedly called.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agolog doc: the argument to --encoding is not optional
Jonathan Nieder [Fri, 2 Aug 2013 22:16:40 +0000 (15:16 -0700)] 
log doc: the argument to --encoding is not optional

 $ git log --encoding
 fatal: Option '--encoding' requires a value
 $ git rev-list --encoding
 fatal: Option '--encoding' requires a value

The argument to --encoding has always been mandatory.  Unfortunately
manpages like git-rev-list(1), git-log(1), and git-show(1) have
described the option's syntax as "--encoding[=<encoding>]" since it
was first documented.  Clarify by removing the extra brackets.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agol10n: zh_CN.po: translate 99 messages (2133t0f0u)
Jiang Xin [Fri, 26 Jul 2013 06:00:02 +0000 (14:00 +0800)] 
l10n: zh_CN.po: translate 99 messages (2133t0f0u)

Translate 99 new messages came from git.pot update in 28b3cff
(l10n: git.pot: v1.8.4 round 1 (99 new, 46 removed)).

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
11 years agopush: teach --force-with-lease to smart-http transport
Junio C Hamano [Fri, 2 Aug 2013 22:14:50 +0000 (15:14 -0700)] 
push: teach --force-with-lease to smart-http transport

We have been passing enough information to enable the
compare-and-swap logic down to the transport layer, but the
transport helper was not passing it to smart-http transport.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agosend-pack: fix parsing of --force-with-lease option
Junio C Hamano [Fri, 2 Aug 2013 23:06:29 +0000 (16:06 -0700)] 
send-pack: fix parsing of --force-with-lease option

The last argument for parse_push_cas_option() is if it is "unset"
(i.e. --no-force-with-lease), and we are parsing the option with an
explicit value here, so it has to be 0.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'rj/cygwin-clarify-use-of-cheating-lstat'
Junio C Hamano [Fri, 2 Aug 2013 18:01:00 +0000 (11:01 -0700)] 
Merge branch 'rj/cygwin-clarify-use-of-cheating-lstat'

Cygwin port added a "not quite correct but a lot faster and good
enough for many lstat() calls that are only used to see if the
working tree entity matches the index entry" lstat() emulation some
time ago, and it started biting us in places.  This removes it and
uses the standard lstat() that comes with Cygwin.

Recent topic that uses lstat on packed-refs file is broken when
this cheating lstat is used, and this is a simplest fix that is
also the cleanest direction to go in the long run.

* rj/cygwin-clarify-use-of-cheating-lstat:
  cygwin: Remove the Win32 l/stat() implementation

11 years agoMerge branch 'jk/cat-file-batch-optim'
Junio C Hamano [Fri, 2 Aug 2013 16:32:48 +0000 (09:32 -0700)] 
Merge branch 'jk/cat-file-batch-optim'

* jk/cat-file-batch-optim:
  Revert "cat-file: split --batch input lines on whitespace"

11 years agoRevert "cat-file: split --batch input lines on whitespace"
Junio C Hamano [Fri, 2 Aug 2013 16:29:30 +0000 (09:29 -0700)] 
Revert "cat-file: split --batch input lines on whitespace"

This reverts commit c334b87b30c1464a1ab563fe1fb8de5eaf0e5bac; the
update assumed that people only used the command to read from
"rev-list --objects" output, whose lines begin with a 40-hex object
name followed by a whitespace, but it turns out that scripts feed
random extended SHA-1 expressions (e.g. "HEAD:$pathname") in which
a whitespace has to be kept.

11 years agoDon't close pack fd when free'ing pack windows
Brandon Casey [Wed, 31 Jul 2013 19:51:37 +0000 (12:51 -0700)] 
Don't close pack fd when free'ing pack windows

Now that close_one_pack() has been introduced to handle file
descriptor pressure, it is not strictly necessary to close the
pack file descriptor in unuse_one_window() when we're under memory
pressure.

Jeff King provided a justification for leaving the pack file open:

   If you close packfile descriptors, you can run into racy situations
   where somebody else is repacking and deleting packs, and they go away
   while you are trying to access them. If you keep a descriptor open,
   you're fine; they last to the end of the process. If you don't, then
   they disappear from under you.

   For normal object access, this isn't that big a deal; we just rescan
   the packs and retry. But if you are packing yourself (e.g., because
   you are a pack-objects started by upload-pack for a clone or fetch),
   it's much harder to recover (and we print some warnings).

Let's do so (or uh, not do so).

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agosha1_file: introduce close_one_pack() to close packs on fd pressure
Brandon Casey [Fri, 2 Aug 2013 05:36:33 +0000 (22:36 -0700)] 
sha1_file: introduce close_one_pack() to close packs on fd pressure

When the number of open packs exceeds pack_max_fds, unuse_one_window()
is called repeatedly to attempt to release the least-recently-used
pack windows, which, as a side-effect, will also close a pack file
after closing its last open window.  If a pack file has been opened,
but no windows have been allocated into it, it will never be selected
by unuse_one_window() and hence its file descriptor will not be
closed.  When this happens, git may exceed the number of file
descriptors permitted by the system.

This latter situation can occur in show-ref or receive-pack during ref
advertisement.  During ref advertisement, receive-pack will iterate
over every ref in the repository and advertise it to the client after
ensuring that the ref exists in the local repository.  If the ref is
located inside a pack, then the pack is opened to ensure that it
exists, but since the object is not actually read from the pack, no
mmap windows are allocated.  When the number of open packs exceeds
pack_max_fds, unuse_one_window() will not be able to find any windows to
free and will not be able to close any packs.  Once the per-process
file descriptor limit is exceeded, receive-pack will produce a warning,
not an error, for each pack it cannot open, and will then most likely
fail with an error to spawn rev-list or index-pack like:

   error: cannot create standard input pipe for rev-list: Too many open files
   error: Could not run 'git rev-list'

This may also occur during upload-pack when refs are packed (in the
packed-refs file) and the number of packs that must be opened to
verify that these packed refs exist exceeds the file descriptor
limit.  If the refs are loose, then upload-pack will read each ref
from the object database (if the object is in a pack, allocating one
or more mmap windows for it) in order to peel tags and advertise the
underlying object.  But when the refs are packed and peeled,
upload-pack will use the peeled sha1 in the packed-refs file and
will not need to read from the pack files, so no mmap windows will
be allocated and just like with receive-pack, unuse_one_window()
will never select these opened packs to close.

When we have file descriptor pressure, we just need to find an open
pack to close.  We can leave the existing mmap windows open.  If
additional windows need to be mapped into the pack file, it will be
reopened when necessary.  If the pack file has been rewritten in the
mean time, open_packed_git_1() should notice when it compares the file
size or the pack's sha1 checksum to what was previously read from the
pack index, and reject it.

Let's introduce a new function close_one_pack() designed specifically
for this purpose to search for and close the least-recently-used pack,
where LRU is defined as (in order of preference):

   * pack with oldest mtime and no allocated mmap windows
   * pack with the least-recently-used windows, i.e. the pack
     with the oldest most-recently-used window, where none of
     the windows are in use
   * pack with the least-recently-used windows

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoProvide some linguistic guidance for the documentation.
Marc Branchaud [Thu, 1 Aug 2013 18:49:54 +0000 (14:49 -0400)] 
Provide some linguistic guidance for the documentation.

This will hopefully avoid questions over which spelling and grammar should
be used.  Translators are of course free to create localizations for
specific English dialects.

Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoGit 1.8.4-rc1 v1.8.4-rc1
Junio C Hamano [Thu, 1 Aug 2013 19:01:53 +0000 (12:01 -0700)] 
Git 1.8.4-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'ob/typofixes'
Junio C Hamano [Thu, 1 Aug 2013 18:58:32 +0000 (11:58 -0700)] 
Merge branch 'ob/typofixes'

* ob/typofixes:
  many small typofixes

11 years agoMerge branch 'ms/subtree-install-fix'
Junio C Hamano [Thu, 1 Aug 2013 18:57:25 +0000 (11:57 -0700)] 
Merge branch 'ms/subtree-install-fix'

* ms/subtree-install-fix:
  contrib/subtree: Fix make install target

11 years agoMerge branch 'jc/rm-submodule-error-message'
Junio C Hamano [Thu, 1 Aug 2013 18:57:25 +0000 (11:57 -0700)] 
Merge branch 'jc/rm-submodule-error-message'

Consolidate two messages phrased subtly differently without a good
reason.

* jc/rm-submodule-error-message:
  builtin/rm.c: consolidate error reporting for removing submodules

11 years agoMerge branch 'lf/echo-n-is-not-portable'
Junio C Hamano [Thu, 1 Aug 2013 18:52:43 +0000 (11:52 -0700)] 
Merge branch 'lf/echo-n-is-not-portable'

* lf/echo-n-is-not-portable:
  Avoid using `echo -n` anywhere

11 years agoMerge branch 'ma/hg-to-git'
Junio C Hamano [Thu, 1 Aug 2013 18:52:40 +0000 (11:52 -0700)] 
Merge branch 'ma/hg-to-git'

* ma/hg-to-git:
  hg-to-git: --allow-empty-message in git commit

11 years agoMerge branch 'jx/clean-interactive'
Junio C Hamano [Thu, 1 Aug 2013 18:52:37 +0000 (11:52 -0700)] 
Merge branch 'jx/clean-interactive'

* jx/clean-interactive:
  git-clean: implement partial matching for selection
  Documentation/git-clean: fix description for range

11 years agot5540/5541: smart-http does not support "--force-with-lease"
Junio C Hamano [Thu, 1 Aug 2013 18:05:02 +0000 (11:05 -0700)] 
t5540/5541: smart-http does not support "--force-with-lease"

The push() method in remote-curl.c is not told and does not pass the
necessary information to underlying send-pack, so this extension
does not yet work.  Leave a note in the test suite.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agolog: use true parents for diff even when rewriting
Thomas Rast [Wed, 31 Jul 2013 20:13:20 +0000 (22:13 +0200)] 
log: use true parents for diff even when rewriting

When using pathspec filtering in combination with diff-based log
output, parent simplification happens before the diff is computed.
The diff is therefore against the *simplified* parents.

This works okay, arguably by accident, in the normal case:
simplification reduces to one parent as long as the commit is TREESAME
to it.  So the simplified parent of any given commit must have the
same tree contents on the filtered paths as its true (unfiltered)
parent.

However, --full-diff breaks this guarantee, and indeed gives pretty
spectacular results when comparing the output of

  git log --graph --stat ...
  git log --graph --full-diff --stat ...

(--graph internally kicks in parent simplification, much like
--parents).

To fix it, store a copy of the parent list before simplification (in a
slab) whenever --full-diff is in effect.  Then use the stored parents
instead of the simplified ones in the commit display code paths.  The
latter do not actually check for --full-diff to avoid duplicated code;
they just grab the original parents if save_parents() has not been
called for this revision walk.

For ordinary commits it should be obvious that this is the right thing
to do.

Merge commits are a bit subtle.  Observe that with default
simplification, merge simplification is an all-or-nothing decision:
either the merge is TREESAME to one parent and disappears, or it is
different from all parents and the parent list remains intact.
Redundant parents are not pruned, so the existing code also shows them
as a merge.

So if we do show a merge commit, the parent list just consists of the
rewrite result on each parent.  Running, e.g., --cc on this in
--full-diff mode is not very useful: if any commits were skipped, some
hunks will disagree with all sides of the merge (with one side,
because commits were skipped; with the others, because they didn't
have those changes in the first place).  This triggers --cc showing
these hunks spuriously.

Therefore I believe that even for merge commits it is better to show
the diffs wrt. the original parents.

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoRename advice.object_name_warning to objectNameWarning
Thomas Rast [Wed, 31 Jul 2013 20:23:31 +0000 (22:23 +0200)] 
Rename advice.object_name_warning to objectNameWarning

We spell config variables in camelCase instead of with_underscores.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoconfig: add generic callback wrapper to parse section.<url>.key
Junio C Hamano [Wed, 31 Jul 2013 17:42:01 +0000 (10:42 -0700)] 
config: add generic callback wrapper to parse section.<url>.key

Existing configuration parsing functions (e.g. http_options() in
http.c) know how to parse two-level configuration variable names.
We would like to exploit them and parse something like this:

[http]
sslVerify = true
[http "https://weak.example.com"]
sslVerify = false

and pretend as if http.sslVerify were set to false when talking to
"https://weak.example.com/path".

Introduce `urlmatch_config_entry()` wrapper that:

 - is called with the target URL (e.g. "https://weak.example.com/path"),
   and the two-level variable parser (e.g. `http_options`);

 - uses `url_normalize()` and `match_urls()` to see if configuration
   data matches the target URL; and

 - calls the traditional two-level configuration variable parser
   only for the configuration data whose <url> part matches the
   target URL (and if there are multiple matches, only do so if the
   current match is a better match than the ones previously seen).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoconfig: add helper to normalize and match URLs
Kyle J. McKay [Wed, 31 Jul 2013 20:52:00 +0000 (13:52 -0700)] 
config: add helper to normalize and match URLs

Some http.* configuration variables need to take values customized
for the URL we are talking to.  We may want to set http.sslVerify to
true in general but to false only for a certain site, for example,
with a configuration file like this:

[http]
sslVerify = true
[http "https://weak.example.com"]
sslVerify = false

and let the configuration machinery pick up the latter only when
talking to "https://weak.example.com".  The latter needs to kick in
not only when the URL is exactly "https://weak.example.com", but
also is anything that "match" it, e.g.

https://weak.example.com/test
https://me@weak.example.com/test

The <url> in the configuration key consists of the following parts,
and is considered a match to the URL we are attempting to access
under certain conditions:

  . Scheme (e.g., `https` in `https://example.com/`). This field
    must match exactly between the config key and the URL.

  . Host/domain name (e.g., `example.com` in `https://example.com/`).
    This field must match exactly between the config key and the URL.

  . Port number (e.g., `8080` in `http://example.com:8080/`).  This
    field must match exactly between the config key and the URL.
    Omitted port numbers are automatically converted to the correct
    default for the scheme before matching.

  . Path (e.g., `repo.git` in `https://example.com/repo.git`). The
    path field of the config key must match the path field of the
    URL either exactly or as a prefix of slash-delimited path
    elements.  A config key with path `foo/` matches URL path
    `foo/bar`.  A prefix can only match on a slash (`/`) boundary.
    Longer matches take precedence (so a config key with path
    `foo/bar` is a better match to URL path `foo/bar` than a config
    key with just path `foo/`).

  . User name (e.g., `me` in `https://me@example.com/repo.git`). If
    the config key has a user name, it must match the user name in
    the URL exactly. If the config key does not have a user name,
    that config key will match a URL with any user name (including
    none), but at a lower precedence than a config key with a user
    name.

Longer matches take precedence over shorter matches.

This step adds two helper functions `url_normalize()` and
`match_urls()` to help implement the above semantics. The
normalization rules are based on RFC 3986 and should result in any
two equivalent urls being a match.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 years agoMerge branch 'rr/rebase-autostash'
Junio C Hamano [Wed, 31 Jul 2013 19:38:29 +0000 (12:38 -0700)] 
Merge branch 'rr/rebase-autostash'

* rr/rebase-autostash:
  git-rebase: fix typo

11 years agoMerge branch 'rj/commit-slab-fix'
Junio C Hamano [Wed, 31 Jul 2013 19:38:27 +0000 (12:38 -0700)] 
Merge branch 'rj/commit-slab-fix'

* rj/commit-slab-fix:
  commit-slab.h: Fix memory allocation and addressing

11 years agoMerge branch 'jk/commit-how-to-abort-cherry-pick'
Junio C Hamano [Wed, 31 Jul 2013 19:38:23 +0000 (12:38 -0700)] 
Merge branch 'jk/commit-how-to-abort-cherry-pick'

* jk/commit-how-to-abort-cherry-pick:
  commit: tweak empty cherry pick advice for sequencer

11 years agoMerge branch 'ds/doc-two-kinds-of-tags'
Junio C Hamano [Wed, 31 Jul 2013 19:38:21 +0000 (12:38 -0700)] 
Merge branch 'ds/doc-two-kinds-of-tags'

* ds/doc-two-kinds-of-tags:
  docs/git-tag: explain lightweight versus annotated tags