git.git
5 years agomktag tests: test "hash-object" compatibility
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:40 +0000 (20:42 +0100)]
mktag tests: test "hash-object" compatibility

Change all the successful "mktag" tests to test that "hash-object"
produces the same hash for the input, and that fsck passes for
both.

This tests e.g. that "mktag" doesn't trim its input or otherwise munge
it in a way that "hash-object" doesn't.

Since we're doing an "fsck --strict" here at the end let's incorporate
the creation of the "mytag" name into this test, removing the
special-case at the end of the file.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag tests: stress test whitespace handling
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:39 +0000 (20:42 +0100)]
mktag tests: stress test whitespace handling

Add tests for a couple of whitespace edge cases around the header/body
boundary.

I consider the requirement for a blank line before the empty body a
bug, it's a long-standing regression which goes against the command's
documented behavior. This bug will be addressed in a follow-up change.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag tests: run "fsck" after creating "mytag"
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:38 +0000 (20:42 +0100)]
mktag tests: run "fsck" after creating "mytag"

Change the last test in the file to run an "fsck --strict" after
creating the tag at the end.

We're just doing this for good measure to check that fsck behaves as
expected now that there's finally a reference for our valid tag. Other
tests going to be checking this elsewhere, but it's nice to cover all
the edge cases in this test to make it as self-contained as possible.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag tests: don't create "mytag" twice
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:37 +0000 (20:42 +0100)]
mktag tests: don't create "mytag" twice

Change a test added in e0aaf781f6 (mktag.c: improve verification of
tagger field and tests, 2008-03-27) to not create "mytag", which
should only be created and verified at the end in an earlier test
added in 446c6faec6 (New tests and en-passant modifications to mktag.,
2006-07-29).

While we're at it let's prevent a similar logic error from creeping
into the test by asserting that "mytag" doesn't exist before we create
it. Let's do this by moving the test to use "update-ref", instead of
our own homebrew ad-hoc refstore update.

We're not really testing for anything yet by creating the tag at the
end here. A subsequent commit will change that.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag tests: don't redirect stderr to a file needlessly
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:36 +0000 (20:42 +0100)]
mktag tests: don't redirect stderr to a file needlessly

Remove the redirection of stderr to "message" in the valid tag
test. This pattern seems to have been copy/pasted from the failure
case in 446c6faec6 (New tests and en-passant modifications to mktag.,
2006-07-29).

While I'm at it do the same for the "replace" tests. The tag creation
I'm changing here seems to have been copy/pasted from the "mktag"
tests to those tests in cc400f50112 (mktag: call
"check_sha1_signature" with the replacement sha1, 2009-01-23).

Nobody examines the contents of the resulting "message" file, so the
net result is that error messages cannot be seen in "sh t3800-mktag.sh
-v" output.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag tests: remove needless SHA-1 hardcoding
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:35 +0000 (20:42 +0100)]
mktag tests: remove needless SHA-1 hardcoding

Change the tests amended in acb49d1cc8b (t3800: make hash-size
independent, 2019-08-18) even more to make them independent of either
SHA-1 or SHA-256.

Some of these tests were failing for the wrong reasons. The first one
being modified here would fail because the line starts with "xxxxxx"
instead of "object", the rest of the line doesn't matter.

Let's just put a valid hash on the rest of the line anyway to narrow
the test down for just the s/object/xxxxxx/ case.

The second one being modified here would fail under
GIT_TEST_DEFAULT_HASH=sha256 because <some sha-1 length garbage> is an
invalid SHA-256, but we should really be testing <some sha-256 length
garbage> when under SHA-256.

This doesn't really matter since we should be able to trust other
parts of the code to validate things in the 0-9a-f range, but let's
keep it for good measure.

There's a later test which tests an invalid SHA which looks like a
valid one, to stress the "We refuse to tag something we can't
verify[...]" logic in mktag.c.

But here we're testing for a SHA-length string which contains
characters outside of the /[0-9a-f]/i set.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag tests: use "test_commit" helper
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:34 +0000 (20:42 +0100)]
mktag tests: use "test_commit" helper

Replace ad-hoc setup of a single commit in the "mktag" tests with our
standard helper pattern. The old setup dated back to 446c6faec69 (New
tests and en-passant modifications to mktag., 2006-07-29) before the
helper existed.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag tests: don't needlessly use a subshell
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:33 +0000 (20:42 +0100)]
mktag tests: don't needlessly use a subshell

The use of a subshell dates back to e9b20943b77 (t/t3800: do not use a
temporary file to hold expected result., 2008-01-04). It's not needed
anymore, if it ever was.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag doc: update to explain why to use this
Ævar Arnfjörð Bjarmason [Tue, 5 Jan 2021 19:42:32 +0000 (20:42 +0100)]
mktag doc: update to explain why to use this

Change the mktag documentation to compare itself to the similar
"hash-object -t tag" command. Before this someone reading the
documentation wouldn't have much of an idea what the difference
was.

Let's allude to our own validation logic, and cross-link the "mktag"
and "hash-object" documentation to aid discover-ability. A follow-up
change to migrate "mktag" to use "fsck" validation will make the part
about validation logic clearer.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomaintenance: use Windows scheduled tasks
Derrick Stolee [Tue, 5 Jan 2021 13:08:28 +0000 (13:08 +0000)]
maintenance: use Windows scheduled tasks

Git's background maintenance uses cron by default, but this is not
available on Windows. Instead, integrate with Task Scheduler.

Tasks can be scheduled using the 'schtasks' command. There are several
command-line options that can allow for some advanced scheduling, but
unfortunately these seem to all require authenticating using a password.

Instead, use the "/xml" option to pass an XML file that contains the
configuration for the necessary schedule. These XML files are based on
some that I exported after constructing a schedule in the Task Scheduler
GUI. These options only run background maintenance when the user is
logged in, and more fields are populated with the current username and
SID at run-time by 'schtasks'.

Since the GIT_TEST_MAINT_SCHEDULER environment variable allows us to
specify 'schtasks' as the scheduler, we can test the Windows-specific
logic on other platforms. Thus, add a check that the XML file written
by Git is valid when xmllint exists on the system.

Since we use a temporary file for the XML files sent to 'schtasks', we
prefix the random characters with the frequency so it is easier to
examine the proper file during tests. Instead of an exact match on the
'args' file, we 'grep' for the arguments other than the filename.

There is a deficiency in the current design. Windows has two kinds of
applications: GUI applications that start by "winmain()" and console
applications that start by "main()". Console applications are attached
to a new Console window if they are not already associated with a GUI
application. This means that every hour the scheudled task launches a
command window for the scheduled tasks. Not only is this visually
obtrusive, but it also takes focus from whatever else the user is
doing!

A simple fix would be to insert a GUI application that acts as a shim
between the scheduled task and Git. This is currently possible in Git
for Windows by setting the <Command> tag equal to

  C:\Program Files\Git\git-bash.exe

