gitweb.git
Merge branch 'dr/doc-check-ref-format-normalize'Junio C Hamano Fri, 24 Feb 2017 18:48:09 +0000 (10:48 -0800)

Merge branch 'dr/doc-check-ref-format-normalize'

Doc update.

* dr/doc-check-ref-format-normalize:
git-check-ref-format: clarify documentation for --normalize

Merge branch 'gp/document-dotfiles-in-templates-are... Junio C Hamano Fri, 24 Feb 2017 18:48:09 +0000 (10:48 -0800)

Merge branch 'gp/document-dotfiles-in-templates-are-not-copied'

Doc update.

* gp/document-dotfiles-in-templates-are-not-copied:
init: document dotfiles exclusion on template copy

Merge branch 'rt/align-add-i-help-text'Junio C Hamano Fri, 24 Feb 2017 18:48:08 +0000 (10:48 -0800)

Merge branch 'rt/align-add-i-help-text'

Doc update.

* rt/align-add-i-help-text:
git add -i: replace \t with blanks in the help message

Merge branch 'bc/blame-doc-fix'Junio C Hamano Fri, 24 Feb 2017 18:48:07 +0000 (10:48 -0800)

Merge branch 'bc/blame-doc-fix'

Doc update.

* bc/blame-doc-fix:
Documentation: use brackets for optional arguments

docs/git-gc: fix default value for `--aggressiveDepth`Patrick Steinhardt Fri, 24 Feb 2017 08:46:45 +0000 (09:46 +0100)

docs/git-gc: fix default value for `--aggressiveDepth`

In commit 07e7dbf0d (gc: default aggressive depth to 50, 2016-08-11),
the default aggressive depth of git-gc has been changed to 50. While
git-config(1) has been updated to represent the new default value,
git-gc(1) still mentions the old value. This patch fixes it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge tag 'l10n-2.12.0-rnd2' of git://github.com/git... Junio C Hamano Fri, 24 Feb 2017 17:55:41 +0000 (09:55 -0800)

Merge tag 'l10n-2.12.0-rnd2' of git://github.com/git-l10n/git-po

l10n-2.12.0-rnd2

* tag 'l10n-2.12.0-rnd2' of git://github.com/git-l10n/git-po: (22 commits)
l10n: zh_CN: for git v2.12.0 l10n round 2
l10n: Update Catalan translation
l10n: pt_PT: update Portuguese tranlation
l10n: sv.po: Update Swedish translation (3139t0f0u)
l10n: de.po: translate 241 messages
l10n: ko.po: Update Korean translation
l10n: vi.po (3139t): Updated 2 new messages for rc1
l10n: fr.po: v2.12.0 round 2 3139t
l10n: git.pot: v2.12.0 round 2 (2 new)
l10n: vi.po: Updated Vietnamese translation (3137t)
l10n: update Catalan translation
l10n: sv.po: Update Swedish translation (3137t0f0u)
l10n: fr.po: v2.11-rc0 first round
l10n: ko.po: Update Korean translation
l10n: fr.po: Fix a typo in the French translation
l10n: fr.po: Remove gender specific adjectives
l10n: fr.po: Fix typos
l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)
l10n: bg: Updated Bulgarian translation (2913t+0f+0u)
l10n: fixes to Catalan translation
...

l10n: zh_CN: for git v2.12.0 l10n round 2Jiang Xin Fri, 27 Jan 2017 14:50:57 +0000 (22:50 +0800)

l10n: zh_CN: for git v2.12.0 l10n round 2

Translate 241 messages (3139t0f0u) for git v2.12.0-rc1.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>

l10n: Update Catalan translationJordi Mas Tue, 21 Feb 2017 17:32:29 +0000 (18:32 +0100)

l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>

config: use git_config_parse_key() in git_config_parse_... Junio C Hamano Thu, 23 Feb 2017 23:04:40 +0000 (15:04 -0800)

config: use git_config_parse_key() in git_config_parse_parameter()

The parsing of one-shot assignments of configuration variables that
come from the command line historically was quite loose and allowed
anything to pass. It also downcased everything in the variable name,
even a three-level <section>.<subsection>.<variable> name in which
the <subsection> part must be treated in a case sensitive manner.

Existing git_config_parse_key() helper is used to parse the variable
name that comes from the command line, i.e. "git config VAR VAL",
and handles these details correctly. Replace the strbuf_tolower()
call in git_config_parse_parameter() with a call to it to correct
both issues. git_config_parse_key() does a bit more things that are
not necessary for the purpose of this codepath (e.g. it allocates a
separate buffer to return the canonicalized variable name because it
takes a "const char *" input), but we are not in a performance-critical
codepath here.

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

config: move a few helper functions upJunio C Hamano Thu, 23 Feb 2017 22:44:07 +0000 (14:44 -0800)

config: move a few helper functions up

git_config_parse_key() implements the validation and downcasing of
<section> and <variable> in "<section>[.<subsection>].<variable>"
configuration variable name. Move it (and helpers it uses) a bit up
so that it can be used by git_config_parse_parameter(), which is
used to check configuration settings that are given on the command
line (i.e. "git -c VAR=VAL cmd"), in a later patch.

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

ident: do not ignore empty config name/emailJeff King Thu, 23 Feb 2017 08:17:08 +0000 (03:17 -0500)

ident: do not ignore empty config name/email

When we read user.name and user.email from a config file,
they go into strbufs. When a caller asks ident_default_name()
for the value, we fallback to auto-detecting if the strbuf
is empty.

That means that explicitly setting an empty string in the
config is identical to not setting it at all. This is
potentially confusing, as we usually accept a configured
value as the final value.

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

ident: reject all-crud ident nameJeff King Thu, 23 Feb 2017 08:15:55 +0000 (03:15 -0500)

ident: reject all-crud ident name

An ident name consisting of only "crud" characters (like
whitespace or punctuation) is effectively the same as an
empty one, because our strbuf_addstr_without_crud() will
remove those characters.

We reject an empty name when formatting a strict ident, but
don't notice an all-crud one because our check happens
before the crud-removal step.

We could skip past the crud before checking for an empty
name, but let's make it a separate code path, for two
reasons. One is that we can give a more specific error
message. And two is that unlike a blank name, we probably
don't want to kick in the fallback-to-username behavior.

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

ident: handle NULL email when complaining of empty... Jeff King Thu, 23 Feb 2017 08:13:53 +0000 (03:13 -0500)

ident: handle NULL email when complaining of empty name

If we see an empty name, we complain about and mention the
matching email in the error message (to give it some
context). However, the "email" pointer may be NULL here if
we were planning to fill it in later from ident_default_email().

This was broken by 59f929596 (fmt_ident: refactor strictness
checks, 2016-02-04). Prior to that commit, we would look up
the default name and email before doing any other actions.
So one solution would be to go back to that.

