git.git
6 years agot3432: test for --no-ff's interaction with fast-forward
Ævar Arnfjörð Bjarmason [Tue, 27 Aug 2019 05:37:53 +0000 (01:37 -0400)]
t3432: test for --no-ff's interaction with fast-forward

Add more stress tests for the can_fast_forward() case in
rebase.c. These tests are getting rather verbose, but now we can see
under --ff and --no-ff whether we skip work, or whether we're forced
to run the rebase.

These tests aren't supposed to endorse the status quo, just test for
what we're currently doing.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agofast-import: duplicate into history rather than passing ownership
Jeff King [Sun, 25 Aug 2019 08:10:55 +0000 (04:10 -0400)]
fast-import: duplicate into history rather than passing ownership

Fast-import's read_next_command() has somewhat odd memory ownership
semantics for the command_buf strbuf. After reading a command, we copy
the strbuf's pointer (without duplicating the string) into our cmd_hist
array of recent commands. And then when we're about to read a new
command, we clear the strbuf by calling strbuf_detach(), dropping
ownership from the strbuf (leaving the cmd_hist reference as the
remaining owner).

This has a few surprising implications:

  - if the strbuf hasn't been copied into cmd_hist (e.g., because we
    haven't ready any commands yet), then the strbuf_detach() will leak
    the resulting string

  - any modification to command_buf risks invalidating the pointer held
    by cmd_hist. There doesn't seem to be any way to trigger this
    currently (since we tend to modify it only by detaching and reading
    in a new value), but it's subtly dangerous.

  - any pointers into an input string will remain valid as long as
    cmd_hist points to them. So in general, you can point into
    command_buf.buf and call read_next_command() up to 100 times before
    your string is cycled out and freed, leaving you with a dangling
    pointer. This makes it easy to miss bugs during testing, as they
    might trigger only for a sufficiently large commit (e.g., the bug
    fixed in the previous commit).

Instead, let's make a new string to copy the command into the history
array, rather than having dual ownership with the old. Then we can drop
the strbuf_detach() calls entirely, and just reuse the same buffer
within command_buf over and over. We'd normally have to strbuf_reset()
it before using it again, but in both cases here we're using
strbuf_getline(), which does it automatically for us.

This fixes the leak, and it means that even a single call to
read_next_command() will invalidate any held pointers, making it easier
to find bugs. In fact, we can drop the extra input lines added to the
test case by the previous commit, as the unfixed bug would now trigger
just from reading the commit message, even without any modified files in
the commit.

Reported-by: Mike Hommey <redacted>
Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agofast-import: duplicate parsed encoding string
Jeff King [Sun, 25 Aug 2019 08:08:21 +0000 (04:08 -0400)]
fast-import: duplicate parsed encoding string

We read each line of the fast-import stream into the command_buf strbuf.
When reading a commit, we parse a line like "encoding foo" by storing a
pointer to "foo", but not making a copy. We may then read an unbounded
number of other lines (e.g., one for each modified file in the commit),
each of which writes into command_buf.

This works out in practice for small cases, because we hand off
ownership of the heap buffer from command_buf to the cmd_hist array, and
read new commands into a fresh heap buffer. And thus the pointer to
"foo" remains valid as long as there aren't so many intermediate lines
that we end up dropping the original "encoding" line from the history.

But as the test modification shows, if we go over our default of 100
lines, we end up with our encoding string pointing into freed heap
memory. This seems to fail reliably by writing garbage into the output,
but running under ASan definitely detects this as a use-after-free.

We can fix it by duplicating the encoding value, just as we do for other
parsed lines (e.g., an author line ends up in parse_ident, which copies
it to a new string).

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agostatus: mention --skip for revert and cherry-pick
Denton Liu [Tue, 27 Aug 2019 04:45:41 +0000 (00:45 -0400)]
status: mention --skip for revert and cherry-pick

When reverting or cherry-picking, one of the options we can pass the
sequencer is `--skip`. However, unlike rebasing, `--skip` is not
mentioned as a possible option in the status message. Mention it so that
users are more aware of their options.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agocompletion: add --skip for cherry-pick and revert
Denton Liu [Tue, 27 Aug 2019 04:45:39 +0000 (00:45 -0400)]
completion: add --skip for cherry-pick and revert

Even though `--skip` is a valid command-line option for cherry-pick and
revert while they are in progress, it is not completed. Add this missing
option to the completion script.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agocompletion: merge options for cherry-pick and revert
Denton Liu [Tue, 27 Aug 2019 04:45:36 +0000 (00:45 -0400)]
completion: merge options for cherry-pick and revert

Since revert and cherry-pick share the same sequencer code, they should
both accept the same command-line options. Derive the
`__git_cherry_pick_inprogress_options` and
`__git_revert_inprogress_options` variables from
`__git_sequencer_inprogress_options` so that the options aren't
unnecessarily duplicated twice.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3432: distinguish "noop-same" v.s. "work-same" in "same head" tests
Ævar Arnfjörð Bjarmason [Sun, 25 Aug 2019 09:12:02 +0000 (05:12 -0400)]
t3432: distinguish "noop-same" v.s. "work-same" in "same head" tests

Change "same head" introduced in the preceding commit to check whether
the rebase.c code lands in the can_fast_forward() case in, and thus
prints out an "is up to date" and aborts early.

In some of these cases we make it past that and to "rewinding head",
then do a rebase, only to find out there's nothing to change so HEAD
stays at the same OID.

These tests presumed these two cases were the same thing. In terms of
where HEAD ends up they are, but we're not only interested in rebase
semantics, but also whether or not we're needlessly doing work when we
could avoid it entirely.

I'm adding "same" and "diff" here because I'll follow-up and add
--no-ff tests, where some of those will be "diff"-erent, so add the
"diff" code already.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3432: test rebase fast-forward behavior
Denton Liu [Sun, 25 Aug 2019 09:12:00 +0000 (05:12 -0400)]
t3432: test rebase fast-forward behavior

When rebase is run on a branch that can be fast-forwarded, this should
automatically be done. Create test to ensure this behavior happens.

There are some cases that currently don't pass. The first case is where
a feature and master have diverged, running
"git rebase master... master" causes a full rebase to happen even though
a fast-forward should happen.

The second case is when we are doing "git rebase --fork-point" and a
fork-point commit is found. Once again, a full rebase happens even
though a fast-forward should happen.

