git.git
5 years agoEleventh batch
Junio C Hamano [Thu, 27 Aug 2020 20:57:13 +0000 (13:57 -0700)]
Eleventh batch

Signed-off-by: Junio C Hamano <redacted>
5 years agoMerge branch 'hn/refs-fetch-head-is-special'
Junio C Hamano [Thu, 27 Aug 2020 21:04:49 +0000 (14:04 -0700)]
Merge branch 'hn/refs-fetch-head-is-special'

The FETCH_HEAD is now always read from the filesystem regardless of
the ref backend in use, as its format is much richer than the
normal refs, and written directly by "git fetch" as a plain file..

* hn/refs-fetch-head-is-special:
  refs: read FETCH_HEAD and MERGE_HEAD generically
  refs: move gitdir into base ref_store
  refs: fix comment about submodule ref_stores
  refs: split off reading loose ref data in separate function

5 years agoMerge branch 'rz/complete-more-options'
Junio C Hamano [Thu, 27 Aug 2020 21:04:49 +0000 (14:04 -0700)]
Merge branch 'rz/complete-more-options'

Command line completion (in contrib/) usually omits redundant,
deprecated and/or dangerous options from its output; it learned to
optionally include all of them.

* rz/complete-more-options:
  completion: add GIT_COMPLETION_SHOW_ALL env var
  parse-options: add --git-completion-helper-all

5 years agoMerge branch 'jk/leakfix'
Junio C Hamano [Thu, 27 Aug 2020 21:04:49 +0000 (14:04 -0700)]
Merge branch 'jk/leakfix'

Code clean-up.

* jk/leakfix:
  submodule--helper: fix leak of core.worktree value
  config: fix leak in git_config_get_expiry_in_days()
  config: drop git_config_get_string_const()
  config: fix leaks from git_config_get_string_const()
  checkout: fix leak of non-existent branch names
  submodule--helper: use strbuf_release() to free strbufs
  clear_pattern_list(): clear embedded hashmaps

5 years agoMerge branch 'en/mem-pool'
Junio C Hamano [Thu, 27 Aug 2020 21:04:48 +0000 (14:04 -0700)]
Merge branch 'en/mem-pool'

API update.

* en/mem-pool:
  mem-pool: use consistent pool variable name
  mem-pool: use more standard initialization and finalization
  mem-pool: add convenience functions for strdup and strndup

5 years agodoc: add documentation for the proc-receive hook
Jiang Xin [Thu, 27 Aug 2020 15:45:51 +0000 (11:45 -0400)]
doc: add documentation for the proc-receive hook

"git receive-pack" that accepts requests by "git push" learned to
outsource some of the ref updates to the new "proc-receive" hook.

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agotransport: parse report options for tracking refs
Jiang Xin [Thu, 27 Aug 2020 15:45:50 +0000 (11:45 -0400)]
transport: parse report options for tracking refs

When pushing a pseudo reference (such as "refs/for/master/topic"), may
create or update one or more references.  The real names of the
references will be stored in the report options.  Parse report options
to create or update remote-tracking branches properly.

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot5411: test updates of remote-tracking branches
Jiang Xin [Thu, 27 Aug 2020 15:45:49 +0000 (11:45 -0400)]
t5411: test updates of remote-tracking branches

In order to test update of remote-tracking branches for special refs,
add new "remote.origin.fetch" settings and test cases.

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoreceive-pack: new config receive.procReceiveRefs
Jiang Xin [Thu, 27 Aug 2020 15:45:48 +0000 (11:45 -0400)]
receive-pack: new config receive.procReceiveRefs

Add a new multi-valued config variable "receive.procReceiveRefs"
for `receive-pack` command, like the follows:

    git config --system --add receive.procReceiveRefs refs/for
    git config --system --add receive.procReceiveRefs refs/drafts

If the specific prefix strings given by the config variables match the
reference names of the commands which are sent from git client to
`receive-pack`, these commands will be executed by an external hook
(named "proc-receive"), instead of the internal `execute_commands`
function.

For example, if it is set to "refs/for", pushing to a reference such as
"refs/for/master" will not create or update reference "refs/for/master",
but may create or update a pull request directly by running the hook
"proc-receive".

Optional modifiers can be provided in the beginning of the value to
filter commands for specific actions: create (a), modify (m),
delete (d). A `!` can be included in the modifiers to negate the
reference prefix entry. E.g.:

    git config --system --add receive.procReceiveRefs ad:refs/heads
    git config --system --add receive.procReceiveRefs !:refs/heads

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodoc: add document for capability report-status-v2
Jiang Xin [Thu, 27 Aug 2020 15:45:47 +0000 (11:45 -0400)]
doc: add document for capability report-status-v2

Add ABNF notation for capability 'report-status-v2' which extends
capability 'report-status' by adding additional option lines.

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoNew capability "report-status-v2" for git-push
Jiang Xin [Thu, 27 Aug 2020 15:45:46 +0000 (11:45 -0400)]
New capability "report-status-v2" for git-push

The new introduced "proc-receive" hook may handle a command for a
pseudo-reference with a zero-old as its old-oid, while the hook may
create or update a reference with different name, different new-oid,
and different old-oid (the reference may exist already with a non-zero
old-oid).  Current "report-status" protocol cannot report the status for
such reference rewrite.

Add new capability "report-status-v2" and new report protocol which is
not backward compatible for report of git-push.

If a user pushes to a pseudo-reference "refs/for/master/topic", and
"receive-pack" creates two new references "refs/changes/23/123/1" and
"refs/changes/24/124/1", for client without the knowledge of
"report-status-v2", "receive-pack" will only send "ok/ng" directives in
the report, such as:

    ok ref/for/master/topic

But for client which has the knowledge of "report-status-v2",
"receive-pack" will use "option" directives to report more attributes
for the reference given by the above "ok/ng" directive.

    ok refs/for/master/topic
    option refname refs/changes/23/123/1
    option new-oid <new-oid>
    ok refs/for/master/topic
    option refname refs/changes/24/124/1
    option new-oid <new-oid>

The client will report two new created references to the end user.

Suggested-by: Junio C Hamano <redacted>
Suggested-by: Jeff King <redacted>
Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoreceive-pack: feed report options to post-receive
Jiang Xin [Thu, 27 Aug 2020 15:45:45 +0000 (11:45 -0400)]
receive-pack: feed report options to post-receive

When commands are fed to the "post-receive" hook, report options will
be parsed and the real old-oid, new-oid, reference name will feed to
the "post-receive" hook.

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoreceive-pack: add new proc-receive hook
Jiang Xin [Thu, 27 Aug 2020 15:45:44 +0000 (11:45 -0400)]
receive-pack: add new proc-receive hook

Git calls an internal `execute_commands` function to handle commands
sent from client to `git-receive-pack`.  Regardless of what references
the user pushes, git creates or updates the corresponding references if
the user has write-permission.  A contributor who has no
write-permission, cannot push to the repository directly.  So, the
contributor has to write commits to an alternate location, and sends
pull request by emails or by other ways.  We call this workflow as a
distributed workflow.

It would be more convenient to work in a centralized workflow like what
Gerrit provided for some cases.  For example, a read-only user who
cannot push to a branch directly can run the following `git push`
command to push commits to a pseudo reference (has a prefix "refs/for/",
not "refs/heads/") to create a code review.

    git push origin \
        HEAD:refs/for/<branch-name>/<session>

The `<branch-name>` in the above example can be as simple as "master",
or a more complicated branch name like "foo/bar".  The `<session>` in
the above example command can be the local branch name of the client
side, such as "my/topic".

We cannot implement a centralized workflow elegantly by using
"pre-receive" + "post-receive", because Git will call the internal
function "execute_commands" to create references (even the special
pseudo reference) between these two hooks.  Even though we can delete
the temporarily created pseudo reference via the "post-receive" hook,
having a temporary reference is not safe for concurrent pushes.