However, we can't just do so blindly. The logic for handling
the "!email" condition has grown since then. In particular,
looking up the default email can die if getpwuid() fails,
but there are other errors that should take precedence.
Commit 734c7789a (ident: check for useConfigOnly before
auto-detection of name/email, 2016-03-30) reordered the
checks so that we prefer the error message for
useConfigOnly.

Instead, we can observe that while the name-handling depends
on "email" being set, the reverse is not true. So we can
simply set up the email variable first.

This does mean that if both are bogus, we'll complain about
the email before the name. But between the two, there is no
reason to prefer one over the other.

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

ident: mark error messages for translationJeff King Thu, 23 Feb 2017 08:12:30 +0000 (03:12 -0500)

ident: mark error messages for translation

We already translate the big "please tell me who you are"
hint, but missed the individual error messages that go with
it.

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

upload-pack: report "not our ref" to clientJonathan Tan Thu, 23 Feb 2017 18:43:03 +0000 (10:43 -0800)

upload-pack: report "not our ref" to client

Make upload-pack report "not our ref" errors to the client as an "ERR" line.
(If not, the client would be left waiting for a response when the server is
already dead.)

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

http: restrict auth methods to what the server advertisesJeff King Wed, 22 Feb 2017 23:34:37 +0000 (18:34 -0500)

http: restrict auth methods to what the server advertises

By default, we tell curl to use CURLAUTH_ANY, which does not
limit its set of auth methods. However, this results in an
extra round-trip to the server when authentication is
required. After we've fed the credential to curl, it wants
to probe the server to find its list of available methods
before sending an Authorization header.

We can shortcut this by limiting our http_auth_methods by
what the server told us it supports. In some cases (such as
when the server only supports Basic), that lets curl skip
the extra probe request.

The end result should look the same to the user, but you can
use GIT_TRACE_CURL to verify the sequence of requests:

GIT_TRACE_CURL=1 \
git ls-remote https://example.com/repo.git \
2>&1 >/dev/null |
egrep '(Send|Recv) header: (GET|HTTP|Auth)'

Before this patch, hitting a Basic-only server like
github.com results in:

Send header: GET /repo.git/info/refs?service=git-upload-pack HTTP/1.1
Recv header: HTTP/1.1 401 Authorization Required
Send header: GET /repo.git/info/refs?service=git-upload-pack HTTP/1.1
Recv header: HTTP/1.1 401 Authorization Required
Send header: GET /repo.git/info/refs?service=git-upload-pack HTTP/1.1
Send header: Authorization: Basic <redacted>
Recv header: HTTP/1.1 200 OK

And after:

Send header: GET /repo.git/info/refs?service=git-upload-pack HTTP/1.1
Recv header: HTTP/1.1 401 Authorization Required
Send header: GET /repo.git/info/refs?service=git-upload-pack HTTP/1.1
Send header: Authorization: Basic <redacted>
Recv header: HTTP/1.1 200 OK

The possible downsides are:

