gitweb.git
contacts: reduce git-blame invocationsEric Sunshine Fri, 9 Aug 2013 21:39:56 +0000 (17:39 -0400)

contacts: reduce git-blame invocations

git-contacts invokes git-blame once for each patch hunk it encounters.
No attempt is made to consolidate invocations for multiple hunks
referencing the same file at the same revision. This can become
expensive quickly.

Reduce the number of git-blame invocations by taking advantage of the
ability to specify multiple -L ranges for a single invocation.

Without this patch, on a randomly chosen range of commits:

% time git-contacts 25fba78d36be6297^..23c339c0f262aad2 >/dev/null
real 0m6.142s
user 0m5.429s
sys 0m0.356s

With this patch:

% time git-contacts 25fba78d36be6297^..23c339c0f262aad2 >/dev/null
real 0m2.285s
user 0m2.093s
sys 0m0.165s

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

contacts: gather all blame sources prior to invoking... Eric Sunshine Fri, 9 Aug 2013 21:39:55 +0000 (17:39 -0400)

contacts: gather all blame sources prior to invoking git-blame

git-contacts invokes git-blame immediately upon encountering a patch
hunk. No attempt is made to consolidate invocations for multiple hunks
referencing the same file at the same revision. This can become
expensive quickly.

Any effort to reduce the number of times git-blame is run will need to
to know in advance which line ranges to blame per file per revision.
Make this information available by collecting all sources as a distinct
step from invoking git-blame. A subsequent patch will utilize the
information to optimize git-blame invocations.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

contacts: validate hunk length earlierEric Sunshine Fri, 9 Aug 2013 21:39:54 +0000 (17:39 -0400)

contacts: validate hunk length earlier

Rather than calling get_blame() with a zero-length hunk only to have it
rejected immediately, perform hunk-length validation earlier in order to
avoid calling get_blame() unnecessarily.

This is a preparatory step to simplify later patches which reduce the
number of git-blame invocations by collecting together all lines to
blame within a single file at a particular revision. By validating the
blame range early, the subsequent patch can more easily avoid adding
empty ranges at collection time.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

whatchanged: document its historical natureJunio C Hamano Fri, 9 Aug 2013 20:01:48 +0000 (13:01 -0700)

whatchanged: document its historical nature

Encourage new users to use 'log' instead. These days, these
commands are unified and just have different defaults.

'git log' only allowed you to view the log messages and no diffs
when it was added in early June 2005. It was only in early April
2006 that the command learned to take diff options. Because of
this, power users tended to use 'whatchanged' that already existed
since mid May 2005 and supported diff options.

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

core-tutorial: trim the section on Inspecting ChangesJunio C Hamano Fri, 9 Aug 2013 17:28:53 +0000 (10:28 -0700)

core-tutorial: trim the section on Inspecting Changes

