gitweb.git
convert: rename reusable sub-process functionsBen Peart Fri, 5 May 2017 15:28:00 +0000 (11:28 -0400)

convert: rename reusable sub-process functions

Do a mechanical rename of the functions that will become the reusable
sub-process module.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: update generic functions to only use generic... Ben Peart Fri, 5 May 2017 15:27:59 +0000 (11:27 -0400)

convert: update generic functions to only use generic data structures

Update all functions that are going to be moved into a reusable module
so that they only work with the reusable data structures. Move code
that is specific to the filter out into the filter specific functions.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: separate generic structures and variables... Ben Peart Fri, 5 May 2017 15:27:58 +0000 (11:27 -0400)

convert: separate generic structures and variables from the filter specific ones

To enable future reuse of the filter.<driver>.process infrastructure,
split the cmd2process structure into two separate parts.

subprocess_entry will now contain the generic data required to manage
the creation and tracking of the child process in a hashmap.

cmd2process is a filter protocol specific structure that is used to
track the negotiated capabilities of the filter.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

convert: split start_multi_file_filter() into two separ... Ben Peart Fri, 5 May 2017 15:27:57 +0000 (11:27 -0400)

convert: split start_multi_file_filter() into two separate functions

To enable future reuse of the filter.<driver>.process infrastructure,
split start_multi_file_filter() into two separate parts.

start_multi_file_filter() will now only contain the generic logic to
manage the creation and tracking of the child process in a hashmap.

start_multi_file_filter_fn() is a protocol specific initialization
function that will negotiate the multi-file-filter interface version
and capabilities.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pkt-line: annotate packet_writel with LAST_ARG_MUST_BE_NULLJeff King Sat, 13 May 2017 09:04:58 +0000 (05:04 -0400)

pkt-line: annotate packet_writel with LAST_ARG_MUST_BE_NULL

packet_writel() takes a variable-sized list and reads to
the first NULL. Let's let the compiler know so that it can
help us catch mistakes in the callers.

This should have been annotated similarly when it was a
static function, but it's doubly important now that the
function is available to the whole code-base.

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

usage.c: drop set_error_handle()Jeff King Sat, 13 May 2017 03:48:18 +0000 (23:48 -0400)

usage.c: drop set_error_handle()

The set_error_handle() function was introduced by 3b331e926
(vreportf: report to arbitrary filehandles, 2015-08-11) so
that run-command could send post-fork, pre-exec errors to
the parent's original stderr.

That use went away in 79319b194 (run-command: eliminate
calls to error handling functions in child, 2017-04-19),
which pushes all of the error reporting to the parent.
This leaves no callers of set_error_handle(). As we're not
likely to add any new ones, let's drop it.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

builtin/log: honor log.decoratebrian m. carlson Sun, 14 May 2017 18:00:58 +0000 (18:00 +0000)

builtin/log: honor log.decorate

The recent change that introduced autodecorating of refs accidentally
broke the ability of users to set log.decorate = false to override it.
When the git_log_config was traversed a second time with an option other
than log.decorate, the decoration style would be set to the automatic
style, even if the user had already overridden it. Instead of setting
the option in config parsing, set it in init_log_defaults instead.

Add a test for this case. The actual additional config option doesn't
matter, but it needs to be something not already set in the
configuration file.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Acked-by: Alex Henrie <alexhenrie24@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

config: complain about --local outside of a git repoJeff King Sat, 13 May 2017 03:29:31 +0000 (23:29 -0400)

config: complain about --local outside of a git repo

The "--local" option instructs git-config to read or modify
the repository-level config. This doesn't make any sense if
you're not actually in a repository.

Older versions of Git would blindly try to read or write
".git/config". For reading, this would result in a quiet
failure, since there was no config to read (and thus no
matching config value). Writing would generally fail
noisily, since ".git" was unlikely to exist. But since
b1ef400ee (setup_git_env: avoid blind fall-back to ".git",
2016-10-20), we catch this in the call to git_pathdup() and
die with an assertion.

Dying is the right thing to do, but we should catch the
problem early and give a more human-friendly error message.

Note that even without --local, git-config will sometimes
default to using local repository config (e.g., when
writing). These cases are already protected by similar
checks, and covered by a test in t1308.

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

setup_git_env: convert die("BUG") to BUG()Jeff King Sat, 13 May 2017 03:29:18 +0000 (23:29 -0400)

setup_git_env: convert die("BUG") to BUG()

Converting to BUG() makes it easier to detect and debug
cases where we hit this assertion. Coupled with a new test
in t1300, this shows that the test suite can detect such
corner cases.

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

usage.c: add BUG() functionJeff King Sat, 13 May 2017 03:28:50 +0000 (23:28 -0400)

usage.c: add BUG() function

There's a convention in Git's code base to write assertions
as:

if (...some_bad_thing...)
die("BUG: the terrible thing happened");

with the idea that users should never see a "BUG:" message
(but if they, it at least gives a clue what happened). We
use die() here because it's convenient, but there are a few
draw-backs:

1. Without parsing the messages, it's hard for callers to
distinguish BUG assertions from regular errors.

For instance, it would be nice if the test suite could
check that we don't hit any assertions, but
test_must_fail will pass BUG deaths as OK.

2. It would be useful to add more debugging features to
BUG assertions, like file/line numbers or dumping core.

3. The die() handler can be replaced, and might not
actually exit the whole program (e.g., it may just
pthread_exit()). This is convenient for normal errors,
but for an assertion failure (which is supposed to
never happen), we're probably better off taking down
the whole process as quickly and cleanly as possible.

We could address these by checking in die() whether the
error message starts with "BUG", and behaving appropriately.
But there's little advantage at that point to sharing the
die() code, and only downsides (e.g., we can't change the
BUG() interface independently). Moreover, converting all of
the existing BUG calls reveals that the test suite does
indeed trigger a few of them.

Instead, this patch introduces a new BUG() function, which
prints an error before dying via SIGABRT. This gives us test
suite checking and core dumps. The function is actually a
macro (when supported) so that we can show the file/line
number.

We can convert die("BUG") invocations to BUG() in further
patches, dealing with any test fallouts individually.

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

git-filter-branch: be more direct in an error messageJean-Noel Avila Thu, 11 May 2017 12:06:34 +0000 (14:06 +0200)

git-filter-branch: be more direct in an error message

git-filter-branch requires the specification of a branch by one way or
another. If no branch appears to have been specified, we know the user
got the usage wrong but we don't know what they were trying to do ---
e.g. maybe they specified the ref to rewrite but in the wrong place.

