gitweb.git
mergetools: add support for smerge (Sublime Merge)David Aguilar Thu, 4 Apr 2019 07:34:38 +0000 (00:34 -0700)

mergetools: add support for smerge (Sublime Merge)

Teach difftool and mergetool about the Sublime Merge "smerge" command.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

blame.c: don't drop origin blobs as eagerlyDavid Kastrup Tue, 2 Apr 2019 11:56:25 +0000 (13:56 +0200)

blame.c: don't drop origin blobs as eagerly

When a parent blob already has chunks queued up for blaming, dropping
the blob at the end of one blame step will cause it to get reloaded
right away, doubling the amount of I/O and unpacking when processing a
linear history.

Keeping such parent blobs in memory seems like a reasonable optimization
that should incur additional memory pressure mostly when processing the
merges from old branches.

Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

read-tree.txt: clarify --reset and worktree changesNguyễn Thái Ngọc Duy Mon, 1 Apr 2019 12:05:05 +0000 (19:05 +0700)

read-tree.txt: clarify --reset and worktree changes

The description of --reset stays true to the first implementation in
438195cced (git-read-tree: add "--reset" flag, 2005-06-09). That is,
--reset discards unmerged entries. Or at least true to the commit
message because I can't be sure about read-tree's behavior regarding
local changes.

But in fcc387db9b (read-tree -m -u: do not overwrite or remove untracked
working tree files., 2006-05-17), it is clear that "-m -u" tries to keep
local changes, while --reset is singled out and will keep overwriting
worktree files. It's not stated in the commit message, but it's obvious
from the patch.

I went this far back not because I had a lot of free time, but because I
did not trust my reading of unpack-trees.c code. So far I think the
related changes in history agree with my understanding of the current
code, that "--reset" loses local changes.

This behavior is not mentioned in git-read-tree.txt, even though
old-timers probably can just guess it based on the "reset" name. Update
git-read-tree.txt about this.