- This only helps for a Basic-only server; for a server
with multiple auth options, curl may still send a probe
request to see which ones are available (IOW, there's no
way to say "don't probe, I already know what the server
will say").

- The http_auth_methods variable is global, so this will
apply to all further requests. That's acceptable for
Git's usage of curl, though, which also treats the
credentials as global. I.e., in any given program
invocation we hit only one conceptual server (we may be
redirected at the outset, but in that case that's whose
auth_avail field we'd see).

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

l10n: pt_PT: update Portuguese tranlationVasco Almeida Sun, 5 Feb 2017 18:43:34 +0000 (17:43 -0100)

l10n: pt_PT: update Portuguese tranlation

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>

git add -i: replace \t with blanks in the help messageRalf Thielow Wed, 22 Feb 2017 18:46:27 +0000 (19:46 +0100)

git add -i: replace \t with blanks in the help message

Within the help message of 'git add -i', the 'diff' command uses one
tab character and blanks to create the space between the name and the
description while the others use blanks only. So if the tab size is
not at 4 characters, this description will not be in range.
Replace the tab character with blanks.

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

Documentation: use brackets for optional argumentsbrian m. carlson Wed, 22 Feb 2017 12:25:46 +0000 (12:25 +0000)

Documentation: use brackets for optional arguments

The documentation for git blame used vertical bars for optional
arguments to -M and -C, which is unusual and potentially confusing.
Since most man pages use brackets for optional items, and that's
consistent with how we document the same options for git diff and
friends, use brackets here, too.

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

Documentation: correctly spell git worktree --detachbrian m. carlson Wed, 22 Feb 2017 12:34:42 +0000 (12:34 +0000)

Documentation: correctly spell git worktree --detach

The option is “--detach”, but we accidentally spelled it “--detached” at
one point in the man page.

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

remote: ignore failure to remove missing branch.<name... Ross Lagerwall Sat, 18 Feb 2017 00:23:41 +0000 (00:23 +0000)

remote: ignore failure to remove missing branch.<name>.merge

It is not all too unusual for a branch to use "branch.<name>.remote"
without "branch.<name>.merge". You may be using the 'push.default'
configuration set to 'current', for example, and do

$ git checkout -b side colleague/side
$ git config branch.side.remote colleague

However, "git remote rm" to remove the remote used in such a manner
fails with

"fatal: could not unset 'branch.<name>.merge'"

because it assumes that a branch that has .remote defined must also
have .merge defined. Detect the "cannot unset because it is not set
to begin with" case and ignore it.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-check-ref-format: clarify documentation for --normalizeDamien Regad Sun, 19 Feb 2017 22:32:32 +0000 (23:32 +0100)

git-check-ref-format: clarify documentation for --normalize

Use of 'iff' may be confusing to people not familiar with this term.

Improving the --normalize option's documentation to remove the use of
'iff', and clearly describe what happens when the condition is not met.

Signed-off-by: Damien Regad <dregad@mantisbt.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'master' of git://github.com/nafmo/git... Jiang Xin Tue, 21 Feb 2017 16:06:44 +0000 (00:06 +0800)

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

* 'master' of git://github.com/nafmo/git-l10n-sv:
l10n: sv.po: Update Swedish translation (3139t0f0u)

branch: record creation of renamed branch in HEAD's logKyle Meyer Tue, 21 Feb 2017 01:10:35 +0000 (20:10 -0500)

branch: record creation of renamed branch in HEAD's log

Renaming the current branch adds an event to the current branch's log
and to HEAD's log. However, the logged entries differ. The entry in
the branch's log represents the entire renaming operation (the old and
new hash are identical), whereas the entry in HEAD's log represents
the deletion only (the new sha1 is null).

Extend replace_each_worktree_head_symref(), whose only caller is
branch_rename(), to take a reflog message argument. This allows the
creation of the new ref to be recorded in HEAD's log. As a result,
the renaming event is represented by two entries (a deletion and a
creation entry) in HEAD's log.

It's a bit unfortunate that the branch's log and HEAD's log now
represent the renaming event in different ways. Given that the
renaming operation is not atomic, the two-entry form is a more
accurate representation of the operation and is more useful for
debugging purposes if a failure occurs between the deletion and
creation events. It would make sense to move the branch's log to the
two-entry form, but this would involve changes to how the rename is
carried out and to how the update flags and reflogs are processed for
deletions, so it may not be worth the effort.

Based-on-patch-by: Jeff King <peff@peff.net>
Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rename_ref: replace empty message in HEAD's logKyle Meyer Tue, 21 Feb 2017 01:10:34 +0000 (20:10 -0500)

rename_ref: replace empty message in HEAD's log

When the current branch is renamed, the deletion of the old ref is
recorded in HEAD's log with an empty message. Now that delete_ref()
accepts a reflog message, provide a more descriptive message by
passing along the log message that is given to rename_ref().

The next step will be to extend HEAD's log to also include the second
part of the rename, the creation of the new branch.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

update-ref: pass reflog message to delete_ref()Kyle Meyer Tue, 21 Feb 2017 01:10:33 +0000 (20:10 -0500)

update-ref: pass reflog message to delete_ref()

Now that delete_ref() accepts a reflog message, pass the user-provided
message to delete_ref() rather than silently dropping it.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

delete_ref: accept a reflog message argumentKyle Meyer Tue, 21 Feb 2017 01:10:32 +0000 (20:10 -0500)

delete_ref: accept a reflog message argument

When the current branch is renamed with 'git branch -m/-M' or deleted
with 'git update-ref -m<msg> -d', the event is recorded in HEAD's log
with an empty message. In preparation for adding a more meaningful
message to HEAD's log in these cases, update delete_ref() to take a
message argument and pass it along to ref_transaction_delete().
Modify all callers to pass NULL for the new message argument; no
change in behavior is intended.

Note that this is relevant for HEAD's log but not for the deleted
ref's log, which is currently deleted along with the ref. Even if it
were not, an entry for the deletion wouldn't be present in the deleted
ref's log. files_transaction_commit() writes to the log if
REF_NEEDS_COMMIT or REF_LOG_ONLY are set, but lock_ref_for_update()
doesn't set REF_NEEDS_COMMIT for the deleted ref because REF_DELETING
is set. In contrast, the update for HEAD has REF_LOG_ONLY set by
split_head_update(), resulting in the deletion being logged.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'svn-escape-backslash' of git://bogomips... Junio C Hamano Tue, 21 Feb 2017 06:01:59 +0000 (22:01 -0800)

Merge branch 'svn-escape-backslash' of git://bogomips.org/git-svn

* 'svn-escape-backslash' of git://bogomips.org/git-svn:
git-svn: escape backslashes in refnames

l10n: sv.po: Update Swedish translation (3139t0f0u)Peter Krefting Mon, 20 Feb 2017 18:40:11 +0000 (19:40 +0100)

l10n: sv.po: Update Swedish translation (3139t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>

l10n: de.po: translate 241 messagesRalf Thielow Mon, 20 Feb 2017 17:40:36 +0000 (18:40 +0100)

l10n: de.po: translate 241 messages

Translate 241 messages came from git.pot update in 673bfad09
(l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)) and a4d94835a
(l10n: git.pot: v2.12.0 round 2 (2 new)).

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Acked-by: Phillip Sz <phillip.szelat@gmail.com>

stash: refactor stash_createThomas Gummerer Sun, 19 Feb 2017 11:03:10 +0000 (11:03 +0000)

stash: refactor stash_create

Refactor the internal stash_create function to use a -m flag for
specifying the message and -u flag to indicate whether untracked files
should be added to the stash.

This makes it easier to pass a pathspec argument to stash_create in the
next patch.

The user interface for git stash create stays the same.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: add test for the create command line argumentsThomas Gummerer Sun, 19 Feb 2017 11:03:09 +0000 (11:03 +0000)

stash: add test for the create command line arguments

Currently there is no test showing the expected behaviour of git stash
create's command line arguments. Add a test for that to show the
current expected behaviour and to make sure future refactorings don't
break those expectations.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: introduce push verbThomas Gummerer Sun, 19 Feb 2017 11:03:08 +0000 (11:03 +0000)

stash: introduce push verb

Introduce a new git stash push verb in addition to git stash save. The
push verb is used to transition from the current command line arguments
to a more conventional way, in which the message is given as an argument
to the -m option.

This allows us to have pathspecs at the end of the command line
arguments like other Git commands do, so that the user can say which
subset of paths to stash (and leave others behind).

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'ko/merge-l10n' of https://github.com... Jiang Xin Sun, 19 Feb 2017 14:08:05 +0000 (22:08 +0800)

Merge branch 'ko/merge-l10n' of https://github.com/changwoo/git-l10n-ko

* 'ko/merge-l10n' of https://github.com/changwoo/git-l10n-ko:
l10n: ko.po: Update Korean translation

Merge branch 'master' of https://github.com/vnwildman/gitJiang Xin Sun, 19 Feb 2017 14:04:41 +0000 (22:04 +0800)

Merge branch 'master' of https://github.com/vnwildman/git

* 'master' of https://github.com/vnwildman/git:
l10n: vi.po (3139t): Updated 2 new messages for rc1

l10n: ko.po: Update Korean translationChangwoo Ryu Sun, 19 Feb 2017 10:34:24 +0000 (19:34 +0900)

l10n: ko.po: Update Korean translation

Signed-off-by: Changwoo Ryu <cwryu@debian.org>

l10n: vi.po (3139t): Updated 2 new messages for rc1Tran Ngoc Quan Sat, 18 Feb 2017 00:18:54 +0000 (07:18 +0700)

l10n: vi.po (3139t): Updated 2 new messages for rc1

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>

init: document dotfiles exclusion on template copyGrégoire Paris Fri, 17 Feb 2017 23:37:00 +0000 (00:37 +0100)

init: document dotfiles exclusion on template copy

Not just . and .., but any path that begins with dot is not copied
when copying the template directory to a new repository. You can
customize the template directory, copying some dotfiles might make
sense, but it's actually a good thing not to, because you would not
want to have your git directory copied in every git directory that
is created should you decide to put your template directory under
version control, for example. Plus, it might be used as a feature
by people who would want to exclude some files.

Signed-off-by: Grégoire Paris <postmaster@greg0ire.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: fr.po: v2.12.0 round 2 3139tJean-Noel Avila Fri, 17 Feb 2017 23:10:04 +0000 (00:10 +0100)

l10n: fr.po: v2.12.0 round 2 3139t

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

tempfile: set errno to a known value before calling... Jeff King Fri, 17 Feb 2017 21:07:49 +0000 (16:07 -0500)

tempfile: set errno to a known value before calling ferror()

In close_tempfile(), we return an error if ferror()
indicated a previous failure, or if fclose() failed. In the
latter case, errno is set and it is useful for callers to
report it.

However, if _only_ ferror() triggers, then the value of
errno is based on whatever syscall happened to last fail,
which may not be related to our filehandle at all. A caller
cannot tell the difference between the two cases, and may
use "die_errno()" or similar to report a nonsense errno value.

One solution would be to actually pass back separate return
values for the two cases, so a caller can write a more
appropriate message for each case. But that makes the
interface clunky.

Instead, let's just set errno to the generic EIO in this case.
That's not as descriptive as we'd like, but at least it's
predictable. So it's better than the status quo in all cases
but one: when the last syscall really did involve a failure
on our filehandle, we'll be wiping that out. But that's a
fragile thing for us to rely on.

In any case, we'll let the errno result from fclose() take
precedence over our value, as we know that's recent and
accurate (and many I/O errors will persist through the
fclose anyway).

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

Git 2.12-rc2 v2.12.0-rc2Junio C Hamano Fri, 17 Feb 2017 22:00:19 +0000 (14:00 -0800)

Git 2.12-rc2

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

rev-parse: fix several options when running in a subdir... Johannes Schindelin Fri, 17 Feb 2017 16:59:06 +0000 (17:59 +0100)

rev-parse: fix several options when running in a subdirectory

In addition to making git_path() aware of certain file names that need
to be handled differently e.g. when running in worktrees, the commit
557bd833bb (git_path(): be aware of file relocation in $GIT_DIR,
2014-11-30) also snuck in a new option for `git rev-parse`:
`--git-path`.

On the face of it, there is no obvious bug in that commit's diff: it
faithfully calls git_path() on the argument and prints it out, i.e. `git
rev-parse --git-path <filename>` has the same precise behavior as
calling `git_path("<filename>")` in C.

The problem lies deeper, much deeper. In hindsight (which is always
unfair), implementing the .git/ directory discovery in
`setup_git_directory()` by changing the working directory may have
allowed us to avoid passing around a struct that contains information
about the current repository, but it bought us many, many problems.

In this case, when being called in a subdirectory, `git rev-parse`
changes the working directory to the top-level directory before calling
`git_path()`. In the new working directory, the result is correct. But
in the working directory of the calling script, it is incorrect.

Example: when calling `git rev-parse --git-path HEAD` in, say, the
Documentation/ subdirectory of Git's own source code, the string
`.git/HEAD` is printed.

Side note: that bug is hidden when running in a subdirectory of a
worktree that was added by the `git worktree` command: in that case, the
(correct) absolute path of the `HEAD` file is printed.

In the interest of time, this patch does not go the "correct" route to
introduce a struct with repository information (and removing global
state in the process), instead this patch chooses to detect when the
command was called in a subdirectory and forces the result to be an
absolute path.

While at it, we are also fixing the output of --git-common-dir and
--shared-index-path.

Lastly, please note that we reuse the same strbuf for all of the
relative_path() calls; this avoids frequent allocation (and duplicated
code), and it does not risk memory leaks, for two reasons: 1) the
cmd_rev_parse() function does not return anywhere between the use of
the new strbuf instance and its final release, and 2) git-rev-parse is
one of these "one-shot" programs in Git, i.e. it exits after running
for a very short time, meaning that all allocated memory is released
with the exit() call anyway.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rev-parse tests: add tests executed from a subdirectoryMichael Rappazzo Fri, 17 Feb 2017 16:59:02 +0000 (17:59 +0100)