Mark these cases as failure so we can fix it later.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3431: add rebase --fork-point tests
Denton Liu [Sun, 25 Aug 2019 09:11:57 +0000 (05:11 -0400)]
t3431: add rebase --fork-point tests

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot7300-clean: demonstrate deleting nested repo with an ignored file breakage
SZEDER Gábor [Sun, 25 Aug 2019 18:59:18 +0000 (20:59 +0200)]
t7300-clean: demonstrate deleting nested repo with an ignored file breakage

'git clean -fd' must not delete an untracked directory if it belongs
to a different Git repository or worktree.  Unfortunately, if a
'.gitignore' rule in the outer repository happens to match a file in a
nested repository or worktree, then something goes awry and 'git clean
-fd' does delete the content of the nested repository's worktree
except that ignored file, potentially leading to data loss.

Add a test to 't7300-clean.sh' to demonstrate this breakage.

This issue is a regression introduced in 6b1db43109 (clean: teach
clean -d to preserve ignored paths, 2017-05-23).

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agogrep: refactor and simplify PCRE1 support
Carlo Marcelo Arenas Belón [Sun, 25 Aug 2019 18:22:23 +0000 (11:22 -0700)]
grep: refactor and simplify PCRE1 support

The code used both a macro and a variable to keep track if JIT
support was desired and relied on the fact that a non JIT
enabled library will ignore a request for JIT compilation
(as defined by the second parameter of the call to pcre_study)

Cleanup the multiple levels of macros used and call pcre_study
with the right parameter after JIT support has been confirmed
and unless it was requested to be disabled with NO_LIBPCRE1_JIT

Signed-off-by: Carlo Marcelo Arenas Belón <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agogrep: make sure NO_LIBPCRE1_JIT disable JIT in PCRE1
Carlo Marcelo Arenas Belón [Sun, 25 Aug 2019 18:22:22 +0000 (11:22 -0700)]
grep: make sure NO_LIBPCRE1_JIT disable JIT in PCRE1

e87de7cab4 ("grep: un-break building with PCRE < 8.32", 2017-05-25)
added a restriction for JIT support that is no longer needed after
pcre_jit_exec() calls were removed.

Reorganize the definitions in grep.h so that JIT support could be
detected early and NO_LIBPCRE1_JIT could be used reliably to enforce
JIT doesn't get used.

Signed-off-by: Carlo Marcelo Arenas Belón <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agotrace2: use warning() directly in tr2_dst_malformed_warning()
René Scharfe [Sun, 25 Aug 2019 17:44:10 +0000 (19:44 +0200)]
trace2: use warning() directly in tr2_dst_malformed_warning()

Let warning() format the message instead of using an intermediate strbuf
for that.  This is shorter, easier to read and avoids an allocation.

Signed-off-by: René Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agogrep: use return value of strbuf_detach()
René Scharfe [Sun, 25 Aug 2019 13:26:40 +0000 (15:26 +0200)]
grep: use return value of strbuf_detach()

Append the strbuf buffer only after detaching it.  There is no practical
difference here, as the strbuf is not empty and no strbuf_ function is
called between storing the pointer to the still attached buffer and
calling strbuf_detach(), so that pointer is valid, but make sure to
follow the standard sequence anyway for consistency.

Signed-off-by: René Scharfe <redacted>
Acked-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agolog-tree: always use return value of strbuf_detach()
René Scharfe [Sun, 25 Aug 2019 12:53:26 +0000 (14:53 +0200)]
log-tree: always use return value of strbuf_detach()