So, add a filter and a new handler to support this kind of workflow.
The filter will check the prefix of the reference name, and if the
command has a special reference name, the filter will turn a specific
field (`run_proc_receive`) on for the command.  Commands with this filed
turned on will be executed by a new handler (a hook named
"proc-receive") instead of the internal `execute_commands` function.
We can use this "proc-receive" command to create pull requests or send
emails for code review.

Suggested by Junio, this "proc-receive" hook reads the commands,
push-options (optional), and send result using a protocol in pkt-line
format.  In the following example, the letter "S" stands for
"receive-pack" and letter "H" stands for the hook.

    # Version and features negotiation.
    S: PKT-LINE(version=1\0push-options atomic...)
    S: flush-pkt
    H: PKT-LINE(version=1\0push-options...)
    H: flush-pkt

    # Send commands from server to the hook.
    S: PKT-LINE(<old-oid> <new-oid> <ref>)
    S: ... ...
    S: flush-pkt
    # Send push-options only if the 'push-options' feature is enabled.
    S: PKT-LINE(push-option)
    S: ... ...
    S: flush-pkt

    # Receive result from the hook.
    # OK, run this command successfully.
    H: PKT-LINE(ok <ref>)
    # NO, I reject it.
    H: PKT-LINE(ng <ref> <reason>)
    # Fall through, let 'receive-pack' to execute it.
    H: PKT-LINE(ok <ref>)
    H: PKT-LINE(option fall-through)
    # OK, but has an alternate reference.  The alternate reference name
    # and other status can be given in options
    H: PKT-LINE(ok <ref>)
    H: PKT-LINE(option refname <refname>)
    H: PKT-LINE(option old-oid <old-oid>)
    H: PKT-LINE(option new-oid <new-oid>)
    H: PKT-LINE(option forced-update)
    H: ... ...
    H: flush-pkt

After receiving a command, the hook will execute the command, and may
create/update different reference.  For example, a command for a pseudo
reference "refs/for/master/topic" may create/update different reference
such as "refs/pull/123/head".  The alternate reference name and other
status are given in option lines.

The list of commands returned from "proc-receive" will replace the
relevant commands that are sent from user to "receive-pack", and
"receive-pack" will continue to run the "execute_commands" function and
other routines.  Finally, the result of the execution of these commands
will be reported to end user.

The reporting function from "receive-pack" to "send-pack" will be
extended in latter commit just like what the "proc-receive" hook reports
to "receive-pack".

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot5411: add basic test cases for proc-receive hook
Jiang Xin [Thu, 27 Aug 2020 15:45:43 +0000 (11:45 -0400)]
t5411: add basic test cases for proc-receive hook

Topic "proc-receive-hook" will change the workflow and output of
git-push. Add some basic test cases in t5411 before introducing the new
topic.

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agotransport: not report a non-head push as a branch
Jiang Xin [Thu, 27 Aug 2020 15:45:42 +0000 (11:45 -0400)]
transport: not report a non-head push as a branch

When pushing a new reference (not a head or tag), report it as a new
reference instead of a new branch.

Signed-off-by: Jiang Xin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot7421: eliminate 'grep' check in t7421.4 for mingw compatibility
Shourya Shukla [Thu, 27 Aug 2020 17:45:01 +0000 (23:15 +0530)]
t7421: eliminate 'grep' check in t7421.4 for mingw compatibility

The 'grep' check in test 4 of t7421 resulted in the failure of t7421 on
Windows due to a different error message

    error: cannot spawn git: No such file or directory

instead of

    fatal: exec 'rev-parse': cd to 'my-subm' failed: No such file or directory

Tighten up the check to compute 'src_abbrev' by guarding the
'verify_submodule_committish()' call using `p->status !='D'`, so that
the former isn't called in case of non-existent submodule directory,
consequently, there is no such error message on any execution
environment. The same need not be implemented for 'dst_abbrev' and is
rather redundant since the conditional 'if (S_ISGITLINK(p->mod_dst))'
already guards the 'verify_submodule_committish()' when we have a
status of 'D'.

Therefore, eliminate the 'grep' check in t7421. Instead, verify the
absence of an error message by doing a 'test_must_be_empty' on the
file containing the error.

Reported-by: Johannes Schindelin <redacted>
Helped-by: Kaartic Sivaraam <redacted>
Mentored-by: Christian Couder <redacted>
Mentored-by: Kaartic Sivaraam <redacted>
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoworktree: add skeleton "repair" command
Eric Sunshine [Thu, 27 Aug 2020 08:21:25 +0000 (04:21 -0400)]
worktree: add skeleton "repair" command

Worktree administrative files can become corrupted or outdated due to
external factors. Although, it is often possible to recover from such
situations by hand-tweaking these files, doing so requires intimate
knowledge of worktree internals. While information necessary to make
such repairs manually can be obtained from git-worktree.txt and
gitrepository-layout.txt, we can assist users more directly by teaching
git-worktree how to repair its administrative files itself (at least to
some extent). Therefore, add a "git worktree repair" command which
attempts to correct common problems which may arise due to factors
beyond Git's control.

At this stage, the "repair" command is a mere skeleton; subsequent
commits will flesh out the functionality.

Signed-off-by: Eric Sunshine <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agopretty-options.txt: fix --no-abbrev-commit description
Sergey Organov [Wed, 26 Aug 2020 14:49:23 +0000 (17:49 +0300)]
pretty-options.txt: fix --no-abbrev-commit description

Description suggested --no-abbrev-commit negates --oneline as well as any other
option that implies --abbrev-commit. Fix it to say that it's --abbrev-commit
that is negated, not the option that implies it.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocredential-cache: use child_process.args
Junio C Hamano [Wed, 26 Aug 2020 21:37:39 +0000 (14:37 -0700)]
credential-cache: use child_process.args

As child_process structure has an embedded strvec args for
formulating the command line, let's use it instead of using
an out-of-line argv[] whose length needs to be maintained
correctly.

Also, when spawning a git subcommand, omit it from the command list
and instead use the .git_cmd bit in the child_process structure.

Signed-off-by: Junio C Hamano <redacted>
5 years agoworktree: fix leak in check_clean_worktree()
Jeff King [Thu, 27 Aug 2020 05:25:04 +0000 (01:25 -0400)]
worktree: fix leak in check_clean_worktree()

We allocate a child_env strvec but never free its memory. Instead, let's
just use the strvec that our child_process struct provides, which is
cleaned up automatically when we run the command.

And while we're moving the initialization of the child_process around,
let's switch it to use the official init function (zero-initializing it
works OK, since strvec is happy enough with that, but it sets a bad
example).

Signed-off-by: Jeff King <redacted>
Reviewed-by: Eric Sunshine <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorun_command: teach API users to use embedded 'args' more
Junio C Hamano [Wed, 26 Aug 2020 22:25:03 +0000 (15:25 -0700)]
run_command: teach API users to use embedded 'args' more

The child_process structure has an embedded strvec for formulating
the command line argument list these days, but code that predates
the wide use of it prepared a separate char *argv[] array and
manually set the child_process.argv pointer point at it.

Teach these old-style code to lose the separate argv[] array.

Signed-off-by: Junio C Hamano <redacted>
5 years agocvsexportcommit: do not run git programs in dashed form
Junio C Hamano [Wed, 26 Aug 2020 19:46:50 +0000 (12:46 -0700)]
cvsexportcommit: do not run git programs in dashed form

This ancient script runs "git-foo" all over the place, which is
OK for a scripted Porcelain in the Git suite, but asking "git" to
dispatch to subcommands is the usual way these days.

Signed-off-by: Junio C Hamano <redacted>
5 years agotransport-helper: do not run git-remote-ext etc. in dashed form
Junio C Hamano [Wed, 26 Aug 2020 19:46:49 +0000 (12:46 -0700)]
transport-helper: do not run git-remote-ext etc. in dashed form

Running it as "git remote-ext" and letting "git" dispatch to
"remote-ext" would just be fine and is more idiomatic.