with options "--hide --no-needs-console --command=cmd\git.exe"
followed by the arguments currently used. Since git-bash.exe is not
included in Windows builds of core Git, I chose to leave out this
feature. My plan is to submit a small patch to Git for Windows that
converts the use of git.exe with this use of git-bash.exe in the
short term. In the long term, we can consider creating this GUI
shim application within core Git, perhaps in contrib/.

Co-authored-by: Eric Sunshine <redacted>
Signed-off-by: Eric Sunshine <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomaintenance: use launchctl on macOS
Derrick Stolee [Tue, 5 Jan 2021 13:08:27 +0000 (13:08 +0000)]
maintenance: use launchctl on macOS

The existing mechanism for scheduling background maintenance is done
through cron. The 'crontab -e' command allows updating the schedule
while cron itself runs those commands. While this is technically
supported by macOS, it has some significant deficiencies:

1. Every run of 'crontab -e' must request elevated privileges through
   the user interface. When running 'git maintenance start' from the
   Terminal app, it presents a dialog box saying "Terminal.app would
   like to administer your computer. Administration can include
   modifying passwords, networking, and system settings." This is more
   alarming than what we are hoping to achieve. If this alert had some
   information about how "git" is trying to run "crontab" then we would
   have some reason to believe that this dialog might be fine. However,
   it also doesn't help that some scenarios just leave Git waiting for
   a response without presenting anything to the user. I experienced
   this when executing the command from a Bash terminal view inside
   Visual Studio Code.

2. While cron initializes a user environment enough for "git config
   --global --show-origin" to show the correct config file information,
   it does not set up the environment enough for Git Credential Manager
   Core to load credentials during a 'prefetch' task. My prefetches
   against private repositories required re-authenticating through UI
   pop-ups in a way that should not be required.

The solution is to switch from cron to the Apple-recommended [1]
'launchd' tool.

[1] https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html

The basics of this tool is that we need to create XML-formatted
"plist" files inside "~/Library/LaunchAgents/" and then use the
'launchctl' tool to make launchd aware of them. The plist files
include all of the scheduling information, along with the command-line
arguments split across an array of <string> tags.

For example, here is my plist file for the weekly scheduled tasks:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>Label</key><string>org.git-scm.git.weekly</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/libexec/git-core/git</string>
<string>--exec-path=/usr/local/libexec/git-core</string>
<string>for-each-repo</string>
<string>--config=maintenance.repo</string>
<string>maintenance</string>
<string>run</string>
<string>--schedule=weekly</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Day</key><integer>0</integer>
<key>Hour</key><integer>0</integer>
<key>Minute</key><integer>0</integer>
</dict>
</array>
</dict>
</plist>

The schedules for the daily and hourly tasks are more complicated
since we need to use an array for the StartCalendarInterval with
an entry for each of the six days other than the 0th day (to avoid
colliding with the weekly task), and each of the 23 hours other
than the 0th hour (to avoid colliding with the daily task).

The "Label" value is currently filled with "org.git-scm.git.X"
where X is the frequency. We need a different plist file for each
frequency.

The launchctl command needs to be aligned with a user id in order
to initialize the command environment. This must be done using
the 'launchctl bootstrap' subcommand. This subcommand is new as
of macOS 10.11, which was released in September 2015. Before that
release the 'launchctl load' subcommand was recommended. The best
source of information on this transition I have seen is available
at [2]. The current design does not preclude a future version that
detects the available fatures of 'launchctl' to use the older
commands. However, it is best to rely on the newest version since
Apple might completely remove the deprecated version on short
notice.

[2] https://babodee.wordpress.com/2016/04/09/launchctl-2-0-syntax/

To remove a schedule, we must run 'launchctl bootout' with a valid
plist file. We also need to 'bootout' a task before the 'bootstrap'
subcommand will succeed, if such a task already exists.

The need for a user id requires us to run 'id -u' which works on
POSIX systems but not Windows. Further, the need for fully-qualitifed
path names including $HOME behaves differently in the Git internals and
the external test suite. The $HOME variable starts with "C:\..." instead
of the "/c/..." that is provided by Git in these subcommands. The test
therefore has a prerequisite that we are not on Windows. The cross-
platform logic still allows us to test the macOS logic on a Linux
machine.

We can verify the commands that were run by 'git maintenance start'
and 'git maintenance stop' by injecting a script that writes the
command-line arguments into GIT_TEST_MAINT_SCHEDULER.

An earlier version of this patch accidentally had an opening
"<dict>" tag when it should have had a closing "</dict>" tag. This
was caught during manual testing with actual 'launchctl' commands,
but we do not want to update developers' tasks when running tests.
It appears that macOS includes the "xmllint" tool which can verify
the XML format. This is useful for any system that might contain
the tool, so use it whenever it is available.

We strive to make these tests work on all platforms, but Windows caused
some headaches. In particular, the value of getuid() called by the C
code is not guaranteed to be the same as `$(id -u)` invoked by a test.
This is because `git.exe` is a native Windows program, whereas the
utility programs run by the test script mostly utilize the MSYS2 runtime,
which emulates a POSIX-like environment. Since the purpose of the test
is to check that the input to the hook is well-formed, the actual user
ID is immaterial, thus we can work around the problem by making the the
test UID-agnostic. Another subtle issue is the $HOME environment
variable being a Windows-style path instead of a Unix-style path. We can
be more flexible here instead of expecting exact path matches.

Helped-by: Ævar Arnfjörð Bjarmason <redacted>
Co-authored-by: Eric Sunshine <redacted>
Signed-off-by: Eric Sunshine <redacted>
Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocompletion: add proper public __git_complete
Felipe Contreras [Wed, 30 Dec 2020 23:29:50 +0000 (17:29 -0600)]
completion: add proper public __git_complete

When __git_complete was introduced, it was meant to be temporarily, while
a proper guideline for public shell functions was established
(tentatively _GIT_complete), but since that never happened, people
in the wild started to use __git_complete, even though it was marked as
not public.

Eight years is more than enough wait, let's mark this function as
public, and make it a bit more user-friendly.

So that instead of doing:

  __git_complete gk __gitk_main

The user can do:

  __git_complete gk gitk

And instead of:

  __git_complete gf _git_fetch

Do:

  __git_complete gf git_fetch

Backwards compatibility is maintained.

Signed-off-by: Felipe Contreras <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agotest: completion: add tests for __git_complete
Felipe Contreras [Wed, 30 Dec 2020 23:29:49 +0000 (17:29 -0600)]
test: completion: add tests for __git_complete

Even though the function was marked as not public, it's already used in
the wild.

We should at least test basic functionality.

Signed-off-by: Felipe Contreras <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocompletion: bash: improve function detection
Felipe Contreras [Wed, 30 Dec 2020 23:29:48 +0000 (17:29 -0600)]
completion: bash: improve function detection

 1. We should quote the argument
 2. We don't need two redirections
 3. A safeguard for arguments (-a) would be good

Suggested-by: René Scharfe <redacted>
Signed-off-by: Felipe Contreras <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocompletion: bash: add __git_have_func helper
Felipe Contreras [Wed, 30 Dec 2020 23:29:47 +0000 (17:29 -0600)]
completion: bash: add __git_have_func helper

This makes the code more readable, and also will help when new code
wants to do similar checks.