strbuf_detach() has been returning a pointer to a buffer even for empty
strbufs since 08ad56f3f0 ("strbuf: always return a non-NULL value from
strbuf_detach", 2012-10-18).  Use that feature in show_log() instead of
having it handle empty strbufs specially.

Signed-off-by: René Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agohttp: don't leak urlmatch_config.vars
Mike Hommey [Mon, 26 Aug 2019 07:49:11 +0000 (16:49 +0900)]
http: don't leak urlmatch_config.vars

Signed-off-by: Mike Hommey <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agocommit: free the right buffer in release_commit_memory
Mike Hommey [Mon, 26 Aug 2019 02:01:37 +0000 (11:01 +0900)]
commit: free the right buffer in release_commit_memory

The index field in the commit object is used to find the buffer
corresponding to that commit in the buffer_slab. Resetting it first
means free_commit_buffer is not going to free the right buffer.

Signed-off-by: Mike Hommey <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agopath: add a function to check for path suffix
brian m. carlson [Sun, 25 Aug 2019 23:33:39 +0000 (23:33 +0000)]
path: add a function to check for path suffix

We have a function to strip the path suffix from a commit, but we don't
have one to check for a path suffix. For a plain filename, we can use
basename, but that requires an allocation, since POSIX allows it to
modify its argument. Refactor strip_path_suffix into a helper function
and a new function, ends_with_path_components, to meet this need.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobanned.h: fix vsprintf()'s ban message
Taylor Blau [Sun, 25 Aug 2019 19:42:13 +0000 (15:42 -0400)]
banned.h: fix vsprintf()'s ban message

In cc8fdaee1e (banned.h: mark sprintf() as banned, 2018-07-24), both
'sprintf()' and 'vsprintf()' were marked as banned functions. The
non-variadic macro to ban 'vsprintf' has a typo which says that
'sprintf', not 'vsprintf' is banned. The variadic version does not have
the same typo.

Fix this by updating the explicit form of 'vsprintf' as the banned
version of itself, not 'sprintf'.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agonotes: avoid potential use-after-free during insertion
Jeff King [Sun, 25 Aug 2019 07:19:51 +0000 (03:19 -0400)]
notes: avoid potential use-after-free during insertion

The note_tree_insert() function may free the leaf_node struct we pass in
(e.g., if it's a duplicate, or if it needs to be combined with an
existing note).

Most callers are happy with this, as they assume that ownership of the
struct is handed off. But in load_subtree(), if we see an error we'll
use the handed-off struct's key_oid to generate the die() message,
potentially accessing freed memory.

We can easily fix this by instead using the original oid that we copied
into the leaf_node struct.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agonotes: avoid leaking duplicate entries
Mike Hommey [Sun, 25 Aug 2019 05:18:18 +0000 (14:18 +0900)]
notes: avoid leaking duplicate entries

When add_note is called multiple times with the same key/value pair, the
leaf_node it creates is leaked by notes_tree_insert.

Signed-off-by: Mike Hommey <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomingw: fix launching of externals from Unicode paths
Adam Roben [Sat, 24 Aug 2019 22:38:56 +0000 (15:38 -0700)]
mingw: fix launching of externals from Unicode paths

If Git were installed in a path containing non-ASCII characters,
commands such as `git am` and `git submodule`, which are implemented as
externals, would fail to launch with the following error:

> fatal: 'am' appears to be a git command, but we were not
> able to execute it. Maybe git-am is broken?

This was due to lookup_prog not being Unicode-aware. It was somehow
missed in 85faec9d3a (Win32: Unicode file name support (except dirent),
2012-03-15).

Note that the only problem in this function was calling
`GetFileAttributes()` instead of `GetFileAttributesW()`. The calls to
`access()` were fine because `access()` is a macro which resolves to
`mingw_access()`, which already handles Unicode correctly. But
`lookup_prog()` was changed to use `_waccess()` directly so that we only
convert the path to UTF-16 once.

To make things work correctly, we have to maintain UTF-8 and UTF-16
versions in tandem in `lookup_prog()`.

Signed-off-by: Adam Roben <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosetup_git_directory(): handle UNC root paths correctly
Johannes Schindelin [Sat, 24 Aug 2019 22:10:46 +0000 (15:10 -0700)]
setup_git_directory(): handle UNC root paths correctly

When working in the root directory of a file share (this is only
possible in Git Bash and Powershell, but not in CMD), the current
directory is reported without a trailing slash.

This is different from Unix and standard Windows directories: both / and
C:\ are reported with a trailing slash as current directories.

If a Git worktree is located there, Git is not quite prepared for that:
while it does manage to find the .git directory/file, it returns as
length of the top-level directory's path *one more* than the length of
the current directory, and setup_git_directory_gently() would then
return an undefined string as prefix.

In practice, this undefined string usually points to NUL bytes, and does
not cause much harm. Under rare circumstances that are really involved
to reproduce (and not reliably so), the reported prefix could be a
suffix string of Git's exec path, though.

A careful analysis determined that this bug is unlikely to be
exploitable, therefore we mark this as a regular bug fix.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoFix .git/ discovery at the root of UNC shares
Johannes Schindelin [Sat, 24 Aug 2019 22:10:45 +0000 (15:10 -0700)]
Fix .git/ discovery at the root of UNC shares

A very common assumption in Git's source code base is that
offset_1st_component() returns either 0 for relative paths, or 1 for
absolute paths that start with a slash. In other words, the return value
is either 0 or points just after the dir separator.

This assumption is not fulfilled when calling offset_1st_component()
e.g. on UNC paths on Windows, e.g. "//my-server/my-share". In this case,
offset_1st_component() returns the length of the entire string (which is
correct, because stripping the last "component" would not result in a
valid directory), yet the return value still does not point just after a
dir separator.

This assumption is most prominently seen in the
setup_git_directory_gently_1() function, where we want to append a
".git" component and simply assume that there is already a dir
separator. In the UNC example given above, this assumption is incorrect.

As a consequence, Git will fail to handle a worktree at the top of a UNC
share correctly.

Let's fix this by adding a dir separator specifically for that case: we
found that there is no first component in the path and it does not end
in a dir separator? Then add it.

This fixes https://github.com/git-for-windows/git/issues/1320

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosetup_git_directory(): handle UNC paths correctly
Johannes Schindelin [Sat, 24 Aug 2019 22:10:44 +0000 (15:10 -0700)]
setup_git_directory(): handle UNC paths correctly

The first offset in a UNC path is not the host name, but the folder name after that.

This fixes https://github.com/git-for-windows/git/issues/1181

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomingw: support UNC in git clone file://server/share/repo
Torsten Bögershausen [Sat, 24 Aug 2019 22:07:59 +0000 (15:07 -0700)]
mingw: support UNC in git clone file://server/share/repo

Extend the parser to accept file://server/share/repo in the way that
Windows users expect it to be parsed who are used to referring to file
shares by UNC paths of the form \\server\share\folder.

[jes: tightened check to avoid handling file://C:/some/path as a UNC
path.]

This closes https://github.com/git-for-windows/git/issues/1264.

Signed-off-by: Torsten Bögershausen <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot4009: make hash size independent
brian m. carlson [Mon, 26 Aug 2019 01:43:44 +0000 (01:43 +0000)]
t4009: make hash size independent

Instead of hard-coding object IDs, compute them and use those in the
comparison.  Note that the comparison code ignores the actual object
IDs, but does check that they're the right size, so computing them is
the easiest way to ensure that they are.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot4002: make hash independent
brian m. carlson [Mon, 26 Aug 2019 01:43:43 +0000 (01:43 +0000)]
t4002: make hash independent

Factor out the hard-coded object IDs and use test_oid to provide values
for both SHA-1 and SHA-256.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot4000: make hash size independent
brian m. carlson [Mon, 26 Aug 2019 01:43:42 +0000 (01:43 +0000)]
t4000: make hash size independent

Use $ZERO_OID instead of hard-coding a fixed size all-zeros object ID.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3903: abstract away SHA-1-specific constants
brian m. carlson [Mon, 26 Aug 2019 01:43:41 +0000 (01:43 +0000)]
t3903: abstract away SHA-1-specific constants

Abstract away the SHA-1-specific constants by sanitizing diff output to
remove the index lines, since it's clear from the assertions in question
that we are not interested in the specific object IDs.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agogit-gui: return early when patch fails to apply
Pratyush Yadav [Sun, 25 Aug 2019 22:53:13 +0000 (04:23 +0530)]
git-gui: return early when patch fails to apply

In the procedure apply_or_revert_range_or_line, if the patch does not
apply successfully, a dialog is shown, but execution proceeds after
that. Instead, return early on error so the parts that come after this
don't work on top of an error state.

Signed-off-by: Pratyush Yadav <redacted>
6 years agogit-gui: allow reverting selected hunk
Pratyush Yadav [Sat, 17 Aug 2019 18:31:43 +0000 (00:01 +0530)]
git-gui: allow reverting selected hunk

Just like the user can select a hunk to stage or unstage, add the
ability to revert hunks.

Signed-off-by: Pratyush Yadav <redacted>
6 years agogit-gui: allow reverting selected lines
Pratyush Yadav [Sun, 25 Aug 2019 20:05:27 +0000 (01:35 +0530)]
git-gui: allow reverting selected lines

Just like the user can select lines to stage or unstage, add the
ability to revert selected lines.

Signed-off-by: Pratyush Yadav <redacted>
6 years agotransport: teach all vtables to allow fetch first
Jonathan Tan [Wed, 21 Aug 2019 22:20:10 +0000 (15:20 -0700)]
transport: teach all vtables to allow fetch first

The only transport that does not allow fetch() to be called before
get_refs_list() is the bundle transport. Clean up the code by teaching
the bundle transport the ability to do this, and removing support for
transports that don't support this order of invocation.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agotransport-helper: skip ls-refs if unnecessary
Jonathan Tan [Wed, 21 Aug 2019 22:20:09 +0000 (15:20 -0700)]
transport-helper: skip ls-refs if unnecessary

Commit e70a3030e7 ("fetch: do not list refs if fetching only hashes",
2018-10-07) and its ancestors taught Git, as an optimization, to skip
the ls-refs step when it is not necessary during a protocol v2 fetch
(for example, when lazy fetching a missing object in a partial clone, or
when running "git fetch --no-tags <remote> <SHA-1>"). But that was only
done for natively supported protocols; in particular, HTTP was not
supported.

Teach Git to skip ls-refs when using remote helpers that support connect
or stateless-connect. To do this, fetch() is made an acceptable entry
point. Because fetch() can now be the first function in the vtable
called, "get_helper(transport);" has to be added to the beginning of
that function to set the transport up (if not yet set up) before
process_connect() is invoked.

When fetch() is called, the transport could be taken over (this happens
if "connect" or "stateless-connect" is successfully run without any
"fallback" response), or not. If the transport is taken over, execution
continues like execution for natively supported protocols
(fetch_refs_via_pack() is executed, which will fetch refs using ls-refs
if needed). If not, the remote helper interface will invoke
get_refs_list() if it hasn't been invoked yet, preserving existing
behavior.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoFirst batch after Git 2.23
Junio C Hamano [Thu, 22 Aug 2019 19:41:04 +0000 (12:41 -0700)]
First batch after Git 2.23

Signed-off-by: Junio C Hamano <redacted>
6 years agoMerge branch 'sg/worktree-remove-errormsg'
Junio C Hamano [Thu, 22 Aug 2019 19:34:12 +0000 (12:34 -0700)]
Merge branch 'sg/worktree-remove-errormsg'

Error message update/clarification.

* sg/worktree-remove-errormsg:
  worktree remove: clarify error message on dirty worktree

6 years agoMerge branch 'en/fast-import-merge-doc'
Junio C Hamano [Thu, 22 Aug 2019 19:34:12 +0000 (12:34 -0700)]
Merge branch 'en/fast-import-merge-doc'

Doc update.

* en/fast-import-merge-doc:
  git-fast-import.txt: clarify that multiple merge commits are allowed

6 years agoMerge branch 'jk/perf-no-dups'
Junio C Hamano [Thu, 22 Aug 2019 19:34:11 +0000 (12:34 -0700)]
Merge branch 'jk/perf-no-dups'

Test & perf scripts must use unique numeric prefix, but a pair
shared the same number, which is fixed here.

* jk/perf-no-dups:
  t/perf: rename duplicate-numbered test script

6 years agoMerge branch 'rs/nedalloc-fixlets'
Junio C Hamano [Thu, 22 Aug 2019 19:34:11 +0000 (12:34 -0700)]
Merge branch 'rs/nedalloc-fixlets'

Compilation fix.

* rs/nedalloc-fixlets:
  nedmalloc: avoid compiler warning about unused value
  nedmalloc: do assignments only after the declaration section

6 years agoMerge branch 'sg/show-failed-test-names'
Junio C Hamano [Thu, 22 Aug 2019 19:34:11 +0000 (12:34 -0700)]
Merge branch 'sg/show-failed-test-names'

The first line of verbose output from each test piece now carries
the test name and number to help scanning with eyeballs.

* sg/show-failed-test-names:
  tests: show the test name and number at the start of verbose output
  t0000-basic: use realistic test script names in the verbose tests

6 years agoMerge branch 'sg/commit-graph-validate'
Junio C Hamano [Thu, 22 Aug 2019 19:34:11 +0000 (12:34 -0700)]
Merge branch 'sg/commit-graph-validate'

The code to write commit-graph over given commit object names has
been made a bit more robust.

* sg/commit-graph-validate:
  commit-graph: error out on invalid commit oids in 'write --stdin-commits'
  commit-graph: turn a group of write-related macro flags into an enum
  t5318-commit-graph: use 'test_expect_code'

6 years agoMerge branch 'vn/restore-empty-ita-corner-case-fix'
Junio C Hamano [Thu, 22 Aug 2019 19:34:11 +0000 (12:34 -0700)]
Merge branch 'vn/restore-empty-ita-corner-case-fix'

"git checkout" and "git restore" to re-populate the index from a
tree-ish (typically HEAD) did not work correctly for a path that
was removed and then added again with the intent-to-add bit, when
the corresponding working tree file was empty.  This has been
corrected.

* vn/restore-empty-ita-corner-case-fix:
  restore: add test for deleted ita files
  checkout.c: unstage empty deleted ita files

6 years agoMerge branch 'sc/pack-refs-deletion-racefix'
Junio C Hamano [Thu, 22 Aug 2019 19:34:10 +0000 (12:34 -0700)]
Merge branch 'sc/pack-refs-deletion-racefix'

"git pack-refs" can lose refs that are created while running, which
is getting corrected.

* sc/pack-refs-deletion-racefix:
  pack-refs: always refresh after taking the lock file

6 years agoMerge branch 'sg/do-not-skip-non-httpd-tests'
Junio C Hamano [Thu, 22 Aug 2019 19:34:10 +0000 (12:34 -0700)]
Merge branch 'sg/do-not-skip-non-httpd-tests'

Test fix.

* sg/do-not-skip-non-httpd-tests:
  t: warn against adding non-httpd-specific tests after sourcing 'lib-httpd'
  t5703: run all non-httpd-specific tests before sourcing 'lib-httpd.sh'
  t5510-fetch: run non-httpd-specific test before sourcing 'lib-httpd.sh'

6 years agoMerge branch 'jk/tree-walk-overflow'
Junio C Hamano [Thu, 22 Aug 2019 19:34:10 +0000 (12:34 -0700)]
Merge branch 'jk/tree-walk-overflow'

Codepaths to walk tree objects have been audited for integer
overflows and hardened.

* jk/tree-walk-overflow:
  tree-walk: harden make_traverse_path() length computations
  tree-walk: add a strbuf wrapper for make_traverse_path()
  tree-walk: accept a raw length for traverse_path_len()
  tree-walk: use size_t consistently
  tree-walk: drop oid from traverse_info
  setup_traverse_info(): stop copying oid

6 years agoMerge branch 'sg/t5510-test-i18ngrep-fix'
Junio C Hamano [Thu, 22 Aug 2019 19:34:10 +0000 (12:34 -0700)]
Merge branch 'sg/t5510-test-i18ngrep-fix'

Test fix.

* sg/t5510-test-i18ngrep-fix:
  t5510-fetch: fix negated 'test_i18ngrep' invocation

6 years agoMerge branch 'mt/grep-submodules-working-tree'
Junio C Hamano [Thu, 22 Aug 2019 19:34:10 +0000 (12:34 -0700)]
Merge branch 'mt/grep-submodules-working-tree'

"git grep --recurse-submodules" that looks at the working tree
files looked at the contents in the index in submodules, instead of
files in the working tree.

* mt/grep-submodules-working-tree:
  grep: fix worktree case in submodules

6 years agot0021: make sure clean filter runs
Thomas Gummerer [Thu, 22 Aug 2019 19:22:40 +0000 (20:22 +0100)]
t0021: make sure clean filter runs

In t0021.15 one of the things we are checking is that the clean filter
is run when checking out empty-branch.  The clean filter needs to be
run to make sure there are no modifications on the file system for the
test.r file, and thus it isn't dangerous to overwrite it.

However in the current test setup it is not always necessary to run
the clean filter, and thus the test sometimes fails, as debug.log
isn't written.

This happens when test.r has an older mtime than the index itself.
That mtime is also recorded as stat data for test.r in the index, and
based on the heuristic we're using for index entries, git correctly
assumes this file is up-to-date.

Usually this test succeeds because the mtime of test.r is the same as
the mtime of the index.  In this case test.r is racily clean, so git
actually checks the contents, for which the clean filter is run.

Fix the test by updating the mtime of test.r, so git is forced to
check the contents of the file, and the clean filter is run as the
test expects.

Signed-off-by: Thomas Gummerer <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoref-filter: initialize empty name or email fields
Mischa POSLAWSKY [Sat, 17 Aug 2019 21:51:07 +0000 (23:51 +0200)]
ref-filter: initialize empty name or email fields

Formatting $(taggername) on headerless tags such as v0.99 in Git
causes a SIGABRT with error "munmap_chunk(): invalid pointer",
because of an oversight in commit f0062d3b74 (ref-filter: free
item->value and item->value->s, 2018-10-19).

Signed-off-by: Mischa POSLAWSKY <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agouserdiff: add a builtin pattern for dts files
Stephen Boyd [Mon, 19 Aug 2019 21:22:43 +0000 (14:22 -0700)]
userdiff: add a builtin pattern for dts files

The Linux kernel receives many patches to the devicetree files each
release. The hunk header for those patches typically show nothing,
making it difficult to figure out what node is being modified without
applying the patch or opening the file and seeking to the context. Let's
add a builtin 'dts' pattern to git so that users can get better diff
output on dts files when they use the diff=dts driver.

The regex has been constructed based on the spec at devicetree.org[1]
and with some help from Johannes Sixt.

[1] https://github.com/devicetree-org/devicetree-specification/releases/latest

Cc: Rob Herring <redacted>
Cc: Frank Rowand <redacted>
Signed-off-by: Stephen Boyd <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot4014: drop unnecessary blank lines from test cases
Denton Liu [Tue, 20 Aug 2019 07:18:46 +0000 (03:18 -0400)]
t4014: drop unnecessary blank lines from test cases

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoline-log: avoid unnecessary full tree diffs
SZEDER Gábor [Wed, 21 Aug 2019 11:04:24 +0000 (13:04 +0200)]
line-log: avoid unnecessary full tree diffs

With rename detection enabled the line-level log is able to trace the
evolution of line ranges across whole-file renames [1].  Alas, to
achieve that it uses the diff machinery very inefficiently, making the
operation very slow [2].  And since rename detection is enabled by
default, the line-level log is very slow by default.

When the line-level log processes a commit with rename detection
enabled, it currently does the following (see queue_diffs()):

  1. Computes a full tree diff between the commit and (one of) its
     parent(s), i.e. invokes diff_tree_oid() with an empty
     'diffopt->pathspec'.
  2. Checks whether any paths in the line ranges were modified.
  3. Checks whether any modified paths in the line ranges are missing
     in the parent commit's tree.
  4. If there is such a missing path, then calls diffcore_std() to
     figure out whether the path was indeed renamed based on the
     previously computed full tree diff.
  5. Continues doing stuff that are unrelated to the slowness.

So basically the line-level log computes a full tree diff for each
commit-parent pair in step (1) to be used for rename detection in step
(4) in the off chance that an interesting path is missing from the
parent.

Avoid these expensive and mostly unnecessary full tree diffs by
limiting the diffs to paths in the line ranges.  This is much cheaper,
and makes step (2) unnecessary.  If it turns out that an interesting
path is missing from the parent, then fall back and compute a full
tree diff, so the rename detection will still work.

Care must be taken when to update the pathspec used to limit the diff
in case of renames.  A path might be renamed on one branch and
modified on several parallel running branches, and while processing
commits on these branches the line-level log might have to alternate
between looking at a path's new and old name.  However, at any one
time there is only a single 'diffopt->pathspec'.

So add a step (0) to the above to ensure that the paths in the
pathspec match the paths in the line ranges associated with the
currently processed commit, and re-parse the pathspec from the paths
in the line ranges if they differ.

The new test cases include a specially crafted piece of history with
two merged branches and two files, where each branch modifies both
files, renames on of them, and then modifies both again.  Then two
separate 'git log -L' invocations check the line-level log of each of
those two files, which ensures that at least one of those invocations
have to do that back-and-forth between the file's old and new name (no
matter which branch is traversed first).  't/t4211-line-log.sh'
already contains two tests involving renames, they don't don't trigger
this back-and-forth.