Signed-off-by: Junio C Hamano <redacted>
5 years agot3436: do not run git-merge-recursive in dashed form
Junio C Hamano [Wed, 26 Aug 2020 21:46:23 +0000 (14:46 -0700)]
t3436: do not run git-merge-recursive in dashed form

Signed-off-by: Junio C Hamano <redacted>
5 years agobuiltin/repack.c: invalidate MIDX only when necessary
Taylor Blau [Tue, 25 Aug 2020 16:04:36 +0000 (12:04 -0400)]
builtin/repack.c: invalidate MIDX only when necessary

In 525e18c04b (midx: clear midx on repack, 2018-07-12), 'git repack'
learned to remove a multi-pack-index file if it added or removed a pack
from the object store.

This mechanism is a little over-eager, since it is only necessary to
drop a MIDX if 'git repack' removes a pack that the MIDX references.
Adding a pack outside of the MIDX does not require invalidating the
MIDX, and likewise for removing a pack the MIDX does not know about.

Teach 'git repack' to check for this by loading the MIDX, and checking
whether the to-be-removed pack is known to the MIDX. This requires a
slightly odd alternation to a test in t5319, which is explained with a
comment. A new test is added to show that the MIDX is left alone when
both packs known to it are marked as .keep, but two packs unknown to it
are removed and combined into one new pack.

Helped-by: Derrick Stolee <redacted>
Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorevision: set rev_input_given in handle_revision_arg()
Jeff King [Wed, 26 Aug 2020 20:13:05 +0000 (16:13 -0400)]
revision: set rev_input_given in handle_revision_arg()

Commit 7ba826290a (revision: add rev_input_given flag, 2017-08-02) added
a flag to rev_info to tell whether we got any revision arguments. As
explained there, this is necessary because some revision arguments may
not produce any pending traversal objects, but should still inhibit
default behaviors (e.g., a glob that matches nothing).

However, it only set the flag in the globbing code, but not for
revisions we get on the command-line or via stdin. This leads to two
problems:

  - the command-line code keeps its own separate got_rev_arg flag; this
    isn't wrong, but it's confusing and an extra maintenance burden

  - even specifically-named rev arguments might end up not adding any
    pending objects: if --ignore-missing is set, then specifying a
    missing object is a noop rather than an error.