Side note. There's another change regarding --reset that is not
obviously about local changes, b018ff6085 (unpack-trees: fix "read-tree
-u --reset A B" with conflicted index, 2012-12-29). But I'm pretty sure
this is about the first function of --reset, to discard unmerged entries
correctly.

PS. The patch changes one more line than necessary because the first
line uses spaces instead of tab.

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

tests (pack-objects): use the full, unabbreviated ... Johannes Schindelin Mon, 25 Mar 2019 18:14:23 +0000 (11:14 -0700)

tests (pack-objects): use the full, unabbreviated `--revs` option

To use the singular form of a word, when the option wants the plural
form (and quietly expands it because it thinks it was abbreviated), is
an easy mistake to make, and t5317 contains almost two dozen of them.

However, using abbreviated options in tests is a bit fragile, so we will
disallow use of abbreviated options in our test suite.

In preparation for this change, let's fix
`t5317-pack-objects-filter-objects.sh`.

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

tests (status): spell out the `--find-renames` option... Johannes Schindelin Mon, 25 Mar 2019 18:14:22 +0000 (11:14 -0700)

tests (status): spell out the `--find-renames` option in full

To avoid future ambiguities, we really want to use full option names in
the test suite. `t7525-status-rename.sh` used an abbreviated form of the
`--find-renames` option, though, so let's change that.

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

tests (push): do not abbreviate the `--follow-tags... Johannes Schindelin Mon, 25 Mar 2019 18:14:21 +0000 (11:14 -0700)

tests (push): do not abbreviate the `--follow-tags` option

We really want to spell out the option in the full form, to avoid any
ambiguity that might be introduced by future patches.

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

t5531: avoid using an abbreviated optionJohannes Schindelin Mon, 25 Mar 2019 18:14:20 +0000 (11:14 -0700)

t5531: avoid using an abbreviated option

It was probably just an oversight: the `--recurse-submodules` option
puts the term "submodules" in the plural form, not the singular one.

To avoid future problems in case that another option is introduced that
starts with the prefix `--recurse-submodule`, let's just fix this.

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

t7810: do not abbreviate `--no-exclude-standard` nor... Johannes Schindelin Mon, 25 Mar 2019 18:14:19 +0000 (11:14 -0700)

t7810: do not abbreviate `--no-exclude-standard` nor `--invert-match`

This script used abbreviated options, which is unnecessarily fragile.

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

tests (rebase): spell out the `--force-rebase` optionJohannes Schindelin Mon, 25 Mar 2019 18:14:19 +0000 (11:14 -0700)

tests (rebase): spell out the `--force-rebase` option

In quite a few test cases, we were sloppy and used the abbreviation
`--force`, but we really should be precise in what we want to test.

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

tests (rebase): spell out the `--keep-empty` optionJohannes Schindelin Mon, 25 Mar 2019 18:14:18 +0000 (11:14 -0700)

tests (rebase): spell out the `--keep-empty` option

This test wants to run `git rebase` with the `--keep-empty` option, but
it really only spelled out `--keep` and trusted Git's option parsing to
determine that this was a unique abbreviation of the real option.

However, Denton Liu contributed a patch series in
https://public-inbox.org/git/cover.1553354374.git.liu.denton@gmail.com/
that introduces a new `git rebase` option called `--keep-base`, which
makes this previously unique abbreviation non-unique.

Whether this patch series is accepted or not, it is actually a bad
practice to use abbreviated options in our test suite, because of the
issue that those unique option names are not guaranteed to stay unique
in the future.

So let's just not use abbreviated options in the test suite.

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

index-pack: show progress while checking objectsSZEDER Gábor Sun, 31 Mar 2019 23:12:35 +0000 (01:12 +0200)

index-pack: show progress while checking objects

When 'git index-pack' is run by 'git clone', its check_objects()
function usually doesn't take long enough to be a concern, but I just
run into a situation where it took about a minute or so: I
inadvertently put some memory pressure on my tiny laptop while cloning
linux.git, and then there was quite a long silence between the
"Resolving deltas" and "Checking connectivity" progress bars.

Show a progress bar during the loop of check_objects() to let the user
know that something is still going on.

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

t6050: redirect expected error output to a fileChristian Couder Sun, 31 Mar 2019 13:46:57 +0000 (15:46 +0200)

t6050: redirect expected error output to a file

Otherwise the error from `git rev-parse` is uselessly
polluting the debug output.

Redirecting to a file, instead of /dev/null, makes it
possible to check that we got the error we expected, so
let's check that too.

Reviewed-by: Taylor Blau <me@ttaylorr.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6050: use test_line_count instead of wc -lChristian Couder Sun, 31 Mar 2019 13:46:56 +0000 (15:46 +0200)

t6050: use test_line_count instead of wc -l

This modernizes a test and makes it more portable.

Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/git-status: fix titles in porcelain v2... Todd Zullinger Sat, 30 Mar 2019 18:30:01 +0000 (14:30 -0400)

Documentation/git-status: fix titles in porcelain v2 section

Asciidoc uses either one-line or two-line syntax for document/section
titles[1]. The two-line form is used in git-status. Fix a few section
titles in the porcelain v2 section which were inadvertently using
markdown syntax.

[1] http://asciidoc.org/userguide.html#X17

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

Documentation/rev-list-options: wrap --date=<format... Todd Zullinger Sat, 30 Mar 2019 18:30:00 +0000 (14:30 -0400)

Documentation/rev-list-options: wrap --date=<format> block with "--"

Using "+" to continue multiple list items is more tedious and
error-prone than wrapping the entire block with "--" block markers.

When using asciidoctor, the list items after the --date=iso list items
are incorrectly formatted when using "+" continuation. Use "--" block
markers to correctly format the block.

When using asciidoc there is no change in how the content is rendered.

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

test-lib: whitelist GIT_TR2_* in the environmentÆvar Arnfjörð Bjarmason Sat, 30 Mar 2019 07:51:19 +0000 (08:51 +0100)

test-lib: whitelist GIT_TR2_* in the environment

Add GIT_TR2_* to the whitelist of environment variables that we don't
clear when running the test suite.

This allows us to use the test suite to produce trace2 test data,
which is handy to e.g. write consumers that collate the trace data
itself.

One caveat here is that we produce trace output for not *just* the
tests, but also e.g. from this line in test-lib.sh:

# It appears that people try to run tests without building...
"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null
[...]

I consider this not just OK but a feature. Let's log *all* the git
commands we're going to execute, not just those within
test_expect_*().

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

fetch-pack: binary search when storing wanted-refsJonathan Tan Wed, 27 Mar 2019 21:11:10 +0000 (14:11 -0700)

fetch-pack: binary search when storing wanted-refs

In do_fetch_pack_v2(), the "sought" array is sorted by name, and it is
not subsequently reordered (within the function). Therefore,
receive_wanted_refs() can assume that "sought" is sorted, and can thus
use a binary search when storing wanted-refs retrieved from the server.

Replace the existing linear search with a binary search. This improves
performance significantly when mirror cloning a repository with more
than 1 million refs.

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

interpret-trailers.txt: start the desc line with a... Nguyễn Thái Ngọc Duy Wed, 27 Mar 2019 09:16:28 +0000 (16:16 +0700)

interpret-trailers.txt: start the desc line with a capital letter

This description line is shown in 'git help -a' and all other commands
description starts with an uppercase character. This just makes that
printout a bit nicer.

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

sha1-file: support OBJECT_INFO_FOR_PREFETCHJonathan Tan Fri, 29 Mar 2019 21:39:27 +0000 (14:39 -0700)

sha1-file: support OBJECT_INFO_FOR_PREFETCH

Teach oid_object_info_extended() to support a new flag that inhibits
fetching of missing objects. This is equivalent to setting
fetch_is_missing to 0, calling oid_object_info_extended(), then setting
fetch_if_missing to whatever it was before. Update unpack-trees.c to use
this new flag instead of repeatedly setting fetch_if_missing.

This new flag complicates things slightly in that there are now 2 ways
to do the same thing. But this eliminates the need to repeatedly set a
global variable, and more importantly, allows prefetching to be done in
parallel (in the future); hence, this patch.

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

fetch-pack: respect --no-update-shallow in v2Jonathan Tan Tue, 26 Mar 2019 19:31:21 +0000 (12:31 -0700)

fetch-pack: respect --no-update-shallow in v2

In protocol v0, when sending "shallow" lines, the server distinguishes
between lines caused by the remote repo being shallow and lines caused
by client-specified depth settings. Unless "--update-shallow" is
specified, there is a difference in behavior: refs that reach the former
"shallow" lines, but not the latter, are rejected. But in v2, the server
does not, and the client treats all "shallow" lines like lines caused by
client-specified depth settings.

Full restoration of v0 functionality is not possible without protocol
change, but we can implement a heuristic: if we specify any depth
setting, treat all "shallow" lines like lines caused by client-specified
depth settings (that is, unaffected by "--no-update-shallow"), but
otherwise, treat them like lines caused by the remote repo being shallow
(that is, affected by "--no-update-shallow"). This restores most of v0
behavior, except in the case where a client fetches from a shallow
repository with depth settings.

This patch causes a test that previously failed with
GIT_TEST_PROTOCOL_VERSION=2 to pass.

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

fetch-pack: call prepare_shallow_info only if v0Jonathan Tan Tue, 26 Mar 2019 19:31:20 +0000 (12:31 -0700)

fetch-pack: call prepare_shallow_info only if v0

In fetch_pack(), be clearer that there is no shallow information before
the fetch when v2 is used - memset the struct shallow_info to 0 instead
of calling prepare_shallow_info().

This patch is in preparation for a future patch in which a v2 fetch
might call prepare_shallow_info() after shallow info has been retrieved
during the fetch, so I needed to ensure that prepare_shallow_info() is
not called before the fetch.

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

Merge branch 'jt/test-protocol-version' into jt/fetch... Junio C Hamano Mon, 1 Apr 2019 06:35:01 +0000 (15:35 +0900)

Merge branch 'jt/test-protocol-version' into jt/fetch-no-update-shallow-in-proto-v2

* jt/test-protocol-version:
t5552: compensate for v2 filtering ref adv.
tests: fix protocol version for overspecifications
t5700: only run with protocol version 1
t5512: compensate for v0 only sending HEAD symrefs
t5503: fix overspecification of trace expectation
tests: always test fetch of unreachable with v0
t5601: check ssh command only with protocol v0
tests: define GIT_TEST_PROTOCOL_VERSION

ci: install Asciidoctor in 'ci/install-dependencies.sh'SZEDER Gábor Fri, 29 Mar 2019 12:35:18 +0000 (13:35 +0100)

ci: install Asciidoctor in 'ci/install-dependencies.sh'

When our '.travis.yml' was split into several 'ci/*' scripts [1], the
installation of the 'asciidoctor' gem somehow ended up in
'ci/test-documentation.sh'.

Install it in 'ci/install-dependencies.sh', where we install other
dependencies of the Documentation build job as well (asciidoc,
xmlto).

[1] 657343a602 (travis-ci: move Travis CI code into dedicated scripts,
2017-09-10)

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

Documentation/technical/protocol-v2.txt: fix formattingSZEDER Gábor Fri, 29 Mar 2019 12:35:17 +0000 (13:35 +0100)

Documentation/technical/protocol-v2.txt: fix formatting

Asciidoctor versions v1.5.7 or later print the following warning while
building the documentation:

ASCIIDOC technical/protocol-v2.html
asciidoctor: WARNING: protocol-v2.txt: line 38: unterminated listing block

This highlights an issue (even with older Asciidoctor versions) where
the 'Initial Client Request' header is not rendered as a header but in
monospace. I'm not sure what exactly causes this issue and why it's
an issue only with this particular header, but all headers in
'protocol-v2.txt' are written like this:

Initial Client Request
------------------------

i.e. the header itself is indented by a space, and the "underline" is
two characters longer than the header.

Dropping that indentation and making the length of the underline match
the length of the header apparently fixes this issue.

While at it, adjust all other headers 'protocol-v2.txt' as well, to
match the style we use everywhere else.

The page rendered with AsciiDoc doesn't have this formatting issue.

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

Documentation/technical/api-config.txt: fix formattingSZEDER Gábor Fri, 29 Mar 2019 12:35:16 +0000 (13:35 +0100)

Documentation/technical/api-config.txt: fix formatting

Asciidoctor versions v1.5.7 or later print the following warning while
building the documentation:

ASCIIDOC technical/api-config.html
asciidoctor: WARNING: api-config.txt: line 232: unterminated listing block

This highlight an issue (even with older Asciidoctor versions) where
the length of the '----' lines surrounding a code example don't match,
and the rest of the document is rendered in monospace.

Fix this by making sure that the length of those lines match.

The page rendered with AsciiDoc doesn't have this formatting issue.

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

Documentation/git-diff-tree.txt: fix formattingSZEDER Gábor Fri, 29 Mar 2019 12:35:15 +0000 (13:35 +0100)

Documentation/git-diff-tree.txt: fix formatting

Asciidoctor versions v1.5.7 or later print the following warning while
building the documentation:

ASCIIDOC git-diff-tree.xml
asciidoctor: WARNING: diff-format.txt: line 2: unterminated listing block

This highlights an issue (even with older Asciidoctor versions) where
the "Raw output format" header is not rendered as a header, and the
rest of the document is rendered in monospace. This is not caused by
'diff-format.txt' in itself, but rather by 'git-diff-tree.txt'
including 'pretty-formats.txt' and 'diff-format.txt' on subsequent
lines, while the former happens to end with monospace-formatted
example commands.

Fix this by inserting an empty line between the two include::
directives.

The page rendered with AsciiDoc doesn't have this formatting issue.

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

config: correct '**' matching in includeIf patternsNguyễn Thái Ngọc Duy Tue, 26 Mar 2019 09:41:01 +0000 (16:41 +0700)

config: correct '**' matching in includeIf patterns

The current wildmatch() call for includeIf's gitdir pattern does not
pass the WM_PATHNAME flag. Without this flag, '*' is treated _almost_
the same as '**' (because '*' also matches slashes) with one exception:

'/**/' can match a single slash. The pattern 'foo/**/bar' matches
'foo/bar'.

But '/*/', which is essentially what wildmatch engine sees without
WM_PATHNAME, has to match two slashes (and '*' matches nothing). Which
means 'foo/*/bar' cannot match 'foo/bar'. It can only match 'foo//bar'.

The result of this is the current wildmatch() call works most of the
time until the user depends on '/**/' matching no path component. And
also '*' matches slashes while it should not, but people probably
haven't noticed this yet. The fix is straightforward.

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

check-docs: fix for setups where executables have an... Johannes Schindelin Mon, 25 Mar 2019 21:41:39 +0000 (14:41 -0700)

check-docs: fix for setups where executables have an extension

On Windows, for example, executables (must) have the extension `.exe`.
Our `check-docs` target was not prepared for that.

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

check-docs: do not expect guide pages to correspond... Johannes Schindelin Mon, 25 Mar 2019 21:41:38 +0000 (14:41 -0700)

check-docs: do not expect guide pages to correspond to commands

When we want to see what commands are listed in `command-list.txt` but
not installed, we currently include lines that refer to guides, e.g.
`gitattributes` or `gitcli`.

Let's not include those lines, as they are not referring to commands.

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

check-docs: really look at the documented commands... Johannes Schindelin Mon, 25 Mar 2019 21:41:37 +0000 (14:41 -0700)

check-docs: really look at the documented commands again

As part of the `check-docs` target, we verify that commands that are
documented are actually in the current list of commands to be built.

However, this logic broke in 5fafce0b78 (check-docs: get documented
command list from Makefile, 2012-08-08), when we tried to make the logic
safer by not looking at the files in the worktree, but at the list of
files to be generated in `Documentation/Makefile`. While this was the
right thing to do, it failed to accommodate for the fact that `make -C
Documentation/ print-man1`, unlike `ls Documentation/*.txt`, would *not*
print lines starting with the prefix `Documentation/`.

At long last, let's fix this.

Note: This went undetected due to a funny side effect of the
`ALL_PROGRAMS` variable starting with a space. That space, together with
the extra space we inserted before `$(ALL_PROGRAMS)` in the

case " $(ALL_PROGRAMS)" in
*" $$cmd ")
[...]

construct, is responsible that this case arm is used when `cmd` is empty
(which was clearly not intended to be the case).

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

docs: do not document the `git remote-testgit` commandJohannes Schindelin Mon, 25 Mar 2019 21:41:37 +0000 (14:41 -0700)

docs: do not document the `git remote-testgit` command

Since 7ded055401 (build: do not install git-remote-testgit, 2013-06-07),
we do not install it. Therefore it makes no sense to document it,
either.

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

docs: move gitremote-helpers into section 7Johannes Schindelin Mon, 25 Mar 2019 21:41:36 +0000 (14:41 -0700)

docs: move gitremote-helpers into section 7

It is currently in section 1, but that section is intended for
"Executable programs or shell commands".

A more appropriate place is section 7: "Miscellaneous (including macro
packages and conventions), e.g. man(7), groff(7)".

This issue should have been detected earlier by `make check-docs`, but
was missed due to a bug in that Makefile target (that we are about to
fix).

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

gc: handle & check gc.reflogExpire configÆvar Arnfjörð Bjarmason Thu, 28 Mar 2019 16:14:34 +0000 (17:14 +0100)

gc: handle & check gc.reflogExpire config

Don't redundantly run "git reflog expire --all" when gc.reflogExpire
and gc.reflogExpireUnreachable are set to "never", and die immediately
if those configuration valuer are bad.

As an earlier "assert lack of early exit" change to the tests for "git
reflog expire" shows, an early check of gc.reflogExpire{Unreachable,}
isn't wanted in general for "git reflog expire", but it makes sense
for "gc" because:

1) Similarly to 8ab5aa4bd8 ("parseopt: handle malformed --expire
arguments more nicely", 2018-04-21) we'll now die early if the
config variables are set to invalid values.

We run "pack-refs" before "reflog expire", which can take a while,
only to then die on an invalid gc.reflogExpire{Unreachable,}
configuration.

2) Not invoking the command at all means it won't show up in trace
output, which makes what's going on more obvious when the two are
set to "never".

3) As a later change documents we lock the refs when looping over the
refs to expire, even in cases where we end up doing nothing due to
this config.

For the reasons noted in the earlier "assert lack of early exit"
change I don't think it's worth it to bend over backwards in "git
reflog expire" itself to carefully detect if we'll really do
nothing given the combination of all its possible options and skip
that locking, but that's easy to detect here in "gc" where we'll
only run "reflog expire" in a relatively simple mode.

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

reflog tests: assert lack of early exit with expiry... Ævar Arnfjörð Bjarmason Thu, 28 Mar 2019 16:14:33 +0000 (17:14 +0100)

reflog tests: assert lack of early exit with expiry="never"

When gc.reflogExpire and gc.reflogExpireUnreachable are set to "never"
and --stale-fix isn't in effect we *could* exit early without
pointlessly looping over all the reflogs.

However, as an earlier change to add a test for the "points nowhere"
warning shows even in such a mode we might want to print out a
warning.

So while it's conceivable to implement this, I don't think it's worth
it. It's going to be too easy to inadvertently add some flag that'll
make the expiry happen anyway, and even with "never" we'd like to see
all the lines we're going to keep.

So let's assert that we're going to loop over all the references even
when this configuration is in effect.

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

commit-graph: improve & i18n error messagesÆvar Arnfjörð Bjarmason Mon, 25 Mar 2019 12:08:34 +0000 (13:08 +0100)

commit-graph: improve & i18n error messages

Change the error emitted when a commit-graph file is corrupt so that
we actually mention the commit-graph, e.g. change errors like:

error: improper chunk offset 0000000000385e0c

To:

error: commit-graph improper chunk offset 0000000000385e0c

As discussed in the commits leading up to this one the commit-graph
machinery is now used by common commands like "status". If the graph
was corrupt we'd often emit some error that gave no indication what
was wrong. Now some of them are still cryptic, but they'll at least
mention "commit-graph" to give the user a hint as to where to look.

While I'm at it mark some of the strings that hadn't been marked for
translation. It's clear from the commit history and the code that this
was merely forgotten at the time, and wasn't intentional.p5

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

commit-graph write: don't die if the existing graph... Ævar Arnfjörð Bjarmason Mon, 25 Mar 2019 12:08:33 +0000 (13:08 +0100)

commit-graph write: don't die if the existing graph is corrupt

When the commit-graph is written we end up calling
parse_commit(). This will in turn invoke code that'll consult the
existing commit-graph about the commit, if the graph is corrupted we
die.

We thus get into a state where a failing "commit-graph verify" can't
be followed-up with a "commit-graph write" if core.commitGraph=true is
set, the graph either needs to be manually removed to proceed, or
core.commitGraph needs to be set to "false".

Change the "commit-graph write" codepath to use a new
parse_commit_no_graph() helper instead of parse_commit() to avoid
this. The latter will call repo_parse_commit_internal() with
use_commit_graph=1 as seen in 177722b344 ("commit: integrate commit
graph with commit parsing", 2018-04-10).

Not using the old graph at all slows down the writing of the new graph
by some small amount, but is a sensible way to prevent an error in the
existing commit-graph from spreading.

Just fixing the current issue would be likely to result in code that's
inadvertently broken in the future. New code might use the
commit-graph at a distance. To detect such cases introduce a
"GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD" setting used when we do our
corruption tests, and test that a "write/verify" combo works after
every one of our current test cases where we now detect commit-graph
corruption.

Some of the code changes here might be strictly unnecessary, e.g. I
was unable to find cases where the parse_commit() called from
write_graph_chunk_data() didn't exit early due to
"item->object.parsed" being true in
repo_parse_commit_internal() (before the use_commit_graph=1 has any
effect). But let's also convert those cases for good measure, we do
not have exhaustive tests for all possible types of commit-graph
corruption.

This might need to be re-visited if we learn to write the commit-graph
incrementally, but probably not. Hopefully we'll just start by finding
out what commits we have in total, then read the old graph(s) to see
what they cover, and finally write a new graph file with everything
that's missing. In that case the new graph writing code just needs to
continue to use e.g. a parse_commit() that doesn't consult the
existing commit-graphs.

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

commit-graph verify: detect inability to read the graphÆvar Arnfjörð Bjarmason Mon, 25 Mar 2019 12:08:32 +0000 (13:08 +0100)

commit-graph verify: detect inability to read the graph

Change "commit-graph verify" to error on open() failures other than
ENOENT. As noted in the third paragraph of 283e68c72f ("commit-graph:
add 'verify' subcommand", 2018-06-27) and the test it added it's
intentional that "commit-graph verify" doesn't error out when the file
doesn't exist.

But let's not be overly promiscuous in what we accept. If we can't
read the file for other reasons, e.g. permission errors, bad file
descriptor etc. we'd like to report an error to the user.

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

commit-graph: don't pass filename to load_commit_graph_... Ævar Arnfjörð Bjarmason Mon, 25 Mar 2019 12:08:31 +0000 (13:08 +0100)

commit-graph: don't pass filename to load_commit_graph_one_fd_st()

An earlier change implemented load_commit_graph_one_fd_st() in a way
that was bug-compatible with earlier code in terms of the "graph file
%s is too small" error message printing out the path to the
commit-graph (".git/objects/info/commit-graph").

But change that, because:

* A function that takes an already-open file descriptor also needing
the filename isn't very intuitive.

* The vast majority of errors we might emit when loading the graph
come from parse_commit_graph(), which doesn't report the
filename. Let's not do that either in this case for consistency.

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

commit-graph: don't early exit(1) on e.g. "git status"Ævar Arnfjörð Bjarmason Mon, 25 Mar 2019 12:08:30 +0000 (13:08 +0100)

commit-graph: don't early exit(1) on e.g. "git status"

Make the commit-graph loading code work as a library that returns an
error code instead of calling exit(1) when the commit-graph is
corrupt. This means that e.g. "status" will now report commit-graph
corruption as an "error: [...]" at the top of its output, but then
proceed to work normally.

This required splitting up the load_commit_graph_one() function so
that the code that deals with open()-ing and stat()-ing the graph can
now be called independently as open_commit_graph().

This is needed because "commit-graph verify" where the graph doesn't
exist isn't an error. See the third paragraph in
283e68c72f ("commit-graph: add 'verify' subcommand",
2018-06-27). There's a bug in that logic where we conflate the
intended ENOENT with other errno values (e.g. EACCES), but this change
doesn't address that. That'll be addressed in a follow-up change.

I'm then splitting most of the logic out of load_commit_graph_one()
into load_commit_graph_one_fd_st(), which allows for providing an
existing file descriptor and stat information to the loading
code. This isn't strictly needed, but it would be redundant and
confusing to open() and stat() the file twice for some of the
codepaths, this allows for calling open_commit_graph() followed by
load_commit_graph_one_fd_st(). The "graph_file" still needs to be
passed to that function for the the "graph file %s is too small" error
message.

This leaves load_commit_graph_one() unused by everything except the
internal prepare_commit_graph_one() function, so let's mark it as
"static". If someone needs it in the future we can remove the "static"
attribute. I could also rewrite its sole remaining
user ("prepare_commit_graph_one()") to use
load_commit_graph_one_fd_st() instead, but let's leave it at this.

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

commit-graph: fix segfault on e.g. "git status"Ævar Arnfjörð Bjarmason Mon, 25 Mar 2019 12:08:29 +0000 (13:08 +0100)

commit-graph: fix segfault on e.g. "git status"

When core.commitGraph=true is set, various common commands now consult
the commit graph. Because the commit-graph code is very trusting of
its input data, it's possibly to construct a graph that'll cause an
immediate segfault on e.g. "status" (and e.g. "log", "blame", ...). In
some other cases where git immediately exits with a cryptic error
about the graph being broken.

The root cause of this is that while the "commit-graph verify"
sub-command exhaustively verifies the graph, other users of the graph
simply trust the graph, and will e.g. deference data found at certain
offsets as pointers, causing segfaults.

This change does the bare minimum to ensure that we don't segfault in
the common fill_commit_in_graph() codepath called by
e.g. setup_revisions(), to do this instrument the "commit-graph
verify" tests to always check if "status" would subsequently
segfault. This fixes the following tests which would previously
segfault:

not ok 50 - detect low chunk count
not ok 51 - detect missing OID fanout chunk
not ok 52 - detect missing OID lookup chunk
not ok 53 - detect missing commit data chunk

Those happened because with the commit-graph enabled setup_revisions()
would eventually call fill_commit_in_graph(), where e.g.
g->chunk_commit_data is used early as an offset (and will be
0x0). With this change we get far enough to detect that the graph is
broken, and show an error instead. E.g.:

$ git status; echo $?
error: commit-graph is missing the Commit Data chunk
1

That also sucks, we should *warn* and not hard-fail "status" just
because the commit-graph is corrupt, but fixing is left to a follow-up
change.

A side-effect of changing the reporting from graph_report() to error()
is that we now have an "error: " prefix for these even for
"commit-graph verify". Pseudo-diff before/after:

$ git commit-graph verify
-commit-graph is missing the Commit Data chunk
+error: commit-graph is missing the Commit Data chunk

Changing that is OK. Various errors it emits now early on are prefixed
with "error: ", moving these over and changing the output doesn't
break anything.

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

fast-import: fix erroneous handling of get-mark with... Elijah Newren Wed, 20 Feb 2019 22:58:46 +0000 (14:58 -0800)

fast-import: fix erroneous handling of get-mark with empty orphan commits

When get-mark was introduced in commit 28c7b1f7b7b7 ("fast-import: add a
get-mark command", 2015-07-01), it followed the precedent of the
cat-blob command to be allowed on any line other than in the middle of a
data directive; see commit 777f80d7429b ("fast-import: Allow cat-blob
requests at arbitrary points in stream", 2010-11-28). It was useful to
allow cat-blob directives in the middle of a commit to get more data
that would be used in writing the current commit object. get-mark is
not similarly useful since fast-import can already use either object id
or mark. Further, trying to allow this command anywhere caused parsing
bugs. Fix the parsing problems by only allowing get-mark commands to
appear when other commands have completed.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fast-import: only allow cat-blob requests where it... Elijah Newren Wed, 20 Feb 2019 22:58:45 +0000 (14:58 -0800)

fast-import: only allow cat-blob requests where it makes sense

In commit 777f80d7429b ("fast-import: Allow cat-blob requests at
arbitrary points in stream", 2010-11-28), fast-import started allowing
cat-blob commands to appear on the start of any line except in the
middle of a "data" command. It could be in the middle of various
directives that were part of a tag command, or in the middle of
checkpoints or progresses (each of which allow an optional second empty
newline), or even immediately after the mark command of a blob before
the data directive appeared (raising the question of what if it used the
mark for the blob that just barely appeared in the stream that we do not
yet have the data for). None of these locations make any sense as
places to put cat-blob requests.

The purpose of this change as stated in that commit message was to

[save] frontends from having to loop over everything they want to
commit in the next commit and cat-ing the necessary objects in
advance.

However, that can be achieved by simply allowing cat-blob requests to
appear whenever a filemodify directive is allowed. Further, it avoids
setting a bad precedent for other commands to follow (e.g. get-mark); a
precedent which caused parsing problems in corner cases.

Technically, inline filemodify directives add a slight wrinkle in that
frontends might want to have cat-blob directives appear after the start
of the filemodify and before the data directive contained within it. I
think it would have been better to disallow such a case (it would be
trivial to use cat-blob before the filemodify instead), but since there
is evidence this was used, for backwards compatibility let's support
that case too.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fast-import: check most prominent commands firstElijah Newren Wed, 20 Feb 2019 22:58:44 +0000 (14:58 -0800)

fast-import: check most prominent commands first

This is not a very important change, and one that I expect to have no
performance impact whatsoever, but reading the code bothered me. The
parsing of command types in cmd_main() mostly runs in order of most
common to least common commands; sure, it's hard to say for sure what
the most common are without some type of study, but it seems fairly
clear to mark the original four ("blob", "commit", "tag", "reset") as
the most prominent. Indeed, the parsing for most other commands were
added to later in the list. However, when "ls" was added, it was stuck
near the top of the list, with no rationale for that particular
location. Move it down to later to appease my Tourette's-like internal
twitching that its former location was causing.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-fast-import.txt: fix wording about where ls command... Elijah Newren Wed, 20 Feb 2019 22:58:43 +0000 (14:58 -0800)

git-fast-import.txt: fix wording about where ls command can appear

The docs claimed `ls` commands could appear almost anywhere, but the
code told a different story. Modify the docs to match the code.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t9300: demonstrate bug with get-mark and empty orphan... Elijah Newren Wed, 20 Feb 2019 22:58:42 +0000 (14:58 -0800)

t9300: demonstrate bug with get-mark and empty orphan commits

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gitweb: make hash size independentbrian m. carlson Tue, 19 Feb 2019 00:05:26 +0000 (00:05 +0000)

gitweb: make hash size independent

Gitweb has several hard-coded 40 values throughout it to check for
values that are passed in or acquired from Git. To simplify the code,
introduce a regex variable that matches either exactly 40 or exactly 64
hex characters, and use this variable anywhere we would have previously
hard-coded a 40 in a regex.

Add some helper functions which allow us to write tighter regexes that
match exactly the number of hex characters we're expecting.

Similarly, switch the code that looks for deleted diffinfo information
to look for either 40 or 64 zeros, and update one piece of code to use
this function. Finally, when formatting a log line, allow an
abbreviated describe output to contain up to 64 characters.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Git.pm: make hash size independentbrian m. carlson Tue, 19 Feb 2019 00:05:25 +0000 (00:05 +0000)

Git.pm: make hash size independent

The cat_blob function was matching on exactly 40 hex characters. This
won't work with SHA-256, which uses 64-character hex object IDs. While
it should be fine to simply match any number of hex characters since the
output is space delimited, be extra safe by matching either exactly 40
or exactly 64 hex characters.

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

read-cache: read data in a hash-independent waybrian m. carlson Tue, 19 Feb 2019 00:05:24 +0000 (00:05 +0000)

read-cache: read data in a hash-independent way

Index entries are structured with a variety of fields up front, followed
by a hash and one or two flags fields. Because the hash field is stored
in the middle of the structure, it's difficult to use one fixed-size
structure that easily allows access to the hash and flags fields.
Adjust the structure to hold the maximum amount of data that may be
needed using a member called "data" and read and write this field
independently in the various places that need to read and write the
structure.

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

dir: make untracked cache extension hash size independentbrian m. carlson Tue, 19 Feb 2019 00:05:23 +0000 (00:05 +0000)

dir: make untracked cache extension hash size independent

Instead of using a struct with a flex array member to read and write the
untracked cache extension, use a shorter, fixed-length struct and add
the name and hash data explicitly.

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

builtin/difftool: use parse_oid_hexbrian m. carlson Tue, 19 Feb 2019 00:05:22 +0000 (00:05 +0000)

builtin/difftool: use parse_oid_hex

Instead of using get_oid_hex and adding constants to the result, use
parse_oid_hex to make this code independent of the hash size.

Additionally, correct a typo that would cause us to print one too few
characters on error, since we will already have incremented the pointer
to point to the beginning of the object ID before we get to printing the
error message.

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

refspec: make hash size independentbrian m. carlson Tue, 19 Feb 2019 00:05:21 +0000 (00:05 +0000)

refspec: make hash size independent

Switch a use of GIT_SHA1_HEXSZ to use the_hash_algo.

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

archive: convert struct archiver_args to object_idbrian m. carlson Tue, 19 Feb 2019 00:05:20 +0000 (00:05 +0000)

archive: convert struct archiver_args to object_id

Change the commit_sha1 member to be called "commit_oid" and change it to
be a pointer to struct object_id. Additionally, update some uses of
GIT_SHA1_HEXSZ and hard-coded values to use the_hash_algo instead.

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

builtin/get-tar-commit-id: make hash size independentbrian m. carlson Tue, 19 Feb 2019 00:05:19 +0000 (00:05 +0000)

builtin/get-tar-commit-id: make hash size independent

To make this code independent of the hash size, verify that the length
of the comment is equal to that of any supported hash algorithm.

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

get-tar-commit-id: parse comment recordRene Scharfe Tue, 19 Feb 2019 00:05:18 +0000 (00:05 +0000)

get-tar-commit-id: parse comment record

Parse pax comment records properly and get rid of magic numbers for
acceptable comment length. This simplifies a later change to handle
longer hashes.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

hash: add a function to lookup hash algorithm by lengthbrian m. carlson Tue, 19 Feb 2019 00:05:17 +0000 (00:05 +0000)

hash: add a function to lookup hash algorithm by length

There are some cases, such as the dumb HTTP transport and bundles, where
we can only determine the hash algorithm in use by the length of the
object IDs. Provide a function that looks up the algorithm by length.

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

remote-curl: make hash size independentbrian m. carlson Tue, 19 Feb 2019 00:05:16 +0000 (00:05 +0000)

remote-curl: make hash size independent

Change one hard-coded use of the constant 40 to a reference to
the_hash_algo. In addition, switch a use of get_oid_hex to
parse_oid_hex to avoid the need to use a constant.

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

http: replace sha1_to_hexbrian m. carlson Tue, 19 Feb 2019 00:05:15 +0000 (00:05 +0000)

http: replace sha1_to_hex

Since sha1_to_hex is limited to SHA-1, replace it with hash_to_hex.

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

http: compute hash of downloaded objects using the_hash... brian m. carlson Tue, 19 Feb 2019 00:05:14 +0000 (00:05 +0000)

http: compute hash of downloaded objects using the_hash_algo

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

http: replace hard-coded constant with the_hash_algobrian m. carlson Tue, 19 Feb 2019 00:05:13 +0000 (00:05 +0000)

http: replace hard-coded constant with the_hash_algo

Replace a hard-coded 40 with a reference to the_hash_algo.

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

http-walker: replace sha1_to_hexbrian m. carlson Tue, 19 Feb 2019 00:05:12 +0000 (00:05 +0000)

http-walker: replace sha1_to_hex

Since sha1_to_hex is limited to SHA-1, replace the uses of it in this
file with hash_to_hex. Rename several variables accordingly to reflect
that they are no longer limited to SHA-1.

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

http-push: remove remaining uses of sha1_to_hexbrian m. carlson Tue, 19 Feb 2019 00:05:11 +0000 (00:05 +0000)

http-push: remove remaining uses of sha1_to_hex

Since sha1_to_hex is limited to SHA-1, switch all remaining uses of it
in this file to hash_to_hex or oid_to_hex. Modify update_remote to take
a pointer to struct object_id, and since we don't modify that parameter
in the function, set it to be const as well.

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

http-backend: allow 64-character hex namesbrian m. carlson Tue, 19 Feb 2019 00:05:10 +0000 (00:05 +0000)

http-backend: allow 64-character hex names

In an SHA-256-backed repository using the http-backend handler for dumb
protocol clients, it may be necessary to access the raw packs using
their full SHA-256-specified names. Allow packs and loose objects to be
accessed using their full SHA-256-specified 64-character hex names.

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

http-push: convert to use the_hash_algobrian m. carlson Tue, 19 Feb 2019 00:05:09 +0000 (00:05 +0000)

http-push: convert to use the_hash_algo

Switch the lock token code to use the_hash_algo and increase its buffers
to be allocated using GIT_MAX_* constants. Update the parsing of object
paths to use the_hash_algo as well.

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

builtin/pull: make hash-size independentbrian m. carlson Tue, 19 Feb 2019 00:05:08 +0000 (00:05 +0000)

builtin/pull: make hash-size independent

Instead of using get_oid_hex and GIT_SHA1_HEXSZ, use parse_oid_hex to
avoid the need for a constant and simplify the code.

Additionally, fix some comments to refer to object IDs instead of SHA-1
and update a constant used to provide an allocation hint.

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

builtin/am: make hash size independentbrian m. carlson Tue, 19 Feb 2019 00:05:07 +0000 (00:05 +0000)

builtin/am: make hash size independent

Instead of using GIT_SHA1_HEXSZ, switch to using the_hash_algo and
parse_oid_hex to parse the lines involved in rebasing notes.

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

fast-import: replace sha1_to_hexbrian m. carlson Tue, 19 Feb 2019 00:05:06 +0000 (00:05 +0000)

fast-import: replace sha1_to_hex

Replace the uses of sha1_to_hex in this function with hash_to_hex to
allow the use of SHA-256 as well. Rename a variable since it is no
longer limited to SHA-1.

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

fast-import: make hash-size independentbrian m. carlson Tue, 19 Feb 2019 00:05:05 +0000 (00:05 +0000)

fast-import: make hash-size independent

Replace several uses of GIT_SHA1_HEXSZ and 40-based constants with
references to the_hash_algo. Update the note handling code here to
compute path sizes based on GIT_MAX_RAWSZ as well.

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

builtin/name-rev: make hash-size independentbrian m. carlson Tue, 19 Feb 2019 00:05:04 +0000 (00:05 +0000)

builtin/name-rev: make hash-size independent

Use the_hash_algo when parsing instead of GIT_SHA1_HEXSZ so that this
function works with any size hash. Rename the variable forty to
counter, as this is a better name and is independent of the hash size.

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

object-store: rename and expand packed_git's sha1 memberbrian m. carlson Tue, 19 Feb 2019 00:05:03 +0000 (00:05 +0000)

object-store: rename and expand packed_git's sha1 member

This member is used to represent the pack checksum of the pack in
question. Expand this member to be GIT_MAX_RAWSZ bytes in length so it
works with longer hashes and rename it to be "hash" instead of "sha1".
This transformation was made with a change to the definition and the
following semantic patch:

@@
struct packed_git *E1;
@@
- E1->sha1
+ E1->hash

@@
struct packed_git E1;
@@
- E1.sha1
+ E1.hash

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

notes: replace sha1_to_hexbrian m. carlson Tue, 19 Feb 2019 00:05:02 +0000 (00:05 +0000)

notes: replace sha1_to_hex

Replace the uses of sha1_to_hex in this function with hash_to_hex to
allow the use of SHA-256 as well. Rename some variables since this code
is no longer limited to SHA-1.

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

notes: make hash size independentbrian m. carlson Tue, 19 Feb 2019 00:05:01 +0000 (00:05 +0000)

notes: make hash size independent

Switch out various uses of the GIT_SHA1_* constants with GIT_MAX_*
constants for allocations and the_hash_algo for general parsing. Update
a comment to no longer be SHA-1 specific.

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

notes-merge: switch to use the_hash_algobrian m. carlson Tue, 19 Feb 2019 00:05:00 +0000 (00:05 +0000)

notes-merge: switch to use the_hash_algo

Switch from using GIT_SHA1_HEXSZ to GIT_MAX_HEXSZ and the_hash_algo so
that the code works with any hash algorithm.

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

submodule: avoid hard-coded constantsbrian m. carlson Tue, 19 Feb 2019 00:04:59 +0000 (00:04 +0000)

submodule: avoid hard-coded constants

Instead of using hard-coded 40-based constants, express these values in
terms of the_hash_algo and GIT_MAX_HEXSZ.

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

pack-bitmap: switch hash tables to use struct object_idbrian m. carlson Tue, 19 Feb 2019 00:04:58 +0000 (00:04 +0000)

pack-bitmap: switch hash tables to use struct object_id

Instead of storing unsigned char pointers in the hash tables, switch to
storing instances of struct object_id. Update several internal functions
and one external function to take pointers to struct object_id.

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

pack-bitmap: switch hard-coded constants to the_hash_algobrian m. carlson Tue, 19 Feb 2019 00:04:57 +0000 (00:04 +0000)

pack-bitmap: switch hard-coded constants to the_hash_algo

Switch two hard-coded uses of 20 to references to the_hash_algo.

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

pack-bitmap: replace sha1_to_hexbrian m. carlson Tue, 19 Feb 2019 00:04:56 +0000 (00:04 +0000)

pack-bitmap: replace sha1_to_hex

Replace the uses of sha1_to_hex in the pack bitmap code with hash_to_hex
to allow the use of SHA-256 as well. Rename a few variables since they
are no longer limited to SHA-1.

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

pack-bitmap: convert struct stored_bitmap to object_idbrian m. carlson Tue, 19 Feb 2019 00:04:55 +0000 (00:04 +0000)

pack-bitmap: convert struct stored_bitmap to object_id

Convert struct stored_bitmap to use struct object_id.

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

pack-bitmap: make bitmap header handling hash agnosticbrian m. carlson Tue, 19 Feb 2019 00:04:54 +0000 (00:04 +0000)

pack-bitmap: make bitmap header handling hash agnostic

Increase the checksum field in struct bitmap_disk_header to be
GIT_MAX_RAWSZ bytes in length and ensure that we hash the proper number
of bytes out when computing the bitmap checksum.

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

khash: move oid hash table definitionbrian m. carlson Tue, 19 Feb 2019 00:04:53 +0000 (00:04 +0000)

khash: move oid hash table definition

Move the oid khash table definition to khash.h and define a typedef for
it, similar to the one we have for unsigned char pointers. Define
variants that are maps as well.

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

t/lib-submodule-update: use appropriate length constantbrian m. carlson Tue, 19 Feb 2019 00:04:52 +0000 (00:04 +0000)

t/lib-submodule-update: use appropriate length constant

Instead of using a specific invalid hard-coded object ID, produce one
of the appropriate length by using test_oid.

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

am: avoid diff_opt_parse()Nguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:14 +0000 (15:20 +0700)

am: avoid diff_opt_parse()

diff_opt_parse() is a heavy hammer to just set diff filter. But it's
the only way because of the diff_status_letters[] mapping. Add a new
API to set diff filter and use it in git-am. diff_opt_parse()'s only
remaining call site in revision.c will be gone soon and having it here
just because of git-am does not make sense.

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

diff --no-index: use parse_options() instead of diff_op... Nguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:13 +0000 (15:20 +0700)

diff --no-index: use parse_options() instead of diff_opt_parse()

While at there, move exit() back to the caller. It's easier to see the
flow that way than burying it in diff-no-index.c

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

range-diff: use parse_options() instead of diff_opt_parse()Nguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:12 +0000 (15:20 +0700)

range-diff: use parse_options() instead of diff_opt_parse()

Diff's internal option parsing is now done with 'struct option', which
makes it possible to combine all diff options to range-diff and parse
everything all at once. Parsing code becomes simpler, and we get a
looong 'git range-diff -h'

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

diff.c: allow --no-color-moved-wsNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:11 +0000 (15:20 +0700)

diff.c: allow --no-color-moved-ws

This option is added in commit b73bcbac4a (diff: allow
--no-color-moved-ws - 2018-11-23) in pw/diff-color-moved-ws-fix. To ease
merge conflict resolution, re-implement the option handling here so that
the conflict could be resolved by taking this side of change.

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

diff-parseopt: convert --color-moved-wsNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:10 +0000 (15:20 +0700)

diff-parseopt: convert --color-moved-ws

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

diff-parseopt: convert --[no-]color-movedNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:09 +0000 (15:20 +0700)

diff-parseopt: convert --[no-]color-moved

Mark one more string for translation while at there

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

diff-parseopt: convert --inter-hunk-contextNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:08 +0000 (15:20 +0700)

diff-parseopt: convert --inter-hunk-context

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

diff-parseopt: convert --no-prefixNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:07 +0000 (15:20 +0700)

diff-parseopt: convert --no-prefix

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

diff-parseopt: convert --line-prefixNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:06 +0000 (15:20 +0700)

diff-parseopt: convert --line-prefix

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

diff-parseopt: convert --[src|dst]-prefixNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:05 +0000 (15:20 +0700)

diff-parseopt: convert --[src|dst]-prefix

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

diff-parseopt: convert --[no-]abbrevNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:04 +0000 (15:20 +0700)

diff-parseopt: convert --[no-]abbrev

OPT__ABBREV() has the same behavior as the deleted code with one
difference: it does check for valid number and error out if not. And the
'40' change is self explanatory.

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

diff-parseopt: convert --diff-filterNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:03 +0000 (15:20 +0700)

diff-parseopt: convert --diff-filter

While at it, mark one more string for translation

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

diff-parseopt: convert --find-objectNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:02 +0000 (15:20 +0700)

diff-parseopt: convert --find-object

While at it, mark one more string for translation.

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

diff-parseopt: convert -ONguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:01 +0000 (15:20 +0700)

diff-parseopt: convert -O

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

diff-parseopt: convert --pickaxe-all|--pickaxe-regexNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:20:00 +0000 (15:20 +0700)

diff-parseopt: convert --pickaxe-all|--pickaxe-regex

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

diff-parseopt: convert -S|-GNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:19:59 +0000 (15:19 +0700)

diff-parseopt: convert -S|-G

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

diff-parseopt: convert -lNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:19:58 +0000 (15:19 +0700)

diff-parseopt: convert -l

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

diff-parseopt: convert -zNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:19:57 +0000 (15:19 +0700)

diff-parseopt: convert -z

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

diff-parseopt: convert --ita-[in]visible-in-indexNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:19:56 +0000 (15:19 +0700)

diff-parseopt: convert --ita-[in]visible-in-index

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

diff-parseopt: convert --ws-error-highlightNguyễn Thái Ngọc Duy Sun, 24 Mar 2019 08:19:55 +0000 (15:19 +0700)

diff-parseopt: convert --ws-error-highlight

Mark one more string for translation while at there.

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