Avoiding these unnecessary full tree diffs can have huge impact on
performance, especially in big repositories with big trees and mergy
history.  Tracing the evolution of a function through the whole
history:

  # git.git
  $ time git --no-pager log -L:read_alternate_refs:sha1-file.c v2.23.0

  Before:

    real    0m8.874s
    user    0m8.816s
    sys     0m0.057s

  After:

    real    0m2.516s
    user    0m2.456s
    sys     0m0.060s

  # linux.git
  $ time ~/src/git/git --no-pager log \
    -L:build_restore_work_registers:arch/mips/mm/tlbex.c v5.2

  Before:

    real    3m50.033s
    user    3m48.041s
    sys     0m0.300s

  After:

    real    0m2.599s
    user    0m2.466s
    sys     0m0.157s

That's just over 88x speedup.

[1] Line-level log's rename following is quite similar to 'git log
    --follow path', with the notable differences that it does handle
    multiple paths at once as well, and that it doesn't show the
    commit performing the rename if it's an exact rename.

[2] This slowness might not have been apparent initially, because back
    when the line-level log feature was introduced rename detection
    was not yet enabled by default; 12da1d1f6f (Implement line-history
    search (git log -L), 2013-03-28) and 5404c116aa (diff: activate
    diff.renames by default, 2016-02-25).

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoline-log: extract pathspec parsing from line ranges into a helper function
SZEDER Gábor [Wed, 21 Aug 2019 11:04:23 +0000 (13:04 +0200)]
line-log: extract pathspec parsing from line ranges into a helper function