And that leads to some user-visible bugs:

  - when deciding whether a default rev like "HEAD" should kick in, we
    check both got_rev_arg and rev_input_given. That means that
    "--ignore-missing $ZERO_OID" works on the command-line (where we set
    got_rev_arg) but not on --stdin (where we don't)

  - when rev-list decides whether it should complain that it wasn't
    given a starting point, it relies on rev_input_given. So it can't
    even get the command-line "--ignore-missing $ZERO_OID" right

Let's consistently set the flag if we got any revision argument. That
lets us clean up the redundant got_rev_arg, and fixes both of those bugs
(but note there are three new tests: we'll confirm the already working
git-log command-line case).

A few implementation notes:

  - conceptually we want to set the flag whenever handle_revision_arg()
    finds an actual revision arg ("handles" it, you might say). But it
    covers a ton of cases with early returns. Rather than annotating
    each one, we just wrap it and use its success exit-code to set the
    flag in one spot.

  - the new rev-list test is in t6018, which is titled to cover globs.
    This isn't exactly a glob, but it made sense to stick it with the
    other tests that handle the "even though we got a rev, we have no
    pending objects" case, which are globs.

  - the tests check for the oid of a missing object, which it's pretty
    clear --ignore-missing should ignore. You can see the same behavior
    with "--ignore-missing a-ref-that-does-not-exist", because
    --ignore-missing treats them both the same. That's perhaps less
    clearly correct, and we may want to change that in the future. But
    the way the code and tests here are written, we'd continue to do the
    right thing even if it does.

Reported-by: Bryan Turner <redacted>
Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorefs: remove lookup cache for reference-transaction hook
Patrick Steinhardt [Tue, 25 Aug 2020 10:35:24 +0000 (12:35 +0200)]
refs: remove lookup cache for reference-transaction hook

When adding the reference-transaction hook, there were concerns about
the performance impact it may have on setups which do not make use of
the new hook at all. After all, it gets executed every time a reftx is
prepared, committed or aborted, which linearly scales with the number of
reference-transactions created per session. And as there are code paths
like `git push` which create a new transaction for each reference to be
updated, this may translate to calling `find_hook()` quite a lot.

To address this concern, a cache was added with the intention to not
repeatedly do negative hook lookups. Turns out this cache caused a
regression, which was fixed via e5256c82e5 (refs: fix interleaving hook
calls with reference-transaction hook, 2020-08-07). In the process of
discussing the fix, we realized that the cache doesn't really help even
in the negative-lookup case. While performance tests added to benchmark
this did show a slight improvement in the 1% range, this really doesn't
warrent having a cache. Furthermore, it's quite flaky, too. E.g. running
it twice in succession produces the following results:

Test                         master            pks-reftx-hook-remove-cache
--------------------------------------------------------------------------
1400.2: update-ref           2.79(2.16+0.74)   2.73(2.12+0.71) -2.2%
1400.3: update-ref --stdin   0.22(0.08+0.14)   0.21(0.08+0.12) -4.5%

Test                         master            pks-reftx-hook-remove-cache
--------------------------------------------------------------------------
1400.2: update-ref           2.70(2.09+0.72)   2.74(2.13+0.71) +1.5%
1400.3: update-ref --stdin   0.21(0.10+0.10)   0.21(0.08+0.13) +0.0%

One case notably absent from those benchmarks is a single executable
searching for the hook hundreds of times, which is exactly the case for
which the negative cache was added. p1400.2 will spawn a new update-ref
for each transaction and p1400.3 only has a single reference-transaction
for all reference updates. So this commit adds a third benchmark, which
performs an non-atomic push of a thousand references. This will create a
new reference transaction per reference. But even for this case, the
negative cache doesn't consistently improve performance:

Test                         master            pks-reftx-hook-remove-cache
--------------------------------------------------------------------------
1400.4: nonatomic push       6.63(6.50+0.13)   6.81(6.67+0.14) +2.7%
1400.4: nonatomic push       6.35(6.21+0.14)   6.39(6.23+0.16) +0.6%
1400.4: nonatomic push       6.43(6.31+0.13)   6.42(6.28+0.15) -0.2%

So let's just remove the cache altogether to simplify the code.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agosubmodule: fix style in function definition
Shourya Shukla [Tue, 25 Aug 2020 11:30:19 +0000 (17:00 +0530)]
submodule: fix style in function definition

The definitions of 'verify_submodule_committish()' and
'print_submodule_summary()' had wrong styling in terms of the asterisk
placement. Amend them.

Also, the warning printed in case of an unexpected file mode printed the
mode in decimal. Print it in octal for enhanced readability.

Reported-by: Kaartic Sivaraam <redacted>
Mentored-by: Christian Couder <redacted>
Mentored-by: Kaartic Sivaraam <redacted>
Helped-by: Junio C Hamano <redacted>
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agosubmodule: eliminate unused parameters from print_submodule_summary()
Shourya Shukla [Tue, 25 Aug 2020 11:30:18 +0000 (17:00 +0530)]
submodule: eliminate unused parameters from print_submodule_summary()

Eliminate the parameters 'missing_{src,dst}' from the
'print_submodule_summary()' function call since they are not used
anywhere in the function.

Reported-by: Jeff King <redacted>
Mentored-by: Christian Couder <redacted>
Mentored-by: Kaartic Sivaraam <redacted>
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agofetch-pack: make packfile URIs work with transfer.fsckobjects
Jonathan Tan [Mon, 17 Aug 2020 19:48:20 +0000 (12:48 -0700)]
fetch-pack: make packfile URIs work with transfer.fsckobjects

When fetching with packfile URIs and transfer.fsckobjects=1, use the
--fsck-objects instead of the --strict flag when invoking index-pack so
that links are not checked, only objects. This is because incomplete
links are expected. (A subsequent connectivity check will be done when
all the packs have been downloaded regardless of whether
transfer.fsckobjects is set.)

This is similar to 98a2ea46c2 ("fetch-pack: do not check links for
partial fetch", 2018-03-15), but for packfile URIs instead of partial
clones.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agofetch-pack: document only_packfile in get_pack()
Jonathan Tan [Mon, 17 Aug 2020 19:48:19 +0000 (12:48 -0700)]
fetch-pack: document only_packfile in get_pack()

dd4b732df7 ("upload-pack: send part of packfile response as uri",
2020-06-10) added the "only_packfile" parameter to get_pack() but did
not document it. Add documentation.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years ago(various): document from_promisor parameter
Jonathan Tan [Mon, 17 Aug 2020 19:48:18 +0000 (12:48 -0700)]
(various): document from_promisor parameter

88e2f9ed8e ("introduce fetch-object: fetch one promisor object",
2017-12-05) plumbed through the from_promisor parameter but did
not document it everywhere it appeared. Add the documentation.

(It also plumbed through the no_dependents parameter, but I have left
that alone because it is being removed in a commit under review [1].)

[1] https://lore.kernel.org/git/e8f16d69089a5011c355d5939c56fa53b7a1eb2d.1597184949.git.jonathantanmy@google.com/

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoTenth batch
Junio C Hamano [Mon, 24 Aug 2020 21:47:38 +0000 (14:47 -0700)]
Tenth batch

Signed-off-by: Junio C Hamano <redacted>
5 years agoMerge branch 'en/dir-clear'
Junio C Hamano [Mon, 24 Aug 2020 21:54:33 +0000 (14:54 -0700)]
Merge branch 'en/dir-clear'

Leakfix with code clean-up.

* en/dir-clear:
  dir: fix problematic API to avoid memory leaks
  dir: make clear_directory() free all relevant memory

5 years agoMerge branch 'rs/patch-id-with-incomplete-line'
Junio C Hamano [Mon, 24 Aug 2020 21:54:33 +0000 (14:54 -0700)]
Merge branch 'rs/patch-id-with-incomplete-line'

The patch-id computation did not ignore the "incomplete last line"
marker like whitespaces.

* rs/patch-id-with-incomplete-line:
  patch-id: ignore newline at end of file in diff_flush_patch_id()

5 years agoMerge branch 'dl/subtree-docs'
Junio C Hamano [Mon, 24 Aug 2020 21:54:33 +0000 (14:54 -0700)]
Merge branch 'dl/subtree-docs'

Doc updates for subtree (in contrib/)

* dl/subtree-docs:
  contrib/subtree: document 'push' does not take '--squash'
  contrib/subtree: fix "unsure" for --message in the document

5 years agoMerge branch 'mt/checkout-entry-dead-code-removal'
Junio C Hamano [Mon, 24 Aug 2020 21:54:32 +0000 (14:54 -0700)]
Merge branch 'mt/checkout-entry-dead-code-removal'

Code clean-up.

* mt/checkout-entry-dead-code-removal:
  checkout_entry(): remove unreachable error() call

5 years agoMerge branch 'jc/no-update-fetch-head'
Junio C Hamano [Mon, 24 Aug 2020 21:54:31 +0000 (14:54 -0700)]
Merge branch 'jc/no-update-fetch-head'

"git fetch" learned --no-write-fetch-head option to avoid writing
the FETCH_HEAD file.

* jc/no-update-fetch-head:
  fetch: optionally allow disabling FETCH_HEAD update

5 years agoMerge branch 'ma/doc-sha-256-is-experimental'
Junio C Hamano [Mon, 24 Aug 2020 21:54:31 +0000 (14:54 -0700)]
Merge branch 'ma/doc-sha-256-is-experimental'

The recent addition of SHA-256 support is marked as experimental in
the documentation.

* ma/doc-sha-256-is-experimental:
  Documentation: mark `--object-format=sha256` as experimental

5 years agoMerge branch 'rs/more-buffered-io'
Junio C Hamano [Mon, 24 Aug 2020 21:54:31 +0000 (14:54 -0700)]
Merge branch 'rs/more-buffered-io'

Use more buffered I/O where we used to call many small write(2)s.

* rs/more-buffered-io:
  upload-pack: use buffered I/O to talk to rev-list
  midx: use buffered I/O to talk to pack-objects
  connected: use buffered I/O to talk to rev-list

5 years agoMerge branch 'jk/unleak-fixes'
Junio C Hamano [Mon, 24 Aug 2020 21:54:30 +0000 (14:54 -0700)]
Merge branch 'jk/unleak-fixes'

Fix some incorrect UNLEAK() annotations.

* jk/unleak-fixes:
  ls-remote: simplify UNLEAK() usage
  stop calling UNLEAK() before die()

5 years agoMerge branch 'en/dir-nonbare-embedded'
Junio C Hamano [Mon, 24 Aug 2020 21:54:29 +0000 (14:54 -0700)]
Merge branch 'en/dir-nonbare-embedded'

"ls-files -o" mishandled the top-level directory of another git
working tree that hangs in the current git working tree.

* en/dir-nonbare-embedded:
  dir: avoid prematurely marking nonbare repositories as matches
  t3000: fix some test description typos

5 years agoMerge branch 'ds/midx-repack-to-batch-size'
Junio C Hamano [Mon, 24 Aug 2020 21:54:28 +0000 (14:54 -0700)]
Merge branch 'ds/midx-repack-to-batch-size'

The "--batch-size" option of "git multi-pack-index repack" command
is now used to specify that very small packfiles are collected into
one until the total size roughly exceeds it.

* ds/midx-repack-to-batch-size:
  multi-pack-index: repack batches below --batch-size

5 years agoMerge branch 'es/init-no-separate-git-dir-in-bare'
Junio C Hamano [Mon, 24 Aug 2020 21:54:28 +0000 (14:54 -0700)]
Merge branch 'es/init-no-separate-git-dir-in-bare'

The purpose of "git init --separate-git-dir" is to initialize a
new project with the repository separate from the working tree,
or, in the case of an existing project, to move the repository
(the .git/ directory) out of the working tree. It does not make
sense to use --separate-git-dir with a bare repository for which
there is no working tree, so disallow its use with bare
repositories.

* es/init-no-separate-git-dir-in-bare:
  init: disallow --separate-git-dir with bare repository

5 years agoindex-pack: make resolve_delta() assume base data
Jonathan Tan [Mon, 24 Aug 2020 19:16:37 +0000 (12:16 -0700)]
index-pack: make resolve_delta() assume base data

A subsequent commit will make the quantum of work smaller, necessitating
more locking. This commit allows resolve_delta() to be called outside
the lock.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoindex-pack: calculate {ref,ofs}_{first,last} early
Jonathan Tan [Mon, 24 Aug 2020 19:16:36 +0000 (12:16 -0700)]
index-pack: calculate {ref,ofs}_{first,last} early

This is refactoring 2 of 2 to simplify struct base_data.

Whenever we make a struct base_data, immediately calculate its delta
children. This eliminates confusion as to when the
{ref,ofs}_{first,last} fields are initialized.

Before this patch, the delta children were calculated at the last
possible moment. This allowed the members of struct base_data to be
populated in any order, superficially useful when we have the object
contents before the struct object_entry. But this makes reasoning about
the state of struct base_data more complicated, hence this patch.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoindex-pack: remove redundant child field
Jonathan Tan [Mon, 24 Aug 2020 19:16:35 +0000 (12:16 -0700)]
index-pack: remove redundant child field

This is refactoring 1 of 2 to simplify struct base_data.

In index-pack, each thread maintains a doubly-linked list of the delta
chain that it is currently processing (the "base" and "child" pointers
in struct base_data). When a thread exceeds the delta base cache limit
and needs to reclaim memory, it uses the "child" pointers to traverse
the lineage, reclaiming the memory of the eldest delta bases first.

A subsequent patch will perform memory reclaiming in a different way and
will thus no longer need the "child" pointer. Because the "child"
pointer is redundant even now, remove it so that the aforementioned
subsequent patch will be clearer. In the meantime, reclaim memory in the
reverse order of the "base" pointers.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoindex-pack: unify threaded and unthreaded code
Jonathan Tan [Mon, 24 Aug 2020 19:16:34 +0000 (12:16 -0700)]
index-pack: unify threaded and unthreaded code

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoindex-pack: remove redundant parameter
Jonathan Tan [Mon, 24 Aug 2020 19:16:33 +0000 (12:16 -0700)]
index-pack: remove redundant parameter

find_{ref,ofs}_delta_{,children} take an enum object_type parameter, but
the object type is already present in the name of the function. Remove
that parameter from these functions.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoDocumentation: deltaBaseCacheLimit is per-thread
Jonathan Tan [Mon, 24 Aug 2020 19:16:31 +0000 (12:16 -0700)]
Documentation: deltaBaseCacheLimit is per-thread

Clarify that core.deltaBaseCacheLimit is per-thread, as can be seen from
the fact that cache usage (base_cache_used in struct thread_local in
builtin/index-pack.c) is tracked individually for each thread and
compared against delta_base_cache_limit.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agobisect: add first-parent option to documentation
Aaron Lipman [Sat, 22 Aug 2020 20:32:03 +0000 (16:32 -0400)]
bisect: add first-parent option to documentation

Ensure that the [--first-parent] option is listed in the output of
"git bisect -h".

Signed-off-by: Aaron Lipman <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocheckout, restore: make pathspec recursive
René Scharfe [Sat, 22 Aug 2020 08:57:59 +0000 (10:57 +0200)]
checkout, restore: make pathspec recursive

The pathspec given to git checkout and git restore is used with both
tree_entry_interesting (via read_tree_recursive) and match_pathspec
(via ce_path_match).  The latter effectively only supports recursive
matching regardless of the value of the pathspec flag "recursive",
which is unset here.

That causes different match results for pathspecs with wildcards, and
can lead checkout and restore in no-overlay mode to remove entries
instead of modifying them.  Enable recursive matching for both checkout
and restore to make matching consistent.

Setting the flag in checkout_main() technically also affects git switch,
but since that command doesn't accept pathspecs at all this has no
actual consequence.

Reported-by: Sergii Shkarnikov <redacted>
Initial-test-by: Sergii Shkarnikov <redacted>
Helped-by: Jeff King <redacted>
Signed-off-by: René Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoident: say whose identity is missing when giving user.name hint
Junio C Hamano [Fri, 21 Aug 2020 20:36:28 +0000 (13:36 -0700)]
ident: say whose identity is missing when giving user.name hint

If `user.name` and `user.email` have not been configured and the
user invokes:

    git commit --author=...

without specifying the committer identity, then Git errors out with
a message asking the user to configure `user.name` and `user.email`
but doesn't tell the user which attribution was missing. This can be
confusing for a user new to Git who isn't aware of the distinction
between user, author, and committer.

Give such users a bit more help by extending the error message to
also say which attribution is expected.

Signed-off-by: Junio C Hamano <redacted>
5 years agoref-filter: 'contents:trailers' show error if `:` is missing
Hariom Verma [Fri, 21 Aug 2020 21:06:14 +0000 (21:06 +0000)]
ref-filter: 'contents:trailers' show error if `:` is missing

The 'contents' atom does not show any error if used with 'trailers'
atom and colon is missing before trailers arguments.

e.g %(contents:trailersonly) works, while it shouldn't.

It is definitely not an expected behavior.

Let's fix this bug.

Mentored-by: Christian Couder <redacted>
Mentored-by: Heba Waly <redacted>
Helped-by: Eric Sunshine <redacted>
Signed-off-by: Hariom Verma <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff: index-line: respect --abbrev in object's name
Đoàn Trần Công Danh [Fri, 21 Aug 2020 11:51:47 +0000 (18:51 +0700)]
diff: index-line: respect --abbrev in object's name

A handful of Git's commands respect `--abbrev' for customizing length
of abbreviation of object names.

For diff-family, Git supports 2 different options for 2 different
purposes, `--full-index' for showing diff-patch object's name in full,
and `--abbrev' to customize the length of object names in diff-raw and
diff-tree header lines, without any options to customise the length of
object names in diff-patch format. When working with diff-patch format,
we only have two options, either full index, or default abbrev length.

Although, that behaviour is documented, it doesn't stop users from
trying to use `--abbrev' with the hope of customising diff-patch's
objects' name's abbreviation.

Let's allow the blob object names shown on the "index" line to be
abbreviated to arbitrary length given via the "--abbrev" option.

To preserve backward compatibility with old script that specify both
`--full-index' and `--abbrev', always show full object id
if `--full-index' is specified.

Signed-off-by: Đoàn Trần Công Danh <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot4013: improve diff-post-processor logic
brian m. carlson [Fri, 21 Aug 2020 11:51:46 +0000 (18:51 +0700)]
t4013: improve diff-post-processor logic

From 72f936b1 (t4013: make test hash independent, 2020-02-07),
we started to adjust metadata of git-diff's output in order to
ignore uninteresting metadata which is dependent of underlying hash
algorithm.

However, we forgot to special case all-zero object names, which is
special for missing objects, in consequence, we could't catch
possible future bugs where object names is all-zeros including but
not limited to:
* show intend-to-add entry
* deleted entry
* diff between index and working tree with new file

We also mistakenly munged file-modes as if they were object names
abbreviated to 6 hexadecimal digits.

In addition, in the upcoming change, we would like to test for
customizing the length of abbreviated blob objects on the index line,
which is not supported by current diff-processor logic.

Let's fix the bug for all-zero object names, and file modes.
While we're at it, support abbreviation of object names up to 16 bytes.

Based-on-patch-by: Junio C Hamano <redacted>
Signed-off-by: Junio C Hamano <redacted>
Signed-off-by: brian m. carlson <redacted>
Signed-off-by: Đoàn Trần Công Danh <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot6300: unify %(trailers) and %(contents:trailers) tests
Hariom Verma [Fri, 21 Aug 2020 10:11:01 +0000 (10:11 +0000)]
t6300: unify %(trailers) and %(contents:trailers) tests

Currently, there are different tests for testing %(trailers) and
%(contents:trailers) causing redundant copy.

Its time to get rid of duplicate code.

Mentored-by: Christian Couder <redacted>
Mentored-by: Heba Waly <redacted>
Signed-off-by: Hariom Verma <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoci: fix inconsistent indentation
Adrian Moennich [Fri, 21 Aug 2020 09:27:26 +0000 (09:27 +0000)]
ci: fix inconsistent indentation

While YAML allows different indentation styles as long as each block
is consistent, it is rather unusual to mix different indentations in
a single file.  Adjust to use two-space indentation everywhere.

Signed-off-by: Adrian Moennich <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoindex-pack: adjust default threading cap
Jeff King [Fri, 21 Aug 2020 17:58:00 +0000 (13:58 -0400)]
index-pack: adjust default threading cap

Commit b8a2486f15 (index-pack: support multithreaded delta resolving,
2012-05-06) describes an experiment that shows that setting the number
of threads for index-pack higher than 3 does not help.

I repeated that experiment using a more modern version of Git and a more
modern CPU and got different results.

Here are timings for p5302 against linux.git run on my laptop, a Core
i9-9880H with 8 cores plus hyperthreading (so online-cpus returns 16):

  5302.3: index-pack 0 threads                   256.28(253.41+2.79)
  5302.4: index-pack 1 threads                   257.03(254.03+2.91)
  5302.5: index-pack 2 threads                   149.39(268.34+3.06)
  5302.6: index-pack 4 threads                   94.96(294.10+3.23)
  5302.7: index-pack 8 threads                   68.12(339.26+3.89)
  5302.8: index-pack 16 threads                  70.90(655.03+7.21)
  5302.9: index-pack default number of threads   116.91(290.05+3.21)

You can see that wall-clock times continue to improve dramatically up to
the number of cores, but bumping beyond that (into hyperthreading
territory) does not help (and in fact hurts a little).

Here's the same experiment on a machine with dual Xeon 6230's, totaling
40 cores (80 with hyperthreading):

  5302.3: index-pack 0 threads                    310.04(302.73+6.90)
  5302.4: index-pack 1 threads                    310.55(302.68+7.40)
  5302.5: index-pack 2 threads                    178.17(304.89+8.20)
  5302.6: index-pack 5 threads                    99.53(315.54+9.56)
  5302.7: index-pack 10 threads                   72.80(327.37+12.79)
  5302.8: index-pack 20 threads                   60.68(357.74+21.66)
  5302.9: index-pack 40 threads                   58.07(454.44+67.96)
  5302.10: index-pack 80 threads                  59.81(720.45+334.52)
  5302.11: index-pack default number of threads   134.18(309.32+7.98)

The results are similar; things stop improving at 40 threads. Curiously,
going from 20 to 40 really doesn't help much, either (and increases CPU
time considerably). So that may represent an actual barrier to
parallelism, where we lose out due to context-switching and loss of
cache locality, but don't reap the wall-clock benefits due to contention
of our coarse-grained locks.

So what's a good default value? It's clear that the current cap of 3 is
too low; our default values are 42% and 57% slower than the best times
on each machine. The results on the 40-core machine imply that 20
threads is an actual barrier regardless of the number of cores, so we'll
take that as a maximum. We get the best results on these machines at
half of the online-cpus value. That's presumably a result of the
hyperthreading. That's common on multi-core Intel processors, but not
necessarily elsewhere. But if we take it as an assumption, we can
perform optimally on hyperthreaded machines and still do much better
than the status quo on other machines, as long as we never half below
the current value of 3.

So that's what this patch does.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agop5302: count up to online-cpus for thread tests
Jeff King [Fri, 21 Aug 2020 17:54:51 +0000 (13:54 -0400)]
p5302: count up to online-cpus for thread tests

When PERF_EXTRA is enabled, p5302 checks the performance of index-pack
with various numbers of threads. This can be useful for deciding what
the default should be (which is currently capped at 3 threads based on
the results of this script).

However, we only go up to 8 threads, and modern machines may have more.
Let's get the number of CPUs from test-tool, and test various numbers of
threads between one and that maximum.

Note that the current tests aren't all identical, as we have to set
GIT_FORCE_THREADS for the --threads=1 test (which measures the overhead
of starting a single worker thread versus the "0" case of using the main
thread). To keep the loop simple, we'll keep the "0" case out of it, and
set GIT_FORCE_THREADS=1 for all of the other cases (it's a noop for all
but the "1" case, since numbers higher than 1 would always need
threads).

Note also that we could skip running "test-tool" if PERF_EXTRA isn't
set. However, there's some small value in knowing the number of threads,
so that we can mark each test as skipped in the output.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agop5302: disable thread-count parameter tests by default
Jeff King [Fri, 21 Aug 2020 17:53:39 +0000 (13:53 -0400)]
p5302: disable thread-count parameter tests by default

The primary function of the perf suite is to detect regressions (or
improvements) between versions of Git. The only numbers we show a direct
comparison for are timings between the same test run on two different
versions.

However, it can sometimes be used to collect other information.  For
instance, p5302 runs the same index-pack operation with different thread
counts. The output doesn't directly compare these, but anybody
interested in working on index-pack can manually compare the results.

For a normal regression run of the full perf-suite, though, this incurs
a significant cost to generate numbers nobody will actually look at;
about 25% of the total time of the test suite is spent in p5302. And the
low-thread-count runs are the most expensive part of it, since they're
(unsurprisingly) not using as many threads.

Let's skip these tests by default, but make it possible for people
working on index-pack to still run them by setting an environment
variable. Rather than make this specific to p5302, let's introduce a
generic mechanism. This makes it possible to run the full suite with
every possible test if somebody really wants to burn some CPU.

Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot7401: add a NEEDSWORK
Shourya Shukla [Fri, 21 Aug 2020 16:59:52 +0000 (22:29 +0530)]
t7401: add a NEEDSWORK

Add a NEEDSWORK regarding the outdated syntax and working of the test,
which may need to be improved to obtain better and desired results.

While at it, change the word 'test' to 'test script' in the test
description to avoid ambiguity.

Mentored-by: Christian Couder <redacted>
Mentored-by: Kaartic Sivaraam <redacted>
Helped-by: Taylor Blau <redacted>
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot7401: change indentation for enhanced readability
Shourya Shukla [Fri, 21 Aug 2020 16:59:51 +0000 (22:29 +0530)]
t7401: change indentation for enhanced readability

Change the indentation of expected outputs for enhanced readability of
the tests. Also modify the heredoc string limiter in a test which lacks
it to support the indentation change.

Mentored-by: Christian Couder <redacted>
Mentored-by: Kaartic Sivaraam <redacted>
Helped-by: Junio C Hamano <redacted>
Helped-by: Taylor Blau <redacted>
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot7401: change syntax of test_i18ncmp calls for clarity
Shourya Shukla [Fri, 21 Aug 2020 16:59:50 +0000 (22:29 +0530)]
t7401: change syntax of test_i18ncmp calls for clarity

Change the test_i18ncmp syntax from 'test_i18ncmp actual expected' to
'test_i18ncmp expected actual' to align it with the convention followed
by other tests in the test script.

Mentored-by: Christian Couder <redacted>
Mentored-by: Kaartic Sivaraam <redacted>
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot7401: use 'short' instead of 'verify' and cut in rev-parse calls
Shourya Shukla [Fri, 21 Aug 2020 16:59:49 +0000 (22:29 +0530)]
t7401: use 'short' instead of 'verify' and cut in rev-parse calls

'git rev-parse' can limit the number of characters in the hash it
outputs using the '--short' option, thereby, making the 'cut' invocation
redundant. Since using '--short' implies '--verify' as well, we can
safely replace the latter with the former. This change results in the
helper functions getting the hash in the same way 'summary' gets the
hash internally.

So, avoid the unnecessary invocation to 'cut' in the helper
functions.

Mentored-by: Christian Couder <redacted>
Mentored-by: Kaartic Sivaraam <redacted>
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot7401: modernize style
Shourya Shukla [Fri, 21 Aug 2020 16:59:48 +0000 (22:29 +0530)]
t7401: modernize style

The tests in 't7401-submodule-summary.sh' were written a long time ago
and has a violation with respect to our CodingGuidelines which is,
incorrect spacing in usages of the redirection operator.

Mentored-by: Christian Couder <redacted>
Mentored-by: Kaartic Sivaraam <redacted>
Helped-by: Denton Liu <redacted>
Helped-by: Taylor Blau <redacted>
Signed-off-by: Shourya Shukla <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agosequencer: treat REVERT_HEAD as a pseudo ref
Han-Wen Nienhuys [Fri, 21 Aug 2020 16:59:37 +0000 (16:59 +0000)]
sequencer: treat REVERT_HEAD as a pseudo ref

Signed-off-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agobuiltin/commit: suggest update-ref for pseudoref removal
Han-Wen Nienhuys [Fri, 21 Aug 2020 16:59:36 +0000 (16:59 +0000)]
builtin/commit: suggest update-ref for pseudoref removal

When pseudorefs move to a different ref storage mechanism, pseudorefs no longer
can be removed with 'rm'. Instead, suggest a "update-ref -d" command, which will
work regardless of ref storage backend.

Signed-off-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agosequencer: treat CHERRY_PICK_HEAD as a pseudo ref
Han-Wen Nienhuys [Fri, 21 Aug 2020 16:59:35 +0000 (16:59 +0000)]
sequencer: treat CHERRY_PICK_HEAD as a pseudo ref

Check for existence and delete CHERRY_PICK_HEAD through ref functions.
This will help cherry-pick work with alternate ref storage backends.

Signed-off-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorefs: make refs_ref_exists public
Han-Wen Nienhuys [Fri, 21 Aug 2020 16:59:34 +0000 (16:59 +0000)]
refs: make refs_ref_exists public

This will be necessary to replace file existence checks for pseudorefs.

Signed-off-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agogit-apply.txt: update descriptions of --cached, --index
Raymond E. Pasco [Thu, 20 Aug 2020 23:10:51 +0000 (19:10 -0400)]
git-apply.txt: update descriptions of --cached, --index

The blurb for "--cached" says it implies "--index", but in reality
"--cached" and "--index" are distinct modes with different behavior.

Additionally, the descriptions of "--index" and "--cached" are somewhat
unclear about what might be modified, and what "--index" looks for to
determine that the index and working copy "match".

Rewrite the blurbs for both options for clarity and accuracy.

Signed-off-by: Raymond E. Pasco <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agofetch-pack: in partial clone, pass --promisor
Jonathan Tan [Thu, 20 Aug 2020 17:51:16 +0000 (10:51 -0700)]
fetch-pack: in partial clone, pass --promisor

When fetching a pack from a promisor remote, the corresponding .promisor
file needs to be created. "fetch-pack" originally did this by passing
"--promisor" to "index-pack", but in 5374a290aa ("fetch-pack: write
fetched refs to .promisor", 2019-10-16), "fetch-pack" was taught to do
this itself instead, because it needed to store ref information in the
.promisor file.

This causes a problem with superprojects when transfer.fsckobjects is
set, because in the current implementation, it is "index-pack" that
calls fsck_finish() to check the objects; before 5374a290aa,
fsck_finish() would see that .gitmodules is a promisor object and
tolerate it being missing, but after, there is no .promisor file (at the
time of the invocation of fsck_finish() by "index-pack") to tell it that
.gitmodules is a promisor object, so it returns an error.

Therefore, teach "fetch-pack" to pass "--promisor" to index pack once
again. "fetch-pack" will subsequently overwrite this file with the ref
information.

An alternative is to instead move object checking to "fetch-pack", and
let "index-pack" only index the files. However, since "index-pack" has
to inflate objects in order to index them, it seems reasonable to also
let it check the objects (which also require inflated files).

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff: teach --stat to ignore uninteresting modifications
Matthew Rogers [Thu, 20 Aug 2020 00:41:32 +0000 (00:41 +0000)]
diff: teach --stat to ignore uninteresting modifications

When options such as --ignore-space-change are in use, files with
modifications can have no interesting textual changes worth showing.  In
such cases, "git diff --stat" shows 0 lines of additions and deletions.
Teach "git diff --stat" not to show such a path in its output, which
would be more natural.

However, we don't want to prevent the display  of all files that have 0
effective diffs since they could be the result of a rename, permission
change, or other similar operation that may still be of interest so we
special case additions and deletions as they are always interesting.

Signed-off-by: Matthew Rogers <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocompletion: add GIT_COMPLETION_SHOW_ALL env var
Ryan Zoeller [Wed, 19 Aug 2020 23:06:13 +0000 (23:06 +0000)]
completion: add GIT_COMPLETION_SHOW_ALL env var

When set to 1, GIT_COMPLETION_SHOW_ALL causes --git-completion-helper-all
to be passed instead of --git-completion-helper.

Signed-off-by: Ryan Zoeller <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoparse-options: add --git-completion-helper-all
Ryan Zoeller [Wed, 19 Aug 2020 23:06:08 +0000 (23:06 +0000)]
parse-options: add --git-completion-helper-all

--git-completion-helper excludes hidden options, such as --allow-empty
for git commit. This is typically helpful, but occasionally we want
auto-completion for obscure flags. --git-completion-helper-all returns
all options, even if they are marked as hidden or nocomplete.

Signed-off-by: Ryan Zoeller <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoNinth batch
Junio C Hamano [Wed, 19 Aug 2020 23:14:30 +0000 (16:14 -0700)]
Ninth batch

Signed-off-by: Junio C Hamano <redacted>
5 years agoMerge branch 'jh/mingw-unlink'
Junio C Hamano [Wed, 19 Aug 2020 23:14:53 +0000 (16:14 -0700)]
Merge branch 'jh/mingw-unlink'

"unlink" emulation on MinGW has been optimized.

* jh/mingw-unlink:
  mingw: improve performance of mingw_unlink()

5 years agoMerge branch 'ds/sha256-leftover-bits'
Junio C Hamano [Wed, 19 Aug 2020 23:14:52 +0000 (16:14 -0700)]
Merge branch 'ds/sha256-leftover-bits'

midx and commit-graph files now use the byte defined in their file
format specification for identifying the hash function used for
object names.

* ds/sha256-leftover-bits:
  multi-pack-index: use hash version byte
  commit-graph: use the "hash version" byte
  t/README: document GIT_TEST_DEFAULT_HASH

5 years agoMerge branch 'ma/sha-256-docs'
Junio C Hamano [Wed, 19 Aug 2020 23:14:52 +0000 (16:14 -0700)]
Merge branch 'ma/sha-256-docs'

Further update of docs to adjust to the recent SHA-256 work.

* ma/sha-256-docs:
  shallow.txt: document SHA-256 shallow format
  protocol-capabilities.txt: clarify "allow-x-sha1-in-want" re SHA-256
  index-format.txt: document SHA-256 index format
  http-protocol.txt: document SHA-256 "want"/"have" format

5 years agoMerge branch 'jc/object-names-are-not-sha-1'
Junio C Hamano [Wed, 19 Aug 2020 23:14:52 +0000 (16:14 -0700)]
Merge branch 'jc/object-names-are-not-sha-1'

A few end-user facing messages have been updated to be
hash-algorithm agnostic.

* jc/object-names-are-not-sha-1:
  messages: avoid SHA-1 in end-user facing messages

5 years agoMerge branch 'bc/sha-256-doc-updates'
Junio C Hamano [Wed, 19 Aug 2020 23:14:51 +0000 (16:14 -0700)]
Merge branch 'bc/sha-256-doc-updates'

Further update of docs to adjust to the recent SHA-256 work.

* bc/sha-256-doc-updates:
  docs: fix step in transition plan
  docs: document SHA-256 pack and indices

5 years agoMerge branch 'pb/set-url-docfix'
Junio C Hamano [Wed, 19 Aug 2020 23:14:51 +0000 (16:14 -0700)]
Merge branch 'pb/set-url-docfix'

Doc fix.

* pb/set-url-docfix:
  fetch, pull doc: correct description of '--set-upstream'

5 years agoMerge branch 'pb/userdiff-fortran-update'
Junio C Hamano [Wed, 19 Aug 2020 23:14:50 +0000 (16:14 -0700)]
Merge branch 'pb/userdiff-fortran-update'

The regexp to identify the function boundary for FORTRAN programs
has been updated.

* pb/userdiff-fortran-update:
  userdiff: improve Fortran xfuncname regex
  userdiff: add tests for Fortran xfuncname regex

5 years agoMerge branch 'jb/commit-graph-doc-fix'
Junio C Hamano [Wed, 19 Aug 2020 23:14:49 +0000 (16:14 -0700)]
Merge branch 'jb/commit-graph-doc-fix'

Docfix.

* jb/commit-graph-doc-fix:
  docs: commit-graph: fix some whitespace in the diagram

5 years agoMerge branch 'jk/blame-coalesce-fix'
Junio C Hamano [Wed, 19 Aug 2020 23:14:49 +0000 (16:14 -0700)]
Merge branch 'jk/blame-coalesce-fix'

When given more than one target line ranges, "git blame -La,b
-Lc,d" was over-eager to coalesce groups of original lines and
showed incorrect results, which has been corrected.

* jk/blame-coalesce-fix:
  blame: only coalesce lines that are adjacent in result
  t8003: factor setup out of coalesce test
  t8003: check output of coalesced blame

5 years agoMerge branch 'ak/sequencer-fix-find-uniq-abbrev'
Junio C Hamano [Wed, 19 Aug 2020 23:14:48 +0000 (16:14 -0700)]
Merge branch 'ak/sequencer-fix-find-uniq-abbrev'

Ring buffer with size 4 used for bin-hex translation resulted in a
wrong object name in the sequencer's todo output, which has been
corrected.

* ak/sequencer-fix-find-uniq-abbrev:
  rebase -i: fix possibly wrong onto hash in todo

5 years agoMerge branch 'en/sequencer-merge-labels'
Junio C Hamano [Wed, 19 Aug 2020 23:14:47 +0000 (16:14 -0700)]
Merge branch 'en/sequencer-merge-labels'

The commit labels used to explain each side of conflicted hunks
placed by the sequencer machinery have been made more readable by
humans.

* en/sequencer-merge-labels:
  sequencer: avoid garbled merge machinery messages due to commit labels

5 years agoMerge branch 'rs/preserve-merges-unused-code-removal'
Junio C Hamano [Wed, 19 Aug 2020 23:14:46 +0000 (16:14 -0700)]
Merge branch 'rs/preserve-merges-unused-code-removal'

Code clean-up.

* rs/preserve-merges-unused-code-removal:
  rebase: remove unused function reschedule_last_action

5 years agoMerge branch 'rs/upload-pack-sigchain-fix'
Junio C Hamano [Wed, 19 Aug 2020 23:14:45 +0000 (16:14 -0700)]
Merge branch 'rs/upload-pack-sigchain-fix'

Code clean-up.

* rs/upload-pack-sigchain-fix:
  upload-pack: remove superfluous sigchain_pop() call

5 years agoMerge branch 'rp/ita-diff-modefix'
Junio C Hamano [Wed, 19 Aug 2020 23:14:44 +0000 (16:14 -0700)]
Merge branch 'rp/ita-diff-modefix'

"git diff [<tree-ish>] $path" for a $path that is marked with i-t-a
bit was not showing the mode bits from the working tree.

* rp/ita-diff-modefix:
  diff-lib: use worktree mode in diffs from i-t-a entries

5 years agoMerge branch 'en/merge-tests'
Junio C Hamano [Wed, 19 Aug 2020 23:14:43 +0000 (16:14 -0700)]
Merge branch 'en/merge-tests'

Updates to "git merge" tests, in preparation for a new merge
strategy backend.

* en/merge-tests:
  t6425: be more flexible with rename/delete conflict messages
  t642[23]: be more flexible for add/add conflicts involving pair renames
  t6422, t6426: be more flexible for add/add conflicts involving renames
  t6423: add an explanation about why one of the tests does not pass
  t6416, t6423: clarify some comments and fix some typos
  t6422: fix multiple errors with the mod6 test expectations
  t6423: fix test setup for a couple tests
  t6416, t6422: fix incorrect untracked file count
  t6422: fix bad check against missing file
  t6418: tighten delete/normalize conflict testcase
  Collect merge-related tests to t64xx

5 years agorebase: add --reset-author-date
Rohit Ashiwal [Mon, 17 Aug 2020 17:40:04 +0000 (18:40 +0100)]
rebase: add --reset-author-date

The previous commit introduced --ignore-date flag to rebase -i, but the
name is rather vague as it does not say whether the author date or the
committer date is ignored. Add an alias to convey the precise purpose.

Helped-by: Junio C Hamano <redacted>
Signed-off-by: Rohit Ashiwal <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorebase -i: support --ignore-date
Phillip Wood [Mon, 17 Aug 2020 17:40:03 +0000 (18:40 +0100)]
rebase -i: support --ignore-date

Rebase is implemented with two different backends - 'apply' and
'merge' each of which support a different set of options. In
particular the apply backend supports a number of options implemented
by 'git am' that are not implemented in the merge backend. This means
that the available options are different depending on which backend is
used which is confusing. This patch adds support for the --ignore-date
option to the merge backend. This option uses the current time as the
author date rather than reusing the original author date when
rewriting commits. We take care to handle the combination of
--ignore-date and --committer-date-is-author-date in the same way as
the apply backend.

Original-patch-by: Rohit Ashiwal <redacted>
Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorefs: read FETCH_HEAD and MERGE_HEAD generically
Han-Wen Nienhuys [Wed, 19 Aug 2020 14:27:58 +0000 (14:27 +0000)]
refs: read FETCH_HEAD and MERGE_HEAD generically

The FETCH_HEAD and MERGE_HEAD refs must be stored in a file, regardless of the
type of ref backend. This is because they can hold more than just a single ref.

To accomodate them for alternate ref backends, read them from a file generically
in refs_read_raw_ref()

Signed-off-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorefs: move gitdir into base ref_store
Han-Wen Nienhuys [Wed, 19 Aug 2020 14:27:57 +0000 (14:27 +0000)]
refs: move gitdir into base ref_store

Signed-off-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorefs: fix comment about submodule ref_stores
Han-Wen Nienhuys [Wed, 19 Aug 2020 14:27:56 +0000 (14:27 +0000)]
refs: fix comment about submodule ref_stores

Signed-off-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorefs: split off reading loose ref data in separate function
Han-Wen Nienhuys [Wed, 19 Aug 2020 14:27:55 +0000 (14:27 +0000)]
refs: split off reading loose ref data in separate function

This prepares for handling FETCH_HEAD (which is not a regular ref)
separately from the ref backend.

Signed-off-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodir: fix problematic API to avoid memory leaks
Elijah Newren [Tue, 18 Aug 2020 22:58:26 +0000 (22:58 +0000)]
dir: fix problematic API to avoid memory leaks

The dir structure seemed to have a number of leaks and problems around
it.  First I noticed that parent_hashmap and recursive_hashmap were
being leaked (though Peff noticed and submitted fixes before me).  Then
I noticed in the previous commit that clear_directory() was only taking
responsibility for a subset of fields within dir_struct, despite the
fact that entries[] and ignored[] we allocated internally to dir.c.
That, of course, resulted in many callers either leaking or haphazardly
trying to free these arrays and their contents.

Digging further, I found that despite the pretty clear documentation
near the top of dir.h that folks were supposed to call clear_directory()
when the user no longer needed the dir_struct, there were four callers
that didn't bother doing that at all.  However, two of them clearly
thought about leaks since they had an UNLEAK(dir) directive, which to me
suggests that the method to free the data was too unclear.  I suspect
the non-obviousness of the API and its holes led folks to avoid it,
which then snowballed into further problems with the entries[],
ignored[], parent_hashmap, and recursive_hashmap problems.

Rename clear_directory() to dir_clear() to be more in line with other
data structures in git, and introduce a dir_init() to handle the
suggested memsetting of dir_struct to all zeroes.  I hope that a name
like "dir_clear()" is more clear, and that the presence of dir_init()
will provide a hint to those looking at the code that they need to look
for either a dir_clear() or a dir_free() and lead them to find
dir_clear().

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodir: make clear_directory() free all relevant memory
Elijah Newren [Tue, 18 Aug 2020 22:58:25 +0000 (22:58 +0000)]
dir: make clear_directory() free all relevant memory

The calling convention for the dir API is supposed to end with a call to
clear_directory() to free up no longer needed memory.  However,
clear_directory() didn't free dir->entries or dir->ignored.  I believe
this was an oversight, but a number of callers noticed memory leaks and
started free'ing these.  Unfortunately, they did so somewhat haphazardly
(sometimes freeing the entries in the arrays, and sometimes only
free'ing the arrays themselves).  This suggests the callers weren't
trying to make sure any possible memory used might be free'd, but just
the memory they noticed their usecase definitely had allocated.

Fix this mess by moving all the duplicated free'ing logic into
clear_directory().  End by resetting dir to a pristine state so it could
be reused if desired.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agofetch-pack: remove no_dependents code
Jonathan Tan [Tue, 18 Aug 2020 04:01:37 +0000 (21:01 -0700)]
fetch-pack: remove no_dependents code

Now that Git has switched to using a subprocess to lazy-fetch missing
objects, remove the no_dependents code as it is no longer used.

Signed-off-by: Jonathan Tan <redacted>
Signed-off-by: Junio C Hamano <redacted>
git clone https://git.99rst.org/PROJECT