In this case, just state that the branch specification is missing.

Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

read-tree -m: make error message for merging 0 trees... Jean-Noel Avila Thu, 11 May 2017 12:06:33 +0000 (14:06 +0200)

read-tree -m: make error message for merging 0 trees less smart aleck

"git read-tree -m" requires a tree argument to name the tree to be
merged in. Git uses a cutesy error message to say so and why:

$ git read-tree -m
warning: read-tree: emptying the index with no arguments is
deprecated; use --empty
fatal: just how do you expect me to merge 0 trees?
$ git read-tree -m --empty
fatal: just how do you expect me to merge 0 trees?

When lucky, that could produce an ah-hah moment for the user, but it's
more likely to irritate and distract them.

Instead, tell the user plainly that the tree argument is
required. Also document this requirement in the git-read-tree(1)
manpage where there is room to explain it in a more straightforward way.

Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

usability: don't ask questions if no reply is requiredJean-Noel Avila Thu, 11 May 2017 12:06:32 +0000 (14:06 +0200)

usability: don't ask questions if no reply is required

There has been a bug report by a corporate user that stated that
"spelling mistake of stash followed by a yes prints character 'y'
infinite times."

This analysis was false. When the spelling of a command contains
errors, the git program tries to help the user by providing candidates
which are close to the unexisting command. E.g Git prints the
following:

git: 'stahs' is not a git command. See 'git --help'.
Did you mean this?

stash

and then exits.

The problem with this hint is that it is not formally indicated as an
hint and the user is in fact encouraged to reply to the question,
whereas the Git command is already finished.

The user was unlucky enough that it was the command he was looking
for, and replied "yes" on the command line, effectively launching the
`yes` program.

The initial error is that the Git programs, when launched in
command-line mode (without interaction) must not ask questions,
because these questions would normally require a user input as a reply
that they won't handle indeed. That's a source of confusion on UX
level.

To improve the general usability of the Git suite, the following rule
was applied:

if the sentence
* appears in a non-interactive session
* is printed last before exit
* is a question addressing the user ("you")

the sentence is turned into affirmative and proposes the option.

The basic rewording of the question sentences has been extended to
other spots found in the source.

Requested at https://github.com/git/git-scm.com/issues/999 by rpai1

Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pathspec: convert find_pathspecs_matching_against_index... Brandon Williams Thu, 11 May 2017 22:04:27 +0000 (15:04 -0700)

pathspec: convert find_pathspecs_matching_against_index to take an index

Convert find_pathspecs_matching_against_index to take an index
parameter.

In addition mark pathspec.c with NO_THE_INDEX_COMPATIBILITY_MACROS now
that it doesn't use any cache macros or reference 'the_index'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAPBrandon Williams Thu, 11 May 2017 22:04:26 +0000 (15:04 -0700)

pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP

Since (ae8d08242 pathspec: pass directory indicator to
match_pathspec_item()) the path matching logic has been able to cope
with submodules without needing to strip off a trailing slash if a path
refers to a submodule.

Since stripping the slash is no longer necessary, remove the
PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: prevent prune_cache from overeagerly pruning... Brandon Williams Thu, 11 May 2017 22:04:25 +0000 (15:04 -0700)

ls-files: prevent prune_cache from overeagerly pruning submodules

Since (ae8d08242 pathspec: pass directory indicator to
match_pathspec_item()) the path matching logic has been able to cope
with submodules without needing to strip off a trailing slash if a path
refers to a submodule.

ls-files is the only caller of 'parse_pathspec()' which relies on the
behavior of the PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag because it
uses the result to construct a common prefix of all provided pathspecs
which is then used to prune the index of all entries which don't have
that prefix. Since submodules entries in the index don't have a
trailing slash 'prune_cache()' will be overeager and prune a submodule
'sub' if the common prefix is 'sub/'. To correct this behavior, only
prune entries which don't match up to, but not including, a trailing
slash of the common prefix.

This is in preparation to remove the
PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP flag in a later patch.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSI... Brandon Williams Thu, 11 May 2017 22:04:24 +0000 (15:04 -0700)

pathspec: remove PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE flag

Since (ae8d08242 pathspec: pass directory indicator to
match_pathspec_item()) the path matching logic has been able to cope
with submodules without needing to strip off a trailing slash if a path
refers to a submodule.

Since the stripping the trailing slash is no longer necessary, remove
the PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE flag. In addition, factor
out the logic which dies if a path decends into a submodule so that it
can still be used as a check after a pathspec struct has been
initialized.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

perf: add test showing exponential growth in path globbingÆvar Arnfjörð Bjarmason Thu, 11 May 2017 09:41:08 +0000 (09:41 +0000)

perf: add test showing exponential growth in path globbing

Add a test showing that runtimes of the wildmatch() function used for
globbing in git grow exponentially in the face of some pathological
globs.

This issue affects both globs matching filenames via e.g. ls-files,
and globs matching refnames via e.g. for-each-ref.

As noted in the test description this is a test to see whether Git
suffers from the issue noted in an article Russ Cox posted today about
common bugs in various glob implementations:
https://research.swtch.com/glob

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

perf: add function to setup a fresh test repoÆvar Arnfjörð Bjarmason Thu, 11 May 2017 09:41:07 +0000 (09:41 +0000)

perf: add function to setup a fresh test repo

Add a function to setup a fresh test repo via 'git init' to compliment
the existing functions to copy over a normal & large repo.

Some performance tests don't need any existing repository data at all
to be significant, e.g. tests which stress glob matches against single
pathological revisions or files, which I'm about to add in a
subsequent commit.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

docs/config: consistify include.path examplesJeff King Thu, 11 May 2017 09:14:30 +0000 (05:14 -0400)

docs/config: consistify include.path examples

Most of the include examples use "foo.inc", but some use
"foo". Since the string of examples are meant to show
variations and how they differ, it's a good idea to change
only one thing at a time. The filename differences are not
relevant to what we're trying to show.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

docs/config: avoid the term "expand" for includesJeff King Thu, 11 May 2017 09:13:04 +0000 (05:13 -0400)

docs/config: avoid the term "expand" for includes

Using the word "expand" to refer to including the contents
of another config file isn't really accurate, since it's a
verbatim insertion. And it can cause confusion with the
expanding of the path itself via things like "~".

Let's clarify when we are referring to the contents versus
the filename, and use appropriate verbs in each case.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