A helper function to parse the paths involved in the line ranges and
to turn them into a pathspec will be useful in the next patch.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agodiff: skip GITLINK when lazy fetching missing objs
Jonathan Tan [Tue, 20 Aug 2019 20:53:20 +0000 (13:53 -0700)]
diff: skip GITLINK when lazy fetching missing objs

In 7fbbcb21b1 ("diff: batch fetching of missing blobs", 2019-04-08),
diff was taught to batch the fetching of missing objects when operating
on a partial clone, but was not taught to refrain from fetching
GITLINKs. Teach diff to check if an object is a GITLINK before including
it in the set to be fetched.

(As stated in the commit message of that commit, unpack-trees was also
taught a similar thing prior, but unpack-trees correctly checks for
GITLINK before including objects in the set to be fetched.)

Signed-off-by: Junio C Hamano <redacted>
6 years agosha1-name: make sort_ambiguous_oid_array() thread-safe
René Scharfe [Tue, 20 Aug 2019 18:49:12 +0000 (20:49 +0200)]
sha1-name: make sort_ambiguous_oid_array() thread-safe

Use QSORT_S instead of QSORT, which allows passing the repository
pointer to the comparison function without using a static variable.

Signed-off-by: René Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoparseopt: move definition of enum parse_opt_result up
René Scharfe [Tue, 20 Aug 2019 18:49:07 +0000 (20:49 +0200)]
parseopt: move definition of enum parse_opt_result up