rev-parse tests: add tests executed from a subdirectory

t2027-worktree-list has an incorrect expectation for --git-common-dir
which has been adjusted and marked to expect failure.

Some of the tests added have been marked to expect failure. These
demonstrate a problem with the way that some options to git rev-parse
behave when executed from a subdirectory of the main worktree.

[jes: fixed incorrect assumption that objects/ lives in the
worktree-specific git-dir (it lives in the common dir instead). Also
adjusted t1700 so that the test case does not *need* to be the last
one in that script.]

Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: git.pot: v2.12.0 round 2 (2 new)Jiang Xin Fri, 17 Feb 2017 17:00:54 +0000 (01:00 +0800)

l10n: git.pot: v2.12.0 round 2 (2 new)

Generate po/git.pot from v2.12.0-rc1 for git v2.12.0 l10n round 2.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>

Merge branch 'master' of git://github.com/git-l10n... Jiang Xin Fri, 17 Feb 2017 16:59:51 +0000 (00:59 +0800)

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

* 'master' of git://github.com/git-l10n/git-po:
l10n: vi.po: Updated Vietnamese translation (3137t)
l10n: update Catalan translation
l10n: sv.po: Update Swedish translation (3137t0f0u)
l10n: fr.po: v2.11-rc0 first round
l10n: ko.po: Update Korean translation
l10n: fr.po: Fix a typo in the French translation
l10n: fr.po: Remove gender specific adjectives
l10n: fr.po: Fix typos
l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)
l10n: bg: Updated Bulgarian translation (2913t+0f+0u)
l10n: fixes to Catalan translation
l10n: zh_CN: review for git v2.11.0 l10n
l10n: New Catalan translation maintainer

Merge branch 'master' of https://github.com/vnwildman/gitJiang Xin Fri, 17 Feb 2017 16:54:49 +0000 (00:54 +0800)

Merge branch 'master' of https://github.com/vnwildman/git

* 'master' of https://github.com/vnwildman/git:
l10n: vi.po: Updated Vietnamese translation (3137t)

Merge branch 'master' of https://github.com/Softcatala... Jiang Xin Fri, 17 Feb 2017 16:49:06 +0000 (00:49 +0800)

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

* 'master' of https://github.com/Softcatala/git-po:
l10n: update Catalan translation

l10n: vi.po: Updated Vietnamese translation (3137t)Tran Ngoc Quan Fri, 17 Feb 2017 06:51:34 +0000 (13:51 +0700)

l10n: vi.po: Updated Vietnamese translation (3137t)

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>

Hopefully the final batch of mini-topics before the... Junio C Hamano Thu, 16 Feb 2017 22:46:35 +0000 (14:46 -0800)

Hopefully the final batch of mini-topics before the final

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

Merge branch 'jk/tempfile-ferror-fclose-confusion'Junio C Hamano Thu, 16 Feb 2017 22:45:15 +0000 (14:45 -0800)