docs/config: give a relative includeIf exampleJeff King Thu, 11 May 2017 09:11:06 +0000 (05:11 -0400)

docs/config: give a relative includeIf example

The changes in the previous commit hopefully clarify that
the evaluation of an include "path" variable is the same no
matter if it's in a conditional section or not. But since
this question came up on the list, let's add an example that
makes it obvious.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

docs/config: clarify include/includeIf relationshipJeff King Thu, 11 May 2017 09:10:47 +0000 (05:10 -0400)

docs/config: clarify include/includeIf relationship

The "includeIf" directives behave exactly like include ones,
except they only kick in when the conditional is true. That
was mentioned in the "conditional" section, but let's make
it more clear for the whole "includes" section, since people
don't necessarily read the documentation top to bottom.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

travis-ci: add job to run tests with GETTEXT_POISONLars Schneider Fri, 5 May 2017 15:40:53 +0000 (17:40 +0200)

travis-ci: add job to run tests with GETTEXT_POISON

Add a job to run Git tests with GETTEXT_POISON. In this job we don't run
the git-p4, git-svn, and HTTPD tests to save resources/time (those tests
are already executed in other jobs). Since we don't run these tests, we
can also skip the "before_install" step (which would install the
necessary dependencies) with an empty override.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

travis-ci: setup "prove cache" in "script" stepLars Schneider Fri, 5 May 2017 15:40:52 +0000 (17:40 +0200)

travis-ci: setup "prove cache" in "script" step

The command that made the "prove cache" persistent across builds was
executed in the "before_install" step. Consequently, every job that
wanted to make use of the cache had to run this step.

The "prove cache" is only used in the "script" step for the
"make test" command. Therefore, we should configure the "prove cache"
in this step.

This change is useful for a subsequent patch that adds a job which does
not need the "before_install" step but wants to run the "script" step to
execute the tests.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

tests: fix tests broken under GETTEXT_POISON=YesPleaseÆvar Arnfjörð Bjarmason Fri, 5 May 2017 18:19:32 +0000 (18:19 +0000)

tests: fix tests broken under GETTEXT_POISON=YesPlease