Define enum parse_opt_result before using it in a typedef.  This avoids
the following compiler warning:

   ./parse-options.h:53:14: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic]
   typedef enum parse_opt_result parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,
                ^

While GCC and Clang both accept such a forward reference by default,
other compilers might be less forgiving.

Signed-off-by: René Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agopackfile.h: drop extern from function declaration
Denton Liu [Mon, 19 Aug 2019 06:26:19 +0000 (02:26 -0400)]
packfile.h: drop extern from function declaration

In 336226c259 (packfile.h: drop extern from function declarations,
2019-04-05), `extern` was removed from function declarations because
it's redundant. However, in 8434e85d5f (repack: refactor pack deletion
for future use, 2019-06-10), an `extern` was mistakenly included.

Remove this spurious `extern`.

Signed-off-by: Denton Liu <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3800: make hash-size independent
brian m. carlson [Sun, 18 Aug 2019 19:16:42 +0000 (19:16 +0000)]
t3800: make hash-size independent

Replace references to several hard-coded object IDs with a variable
referring to the generated commit.  Avoid matching on exact character
positions, which will be different depending on the hash in use.  In the
test for a valid object ID, use an obviously invalid one from the lookup
table.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3600: make hash size independent
brian m. carlson [Sun, 18 Aug 2019 19:16:41 +0000 (19:16 +0000)]
t3600: make hash size independent

Instead of hard-coding a fixed length invalid object ID in the test,
compute one using the lookup tables.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3506: make hash independent
brian m. carlson [Sun, 18 Aug 2019 19:16:40 +0000 (19:16 +0000)]
t3506: make hash independent

This test uses a hard-coded object ID to ensure that the result of
cherry-pick --ff is correct.  Use test_oid to make this work for both
SHA-1 and SHA-256.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3430: avoid hard-coded object IDs
brian m. carlson [Sun, 18 Aug 2019 19:16:39 +0000 (19:16 +0000)]
t3430: avoid hard-coded object IDs

Compute the object IDs used in the todo list instead of hard-coding
them.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3404: abstract away SHA-1-specific constants
brian m. carlson [Sun, 18 Aug 2019 19:16:38 +0000 (19:16 +0000)]
t3404: abstract away SHA-1-specific constants

Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.  Add a use of $EMPTY_TREE instead of a
hard-coded value.  Remove a comment about hard-coded hashes which is no
longer applicable.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3306: abstract away SHA-1-specific constants
brian m. carlson [Sun, 18 Aug 2019 19:16:37 +0000 (19:16 +0000)]
t3306: abstract away SHA-1-specific constants

Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.  Convert some single-line heredocs into inline
uses of echo now that they can be expressed succinctly.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3305: make hash size independent
brian m. carlson [Sun, 18 Aug 2019 19:16:36 +0000 (19:16 +0000)]
t3305: make hash size independent

Instead of hard-coding 40-character shell patterns, use grep to
determine if all of the paths have either zero or one levels of fanout,
as appropriate.

Note that the final test is implicitly dependent on the hash algorithm.
Depending on the algorithm in use, the fanout may or may not completely
compress.  In its current state, this is not a problem, but it could be
if the hash algorithm changes again.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3301: abstract away SHA-1-specific constants
brian m. carlson [Sun, 18 Aug 2019 19:16:35 +0000 (19:16 +0000)]
t3301: abstract away SHA-1-specific constants

Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.  Move some invocations of test_commit around so
that we can compute the object IDs for these commits.

Compute several object IDs in the tests instead of using hard-coded
values so that the test works with any hash algorithm.  Since the actual
values are sorted by the object ID of the object being annotated, sort
the expected values accordingly as well.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3206: abstract away hash size constants
brian m. carlson [Sun, 18 Aug 2019 19:16:34 +0000 (19:16 +0000)]
t3206: abstract away hash size constants