Signed-off-by: Felipe Contreras <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorebase: verify commit parameter
René Scharfe [Thu, 31 Dec 2020 23:55:12 +0000 (00:55 +0100)]
rebase: verify commit parameter

If the user specifies a base commit to switch to, check if it actually
references a commit right away to avoid getting confused later on when
it turns out to be an invalid object.

Reported-by: LeSeulArtichaut <redacted>
Signed-off-by: René Scharfe <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocache-tree: use trace2 in cache_tree_update()
Derrick Stolee [Mon, 4 Jan 2021 03:09:12 +0000 (03:09 +0000)]
cache-tree: use trace2 in cache_tree_update()

This matches a trace_performance_enter()/trace_performance_leave() pair
added by 0d1ed59 (unpack-trees: add performance tracing, 2018-08-18).

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agounpack-trees: add trace2 regions
Derrick Stolee [Mon, 4 Jan 2021 03:09:11 +0000 (03:09 +0000)]
unpack-trees: add trace2 regions

The unpack_trees() method is quite complicated and its performance can
change dramatically depending on how it is used. We already have some
performance tracing regions, but they have not been updated to the
trace2 API. Do so now.

We already have trace2 regions in unpack_trees.c:clear_ce_flags(), which
uses a linear scan through the index without recursing into trees.

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agotree-walk: report recursion counts
Derrick Stolee [Mon, 4 Jan 2021 03:09:10 +0000 (03:09 +0000)]
tree-walk: report recursion counts

The traverse_trees() method recursively walks through trees, but also
prunes the tree-walk based on a callback. Some callers, such as
unpack_trees(), are quite complicated and can have wildly different
performance between two different commands.

Create constants that count these values and then report the results at
the end of a process. These counts are cumulative across multiple "root"
instances of traverse_trees(), but they provide reproducible values for
demonstrating improvements to the pruning algorithm when possible.

This change is modeled after a similar statistics reporting in 42e50e78
(revision.c: add trace2 stats around Bloom filter usage, 2020-04-06).

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agorevision: trace topo-walk statistics
Derrick Stolee [Wed, 30 Dec 2020 04:31:53 +0000 (04:31 +0000)]
revision: trace topo-walk statistics

We trace statistics about the effectiveness of changed-path Bloom
filters since 42e50e78 (revision.c: add trace2 stats around Bloom
filter usage, 2020-04-06). Add similar tracing for the topo-walk
algorithm that uses generation numbers to limit the walk size.

This information can help investigate and describe benefits to
heuristics and other changes.

The information that is printed is in JSON format and can be formatted
nicely to present as follows:

    {
"count_explort_walked":2603,
"count_indegree_walked":2603,
"count_topo_walked":473
    }

Each of these values count the number of commits are visited by each of
the three "stages" of the topo-walk as detailed in b4542418 (revision.c:
generation-based topo-order algorithm, 2018-11-01).

Signed-off-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agohash-lookup: rename from sha1-lookup
Martin Ågren [Thu, 31 Dec 2020 11:56:23 +0000 (12:56 +0100)]
hash-lookup: rename from sha1-lookup

Change all remnants of "sha1" in hash-lookup.c and .h and rename them to
reflect that we're not just able to handle SHA-1 these days.

Signed-off-by: Martin Ågren <redacted>
Reviewed-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agosha1-lookup: rename `sha1_pos()` as `hash_pos()`
Martin Ågren [Thu, 31 Dec 2020 11:56:22 +0000 (12:56 +0100)]
sha1-lookup: rename `sha1_pos()` as `hash_pos()`

Rename this function to reflect that we're not just able to handle SHA-1
these days. There are a few instances of "sha1" left in sha1-lookup.[ch]
after this, but those will be addressed in the next commit.

Signed-off-by: Martin Ågren <redacted>
Reviewed-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoobject-file.c: rename from sha1-file.c
Martin Ågren [Thu, 31 Dec 2020 11:56:21 +0000 (12:56 +0100)]
object-file.c: rename from sha1-file.c

Drop the last remnant of "sha1" in this file and rename it to reflect
that we're not just able to handle SHA-1 these days.

Signed-off-by: Martin Ågren <redacted>
Reviewed-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoobject-name.c: rename from sha1-name.c
Martin Ågren [Thu, 31 Dec 2020 11:56:20 +0000 (12:56 +0100)]
object-name.c: rename from sha1-name.c

Generalize the last remnants of "sha" and "sha1" in this file and rename
it to reflect that we're not just able to handle SHA-1 these days.

We need to update one test to check for an updated error string.

Signed-off-by: Martin Ågren <redacted>
Reviewed-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agopack-format.txt: document sizes at start of delta data
Martin Ågren [Tue, 29 Dec 2020 22:43:35 +0000 (23:43 +0100)]
pack-format.txt: document sizes at start of delta data

We document the delta data as a set of instructions, but forget to
document the two sizes that precede those instructions: the size of the
base object and the size of the object to be reconstructed. Fix this
omission.

Rather than cramming all the details about the encoding into the running
text, introduce a separate section detailing our "size encoding" and
refer to it.

Reported-by: Ross Light <redacted>
Signed-off-by: Martin Ågren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiffcore-rename: remove unnecessary duplicate entry checks
Elijah Newren [Tue, 29 Dec 2020 20:05:28 +0000 (20:05 +0000)]
diffcore-rename: remove unnecessary duplicate entry checks

Commit 25d5ea410f ("[PATCH] Redo rename/copy detection logic.",
2005-05-24) added a duplicate entry check on rename_src in order to
avoid segfaults; the code at the time was prone to double free()s and an
easy way to avoid it was just to turn off rename detection for any
duplicate entries.  Note that the form of the check was modified two
commits ago in this series.