The GETTEXT_POISON=YesPlease compile-time testing option added in my
bb946bba76 ("i18n: add GETTEXT_POISON to simulate unfriendly
translator", 2011-02-22) has been slowly bitrotting as strings have
been marked for translation, and new tests have been added without
running it.

I brought this up on the list ("[BUG] test suite broken with
GETTEXT_POISON=YesPlease", [1]) asking whether this mode was useful at
all anymore. At least one person occasionally uses it, and Lars
Schneider offered to change one of the the Travis builds to run in
this mode, so fix up the failing ones.

My test setup runs most of the tests, with the notable exception of
skipping all the p4 tests, so it's possible that there's still some
lurking regressions I haven't fixed.

1. <CACBZZX62+acvi1dpkknadTL827mtCm_QesGSZ=6+UnyeMpg8+Q@mail.gmail.com>

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

read-tree: "read-tree -m --empty" does not make senseJunio C Hamano Thu, 11 May 2017 04:31:54 +0000 (21:31 -0700)

read-tree: "read-tree -m --empty" does not make sense

fb1bb965 ("read-tree: deprecate syntax without tree-ish args",
2010-09-10) wanted to deprecate "git read-tree" without any tree,
which used to be the way to empty the index, and encourage use of
"git read-tree --empty" instead.

However, when used with "-m", "--empty" does not make any sense,
either, simply because merging 0 trees will result in a different
error anyway.

Omit the deprecation warning and let the code to emit real error
message diagnose the error.

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

t0027: tests are not expensive; remove t0025Torsten Bögershausen Wed, 10 May 2017 14:06:19 +0000 (16:06 +0200)

t0027: tests are not expensive; remove t0025

The purpose of t0027 is to test all CRLF related conversions at "git
checkout" and "git add". Running t0027 under Git for Windows takes
3-4 minutes, so the whole script had been marked as "EXPENSIVE".

However, the "Git for Windows" fork overrides this since 2014:
"t0027 is marked expensive, but really, for MinGW we want to run
these tests always."

The test seems not to be expensive on other platforms at all: it
takes less than 14 seconds under Linux, and 63 seconds under Mac Os
X, and this is more or less the same with a SSD or a spinning disk.

So let's drop the "EXPENSIVE" prereq.

While at it, retire t0025; recent "stress" tests show that t0025 is
flaky, reported by Lars Schneider <larsxschneider@gmail.com>, but
all tests in t0025 are covered by t0027 already.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: add die_in_unpopulated_submodule functionBrandon Williams Tue, 9 May 2017 19:17:59 +0000 (12:17 -0700)

submodule: add die_in_unpopulated_submodule function

Currently 'git add' is the only command which dies when launched from an
unpopulated submodule (the place-holder directory for a submodule which
hasn't been checked out). This is triggered implicitly by passing the
PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE flag to 'parse_pathspec()'.

Instead make this desire more explicit by creating a function
'die_in_unpopulated_submodule()' which dies if the provided 'prefix' has
a leading path component which matches a submodule in the the index.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pathspec: provide a more descriptive die messageBrandon Williams Tue, 9 May 2017 19:17:58 +0000 (12:17 -0700)

pathspec: provide a more descriptive die message

The current message displayed upon an internal error in
'init_pathspec_item()' isn't very descriptive and doesn't provide much
context to where the error occurred. Update the error message to
provide more context to where the error occured.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t4051: mark supporting files as requiring LF-only line... Johannes Schindelin Tue, 9 May 2017 12:54:32 +0000 (14:54 +0200)

t4051: mark supporting files as requiring LF-only line endings

The test t4051-diff-function-context.sh passes on Linux when
core.autocrlf=true even without marking its support files as LF-only,
but they fail when core.autocrlf=true in Git for Windows' SDK.

The reason is that `grep ... >file.c.new` will keep CR/LF line endings
on Linux (obviously treating CRs as if they were regular characters),
but will be converted to LF-only line endings with MSYS2's grep that is
used in Git for Windows.

As we do not want to validate the way the available `grep` works, let's
just mark the input as LF-only and move on.

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

Fix the remaining tests that failed with core.autocrlf... Johannes Schindelin Tue, 9 May 2017 12:54:27 +0000 (14:54 +0200)

Fix the remaining tests that failed with core.autocrlf=true

The test suite is mainly developed on Linux and MacOSX, which is the
reason that nobody thought to mark files as LF-only as needed.

The symptom is a test suite that fails left and right when being checked
out using Git for Windows (which defaults to core.autocrlf=true).

Mostly, the problems stem from Git's (LF-only) output being compared to
hard-coded files that are checked out with line endings according to
core.autocrlf (which is of course incorrect). This includes the two test
files in t/diff-lib/, README and COPYING.

This patch can be validated even on Linux by using this cadence:

git config core.autocrlf true
rm .git/index && git stash
make -j15 DEVELOPER=1 test

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

t3901: move supporting files into t/t3901/Johannes Schindelin Tue, 9 May 2017 12:54:24 +0000 (14:54 +0200)

t3901: move supporting files into t/t3901/

The current convention is to either generate files on the fly in tests,
or to use supporting files taken from a t/tNNNN/ directory (where NNNN
matches the test's number, or the number of the test from which we
borrow supporting files).

The test t3901-i18n-patch.sh was obviously introduced before that
convention was in full swing, hence its supporting files still lived in
t/t3901-8859-1.txt and t/t3901-utf8.txt, respectively.

Let's adjust to the current convention.

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

completion: mark bash script as LF-onlyJohannes Schindelin Tue, 9 May 2017 12:54:20 +0000 (14:54 +0200)

completion: mark bash script as LF-only

Without this change, the completion script does not work, as Bash expects
its scripts to have line feeds as end-of-line markers (this is
particularly prominent in quoted multi-line strings, where carriage
returns would slip into the strings as verbatim characters otherwise).

This change is required to let t9902-completion pass when Git's source
code is checked out with `core.autocrlf = true`.

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

git-new-workdir: mark script as LF-onlyJohannes Schindelin Tue, 9 May 2017 12:53:25 +0000 (14:53 +0200)

git-new-workdir: mark script as LF-only

Bash does not handle scripts with CR/LF line endings correctly, therefore
they *have* to be forced to LF-only line endings.

Funnily enough, this fixes t3000-ls-files-others and
t1021-rerere-in-workdir when git.git was checked out with
core.autocrlf=true, as these test still use git-new-workdir (once `git
worktree` is no longer marked as experimental, both scripts probably
want to be ported to using that command instead).

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

Fix build with core.autocrlf=trueJohannes Schindelin Tue, 9 May 2017 12:53:21 +0000 (14:53 +0200)

Fix build with core.autocrlf=true

On Windows, the default line endings are denoted by a Carriage Return
byte followed by a Line Feed byte, while Linux and MacOSX use a single
Line Feed byte to denote a line ending.

To help with this situation, Git introduced several mechanisms over the
last decade, most prominently the `core.autocrlf` setting.

Sometimes, however, a single setting is incorrect, e.g. when certain
files in the source code are to be consumed by software that can handle
only LF line endings, while other files can use whatever is appropriate
for the current platform.

To allow for that, Git added the `eol` option to its .gitattributes
handling, expecting every user of Git to mark their source code
appropriately.

Bash assumes that line-endings of scripts are denoted by a single Line
Feed byte. Therefore, shell scripts in Git's source code are one example
where that `eol=lf` option is *required*.

When generating common-cmds.h, the Unix tools we use generally operate on
the assumption that input and output deliminate their lines using LF-only
line endings. Consequently, they would happily copy the CR byte verbatim
into the strings in common-cmds.h, which in turn makes the C preprocessor
barf (that interprets them as MacOS-style line endings). Therefore, we
have to mark the input files as LF-only: command-list.txt and
Documentation/git-*.txt.

Quite a bit belatedly, this patch brings Git's own source code in line
with those expectations by setting those attributes to allow for a
correct build even when core.autocrlf=true.

This patch can be validated even on Linux, by using this cadence:

git config core.autocrlf true
rm .git/index && git stash
make -j15 DEVELOPER=1

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

receive-pack: verify push options in certJonathan Tan Tue, 9 May 2017 19:23:53 +0000 (12:23 -0700)

receive-pack: verify push options in cert

In commit f6a4e61 ("push: accept push options", 2016-07-14), send-pack
was taught to include push options both within the signed cert (if the
push is a signed push) and outside the signed cert; however,
receive-pack ignores push options within the cert, only handling push
options outside the cert.

Teach receive-pack, in the case that push options are provided for a
signed push, to verify that the push options both within the cert and
outside the cert are consistent.

This sets in stone the requirement that send-pack redundantly send its
push options in 2 places, but I think that this is better than the
alternatives. Sending push options only within the cert is
backwards-incompatible with existing Git servers (which read push
options only from outside the cert), and sending push options only
outside the cert means that the push options are not signed for.

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

doc: replace more gmane linksJunio C Hamano Mon, 8 May 2017 01:38:59 +0000 (10:38 +0900)

doc: replace more gmane links

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

checkout: fix memory leakJunio C Hamano Mon, 8 May 2017 04:21:06 +0000 (13:21 +0900)

checkout: fix memory leak

When "git checkout -m" does an in-core three-way merge to carry
local modifications forward to check out a different branch, the
code forgot to free the updated contents it has in-core.

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

Git 2.13 v2.13.0Junio C Hamano Tue, 9 May 2017 14:26:02 +0000 (23:26 +0900)

Git 2.13

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

Merge tag 'l10n-2.13.0-rnd2.1' of git://github.com... Junio C Hamano Tue, 9 May 2017 14:25:26 +0000 (23:25 +0900)

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

l10n for Git 2.13.0 round 2.1

* tag 'l10n-2.13.0-rnd2.1' of git://github.com/git-l10n/git-po:
l10n: zh_CN: for git v2.13.0 l10n round 2
l10n: sv.po: Update Swedish translation (3195t0f0u)
l10n: zh_CN: review for git v2.13.0 l10n round 1
l10n: Update Catalan translation
l10n: bg.po: Updated Bulgarian translation (3195t)
l10n: fr.po v2.13 rnd 2
l10n: de.po: translate 4 new messages
l10n: de.po: update German translation
l10n: de.po: lower case after semi-colon
l10n: vi.po(3195t): Update translation for v2.13.0 round 2
l10n: git.pot: v2.13.0 round 2 (4 new, 7 removed)
l10n: zh_CN: for git v2.13.0 l10n round 1
l10n: fr.po v2.13 round 1
l10n: pt_PT: update Portuguese translation
l10n: bg.po: Updated Bulgarian translation (3201t)
l10n: vi.po(3198t): Updated Vietnamese translation for v2.13.0-rc0
l10n: sv.po: Update Swedish translation (3199t0f0u)
l10n: git.pot: v2.13.0 round 1 (96 new, 37 removed)

Merge branch 'master' of git://github.com/nafmo/git... Jiang Xin Tue, 9 May 2017 14:12:34 +0000 (22:12 +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 (3195t0f0u)

l10n: zh_CN: for git v2.13.0 l10n round 2Jiang Xin Tue, 9 May 2017 13:55:38 +0000 (21:55 +0800)

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

Translate 4 messages (3195t0f0u) for git v2.13.0-rc2.

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

l10n: sv.po: Update Swedish translation (3195t0f0u)Peter Krefting Tue, 9 May 2017 07:05:09 +0000 (08:05 +0100)

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

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

Sync with v2.12.3Junio C Hamano Tue, 9 May 2017 03:20:21 +0000 (20:20 -0700)

Sync with v2.12.3

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

Merge branch 'jh/verify-index-checksum-only-in-fsck'Junio C Hamano Tue, 9 May 2017 03:17:42 +0000 (12:17 +0900)

Merge branch 'jh/verify-index-checksum-only-in-fsck'

* jh/verify-index-checksum-only-in-fsck:
t1450: avoid use of "sed" on the index, which is a binary file

docs: correct receive.advertisePushOptions defaultJonathan Tan Mon, 8 May 2017 21:33:50 +0000 (14:33 -0700)

docs: correct receive.advertisePushOptions default

In commit c714e45 ("receive-pack: implement advertising and receiving
push options", 2016-07-14), receive-pack was taught to (among other
things) advertise that it understood push options, depending on
configuration. It was documented that it advertised such ability by
default; however, it actually does not. (In that commit, notice that
advertise_push_options defaults to 0, unlike advertise_atomic_push which
defaults to 1.)

Update the documentation to state that it does not advertise the ability
by default.

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

t5310: fix "; do" styleJeff King Tue, 9 May 2017 02:59:46 +0000 (22:59 -0400)

t5310: fix "; do" style

Our usual shell style is to put the "do" of a loop on its
own line, like:

while $cond
do
something
done

instead of:

while $cond; do
something
done

We have a bit of both in our code base, but the former is
what's in CodingGuidelines (and outnumbers the latter in t/
by about 6:1).

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

pack-objects: disable pack reuse for object-selection... Jeff King Tue, 9 May 2017 02:54:13 +0000 (22:54 -0400)

pack-objects: disable pack reuse for object-selection options

If certain options like --honor-pack-keep, --local, or
--incremental are used with pack-objects, then we need to
feed each potential object to want_object_in_pack() to see
if it should be filtered out. But when the bitmap
reuse_packfile optimization is in effect, we do not call
that function at all, and in fact skip adding the objects to
the to_pack list entirely. This means we have a bug: for
certain requests we will silently ignore those options and
include objects in that pack that should not be there.

The problem has been present since the inception of the
pack-reuse code in 6b8fda2db (pack-objects: use bitmaps when
packing objects, 2013-12-21), but it was unlikely to come up
in practice. These options are generally used for on-disk
packing, not transfer packs (which go to stdout), but we've
never allowed pack reuse for non-stdout packs (until
645c432d6, we did not even use bitmaps, which the reuse
optimization relies on; after that, we explicitly turned it
off when not packing to stdout).

We can fix this by just disabling the reuse_packfile
optimization when the options are in use. In theory we could
teach the pack-reuse code to satisfy these checks, but it's
not worth the complexity. The purpose of the optimization is
to keep the amount of per-object work we do to a minimum.
But these options inherently require us to search for other
copies of each object, drowning out any benefit of the
pack-reuse optimization. But note that the optimizations
from 56dfeb626 (pack-objects: compute local/ignore_pack_keep
early, 2016-07-29) happen before pack-reuse, meaning that
specifying "--honor-pack-keep" in a repository with no .keep
files can still follow the fast path.

There are tests in t5310 that check these options with
bitmaps and --stdout, but they didn't catch the bug, and
it's hard to adapt them to do so.

One problem is that they don't use --delta-base-offset;
without that option, we always disable the reuse
optimization entirely. It would be fine to add it in (it
actually makes the test more realistic), but that still
isn't quite enough.

The other problem is that the reuse code is very picky; it
only kicks in when it can reuse most of a pack, starting
from the first byte. So we'd have to start from a fully
repacked and bitmapped state to trigger it. But the tests
for these options use a much more subtle state; they want to
be sure that the want_object_in_pack() code is allowing some
objects but not others. Doing a full repack runs counter to
that.

So this patch adds new tests at the end of the script which
create the fully-packed state and make sure that each option
is not fooled by reusable pack.

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

apply.c: fix whitespace-only mismergeJunio C Hamano Tue, 9 May 2017 02:30:24 +0000 (19:30 -0700)

apply.c: fix whitespace-only mismerge

4af9a7d3 ("Merge branch 'bc/object-id'", 2016-09-19) involved
merging a lot of changes made to builtin/apply.c on the side branch
manually to apply.c as an intervening commit 13b5af22 ("apply: move
libified code from builtin/apply.c to apply.{c,h}", 2016-04-22)
moved a lot of the lines changed on the side branch to a different
file apply.c at the top-level, requiring manual patching of it.
Apparently, the maintainer screwed up and made the code indent in a
funny way while doing so.

Reported-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive-tar: fix a sparse 'constant too large' warningRamsay Jones Mon, 8 May 2017 20:34:58 +0000 (21:34 +0100)

archive-tar: fix a sparse 'constant too large' warning

Commit dddbad728c ("timestamp_t: a new data type for timestamps",
26-04-2017) introduced a new typedef 'timestamp_t', as a synonym for an
unsigned long, which was used at the time to represent timestamps in
git. A later commit 28f4aee3fb ("use uintmax_t for timestamps",
26-04-2017) changed the typedef to use an 'uintmax_t' for the timestamp
representation type.

When building on a 32-bit Linux system, sparse complains that a constant
(USTAR_MAX_MTIME) used to detect a 'far-future mtime' timestamp, is too
large; 'warning: constant 077777777777UL is so big it is unsigned long
long' on lines 335 and 338 of archive-tar.c. Note that both gcc and
clang only issue a warning if this constant is used in a context that
requires an 'unsigned long' (rather than an uintmax_t). (Since TIME_MAX
is no longer equal to 0xFFFFFFFF, even on a 32-bit system, the macro
USTAR_MAX_MTIME is set to 077777777777UL, which cannot be represented as
an 'unsigned long' constant).

In order to suppress the warning, change the definition of the macro
constant USTAR_MAX_MTIME to use an 'ULL' type suffix.

In a similar vein, on systems which use a 64-bit representation of the
'unsigned long' type, the USTAR_MAX_SIZE constant macro is defined with
the value 077777777777ULL. Although this does not cause any warning
messages to be issued, it would be more appropriate for this constant
to use an 'UL' type suffix rather than 'ULL'.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

l10n: zh_CN: review for git v2.13.0 l10n round 1Ray Chen Tue, 2 May 2017 15:42:43 +0000 (23:42 +0800)

l10n: zh_CN: review for git v2.13.0 l10n round 1

Signed-off-by: Ray Chen <oldsharp@gmail.com>

Merge branch 'master' of https://github.com/vnwildman/gitJiang Xin Mon, 8 May 2017 22:39:31 +0000 (06:39 +0800)

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

* 'master' of https://github.com/vnwildman/git:
l10n: vi.po(3195t): Update translation for v2.13.0 round 2

l10n: Update Catalan translationJordi Mas Sun, 7 May 2017 08:12:01 +0000 (10:12 +0200)

l10n: Update Catalan translation

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

l10n: bg.po: Updated Bulgarian translation (3195t)Alexander Shopov Sun, 7 May 2017 07:25:19 +0000 (09:25 +0200)

l10n: bg.po: Updated Bulgarian translation (3195t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>

Merge branch 'fr_l10n_v2.13_rnd2' of git://github.com... Jiang Xin Mon, 8 May 2017 22:18:53 +0000 (06:18 +0800)

Merge branch 'fr_l10n_v2.13_rnd2' of git://github.com/jnavila/git

* 'fr_l10n_v2.13_rnd2' of git://github.com/jnavila/git:
l10n: fr.po v2.13 rnd 2

object: convert parse_object* to take struct object_idbrian m. carlson Sat, 6 May 2017 22:10:38 +0000 (22:10 +0000)

object: convert parse_object* to take struct object_id

Make parse_object, parse_object_or_die, and parse_object_buffer take a
pointer to struct object_id. Remove the temporary variables inserted
earlier, since they are no longer necessary. Transform all of the
callers using the following semantic patch:

@@
expression E1;
@@
- parse_object(E1.hash)
+ parse_object(&E1)

@@
expression E1;
@@
- parse_object(E1->hash)
+ parse_object(E1)

@@
expression E1, E2;
@@
- parse_object_or_die(E1.hash, E2)
+ parse_object_or_die(&E1, E2)

@@
expression E1, E2;
@@
- parse_object_or_die(E1->hash, E2)
+ parse_object_or_die(E1, E2)

@@
expression E1, E2, E3, E4, E5;
@@
- parse_object_buffer(E1.hash, E2, E3, E4, E5)
+ parse_object_buffer(&E1, E2, E3, E4, E5)

@@
expression E1, E2, E3, E4, E5;
@@
- parse_object_buffer(E1->hash, E2, E3, E4, E5)
+ parse_object_buffer(E1, E2, E3, E4, E5)

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

tree: convert parse_tree_indirect to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:37 +0000 (22:10 +0000)

tree: convert parse_tree_indirect to struct object_id

Convert parse_tree_indirect to take a pointer to struct object_id.
Update all the callers. This transformation was achieved using the
following semantic patch and manual updates to the declaration and
definition. Update builtin/checkout.c manually as well, since it uses a
ternary expression not handled by the semantic patch.

@@
expression E1;
@@
- parse_tree_indirect(E1.hash)
+ parse_tree_indirect(&E1)

@@
expression E1;
@@
- parse_tree_indirect(E1->hash)
+ parse_tree_indirect(E1)

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

sequencer: convert do_recursive_merge to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:36 +0000 (22:10 +0000)

sequencer: convert do_recursive_merge to struct object_id

This conversion is required to convert parse_tree_indirect.

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

diff-lib: convert do_diff_cache to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:35 +0000 (22:10 +0000)

diff-lib: convert do_diff_cache to struct object_id

This is needed to convert parse_tree_indirect.

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

builtin/ls-tree: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:34 +0000 (22:10 +0000)

builtin/ls-tree: convert to struct object_id

This is a prerequisite to convert do_diff_cache, which is required to
convert parse_tree_indirect.

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

merge: convert checkout_fast_forward to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:33 +0000 (22:10 +0000)

merge: convert checkout_fast_forward to struct object_id

Converting checkout_fast_forward is required to convert
parse_tree_indirect.

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

sequencer: convert fast_forward_to to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:32 +0000 (22:10 +0000)

sequencer: convert fast_forward_to to struct object_id

fast_forward_to is required for checkout_fast_fowrard, which is required
for parse_tree_indirect.

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

builtin/ls-files: convert overlay_tree_on_cache to... brian m. carlson Sat, 6 May 2017 22:10:31 +0000 (22:10 +0000)

builtin/ls-files: convert overlay_tree_on_cache to object_id

This is another caller of parse_tree_indirect.

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

builtin/read-tree: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:30 +0000 (22:10 +0000)

builtin/read-tree: convert to struct object_id

This is a caller of parse_tree_indirect, which must be converted in
order to convert parse_object.

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

sha1_name: convert internals of peel_onion to object_idbrian m. carlson Sat, 6 May 2017 22:10:29 +0000 (22:10 +0000)

sha1_name: convert internals of peel_onion to object_id

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

upload-pack: convert remaining parse_object callers... brian m. carlson Sat, 6 May 2017 22:10:28 +0000 (22:10 +0000)

upload-pack: convert remaining parse_object callers to object_id

Convert the remaining parse_object callers to struct object_id. Use
named constants for several hard-coded values. In addition, rename
got_sha1 to got_oid to reflect the new argument.

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

revision: convert remaining parse_object callers to... brian m. carlson Sat, 6 May 2017 22:10:27 +0000 (22:10 +0000)

revision: convert remaining parse_object callers to object_id

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

revision: rename add_pending_sha1 to add_pending_oidbrian m. carlson Sat, 6 May 2017 22:10:26 +0000 (22:10 +0000)

revision: rename add_pending_sha1 to add_pending_oid

Rename this function and convert it to take a pointer to struct
object_id.

This is a prerequisite for converting get_reference, which is needed to
convert parse_object.

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

http-push: convert process_ls_object and descendants... brian m. carlson Sat, 6 May 2017 22:10:25 +0000 (22:10 +0000)

http-push: convert process_ls_object and descendants to object_id

Rename one function to reflect that it now uses struct object_id. This
conversion is a prerequisite for converting parse_object.

Note that while the use of a buffer that is exactly forty bytes long
looks questionable, get_oid_hex reads exactly the right number of bytes
and does not require the data to be NUL-terminated.

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

refs/files-backend: convert many internals to struct... brian m. carlson Sat, 6 May 2017 22:10:24 +0000 (22:10 +0000)

refs/files-backend: convert many internals to struct object_id

Convert many of the internals of the files backend to use struct
object_id. Avoid converting public APIs (except one change to
refs/ref-cache.c) to limit the scope of the changes.

Convert one use of get_sha1_hex to parse_oid_hex, and rely on the fact
that a strbuf will be NUL-terminated and that parse_oid_hex will fail on
truncated input to avoid the need to check the length.

This is a requirement to convert parse_object later on.

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

refs: convert struct ref_update to use struct object_idbrian m. carlson Sat, 6 May 2017 22:10:23 +0000 (22:10 +0000)

refs: convert struct ref_update to use struct object_id

Convert struct ref_array_item to use struct object_id by changing the
definition and applying the following semantic patch, plus the standard
object_id transforms:

@@
struct ref_update E1;
@@
- E1.new_sha1
+ E1.new_oid.hash

@@
struct ref_update *E1;
@@
- E1->new_sha1
+ E1->new_oid.hash

@@
struct ref_update E1;
@@
- E1.old_sha1
+ E1.old_oid.hash

@@
struct ref_update *E1;
@@
- E1->old_sha1
+ E1->old_oid.hash

This transformation allows us to convert write_ref_to_lockfile, which is
required to convert parse_object.

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

ref-filter: convert some static functions to struct... brian m. carlson Sat, 6 May 2017 22:10:22 +0000 (22:10 +0000)

ref-filter: convert some static functions to struct object_id

Among the converted functions is a caller of parse_object_buffer, which
we will convert later.

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

Convert struct ref_array_item to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:21 +0000 (22:10 +0000)

Convert struct ref_array_item to struct object_id

Convert struct ref_array_item to use struct object_id by changing the
definition and applying the following semantic patch, plus the standard
object_id transforms:

@@
struct ref_array_item E1;
@@
- E1.objectname
+ E1.objectname.hash

@@
struct ref_array_item *E1;
@@
- E1->objectname
+ E1->objectname.hash

This transformation allows us to convert get_obj, which is needed to
convert parse_object_buffer.

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

Convert the verify_pack callback to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:20 +0000 (22:10 +0000)

Convert the verify_pack callback to struct object_id

Make the verify_pack_callback take a pointer to struct object_id.
Change the pack checksum to use GIT_MAX_RAWSZ, even though it is not
strictly an object ID. Doing so ensures resilience against future hash
size changes, and allows us to remove hard-coded assumptions about how
big the buffer needs to be.

Also, use a union to convert the pointer from nth_packed_object_sha1 to
to a pointer to struct object_id. This behavior is compatible with GCC
and clang and explicitly sanctioned by C11. The alternatives are to
just perform a cast, which would run afoul of strict aliasing rules, but
should just work, and changing the pointer into an instance of struct
object_id and copying the value. The latter operation could seriously
bloat memory usage on fsck, which already uses a lot of memory on some
repositories.

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

Convert lookup_tag to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:19 +0000 (22:10 +0000)

Convert lookup_tag to struct object_id

Convert lookup_tag to take a pointer to struct object_id.

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

log-tree: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:18 +0000 (22:10 +0000)

log-tree: convert to struct object_id

Convert the remaining functions to take pointers to struct object_id
instead of pointers to unsigned char, and update the internals of these
functions as well. Among these functions is a caller of lookup_tag,
which we will convert shortly.

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

Convert lookup_tree to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:17 +0000 (22:10 +0000)

Convert lookup_tree to struct object_id

Convert the lookup_tree function to take a pointer to struct object_id.

The commit was created with manual changes to tree.c, tree.h, and
object.c, plus the following semantic patch:

@@
@@
- lookup_tree(EMPTY_TREE_SHA1_BIN)
+ lookup_tree(&empty_tree_oid)

@@
expression E1;
@@
- lookup_tree(E1.hash)
+ lookup_tree(&E1)

@@
expression E1;
@@
- lookup_tree(E1->hash)
+ lookup_tree(E1)

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

builtin/reflog: convert tree_is_complete to take struct... brian m. carlson Sat, 6 May 2017 22:10:16 +0000 (22:10 +0000)

builtin/reflog: convert tree_is_complete to take struct object_id

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

tree: convert read_tree_1 to use struct object_id inter... brian m. carlson Sat, 6 May 2017 22:10:15 +0000 (22:10 +0000)

tree: convert read_tree_1 to use struct object_id internally

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

Convert lookup_blob to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:14 +0000 (22:10 +0000)

Convert lookup_blob to struct object_id

Convert lookup_blob to take a pointer to struct object_id.

The commit was created with manual changes to blob.c and blob.h, plus
the following semantic patch:

@@
expression E1;
@@
- lookup_blob(E1.hash)
+ lookup_blob(&E1)

@@
expression E1;
@@
- lookup_blob(E1->hash)
+ lookup_blob(E1)

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

Convert remaining callers of lookup_blob to object_idbrian m. carlson Sat, 6 May 2017 22:10:13 +0000 (22:10 +0000)

Convert remaining callers of lookup_blob to object_id

All but a few callers of lookup_blob have been converted to struct
object_id. Introduce a temporary, which will be removed later, into
parse_object to ease the transition, and convert the remaining callers
so that we can update lookup_blob to take struct object_id *.

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

builtin/unpack-objects: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:12 +0000 (22:10 +0000)

builtin/unpack-objects: convert to struct object_id

Convert struct delta_info and struct object_info, as well as the various
functions, to use struct object_id. Convert several hard-coded 20
values to GIT_SHA1_RAWSZ. Among the functions converted is a caller of
lookup_blob, which we will convert shortly.

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

pack: convert struct pack_idx_entry to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:11 +0000 (22:10 +0000)

pack: convert struct pack_idx_entry to struct object_id

Convert struct pack_idx_entry to use struct object_id by changing the
definition and applying the following semantic patch, plus the standard
object_id transforms:

@@
struct pack_idx_entry E1;
@@
- E1.sha1
+ E1.oid.hash

@@
struct pack_idx_entry *E1;
@@
- E1->sha1
+ E1->oid.hash

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

Convert lookup_commit* to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:10 +0000 (22:10 +0000)

Convert lookup_commit* to struct object_id

Convert lookup_commit, lookup_commit_or_die,
lookup_commit_reference, and lookup_commit_reference_gently to take
struct object_id arguments.

Introduce a temporary in parse_object buffer in order to convert this
function. This is required since in order to convert parse_object and
parse_object_buffer, lookup_commit_reference_gently and
lookup_commit_or_die would need to be converted. Not introducing a
temporary would therefore require that lookup_commit_or_die take a
struct object_id *, but lookup_commit would take unsigned char *,
leaving a confusing and hard-to-use interface.

parse_object_buffer will lose this temporary in a later patch.

This commit was created with manual changes to commit.c, commit.h, and
object.c, plus the following semantic patch:

@@
expression E1, E2;
@@
- lookup_commit_reference_gently(E1.hash, E2)
+ lookup_commit_reference_gently(&E1, E2)

@@
expression E1, E2;
@@
- lookup_commit_reference_gently(E1->hash, E2)
+ lookup_commit_reference_gently(E1, E2)

@@
expression E1;
@@
- lookup_commit_reference(E1.hash)
+ lookup_commit_reference(&E1)

@@
expression E1;
@@
- lookup_commit_reference(E1->hash)
+ lookup_commit_reference(E1)

@@
expression E1;
@@
- lookup_commit(E1.hash)
+ lookup_commit(&E1)

@@
expression E1;
@@
- lookup_commit(E1->hash)
+ lookup_commit(E1)

@@
expression E1, E2;
@@
- lookup_commit_or_die(E1.hash, E2)
+ lookup_commit_or_die(&E1, E2)

@@
expression E1, E2;
@@
- lookup_commit_or_die(E1->hash, E2)
+ lookup_commit_or_die(E1, E2)

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

Convert remaining callers of lookup_commit_reference... brian m. carlson Sat, 6 May 2017 22:10:09 +0000 (22:10 +0000)

Convert remaining callers of lookup_commit_reference* to object_id

There are a small number of remaining callers of lookup_commit_reference
and lookup_commit_reference_gently that still need to be converted to
struct object_id. Convert these.

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

builtin/tag: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:08 +0000 (22:10 +0000)

builtin/tag: convert to struct object_id

Parts of this module call lookup_commit_reference, which we want to
convert. The module is small and mostly self-contained, so convert the
rest of it while we're at it.

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

sequencer: convert some functions to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:07 +0000 (22:10 +0000)

sequencer: convert some functions to struct object_id

Convert update_squash_messages and is_index_unchanged to struct
object_id. These are callers of lookup_commit and
lookup_commit_reference, which we want to convert.

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

shallow: convert shallow registration functions to... brian m. carlson Sat, 6 May 2017 22:10:06 +0000 (22:10 +0000)

shallow: convert shallow registration functions to object_id

Convert register_shallow and unregister_shallow to take struct
object_id. register_shallow is a caller of lookup_commit, which we will
convert later. It doesn't make sense for the registration and
unregistration functions to have incompatible interfaces, so convert
them both.

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

revision: convert prepare_show_merge to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:05 +0000 (22:10 +0000)

revision: convert prepare_show_merge to struct object_id

This is a caller of lookup_commit_or_die, which we will convert later
on.

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

notes-utils: convert internals to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:04 +0000 (22:10 +0000)

notes-utils: convert internals to struct object_id

Convert the internals of create_notes_comit and commit_notes to use
struct object_id.

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

http-push: convert some static functions to struct... brian m. carlson Sat, 6 May 2017 22:10:03 +0000 (22:10 +0000)

http-push: convert some static functions to struct object_id

Among the functions converted is a caller of lookup_commit_or_die, which
we will convert later on.

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

tag: convert parse_tag_buffer to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:02 +0000 (22:10 +0000)

tag: convert parse_tag_buffer to struct object_id

Specify some constants in terms of GIT_SHA1_HEXSZ, and convert a
get_sha1_hex into parse_oid_hex to avoid needing to specify additional
constants.

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

builtin/verify-commit: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:01 +0000 (22:10 +0000)

builtin/verify-commit: convert to struct object_id

This is a prerequisite to convert to lookup_commit, which we will
convert later.

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

reflog_expire: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:10:00 +0000 (22:10 +0000)

reflog_expire: convert to struct object_id

Adjust the callback functions to take struct object_id * instead of
unsigned char *, and modify related static functions accordingly.

Introduce a temporary object_id instance into files_reflog_expire and
copy the SHA-1 value passed in. This is necessary because the sha1
parameter can come indirectly from get_sha1. Without the temporary, it
would require much more refactoring to be able to convert this function.

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

parse-options-cb: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:09:59 +0000 (22:09 +0000)

parse-options-cb: convert to struct object_id

This is a caller of lookup_commit_reference, which we will soon convert.

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

notes-cache: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:09:58 +0000 (22:09 +0000)

notes-cache: convert to struct object_id

Convert as many instances of unsigned char [20] as possible. Update the
callers of notes_cache_get and notes_cache_put to use the new interface.
Among the functions updated are callers of
lookup_commit_reference_gently, which we will soon convert.

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

submodule: convert merge_submodule to use struct object_idbrian m. carlson Sat, 6 May 2017 22:09:57 +0000 (22:09 +0000)

submodule: convert merge_submodule to use struct object_id

This is a caller of lookup_commit_reference, which we will convert
later.

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

fast-import: convert to struct object_idbrian m. carlson Sat, 6 May 2017 22:09:56 +0000 (22:09 +0000)

fast-import: convert to struct object_id

Convert the remaining parts of fast-import.c to use struct object_id.
Convert several instances of get_sha1_hex to parse_oid_hex to avoid
needing to specify constants. Convert other hardcoded values to named
constants. Finally, use the is_empty_tree_oid function instead of a
direct comparison against a fixed string.

Note that the odd computation with GIT_MAX_HEXSZ is due to the insertion
of a slash between every two hex digits in the path, plus one for the
terminating NUL.

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

submodule_uses_worktrees(): plug memory leakJohannes Schindelin Thu, 4 May 2017 13:59:19 +0000 (15:59 +0200)

submodule_uses_worktrees(): plug memory leak

There is really no reason why we would need to hold onto the allocated
string longer than necessary.

Reported by Coverity.

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