The various short object IDs in the range-diff output differ between
hash algorithms.  Use test_oid_cache to look up values for both SHA-1
and SHA-256.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agot3201: abstract away SHA-1-specific constants
brian m. carlson [Sun, 18 Aug 2019 19:16:33 +0000 (19:16 +0000)]
t3201: abstract away SHA-1-specific constants

Adjust the test so that it computes variables for object IDs instead of
using hard-coded hashes.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agorepository-layout.txt: correct pluralization of 'object'
Ben Milman [Mon, 19 Aug 2019 21:36:18 +0000 (14:36 -0700)]
repository-layout.txt: correct pluralization of 'object'

In the description of 'objects/pack', 'object' should be
pluralized to match the subject and agree with the
rest of the sentence.

Signed-off-by: Ben Milman <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosequencer: simplify root commit creation
Phillip Wood [Mon, 19 Aug 2019 09:18:23 +0000 (02:18 -0700)]
sequencer: simplify root commit creation

Adapt try_to_commit() to create a new root commit rather than special
casing this in run_git_commit(). This significantly reduces the amount of
special case code for creating the root commit and reduces the number of
commit code paths we have to worry about.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agorebase -i: check for updated todo after squash and reword
Phillip Wood [Mon, 19 Aug 2019 09:18:22 +0000 (02:18 -0700)]
rebase -i: check for updated todo after squash and reword

While a rebase is stopped for the user to edit a commit message it can
be convenient for them to also edit the todo list. The scripted version
of rebase supported this but the C version does not. We already check to
see if the todo list has been updated by an exec command so extend this
to rewords and squashes. It only costs a single stat call to do this so
it should not affect the speed of the rebase (especially as it has just
stopped for the user to edit a message)

Note that for squashes the editor may be opened on a different pick to
the squash itself as we edit the message at the end of a chain fixups
and squashes.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agorebase -i: always update HEAD before rewording
Phillip Wood [Mon, 19 Aug 2019 09:18:21 +0000 (02:18 -0700)]
rebase -i: always update HEAD before rewording

If the user runs git log while rewording a commit it is confusing if
sometimes we're amending the commit that's being reworded and at other
times we're creating a new commit depending on whether we could
fast-forward or not[1]. Fix this inconsistency by always committing the
picked commit and then running 'git commit --amend' to do the reword.

The first commit is performed by the sequencer without forking git
commit and does not impact on the speed of rebase. In a test rewording
100 commits with

    GIT_EDITOR=true GIT_SEQUENCE_EDITOR='sed -i s/pick/reword/' \
../bin-wrappers/git rebase -i --root

and taking the best of three runs the current master took
957ms and with this patch it took 961ms.

This change fixes rewording the new root commit when rearranging commits
with --root.

Note that the new code no longer updates CHERRY_PICK_HEAD after creating
a root commit - I'm not sure why the old code was that creating that ref
after a successful commit, everywhere else it is removed after a
successful commit.

[1] https://public-inbox.org/git/xmqqlfvu4be3.fsf@gitster-ct.c.googlers.com/T/#m133009cb91cf0917bcf667300f061178be56680a

Reported-by: SZEDER Gábor <redacted>
Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agogrep: under --debug, show whether PCRE JIT is enabled
Beat Bolli [Sun, 18 Aug 2019 20:17:27 +0000 (22:17 +0200)]
grep: under --debug, show whether PCRE JIT is enabled

This information is useful and not visible anywhere else, so show it.

Signed-off-by: Beat Bolli <redacted>
Suggested-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agomidx: switch to using the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:27 +0000 (20:04 +0000)]
midx: switch to using the_hash_algo

Instead of hard-coding the hash size, use the_hash_algo to look up the
hash size at runtime.  Remove the #define constant which was used to
hold the hash length, since writing the expression with the_hash_algo
provide enough documentary value on its own.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/show-index: replace sha1_to_hex
brian m. carlson [Sun, 18 Aug 2019 20:04:26 +0000 (20:04 +0000)]
builtin/show-index: replace sha1_to_hex

In this code path, we use sha1_to_hex to display the contents of a v1
pack index.  While we plan to switch to v3 indices for SHA-256, the v1
pack indices still function, so to support both algorithms, switch
sha1_to_hex to hash_to_hex.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agorerere: replace sha1_to_hex
brian m. carlson [Sun, 18 Aug 2019 20:04:25 +0000 (20:04 +0000)]
rerere: 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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/receive-pack: replace sha1_to_hex
brian m. carlson [Sun, 18 Aug 2019 20:04:24 +0000 (20:04 +0000)]
builtin/receive-pack: replace sha1_to_hex

Since sha1_to_hex is limited to SHA-1, replace it with hash_to_hex.
Rename several variables to indicate that they can contain any hash.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/index-pack: replace sha1_to_hex
brian m. carlson [Sun, 18 Aug 2019 20:04:23 +0000 (20:04 +0000)]
builtin/index-pack: replace sha1_to_hex

Since sha1_to_hex is limited to SHA-1, replace it with hash_to_hex so
this code works with other algorithms.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agopackfile: replace sha1_to_hex
brian m. carlson [Sun, 18 Aug 2019 20:04:22 +0000 (20:04 +0000)]
packfile: replace sha1_to_hex

Replace a use of sha1_to_hex with hash_to_hex so that this code works
with a hash algorithm other than SHA-1.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agowt-status: convert struct wt_status to object_id
brian m. carlson [Sun, 18 Aug 2019 20:04:21 +0000 (20:04 +0000)]
wt-status: convert struct wt_status to object_id

Change struct wt_status to use struct object_id instead of an array of
unsigned char.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agocache: remove null_sha1
brian m. carlson [Sun, 18 Aug 2019 20:04:20 +0000 (20:04 +0000)]
cache: remove null_sha1

All of the existing uses of null_sha1 can be converted into uses of
null_oid, so do so.  Remove null_sha1 and is_null_sha1, and define
is_null_oid in terms of null_oid.  This also has the additional benefit
of removing several uses of sha1_to_hex.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/worktree: switch null_sha1 to null_oid
brian m. carlson [Sun, 18 Aug 2019 20:04:19 +0000 (20:04 +0000)]
builtin/worktree: switch null_sha1 to null_oid

Switch the remaining use of null_sha1 to null_oid.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/repack: write object IDs of the proper length
brian m. carlson [Sun, 18 Aug 2019 20:04:18 +0000 (20:04 +0000)]
builtin/repack: write object IDs of the proper length