Merge branch 'jk/tempfile-ferror-fclose-confusion'

Code clean-up.

* jk/tempfile-ferror-fclose-confusion:
tempfile: avoid "ferror | fclose" trick

Merge branch 'dp/submodule-doc-markup-fix'Junio C Hamano Thu, 16 Feb 2017 22:45:15 +0000 (14:45 -0800)

Merge branch 'dp/submodule-doc-markup-fix'

Doc fix.

* dp/submodule-doc-markup-fix:
config.txt: fix formatting of submodule.alternateErrorStrategy section

Merge branch 'jk/reset-to-break-a-commit-doc-updated'Junio C Hamano Thu, 16 Feb 2017 22:45:14 +0000 (14:45 -0800)

Merge branch 'jk/reset-to-break-a-commit-doc-updated'

Doc update.

* jk/reset-to-break-a-commit-doc-updated:
reset: add an example of how to split a commit into two

Merge branch 'jk/reset-to-break-a-commit-doc'Junio C Hamano Thu, 16 Feb 2017 22:45:14 +0000 (14:45 -0800)

Merge branch 'jk/reset-to-break-a-commit-doc'

Doc update.

* jk/reset-to-break-a-commit-doc:
Revert "reset: add an example of how to split a commit into two"

Merge branch 'js/mingw-isatty'Junio C Hamano Thu, 16 Feb 2017 22:45:13 +0000 (14:45 -0800)

Merge branch 'js/mingw-isatty'

A hotfix for a topic already in 'master'.

* js/mingw-isatty:
mingw: make stderr unbuffered again

Merge branch 'rs/strbuf-cleanup-in-rmdir-recursively'Junio C Hamano Thu, 16 Feb 2017 22:45:13 +0000 (14:45 -0800)

Merge branch 'rs/strbuf-cleanup-in-rmdir-recursively'

Code clean-up.

* rs/strbuf-cleanup-in-rmdir-recursively:
rm: reuse strbuf for all remove_dir_recursively() calls, again

Merge branch 'rs/ls-files-partial-optim'Junio C Hamano Thu, 16 Feb 2017 22:45:13 +0000 (14:45 -0800)

Merge branch 'rs/ls-files-partial-optim'

"ls-files" run with pathspec has been micro-optimized to avoid
having to memmove(3) unnecessary bytes.

* rs/ls-files-partial-optim:
ls-files: move only kept cache entries in prune_cache()
ls-files: pass prefix length explicitly to prune_cache()

Merge branch 'rs/cocci-check-free-only-null'Junio C Hamano Thu, 16 Feb 2017 22:45:13 +0000 (14:45 -0800)

Merge branch 'rs/cocci-check-free-only-null'

A new coccinelle rule that catches a check of !pointer before the
pointer is free(3)d, which most likely is a bug.

* rs/cocci-check-free-only-null:
cocci: detect useless free(3) calls

Merge branch 'ls/p4-path-encoding'Junio C Hamano Thu, 16 Feb 2017 22:45:12 +0000 (14:45 -0800)

Merge branch 'ls/p4-path-encoding'

When "git p4" imports changelist that removes paths, it failed to
convert pathnames when the p4 used encoding different from the one
used on the Git side. This has been corrected.

* ls/p4-path-encoding:
git-p4: fix git-p4.pathEncoding for removed files

tempfile: avoid "ferror | fclose" trickJeff King Thu, 16 Feb 2017 21:31:40 +0000 (16:31 -0500)

tempfile: avoid "ferror | fclose" trick

The current code wants to record an error condition from
either ferror() or fclose(), but makes sure that we always
call both functions. So it can't use logical-OR "||", which
would short-circuit when ferror() is true. Instead, it uses
bitwise-OR "|" to evaluate both functions and set one or
more bits in the "err" flag if they reported a failure.

Unlike logical-OR, though, bitwise-OR does not introduce a
sequence point, and the order of evaluation for its operands
is unspecified. So a compiler would be free to generate code
which calls fclose() first, and then ferror() on the
now-freed filehandle.

There's no indication that this has happened in practice,
but let's write it out in a way that follows the standard.

Noticed-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config.txt: fix formatting of submodule.alternateErrorS... David Pursehouse Thu, 16 Feb 2017 05:05:35 +0000 (14:05 +0900)

config.txt: fix formatting of submodule.alternateErrorStrategy section

Add missing `::` after the title.

Signed-off-by: David Pursehouse <dpursehouse@collab.net>
Acked-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

clean: use warning_errno() when appropriateNguyễn Thái Ngọc Duy Tue, 14 Feb 2017 09:54:49 +0000 (16:54 +0700)

clean: use warning_errno() when appropriate

All these warning() calls are preceded by a system call. Report the
actual error to help the user understand why we fail to remove
something.

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

reset: add an example of how to split a commit into twoJacob Keller Thu, 16 Feb 2017 00:22:12 +0000 (16:22 -0800)

reset: add an example of how to split a commit into two

It is often useful to break a commit into multiple parts that are more
logical separations. This can be tricky to learn how to do without the
brute-force method if re-writing code or commit messages from scratch.

Add a section to the git-reset documentation which shows an example
process for how to use git add -p and git commit -c HEAD@{1} to
interactively break a commit apart and re-use the original commit
message as a starting point when making the new commit message.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Revert "reset: add an example of how to split a commit... Junio C Hamano Thu, 16 Feb 2017 21:35:50 +0000 (13:35 -0800)

Revert "reset: add an example of how to split a commit into two"

This reverts commit 7326451bedaa67d29afe02184b166e28d9393c91; a
better rewrite will be queued separately.

bisect_next_all: convert xsnprintf to xstrfmtMaxim Moseychuk Thu, 16 Feb 2017 17:07:12 +0000 (20:07 +0300)

bisect_next_all: convert xsnprintf to xstrfmt

