summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-format25
-rw-r--r--.github/workflows/check-style.yml34
-rw-r--r--.gitlab-ci.yml25
-rw-r--r--Documentation/CodingGuidelines27
-rw-r--r--Documentation/RelNotes/2.47.0.txt52
-rw-r--r--Documentation/ReviewingGuidelines.txt25
-rw-r--r--Documentation/git-commit.txt2
-rw-r--r--Documentation/git-rebase.txt2
-rw-r--r--Documentation/githooks.txt15
-rw-r--r--Documentation/howto/maintain-git.txt158
-rwxr-xr-xGIT-VERSION-GEN2
-rw-r--r--Makefile4
l---------RelNotes2
-rw-r--r--add-patch.c23
-rw-r--r--builtin/am.c2
-rw-r--r--builtin/checkout.c23
-rw-r--r--builtin/commit.c2
-rw-r--r--builtin/merge-recursive.c2
-rw-r--r--builtin/merge-tree.c2
-rw-r--r--builtin/merge.c2
-rw-r--r--builtin/replay.c2
-rw-r--r--builtin/show-ref.c4
-rw-r--r--builtin/stash.c2
-rwxr-xr-xci/check-whitespace.sh10
-rwxr-xr-xci/install-dependencies.sh4
-rwxr-xr-xci/run-style-check.sh25
-rw-r--r--config.mak.uname1
-rw-r--r--log-tree.c2
-rw-r--r--merge-recursive.c29
-rw-r--r--merge-recursive.h5
-rw-r--r--reftable/reftable-tests.h1
-rw-r--r--sequencer.c4
-rw-r--r--t/helper/test-reftable.c1
-rwxr-xr-xt/t3701-add-interactive.sh19
-rwxr-xr-xt/t7201-co.sh13
-rwxr-xr-xt/t7615-diff-algo-with-mergy-operations.sh60
-rw-r--r--t/t7615/base.c17
-rw-r--r--t/t7615/ours.c17
-rw-r--r--t/t7615/theirs.c17
-rw-r--r--t/unit-tests/t-reftable-merged.c (renamed from reftable/merged_test.c)208
-rw-r--r--t/unit-tests/t-strvec.c47
41 files changed, 674 insertions, 243 deletions
diff --git a/.clang-format b/.clang-format
index 6408251577..16fd12253e 100644
--- a/.clang-format
+++ b/.clang-format
@@ -72,6 +72,10 @@ AlwaysBreakAfterReturnType: None
BinPackArguments: true
BinPackParameters: true
+# Add no space around the bit field
+# unsigned bf:2;
+BitFieldColonSpacing: None
+
# Attach braces to surrounding context except break before braces on function
# definitions.
# void foo()
@@ -96,6 +100,12 @@ BreakStringLiterals: false
# Switch statement body is always indented one level more than case labels.
IndentCaseLabels: false
+# Indents directives before the hash.
+# #if FOO
+# # include <foo>
+# #endif
+IndentPPDirectives: AfterHash
+
# Don't indent a function definition or declaration if it is wrapped after the
# type
IndentWrappedFunctionNames: false
@@ -108,11 +118,18 @@ PointerAlignment: Right
# x = (int32)y; not x = (int32) y;
SpaceAfterCStyleCast: false
+# No space is inserted after the logical not operator
+SpaceAfterLogicalNot: false
+
# Insert spaces before and after assignment operators
# int a = 5; not int a=5;
# a += 42; a+=42;
SpaceBeforeAssignmentOperators: true
+# Spaces will be removed before case colon.
+# case 1: break; not case 1 : break;
+SpaceBeforeCaseColon: false
+
# Put a space before opening parentheses only after control statement keywords.
# void f() {
# if (true) {
@@ -124,6 +141,14 @@ SpaceBeforeParens: ControlStatements
# Don't insert spaces inside empty '()'
SpaceInEmptyParentheses: false
+# No space before first '[' in arrays
+# int a[5][5]; not int a [5][5];
+SpaceBeforeSquareBrackets: false
+
+# No space will be inserted into {}
+# while (true) {} not while (true) { }
+SpaceInEmptyBlock: false
+
# The number of spaces before trailing line comments (// - comments).
# This does not affect trailing block comments (/* - comments).
SpacesBeforeTrailingComments: 1
diff --git a/.github/workflows/check-style.yml b/.github/workflows/check-style.yml
new file mode 100644
index 0000000000..c052a5df23
--- /dev/null
+++ b/.github/workflows/check-style.yml
@@ -0,0 +1,34 @@
+name: check-style
+
+# Get the repository with all commits to ensure that we can analyze
+# all of the commits contributed via the Pull Request.
+
+on:
+ pull_request:
+ types: [opened, synchronize]
+
+# Avoid unnecessary builds. Unlike the main CI jobs, these are not
+# ci-configurable (but could be).
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ check-style:
+ env:
+ CC: clang
+ jobname: ClangFormat
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - run: ci/install-dependencies.sh
+
+ - name: git clang-format
+ continue-on-error: true
+ id: check_out
+ run: |
+ ./ci/run-style-check.sh \
+ "${{github.event.pull_request.base.sha}}"
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 37b991e080..2589098eff 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -118,8 +118,31 @@ check-whitespace:
image: ubuntu:latest
before_script:
- ./ci/install-dependencies.sh
+ # Since $CI_MERGE_REQUEST_TARGET_BRANCH_SHA is only defined for merged
+ # pipelines, we fallback to $CI_MERGE_REQUEST_DIFF_BASE_SHA, which should
+ # be defined in all pipelines.
script:
- - ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA"
+ - |
+ R=${CI_MERGE_REQUEST_TARGET_BRANCH_SHA-${CI_MERGE_REQUEST_DIFF_BASE_SHA:?}} || exit
+ ./ci/check-whitespace.sh "$R"
+ rules:
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+
+check-style:
+ image: ubuntu:latest
+ allow_failure: true
+ variables:
+ CC: clang
+ jobname: ClangFormat
+ before_script:
+ - ./ci/install-dependencies.sh
+ # Since $CI_MERGE_REQUEST_TARGET_BRANCH_SHA is only defined for merged
+ # pipelines, we fallback to $CI_MERGE_REQUEST_DIFF_BASE_SHA, which should
+ # be defined in all pipelines.
+ script:
+ - |
+ R=${CI_MERGE_REQUEST_TARGET_BRANCH_SHA-${CI_MERGE_REQUEST_DIFF_BASE_SHA:?}} || exit
+ ./ci/run-style-check.sh "$R"
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 1d92b2da03..52afb2725f 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -204,6 +204,33 @@ For shell scripts specifically (not exhaustive):
local variable="$value"
local variable="$(command args)"
+ - The common construct
+
+ VAR=VAL command args
+
+ to temporarily set and export environment variable VAR only while
+ "command args" is running is handy, but this triggers an
+ unspecified behaviour according to POSIX when used for a command
+ that is not an external command (like shell functions). Indeed,
+ dash 0.5.10.2-6 on Ubuntu 20.04, /bin/sh on FreeBSD 13, and AT&T
+ ksh all make a temporary assignment without exporting the variable,
+ in such a case. As it does not work portably across shells, do not
+ use this syntax for shell functions. A common workaround is to do
+ an explicit export in a subshell, like so:
+
+ (incorrect)
+ VAR=VAL func args
+
+ (correct)
+ (
+ VAR=VAL &&
+ export VAR &&
+ func args
+ )
+
+ but be careful that the effect "func" makes to the variables in the
+ current shell will be lost across the subshell boundary.
+
- Use octal escape sequences (e.g. "\302\242"), not hexadecimal (e.g.
"\xc2\xa2") in printf format strings, since hexadecimal escape
sequences are not portable.
diff --git a/Documentation/RelNotes/2.47.0.txt b/Documentation/RelNotes/2.47.0.txt
new file mode 100644
index 0000000000..fc713b4696
--- /dev/null
+++ b/Documentation/RelNotes/2.47.0.txt
@@ -0,0 +1,52 @@
+Git v2.47 Release Notes
+=======================
+
+UI, Workflows & Features
+------------------------
+
+ * Many Porcelain commands that internally use the merge machinery
+ were taught to consistently honor the diff.algorithm configuration.
+
+ * A few descriptions in "git show-ref -h" have been clarified.
+
+
+Performance, Internal Implementation, Development Support etc.
+--------------------------------------------------------------
+
+ * A build tweak knob has been simplified by not setting the value
+ that is already the default; another unused one has been removed.
+
+ * A CI job that use clang-format to check coding style issues in new
+ code has been added.
+
+ * The reviewing guidelines document now explicitly encourages people
+ to give positive reviews and how.
+
+
+Fixes since v2.46
+-----------------
+
+ * "git add -p" by users with diff.suppressBlankEmpty set to true
+ failed to parse the patch that represents an unmodified empty line
+ with an empty line (not a line with a single space on it), which
+ has been corrected.
+ (merge 60cf761ed1 pw/add-patch-with-suppress-blank-empty later to maint).
+
+ * "git checkout --ours" (no other arguments) complained that the
+ option is incompatible with branch switching, which is technically
+ correct, but found confusing by some users. It now says that the
+ user needs to give pathspec to specify what paths to checkout.
+ (merge d1e6c61272 jc/checkout-no-op-switch-errors later to maint).
+
+ * It has been documented that we avoid "VAR=VAL shell_func" and why.
+ (merge 728a1962cd jc/doc-one-shot-export-with-shell-func later to maint).
+
+ * "git rebase --help" referred to "offset" (the difference between
+ the location a change was taken from and the change gets replaced)
+ incorrectly and called it "fuzz", which has been corrected.
+ (merge 70058db385 jc/doc-rebase-fuzz-vs-offset-fix later to maint).
+
+ * Other code cleanup, docfix, build fix, etc.
+ (merge 8db8786fc2 jt/doc-post-receive-hook-update later to maint).
+ (merge 1c473dd6af tn/doc-commit-fix later to maint).
+ (merge bb0498b1bb jc/how-to-maintain-updates later to maint).
diff --git a/Documentation/ReviewingGuidelines.txt b/Documentation/ReviewingGuidelines.txt
index 515d470d23..6534643cff 100644
--- a/Documentation/ReviewingGuidelines.txt
+++ b/Documentation/ReviewingGuidelines.txt
@@ -72,12 +72,29 @@ guidance, and concrete tips for interacting with patches on the mailing list.
could fix it. This not only helps the author to understand and fix the issue,
it also deepens and improves your understanding of the topic.
-- Reviews do not need to exclusively point out problems. Feel free to "think out
+- Reviews do not need to exclusively point out problems. Positive
+ reviews indicate that it is not only the original author of the
+ patches who care about the issue the patches address, and are
+ highly encouraged.
+
+- Do not hesitate to give positive reviews on a series from your
+ work colleague. If your positive review is written well, it will
+ not make you look as if you two are representing corporate
+ interest on a series that is otherwise uninteresting to other
+ community members and shoving it down their throat.
+
+- Write a positive review in such a way that others can understand
+ why you support the goal, the approach, and the implementation the
+ patches took. Make sure to demonstrate that you did thoroughly read
+ the series and understood problem area well enough to be able to
+ say that the patches are written well. Feel free to "think out
loud" in your review: describe how you read & understood a complex section of
a patch, ask a question about something that confused you, point out something
- you found exceptionally well-written, etc. In particular, uplifting feedback
- goes a long way towards encouraging contributors to participate more actively
- in the Git community.
+ you found exceptionally well-written, etc.
+
+- In particular, uplifting feedback goes a long way towards
+ encouraging contributors to participate more actively in the Git
+ community.
==== Performing your review
- Provide your review comments per-patch in a plaintext "Reply-All" email to the
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 89ecfc63a8..c822113c11 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
'git commit' [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
- [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)]
+ [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>]
[-F <file> | -m <msg>] [--reset-author] [--allow-empty]
[--allow-empty-message] [--no-verify] [-e] [--author=<author>]
[--date=<date>] [--cleanup=<mode>] [--[no-]status]
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 74df345f9e..b18cdbc023 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -737,7 +737,7 @@ The 'apply' backend works by creating a sequence of patches (by calling
`format-patch` internally), and then applying the patches in sequence
(calling `am` internally). Patches are composed of multiple hunks,
each with line numbers, a context region, and the actual changes. The
-line numbers have to be taken with some fuzz, since the other side
+line numbers have to be taken with some offset, since the other side
will likely have inserted or deleted lines earlier in the file. The
context region is meant to help find how to adjust the line numbers in
order to apply the changes to the right lines. However, if multiple
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 06e997131b..0397dec64d 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -415,13 +415,13 @@ post-receive
This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
`git push` and updates reference(s) in its repository.
-It executes on the remote repository once after all the refs have
-been updated.
+The hook executes on the remote repository once after all the proposed
+ref updates are processed and if at least one ref is updated as the
+result.
-This hook executes once for the receive operation. It takes no
-arguments, but gets the same information as the
-<<pre-receive,'pre-receive'>>
-hook does on its standard input.
+The hook takes no arguments. It receives one line on standard input for
+each ref that is successfully updated following the same format as the
+<<pre-receive,'pre-receive'>> hook.
This hook does not affect the outcome of `git receive-pack`, as it
is called after the real work is done.
@@ -448,6 +448,9 @@ environment variables will not be set. If the client selects
to use push options, but doesn't transmit any, the count variable
will be set to zero, `GIT_PUSH_OPTION_COUNT=0`.
+See the "post-receive" section in linkgit:git-receive-pack[1] for
+additional details.
+
[[post-update]]
post-update
~~~~~~~~~~~
diff --git a/Documentation/howto/maintain-git.txt b/Documentation/howto/maintain-git.txt
index 013014bbef..41f54050f8 100644
--- a/Documentation/howto/maintain-git.txt
+++ b/Documentation/howto/maintain-git.txt
@@ -37,22 +37,20 @@ The Policy
The policy on Integration is informally mentioned in "A Note
from the maintainer" message, which is periodically posted to
-this mailing list after each feature release is made.
+the mailing list after each feature release is made:
- Feature releases are numbered as vX.Y.0 and are meant to
contain bugfixes and enhancements in any area, including
functionality, performance and usability, without regression.
- - One release cycle for a feature release is expected to last for
- eight to ten weeks.
-
- - Maintenance releases are numbered as vX.Y.Z and are meant
+ - Maintenance releases are numbered as vX.Y.Z (0 < Z) and are meant
to contain only bugfixes for the corresponding vX.Y.0 feature
release and earlier maintenance releases vX.Y.W (W < Z).
- - 'master' branch is used to prepare for the next feature
+ - The 'master' branch is used to prepare for the next feature
release. In other words, at some point, the tip of 'master'
- branch is tagged with vX.Y.0.
+ branch is tagged as vX.(Y+1).0, when vX.Y.0 is the latest
+ feature release.
- 'maint' branch is used to prepare for the next maintenance
release. After the feature release vX.Y.0 is made, the tip
@@ -63,11 +61,13 @@ this mailing list after each feature release is made.
- 'next' branch is used to publish changes (both enhancements
and fixes) that (1) have worthwhile goal, (2) are in a fairly
good shape suitable for everyday use, (3) but have not yet
- demonstrated to be regression free. New changes are tested
- in 'next' before merged to 'master'.
+ demonstrated to be regression free. Reviews from contributors on
+ the mailing list help to make the determination. After a topic
+ is merged to 'next', it is tested for at least 7 calendar days
+ before getting merged to 'master'.
- 'seen' branch is used to publish other proposed changes that do
- not yet pass the criteria set for 'next'.
+ not yet pass the criteria set for 'next' (see above).
- The tips of 'master' and 'maint' branches will not be rewound to
allow people to build their own customization on top of them.
@@ -86,6 +86,38 @@ this mailing list after each feature release is made.
users are encouraged to test it so that regressions and bugs
are found before new topics are merged to 'master'.
+ - When a problem is found in a topic in 'next', the topic is marked
+ not to be merged to 'master'. Follow-up patches are discussed on
+ the mailing list and applied to the topic after being reviewed and
+ then the topic is merged (again) to 'next'. After going through
+ the usual testing in 'next', the entire (fixed) topic is merged
+ to 'master'.
+
+ - One release cycle for a feature release is expected to last for
+ eight to ten weeks. A few "release candidate" releases are
+ expected to be tagged about a week apart before the final
+ release, and a "preview" release is tagged about a week before
+ the first release candidate gets tagged.
+
+ - After the preview release is tagged, topics that were well
+ reviewed may be merged to 'master' before spending the usual 7
+ calendar days in 'next', with the expectation that any bugs in
+ them can be caught and fixed in the release candidates before
+ the final release.
+
+ - After the first release candidate is tagged, the contributors are
+ strongly encouraged to focus on finding and fixing new regressions
+ introduced during the cycle, over addressing old bugs and any new
+ features. Topics stop getting merged down from 'next' to 'master',
+ and new topics stop getting merged to 'next'. Unless they are fixes
+ to new regressions in the cycle, that is.
+
+ - Soon after a feature release is made, the tip of 'maint' gets
+ fast-forwarded to point at the release. Topics that have been
+ kept in 'next' are merged down to 'master' and a new development
+ cycle starts.
+
+
Note that before v1.9.0 release, the version numbers used to be
structured slightly differently. vX.Y.Z were feature releases while
vX.Y.Z.W were maintenance releases for vX.Y.Z.
@@ -179,12 +211,12 @@ by doing the following:
The initial round is done with:
$ git checkout ai/topic ;# or "git checkout -b ai/topic master"
- $ git am -sc3 mailbox
+ $ git am -sc3 --whitespace=warn mailbox
and replacing an existing topic with subsequent round is done with:
$ git checkout master...ai/topic ;# try to reapply to the same base
- $ git am -sc3 mailbox
+ $ git am -sc3 --whitespace=warn mailbox
to prepare the new round on a detached HEAD, and then
@@ -209,39 +241,59 @@ by doing the following:
(trivial typofixes etc. are often squashed directly into the
patches that need fixing, without being applied as a separate
"SQUASH???" commit), so that they can be removed easily as needed.
+ The expectation is that the original author will make corrections
+ in a reroll.
+ - By now, new topic branches are created and existing topic
+ branches are updated. The integration branches 'next', 'jch',
+ and 'seen' need to be updated to contain them.
- - Merge maint to master as needed:
+ - If there are topics that have been merged to 'master' and should
+ be merged to 'maint', merge them to 'maint', and update the
+ release notes to the next maintenance release.
- $ git checkout master
- $ git merge maint
- $ make test
+ - Review the latest issue of "What's cooking" again. Are topics
+ that have been sufficiently long in 'next' ready to be merged to
+ 'master'? Are topics we saw earlier and are in 'seen' now got
+ positive reviews and are ready to be merged to 'next'?
- - Merge master to next as needed:
+ - If there are topics that have been cooking in 'next' long enough
+ and should be merged to 'master', merge them to 'master', and
+ update the release notes to the next feature release.
- $ git checkout next
- $ git merge master
- $ make test
+ - If there were patches directly made on 'maint', merge 'maint' to
+ 'master'; make sure that the result is what you want.
- - Review the last issue of "What's cooking" again and see if topics
- that are ready to be merged to 'next' are still in good shape
- (e.g. has there any new issue identified on the list with the
- series?)
+ $ git checkout master
+ $ git merge -m "Sync with 'maint'" --no-log maint
+ $ git log -p --first-parent ORIG_HEAD..
+ $ make test
- - Prepare 'jch' branch, which is used to represent somewhere
- between 'master' and 'seen' and often is slightly ahead of 'next'.
+ - Prepare to update the 'jch' branch, which is used to represent
+ somewhere between 'master' and 'seen' and often is slightly ahead
+ of 'next', and the 'seen' branch, which is used to hold the rest.
$ Meta/Reintegrate master..jch >Meta/redo-jch.sh
The result is a script that lists topics to be merged in order to
- rebuild 'seen' as the input to Meta/Reintegrate script. Remove
- later topics that should not be in 'jch' yet. Add a line that
- consists of '### match next' before the name of the first topic
- in the output that should be in 'jch' but not in 'next' yet.
+ rebuild the current 'jch'. Do the same for 'seen'.
+
+ - Review the Meta/redo-jch.sh and Meta/redo-seen.sh scripts. The
+ former should have a line '### match next'---the idea is that
+ merging the topics listed before the line on top of 'master'
+ should result in a tree identical to that of 'next'.
- - Now we are ready to start merging topics to 'next'. For each
- branch whose tip is not merged to 'next', one of three things can
- happen:
+ - As newly created topics are usually merged near the tip of
+ 'seen', add them to the end of the Meta/redo-seen.sh script.
+ Among the topics that were in 'seen', there may be ones that
+ are not quite ready for 'next' but are getting there. Move
+ them from Meta/redo-seen.sh to the end of Meta/redo-jch.sh.
+ The expectation is that you'd use 'jch' as your daily driver
+ as the first guinea pig, so you should choose carefully.
+
+ - Now we are ready to start rebuilding 'jch' and merging topics to
+ 'next'. For each branch whose tip is not merged to 'next', one
+ of three things can happen:
- The commits are all next-worthy; merge the topic to next;
- The new parts are of mixed quality, but earlier ones are
@@ -252,10 +304,12 @@ by doing the following:
If a topic that was already in 'next' gained a patch, the script
would list it as "ai/topic~1". To include the new patch to the
updated 'next', drop the "~1" part; to keep it excluded, do not
- touch the line. If a topic that was not in 'next' should be
- merged to 'next', add it at the end of the list. Then:
+ touch the line.
+
+ If a topic that was not in 'next' should be merged to 'next', add
+ it before the '### match next' line. Then:
- $ git checkout -B jch master
+ $ git checkout --detach master
$ sh Meta/redo-jch.sh -c1
to rebuild the 'jch' branch from scratch. "-c1" tells the script
@@ -267,26 +321,29 @@ by doing the following:
reference to the variable under its old name), in which case
prepare an appropriate merge-fix first (see appendix), and
rebuild the 'jch' branch from scratch, starting at the tip of
- 'master'.
+ 'master', this time without using "-c1" to merge all topics.
- Then do the same to 'next'
+ Then do the same to 'next'.
$ git checkout next
$ sh Meta/redo-jch.sh -c1 -e
The "-e" option allows the merge message that comes from the
history of the topic and the comments in the "What's cooking" to
- be edited. The resulting tree should match 'jch' as the same set
- of topics are merged on 'master'; otherwise there is a mismerge.
- Investigate why and do not proceed until the mismerge is found
- and rectified.
+ be edited. The resulting tree should match 'jch^{/^### match next'}'
+ as the same set of topics are merged on 'master'; otherwise there
+ is a mismerge. Investigate why and do not proceed until the mismerge
+ is found and rectified.
+
+ If 'master' was updated before you started redoing 'next', then
- $ git diff jch next
+ $ git diff 'jch^{/^### match next}' next
- Then build the rest of 'jch':
+ would show differences that went into 'master' (which 'jch' has,
+ but 'next' does not yet---often it is updates to the release
+ notes). Merge 'master' back to 'next' if that is the case.
- $ git checkout jch
- $ sh Meta/redo-jch.sh
+ $ git merge -m "Sync with 'master'" --no-log master
When all is well, clean up the redo-jch.sh script with
@@ -296,12 +353,7 @@ by doing the following:
merged to 'master'. This may lose '### match next' marker;
add it again to the appropriate place when it happens.
- - Rebuild 'seen'.
-
- $ Meta/Reintegrate jch..seen >Meta/redo-seen.sh
-
- Edit the result by adding new topics that are not still in 'seen'
- in the script. Then
+ - Rebuild 'seen' on top of 'jch'.
$ git checkout -B seen jch
$ sh Meta/redo-seen.sh
@@ -312,7 +364,7 @@ by doing the following:
Double check by running
- $ git branch --no-merged seen
+ $ git branch --no-merged seen '??/*'
to see there is no unexpected leftover topics.
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 7b81915e52..ee71e9d8aa 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=v2.46.0
+DEF_VER=v2.46.GIT
LF='
'
diff --git a/Makefile b/Makefile
index d6479092a0..3863e60b66 100644
--- a/Makefile
+++ b/Makefile
@@ -1340,6 +1340,7 @@ UNIT_TEST_PROGRAMS += t-oidmap
UNIT_TEST_PROGRAMS += t-oidtree
UNIT_TEST_PROGRAMS += t-prio-queue
UNIT_TEST_PROGRAMS += t-reftable-basics
+UNIT_TEST_PROGRAMS += t-reftable-merged
UNIT_TEST_PROGRAMS += t-reftable-record
UNIT_TEST_PROGRAMS += t-strbuf
UNIT_TEST_PROGRAMS += t-strcmp-offset
@@ -1376,7 +1377,7 @@ PTHREAD_CFLAGS =
# For the 'sparse' target
SPARSE_FLAGS ?= -std=gnu99
-SP_EXTRA_FLAGS = -Wno-universal-initializer
+SP_EXTRA_FLAGS =
# For informing GIT-BUILD-OPTIONS of the SANITIZE=leak,address targets
SANITIZE_LEAK =
@@ -2680,7 +2681,6 @@ REFTABLE_OBJS += reftable/writer.o
REFTABLE_TEST_OBJS += reftable/block_test.o
REFTABLE_TEST_OBJS += reftable/dump.o
-REFTABLE_TEST_OBJS += reftable/merged_test.o
REFTABLE_TEST_OBJS += reftable/pq_test.o
REFTABLE_TEST_OBJS += reftable/readwrite_test.o
REFTABLE_TEST_OBJS += reftable/stack_test.o
diff --git a/RelNotes b/RelNotes
index cc696fc869..0104513a31 120000
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/2.46.0.txt \ No newline at end of file
+Documentation/RelNotes/2.47.0.txt \ No newline at end of file
diff --git a/add-patch.c b/add-patch.c
index 6e176cd21a..46f6bddfe5 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -402,6 +402,12 @@ static void complete_file(char marker, struct hunk *hunk)
hunk->splittable_into++;
}
+/* Empty context lines may omit the leading ' ' */
+static int normalize_marker(const char *p)
+{
+ return p[0] == '\n' || (p[0] == '\r' && p[1] == '\n') ? ' ' : p[0];
+}
+
static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
{
struct strvec args = STRVEC_INIT;
@@ -487,6 +493,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
while (p != pend) {
char *eol = memchr(p, '\n', pend - p);
const char *deleted = NULL, *mode_change = NULL;
+ char ch = normalize_marker(p);
if (!eol)
eol = pend;
@@ -534,7 +541,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
* Start counting into how many hunks this one can be
* split
*/
- marker = *p;
+ marker = ch;
} else if (hunk == &file_diff->head &&
starts_with(p, "new file")) {
file_diff->added = 1;
@@ -588,10 +595,10 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
(int)(eol - (plain->buf + file_diff->head.start)),
plain->buf + file_diff->head.start);
- if ((marker == '-' || marker == '+') && *p == ' ')
+ if ((marker == '-' || marker == '+') && ch == ' ')
hunk->splittable_into++;
- if (marker && *p != '\\')
- marker = *p;
+ if (marker && ch != '\\')
+ marker = ch;
p = eol == pend ? pend : eol + 1;
hunk->end = p - plain->buf;
@@ -815,7 +822,7 @@ static int merge_hunks(struct add_p_state *s, struct file_diff *file_diff,
(int)(hunk->end - hunk->start),
plain + hunk->start);
- if (plain[overlap_end] != ' ')
+ if (normalize_marker(&plain[overlap_end]) != ' ')
return error(_("expected context line "
"#%d in\n%.*s"),
(int)(j + 1),
@@ -955,7 +962,7 @@ static int split_hunk(struct add_p_state *s, struct file_diff *file_diff,
context_line_count = 0;
while (splittable_into > 1) {
- ch = s->plain.buf[current];
+ ch = normalize_marker(&s->plain.buf[current]);
if (!ch)
BUG("buffer overrun while splitting hunks");
@@ -1173,14 +1180,14 @@ static ssize_t recount_edited_hunk(struct add_p_state *s, struct hunk *hunk,
header->old_count = header->new_count = 0;
for (i = hunk->start; i < hunk->end; ) {
- switch (s->plain.buf[i]) {
+ switch(normalize_marker(&s->plain.buf[i])) {
case '-':
header->old_count++;
break;
case '+':
header->new_count++;
break;
- case ' ': case '\r': case '\n':
+ case ' ':
header->old_count++;
header->new_count++;
break;
diff --git a/builtin/am.c b/builtin/am.c
index 370f5593f2..a12be088f7 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1630,7 +1630,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
* changes.
*/
- init_merge_options(&o, the_repository);
+ init_ui_merge_options(&o, the_repository);
o.branch1 = "HEAD";
their_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 3cf44b4683..0f21ddd2c6 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -884,7 +884,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
add_files_to_cache(the_repository, NULL, NULL, NULL, 0,
0);
- init_merge_options(&o, the_repository);
+ init_ui_merge_options(&o, the_repository);
o.verbosity = 0;
work = write_in_core_index_as_tree(the_repository);
@@ -1572,6 +1572,10 @@ static void die_if_switching_to_a_branch_in_use(struct checkout_opts *opts,
static int checkout_branch(struct checkout_opts *opts,
struct branch_info *new_branch_info)
{
+ int noop_switch = (!new_branch_info->name &&
+ !opts->new_branch &&
+ !opts->force_detach);
+
if (opts->pathspec.nr)
die(_("paths cannot be used with switching branches"));
@@ -1583,9 +1587,14 @@ static int checkout_branch(struct checkout_opts *opts,
die(_("'%s' cannot be used with switching branches"),
"--[no]-overlay");
- if (opts->writeout_stage)
- die(_("'%s' cannot be used with switching branches"),
- "--ours/--theirs");
+ if (opts->writeout_stage) {
+ const char *msg;
+ if (noop_switch)
+ msg = _("'%s' needs the paths to check out");
+ else
+ msg = _("'%s' cannot be used with switching branches");
+ die(msg, "--ours/--theirs");
+ }
if (opts->force && opts->merge)
die(_("'%s' cannot be used with '%s'"), "-f", "-m");
@@ -1612,10 +1621,8 @@ static int checkout_branch(struct checkout_opts *opts,
die(_("Cannot switch branch to a non-commit '%s'"),
new_branch_info->name);
- if (!opts->switch_branch_doing_nothing_is_ok &&
- !new_branch_info->name &&
- !opts->new_branch &&
- !opts->force_detach)
+ if (noop_switch &&
+ !opts->switch_branch_doing_nothing_is_ok)
die(_("missing branch or commit argument"));
if (!opts->implicit_detach &&
diff --git a/builtin/commit.c b/builtin/commit.c
index dec78dfb86..66427ba82d 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -41,7 +41,7 @@
static const char * const builtin_commit_usage[] = {
N_("git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]\n"
- " [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)]\n"
+ " [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>]\n"
" [-F <file> | -m <msg>] [--reset-author] [--allow-empty]\n"
" [--allow-empty-message] [--no-verify] [-e] [--author=<author>]\n"
" [--date=<date>] [--cleanup=<mode>] [--[no-]status]\n"
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 82bebea15b..e951b09805 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -31,7 +31,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix UNUSED)
char *better1, *better2;
struct commit *result;
- init_merge_options(&o, the_repository);
+ init_basic_merge_options(&o, the_repository);
if (argv[0] && ends_with(argv[0], "-subtree"))
o.subtree_shift = "";
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index dab2fdc2a6..9bca9b5f33 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -571,7 +571,7 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
};
/* Init merge options */
- init_merge_options(&o.merge_options, the_repository);
+ init_ui_merge_options(&o.merge_options, the_repository);
/* Parse arguments */
original_argc = argc - 1; /* ignoring argv[0] */
diff --git a/builtin/merge.c b/builtin/merge.c
index 9fba27d85d..c896b18d1a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -724,7 +724,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
return 2;
}
- init_merge_options(&o, the_repository);
+ init_ui_merge_options(&o, the_repository);
if (!strcmp(strategy, "subtree"))
o.subtree_shift = "";
diff --git a/builtin/replay.c b/builtin/replay.c
index 0448326636..9acf51c32b 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -377,7 +377,7 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
goto cleanup;
}
- init_merge_options(&merge_opt, the_repository);
+ init_basic_merge_options(&merge_opt, the_repository);
memset(&result, 0, sizeof(result));
merge_opt.show_rename_progress = 0;
last_commit = onto;
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 839a5c29f3..85700caae9 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -293,8 +293,8 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
struct show_one_options show_one_opts = {0};
int verify = 0, exists = 0;
const struct option show_ref_options[] = {
- OPT_BOOL(0, "tags", &patterns_opts.tags_only, N_("only show tags (can be combined with branches)")),
- OPT_BOOL(0, "branches", &patterns_opts.branches_only, N_("only show branches (can be combined with tags)")),
+ OPT_BOOL(0, "tags", &patterns_opts.tags_only, N_("only show tags (can be combined with --branches)")),
+ OPT_BOOL(0, "branches", &patterns_opts.branches_only, N_("only show branches (can be combined with --tags)")),
OPT_HIDDEN_BOOL(0, "heads", &patterns_opts.branches_only,
N_("deprecated synonym for --branches")),
OPT_BOOL(0, "exists", &exists, N_("check for reference existence without resolving")),
diff --git a/builtin/stash.c b/builtin/stash.c
index 46b981c4dd..fb75ca219e 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -574,7 +574,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
}
}
- init_merge_options(&o, the_repository);
+ init_ui_merge_options(&o, the_repository);
o.branch1 = "Updated upstream";
o.branch2 = "Stashed changes";
diff --git a/ci/check-whitespace.sh b/ci/check-whitespace.sh
index db399097a5..c40804394c 100755
--- a/ci/check-whitespace.sh
+++ b/ci/check-whitespace.sh
@@ -9,7 +9,7 @@ baseCommit=$1
outputFile=$2
url=$3
-if test "$#" -ne 1 && test "$#" -ne 3
+if test "$#" -ne 1 && test "$#" -ne 3 || test -z "$1"
then
echo "USAGE: $0 <BASE_COMMIT> [<OUTPUT_FILE> <URL>]"
exit 1
@@ -21,6 +21,12 @@ commitText=
commitTextmd=
goodParent=
+if ! git rev-parse --quiet --verify "${baseCommit}"
+then
+ echo "Invalid <BASE_COMMIT> '${baseCommit}'"
+ exit 1
+fi
+
while read dash sha etc
do
case "${dash}" in
@@ -67,7 +73,7 @@ then
goodParent=${baseCommit: 0:7}
fi
- echo "A whitespace issue was found in onen of more of the commits."
+ echo "A whitespace issue was found in one or more of the commits."
echo "Run the following command to resolve whitespace issues:"
echo "git rebase --whitespace=fix ${goodParent}"
diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
index 6ec0f85972..fb34ced8f0 100755
--- a/ci/install-dependencies.sh
+++ b/ci/install-dependencies.sh
@@ -87,6 +87,10 @@ macos-*)
esac
case "$jobname" in
+ClangFormat)
+ sudo apt-get -q update
+ sudo apt-get -q -y install clang-format
+ ;;
StaticAnalysis)
sudo apt-get -q update
sudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \
diff --git a/ci/run-style-check.sh b/ci/run-style-check.sh
new file mode 100755
index 0000000000..6cd4b1d934
--- /dev/null
+++ b/ci/run-style-check.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Perform style check
+#
+
+baseCommit=$1
+
+# Remove optional braces of control statements (if, else, for, and while)
+# according to the LLVM coding style. This avoids braces on simple
+# single-statement bodies of statements but keeps braces if one side of
+# if/else if/.../else cascade has multi-statement body.
+#
+# As this rule comes with a warning [1], we want to experiment with it
+# before adding it in-tree. since the CI job for the style check is allowed
+# to fail, appending the rule here allows us to validate its efficacy.
+# While also ensuring that end-users are not affected directly.
+#
+# [1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm
+{
+ cat .clang-format
+ echo "RemoveBracesLLVM: true"
+} >/tmp/clang-format-rules
+
+git clang-format --style=file:/tmp/clang-format-rules \
+ --diff --extensions c,h "$baseCommit"
diff --git a/config.mak.uname b/config.mak.uname
index 85d63821ec..aa0fd26bd5 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -8,7 +8,6 @@ uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
-uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
ifneq ($(findstring MINGW,$(uname_S)),)
diff --git a/log-tree.c b/log-tree.c
index 52feec4356..576ef30d90 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -1025,7 +1025,7 @@ static int do_remerge_diff(struct rev_info *opt,
struct strbuf parent2_desc = STRBUF_INIT;
/* Setup merge options */
- init_merge_options(&o, the_repository);
+ init_ui_merge_options(&o, the_repository);
o.show_rename_progress = 0;
o.record_conflict_msgs_as_headers = 1;
o.msg_header_prefix = "remerge";
diff --git a/merge-recursive.c b/merge-recursive.c
index 5cc638066a..ed64a4c537 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3921,7 +3921,7 @@ int merge_recursive_generic(struct merge_options *opt,
return clean ? 0 : 1;
}
-static void merge_recursive_config(struct merge_options *opt)
+static void merge_recursive_config(struct merge_options *opt, int ui)
{
char *value = NULL;
int renormalize = 0;
@@ -3950,11 +3950,20 @@ static void merge_recursive_config(struct merge_options *opt)
} /* avoid erroring on values from future versions of git */
free(value);
}
+ if (ui) {
+ if (!git_config_get_string("diff.algorithm", &value)) {
+ long diff_algorithm = parse_algorithm_value(value);
+ if (diff_algorithm < 0)
+ die(_("unknown value for config '%s': %s"), "diff.algorithm", value);
+ opt->xdl_opts = (opt->xdl_opts & ~XDF_DIFF_ALGORITHM_MASK) | diff_algorithm;
+ free(value);
+ }
+ }
git_config(git_xmerge_config, NULL);
}
-void init_merge_options(struct merge_options *opt,
- struct repository *repo)
+static void init_merge_options(struct merge_options *opt,
+ struct repository *repo, int ui)
{
const char *merge_verbosity;
memset(opt, 0, sizeof(struct merge_options));
@@ -3973,7 +3982,7 @@ void init_merge_options(struct merge_options *opt,
opt->conflict_style = -1;
- merge_recursive_config(opt);
+ merge_recursive_config(opt, ui);
merge_verbosity = getenv("GIT_MERGE_VERBOSITY");
if (merge_verbosity)
opt->verbosity = strtol(merge_verbosity, NULL, 10);
@@ -3981,6 +3990,18 @@ void init_merge_options(struct merge_options *opt,
opt->buffer_output = 0;
}
+void init_ui_merge_options(struct merge_options *opt,
+ struct repository *repo)
+{
+ init_merge_options(opt, repo, 1);
+}
+
+void init_basic_merge_options(struct merge_options *opt,
+ struct repository *repo)
+{
+ init_merge_options(opt, repo, 0);
+}
+
/*
* For now, members of merge_options do not need deep copying, but
* it may change in the future, in which case we would need to update
diff --git a/merge-recursive.h b/merge-recursive.h
index 3136c7cc2d..0b91f28f90 100644
--- a/merge-recursive.h
+++ b/merge-recursive.h
@@ -54,7 +54,10 @@ struct merge_options {
struct merge_options_internal *priv;
};
-void init_merge_options(struct merge_options *opt, struct repository *repo);
+/* for use by porcelain commands */
+void init_ui_merge_options(struct merge_options *opt, struct repository *repo);
+/* for use by plumbing commands */
+void init_basic_merge_options(struct merge_options *opt, struct repository *repo);
void copy_merge_options(struct merge_options *dst, struct merge_options *src);
void clear_merge_options(struct merge_options *opt);
diff --git a/reftable/reftable-tests.h b/reftable/reftable-tests.h
index 114cc3d053..d5e03dcc1b 100644
--- a/reftable/reftable-tests.h
+++ b/reftable/reftable-tests.h
@@ -11,7 +11,6 @@ https://developers.google.com/open-source/licenses/bsd
int basics_test_main(int argc, const char **argv);
int block_test_main(int argc, const char **argv);
-int merged_test_main(int argc, const char **argv);
int pq_test_main(int argc, const char **argv);
int record_test_main(int argc, const char **argv);
int readwrite_test_main(int argc, const char **argv);
diff --git a/sequencer.c b/sequencer.c
index a2284ac9e9..0291920f0b 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -762,7 +762,7 @@ static int do_recursive_merge(struct repository *r,
repo_read_index(r);
- init_merge_options(&o, r);
+ init_ui_merge_options(&o, r);
o.ancestor = base ? base_label : "(empty tree)";
o.branch1 = "HEAD";
o.branch2 = next ? next_label : "(empty tree)";
@@ -4309,7 +4309,7 @@ static int do_merge(struct repository *r,
bases = reverse_commit_list(bases);
repo_read_index(r);
- init_merge_options(&o, r);
+ init_ui_merge_options(&o, r);
o.branch1 = "HEAD";
o.branch2 = ref_name.buf;
o.buffer_output = 2;
diff --git a/t/helper/test-reftable.c b/t/helper/test-reftable.c
index aa6538a8da..9d378427da 100644
--- a/t/helper/test-reftable.c
+++ b/t/helper/test-reftable.c
@@ -9,7 +9,6 @@ int cmd__reftable(int argc, const char **argv)
tree_test_main(argc, argv);
pq_test_main(argc, argv);
readwrite_test_main(argc, argv);
- merged_test_main(argc, argv);
stack_test_main(argc, argv);
return 0;
}
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 5d78868ac1..9a48933cec 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -1164,4 +1164,23 @@ test_expect_success 'reset -p with unmerged files' '
test_must_be_empty staged
'
+test_expect_success 'hunk splitting works with diff.suppressBlankEmpty' '
+ test_config diff.suppressBlankEmpty true &&
+ write_script fake-editor.sh <<-\EOF &&
+ tr F G <"$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+
+ test_write_lines a b "" c d "" e f "" >file &&
+ git add file &&
+ test_write_lines A b "" c D "" e F "" >file &&
+ (
+ test_set_editor "$(pwd)/fake-editor.sh" &&
+ test_write_lines s n y e q | git add -p file
+ ) &&
+ git cat-file blob :file >actual &&
+ test_write_lines a b "" c D "" e G "" >expect &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 189d8e341b..2d984eb4c6 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -498,6 +498,19 @@ test_expect_success 'checkout unmerged stage' '
test ztheirside = "z$(cat file)"
'
+test_expect_success 'checkout --ours is incompatible with switching' '
+ test_must_fail git checkout --ours 2>error &&
+ test_grep "needs the paths to check out" error &&
+
+ test_must_fail git checkout --ours HEAD 2>error &&
+ test_grep "cannot be used with switching" error &&
+
+ test_must_fail git checkout --ours main 2>error &&
+ test_grep "cannot be used with switching" error &&
+
+ git checkout --ours file
+'
+
test_expect_success 'checkout path with --merge from tree-ish is a no-no' '
setup_conflicting_index &&
test_must_fail git checkout -m HEAD -- file
diff --git a/t/t7615-diff-algo-with-mergy-operations.sh b/t/t7615-diff-algo-with-mergy-operations.sh
new file mode 100755
index 0000000000..9a83be518c
--- /dev/null
+++ b/t/t7615-diff-algo-with-mergy-operations.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+test_description='git merge and other operations that rely on merge
+
+Testing the influence of the diff algorithm on the merge output.'
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ cp "$TEST_DIRECTORY"/t7615/base.c file.c &&
+ git add file.c &&
+ git commit -m c0 &&
+ git tag c0 &&
+ cp "$TEST_DIRECTORY"/t7615/ours.c file.c &&
+ git add file.c &&
+ git commit -m c1 &&
+ git tag c1 &&
+ git reset --hard c0 &&
+ cp "$TEST_DIRECTORY"/t7615/theirs.c file.c &&
+ git add file.c &&
+ git commit -m c2 &&
+ git tag c2
+'
+
+GIT_TEST_MERGE_ALGORITHM=recursive
+
+test_expect_success 'merge c2 to c1 with recursive merge strategy fails with the current default myers diff algorithm' '
+ git reset --hard c1 &&
+ test_must_fail git merge -s recursive c2
+'
+
+test_expect_success 'merge c2 to c1 with recursive merge strategy succeeds with -Xdiff-algorithm=histogram' '
+ git reset --hard c1 &&
+ git merge --strategy recursive -Xdiff-algorithm=histogram c2
+'
+
+test_expect_success 'merge c2 to c1 with recursive merge strategy succeeds with diff.algorithm = histogram' '
+ git reset --hard c1 &&
+ git config diff.algorithm histogram &&
+ git merge --strategy recursive c2
+'
+
+test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy fails with the current default myers diff algorithm' '
+ git reset --hard c1 &&
+ test_must_fail git cherry-pick -s recursive c2
+'
+
+test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy succeeds with -Xdiff-algorithm=histogram' '
+ git reset --hard c1 &&
+ git cherry-pick --strategy recursive -Xdiff-algorithm=histogram c2
+'
+
+test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy succeeds with diff.algorithm = histogram' '
+ git reset --hard c1 &&
+ git config diff.algorithm histogram &&
+ git cherry-pick --strategy recursive c2
+'
+
+test_done
diff --git a/t/t7615/base.c b/t/t7615/base.c
new file mode 100644
index 0000000000..c64abc5936
--- /dev/null
+++ b/t/t7615/base.c
@@ -0,0 +1,17 @@
+int f(int x, int y)
+{
+ if (x == 0)
+ {
+ return y;
+ }
+ return x;
+}
+
+int g(size_t u)
+{
+ while (u < 30)
+ {
+ u++;
+ }
+ return u;
+}
diff --git a/t/t7615/ours.c b/t/t7615/ours.c
new file mode 100644
index 0000000000..44d8251397
--- /dev/null
+++ b/t/t7615/ours.c
@@ -0,0 +1,17 @@
+int g(size_t u)
+{
+ while (u < 30)
+ {
+ u++;
+ }
+ return u;
+}
+
+int h(int x, int y, int z)
+{
+ if (z == 0)
+ {
+ return x;
+ }
+ return y;
+}
diff --git a/t/t7615/theirs.c b/t/t7615/theirs.c
new file mode 100644
index 0000000000..85f02146fe
--- /dev/null
+++ b/t/t7615/theirs.c
@@ -0,0 +1,17 @@
+int f(int x, int y)
+{
+ if (x == 0)
+ {
+ return y;
+ }
+ return x;
+}
+
+int g(size_t u)
+{
+ while (u > 34)
+ {
+ u--;
+ }
+ return u;
+}
diff --git a/reftable/merged_test.c b/t/unit-tests/t-reftable-merged.c
index a9d6661c13..b6263ee8b5 100644
--- a/reftable/merged_test.c
+++ b/t/unit-tests/t-reftable-merged.c
@@ -6,27 +6,33 @@ license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/
-#include "merged.h"
-
-#include "system.h"
+#include "test-lib.h"
+#include "reftable/blocksource.h"
+#include "reftable/constants.h"
+#include "reftable/merged.h"
+#include "reftable/reader.h"
+#include "reftable/reftable-error.h"
+#include "reftable/reftable-generic.h"
+#include "reftable/reftable-merged.h"
+#include "reftable/reftable-writer.h"
+
+static ssize_t strbuf_add_void(void *b, const void *data, const size_t sz)
+{
+ strbuf_add(b, data, sz);
+ return sz;
+}
-#include "basics.h"
-#include "blocksource.h"
-#include "constants.h"
-#include "reader.h"
-#include "record.h"
-#include "test_framework.h"
-#include "reftable-merged.h"
-#include "reftable-tests.h"
-#include "reftable-generic.h"
-#include "reftable-writer.h"
+static int noop_flush(void *arg)
+{
+ return 0;
+}
static void write_test_table(struct strbuf *buf,
- struct reftable_ref_record refs[], int n)
+ struct reftable_ref_record refs[], const size_t n)
{
uint64_t min = 0xffffffff;
uint64_t max = 0;
- int i = 0;
+ size_t i;
int err;
struct reftable_write_options opts = {
@@ -35,12 +41,10 @@ static void write_test_table(struct strbuf *buf,
struct reftable_writer *w = NULL;
for (i = 0; i < n; i++) {
uint64_t ui = refs[i].update_index;
- if (ui > max) {
+ if (ui > max)
max = ui;
- }
- if (ui < min) {
+ if (ui < min)
min = ui;
- }
}
w = reftable_new_writer(&strbuf_add_void, &noop_flush, buf, &opts);
@@ -49,21 +53,19 @@ static void write_test_table(struct strbuf *buf,
for (i = 0; i < n; i++) {
uint64_t before = refs[i].update_index;
int n = reftable_writer_add_ref(w, &refs[i]);
- EXPECT(n == 0);
- EXPECT(before == refs[i].update_index);
+ check_int(n, ==, 0);
+ check_int(before, ==, refs[i].update_index);
}
err = reftable_writer_close(w);
- EXPECT_ERR(err);
+ check(!err);
reftable_writer_free(w);
}
-static void write_test_log_table(struct strbuf *buf,
- struct reftable_log_record logs[], int n,
- uint64_t update_index)
+static void write_test_log_table(struct strbuf *buf, struct reftable_log_record logs[],
+ const size_t n, const uint64_t update_index)
{
- int i = 0;
int err;
struct reftable_write_options opts = {
@@ -74,13 +76,13 @@ static void write_test_log_table(struct strbuf *buf,
w = reftable_new_writer(&strbuf_add_void, &noop_flush, buf, &opts);
reftable_writer_set_limits(w, update_index, update_index);
- for (i = 0; i < n; i++) {
+ for (size_t i = 0; i < n; i++) {
int err = reftable_writer_add_log(w, &logs[i]);
- EXPECT_ERR(err);
+ check(!err);
}
err = reftable_writer_close(w);
- EXPECT_ERR(err);
+ check(!err);
reftable_writer_free(w);
}
@@ -88,8 +90,8 @@ static void write_test_log_table(struct strbuf *buf,
static struct reftable_merged_table *
merged_table_from_records(struct reftable_ref_record **refs,
struct reftable_block_source **source,
- struct reftable_reader ***readers, int *sizes,
- struct strbuf *buf, size_t n)
+ struct reftable_reader ***readers, const size_t *sizes,
+ struct strbuf *buf, const size_t n)
{
struct reftable_merged_table *mt = NULL;
struct reftable_table *tabs;
@@ -105,24 +107,23 @@ merged_table_from_records(struct reftable_ref_record **refs,
err = reftable_new_reader(&(*readers)[i], &(*source)[i],
"name");
- EXPECT_ERR(err);
+ check(!err);
reftable_table_from_reader(&tabs[i], (*readers)[i]);
}
err = reftable_new_merged_table(&mt, tabs, n, GIT_SHA1_FORMAT_ID);
- EXPECT_ERR(err);
+ check(!err);
return mt;
}
-static void readers_destroy(struct reftable_reader **readers, size_t n)
+static void readers_destroy(struct reftable_reader **readers, const size_t n)
{
- int i = 0;
- for (; i < n; i++)
+ for (size_t i = 0; i < n; i++)
reftable_reader_free(readers[i]);
reftable_free(readers);
}
-static void test_merged_between(void)
+static void t_merged_single_record(void)
{
struct reftable_ref_record r1[] = { {
.refname = (char *) "b",
@@ -135,37 +136,40 @@ static void test_merged_between(void)
.update_index = 2,
.value_type = REFTABLE_REF_DELETION,
} };
+ struct reftable_ref_record r3[] = { {
+ .refname = (char *) "c",
+ .update_index = 3,
+ .value_type = REFTABLE_REF_DELETION,
+ } };
- struct reftable_ref_record *refs[] = { r1, r2 };
- int sizes[] = { 1, 1 };
- struct strbuf bufs[2] = { STRBUF_INIT, STRBUF_INIT };
+ struct reftable_ref_record *refs[] = { r1, r2, r3 };
+ size_t sizes[] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) };
+ struct strbuf bufs[3] = { STRBUF_INIT, STRBUF_INIT, STRBUF_INIT };
struct reftable_block_source *bs = NULL;
struct reftable_reader **readers = NULL;
struct reftable_merged_table *mt =
- merged_table_from_records(refs, &bs, &readers, sizes, bufs, 2);
- int i;
- struct reftable_ref_record ref = { NULL };
- struct reftable_iterator it = { NULL };
+ merged_table_from_records(refs, &bs, &readers, sizes, bufs, 3);
+ struct reftable_ref_record ref = { 0 };
+ struct reftable_iterator it = { 0 };
int err;
merged_table_init_iter(mt, &it, BLOCK_TYPE_REF);
err = reftable_iterator_seek_ref(&it, "a");
- EXPECT_ERR(err);
+ check(!err);
err = reftable_iterator_next_ref(&it, &ref);
- EXPECT_ERR(err);
- EXPECT(ref.update_index == 2);
+ check(!err);
+ check(reftable_ref_record_equal(&r2[0], &ref, GIT_SHA1_RAWSZ));
reftable_ref_record_release(&ref);
reftable_iterator_destroy(&it);
- readers_destroy(readers, 2);
+ readers_destroy(readers, 3);
reftable_merged_table_free(mt);
- for (i = 0; i < ARRAY_SIZE(bufs); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(bufs); i++)
strbuf_release(&bufs[i]);
- }
reftable_free(bs);
}
-static void test_merged(void)
+static void t_merged_refs(void)
{
struct reftable_ref_record r1[] = {
{
@@ -215,27 +219,28 @@ static void test_merged(void)
};
struct reftable_ref_record *refs[] = { r1, r2, r3 };
- int sizes[3] = { 3, 1, 2 };
+ size_t sizes[3] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) };
struct strbuf bufs[3] = { STRBUF_INIT, STRBUF_INIT, STRBUF_INIT };
struct reftable_block_source *bs = NULL;
struct reftable_reader **readers = NULL;
struct reftable_merged_table *mt =
merged_table_from_records(refs, &bs, &readers, sizes, bufs, 3);
- struct reftable_iterator it = { NULL };
+ struct reftable_iterator it = { 0 };
int err;
struct reftable_ref_record *out = NULL;
size_t len = 0;
size_t cap = 0;
- int i = 0;
+ size_t i;
merged_table_init_iter(mt, &it, BLOCK_TYPE_REF);
err = reftable_iterator_seek_ref(&it, "a");
- EXPECT_ERR(err);
- EXPECT(reftable_merged_table_hash_id(mt) == GIT_SHA1_FORMAT_ID);
- EXPECT(reftable_merged_table_min_update_index(mt) == 1);
+ check(!err);
+ check_int(reftable_merged_table_hash_id(mt), ==, GIT_SHA1_FORMAT_ID);
+ check_int(reftable_merged_table_min_update_index(mt), ==, 1);
+ check_int(reftable_merged_table_max_update_index(mt), ==, 3);
while (len < 100) { /* cap loops/recursion. */
- struct reftable_ref_record ref = { NULL };
+ struct reftable_ref_record ref = { 0 };
int err = reftable_iterator_next_ref(&it, &ref);
if (err > 0)
break;
@@ -245,19 +250,16 @@ static void test_merged(void)
}
reftable_iterator_destroy(&it);
- EXPECT(ARRAY_SIZE(want) == len);
- for (i = 0; i < len; i++) {
- EXPECT(reftable_ref_record_equal(want[i], &out[i],
+ check_int(ARRAY_SIZE(want), ==, len);
+ for (i = 0; i < len; i++)
+ check(reftable_ref_record_equal(want[i], &out[i],
GIT_SHA1_RAWSZ));
- }
- for (i = 0; i < len; i++) {
+ for (i = 0; i < len; i++)
reftable_ref_record_release(&out[i]);
- }
reftable_free(out);
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 3; i++)
strbuf_release(&bufs[i]);
- }
readers_destroy(readers, 3);
reftable_merged_table_free(mt);
reftable_free(bs);
@@ -266,8 +268,8 @@ static void test_merged(void)
static struct reftable_merged_table *
merged_table_from_log_records(struct reftable_log_record **logs,
struct reftable_block_source **source,
- struct reftable_reader ***readers, int *sizes,
- struct strbuf *buf, size_t n)
+ struct reftable_reader ***readers, const size_t *sizes,
+ struct strbuf *buf, const size_t n)
{
struct reftable_merged_table *mt = NULL;
struct reftable_table *tabs;
@@ -283,16 +285,16 @@ merged_table_from_log_records(struct reftable_log_record **logs,
err = reftable_new_reader(&(*readers)[i], &(*source)[i],
"name");
- EXPECT_ERR(err);
+ check(!err);
reftable_table_from_reader(&tabs[i], (*readers)[i]);
}
err = reftable_new_merged_table(&mt, tabs, n, GIT_SHA1_FORMAT_ID);
- EXPECT_ERR(err);
+ check(!err);
return mt;
}
-static void test_merged_logs(void)
+static void t_merged_logs(void)
{
struct reftable_log_record r1[] = {
{
@@ -347,27 +349,28 @@ static void test_merged_logs(void)
};
struct reftable_log_record *logs[] = { r1, r2, r3 };
- int sizes[3] = { 2, 1, 1 };
+ size_t sizes[3] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) };
struct strbuf bufs[3] = { STRBUF_INIT, STRBUF_INIT, STRBUF_INIT };
struct reftable_block_source *bs = NULL;
struct reftable_reader **readers = NULL;
struct reftable_merged_table *mt = merged_table_from_log_records(
logs, &bs, &readers, sizes, bufs, 3);
- struct reftable_iterator it = { NULL };
+ struct reftable_iterator it = { 0 };
int err;
struct reftable_log_record *out = NULL;
size_t len = 0;
size_t cap = 0;
- int i = 0;
+ size_t i;
merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG);
err = reftable_iterator_seek_log(&it, "a");
- EXPECT_ERR(err);
- EXPECT(reftable_merged_table_hash_id(mt) == GIT_SHA1_FORMAT_ID);
- EXPECT(reftable_merged_table_min_update_index(mt) == 1);
+ check(!err);
+ check_int(reftable_merged_table_hash_id(mt), ==, GIT_SHA1_FORMAT_ID);
+ check_int(reftable_merged_table_min_update_index(mt), ==, 1);
+ check_int(reftable_merged_table_max_update_index(mt), ==, 3);
while (len < 100) { /* cap loops/recursion. */
- struct reftable_log_record log = { NULL };
+ struct reftable_log_record log = { 0 };
int err = reftable_iterator_next_log(&it, &log);
if (err > 0)
break;
@@ -377,35 +380,32 @@ static void test_merged_logs(void)
}
reftable_iterator_destroy(&it);
- EXPECT(ARRAY_SIZE(want) == len);
- for (i = 0; i < len; i++) {
- EXPECT(reftable_log_record_equal(want[i], &out[i],
+ check_int(ARRAY_SIZE(want), ==, len);
+ for (i = 0; i < len; i++)
+ check(reftable_log_record_equal(want[i], &out[i],
GIT_SHA1_RAWSZ));
- }
merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG);
err = reftable_iterator_seek_log_at(&it, "a", 2);
- EXPECT_ERR(err);
+ check(!err);
reftable_log_record_release(&out[0]);
err = reftable_iterator_next_log(&it, &out[0]);
- EXPECT_ERR(err);
- EXPECT(reftable_log_record_equal(&out[0], &r3[0], GIT_SHA1_RAWSZ));
+ check(!err);
+ check(reftable_log_record_equal(&out[0], &r3[0], GIT_SHA1_RAWSZ));
reftable_iterator_destroy(&it);
- for (i = 0; i < len; i++) {
+ for (i = 0; i < len; i++)
reftable_log_record_release(&out[i]);
- }
reftable_free(out);
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 3; i++)
strbuf_release(&bufs[i]);
- }
readers_destroy(readers, 3);
reftable_merged_table_free(mt);
reftable_free(bs);
}
-static void test_default_write_opts(void)
+static void t_default_write_opts(void)
{
struct reftable_write_options opts = { 0 };
struct strbuf buf = STRBUF_INIT;
@@ -417,7 +417,7 @@ static void test_default_write_opts(void)
.update_index = 1,
};
int err;
- struct reftable_block_source source = { NULL };
+ struct reftable_block_source source = { 0 };
struct reftable_table *tab = reftable_calloc(1, sizeof(*tab));
uint32_t hash_id;
struct reftable_reader *rd = NULL;
@@ -426,36 +426,38 @@ static void test_default_write_opts(void)
reftable_writer_set_limits(w, 1, 1);
err = reftable_writer_add_ref(w, &rec);
- EXPECT_ERR(err);
+ check(!err);
err = reftable_writer_close(w);
- EXPECT_ERR(err);
+ check(!err);
reftable_writer_free(w);
block_source_from_strbuf(&source, &buf);
err = reftable_new_reader(&rd, &source, "filename");
- EXPECT_ERR(err);
+ check(!err);
hash_id = reftable_reader_hash_id(rd);
- EXPECT(hash_id == GIT_SHA1_FORMAT_ID);
+ check_int(hash_id, ==, GIT_SHA1_FORMAT_ID);
reftable_table_from_reader(&tab[0], rd);
+ err = reftable_new_merged_table(&merged, tab, 1, GIT_SHA256_FORMAT_ID);
+ check_int(err, ==, REFTABLE_FORMAT_ERROR);
err = reftable_new_merged_table(&merged, tab, 1, GIT_SHA1_FORMAT_ID);
- EXPECT_ERR(err);
+ check(!err);
reftable_reader_free(rd);
reftable_merged_table_free(merged);
strbuf_release(&buf);
}
-/* XXX test refs_for(oid) */
-int merged_test_main(int argc, const char *argv[])
+int cmd_main(int argc, const char *argv[])
{
- RUN_TEST(test_merged_logs);
- RUN_TEST(test_merged_between);
- RUN_TEST(test_merged);
- RUN_TEST(test_default_write_opts);
- return 0;
+ TEST(t_default_write_opts(), "merged table with default write opts");
+ TEST(t_merged_logs(), "merged table with multiple log updates for same ref");
+ TEST(t_merged_refs(), "merged table with multiple updates to same ref");
+ TEST(t_merged_single_record(), "ref ocurring in only one record can be fetched");
+
+ return test_done();
}
diff --git a/t/unit-tests/t-strvec.c b/t/unit-tests/t-strvec.c
index d4615ab06d..fa1a041469 100644
--- a/t/unit-tests/t-strvec.c
+++ b/t/unit-tests/t-strvec.c
@@ -3,38 +3,21 @@
#include "strvec.h"
#define check_strvec(vec, ...) \
- check_strvec_loc(TEST_LOCATION(), vec, __VA_ARGS__)
-LAST_ARG_MUST_BE_NULL
-static void check_strvec_loc(const char *loc, struct strvec *vec, ...)
-{
- va_list ap;
- size_t nr = 0;
-
- va_start(ap, vec);
- while (1) {
- const char *str = va_arg(ap, const char *);
- if (!str)
- break;
-
- if (!check_uint(vec->nr, >, nr) ||
- !check_uint(vec->alloc, >, nr) ||
- !check_str(vec->v[nr], str)) {
- struct strbuf msg = STRBUF_INIT;
- strbuf_addf(&msg, "strvec index %"PRIuMAX, (uintmax_t) nr);
- test_assert(loc, msg.buf, 0);
- strbuf_release(&msg);
- va_end(ap);
- return;
- }
-
- nr++;
- }
- va_end(ap);
-
- check_uint(vec->nr, ==, nr);
- check_uint(vec->alloc, >=, nr);
- check_pointer_eq(vec->v[nr], NULL);
-}
+ do { \
+ const char *expect[] = { __VA_ARGS__ }; \
+ if (check_uint(ARRAY_SIZE(expect), >, 0) && \
+ check_pointer_eq(expect[ARRAY_SIZE(expect) - 1], NULL) && \
+ check_uint((vec)->nr, ==, ARRAY_SIZE(expect) - 1) && \
+ check_uint((vec)->nr, <=, (vec)->alloc)) { \
+ for (size_t i = 0; i < ARRAY_SIZE(expect); i++) { \
+ if (!check_str((vec)->v[i], expect[i])) { \
+ test_msg(" i: %"PRIuMAX, \
+ (uintmax_t)i); \
+ break; \
+ } \
+ } \
+ } \
+ } while (0)
static void t_static_init(void)
{