Use the_hash_algo when calling xwrite with a hex object ID so that the
proper amount of data is written.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agopack-write: use hash_to_hex when writing checksums
brian m. carlson [Sun, 18 Aug 2019 20:04:17 +0000 (20:04 +0000)]
pack-write: use hash_to_hex when writing checksums

Pack checksums always use the current hash algorithm in use, so switch
from sha1_to_hex to hash_to_hex.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosequencer: convert to use the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:16 +0000 (20:04 +0000)]
sequencer: convert to use the_hash_algo

Convert several uses of GIT_SHA1_HEXSZ constants to be references to
the_hash_algo.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobisect: switch to using the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:15 +0000 (20:04 +0000)]
bisect: switch to using the_hash_algo

Instead of using GIT_SHA1_HEXSZ, use the_hash_algo so that the code is
hash size independent.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agosha1-lookup: switch hard-coded constants to the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:14 +0000 (20:04 +0000)]
sha1-lookup: switch hard-coded constants to the_hash_algo

Switch a hard-coded 18 to be a reference to the_hash_algo.  Rename the
sha1 parameter to be called hash instead.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoconfig: use the_hash_algo in abbrev comparison
brian m. carlson [Sun, 18 Aug 2019 20:04:13 +0000 (20:04 +0000)]
config: use the_hash_algo in abbrev comparison

Switch one use of a hard-coded 40 constant to use the_hash_algo.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agocombine-diff: replace GIT_SHA1_HEXSZ with the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:12 +0000 (20:04 +0000)]
combine-diff: replace GIT_SHA1_HEXSZ with the_hash_algo

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobundle: switch to use the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:11 +0000 (20:04 +0000)]
bundle: switch to use the_hash_algo

Switch a use of the constant 40 and a use of GIT_SHA1_HEXSZ to use
the_hash_algo instead.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoconnected: switch GIT_SHA1_HEXSZ to the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:10 +0000 (20:04 +0000)]
connected: switch GIT_SHA1_HEXSZ to the_hash_algo

Switch various uses of GIT_SHA1_HEXSZ to reference the_hash_algo
instead.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoshow-index: switch hard-coded constants to the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:09 +0000 (20:04 +0000)]
show-index: switch hard-coded constants to the_hash_algo

show-index uses a variety of hard-coded constants to enumerate the
values in pack indices.  Switch these hard-coded constants to use
the_hash_algo or GIT_MAX_RAWSZ, as appropriate, and convert one instance
of an unsigned char array to struct object_id.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agoblame: remove needless comparison with GIT_SHA1_HEXSZ
brian m. carlson [Sun, 18 Aug 2019 20:04:08 +0000 (20:04 +0000)]
blame: remove needless comparison with GIT_SHA1_HEXSZ

When faking a working tree commit, we read in lines from MERGE_HEAD into
a strbuf.  Because the strbuf is NUL-terminated and get_oid_hex will
fail if it unexpectedly encounters a NUL, the check for the length of
the line is unnecessary.  There is no optimization benefit from this
case, either, since on failure we call die.  Remove this check, since it
is no longer needed.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/rev-parse: switch to use the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:07 +0000 (20:04 +0000)]
builtin/rev-parse: switch to use the_hash_algo

Switch several hard-coded uses of the constant 40 to references to
the_hash_algo.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/blame: switch uses of GIT_SHA1_HEXSZ to the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:06 +0000 (20:04 +0000)]
builtin/blame: switch uses of GIT_SHA1_HEXSZ to the_hash_algo

Switch several uses of GIT_SHA1_HEXSZ to the_hash_algo.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/receive-pack: switch to use the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:05 +0000 (20:04 +0000)]
builtin/receive-pack: switch to use the_hash_algo

The push cert code uses HMAC-SHA-1 to create a nonce.  This is a secure
use of SHA-1 which is not affected by its collision resistance (or lack
thereof).  However, it makes sense for us to use a better algorithm if
one is available, one which may even be more performant.  Futhermore,
until we have specialized functions for computing the hex value of an
arbitrary function, it simplifies the code greatly to use the same hash
algorithm everywhere.

Switch this code to use GIT_MAX_BLKSZ and the_hash_algo for computing
the push cert nonce, and rename the hmac_sha1 function to simply "hmac".

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agofetch-pack: use parse_oid_hex
brian m. carlson [Sun, 18 Aug 2019 20:04:04 +0000 (20:04 +0000)]
fetch-pack: use parse_oid_hex

Instead of hard-coding constants, use parse_oid_hex to compute a pointer
and use it in further parsing operations.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agopatch-id: convert to use the_hash_algo
brian m. carlson [Sun, 18 Aug 2019 20:04:03 +0000 (20:04 +0000)]
patch-id: convert to use the_hash_algo

Convert the two separate patch-id implementations to use the_hash_algo
in their implementation.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agobuiltin/replace: make hash size independent
brian m. carlson [Sun, 18 Aug 2019 20:04:02 +0000 (20:04 +0000)]
builtin/replace: make hash size independent

Instead of using GIT_SHA1_HEXSZ and hard-coded constants, switch to
using the_hash_algo.

Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 years agopull, fetch: add --set-upstream option
Corentin BOMPARD [Mon, 19 Aug 2019 09:11:20 +0000 (11:11 +0200)]
pull, fetch: add --set-upstream option

Add the --set-upstream option to git pull/fetch
which lets the user set the upstream configuration
(branch.<current-branch-name>.merge and
branch.<current-branch-name>.remote) for the current branch.

A typical use-case is:

    git clone http://example.com/my-public-fork
    git remote add main http://example.com/project-main-repo
    git pull --set-upstream main master

or, instead of the last line:

    git fetch --set-upstream main master
    git merge # or git rebase

This is mostly equivalent to cloning project-main-repo (which sets
upsteam) and then "git remote add" my-public-fork, but may feel more
natural for people using a hosting system which allows forking from
the web UI.

This functionality is analog to "git push --set-upstream".

Signed-off-by: Corentin BOMPARD <redacted>
Signed-off-by: Nathan BERBEZIER <redacted>
Signed-off-by: Pablo CHABANNE <redacted>
Signed-off-by: Matthieu Moy <redacted>
Patch-edited-by: Matthieu Moy <redacted>
Signed-off-by: Junio C Hamano <redacted>
git clone https://git.99rst.org/PROJECT