Git can't run bisect between 2048+ commits if use russian
translation, because the translated string is too long for the fixed
buffer it uses (this can be reproduced "LANG=ru_RU.UTF8 git bisect
start v4.9 v4.8" on linux sources).

Use xstrfmt() to format the message string to sufficiently sized
buffer instead to fix this.

Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stop_progress_msg: convert xsnprintf to xstrfmtMaxim Moseychuk Thu, 16 Feb 2017 17:07:13 +0000 (20:07 +0300)

stop_progress_msg: convert xsnprintf to xstrfmt

Simplify code by replacing buffer allocation with a call to xstrfmt().

Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: update Catalan translationJordi Mas Thu, 16 Feb 2017 04:10:04 +0000 (05:10 +0100)

l10n: update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>

A bit more for -rc2Junio C Hamano Wed, 15 Feb 2017 22:58:25 +0000 (14:58 -0800)

A bit more for -rc2

Merge branch 'tg/stash-doc-cleanup'Junio C Hamano Wed, 15 Feb 2017 22:56:41 +0000 (14:56 -0800)

Merge branch 'tg/stash-doc-cleanup'

The documentation explained what "git stash" does to the working
tree (after stashing away the local changes) in terms of "reset
--hard", which was exposing an unnecessary implementation detail.

* tg/stash-doc-cleanup:
Documentation/stash: remove mention of git reset --hard

Merge branch 'jk/doc-submodule-markup-fix'Junio C Hamano Wed, 15 Feb 2017 22:56:40 +0000 (14:56 -0800)

Merge branch 'jk/doc-submodule-markup-fix'

Doc markup fix.

* jk/doc-submodule-markup-fix:
docs/git-submodule: fix unbalanced quote

Merge branch 'jk/doc-remote-helpers-markup-fix'Junio C Hamano Wed, 15 Feb 2017 22:56:40 +0000 (14:56 -0800)

Merge branch 'jk/doc-remote-helpers-markup-fix'

Doc markup fix.

* jk/doc-remote-helpers-markup-fix:
docs/gitremote-helpers: fix unbalanced quotes

show-branch: use skip_prefix to drop magic numbersJeff King Wed, 15 Feb 2017 21:40:52 +0000 (16:40 -0500)

show-branch: use skip_prefix to drop magic numbers

We make several starts_with() calls, only to advance
pointers. This is exactly what skip_prefix() is for, which
lets us avoid manually-counted magic numbers.

Helped-by: Pranit Bauva <pranit.bauva@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'sb/doc-unify-bottom'Junio C Hamano Wed, 15 Feb 2017 20:54:20 +0000 (12:54 -0800)

Merge branch 'sb/doc-unify-bottom'

Doc clean-up.

* sb/doc-unify-bottom:
Documentation: unify bottom "part of git suite" lines

Merge branch 'sb/push-options-via-transport'Junio C Hamano Wed, 15 Feb 2017 20:54:19 +0000 (12:54 -0800)

Merge branch 'sb/push-options-via-transport'

The push-options given via the "--push-options" option were not
passed through to external remote helpers such as "smart HTTP" that
are invoked via the transport helper.

* sb/push-options-via-transport:
push options: pass push options to the transport helper

Merge branch 'cw/completion'Junio C Hamano Wed, 15 Feb 2017 20:54:19 +0000 (12:54 -0800)

Merge branch 'cw/completion'

More command line completion (in contrib/) for recent additions.

* cw/completion:
completion: recognize more long-options
completion: teach remote subcommands to complete options
completion: teach replace to complete options
completion: teach ls-remote to complete options
completion: improve bash completion for git-add
completion: add subcommand completion for rerere
completion: teach submodule subcommands to complete options

Merge branch 'rs/swap'Junio C Hamano Wed, 15 Feb 2017 20:54:19 +0000 (12:54 -0800)

Merge branch 'rs/swap'

Code clean-up.

* rs/swap:
graph: use SWAP macro
diff: use SWAP macro
use SWAP macro
apply: use SWAP macro
add SWAP macro

Merge branch 'sb/submodule-doc'Junio C Hamano Wed, 15 Feb 2017 20:54:18 +0000 (12:54 -0800)

Merge branch 'sb/submodule-doc'

Doc updates.

* sb/submodule-doc:
submodule update documentation: don't repeat ourselves
submodule documentation: add options to the subcommand

grep: treat revs the same for --untracked as for -... Jeff King Tue, 14 Feb 2017 21:54:36 +0000 (16:54 -0500)

grep: treat revs the same for --untracked as for --no-index

git-grep has always disallowed grepping in a tree (as
opposed to the working directory) with both --untracked
and --no-index. But we traditionally did so by first
collecting the revs, and then complaining when any were
provided.

The --no-index option recently learned to detect revs
much earlier. This has two user-visible effects:

- we don't bother to resolve revision names at all. So
when there's a rev/path ambiguity, we always choose to
treat it as a path.

- likewise, when you do specify a revision without "--",
the error you get is "no such path" and not "--untracked
cannot be used with revs".

The rationale for doing this with --no-index is that it is
meant to be used outside a repository, and so parsing revs
at all does not make sense.

This patch gives --untracked the same treatment. While it
_is_ meant to be used in a repository, it is explicitly
about grepping the non-repository contents. Telling the user
"we found a rev, but you are not allowed to use revs" is
not really helpful compared to "we treated your argument as
a path, and could not find it".

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

remote helpers: avoid blind fall-back to ".git" when... Jonathan Nieder Tue, 14 Feb 2017 20:36:19 +0000 (15:36 -0500)

remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR

To push from or fetch to the current repository, remote helpers need
to know what repository that is. Accordingly, Git sets the GIT_DIR
environment variable to the path to the current repository when
invoking remote helpers.

There is a special case it does not handle: "git ls-remote" and "git
archive --remote" can be run to inspect a remote repository without
being run from any local repository. GIT_DIR is not useful in this
scenario:

- if we are not in a repository, we don't need to set GIT_DIR to
override an existing GIT_DIR value from the environment. If GIT_DIR
is present then we would be in a repository if it were valid and
would have called die() if it weren't.

- not setting GIT_DIR may cause a helper to do the usual discovery
walk to find the repository. But we know we're not in one, or we
would have found it ourselves. So in the worst case it may expend
a little extra effort to try to find a repository and fail (for
example, remote-curl would do this to try to find repository-level
configuration).

So leave GIT_DIR unset in this case. This makes GIT_DIR easier to
understand for remote helper authors and makes transport code less of
a special case for repository discovery.

Noticed using b1ef400e (setup_git_env: avoid blind fall-back to
".git", 2016-10-20) from 'next':

$ cd /tmp
$ git ls-remote https://kernel.googlesource.com/pub/scm/git/git
fatal: BUG: setup_git_env called without repository

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote: avoid reading $GIT_DIR config in non-repoJeff King Tue, 14 Feb 2017 20:33:28 +0000 (15:33 -0500)

remote: avoid reading $GIT_DIR config in non-repo

The "git ls-remote" command can be run outside of a
repository, but needs to look up configured remotes. The
config code is smart enough to handle this case itself, but
we also check the historical "branches" and "remotes" paths
in $GIT_DIR. The git_path() function causes us to blindly
look at ".git/remotes", even if we know we aren't in a git
repository.

For now, this is just an unlikely bug (you probably don't
have such a file if you're not in a repository), but it will
become more obvious once we merge b1ef400ee (setup_git_env:
avoid blind fall-back to ".git", 2016-10-20):

[now]
$ git ls-remote
fatal: No remote configured to list refs from.

[with b1ef400ee]
$ git ls-remote
fatal: BUG: setup_git_env called without repository

We can fix this by skipping these sources entirely when
we're outside of a repository.

The test is a little more complex than the demonstration
above. Rather than detect the correct behavior by parsing
the error message, we can actually set up a case where the
remote name we give is a valid repository, but b1ef400ee
would cause us to die in the configuration step.

This test doesn't fail now, but it future-proofs us for the
b1ef400ee change.

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

show-branch: store resolved head in heap bufferJeff King Tue, 14 Feb 2017 17:27:45 +0000 (12:27 -0500)

show-branch: store resolved head in heap buffer

We resolve HEAD and copy the result to a fixed-size buffer
with memcpy, never checking that it actually fits. This bug
dates back to 8098a178b (Add git-symbolic-ref, 2005-09-30).
Before that we used readlink(), which took a maximum buffer
size.

We can fix this by using resolve_refdup(), which duplicates
the buffer on the heap. That also lets us just check
for a NULL pointer to see if we have resolved HEAD, and
drop the extra head_p variable.

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

show-branch: drop head_len variableJeff King Tue, 14 Feb 2017 17:26:01 +0000 (12:26 -0500)

show-branch: drop head_len variable

We copy the result of resolving HEAD into a buffer and keep
track of its length. But we never actually use the length
for anything besides the copy. Let's stop passing it around.

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

grep: do not diagnose misspelt revs with --no-indexJeff King Tue, 14 Feb 2017 06:08:09 +0000 (01:08 -0500)

grep: do not diagnose misspelt revs with --no-index

If we are using --no-index, then our arguments cannot be
revs in the first place. Not only is it pointless to
diagnose them, but if we are not in a repository, we should
not be trying to resolve any names.

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

grep: avoid resolving revision names in --no-index... Jeff King Tue, 14 Feb 2017 06:07:29 +0000 (01:07 -0500)

grep: avoid resolving revision names in --no-index case

We disallow the use of revisions with --no-index, but we
don't actually check and complain until well after we've
parsed the revisions.

This is the cause of a few problems:

1. We shouldn't be calling get_sha1() at all when we aren't
in a repository, as it might access the ref or object
databases. For now, this should generally just return
failure, but eventually it will become a BUG().

2. When there's a "--" disambiguator and you're outside a
repository, we'll complain early with "unable to resolve
revision". But we can give a much more specific error.

3. When there isn't a "--" disambiguator, we still do the
normal rev/path checks. This is silly, as we know we
cannot have any revs with --no-index. Everything we see
must be a path.

Outside of a repository this doesn't matter (since we
know it won't resolve), but inside one, we may complain
unnecessarily if a filename happens to also match a
refname.

This patch skips the get_sha1() call entirely in the
no-index case, and behaves as if it failed (with the
exception of giving a better error message).

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

grep: fix "--" rev/pathspec disambiguationJeff King Tue, 14 Feb 2017 06:05:55 +0000 (01:05 -0500)

grep: fix "--" rev/pathspec disambiguation

If we see "git grep pattern rev -- file" then we apply the
usual rev/pathspec disambiguation rules: any "rev" before
the "--" must be a revision, and we do not need to apply the
verify_non_filename() check.

But there are two bugs here:

1. We keep a seen_dashdash flag to handle this case, but
we set it in the same left-to-right pass over the
arguments in which we parse "rev".

So when we see "rev", we do not yet know that there is
a "--", and we mistakenly complain if there is a
matching file.

We can fix this by making a preliminary pass over the
arguments to find the "--", and only then checking the rev
arguments.

2. If we can't resolve "rev" but there isn't a dashdash,
that's OK. We treat it like a path, and complain later
if it doesn't exist.

But if there _is_ a dashdash, then we know it must be a
rev, and should treat it as such, complaining if it
does not resolve. The current code instead ignores it
and tries to treat it like a path.

This patch fixes both bugs, and tries to comment the parsing
flow a bit better.

It adds tests that cover the two bugs, but also some related
situations (which already worked, but this confirms that our
fixes did not break anything).

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

grep: re-order rev-parsing loopJeff King Tue, 14 Feb 2017 06:04:17 +0000 (01:04 -0500)

grep: re-order rev-parsing loop

We loop over the arguments, but every branch of the loop
hits either a "continue" or a "break". Surely we can make
this simpler.

The final conditional is:

if (arg is a rev) {
... handle rev ...
continue;
}
break;

We can rewrite this as:

if (arg is not a rev)
break;

... handle rev ...

That makes the flow a little bit simpler, and will make
things much easier to follow when we add more logic in
future patches.

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

grep: do not unnecessarily query repo for "--"Jonathan Tan Tue, 14 Feb 2017 06:03:03 +0000 (01:03 -0500)

grep: do not unnecessarily query repo for "--"

When running a command of the form

git grep --no-index pattern -- path

in the absence of a Git repository, an error message will be printed:

fatal: BUG: setup_git_env called without repository

This is because "git grep" tries to interpret "--" as a rev. "git grep"
has always tried to first interpret "--" as a rev for at least a few
years, but this issue was upgraded from a pessimization to a bug in
commit 59332d1 ("Resurrect "git grep --no-index"", 2010-02-06), which
calls get_sha1 regardless of whether --no-index was specified. This bug
appeared to be benign until commit b1ef400 ("setup_git_env: avoid blind
fall-back to ".git"", 2016-10-20) when Git was taught to die in this
situation. (This "git grep" bug appears to be one of the bugs that
commit b1ef400 is meant to flush out.)

Therefore, always interpret "--" as signaling the end of options,
instead of trying to interpret it as a rev first.

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

grep: move thread initialization a little lowerJeff King Tue, 14 Feb 2017 06:02:38 +0000 (01:02 -0500)

grep: move thread initialization a little lower

Originally, we set up the threads for grep before parsing
the non-option arguments. In 53b8d931b (grep: disable
threading in non-worktree case, 2011-12-12), the thread code
got bumped lower in the function because it now needed to
know whether we got any revision arguments.

That put a big block of code in between the parsing of revs
and the parsing of pathspecs, both of which share some loop
variables. That makes it harder to read the code than the
original, where the shared loops were right next to each
other.

Let's bump the thread initialization until after all of the
parsing is done.

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

mingw: make stderr unbuffered againJohannes Schindelin Mon, 13 Feb 2017 22:34:06 +0000 (23:34 +0100)

mingw: make stderr unbuffered again

When removing the hack for isatty(), we actually removed more than just
an isatty() hack: we removed the hack where internal data structures of
the MSVC runtime are modified in order to redirect stdout/stderr.

Instead of using that hack (that does not work with newer versions of
the runtime, anyway), we replaced it by reopening the respective file
descriptors.

What we forgot was to mark stderr as unbuffered again.

Reported by Hannes Sixt. Fixed with Jeff Hostetler's assistance.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Tested-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gc: ignore old gc.log filesDavid Turner Fri, 10 Feb 2017 21:28:22 +0000 (16:28 -0500)

gc: ignore old gc.log files

A server can end up in a state where there are lots of unreferenced
loose objects (say, because many users are doing a bunch of rebasing
and pushing their rebased branches). Running "git gc --auto" in
this state would cause a gc.log file to be created, preventing
future auto gcs, causing pack files to pile up. Since many git
operations are O(n) in the number of pack files, this would lead to
poor performance.

Git should never get itself into a state where it refuses to do any
maintenance, just because at some point some piece of the maintenance
didn't make progress.

Teach Git to ignore gc.log files which are older than (by default)
one day old, which can be tweaked via the gc.logExpiry configuration
variable. That way, these pack files will get cleaned up, if
necessary, at least once per day. And operators who find a need for
more-frequent gcs can adjust gc.logExpiry to meet their needs.

There is also some cleanup: a successful manual gc, or a
warning-free auto gc with an old log file, will remove any old
gc.log files.

It might still happen that manual intervention is required
(e.g. because the repo is corrupt), but at the very least it won't
be because Git is too dumb to try again.

Signed-off-by: David Turner <dturner@twosigma.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

read_loose_refs(): read refs using resolve_ref_recursiv... Michael Haggerty Thu, 9 Feb 2017 20:53:52 +0000 (21:53 +0100)

read_loose_refs(): read refs using resolve_ref_recursively()

There is no need to call read_ref_full() or resolve_gitlink_ref() from
read_loose_refs(), because we already have a ref_store object in hand.
So we can call resolve_ref_recursively() ourselves. Happily, this
unifies the code for the submodule vs. non-submodule cases.

This requires resolve_ref_recursively() to be exposed to the refs
subsystem, though not to non-refs code.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rm: reuse strbuf for all remove_dir_recursively() calls... René Scharfe Sat, 11 Feb 2017 19:51:08 +0000 (20:51 +0100)

rm: reuse strbuf for all remove_dir_recursively() calls, again

Don't throw the memory allocated for remove_dir_recursively() away after
a single call, use it for the other entries as well instead.

This change was done before in deb8e15a (rm: reuse strbuf for all
remove_dir_recursively() calls), but was reverted as a side-effect of
55856a35 (rm: absorb a submodules git dir before deletion). Reinstate
the optimization.

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

Documentation/stash: remove mention of git reset -... Thomas Gummerer Sun, 12 Feb 2017 21:54:14 +0000 (21:54 +0000)

Documentation/stash: remove mention of git reset --hard

Don't mention git reset --hard in the documentation for git stash save.
It's an implementation detail that doesn't matter to the end user and
thus shouldn't be exposed to them. In addition it's not quite true for
git stash -p, and will not be true when a filename argument to limit the
stash to a few files is introduced.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

docs/git-submodule: fix unbalanced quoteJeff King Mon, 13 Feb 2017 21:05:49 +0000 (16:05 -0500)

docs/git-submodule: fix unbalanced quote

The documentation gives an example of the submodule foreach
command that uses both backticks and single-quotes. We stick
the whole thing inside "+" markers to make it monospace, but
the inside punctuation still needs escaping. We handle the
backticks with "{backtick}", and use backslash-escaping for
the single-quotes.

But we missed the escaping on the second quote. Fortunately,
asciidoc renders this unbalanced quote as we want (showing
the quote), but asciidoctor does not. We could fix it by
adding the missing backslash.

However, let's take a step back. Even when rendered
correctly, it's hard to read a long command stuck into the
middle of a paragraph, and the important punctuation is hard
to notice. Let's instead bump it into its own single-line
code block. That makes both the source and the rendered
result more readable, and as a bonus we don't have to worry
about quoting at all.

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

docs/gitremote-helpers: fix unbalanced quotesJeff King Mon, 13 Feb 2017 20:38:35 +0000 (15:38 -0500)

docs/gitremote-helpers: fix unbalanced quotes

Each of these options is missing the closing single-quote on
the option name. This understandably confuses asciidoc,
which ends up rendering a stray quote, like:

option cloning {'true|false}

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

completion: restore removed line continuating backslashSZEDER Gábor Mon, 13 Feb 2017 19:20:36 +0000 (20:20 +0100)

completion: restore removed line continuating backslash

Recent commit 1cd23e9e0 (completion: don't use __gitdir() for git
commands, 2017-02-03) rewrapped a couple of long lines, and while
doing so it inadvertently removed a '\' from the end of a line, thus
breaking completion for 'git config remote.name.push <TAB>'.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: move only kept cache entries in prune_cache()René Scharfe Fri, 10 Feb 2017 20:03:30 +0000 (21:03 +0100)

ls-files: move only kept cache entries in prune_cache()

prune_cache() first identifies those entries at the start of the sorted
array that can be discarded. Then it moves the rest of the entries up.
Last it identifies the unwanted trailing entries among the moved ones
and cuts them off.

Change the order: Identify both start *and* end of the range to keep
first and then move only those entries to the top. The resulting code
is slightly shorter and a bit more efficient.

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

ls-files: pass prefix length explicitly to prune_cache()René Scharfe Fri, 10 Feb 2017 19:42:28 +0000 (20:42 +0100)

ls-files: pass prefix length explicitly to prune_cache()

The function prune_cache() relies on the fact that it is only called on
max_prefix and sneakily uses the matching global variable max_prefix_len
directly. Tighten its interface by passing both the string and its
length as parameters. While at it move the NULL check into the function
to collect all cache-pruning related logic in one place.

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

Merge branch 'master' of git://github.com/nafmo/git... Jiang Xin Mon, 13 Feb 2017 16:19:11 +0000 (00:19 +0800)

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

* 'master' of git://github.com/nafmo/git-l10n-sv:
l10n: sv.po: Update Swedish translation (3137t0f0u)

Merge branch 'fr_v2.11.0_rnd1' of git://github.com... Jiang Xin Mon, 13 Feb 2017 16:17:21 +0000 (00:17 +0800)

Merge branch 'fr_v2.11.0_rnd1' of git://github.com/jnavila/git

* 'fr_v2.11.0_rnd1' of git://github.com/jnavila/git:
l10n: fr.po: v2.11-rc0 first round
l10n: fr.po: Fix a typo in the French translation
l10n: fr.po: Remove gender specific adjectives
l10n: fr.po: Fix typos

cocci: detect useless free(3) callsRené Scharfe Sat, 11 Feb 2017 13:58:44 +0000 (14:58 +0100)

cocci: detect useless free(3) calls

Add a semantic patch for removing checks that cause free(3) to only be
called with a NULL pointer, as that must be a programming mistake.

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