Similarly, commit 4d6be03b95 ("diffcore-rename: avoid processing
duplicate destinations", 2015-02-26) added a duplicate entry check
on rename_dst for the exact same reason -- the code was prone to double
free()s, and an easy way to avoid it was just to turn off rename
detection entirely.  Note that the form of the check was modified in the
commit just before this one.

In the original code in both places, the code was dealing with
individual diff_filespecs and trying to match things up, instead of just
keeping the original diff_filepairs around as we do now.  The
intervening change in structure has fixed the accounting problems and
the associated double free()s that used to occur, and thus we already
have a better fix.  As such, we can remove the band-aid checks for
duplicate entries.

Due to the last two patches, the diffcore_rename() setup is no longer a
sizeable chunk of overall runtime.  Thus, in a large rebase of many
commits with lots of renames and several optimizations to inexact rename
detection, this patch only speeds up the overall code by about half a
percent or so and is pretty close to the run-to-run variability making
it hard to get an exact measurement.  However, with some trace2 regions
around the setup code in diffcore_rename() so that I can focus on just
it, I measure that this patch consistently saves almost a third of the
remaining time spent in diffcore_rename() setup.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot6016: move to lib-log-graph.sh framework
Antonio Russo [Mon, 4 Jan 2021 02:30:35 +0000 (19:30 -0700)]
t6016: move to lib-log-graph.sh framework

t6016 manually reconstructs git log --graph output by using the reported
commit hashes from `git rev-parse`.  Each tag is converted into an
environment variable manually, and then `echo`-ed to an expected output
file, which is in turn compared to the actual output.

The expected output is difficult to read and write, because, e.g.,
each line of output must be prefaced with echo, quoted, and properly
escaped.  Additionally, the test is sensitive to trailing whitespace,
which may potentially be removed from graph log output in the future.

In order to reduce duplication, ease troubleshooting of failed tests by
improving readability, and ease the addition of more tests to this file,
port the operations to `lib-log-graph.sh`, which is already used in
several other tests, e.g., t4215.  Give all merges a simple commit
message, and use a common `check_graph` macro taking a heredoc of the
expected output which does not required extensive escaping.

Signed-off-by: Antonio Russo <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot1300: don't needlessly work with `core.foo` configs
Martin Ågren [Sun, 3 Jan 2021 09:36:48 +0000 (10:36 +0100)]
t1300: don't needlessly work with `core.foo` configs

We use various made-up config keys in the "core" section for no real
reason. Change them to work in the "section" section instead and be
careful to also change "cores" to "sections". Make sure to also catch
"Core", "CoReS" and similar.

There are a few instances that actually want to work with a real "core"
config such as `core.bare` or `core.editor`. After this, it's clearer
that they work with "core" for a reason.

Reported-by: Junio C Hamano <redacted>
Signed-off-by: Martin Ågren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot1300: remove duplicate test for `--file no-such-file`
Martin Ågren [Sun, 3 Jan 2021 09:36:47 +0000 (10:36 +0100)]
t1300: remove duplicate test for `--file no-such-file`

We test that we can handle `git config --file symlink` and the error
case of `git config --file symlink-to-missing-file`. For good measure,
we also throw in a test to check that we correctly handle referencing a
missing regular file. But we have such a test earlier in this script.
They both check that we fail to use `--file no-such-file --list`.

Drop the latter of these and keep the one that is in the general area
where we test `--file` and `GIT_CONFIG`. The one we're dropping also
checks that we can't even get a specific key from the missing file --
let's make sure we check that in the test we keep.

Signed-off-by: Martin Ågren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot1300: remove duplicate test for `--file ../foo`
Martin Ågren [Sun, 3 Jan 2021 09:36:46 +0000 (10:36 +0100)]
t1300: remove duplicate test for `--file ../foo`

We have two tests for checking that we can handle `git config --file
../other-config ...`. One, using `--file`, was introduced in 65807ee697
("builtin-config: Fix crash when using "-f <relative path>" from
non-root dir", 2010-01-26), then another, using `GIT_CONFIG`, came about
in 270a34438b ("config: stop using config_exclusive_filename",
2012-02-16).

The latter of these was then converted to use `--file` in f7e8714101
("t: prefer "git config --file" to GIT_CONFIG", 2014-03-20). Both where
then simplified in a5db0b77b9 ("t1300: extract and use
test_cmp_config()", 2018-10-21).

These two tests differ slightly in the order of the options used, but
other than that, they are identical. Let's drop one. As noted in
f7e8714101, we do still have a test for `GIT_CONFIG` and it shares the
implementation with `--file`.

Signed-off-by: Martin Ågren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agogitmodules.txt: fix 'GIT_WORK_TREE' variable name
Philippe Blain [Sun, 3 Jan 2021 17:42:15 +0000 (17:42 +0000)]
gitmodules.txt: fix 'GIT_WORK_TREE' variable name

'gitmodules.txt' is a guide about the '.gitmodules' file that describes
submodule properties, and that file must exist at the root of the
repository. This was clarified in e5b5c1d2cf (Document clarification:
gitmodules, gitattributes, 2008-08-31).

However, that commit mistakenly uses the non-existing environment
variable 'GIT_WORK_DIR' to refer to the root of the repository.

Fix that by using the correct variable, 'GIT_WORK_TREE'. Take the
opportunity to modernize and improve the formatting of that guide,
and fix a grammar mistake.

Signed-off-by: Philippe Blain <redacted>
Acked-by: Martin Ågren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodoc: fix some typos
Thomas Ackermann [Sun, 3 Jan 2021 14:25:50 +0000 (14:25 +0000)]
doc: fix some typos

Signed-off-by: Thomas Ackermann <redacted>
Acked-by: Martin Ågren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: add handling for different types of files at same path
Elijah Newren [Fri, 1 Jan 2021 02:34:48 +0000 (02:34 +0000)]
merge-ort: add handling for different types of files at same path

Add some handling that explicitly considers collisions of the following
types:
  * file/submodule
  * file/symlink
  * submodule/symlink
Leaving them as conflicts at the same path are hard for users to
resolve, so move one or both of them aside so that they each get their
own path.

Note that in the case of recursive handling (i.e. call_depth > 0), we
can just use the merge base of the two merge bases as the merge result
much like we do with modify/delete conflicts, binary files, conflicting
submodule values, and so on.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: copy find_first_merges() implementation from merge-recursive.c
Elijah Newren [Fri, 1 Jan 2021 02:34:47 +0000 (02:34 +0000)]
merge-ort: copy find_first_merges() implementation from merge-recursive.c

Code is identical for the function body in the two files, the call
signature is just slightly different in merge-ort than merge-recursive
as noted a couple commits ago.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: implement format_commit()
Elijah Newren [Fri, 1 Jan 2021 02:34:46 +0000 (02:34 +0000)]
merge-ort: implement format_commit()

This implementation is based on a mixture of print_commit() and
output_commit_title() from merge-recursive.c so that it can be used to
take over both functions.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: copy and adapt merge_submodule() from merge-recursive.c
Elijah Newren [Fri, 1 Jan 2021 02:34:45 +0000 (02:34 +0000)]
merge-ort: copy and adapt merge_submodule() from merge-recursive.c

Take merge_submodule() from merge-recursive.c and make slight
adjustments, predominantly around deferring output using path_msg()
instead of using merge-recursive's output() and show() functions.
There's also a fix for recursive cases (when call_depth > 0) and a
slight change to argument order for find_first_merges().

find_first_merges() and format_commit() are left unimplemented for
now, but will be added by subsequent commits.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: copy and adapt merge_3way() from merge-recursive.c
Elijah Newren [Fri, 1 Jan 2021 02:34:44 +0000 (02:34 +0000)]
merge-ort: copy and adapt merge_3way() from merge-recursive.c

Take merge_3way() from merge-recursive.c and make slight adjustments
based on different data structures (direct usage of object_id
rather diff_filespec, separate pathnames which based on our careful
interning of pathnames in opt->priv->paths can be compared with '!='
rather than 'strcmp').

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: flesh out implementation of handle_content_merge()
Elijah Newren [Fri, 1 Jan 2021 02:34:43 +0000 (02:34 +0000)]
merge-ort: flesh out implementation of handle_content_merge()

This implementation is based heavily on merge_mode_and_contents() from
merge-recursive.c, though it has some fixes for recursive merges (i.e.
when call_depth > 0), and has a number of changes throughout based on
slight differences in data structures and in how the functions are
called.

It is, however, based on two new helper functions -- merge_3way() and
merge_submodule -- for which we only provide die-not-implemented stubs
at this point.  Future commits will add implementations of these
functions.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: handle book-keeping around two- and three-way content merge
Elijah Newren [Fri, 1 Jan 2021 02:34:42 +0000 (02:34 +0000)]
merge-ort: handle book-keeping around two- and three-way content merge

In addition to the content merge (which will go in a subsequent commit),
we need to worry about conflict messages, placing results in higher
order stages in case of a df_conflict, and making sure the results are
placed in ci->merged.result so that they will show up in the working
tree.  Take care of all that external book-keeping, moving the
simplistic just-take-HEAD code into the barebones handle_content_merge()
function for now.  Subsequent commits will flesh out
handle_content_merge().

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: implement unique_path() helper
Elijah Newren [Fri, 1 Jan 2021 02:34:41 +0000 (02:34 +0000)]
merge-ort: implement unique_path() helper

Implement unique_path(), based on the one from merge-recursive.c.  It is
simplified, however, due to: (1) using strmaps, and (2) the fact that
merge-ort lets the checkout codepath handle possible collisions with the
working tree means that other code locations don't have to.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: handle directory/file conflicts that remain
Elijah Newren [Fri, 1 Jan 2021 02:34:40 +0000 (02:34 +0000)]
merge-ort: handle directory/file conflicts that remain

When a directory/file conflict remains, we can leave the directory where
it is, but need to move the information about the file to a different
pathname.  After moving the file to a different pathname, we allow
subsequent process_entry() logic to handle any additional details that
might be relevant.

This depends on a new helper function, unique_path(), that dies with an
unimplemented error currently but will be implemented in a subsequent
commit.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomerge-ort: handle D/F conflict where directory disappears due to merge
Elijah Newren [Fri, 1 Jan 2021 02:34:39 +0000 (02:34 +0000)]
merge-ort: handle D/F conflict where directory disappears due to merge

When one side has a directory at a given path and the other side of
history has a file at the path, but the merge resolves the directory
away (e.g. because no path within that directory was modified and the
other side deleted it, or because renaming moved all the files
elsewhere), then we don't actually have a conflict anymore.  We just
need to clear away any information related to the relevant directory,
and then the subsequent process_entry() handling can handle the given
path.

Signed-off-by: Elijah Newren <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoCoC: explicitly take any whitespace breakage
Junio C Hamano [Mon, 4 Jan 2021 17:43:31 +0000 (09:43 -0800)]
CoC: explicitly take any whitespace breakage

We'll keep this document mostly in sync with the upstream; let's
help "git am" and "git show" by telling them that they may introduce
what we may consider whitespace errors.

Signed-off-by: Junio C Hamano <redacted>
5 years agoCoC: Update word-wrapping to match upstream
Ævar Arnfjörð Bjarmason [Mon, 28 Dec 2020 17:17:33 +0000 (18:17 +0100)]
CoC: Update word-wrapping to match upstream

When the CoC document was added in 5cdf2301d4a (add a Code of Conduct
document, 2019-09-24) it was added from some 1.4 version of the
document whose word wrapping doesn't match what's currently at [1],
which matches content/version/1/4/code-of-conduct.md in the CoC
repository[2].

Let's update our version to match that, to make reading subsequent
diffs easier. There are no non-whitespace changes here.

1. https://www.contributor-covenant.org/version/1/4/code-of-conduct/
2. https://github.com/ContributorCovenant/contributor_covenant

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoGit 2.30
Junio C Hamano [Sun, 27 Dec 2020 23:15:23 +0000 (15:15 -0800)]
Git 2.30

Signed-off-by: Junio C Hamano <redacted>
5 years agoMerge branch 'pb/doc-git-linkit-fix'
Junio C Hamano [Sun, 27 Dec 2020 23:14:31 +0000 (15:14 -0800)]
Merge branch 'pb/doc-git-linkit-fix'

Docfix.

* pb/doc-git-linkit-fix:
  git.txt: fix typos in 'linkgit' macro invocation

5 years agoMerge tag 'l10n-2.30.0-rnd2' of https://github.com/git-l10n/git-po
Junio C Hamano [Sun, 27 Dec 2020 23:01:16 +0000 (15:01 -0800)]
Merge tag 'l10n-2.30.0-rnd2' of https://github.com/git-l10n/git-po

l10n for Git 2.30.0 round 2

* tag 'l10n-2.30.0-rnd2' of https://github.com/git-l10n/git-po:
  l10n: zh_CN: for git v2.30.0 l10n round 1 and 2
  l10n: zh_TW.po: v2.30.0 round 2 (1 untranslated)
  l10n: pl.po: add translation and set team leader
  l10n: pl.po: started Polish translation
  l10n: de.po: Update German translation for Git 2.30.0
  l10n: Update Catalan translation
  l10n: bg.po: Updated Bulgarian translation (5037t)
  l10n: fr.po v2.30.0 rnd 2
  l10n: tr: v2.30.0-r2
  l10n: sv.po: Update Swedish translation (5037t0f0u)
  l10n: vi.po(5037t): v2.30.0 rnd 2
  l10n: git.pot: v2.30.0 round 2 (1 new, 2 removed)
  l10n: Update Catalan translation
  l10n: fr.po: v2.30.0 rnd 1
  l10n: fr.po Fix a typo
  l10n: fr fix misleading message
  l10n: tr: v2.30.0-r1
  l10n: sv.po: Update Swedish translation (5038t0f0u)
  l10n: git.pot: v2.30.0 round 1 (70 new, 45 removed)

5 years agol10n: zh_CN: for git v2.30.0 l10n round 1 and 2
Jiang Xin [Mon, 7 Dec 2020 00:10:10 +0000 (08:10 +0800)]
l10n: zh_CN: for git v2.30.0 l10n round 1 and 2

Translate 71 new messages (5037t0f0u) for git 2.30.0.

Reviewed-by: 依云 <redacted>
Signed-off-by: Jiang Xin <redacted>
5 years agoMerge branch 'l10n/zh_TW/201223' of github.com:l10n-tw/git-po
Jiang Xin [Fri, 25 Dec 2020 07:12:02 +0000 (15:12 +0800)]
Merge branch 'l10n/zh_TW/201223' of github.com:l10n-tw/git-po

* 'l10n/zh_TW/201223' of github.com:l10n-tw/git-po:
  l10n: zh_TW.po: v2.30.0 round 2 (1 untranslated)

5 years agol10n: zh_TW.po: v2.30.0 round 2 (1 untranslated)
pan93412 [Wed, 23 Dec 2020 13:52:18 +0000 (21:52 +0800)]
l10n: zh_TW.po: v2.30.0 round 2 (1 untranslated)

Signed-off-by: pan93412 <redacted>
5 years agol10n: pl.po: add translation and set team leader
Arusekk [Wed, 2 Dec 2020 23:19:58 +0000 (00:19 +0100)]
l10n: pl.po: add translation and set team leader

Signed-off-by: Arusekk <redacted>
5 years agoGit 2.30-rc2
Junio C Hamano [Wed, 23 Dec 2020 21:57:41 +0000 (13:57 -0800)]
Git 2.30-rc2

Signed-off-by: Junio C Hamano <redacted>
5 years agoMerge branch 'nk/refspecs-negative-fix'
Junio C Hamano [Wed, 23 Dec 2020 21:59:46 +0000 (13:59 -0800)]
Merge branch 'nk/refspecs-negative-fix'

Hotfix for recent regression.

* nk/refspecs-negative-fix:
  negative-refspec: improve comment on query_matches_negative_refspec
  negative-refspec: fix segfault on : refspec

5 years agoMerge branch 'ma/maintenance-crontab-fix'
Junio C Hamano [Wed, 23 Dec 2020 21:59:46 +0000 (13:59 -0800)]
Merge branch 'ma/maintenance-crontab-fix'

Hotfix for a topic of this cycle.

* ma/maintenance-crontab-fix:
  t7900-maintenance: test for magic markers
  gc: fix handling of crontab magic markers
  git-maintenance.txt: add missing word

5 years agoMerge branch 'dl/checkout-p-merge-base'
Junio C Hamano [Wed, 23 Dec 2020 21:59:46 +0000 (13:59 -0800)]
Merge branch 'dl/checkout-p-merge-base'

Fix to a regression introduced during this cycle.

* dl/checkout-p-merge-base:
  checkout -p: handle tree arguments correctly again

5 years agoMerge branch 'js/no-more-prepare-for-main-in-test'
Junio C Hamano [Wed, 23 Dec 2020 21:59:46 +0000 (13:59 -0800)]
Merge branch 'js/no-more-prepare-for-main-in-test'

Test coverage fix.

* js/no-more-prepare-for-main-in-test:
  tests: drop the `PREPARE_FOR_MAIN_BRANCH` prereq
  t9902: use `main` as initial branch name
  t6302: use `main` as initial branch name
  t5703: use `main` as initial branch name
  t5510: use `main` as initial branch name
  t5505: finalize transitioning to using the branch name `main`
  t3205: finalize transitioning to using the branch name `main`
  t3203: complete the transition to using the branch name `main`
  t3201: finalize transitioning to using the branch name `main`
  t3200: finish transitioning to the initial branch name `main`
  t1400: use `main` as initial branch name

5 years agoMerge branch 'jx/pack-redundant-on-single-pack'
Junio C Hamano [Wed, 23 Dec 2020 21:59:46 +0000 (13:59 -0800)]
Merge branch 'jx/pack-redundant-on-single-pack'

"git pack-redandant" when there is only one packfile used to crash,
which has been corrected.

* jx/pack-redundant-on-single-pack:
  pack-redundant: fix crash when one packfile in repo

5 years agol10n: pl.po: started Polish translation
m4sk1n [Mon, 16 Jan 2017 19:31:10 +0000 (20:31 +0100)]
l10n: pl.po: started Polish translation

Signed-off-by: Arusekk <redacted>
5 years agogit-p4: fix syncing file types with pattern
Daniel Levin [Wed, 23 Dec 2020 14:37:27 +0000 (14:37 +0000)]
git-p4: fix syncing file types with pattern

Example of pattern file type: text+k

Text filtered through the p4 pattern regexp must be converted from
string back to bytes, otherwise 'data' command for the fast-import
will receive extra invalid characters, followed by the fast-import
process error.

CC: Yang Zhao <redacted>
Signed-off-by: Daniel Levin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocore.abbrev=no disables abbreviations
Eric Wong [Tue, 1 Sep 2020 07:43:55 +0000 (07:43 +0000)]
core.abbrev=no disables abbreviations

This allows users to write hash-agnostic scripts and configs by
disabling abbreviations.  Using "-c core.abbrev=40" will be
insufficient with SHA-256, and "-c core.abbrev=64" won't work with
SHA-1 repos today.

Signed-off-by: Eric Wong <redacted>
[jc: tweaked implementation, added doc and a test]
Signed-off-by: Junio C Hamano <redacted>
5 years agol10n: de.po: Update German translation for Git 2.30.0
Matthias Rüster [Sat, 19 Dec 2020 12:53:23 +0000 (13:53 +0100)]
l10n: de.po: Update German translation for Git 2.30.0

Reviewed-by: Ralf Thielow <redacted>
Reviewed-by: Phillip Szelat <redacted>
Signed-off-by: Matthias Rüster <redacted>
5 years agomktag doc: grammar fix, when exists -> when it exists
Ævar Arnfjörð Bjarmason [Wed, 23 Dec 2020 01:35:47 +0000 (02:35 +0100)]
mktag doc: grammar fix, when exists -> when it exists

Amend the wording of documentation added in 6cfec03680 (mktag:
minimally update the description., 2007-06-10). It makes more sense to
say "when it exists" here, as we're referring to "the message".

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agomktag doc: say <hash> not <sha1>
Ævar Arnfjörð Bjarmason [Wed, 23 Dec 2020 01:35:46 +0000 (02:35 +0100)]
mktag doc: say <hash> not <sha1>

Change the "mktag" documentation to refer to the input hash as just
"hash", not "sha1". This command has supported SHA-256 for a while
now.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoMerge branch 'master' of github.com:Softcatala/git-po
Jiang Xin [Wed, 23 Dec 2020 00:44:44 +0000 (08:44 +0800)]
Merge branch 'master' of github.com:Softcatala/git-po

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

5 years agot/perf: avoid unnecessary test_export() recursion
Eric Sunshine [Sun, 20 Dec 2020 21:27:40 +0000 (16:27 -0500)]
t/perf: avoid unnecessary test_export() recursion

test_export() has been self-recursive since its inception even though a
simple for-loop would have served just as well to append its arguments
to the `test_export_` variable separated by the pipe character "|".
Recently `test_export_` was changed instead to a space-separated list of
tokens to be exported, an operation which can be accomplished via a
single simple assignment, with no need for looping or recursion.
Therefore, simplify the implementation.

While at it, take advantage of the fact that variable names to be
exported are shell identifiers, thus won't be composed of special
characters or whitespace, thus simple a `$*` can be used rather than
magical `"$@"`.

Signed-off-by: Eric Sunshine <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agogit.txt: fix typos in 'linkgit' macro invocation
Philippe Blain [Tue, 22 Dec 2020 15:44:42 +0000 (15:44 +0000)]
git.txt: fix typos in 'linkgit' macro invocation

The 'linkgit' Asciidoc macro is misspelled as 'linkit' in the
description of 'GIT_SEQUENCE_EDITOR' since the addition of that variable
to git(1) in 902a126eca (doc: mention GIT_SEQUENCE_EDITOR and
'sequence.editor' more, 2020-08-31). Also, it uses two colons instead of
one.

Fix that.

Signed-off-by: Philippe Blain <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agol10n: Update Catalan translation
Jordi Mas [Tue, 22 Dec 2020 17:04:53 +0000 (18:04 +0100)]
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <redacted>
5 years agol10n: bg.po: Updated Bulgarian translation (5037t)
Alexander Shopov [Sun, 20 Dec 2020 18:00:54 +0000 (19:00 +0100)]
l10n: bg.po: Updated Bulgarian translation (5037t)

Signed-off-by: Alexander Shopov <redacted>
5 years agonegative-refspec: improve comment on query_matches_negative_refspec
Nipunn Koorapati [Tue, 22 Dec 2020 03:58:17 +0000 (03:58 +0000)]
negative-refspec: improve comment on query_matches_negative_refspec

Comment did not adequately explain how the two loops work
together to achieve the goal of querying for matching of any
negative refspec.

Signed-off-by: Nipunn Koorapati <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agonegative-refspec: fix segfault on : refspec
Nipunn Koorapati [Tue, 22 Dec 2020 03:58:16 +0000 (03:58 +0000)]
negative-refspec: fix segfault on : refspec

The logic added to check for negative pathspec match by c0192df630
(refspec: add support for negative refspecs, 2020-09-30) looks at
refspec->src assuming it is never NULL, however when
remote.origin.push is set to ":", then refspec->src is NULL,
causing a segfault within strcmp.

Tell git to handle matching refspec by adding the needle to the
set of positively matched refspecs, since matching ":" refspecs
match anything as src.

Add test for matching refspec pushes fetch-negative-refspec
both individually and in combination with a negative refspec.

Signed-off-by: Nipunn Koorapati <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agoMerge branch 'fr_2.30_rnd2' of github.com:jnavila/git
Jiang Xin [Tue, 22 Dec 2020 00:46:17 +0000 (08:46 +0800)]
Merge branch 'fr_2.30_rnd2' of github.com:jnavila/git

* 'fr_2.30_rnd2' of github.com:jnavila/git:
  l10n: fr.po v2.30.0 rnd 2

5 years agot7900-maintenance: test for magic markers
Martin Ågren [Mon, 21 Dec 2020 21:26:33 +0000 (22:26 +0100)]
t7900-maintenance: test for magic markers

When we insert our "BEGIN" and "END" markers into the cron table, it's
so that a Git version from many years into the future would be able to
identify this region in the cron table. Let's add a test to make sure
that these markers don't ever change.

Signed-off-by: Martin Ågren <redacted>
Acked-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agogc: fix handling of crontab magic markers
Martin Ågren [Mon, 21 Dec 2020 21:26:32 +0000 (22:26 +0100)]
gc: fix handling of crontab magic markers

On `git maintenance start`, we add a few entries to the user's cron
table. We wrap our entries using two magic markers, "# BEGIN GIT
MAINTENANCE SCHEDULE" and "# END GIT MAINTENANCE SCHEDULE". At a later
`git maintenance stop`, we will go through the table and remove these
lines. Or rather, we will remove the "BEGIN" marker, the "END" marker
and everything between them.

Alas, we have a bug in how we detect the "END" marker: we don't. As we
loop through all the lines of the crontab, if we are in the "old
region", i.e., the region we're aiming to remove, we make an early
`continue` and don't get as far as checking for the "END" marker. Thus,
once we've seen our "BEGIN", we remove everything until the end of the
file.

Rewrite the logic for identifying these markers. There are four cases
that are mutually exclusive: The current line starts a region or it ends
it, or it's firmly within the region, or it's outside of it (and should
be printed).

Signed-off-by: Martin Ågren <redacted>
Acked-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agogit-maintenance.txt: add missing word
Martin Ågren [Mon, 21 Dec 2020 21:26:31 +0000 (22:26 +0100)]
git-maintenance.txt: add missing word

Add a missing "a" before "bunch".

Signed-off-by: Martin Ågren <redacted>
Acked-by: Derrick Stolee <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agocheckout -p: handle tree arguments correctly again
Johannes Schindelin [Sat, 19 Dec 2020 14:55:59 +0000 (14:55 +0000)]
checkout -p: handle tree arguments correctly again

This fixes a segmentation fault.

The bug is caused by dereferencing `new_branch_info->commit` when it is
`NULL`, which is the case when the tree-ish argument is actually a tree,
not a commit-ish. This was introduced in 5602b500c3c (builtin/checkout:
fix `git checkout -p HEAD...` bug, 2020-10-07), where we tried to ensure
that the special tree-ish `HEAD...` is handled correctly.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot4013: add tests for --diff-merges=first-parent
Sergey Organov [Mon, 21 Dec 2020 15:20:00 +0000 (18:20 +0300)]
t4013: add tests for --diff-merges=first-parent

This new option provides essential new functionality, changing diff
output to first parent only, without changing history traversal mode,
so it deserves its own test.

As we do it, add additional test that --diff-merges=first-parent by
itself doesn't imply -p and only outputs diffs for merge commits.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodoc/git-show: include --diff-merges description
Sergey Organov [Mon, 21 Dec 2020 15:19:59 +0000 (18:19 +0300)]
doc/git-show: include --diff-merges description

Move description of --diff-merges option from git-log.txt to
diff-options.txt so that it is included in the git-show help.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodoc/rev-list-options: document --first-parent changes merges format
Sergey Organov [Mon, 21 Dec 2020 15:19:58 +0000 (18:19 +0300)]
doc/rev-list-options: document --first-parent changes merges format

After introduction of the --diff-merges=first-parent, the
--first-parent sets the default format for merges to the same value as
this new option. Document this behavior and add corresponding
reference to --diff-merges.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodoc/diff-generate-patch: mention new --diff-merges option
Sergey Organov [Mon, 21 Dec 2020 15:19:57 +0000 (18:19 +0300)]
doc/diff-generate-patch: mention new --diff-merges option

Mention --diff-merges instead of -m in a note to merge formats to aid
discoverability, as -m is now described among --diff-merges options
anyway.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodoc/git-log: describe new --diff-merges options
Sergey Organov [Mon, 21 Dec 2020 15:19:56 +0000 (18:19 +0300)]
doc/git-log: describe new --diff-merges options

Describe all the new --diff-merges options in the git-log.txt and
adopt description of originals accordingly.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: add '--diff-merges=1' as synonym for 'first-parent'
Sergey Organov [Mon, 21 Dec 2020 15:19:55 +0000 (18:19 +0300)]
diff-merges: add '--diff-merges=1' as synonym for 'first-parent'

As we now have --diff-merges={m|c|cc}, add --diff-merges=1 as synonym
for --diff-merges=first-parent, to have shorter mnemonics for it as
well.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: add old mnemonic counterparts to --diff-merges
Sergey Organov [Mon, 21 Dec 2020 15:19:54 +0000 (18:19 +0300)]
diff-merges: add old mnemonic counterparts to --diff-merges

This adds --diff-merges={m|c|cc} values that match mnemonics of old
options, for those who are used to them.

Note that, say, --diff-meres=cc behaves differently than --cc, as the
latter implies -p and therefore enables diffs for all the commits,
while the former enables output of diffs for merge commits only.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: let new options enable diff without -p
Sergey Organov [Mon, 21 Dec 2020 15:19:53 +0000 (18:19 +0300)]
diff-merges: let new options enable diff without -p

New options don't have any visible effect unless -p is either given or
implied, as unlike -c/-cc we don't imply -p with --diff-merges. To fix
this, this patch adds new functionality by letting new options enable
output of diffs for merge commits only.

Add 'merges_need_diff' field and set it whenever diff output for merges is
enabled by any of the new options.

Extend diff output logic accordingly, to output diffs for merges when
'merges_need_diff' is set even when no -p has been provided.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: do not imply -p for new options
Sergey Organov [Mon, 21 Dec 2020 15:19:52 +0000 (18:19 +0300)]
diff-merges: do not imply -p for new options

Add 'combined_imply_patch' field and set it only for old --cc/-c
options, then imply -p if this flag is set instead of implying -p
whenever 'combined_merge' flag is set.

We don't want new --diff-merge options to imply -p, to make it
possible to enable output of diffs for merges independently from
non-merge commits. At the same time we want to preserve behavior of
old --c/-c/-m options and their interactions with --first-parent, to
stay backward-compatible.

This patch is first step in this direction: it separates old "--cc/-c
imply -p" logic from the rest of the options.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: implement new values for --diff-merges
Sergey Organov [Mon, 21 Dec 2020 15:19:51 +0000 (18:19 +0300)]
diff-merges: implement new values for --diff-merges

We first implement new options as exact synonyms for their original
counterparts, to get all the infrastructure right, and keep functional
improvements for later commits.

The following values are implemented:

--diff-merges=         old equivalent
first|first-parent    = --first-parent (only format implications)
sep|separate          = -m
comb|combined         = -c
dense| dense-combined = --cc

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: make -m/-c/--cc explicitly mutually exclusive
Sergey Organov [Mon, 21 Dec 2020 15:19:50 +0000 (18:19 +0300)]
diff-merges: make -m/-c/--cc explicitly mutually exclusive

-c/--cc got precedence over -m only because of external logic where
corresponding flags are checked before that for -m. This is too
error-prone, so add code that explicitly makes these 3 options
mutually exclusive, so that the last option specified on the
command-line gets precedence.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: refactor opt settings into separate functions
Sergey Organov [Mon, 21 Dec 2020 15:19:49 +0000 (18:19 +0300)]
diff-merges: refactor opt settings into separate functions

To prepare introduction of new options some of which will be synonyms
to existing options, let every option handling code just call
corresponding function.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: get rid of now empty diff_merges_init_revs()
Sergey Organov [Mon, 21 Dec 2020 15:19:48 +0000 (18:19 +0300)]
diff-merges: get rid of now empty diff_merges_init_revs()

After getting rid of 'ignore_merges' field, the diff_merges_init_revs()
function became empty. Get rid of it.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: group diff-merge flags next to each other inside 'rev_info'
Sergey Organov [Mon, 21 Dec 2020 15:19:47 +0000 (18:19 +0300)]
diff-merges: group diff-merge flags next to each other inside 'rev_info'

The relevant flags were somewhat scattered over definition of 'struct
rev_info'. Rearrange them to group them together.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: split 'ignore_merges' field
Sergey Organov [Mon, 21 Dec 2020 15:19:46 +0000 (18:19 +0300)]
diff-merges: split 'ignore_merges' field

'ignore_merges' was 3-way field that served two distinct purposes that
we now assign to 2 new independent flags: 'separate_merges', and
'explicit_diff_merges'.

'separate_merges' tells that we need to output diff format containing
separate diff for every parent (as opposed to 'combine_merges').

'explicit_diff_merges' tells that at least one of diff-merges options
has been explicitly specified on the command line, so no defaults
should apply.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: fix -m to properly override -c/--cc
Sergey Organov [Mon, 21 Dec 2020 15:19:45 +0000 (18:19 +0300)]
diff-merges: fix -m to properly override -c/--cc

Logically, -m, -c, --cc specify 3 different formats for representing
merge commits, yet -m doesn't in fact override -c or --cc, that makes
no sense.

Fix -m to properly override -c/--cc, and change the tests accordingly.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot4013: add tests for -m failing to override -c/--cc
Sergey Organov [Mon, 21 Dec 2020 15:19:44 +0000 (18:19 +0300)]
t4013: add tests for -m failing to override -c/--cc

Logically, -m, -c, --cc specify 3 different formats for representing
merge commits, yet -m doesn't in fact override -c or --cc, that makes
no sense.

Add 2 expected to fail tests that demonstrate the problem.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agot4013: support test_expect_failure through ':failure' magic
Sergey Organov [Mon, 21 Dec 2020 15:19:43 +0000 (18:19 +0300)]
t4013: support test_expect_failure through ':failure' magic

Add support to be able to specify expected failure, through :failure
magic, like this:

:failure cmd args

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: revise revs->diff flag handling
Sergey Organov [Mon, 21 Dec 2020 15:19:42 +0000 (18:19 +0300)]
diff-merges: revise revs->diff flag handling

Do not set revs->diff when we encounter an option that needs it, as
it'd be impossible to undo later. Besides, some other options than
what we handle here set this flag as well, and we'd interfere with
them trying to clear this flag later.

Rather set revs->diff, if finally needed, in diff_merges_setup_revs().

As an additional bonus, this also makes our code shorter.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: handle imply -p on -c/--cc logic for log.c
Sergey Organov [Mon, 21 Dec 2020 15:19:41 +0000 (18:19 +0300)]
diff-merges: handle imply -p on -c/--cc logic for log.c

Move logic that handles implying -p on -c/--cc from
log_setup_revisions_tweak() to diff_merges_setup_revs(), where it
belongs.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: introduce revs->first_parent_merges flag
Sergey Organov [Mon, 21 Dec 2020 15:19:40 +0000 (18:19 +0300)]
diff-merges: introduce revs->first_parent_merges flag

This new field allows us to separate format of diff for merges from
'first_parent_only' flag which primary purpose is limiting history
traversal.

This change further localizes diff format selection logic into the
diff-merges.c file.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: new function diff_merges_set_dense_combined_if_unset()
Sergey Organov [Mon, 21 Dec 2020 15:19:39 +0000 (18:19 +0300)]
diff-merges: new function diff_merges_set_dense_combined_if_unset()

Call it where given functionality is needed instead of direct
checking/tweaking of diff merges related fields.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: new function diff_merges_suppress()
Sergey Organov [Mon, 21 Dec 2020 15:19:38 +0000 (18:19 +0300)]
diff-merges: new function diff_merges_suppress()

This function sets all the relevant flags to disabled state, so that
no code that checks only one of them get it wrong.

Then we call this new function everywhere where diff merges output
suppression is needed.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: re-arrange functions to match the order they are called in
Sergey Organov [Mon, 21 Dec 2020 15:19:37 +0000 (18:19 +0300)]
diff-merges: re-arrange functions to match the order they are called in

For clarity, define public functions in the order they are called, to
make logic inter-dependencies easier to grok.

Signed-off-by: Sergey Organov <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 years agodiff-merges: rename diff_merges_default_to_enable() to match semantics
Sergey Organov [Mon, 21 Dec 2020 15:19:36 +0000 (18:19 +0300)]
diff-merges: rename diff_merges_default_to_enable() to match semantics

Rename diff_merges_default_to_enable() to
diff_merges_default_to_first_parent() to match its semantics.

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