Back when the core tutorial was written, `log` and `whatchanged`
were scripted Porcelains. In the "Inspecting Changes" section that
talks about the plumbing commands in the diff family, it made sense
to use `log` and `whatchanged` as good examples of the use of these
plumbing commands, and because even these scripted Porcelains were
novelty (there wasn't the new end-user tutorial written), it made
some sense to illustrate uses of the `git log` (and `git
whatchanged`) scripted Porcelain commands.

But we no longer have scripted `log` and `whatchanged` to serve as
examples, and this document is not where the end users learn what
`git log` command is about. Stop at briefly mentioning the
possibility of combining rev-list with diff-tree to build your own
log, and leave the end-user documentation of `log` to the new
tutorial and the user manual.

Also resurrect the last version of `git-log`, `git-whatchanged`, and
`git-show` to serve as examples to contrib/examples/ directory.

While at it, remove 'whatchanged' from a list of sample commands
that are affected by GIT_FLUSH environment variable. This is not
meant to be an exhaustive list but as a list of typical ones, and an
old command that is kept primarily for backward compatibility does
not belong to it.

Helped-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-p4: Fix occasional truncation of symlink contents.Alexandru Juncu Thu, 8 Aug 2013 13:17:38 +0000 (16:17 +0300)

git-p4: Fix occasional truncation of symlink contents.

Symlink contents in p4 print sometimes have a trailing
new line character, but sometimes it doesn't. git-p4
should only remove the last character if that character
is '\n'.

Signed-off-by: Alex Juncu <ajuncu@ixiacom.com>
Signed-off-by: Alex Badea <abadea@ixiacom.com>
Acked-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add shared repo upgradeFelipe Contreras Fri, 9 Aug 2013 22:38:04 +0000 (17:38 -0500)

remote-hg: add shared repo upgrade

If we have an old organization (v1.8.3), and want to upgrade to a newer
one (v1.8.4), the user would have to fetch the whole repository, instead
we can just move the repository, so the user would not notice any
difference.

Also, remove other clones, so in time they get set up as shared.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Reviewed-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: ensure shared repo is initializedFelipe Contreras Fri, 9 Aug 2013 22:38:03 +0000 (17:38 -0500)

remote-hg: ensure shared repo is initialized

6796d49 (remote-hg: use a shared repository store) introduced a bug by
making the shared repository '.git/hg', which is already used before
that patch, so clones that happened before that patch, fail after that
patch, because there's no shared Mercurial repo.

So, instead of simply checking if the directory exists, let's always try
to create an empty shared repository to ensure it's there. This works
because we don't need the initial clone, if the repository is shared,
pulling from the child updates the parent's storage; it's exactly the
same as cloning, so we can simplify the shared repo setup this way while
at the same time fixing the problem.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Reviewed-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: Add reference for french translation teamJean-Noel Avila Fri, 9 Aug 2013 22:30:55 +0000 (00:30 +0200)

l10n: Add reference for french translation team

Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>

l10n: fr.po: 821/2112 messages translatedJean-Noel Avila Mon, 1 Jul 2013 20:19:04 +0000 (22:19 +0200)

l10n: fr.po: 821/2112 messages translated

Trying to focus on most useful phrases.

Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>

Merge branch 'maint'Junio C Hamano Fri, 9 Aug 2013 22:49:55 +0000 (15:49 -0700)

Merge branch 'maint'

* maint:
parse-options: fix clang opterror() -Wunused-value warning

remote-hg: fix path when cloning with tilde expansionAntoine Pelisse Fri, 9 Aug 2013 17:13:07 +0000 (19:13 +0200)

remote-hg: fix path when cloning with tilde expansion

The current code fixes the path to make it absolute when cloning, but
doesn't consider tilde expansion, so that scenario fails throwing an
exception because /home/myuser/~/my/repository doesn't exists:

$ git clone hg::~/my/repository && cd repository && git fetch

Expand the tilde when checking if the path is absolute, so that we don't
fix a path that doesn't need to be.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'master' of git://github.com/git-l10n... Junio C Hamano Fri, 9 Aug 2013 21:31:28 +0000 (14:31 -0700)

Merge branch 'master' of git://github.com/git-l10n/git-po

* 'master' of git://github.com/git-l10n/git-po:
l10n: de.po: translate 5 messages
l10n: de.po: translate 99 new messages
l10n: de.po: switch from pure German to German+English
l10n: de.po: Fix a typo
l10n: Update Swedish translation (2135t0f0u)
l10n: zh_CN.po: translate 5 messages (2135t0f0u)
l10n: vi.po(2135t): v1.8.4 round 2
l10n: git.pot: v1.8.4 round 2 (5 new, 3 removed)

Merge branch 'jk/submodule-subdirectory-ok'Junio C Hamano Fri, 9 Aug 2013 21:30:41 +0000 (14:30 -0700)

Merge branch 'jk/submodule-subdirectory-ok'

* jk/submodule-subdirectory-ok:
t/t7407: fix two typos in submodule tests

Merge branch 'sb/mailmap-updates'Junio C Hamano Fri, 9 Aug 2013 21:30:13 +0000 (14:30 -0700)

Merge branch 'sb/mailmap-updates'

* sb/mailmap-updates:
.mailmap: fixup entries

.mailmap: fixup entriesStefan Beller Fri, 9 Aug 2013 18:18:24 +0000 (20:18 +0200)

.mailmap: fixup entries

This patch adds no new names, but fixes the mistakes I made in the previous
commits. (94b410bba8, f4f49e225, c07a6bc57, 2013-07-12, .mailmap: Map
email addresses to names).

These mistakes are double white spaces between name and surname,
different capitalization in email address, or just the email address set
as name.

Also I forgot to include James Knight to the mailmap file.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-merge-file: document option "--diff3"Ralf Thielow Fri, 9 Aug 2013 18:09:32 +0000 (20:09 +0200)

Documentation/git-merge-file: document option "--diff3"

The option "--diff3" was added to "git merge-file" in e0af48e
(xdiff-merge: optionally show conflicts in "diff3 -m" style)
but it was never documented in "Documentation/git-merge-file.txt".
Add documentation for this option.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t/t7407: fix two typos in submodule testsPhil Hord Fri, 9 Aug 2013 20:12:54 +0000 (16:12 -0400)

t/t7407: fix two typos in submodule tests

In t/t7407-submodule-foreach.sh there is a typo in one of the
path names given for a test step. The correct path is
nested1/nested2/.git, but nested1/nested1/nested2/.git is
given instead. The typo is hidden because this line also
accidentally omits the && chain operator. The omitted chain
also means the return values of all the previous commands in
this test are also being ignored.

Fix the path and add the chain operator so the entire test
sequence can be properly validated.

Signed-off-by: Phil Hord <hordp@cisco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rm: remove unneeded null pointer checkStefan Beller Thu, 8 Aug 2013 17:52:41 +0000 (19:52 +0200)

rm: remove unneeded null pointer check

As of 7612a1efdb (2006-06-09 git-rm: honor -n flag.) the variable
'pathspec' seems to be assumed to be never NULL after calling get_pathspec
There was a NULL pointer check after the seen = NULL assignment, which
was removed by that commit. So if pathspec would be NULL now, we'd segfault
in the line accessing the pathspec:
for (i = 0; pathspec[i] ; i++)

A few lines later, 'pathspec' still cannot be NULL, but that check was
overlooked, hence removing it now.

As the null pointer check was removed, it makes no sense to assign NULL
to seen and 3 lines later another value as there are no conditions in
between.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff: fix a possible null pointer dereferenceStefan Beller Thu, 8 Aug 2013 22:11:53 +0000 (00:11 +0200)

diff: fix a possible null pointer dereference

The condition in the ternary operator was wrong, hence the wrong char
pointer could be used as the parameter for show_submodule_summary.
one->path may be null, but we definitely need a non null path given
to the function.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Acked-By: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff: remove ternary operator evaluating always to... Stefan Beller Thu, 8 Aug 2013 18:31:44 +0000 (20:31 +0200)

diff: remove ternary operator evaluating always to true

The line being changed is deep inside the function builtin_diff.
The variable name_b, which is used to evaluate the ternary expression
must evaluate to true at that position, hence the replacement with
just name_b.

The name_b variable only occurs a few times in that lengthy function:
As a parameter to the function itself:
static void builtin_diff(const char *name_a,
const char *name_b,
...
The next occurrences are at:
/* Never use a non-valid filename anywhere if at all possible */
name_a = DIFF_FILE_VALID(one) ? name_a : name_b;
name_b = DIFF_FILE_VALID(two) ? name_b : name_a;

a_one = quote_two(a_prefix, name_a + (*name_a == '/'));
b_two = quote_two(b_prefix, name_b + (*name_b == '/'));

In the last line of this block 'name_b' is dereferenced and compared
to '/'. This would crash if name_b was NULL. Hence in the following code
we can assume name_b being non-null.

The next occurrence is just as a function argument, which doesn't change
the memory, which name_b points to, so the assumption name_b being not
null still holds:
emit_rewrite_diff(name_a, name_b, one, two,
textconv_one, textconv_two, o);

The next occurrence would be the line of this patch. As name_b still must
be not null, we can remove the ternary operator.

Inside the emit_rewrite_diff function there is a also a line
ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a);
which was also simplified as there is also a dereference before the
ternary operator.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parse-options: fix clang opterror() -Wunused-value... Eric Sunshine Fri, 9 Aug 2013 09:06:17 +0000 (05:06 -0400)

parse-options: fix clang opterror() -Wunused-value warning

a469a1019352b8ef (silence some -Wuninitialized false positives;
2012-12-15) triggered "unused value" warnings when the return value of
opterror() and several other error-related functions was not used.
5ded807f7c0be10e (fix clang -Wunused-value warnings for error functions;
2013-01-16) applied a fix by adding #if !defined(__clang__) in cache.h
and git-compat-util.h, but misspelled it as #if !defined(clang) in
parse-options.h. Fix this.

This mistake went unnoticed because existing callers of opterror()
utilize its return value. 1158826394e162c5 (parse-options: add
OPT_CMDMODE(); 2013-07-30), however, adds a new invocation of opterror()
which ignores the return value, thus triggering the "unused value"
warning.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/config.c: compilation fixJunio C Hamano Fri, 9 Aug 2013 04:41:44 +0000 (21:41 -0700)

builtin/config.c: compilation fix

Do not feed a random string as the first parameter to die(); use "%s"
as the format string instead.

Do the same for test-urlmatch-normalization.c while saving a single
pointer variable by turning a "const char *" constant string into
"const char []", which is sufficient to squelch compilation warning
(the compiler can see usage[] given to die() is a constant and will
never have conversion specifiers that cause trouble). But for a
good measure, give them the same "%s" treatment as well.

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

gc: reject if another gc is running, unless --force... Nguyễn Thái Ngọc Duy Thu, 8 Aug 2013 11:05:38 +0000 (18:05 +0700)

gc: reject if another gc is running, unless --force is given

This may happen when `git gc --auto` is run automatically, then the
user, to avoid wait time, switches to a new terminal, keeps working
and `git gc --auto` is started again because the first gc instance has
not clean up the repository.

This patch tries to avoid multiple gc running, especially in --auto
mode. In the worst case, gc may be delayed 12 hours if a daemon reuses
the pid stored in gc.pid.

kill(pid, 0) support is added to MinGW port so it should work on
Windows too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: de.po: translate 5 messagesRalf Thielow Tue, 6 Aug 2013 17:54:29 +0000 (19:54 +0200)

l10n: de.po: translate 5 messages

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: Ralf Thielow <ralf.thielow@gmail.com>

l10n: de.po: translate 99 new messagesRalf Thielow Fri, 26 Jul 2013 15:48:46 +0000 (17:48 +0200)

l10n: de.po: translate 99 new messages

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: Ralf Thielow <ralf.thielow@gmail.com>
Acked-by: Thomas Rast <trast@inf.ethz.ch>

Git 1.8.4-rc2 v1.8.4-rc2Junio C Hamano Thu, 8 Aug 2013 20:58:34 +0000 (13:58 -0700)

Git 1.8.4-rc2

This is with mostly minor documentation and test updates, nothing
spectacular except for removal of funky lstat(2) emulation on Cygwin.

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

l10n: de.po: switch from pure German to German+EnglishRalf Thielow Wed, 29 May 2013 16:03:39 +0000 (18:03 +0200)

l10n: de.po: switch from pure German to German+English

This switches the translation from pure German to German+English.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Acked-by: Thomas Rast <trast@inf.ethz.ch>

l10n: de.po: Fix a typoWieland 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>

fetch: work around "transport-take-over" hackJunio 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>

fetch: refactor code that fetches leftover tagsJunio 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>

fetch: refactor code that prepares a transportJunio 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>

fetch: 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>

t5802: add test for connect helperJunio 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>

die_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>

revert: use the OPT_CMDMODE for parsing, reducing codeStefan 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>

checkout-index: fix negations of even numbers of -nStefan 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>

config parsing options: allow one flag multiple timesStefan 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>

hash-object: replace stdin parsing OPT_BOOLEAN by OPT_C... 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>

branch, commit, name-rev: ease up boolean conditionsStefan 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>

line-range: reject -L line numbers less than 1Eric 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>

t8001/t8002: blame: add tests of -L line numbers less... 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>

line-range: teach -L^:RE to search from start of fileEric 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>

line-range: teach -L:RE to search from end of previous... 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>

line-range: teach -L^/RE/ to search from start of fileEric 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>

line-range-format.txt: document -L/RE/ relative searchEric 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>

log: teach -L/RE/ to search from end of previous -L... 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>

blame: teach -L/RE/ to search from end of previous... 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>

line-range: teach -L/RE/ to search relative to anchor... 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>

blame: document multiple -L supportEric 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>

t8001/t8002: blame: add tests of multiple -L optionsEric 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>

blame: accept multiple -L rangesEric 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>

blame: inline one-line function into its lone callerEric 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>

range-set: publish API for re-use by git-blame -LEric 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>

line-range-format.txt: clarify -L:regex usage formEric 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>

git-log.txt: place each -L option variation on its... 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>

rm: delete .gitmodules entry of submodules removed... 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>

mv: update the path entry in .gitmodules for moved... 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>

t0070: test that git_mkstemps correctly checks return... 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>

l10n: 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>

l10n: 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>

l10n: vi.po(2135t): v1.8.4 round 2Tran 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>

l10n: 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>

config: "git config --get-urlmatch" parses section... 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>

builtin/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>

config: parse http.<url>.<variable> using urlmatchKyle 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>

Sync with maint to grab trivial doc fixesJunio 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

blame: reject empty ranges -L,+0 and -L,-0Eric 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>

t8001/t8002: blame: demonstrate acceptance of bogus... 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>

blame: reject empty ranges -LX,+0 and -LX,-0Eric 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>

t8001/t8002: blame: demonstrate acceptance of bogus... 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>

log: fix -L bounds checking bugEric 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>

t4211: retire soon-to-be unimplementable testsEric 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>

t4211: log: demonstrate -L bounds checking bugEric 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>

blame: fix -L bounds checking bugEric 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>

t8001/t8002: blame: add empty file & partial-line testsEric 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>

t8001/t8002: blame: demonstrate -L bounds checking bugEric 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>

t8001/t8002: blame: decompose overly-large testEric 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>

checkout: remove superfluous local variableStefan 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>

log, format-patch: parsing uses OPT__QUIETStefan 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>

Replace deprecated OPT_BOOLEAN by OPT_BOOLStefan 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>

Remove deprecated OPTION_BOOLEAN for parsing argumentsStefan 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>

t5551: Remove header from curl cookie fileBrian 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>

OS X: Fix redeclaration of die warningBrian 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>

Makefile: Fix APPLE_COMMON_CRYPTO with BLK_SHA1Brian 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>

Merge 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

t8001, t8002: fix "blame -L :literal" test on NetBSDRené 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>

Merge git://github.com/git-l10n/git-poJunio 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)

hooks/post-receive-email: set declared encoding to... 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>

hooks/post-receive-email: force log messages in UTF-8Jonathan 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>

hooks/post-receive-email: use plumbing instead of git... 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>

Merge 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

Merge 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.

Merge 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

commit: typofix for xxFFF[EF] checkJunio 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>

t3900: test rejecting log message with NULs correctlyJunio 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>

Add 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>

fix typo in documentation of git-svnFelix 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>

cat-file: only split on whitespace when %(rest) is... 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>

Documentation/rev-list-options: add missing word in... 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>