* Re: [PATCH v4] unit tests: Add a project plan document
From: Junio C Hamano @ 2023-07-01 0:42 UTC (permalink / raw)
To: Josh Steadmon
Cc: git, szeder.dev, phillip.wood123, chooglen, avarab, sandals,
calvinwan
In-Reply-To: <0169ce6fb9ccafc089b74ae406db0d1a8ff8ac65.1688165272.git.steadmon@google.com>
Josh Steadmon <steadmon@google.com> writes:
I'll normalize this one to match prevailing use.
> Coauthored-by: Calvin Wan <calvinwan@google.com>
$ git log --since=6.months --pretty=raw --no-merges |
sed -n -e 's/^ \([^ :]*-by:\).*/\1/p' |
sort | uniq -c | sort -n | sed -e '/^ *1 /d'
5 Tested-by:
15 Suggested-by:
24 Co-authored-by:
30 Reported-by:
34 Reviewed-by:
38 Helped-by:
68 Acked-by:
1786 Signed-off-by:
> Signed-off-by: Calvin Wan <calvinwan@google.com>
> Signed-off-by: Josh Steadmon <steadmon@google.com>
> ---
Thanks.
^ permalink raw reply
* [PATCH v4] unit tests: Add a project plan document
From: Josh Steadmon @ 2023-06-30 22:51 UTC (permalink / raw)
To: git
Cc: szeder.dev, phillip.wood123, chooglen, avarab, gitster, sandals,
calvinwan
In-Reply-To: <20230517-unit-tests-v2-v2-0-8c1b50f75811@google.com>
In our current testing environment, we spend a significant amount of
effort crafting end-to-end tests for error conditions that could easily
be captured by unit tests (or we simply forgo some hard-to-setup and
rare error conditions). Describe what we hope to accomplish by
implementing unit tests, and explain some open questions and milestones.
Discuss desired features for test frameworks/harnesses, and provide a
preliminary comparison of several different frameworks.
Coauthored-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Josh Steadmon <steadmon@google.com>
---
Unit tests additionally provide stability to the codebase and can
simplify debugging through isolation. Turning parts of Git into
libraries[1] gives us the ability to run unit tests on the libraries and
to write unit tests in C. Writing unit tests in pure C, rather than with
our current shell/test-tool helper setup, simplifies test setup,
simplifies passing data around (no shell-isms required), and reduces
testing runtime by not spawning a separate process for every test
invocation.
This patch adds a project document describing our goals for adding unit
tests, as well as a discussion of features needed from prospective test
frameworks or harnesses. It also includes a WIP comparison of various
proposed frameworks. Later iterations of this series will probably
include a sample unit test and Makefile integration once we've settled
on a framework. A rendered preview of this doc can be found at [2].
In addition to reviewing the document itself, reviewers can help this
series progress by helping to fill in the framework comparison table.
[1] https://lore.kernel.org/git/CAJoAoZ=Cig_kLocxKGax31sU7Xe4==BGzC__Bg2_pr7krNq6MA@mail.gmail.com/
[2] https://github.com/steadmon/git/blob/unit-tests-asciidoc/Documentation/technical/unit-tests.adoc
TODOs remaining:
- List rough priorities across comparison dimensions
- Group dimensions into sensible categories
- Discuss pre-existing harnesses for the current test suite
- Discuss harness vs. framework features, particularly for parallelism
- Figure out how to evaluate frameworks on additional OSes such as *BSD
and NonStop
- Add more discussion about desired features (particularly mocking)
- Add dimension for test timing
- Evaluate remaining missing comparison table entries
Changes in v4:
- Add link anchors for the framework comparison dimensions
- Explain "Partial" results for each dimension
- Use consistent dimension names in the section headers and comparison
tables
- Add "Project KLOC", "Adoption", and "Inline tests" dimensions
- Fill in a few of the missing entries in the comparison table
Changes in v3:
- Expand the doc with discussion of desired features and a WIP
comparison.
- Drop all implementation patches until a framework is selected.
- Link to v2: https://lore.kernel.org/r/20230517-unit-tests-v2-v2-0-21b5b60f4b32@google.com
Documentation/Makefile | 1 +
Documentation/technical/unit-tests.txt | 196 +++++++++++++++++++++++++
2 files changed, 197 insertions(+)
create mode 100644 Documentation/technical/unit-tests.txt
diff --git a/Documentation/Makefile b/Documentation/Makefile
index b629176d7d..3f2383a12c 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -122,6 +122,7 @@ TECH_DOCS += technical/scalar
TECH_DOCS += technical/send-pack-pipeline
TECH_DOCS += technical/shallow
TECH_DOCS += technical/trivial-merge
+TECH_DOCS += technical/unit-tests
SP_ARTICLES += $(TECH_DOCS)
SP_ARTICLES += technical/api-index
diff --git a/Documentation/technical/unit-tests.txt b/Documentation/technical/unit-tests.txt
new file mode 100644
index 0000000000..e302a0e40f
--- /dev/null
+++ b/Documentation/technical/unit-tests.txt
@@ -0,0 +1,196 @@
+= Unit Testing
+
+In our current testing environment, we spend a significant amount of effort
+crafting end-to-end tests for error conditions that could easily be captured by
+unit tests (or we simply forgo some hard-to-setup and rare error conditions).
+Unit tests additionally provide stability to the codebase and can simplify
+debugging through isolation. Writing unit tests in pure C, rather than with our
+current shell/test-tool helper setup, simplifies test setup, simplifies passing
+data around (no shell-isms required), and reduces testing runtime by not
+spawning a separate process for every test invocation.
+
+We believe that a large body of unit tests, living alongside the existing test
+suite, will improve code quality for the Git project.
+
+== Definitions
+
+For the purposes of this document, we'll use *test framework* to refer to
+projects that support writing test cases and running tests within the context
+of a single executable. *Test harness* will refer to projects that manage
+running multiple executables (each of which may contain multiple test cases) and
+aggregating their results.
+
+In reality, these terms are not strictly defined, and many of the projects
+discussed below contain features from both categories.
+
+
+== Choosing a framework & harness
+
+=== Desired features
+
+[[tap-support]]
+==== TAP support
+
+The https://testanything.org/[Test Anything Protocol] is a text-based interface
+that allows tests to communicate with a test harness. It is already used by
+Git's integration test suite. Supporting TAP output is a mandatory feature for
+any prospective test framework.
+
+In the comparison table below, "True" means this is natively supported.
+"Partial" means TAP output must be generated by post-processing the native
+output.
+
+Frameworks that do not have at least Partial support will not be evaluated
+further.
+
+[[diagnostic-output]]
+==== Diagnostic output
+
+When a test case fails, the framework must generate enough diagnostic output to
+help developers find the appropriate test case in source code in order to debug
+the failure.
+
+[[parallel-execution]]
+==== Parallel execution
+
+Ideally, we will build up a significant collection of unit test cases, most
+likely split across multiple executables. It will be necessary to run these
+tests in parallel to enable fast develop-test-debug cycles.
+
+In the comparison table below, "True" means that individual test cases within a
+single test executable can be run in parallel. "Partial" means that test cases
+are run serially within a single executable, but multiple test executables can
+be run at once (with proper harness support).
+
+[[vendorable-or-ubiquitous]]
+==== Vendorable or ubiquitous
+
+If possible, we want to avoid forcing Git developers to install new tools just
+to run unit tests. So any prospective frameworks and harnesses must either be
+vendorable (meaning, we can copy their source directly into Git's repository),
+or so ubiquitous that it is reasonable to expect that most developers will have
+the tools installed already.
+
+[[maintainable-extensible]]
+==== Maintainable / extensible
+
+It is unlikely that any pre-existing project perfectly fits our needs, so any
+project we select will need to be actively maintained and open to accepting
+changes. Alternatively, assuming we are vendoring the source into our repo, it
+must be simple enough that Git developers can feel comfortable making changes as
+needed to our version.
+
+In the comparison table below, "True" means that the framework seems to have
+active developers, that it is simple enough that Git developers can make changes
+to it, and that the project seems open to accepting external contributions (or
+that it is vendorable). "Partial" means that at least one of the above
+conditions holds.
+
+[[major-platform-support]]
+==== Major platform support
+
+At a bare minimum, unit-testing must work on Linux, MacOS, and Windows.
+
+In the comparison table below, "True" means that it works on all three major
+platforms with no issues. "Partial" means that there may be annoyances on one or
+more platforms, but it is still usable in principle.
+
+[[lazy-test-planning]]
+==== Lazy test planning
+
+TAP supports the notion of _test plans_, which communicate which test cases are
+expected to run, or which tests actually ran. This allows test harnesses to
+detect if the TAP output has been truncated, or if some tests were skipped due
+to errors or bugs.
+
+The test framework should handle creating plans at runtime, rather than
+requiring test developers to manually create plans, which leads to both human-
+and merge-errors.
+
+[[runtime-skippable-tests]]
+==== Runtime-skippable tests
+
+Test authors may wish to skip certain test cases based on runtime circumstances,
+so the framework should support this.
+
+[[scheduling-re-running]]
+==== Scheduling / re-running
+
+The test harness scheduling should be configurable so that e.g. developers can
+choose to run slow tests first, or to run only tests that failed in a previous
+run.
+
+"True" means that the framework supports both features, "Partial" means it
+supports only one (assuming proper harness support).
+
+[[mock-support]]
+==== Mock support
+
+Unit test authors may wish to test code that interacts with objects that may be
+inconvenient to handle in a test (e.g. interacting with a network service).
+Mocking allows test authors to provide a fake implementation of these objects
+for more convenient tests.
+
+[[signal-error-handling]]
+==== Signal & error handling
+
+The test framework must fail gracefully when test cases are themselves buggy or
+when they are interrupted by signals during runtime.
+
+[[coverage-reports]]
+==== Coverage reports
+
+It may be convenient to generate coverage reports when running unit tests
+(although it may be possible to accomplish this regardless of test framework /
+harness support).
+
+[[project-kloc]]
+==== Project KLOC
+
+WIP: The size of the project, in thousands of lines of code. All else being
+equal, we probably prefer a project with fewer LOC.
+
+[[adoption]]
+==== Adoption
+
+WIP: we prefer a more widely-used project. We'll need to figure out the best way
+to measure this.
+
+[[inline-tests]]
+==== Inline tests
+
+Can the tests live alongside production code in the same source files? This can
+be a useful reminder for developers to add new tests, and keep existing ones
+synced with new changes.
+
+=== Comparison
+
+[format="csv",options="header"]
+|=====
+Framework,"<<tap-support,TAP support>>","<<diagnostic-output,Diagnostic output>>","<<parallel-execution,Parallel execution>>","<<vendorable-or-ubiquitous,Vendorable or ubiquitous>>","<<maintainable-extensible,Maintainable / extensible>>","<<major-platform-support,Major platform support>>","<<lazy-test-planning,Lazy test planning>>","<<runtime--skippable-tests,Runtime- skippable tests>>","<<scheduling-re-running,Scheduling / re-running>>","<<mock-support,Mock support>>","<<signal-error-handling,Signal & error handling>>","<<coverage-reports,Coverage reports>>","<<project-kloc,Project KLOC>>","<<adoption,Adoption>>","<<inline-tests,Inline tests>>"
+https://lore.kernel.org/git/c902a166-98ce-afba-93f2-ea6027557176@gmail.com/[Custom Git impl.],[lime-background]#True#,[lime-background]#True#,?,[lime-background]#True#,[lime-background]#True#,[lime-background]#True#,[lime-background]#True#,?,?,[red-background]#False#,?,?,?,?,?
+https://cmocka.org/[cmocka],[lime-background]#True#,[lime-background]#True#,?,[red-background]#False#,[yellow-background]#Partial#,[yellow-background]#Partial#,?,?,?,[lime-background]#True#,?,?,?,?,?
+https://libcheck.github.io/check/[Check],[lime-background]#True#,[lime-background]#True#,?,[red-background]#False#,[yellow-background]#Partial#,[lime-background]#True#,?,?,?,[red-background]#False#,?,?,?,?,?
+https://github.com/rra/c-tap-harness/[C TAP],[lime-background]#True#,[red-background]#False#,?,[lime-background]#True#,[yellow-background]#Partial#,[yellow-background]#Partial#,?,?,?,[red-background]#False#,?,?,?,?,?
+https://github.com/silentbicycle/greatest[Greatest],[yellow-background]#Partial#,?,?,[lime-background]#True#,[yellow-background]#Partial#,?,?,?,?,[red-background]#False#,?,?,?,?,?
+https://github.com/Snaipe/Criterion[Criterion],[lime-background]#True#,?,?,[red-background]#False#,?,[lime-background]#True#,?,?,?,[red-background]#False#,?,?,?,?,?
+https://github.com/zorgnax/libtap[libtap],[lime-background]#True#,?,?,?,?,?,?,?,?,?,?,?,?,?,?
+https://www.kindahl.net/mytap/doc/index.html[MyTAP],[lime-background]#True#,?,?,?,?,?,?,?,?,?,?,?,?,?,?
+https://nemequ.github.io/munit/[µnit],[red-background]#False#,-,-,-,-,-,-,-,-,-,-,-,-,-,-
+https://github.com/google/cmockery[cmockery],[red-background]#False#,-,-,-,-,-,-,-,-,-,-,-,-,-,-
+https://github.com/lpabon/cmockery2[cmockery2],[red-background]#False#,-,-,-,-,-,-,-,-,-,-,-,-,-,-
+https://github.com/ThrowTheSwitch/Unity[Unity],[red-background]#False#,-,-,-,-,-,-,-,-,-,-,-,-,-,-
+https://github.com/siu/minunit[minunit],[red-background]#False#,-,-,-,-,-,-,-,-,-,-,-,-,-,-
+https://cunit.sourceforge.net/[CUnit],[red-background]#False#,-,-,-,-,-,-,-,-,-,-,-,-,-,-
+|=====
+
+== Milestones
+
+* Settle on final framework
+* Add useful tests of library-like code
+* Integrate with Makefile
+* Integrate with CI
+* Integrate with
+ https://lore.kernel.org/git/20230502211454.1673000-1-calvinwan@google.com/[stdlib
+ work]
+* Run alongside regular `make test` target
base-commit: a9e066fa63149291a55f383cfa113d8bdbdaa6b3
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply related
* Re: [PATCH v4 6/6] common: move alloc macros to common.h
From: Junio C Hamano @ 2023-06-30 22:49 UTC (permalink / raw)
To: Calvin Wan; +Cc: git, phillip.wood123, jonathantanmy
In-Reply-To: <20230630202346.3069950-6-calvinwan@google.com>
Calvin Wan <calvinwan@google.com> writes:
> alloc_nr, ALLOC_GROW, and ALLOC_GROW_BY are commonly used macros for
> dynamic array allocation. Moving these macros to git-compat-util.h with
> the other alloc macros focuses alloc.[ch] to allocation for Git objects
> and additionally allows us to remove inclusions to alloc.h from files
> that solely used the above macros.
Is this step mistitled? There is no "common.h" in this round.
For that matter, when the series makes a big change like this round,
please update the cover letter so that those who are reading it
without having seen the prior rounds can understand what the series
is about. It will equally help those who have seen prior rounds,
too. what is going on. E.g. The cover letter of v1 emphasized why
moving many things to common.h was a great thing (and promised to
talk about it more in patch 3), but that focus certainly has shifted
in this iteration that no longer even creates "common.h", right?
Thanks.
^ permalink raw reply
* Re: [RFC PATCH v3 1/1] unit tests: Add a project plan document
From: Josh Steadmon @ 2023-06-30 22:35 UTC (permalink / raw)
To: phillip.wood
Cc: git, calvinwan, szeder.dev, chooglen, avarab, gitster, sandals
In-Reply-To: <a99a5134-3bac-64d4-b4e7-f02e8578090a@gmail.com>
On 2023.06.30 15:07, Phillip Wood wrote:
> Hi Josh
>
> Thanks for putting this together, I think it is really helpful to have a
> comparison of the various options. Sorry for the slow reply, I was off the
> list for a couple of weeks.
Thank you for the review! Unfortunately I didn't see it in time for any
of these to make it into v4, but I'll keep them all as TODOs.
> On 10/06/2023 00:25, Josh Steadmon wrote:
> > diff --git a/Documentation/technical/unit-tests.txt b/Documentation/technical/unit-tests.txt
> > new file mode 100644
> > index 0000000000..dac8062a43
> > --- /dev/null
> > +++ b/Documentation/technical/unit-tests.txt
> > +== Definitions
> > +
> > +For the purposes of this document, we'll use *test framework* to refer to
> > +projects that support writing test cases and running tests within the context
> > +of a single executable. *Test harness* will refer to projects that manage
> > +running multiple executables (each of which may contain multiple test cases) and
> > +aggregating their results.
>
> Thanks for adding this, it is really helpful to have definitions for what we
> mean by "test framework" and "test harness" within the git project. It might
> be worth mentioning somewhere that we already use prove as a test harness
> when running our integration tests.
Yeah, I'll try to clarify this, probably not in V4 though. I'll note it
as a remaining TODO.
> > +==== Parallel execution
> > +
> > +Ideally, we will build up a significant collection of unit tests cases, most
> > +likely split across multiple executables. It will be necessary to run these
> > +tests in parallel to enable fast develop-test-debug cycles.
>
> This is a good point, though I think it is really a property of the harness
> rather than the framework so we might want to indicate in the table whether
> a framework provides parallelism itself or relies on the harness providing
> it.
Same here.
> > [...]
> > +==== Major platform support
> > +
> > +At a bare minimum, unit-testing must work on Linux, MacOS, and Windows.
>
> I think we'd want to be able to run unit tests on *BSD and NonStop as well,
> especially as I think some of the platform dependent code probably lends
> itself to being unit tested. I suspect a framework that covers Linux and
> MacOS would probably run on those platforms as well (I don't think NonStop
> has complete POSIX support but it is hard to imagine a test framework doing
> anything very exotic)
Yes, unfortunately I don't have easy access to either of these, but I'll
try to figure out how to evaluate these.
> > [...]
> > +==== Mock support
> > +
> > +Unit test authors may wish to test code that interacts with objects that may be
> > +inconvenient to handle in a test (e.g. interacting with a network service).
> > +Mocking allows test authors to provide a fake implementation of these objects
> > +for more convenient tests.
>
> Do we have any idea what sort of thing we're likely to want to mock and what
> we want that support to look like?
Not at the moment. Another TODO for v5.
> > +==== Signal & exception handling
> > +
> > +The test framework must fail gracefully when test cases are themselves buggy or
> > +when they are interrupted by signals during runtime.
>
> I had assumed that it would be enough for the test harness to detect if a
> test executable was killed by a signal or exited early due to a bug in the
> test script. That requires the framework to have robust support for lazy
> test plans but I'm not sure that we need it to catch and recover from things
> like SIGSEGV.
I think as long as a SIGSEGV in the test code doesn't cause the entire
test run to crash, we'll be OK. Agreed that this is really more of a
harness feature.
> > +==== Coverage reports
> > +
> > +It may be convenient to generate coverage reports when running unit tests
> > +(although it may be possible to accomplish this regardless of test framework /
> > +harness support).
>
> I agree this would be useful, though perhaps we should build it on our
> existing gcov usage.
>
> Related to this do we want timing reports from the harness or the framework?
I'll add this as well in V5.
> > +
> > +=== Comparison
> > +
> > +[format="csv",options="header",width="75%"]
> > +|=====
> > +Framework,"TAP support","Diagnostic output","Parallel execution","Vendorable / ubiquitous","Maintainable / extensible","Major platform support","Lazy test planning","Runtime- skippable tests","Scheduling / re-running",Mocks,"Signal & exception handling","Coverage reports"
> > +https://lore.kernel.org/git/c902a166-98ce-afba-93f2-ea6027557176@gmail.com/[Custom Git impl.],[lime-background]#True#,[lime-background]#True#,?,[lime-background]#True#,[lime-background]#True#,[lime-background]#True#,[lime-background]#True#,?,?,[red-background]#False#,?,?
> > +https://cmocka.org/[cmocka],[lime-background]#True#,[lime-background]#True#,?,[red-background]#False#,[yellow-background]#Partial#,[yellow-background]#Partial#,[yellow-background]#Partial#,?,?,[lime-background]#True#,?,?
> > +https://libcheck.github.io/check/[Check],[lime-background]#True#,[lime-background]#True#,?,[red-background]#False#,[yellow-background]#Partial#,[lime-background]#True#,[yellow-background]#Partial#,?,?,[red-background]#False#,?,?
> > +https://github.com/rra/c-tap-harness/[C TAP],[lime-background]#True#,[red-background]#False#,?,[lime-background]#True#,[yellow-background]#Partial#,[yellow-background]#Partial#,[yellow-background]#Partial#,?,?,[red-background]#False#,?,?
> > +https://github.com/silentbicycle/greatest[Greatest],[yellow-background]#Partial#,?,?,[lime-background]#True#,[yellow-background]#Partial#,?,[yellow-background]#Partial#,?,?,[red-background]#False#,?,?
> > +https://github.com/Snaipe/Criterion[Criterion],[lime-background]#True#,?,?,[red-background]#False#,?,[lime-background]#True#,?,?,?,[red-background]#False#,?,?
> > +https://github.com/zorgnax/libtap[libtap],[lime-background]#True#,?,?,?,?,?,?,?,?,?,?,?
> > +https://nemequ.github.io/munit/[µnit],?,?,?,?,?,?,?,?,?,?,?,?
> > +https://github.com/google/cmockery[cmockery],?,?,?,?,?,?,?,?,?,[lime-background]#True#,?,?
> > +https://github.com/lpabon/cmockery2[cmockery2],?,?,?,?,?,?,?,?,?,[lime-background]#True#,?,?
> > +https://github.com/ThrowTheSwitch/Unity[Unity],?,?,?,?,?,?,?,?,?,?,?,?
> > +https://github.com/siu/minunit[minunit],?,?,?,?,?,?,?,?,?,?,?,?
> > +https://cunit.sourceforge.net/[CUnit],?,?,?,?,?,?,?,?,?,?,?,?
> > +https://www.kindahl.net/mytap/doc/index.html[MyTAP],[lime-background]#True#,?,?,?,?,?,?,?,?,?,?,?
> > +|=====
>
> Thanks for going through these projects, hopefully we can use this
> information to make a decision on a framework soon.
>
> Best Wishes
>
> Phillip
^ permalink raw reply
* Re: [RFC PATCH v3 1/1] unit tests: Add a project plan document
From: Josh Steadmon @ 2023-06-30 22:18 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, calvinwan, szeder.dev, phillip.wood123, chooglen, avarab,
sandals
In-Reply-To: <xmqq7cs73sic.fsf@gitster.g>
On 2023.06.13 15:30, Junio C Hamano wrote:
> Josh Steadmon <steadmon@google.com> writes:
>
> > In our current testing environment, we spend a significant amount of
> > effort crafting end-to-end tests for error conditions that could easily
> > be captured by unit tests (or we simply forgo some hard-to-setup and
> > rare error conditions).Describe what we hope to accomplish by
> > implementing unit tests, and explain some open questions and milestones.
> > Discuss desired features for test frameworks/harnesses, and provide a
> > preliminary comparison of several different frameworks.
> >
> > Signed-off-by: Josh Steadmon <steadmon@google.com>
> > Coauthored-by: Calvin Wan <calvinwan@google.com>
> > ---
>
> The co-author should also signal his acceptance of the D-C-O with
> his own S-o-b. [*1*] gives a good example.
Fixed in V4. Thanks.
^ permalink raw reply
* Re: [PATCH v4 0/6] git-compat-util cleanups
From: Junio C Hamano @ 2023-06-30 21:56 UTC (permalink / raw)
To: Calvin Wan; +Cc: git, phillip.wood123, jonathantanmy
In-Reply-To: <20230630202237.3069327-1-calvinwan@google.com>
Calvin Wan <calvinwan@google.com> writes:
> Changes since v3:
> - Dropped patches 5 and 6 since removing the circular dependency in
> common.h turns out to be quite difficult
> - Patch 8 moves the alloc macros to git-compat-util.h rather than
> common.h since that does not exist anymore
Will queue.
> Note for the maintainer:
>
> I rebased this series onto both seen and next and they rebased cleanly.
Thanks. It is a very indirect way to ensure if the topic is usable,
though. What we want is:
* A series of patches that applies cleanly to 'master'. Call the
result of applying them $T (topic).
* "git checkout next && git merge $T" should give at most trivial
conflicts.
* The same for 'seen'.
If the conflicts with topics in 'seen' are only with topics in the
stalled category and/or expecting a reroll category, we may discard
the other topic have _their_ reroll worry about adjusting for this
topic.
FWIW, I did
(1) tentatively applied these patches to 'next^0', and discarded
the result.
(2) applied these patches with "-3" to 'master^0', which saw a bit
of conflicts in gpg-interface.c (with cw/strbuf-cleanup topic)
and in strbuf.c (again with cw/strbuf-cleanup topic).
(3) to cross check the result, merged (2) into 'next^0' to make
sure that it matches (1).
(4) merged (2) into 'seen^0'.
As this round has been rebased to a more recent codebase, even with
the conflicts with cw/strbuf-cleanup, (4) indeed merged fairly
cleanly, with the same set of conflicts as (3).
Thanks for rebasing the patches.
Hopefully people will be able to review and give feedback to the
series this time.
^ permalink raw reply
* Re: [RFC PATCH v3 1/1] unit tests: Add a project plan document
From: Josh Steadmon @ 2023-06-30 21:33 UTC (permalink / raw)
To: Linus Arver, git, calvinwan, szeder.dev, phillip.wood123,
chooglen, avarab, gitster, sandals
In-Reply-To: <ZJ3uGBEEvYmbPnoQ@google.com>
On 2023.06.29 13:48, Josh Steadmon wrote:
> On 2023.06.29 12:42, Linus Arver wrote:
> > I can think of some other metrics to add to the comparison, namely:
> >
> > 1. Age (how old is the framework)
> > 2. Size in KLOC (thousands of lines of code)
> > 3. Adoption rate (which notable C projects already use this framework?)
> > 4. Project health (how active are its developers?)
> >
> > I think for 3 and 4, we could probably mine some data out of GitHub
> > itself.
>
> Interesting, I'll see about adding some of these.
For now, I'm going to exclude Age (because all else being equal, it's
not clear to me why we would prefer and older or younger project) and
Project Health (because it's not clear how to begin to measure this). If
you have further thoughts that could clarify, I'd be happy to
reconsider.
Thanks!
^ permalink raw reply
* What's cooking in git.git (Jun 2023, #08; Fri, 30)
From: Junio C Hamano @ 2023-06-30 20:27 UTC (permalink / raw)
To: git
Here are the topics that have been cooking in my tree. Commits
prefixed with '+' are in 'next' (being in 'next' is a sign that a
topic is stable enough to be used and are candidate to be in a
future release). Commits prefixed with '-' are only in 'seen', and
aren't considered "accepted" at all and may be annotated with an URL
to a message that raises issues but they are no means exhaustive. A
topic without enough support may be discarded after a long period of
no activity (of course they can be resubmit when new interests
arise).
The northern hemisphere being in Summer vacation season, the list
traffic in the coming week is expected to be lighter. Have fun and
be safe, everybody.
Copies of the source code to Git live in many repositories, and the
following is a list of the ones I push into or their mirrors. Some
repositories have only a subset of branches.
With maint, master, next, seen, todo:
git://git.kernel.org/pub/scm/git/git.git/
git://repo.or.cz/alt-git.git/
https://kernel.googlesource.com/pub/scm/git/git/
https://github.com/git/git/
https://gitlab.com/git-vcs/git/
With all the integration branches and topics broken out:
https://github.com/gitster/git/
Even though the preformatted documentation in HTML and man format
are not sources, they are published in these repositories for
convenience (replace "htmldocs" with "manpages" for the manual
pages):
git://git.kernel.org/pub/scm/git/git-htmldocs.git/
https://github.com/gitster/git-htmldocs.git/
Release tarballs are available at:
https://www.kernel.org/pub/software/scm/git/
--------------------------------------------------
[Graduated to 'master']
* ds/remove-idx-before-pack (2023-06-20) 1 commit
(merged to 'next' on 2023-06-23 at fa97bf0e41)
+ packfile: delete .idx files before .pack files
We create .pack and then .idx, we consider only packfiles that have
.idx usable (those with only .pack are not ready yet), so we should
remove .idx before removing .pack for consistency.
source: <pull.1547.git.1687287675248.gitgitgadget@gmail.com>
* en/header-split-cache-h-part-3 (2023-06-21) 28 commits
(merged to 'next' on 2023-06-23 at 84ad22bf36)
+ fsmonitor-ll.h: split this header out of fsmonitor.h
+ hash-ll, hashmap: move oidhash() to hash-ll
+ object-store-ll.h: split this header out of object-store.h
+ khash: name the structs that khash declares
+ merge-ll: rename from ll-merge
+ git-compat-util.h: remove unneccessary include of wildmatch.h
+ builtin.h: remove unneccessary includes
+ list-objects-filter-options.h: remove unneccessary include
+ diff.h: remove unnecessary include of oidset.h
+ repository: remove unnecessary include of path.h
+ log-tree: replace include of revision.h with simple forward declaration
+ cache.h: remove this no-longer-used header
+ read-cache*.h: move declarations for read-cache.c functions from cache.h
+ repository.h: move declaration of the_index from cache.h
+ merge.h: move declarations for merge.c from cache.h
+ diff.h: move declaration for global in diff.c from cache.h
+ preload-index.h: move declarations for preload-index.c from elsewhere
+ sparse-index.h: move declarations for sparse-index.c from cache.h
+ name-hash.h: move declarations for name-hash.c from cache.h
+ run-command.h: move declarations for run-command.c from cache.h
+ statinfo: move stat_{data,validity} functions from cache/read-cache
+ read-cache: move shared add/checkout/commit code
+ add: modify add_files_to_cache() to avoid globals
+ read-cache: move shared commit and ls-files code
+ setup: adopt shared init-db & clone code
+ init-db, clone: change unnecessary global into passed parameter
+ init-db: remove unnecessary global variable
+ init-db: document existing bug with core.bare in template config
Header files cleanup.
source: <pull.1525.v3.git.1684218848.gitgitgadget@gmail.com>
* jc/abort-ll-merge-with-a-signal (2023-06-23) 2 commits
(merged to 'next' on 2023-06-24 at 685eb5d25c)
+ t6406: skip "external merge driver getting killed by a signal" test on Windows
(merged to 'next' on 2023-06-23 at 9c9c37e95e)
+ ll-merge: killing the external merge driver aborts the merge
When the external merge driver is killed by a signal, its output
should not be trusted as a resolution with conflicts that is
proposed by the driver, but the code did.
source: <xmqq4jmzc91e.fsf_-_@gitster.g>
* tb/gc-recent-object-hook (2023-06-24) 1 commit
(merged to 'next' on 2023-06-24 at e8c295841b)
+ t7701: make annotated tag unreachable
Test update.
source: <259b1b559114ab1a9a0bd7f1ad29a4cba2612ae0.1687617197.git.me@ttaylorr.com>
--------------------------------------------------
[New Topics]
* jk/cherry-pick-revert-status (2023-06-27) 1 commit
(merged to 'next' on 2023-06-28 at 4a0d88ef7a)
+ fix cherry-pick/revert status when doing multiple commits
During a cherry-pick or revert session that works on multiple
commits, "git status" did not give correct information, which has
been corrected.
Will merge to 'master'.
source: <20230627224230.1951135-1-jacob.e.keller@intel.com>
* ks/t4205-test-describe-with-abbrev-fix (2023-06-29) 1 commit
(merged to 'next' on 2023-06-29 at 5fc309dc75)
+ t4205: correctly test %(describe:abbrev=...)
Test update.
Will merge to 'master'.
source: <20230629133841.18784-2-five231003@gmail.com>
* jk/fsck-indices-in-worktrees (2023-06-29) 1 commit
(merged to 'next' on 2023-06-29 at 9d245b3681)
+ fsck: avoid misleading variable name
Code clarification.
Will merge to 'master'.
source: <20230629181333.87465-1-ericsunshine@charter.net>
* js/empty-index-fixes (2023-06-29) 3 commits
(merged to 'next' on 2023-06-29 at cdfd131900)
+ commit -a -m: allow the top-level tree to become empty again
+ split-index: accept that a base index can be empty
+ do_read_index(): always mark index as initialized unless erroring out
A few places failed to differenciate the case where the index is
truly empty (nothing added) and we haven't yet read from the
on-disk index file, which have been corrected.
Will merge to 'master'.
source: <pull.1554.git.1688044991.gitgitgadget@gmail.com>
* vd/adjust-mfow-doc-to-updated-headers (2023-06-29) 1 commit
- docs: include "trace.h" in MyFirstObjectWalk.txt
Code snippets in a tutorial document no longer compiled after
recent header shuffling, which have been corrected.
Will merge to 'next'?
source: <20230629185238.58961-1-vinayakdev.sci@gmail.com>
--------------------------------------------------
[Stalled]
* ed/fsmonitor-windows-named-pipe (2023-03-24) 1 commit
- fsmonitor: handle differences between Windows named pipe functions
Fix fsmonitor on Windows when the filesystem path contains certain
characters.
Expecting a reroll.
cf. <b9cf67e4-22a7-2ff0-8310-9223bea10d6d@jeffhostetler.com>
source: <pull.1503.git.1679678090412.gitgitgadget@gmail.com>
* rn/sparse-diff-index (2023-04-10) 1 commit
- diff-index: enable sparse index
"git diff-index" command has been taught to work better with the
sparse index.
Expecting a reroll.
cf. <62821012-4fc3-5ad8-695c-70f7ab14a8c9@github.com>
source: <20230408112342.404318-1-nanth.raghul@gmail.com>
* es/recurse-submodules-option-is-a-bool (2023-04-10) 1 commit
- usage: clarify --recurse-submodules as a boolean
The "--[no-]recurse-submodules" option of "git checkout" and others
supported an undocumented syntax --recurse-submodules=<value> where
the value can spell a Boolean in various ways. The support for the
syntax is being dropped.
Expecting a reroll.
cf. <ZDSTFwMFO7vbj/du@google.com>
source: <ZDSTFwMFO7vbj/du@google.com>
* cb/checkout-same-branch-twice (2023-03-22) 2 commits
- SQUASH??? the test marked to expect failure passes from day one
- checkout/switch: disallow checking out same branch in multiple worktrees
"git checkout -B $branch" failed to protect against checking out
a branch that is checked out elsewhere, unlike "git branch -f" did.
Expecting a hopefully minor and final reroll.
cf. <CAPUEspj_Bh+LgYLnWfeBdcq_uV5Cbou-7H51GLFjzSa5Qzby9w@mail.gmail.com>
source: <20230120113553.24655-1-carenas@gmail.com>
* tk/pull-conflict-suggest-rebase-merge-not-rebase-true (2023-02-13) 1 commit
- pull: conflict hint pull.rebase suggestion should offer "merges" vs "true"
In an advice message after failed non-ff pull, we used to suggest
setting pull.rebase=true, but these days pull.rebase=merges may be
more inline with the original spirit of "rebuild your side on top
of theirs".
May want to discard.
This is too much of a departure from the existing practice.
cf. <CAMMLpeTPEoKVTbfc17w+Y9qn7jOGmQi_Ux0Y3sFW5QTgGWJ=SA@mail.gmail.com>
cf. <CABPp-BGqAxKnxDRVN4cYMteLp33hvto07R3=TJBT5WubJT4+Og@mail.gmail.com>
source: <pull.1474.git.1675614276549.gitgitgadget@gmail.com>
* ab/tag-object-type-errors (2023-05-10) 4 commits
- tag: don't emit potentially incorrect "object is a X, not a Y"
- tag: don't misreport type of tagged objects in errors
- object tests: add test for unexpected objects in tags
- Merge branch 'jk/parse-object-type-mismatch' into ab/tag-object-type-errors
Hardening checks around mismatched object types when one of those
objects is a tag.
source: <cover-v2-0.3-00000000000-20221230T011725Z-avarab@gmail.com>
* ad/test-record-count-when-harness-is-in-use (2022-12-25) 1 commit
- test-lib: allow storing counts with test harnesses
Allow summary results from tests to be written to t/test-results
directory even when a test harness like 'prove' is in use.
Expecting a reroll.
cf. <CABPp-BGoPuGCZw+9wCgdYyRR4Zf4y9Kun27GrQhtMdYWpOUsYQ@mail.gmail.com>
source: <20221224225200.1027806-1-adam@dinwoodie.org>
* so/diff-merges-more (2022-12-18) 5 commits
- diff-merges: improve --diff-merges documentation
- diff-merges: issue warning on lone '-m' option
- diff-merges: support list of values for --diff-merges
- diff-merges: implement log.diffMerges-m-imply-p config
- diff-merges: implement [no-]hide option and log.diffMergesHide config
Assorted updates to "--diff-merges=X" option.
May want to discard.
Breaking compatibility does not seem worth it.
source: <20221217132955.108542-1-sorganov@gmail.com>
* ab/imap-send-requires-curl (2023-02-02) 6 commits
- imap-send: correctly report "host" when using "tunnel"
- imap-send: remove old --no-curl codepath
- imap-send: make --curl no-optional
- imap-send: replace auto-probe libcurl with hard dependency
- imap-send doc: the imap.sslVerify is used with imap.tunnel
- imap-send: note "auth_method", not "host" on auth method failure
Give a hard dependency on cURL library to build "git imap-send",
and remove the code to interact with IMAP server without using cURL.
Expecting a reroll.
The 'tunnel' part is still iffy.
cf. <230203.86bkmabfjr.gmgdl@evledraar.gmail.com>
source: <cover-v2-0.6-00000000000-20230202T093706Z-avarab@gmail.com>
* cw/submodule-status-in-parallel (2023-03-02) 6 commits
- diff-lib: parallelize run_diff_files for submodules
- diff-lib: refactor out diff_change logic
- submodule: refactor is_submodule_modified()
- submodule: move status parsing into function
- submodule: rename strbuf variable
- run-command: add on_stderr_output_fn to run_processes_parallel_opts
"git submodule status" learned to run the comparison in submodule
repositories in parallel.
Expecting a reroll.
cf. <CAFySSZDk05m6gU5-V1R+y3YnQ5PPduVW54+_gjBwD0rmacsLsw@mail.gmail.com>
cf. <230307.865ybc273g.gmgdl@evledraar.gmail.com>
source: <20230302215237.1473444-1-calvinwan@google.com>
--------------------------------------------------
[Cooking]
* mh/credential-erase-improvements-more (2023-06-24) 2 commits
- credential/wincred: erase matching creds only
- credential/libsecret: erase matching creds only
Needs review.
source: <pull.1529.git.git.1687596777147.gitgitgadget@gmail.com>
* gc/config-context (2023-06-28) 11 commits
(merged to 'next' on 2023-06-28 at 38632f3daf)
+ config: pass source to config_parser_event_fn_t
+ config: add kvi.path, use it to evaluate includes
+ config.c: remove config_reader from configsets
+ config: pass kvi to die_bad_number()
+ trace2: plumb config kvi
+ config.c: pass ctx with CLI config
+ config: pass ctx with config files
+ config.c: pass ctx in configsets
+ config: add ctx arg to config_fn_t
+ urlmatch.h: use config_fn_t type
+ config: inline git_color_default_config
Reduce reliance on a global state in the config reading API.
Will merge to 'master'.
source: <pull.1497.v5.git.git.1687980390.gitgitgadget@gmail.com>
* gc/config-partial-submodule-kvi-fix (2023-06-26) 1 commit
(merged to 'next' on 2023-06-28 at 1fb30a34e3)
+ config: don't BUG when both kvi and source are set
Partially revert a sanity check that the rest of the config code
was not ready, to avoid triggering it in a corner case.
Will merge to 'master'.
source: <pull.1535.git.git.1687801297404.gitgitgadget@gmail.com>
* pw/apply-too-large (2023-06-26) 1 commit
(merged to 'next' on 2023-06-28 at c0460d682c)
+ apply: improve error messages when reading patch
"git apply" punts when it is fed too large a patch input; the error
message it gives when it happens has been clarified.
Will merge to 'master'.
source: <pull.1552.git.1687772253869.gitgitgadget@gmail.com>
* pw/diff-no-index-from-named-pipes (2023-06-27) 3 commits
- diff --no-index: support reading from named pipes
- t4054: test diff --no-index with stdin
- diff --no-index: die on error reading stdin
"git diff --no-index" learned to read from named pipes as if they
were regular files, to allow "git diff <(process) <(substitution)"
some shells support.
Expecting a reroll.
cf. <457ff920-865e-f018-1d79-f3cb1121d199@gmail.com>
source: <cover.1687874975.git.phillip.wood@dunelm.org.uk>
* bc/more-git-var (2023-06-27) 8 commits
(merged to 'next' on 2023-06-27 at ea14687e91)
+ var: add config file locations
+ var: add attributes files locations
+ attr: expose and rename accessor functions
+ var: adjust memory allocation for strings
+ var: format variable structure with C99 initializers
+ var: add support for listing the shell
+ t: add a function to check executable bit
+ var: mark unused parameters in git_var callbacks
Add more "git var" for toolsmiths to learn various locations Git is
configured with either via the configuration or hardcoded defaults.
Will merge to 'master'.
source: <20230627161902.754472-1-sandals@crustytoothpaste.net>
* jc/doc-hash-object-types (2023-06-28) 1 commit
(merged to 'next' on 2023-06-28 at adff1700c2)
+ docs: add git hash-object -t option's possible values
Doc update.
Will merge to 'master'.
source: <pull.1533.v3.git.git.1688004473941.gitgitgadget@gmail.com>
* cc/repack-sift-filtered-objects-to-separate-pack (2023-06-14) 9 commits
- gc: add `gc.repackFilterTo` config option
- repack: implement `--filter-to` for storing filtered out objects
- gc: add `gc.repackFilter` config option
- repack: add `--filter=<filter-spec>` option
- repack: refactor finishing pack-objects command
- repack: refactor piping an oid to a command
- t/helper: add 'find-pack' test-tool
- pack-objects: add `--print-filtered` to print omitted objects
- pack-objects: allow `--filter` without `--stdout`
"git repack" machinery learns to pay attention to the "--filter="
option.
Needs review.
source: <20230614192541.1599256-1-christian.couder@gmail.com>
* ps/revision-stdin-with-options (2023-06-15) 3 commits
(merged to 'next' on 2023-06-26 at eda3e4d0b5)
+ revision: handle pseudo-opts in `--stdin` mode
+ revision: small readability improvement for reading from stdin
+ revision: reorder `read_revisions_from_stdin()`
The set-up code for the get_revision() API now allows feeding
options like --all and --not in the --stdin mode.
Will merge to 'master'.
source: <cover.1686839572.git.ps@pks.im>
* rs/strbuf-expand-step (2023-06-18) 5 commits
(merged to 'next' on 2023-06-28 at 1918915b71)
+ strbuf: simplify strbuf_expand_literal_cb()
+ replace strbuf_expand() with strbuf_expand_step()
+ replace strbuf_expand_dict_cb() with strbuf_expand_step()
+ strbuf: factor out strbuf_expand_step()
+ pretty: factor out expand_separator()
Code clean-up around strbuf_expand() API.
Will merge to 'master'.
source: <767baa64-20a6-daf2-d34b-d81f72363749@web.de>
* js/doc-unit-tests (2023-06-13) 1 commit
- unit tests: Add a project plan document
Process to add some form of low-level unit tests has started.
Comments? Filling in blanks?
source: <8afdb215d7e10ca16a2ce8226b4127b3d8a2d971.1686352386.git.steadmon@google.com>
* mh/mingw-case-sensitive-build (2023-06-12) 1 commit
- mingw: use lowercase includes for some Windows headers
Names of MinGW header files are spelled in mixed case in some
source files, but the build host can be using case sensitive
filesystem with header files with their name spelled in all
lowercase.
Needs review.
source: <20230604211934.1365289-1-mh@glandium.org>
* pb/complete-diff-options (2023-06-26) 24 commits
(merged to 'next' on 2023-06-28 at ccff93557d)
+ diff.c: mention completion above add_diff_options
+ completion: complete --remerge-diff
+ completion: complete --diff-merges, its options and --no-diff-merges
+ completion: move --pickaxe-{all,regex} to __git_diff_common_options
+ completion: complete --ws-error-highlight
+ completion: complete --unified
+ completion: complete --output-indicator-{context,new,old}
+ completion: complete --output
+ completion: complete --no-stat
+ completion: complete --no-relative
+ completion: complete --line-prefix
+ completion: complete --ita-invisible-in-index and --ita-visible-in-index
+ completion: complete --irreversible-delete
+ completion: complete --ignore-matching-lines
+ completion: complete --function-context
+ completion: complete --find-renames
+ completion: complete --find-object
+ completion: complete --find-copies
+ completion: complete --default-prefix
+ completion: complete --compact-summary
+ completion: complete --combined-all-paths
+ completion: complete --cc
+ completion: complete --break-rewrites
+ completion: add comments describing __git_diff_* globals
Completion updates.
Will merge to 'master'.
source: <pull.1543.v3.git.1687796688.gitgitgadget@gmail.com>
* ks/ref-filter-signature (2023-06-06) 2 commits
- ref-filter: add new "signature" atom
- t/lib-gpg: introduce new prereq GPG2
The "git for-each-ref" family of commands learned placeholders
related to GPG signature verification.
Needs review.
source: <20230604185815.15761-1-five231003@gmail.com>
* jt/path-filter-fix (2023-06-13) 4 commits
- commit-graph: new filter ver. that fixes murmur3
- repo-settings: introduce commitgraph.changedPathsVersion
- t4216: test changed path filters with high bit paths
- gitformat-commit-graph: describe version 2 of BDAT
The Bloom filter used for path limited history traversal was broken
on systems whose "char" is unsigned; update the implementation and
bump the format version to 2.
Expecting a reroll.
cf. <c7b66d2c-cdc3-1f0f-60a0-a2ee21c277bf@github.com>
source: <cover.1686677910.git.jonathantanmy@google.com>
* tk/cherry-pick-sequence-requires-clean-worktree (2023-06-01) 1 commit
- cherry-pick: refuse cherry-pick sequence if index is dirty
"git cherry-pick A" that replays a single commit stopped before
clobbering local modification, but "git cherry-pick A..B" did not,
which has been corrected.
Expecting a reroll.
cf. <999f12b2-38d6-f446-e763-4985116ad37d@gmail.com>
source: <pull.1535.v2.git.1685264889088.gitgitgadget@gmail.com>
* mh/credential-libsecret-attrs (2023-06-16) 1 commit
- credential/libsecret: store new attributes
The way authentication related data other than passwords (e.g.
oath token and password expiration data) are stored in libsecret
keyrings has been rethought.
Needs review.
source: <pull.1469.v5.git.git.1686945306242.gitgitgadget@gmail.com>
* tb/refs-exclusion-and-packed-refs (2023-06-20) 16 commits
- ls-refs.c: avoid enumerating hidden refs where possible
- upload-pack.c: avoid enumerating hidden refs where possible
- builtin/receive-pack.c: avoid enumerating hidden references
- refs.h: let `for_each_namespaced_ref()` take excluded patterns
- refs/packed-backend.c: ignore complicated hidden refs rules
- revision.h: store hidden refs in a `strvec`
- refs/packed-backend.c: add trace2 counters for jump list
- refs/packed-backend.c: implement jump lists to avoid excluded pattern(s)
- refs/packed-backend.c: refactor `find_reference_location()`
- refs: plumb `exclude_patterns` argument throughout
- builtin/for-each-ref.c: add `--exclude` option
- ref-filter.c: parameterize match functions over patterns
- ref-filter: add `ref_filter_clear()`
- ref-filter: clear reachable list pointers after freeing
- ref-filter.h: provide `REF_FILTER_INIT`
- refs.c: rename `ref_filter`
Enumerating refs in the packed-refs file, while excluding refs that
match certain patterns, has been optimized.
source: <cover.1687270849.git.me@ttaylorr.com>
* cc/git-replay (2023-06-03) 15 commits
- replay: stop assuming replayed branches do not diverge
- replay: add --contained to rebase contained branches
- replay: add --advance or 'cherry-pick' mode
- replay: disallow revision specific options and pathspecs
- replay: use standard revision ranges
- replay: make it a minimal server side command
- replay: remove HEAD related sanity check
- replay: remove progress and info output
- replay: add an important FIXME comment about gpg signing
- replay: don't simplify history
- replay: introduce pick_regular_commit()
- replay: die() instead of failing assert()
- replay: start using parse_options API
- replay: introduce new builtin
- t6429: remove switching aspects of fast-rebase
source: <20230602102533.876905-1-christian.couder@gmail.com>
* ob/revert-of-revert (2023-05-05) 1 commit
- sequencer: beautify subject of reverts of reverts
Instead of "Revert "Revert "original"", give "Reapply "original""
as the title for a revert of a revert.
Expecting a hopefully final reroll.
Looking much better, except for minor cosmetic issues.
source: <20230428083528.1699221-1-oswald.buddenhagen@gmx.de>
* cw/strbuf-cleanup (2023-06-12) 7 commits
(merged to 'next' on 2023-06-28 at c158b004a8)
+ strbuf: remove global variable
+ path: move related function to path
+ object-name: move related functions to object-name
+ credential-store: move related functions to credential-store file
+ abspath: move related functions to abspath
+ strbuf: clarify dependency
+ strbuf: clarify API boundary
Move functions that are not about pure string manipulation out of
strbuf.[ch]
Will merge to 'master'.
source: <20230606194720.2053551-1-calvinwan@google.com>
* tl/notes-separator (2023-06-21) 7 commits
(merged to 'next' on 2023-06-28 at 74fa459f4d)
+ notes: introduce "--no-separator" option
+ notes.c: introduce "--[no-]stripspace" option
+ notes.c: append separator instead of insert by pos
+ notes.c: introduce '--separator=<paragraph-break>' option
+ t3321: add test cases about the notes stripspace behavior
+ notes.c: use designated initializers for clarity
+ notes.c: cleanup 'strbuf_grow' call in 'append_edit'
'git notes append' was taught '--separator' to specify string to insert
between paragraphs.
Will merge to 'master'.
source: <cover.1685174011.git.dyroneteng@gmail.com>
* pw/rebase-i-after-failure (2023-04-21) 6 commits
- rebase -i: fix adding failed command to the todo list
- rebase: fix rewritten list for failed pick
- rebase --continue: refuse to commit after failed command
- sequencer: factor out part of pick_commits()
- rebase -i: remove patch file after conflict resolution
- rebase -i: move unlink() calls
Various fixes to the behaviour of "rebase -i" when the command got
interrupted by conflicting changes.
Expecting a reroll.
cf. <xmqqsfcthrpb.fsf@gitster.g>
cf. <1fd54422-b66a-c2e4-7cd7-934ea01190ad@gmail.com>
source: <pull.1492.v2.git.1682089074.gitgitgadget@gmail.com>
^ permalink raw reply
* [PATCH v4 6/6] common: move alloc macros to common.h
From: Calvin Wan @ 2023-06-30 20:23 UTC (permalink / raw)
To: git; +Cc: Calvin Wan, phillip.wood123, jonathantanmy
In-Reply-To: <20230630202237.3069327-1-calvinwan@google.com>
alloc_nr, ALLOC_GROW, and ALLOC_GROW_BY are commonly used macros for
dynamic array allocation. Moving these macros to git-compat-util.h with
the other alloc macros focuses alloc.[ch] to allocation for Git objects
and additionally allows us to remove inclusions to alloc.h from files
that solely used the above macros.
Signed-off-by: Calvin Wan <calvinwan@google.com>
---
add-patch.c | 1 -
alias.c | 1 -
alloc.h | 75 ------------------------------
apply.c | 1 -
archive-tar.c | 1 -
archive.c | 1 -
attr.c | 1 -
builtin/blame.c | 1 -
builtin/cat-file.c | 1 -
builtin/checkout--worker.c | 1 -
builtin/config.c | 1 -
builtin/credential-cache--daemon.c | 1 -
builtin/fetch-pack.c | 1 -
builtin/fsmonitor--daemon.c | 1 -
builtin/grep.c | 1 -
builtin/index-pack.c | 1 -
builtin/log.c | 1 -
builtin/merge.c | 1 -
builtin/mktree.c | 1 -
builtin/mv.c | 1 -
builtin/name-rev.c | 1 -
builtin/pack-objects.c | 1 -
builtin/repack.c | 1 -
builtin/rev-parse.c | 1 -
builtin/revert.c | 1 -
builtin/rm.c | 1 -
builtin/submodule--helper.c | 1 -
bulk-checkin.c | 1 -
cache-tree.c | 1 -
chunk-format.c | 1 -
commit-reach.c | 1 -
config.c | 1 -
daemon.c | 1 -
delta-islands.c | 1 -
diff.c | 1 -
diffcore-rename.c | 1 -
dir-iterator.c | 1 -
dir.c | 1 -
ewah/bitmap.c | 1 -
ewah/ewah_bitmap.c | 1 -
fetch-pack.c | 1 -
fmt-merge-msg.c | 1 -
fsck.c | 1 -
git-compat-util.h | 75 ++++++++++++++++++++++++++++++
help.c | 1 -
http-backend.c | 1 -
line-log.c | 1 -
list-objects-filter-options.c | 1 -
list-objects-filter.c | 1 -
midx.c | 1 -
object-file.c | 1 -
oid-array.c | 1 -
oidtree.c | 1 -
pack-bitmap-write.c | 1 -
pack-bitmap.c | 1 -
pack-objects.c | 1 -
packfile.c | 1 -
parallel-checkout.c | 1 -
pretty.c | 1 -
prio-queue.c | 1 -
quote.c | 1 -
read-cache.c | 1 -
ref-filter.c | 1 -
reflog-walk.c | 1 -
refs.c | 1 -
refspec.c | 1 -
remote-curl.c | 1 -
remote.c | 1 -
rerere.c | 1 -
revision.c | 1 -
sequencer.c | 1 -
server-info.c | 1 -
shallow.c | 1 -
sigchain.c | 1 -
sparse-index.c | 1 -
split-index.c | 1 -
strbuf.c | 1 -
string-list.c | 1 -
strvec.c | 1 -
submodule-config.c | 1 -
submodule.c | 1 -
t/helper/test-reach.c | 1 -
trace2/tr2_tls.c | 1 -
trailer.c | 1 -
transport.c | 1 -
tree-walk.c | 1 -
userdiff.c | 1 -
worktree.c | 1 -
88 files changed, 75 insertions(+), 161 deletions(-)
diff --git a/add-patch.c b/add-patch.c
index ba629add62..bfe19876cd 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1,7 +1,6 @@
#include "git-compat-util.h"
#include "add-interactive.h"
#include "advice.h"
-#include "alloc.h"
#include "editor.h"
#include "environment.h"
#include "gettext.h"
diff --git a/alias.c b/alias.c
index 910dd252a0..5a238f2e30 100644
--- a/alias.c
+++ b/alias.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "alias.h"
-#include "alloc.h"
#include "config.h"
#include "gettext.h"
#include "strbuf.h"
diff --git a/alloc.h b/alloc.h
index 4312db4bd0..3f4a0ad310 100644
--- a/alloc.h
+++ b/alloc.h
@@ -17,79 +17,4 @@ void *alloc_object_node(struct repository *r);
struct alloc_state *allocate_alloc_state(void);
void clear_alloc_state(struct alloc_state *s);
-#define alloc_nr(x) (((x)+16)*3/2)
-
-/**
- * Dynamically growing an array using realloc() is error prone and boring.
- *
- * Define your array with:
- *
- * - a pointer (`item`) that points at the array, initialized to `NULL`
- * (although please name the variable based on its contents, not on its
- * type);
- *
- * - an integer variable (`alloc`) that keeps track of how big the current
- * allocation is, initialized to `0`;
- *
- * - another integer variable (`nr`) to keep track of how many elements the
- * array currently has, initialized to `0`.
- *
- * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
- * alloc)`. This ensures that the array can hold at least `n` elements by
- * calling `realloc(3)` and adjusting `alloc` variable.
- *
- * ------------
- * sometype *item;
- * size_t nr;
- * size_t alloc
- *
- * for (i = 0; i < nr; i++)
- * if (we like item[i] already)
- * return;
- *
- * // we did not like any existing one, so add one
- * ALLOC_GROW(item, nr + 1, alloc);
- * item[nr++] = value you like;
- * ------------
- *
- * You are responsible for updating the `nr` variable.
- *
- * If you need to specify the number of elements to allocate explicitly
- * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
- *
- * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
- * added niceties.
- *
- * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
- */
-#define ALLOC_GROW(x, nr, alloc) \
- do { \
- if ((nr) > alloc) { \
- if (alloc_nr(alloc) < (nr)) \
- alloc = (nr); \
- else \
- alloc = alloc_nr(alloc); \
- REALLOC_ARRAY(x, alloc); \
- } \
- } while (0)
-
-/*
- * Similar to ALLOC_GROW but handles updating of the nr value and
- * zeroing the bytes of the newly-grown array elements.
- *
- * DO NOT USE any expression with side-effect for any of the
- * arguments.
- */
-#define ALLOC_GROW_BY(x, nr, increase, alloc) \
- do { \
- if (increase) { \
- size_t new_nr = nr + (increase); \
- if (new_nr < nr) \
- BUG("negative growth in ALLOC_GROW_BY"); \
- ALLOC_GROW(x, new_nr, alloc); \
- memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
- nr = new_nr; \
- } \
- } while (0)
-
#endif
diff --git a/apply.c b/apply.c
index dde124066b..3d69fec836 100644
--- a/apply.c
+++ b/apply.c
@@ -9,7 +9,6 @@
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "base85.h"
#include "config.h"
#include "object-store-ll.h"
diff --git a/archive-tar.c b/archive-tar.c
index 218c901ec7..0726996839 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -2,7 +2,6 @@
* Copyright (c) 2005, 2006 Rene Scharfe
*/
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "gettext.h"
#include "git-zlib.h"
diff --git a/archive.c b/archive.c
index 1817cca9f4..ca11db185b 100644
--- a/archive.c
+++ b/archive.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "convert.h"
#include "environment.h"
diff --git a/attr.c b/attr.c
index e5785c55db..ff0a3e7b61 100644
--- a/attr.c
+++ b/attr.c
@@ -7,7 +7,6 @@
*/
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "exec-cmd.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index f9d316a7bf..9c987d6567 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -6,7 +6,6 @@
*/
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "color.h"
#include "builtin.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index c9c93b80fc..694c8538df 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -5,7 +5,6 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
-#include "alloc.h"
#include "config.h"
#include "convert.h"
#include "diff.h"
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
index c655dc4b13..6b62b5375b 100644
--- a/builtin/checkout--worker.c
+++ b/builtin/checkout--worker.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "alloc.h"
#include "config.h"
#include "entry.h"
#include "gettext.h"
diff --git a/builtin/config.c b/builtin/config.c
index 787d85edac..11a4d4ef14 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -1,6 +1,5 @@
#include "builtin.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "color.h"
#include "editor.h"
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index dc1cf2d25f..3a6a750a8e 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -1,6 +1,5 @@
#include "builtin.h"
#include "abspath.h"
-#include "alloc.h"
#include "gettext.h"
#include "object-file.h"
#include "parse-options.h"
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 3ba0fe5a39..44c05ee86c 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "alloc.h"
#include "gettext.h"
#include "hex.h"
#include "object-file.h"
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index b5796b4a4a..7e99c4d61b 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -1,6 +1,5 @@
#include "builtin.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index 22645c6244..ce866523e2 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -4,7 +4,6 @@
* Copyright (c) 2006 Junio C Hamano
*/
#include "builtin.h"
-#include "alloc.h"
#include "gettext.h"
#include "hex.h"
#include "repository.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 66202b304d..3da879d138 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "alloc.h"
#include "config.h"
#include "delta.h"
#include "environment.h"
diff --git a/builtin/log.c b/builtin/log.c
index 1aca560ec3..1b119eaf0b 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -6,7 +6,6 @@
*/
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 404700a35c..de68910177 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -10,7 +10,6 @@
#include "builtin.h"
#include "abspath.h"
#include "advice.h"
-#include "alloc.h"
#include "config.h"
#include "editor.h"
#include "environment.h"
diff --git a/builtin/mktree.c b/builtin/mktree.c
index 0eea810c7e..9a22d4e277 100644
--- a/builtin/mktree.c
+++ b/builtin/mktree.c
@@ -4,7 +4,6 @@
* Copyright (c) Junio C Hamano, 2006, 2009
*/
#include "builtin.h"
-#include "alloc.h"
#include "gettext.h"
#include "hex.h"
#include "quote.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index ae462bd7d4..fa84fcb20d 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -7,7 +7,6 @@
#include "builtin.h"
#include "abspath.h"
#include "advice.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index c3b722b36f..c706fa3720 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "alloc.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 8251961042..06b33d49e9 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "alloc.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index 51698e3c68..f913e9a8a2 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "alloc.h"
#include "config.h"
#include "dir.h"
#include "environment.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 3e2ee44177..434646b074 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -6,7 +6,6 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "commit.h"
#include "environment.h"
diff --git a/builtin/revert.c b/builtin/revert.c
index f6f07d9b53..e6f9a1ad26 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "builtin.h"
#include "parse-options.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index 463eeabcea..dff819ae50 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -5,7 +5,6 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
-#include "alloc.h"
#include "advice.h"
#include "config.h"
#include "lockfile.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 42706150cf..f6871efd95 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1,7 +1,6 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
-#include "alloc.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
diff --git a/bulk-checkin.c b/bulk-checkin.c
index fec6816259..73bff3a23d 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -2,7 +2,6 @@
* Copyright (c) 2011, Google Inc.
*/
#include "git-compat-util.h"
-#include "alloc.h"
#include "bulk-checkin.h"
#include "environment.h"
#include "gettext.h"
diff --git a/cache-tree.c b/cache-tree.c
index 84d7491420..641427ed41 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "environment.h"
#include "hex.h"
#include "lockfile.h"
diff --git a/chunk-format.c b/chunk-format.c
index e7d613c907..140dfa0dcc 100644
--- a/chunk-format.c
+++ b/chunk-format.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "chunk-format.h"
#include "csum-file.h"
#include "gettext.h"
diff --git a/commit-reach.c b/commit-reach.c
index f15d84566b..4b7c233fd4 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "commit.h"
#include "commit-graph.h"
#include "decorate.h"
diff --git a/config.c b/config.c
index 59fad84eb7..3846a37be9 100644
--- a/config.c
+++ b/config.c
@@ -8,7 +8,6 @@
#include "git-compat-util.h"
#include "abspath.h"
#include "advice.h"
-#include "alloc.h"
#include "date.h"
#include "branch.h"
#include "config.h"
diff --git a/daemon.c b/daemon.c
index a7fe89cd2d..f5e597114b 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "path.h"
diff --git a/delta-islands.c b/delta-islands.c
index 5fc6ea6ff5..5de5759f3f 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "attr.h"
#include "object.h"
#include "blob.h"
diff --git a/diff.c b/diff.c
index 9e4d87a8db..ee3eb629e3 100644
--- a/diff.c
+++ b/diff.c
@@ -3,7 +3,6 @@
*/
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "base85.h"
#include "config.h"
#include "convert.h"
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 926b554bd5..5a6e2bcac7 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -3,7 +3,6 @@
* Copyright (C) 2005 Junio C Hamano
*/
#include "git-compat-util.h"
-#include "alloc.h"
#include "diff.h"
#include "diffcore.h"
#include "object-store-ll.h"
diff --git a/dir-iterator.c b/dir-iterator.c
index fb7c47f0e8..278b04243a 100644
--- a/dir-iterator.c
+++ b/dir-iterator.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "dir.h"
#include "iterator.h"
#include "dir-iterator.h"
diff --git a/dir.c b/dir.c
index d270a1be36..c9dc69fc24 100644
--- a/dir.c
+++ b/dir.c
@@ -7,7 +7,6 @@
*/
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "convert.h"
#include "dir.h"
diff --git a/ewah/bitmap.c b/ewah/bitmap.c
index 12d6aa398e..7b525b1ecd 100644
--- a/ewah/bitmap.c
+++ b/ewah/bitmap.c
@@ -17,7 +17,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "git-compat-util.h"
-#include "alloc.h"
#include "ewok.h"
#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD))
diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c
index c6d4ffc87c..8785cbc54a 100644
--- a/ewah/ewah_bitmap.c
+++ b/ewah/ewah_bitmap.c
@@ -17,7 +17,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "git-compat-util.h"
-#include "alloc.h"
#include "ewok.h"
#include "ewok_rlw.h"
diff --git a/fetch-pack.c b/fetch-pack.c
index bb288d47f3..65c1ff4bb4 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "repository.h"
#include "config.h"
#include "date.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 4239594ad8..66e47449a0 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "refs.h"
diff --git a/fsck.c b/fsck.c
index 3be86616c5..b160b6f9d0 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "date.h"
#include "dir.h"
#include "hex.h"
diff --git a/git-compat-util.h b/git-compat-util.h
index 1832444fa2..d32aa754ae 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1136,6 +1136,81 @@ static inline void move_array(void *dst, const void *src, size_t n, size_t size)
#define FLEXPTR_ALLOC_STR(x, ptrname, str) \
FLEXPTR_ALLOC_MEM((x), ptrname, (str), strlen(str))
+#define alloc_nr(x) (((x)+16)*3/2)
+
+/**
+ * Dynamically growing an array using realloc() is error prone and boring.
+ *
+ * Define your array with:
+ *
+ * - a pointer (`item`) that points at the array, initialized to `NULL`
+ * (although please name the variable based on its contents, not on its
+ * type);
+ *
+ * - an integer variable (`alloc`) that keeps track of how big the current
+ * allocation is, initialized to `0`;
+ *
+ * - another integer variable (`nr`) to keep track of how many elements the
+ * array currently has, initialized to `0`.
+ *
+ * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
+ * alloc)`. This ensures that the array can hold at least `n` elements by
+ * calling `realloc(3)` and adjusting `alloc` variable.
+ *
+ * ------------
+ * sometype *item;
+ * size_t nr;
+ * size_t alloc
+ *
+ * for (i = 0; i < nr; i++)
+ * if (we like item[i] already)
+ * return;
+ *
+ * // we did not like any existing one, so add one
+ * ALLOC_GROW(item, nr + 1, alloc);
+ * item[nr++] = value you like;
+ * ------------
+ *
+ * You are responsible for updating the `nr` variable.
+ *
+ * If you need to specify the number of elements to allocate explicitly
+ * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
+ *
+ * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
+ * added niceties.
+ *
+ * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
+ */
+#define ALLOC_GROW(x, nr, alloc) \
+ do { \
+ if ((nr) > alloc) { \
+ if (alloc_nr(alloc) < (nr)) \
+ alloc = (nr); \
+ else \
+ alloc = alloc_nr(alloc); \
+ REALLOC_ARRAY(x, alloc); \
+ } \
+ } while (0)
+
+/*
+ * Similar to ALLOC_GROW but handles updating of the nr value and
+ * zeroing the bytes of the newly-grown array elements.
+ *
+ * DO NOT USE any expression with side-effect for any of the
+ * arguments.
+ */
+#define ALLOC_GROW_BY(x, nr, increase, alloc) \
+ do { \
+ if (increase) { \
+ size_t new_nr = nr + (increase); \
+ if (new_nr < nr) \
+ BUG("negative growth in ALLOC_GROW_BY"); \
+ ALLOC_GROW(x, new_nr, alloc); \
+ memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
+ nr = new_nr; \
+ } \
+ } while (0)
+
static inline char *xstrdup_or_null(const char *str)
{
return str ? xstrdup(str) : NULL;
diff --git a/help.c b/help.c
index 389382b148..6d2ebfbd2a 100644
--- a/help.c
+++ b/help.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "builtin.h"
#include "exec-cmd.h"
diff --git a/http-backend.c b/http-backend.c
index 25a19c21b9..e24399ed10 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "git-zlib.h"
diff --git a/line-log.c b/line-log.c
index 2eff914bf3..790ab73212 100644
--- a/line-log.c
+++ b/line-log.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "line-range.h"
#include "hex.h"
#include "tag.h"
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index 2a3b7881af..8a08b7af49 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "commit.h"
#include "config.h"
#include "gettext.h"
diff --git a/list-objects-filter.c b/list-objects-filter.c
index e075a66c99..9327ccd505 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "dir.h"
#include "gettext.h"
#include "hex.h"
diff --git a/midx.c b/midx.c
index db459e448b..3a16acabbc 100644
--- a/midx.c
+++ b/midx.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "csum-file.h"
#include "dir.h"
diff --git a/object-file.c b/object-file.c
index 527b740018..5ebe1b00c5 100644
--- a/object-file.c
+++ b/object-file.c
@@ -8,7 +8,6 @@
*/
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "convert.h"
#include "environment.h"
diff --git a/oid-array.c b/oid-array.c
index e8228c777b..8e4717746c 100644
--- a/oid-array.c
+++ b/oid-array.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "oid-array.h"
#include "hash-lookup.h"
diff --git a/oidtree.c b/oidtree.c
index 7d57b7b19e..daef175dc7 100644
--- a/oidtree.c
+++ b/oidtree.c
@@ -4,7 +4,6 @@
*/
#include "git-compat-util.h"
#include "oidtree.h"
-#include "alloc.h"
#include "hash.h"
struct oidtree_iter_data {
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index d86f4e739a..f6757c3cbf 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 7367f62bb6..01fbc0a657 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "commit.h"
#include "gettext.h"
#include "hex.h"
diff --git a/pack-objects.c b/pack-objects.c
index ccab09fe65..1b8052bece 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "object.h"
#include "pack.h"
#include "pack-objects.h"
diff --git a/packfile.c b/packfile.c
index 9126274b37..030b7ec7a8 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 8637723461..b5a714c711 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "entry.h"
#include "gettext.h"
diff --git a/pretty.c b/pretty.c
index 7862be105d..4df716686f 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "commit.h"
#include "environment.h"
diff --git a/prio-queue.c b/prio-queue.c
index dc2476be53..450775a374 100644
--- a/prio-queue.c
+++ b/prio-queue.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "prio-queue.h"
static inline int compare(struct prio_queue *queue, int i, int j)
diff --git a/quote.c b/quote.c
index 43c739671e..3c05194496 100644
--- a/quote.c
+++ b/quote.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "path.h"
#include "quote.h"
#include "strbuf.h"
diff --git a/read-cache.c b/read-cache.c
index 140b4f96a0..53d71134e2 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -4,7 +4,6 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "git-compat-util.h"
-#include "alloc.h"
#include "bulk-checkin.h"
#include "config.h"
#include "date.h"
diff --git a/ref-filter.c b/ref-filter.c
index e0d03a9f8e..2ed0ecf260 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "environment.h"
#include "gettext.h"
#include "gpg-interface.h"
diff --git a/reflog-walk.c b/reflog-walk.c
index d337e64431..d216f6f966 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "commit.h"
#include "refs.h"
#include "diff.h"
diff --git a/refs.c b/refs.c
index d5e0184ca5..c1b3d1f13f 100644
--- a/refs.c
+++ b/refs.c
@@ -4,7 +4,6 @@
#include "git-compat-util.h"
#include "advice.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "hashmap.h"
diff --git a/refspec.c b/refspec.c
index 57f6c2aaf9..d60932f4de 100644
--- a/refspec.c
+++ b/refspec.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "gettext.h"
#include "hash.h"
#include "hex.h"
diff --git a/remote-curl.c b/remote-curl.c
index acf7b2bb40..8a976a0253 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
diff --git a/remote.c b/remote.c
index 6e13993bdc..55e7d22a00 100644
--- a/remote.c
+++ b/remote.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
diff --git a/rerere.c b/rerere.c
index 4227c9612a..7070f75014 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "config.h"
#include "copy.h"
#include "gettext.h"
diff --git a/revision.c b/revision.c
index d66857ecc0..0976d41404 100644
--- a/revision.c
+++ b/revision.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
diff --git a/sequencer.c b/sequencer.c
index 993dd8efbc..cc9821ece2 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1,7 +1,6 @@
#include "git-compat-util.h"
#include "abspath.h"
#include "advice.h"
-#include "alloc.h"
#include "config.h"
#include "copy.h"
#include "environment.h"
diff --git a/server-info.c b/server-info.c
index f350713ecf..e2fe0f9143 100644
--- a/server-info.c
+++ b/server-info.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "dir.h"
#include "environment.h"
#include "hex.h"
diff --git a/shallow.c b/shallow.c
index 2fad3504b7..5413719fd4 100644
--- a/shallow.c
+++ b/shallow.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "hex.h"
#include "repository.h"
#include "tempfile.h"
diff --git a/sigchain.c b/sigchain.c
index ee778c0580..66123bdbab 100644
--- a/sigchain.c
+++ b/sigchain.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "sigchain.h"
#define SIGCHAIN_MAX_SIGNALS 32
diff --git a/sparse-index.c b/sparse-index.c
index 90d0462256..1fdb07a9e6 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "environment.h"
#include "gettext.h"
#include "name-hash.h"
diff --git a/split-index.c b/split-index.c
index 0ee3865a55..8c38687c04 100644
--- a/split-index.c
+++ b/split-index.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "gettext.h"
#include "hash.h"
#include "mem-pool.h"
diff --git a/strbuf.c b/strbuf.c
index ab8e52e9b4..f65d7bee4c 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "gettext.h"
#include "hex.h"
#include "strbuf.h"
diff --git a/string-list.c b/string-list.c
index 0f8ac117fd..954569f381 100644
--- a/string-list.c
+++ b/string-list.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "string-list.h"
-#include "alloc.h"
void string_list_init_nodup(struct string_list *list)
{
diff --git a/strvec.c b/strvec.c
index 17d54b6c3b..89dc9e7e75 100644
--- a/strvec.c
+++ b/strvec.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "strvec.h"
-#include "alloc.h"
#include "hex.h"
#include "strbuf.h"
diff --git a/submodule-config.c b/submodule-config.c
index b6908e295f..6a48fd12f6 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
diff --git a/submodule.c b/submodule.c
index f0f8788d2e..e603a19a87 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "repository.h"
#include "config.h"
#include "submodule-config.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 5b6f217441..119f4908cf 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -1,5 +1,4 @@
#include "test-tool.h"
-#include "alloc.h"
#include "commit.h"
#include "commit-reach.h"
#include "config.h"
diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c
index 9f46ae12f5..601c9e5036 100644
--- a/trace2/tr2_tls.c
+++ b/trace2/tr2_tls.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "thread-utils.h"
#include "trace.h"
#include "trace2/tr2_tls.h"
diff --git a/trailer.c b/trailer.c
index 06dc0b7f68..f408f9b058 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
diff --git a/transport.c b/transport.c
index 0a5794a944..219af8fd50 100644
--- a/transport.c
+++ b/transport.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "advice.h"
-#include "alloc.h"
#include "config.h"
#include "environment.h"
#include "hex.h"
diff --git a/tree-walk.c b/tree-walk.c
index 42ed86ef58..6c07913f3f 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "tree-walk.h"
-#include "alloc.h"
#include "dir.h"
#include "gettext.h"
#include "hex.h"
diff --git a/userdiff.c b/userdiff.c
index 664c7c1402..e399543823 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -1,5 +1,4 @@
#include "git-compat-util.h"
-#include "alloc.h"
#include "config.h"
#include "userdiff.h"
#include "attr.h"
diff --git a/worktree.c b/worktree.c
index 2ea5d45e1e..b8cf29e6a1 100644
--- a/worktree.c
+++ b/worktree.c
@@ -1,6 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
-#include "alloc.h"
#include "environment.h"
#include "gettext.h"
#include "path.h"
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply related
* [PATCH v4 5/6] treewide: remove unnecessary includes for wrapper.h
From: Calvin Wan @ 2023-06-30 20:23 UTC (permalink / raw)
To: git; +Cc: Calvin Wan, phillip.wood123, jonathantanmy
In-Reply-To: <20230630202237.3069327-1-calvinwan@google.com>
Signed-off-by: Calvin Wan <calvinwan@google.com>
---
apply.c | 1 -
builtin/am.c | 1 -
builtin/bisect.c | 1 -
builtin/branch.c | 1 -
builtin/bugreport.c | 1 -
builtin/clone.c | 1 -
builtin/config.c | 1 -
builtin/credential-cache.c | 1 -
builtin/difftool.c | 1 -
builtin/fast-import.c | 1 -
builtin/fmt-merge-msg.c | 1 -
builtin/gc.c | 1 -
builtin/get-tar-commit-id.c | 1 -
builtin/index-pack.c | 1 -
builtin/init-db.c | 1 -
builtin/merge.c | 1 -
builtin/pack-objects.c | 1 -
builtin/rebase.c | 1 -
builtin/receive-pack.c | 1 -
builtin/rerere.c | 1 -
builtin/unpack-file.c | 1 -
builtin/worktree.c | 1 -
bulk-checkin.c | 1 -
combine-diff.c | 1 -
commit-graph.c | 1 -
compat/terminal.c | 1 -
config.c | 1 -
convert.c | 1 -
copy.c | 1 -
csum-file.c | 1 -
daemon.c | 1 -
diff.c | 1 -
dir.c | 1 -
editor.c | 1 -
entry.c | 1 -
environment.c | 1 -
fetch-pack.c | 1 -
gpg-interface.c | 1 -
grep.c | 1 -
http-backend.c | 1 -
imap-send.c | 1 -
merge-ll.c | 1 -
merge-recursive.c | 1 -
notes-merge.c | 1 -
object-file.c | 1 -
pack-write.c | 1 -
packfile.c | 1 -
parallel-checkout.c | 1 -
path.c | 1 -
pkt-line.c | 1 -
read-cache.c | 1 -
rebase-interactive.c | 1 -
refs.c | 1 -
rerere.c | 1 -
send-pack.c | 1 -
sequencer.c | 1 -
server-info.c | 1 -
setup.c | 1 -
shallow.c | 1 -
strbuf.c | 1 -
streaming.c | 1 -
t/helper/test-delta.c | 1 -
t/helper/test-fsmonitor-client.c | 1 -
t/helper/test-read-cache.c | 1 -
tag.c | 1 -
tempfile.c | 1 -
trace.c | 1 -
transport-helper.c | 1 -
transport.c | 1 -
upload-pack.c | 1 -
usage.c | 1 -
worktree.c | 1 -
wrapper.c | 1 -
write-or-die.c | 1 -
74 files changed, 74 deletions(-)
diff --git a/apply.c b/apply.c
index 45dcd645e6..dde124066b 100644
--- a/apply.c
+++ b/apply.c
@@ -37,7 +37,6 @@
#include "symlinks.h"
#include "wildmatch.h"
#include "ws.h"
-#include "wrapper.h"
struct gitdiff_data {
struct strbuf *root;
diff --git a/builtin/am.c b/builtin/am.c
index 5fab159599..dcb89439b1 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -44,7 +44,6 @@
#include "path.h"
#include "repository.h"
#include "pretty.h"
-#include "wrapper.h"
/**
* Returns the length of the first line of msg.
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 6478df3489..65478ef40f 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -15,7 +15,6 @@
#include "prompt.h"
#include "quote.h"
#include "revision.h"
-#include "wrapper.h"
static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
diff --git a/builtin/branch.c b/builtin/branch.c
index e8ff3ecc07..a27bc0a3df 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -28,7 +28,6 @@
#include "worktree.h"
#include "help.h"
#include "commit-reach.h"
-#include "wrapper.h"
static const char * const builtin_branch_usage[] = {
N_("git branch [<options>] [-r | -a] [--merged] [--no-merged]"),
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index daf6c23657..d2ae5c305d 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -11,7 +11,6 @@
#include "diagnose.h"
#include "object-file.h"
#include "setup.h"
-#include "wrapper.h"
static void get_system_info(struct strbuf *sys_info)
{
diff --git a/builtin/clone.c b/builtin/clone.c
index da35f1a6b4..c65378b3d2 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -45,7 +45,6 @@
#include "hook.h"
#include "bundle.h"
#include "bundle-uri.h"
-#include "wrapper.h"
/*
* Overall FIXMEs:
diff --git a/builtin/config.c b/builtin/config.c
index 1c75cbc43d..787d85edac 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -15,7 +15,6 @@
#include "setup.h"
#include "strbuf.h"
#include "worktree.h"
-#include "wrapper.h"
static const char *const builtin_config_usage[] = {
N_("git config [<options>]"),
diff --git a/builtin/credential-cache.c b/builtin/credential-cache.c
index ff3a47badb..43b9d0e5b1 100644
--- a/builtin/credential-cache.c
+++ b/builtin/credential-cache.c
@@ -3,7 +3,6 @@
#include "parse-options.h"
#include "path.h"
#include "strbuf.h"
-#include "wrapper.h"
#include "write-or-die.h"
#ifndef NO_UNIX_SOCKETS
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 24d88f88ba..0f5eae9cd4 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -32,7 +32,6 @@
#include "dir.h"
#include "entry.h"
#include "setup.h"
-#include "wrapper.h"
static int trust_exit_code;
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 2ee19c7373..4dbb10aff3 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -26,7 +26,6 @@
#include "commit-reach.h"
#include "khash.h"
#include "date.h"
-#include "wrapper.h"
#define PACK_ID_BITS 16
#define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index cc81241642..0f9855b680 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -3,7 +3,6 @@
#include "fmt-merge-msg.h"
#include "gettext.h"
#include "parse-options.h"
-#include "wrapper.h"
static const char * const fmt_merge_msg_usage[] = {
N_("git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]"),
diff --git a/builtin/gc.c b/builtin/gc.c
index 91eec7703a..19d73067aa 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -41,7 +41,6 @@
#include "hook.h"
#include "setup.h"
#include "trace2.h"
-#include "wrapper.h"
#define FAILED_RUN "failed to run %s"
diff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c
index 9303e386cc..20d0dfe9cf 100644
--- a/builtin/get-tar-commit-id.c
+++ b/builtin/get-tar-commit-id.c
@@ -5,7 +5,6 @@
#include "commit.h"
#include "tar.h"
#include "quote.h"
-#include "wrapper.h"
static const char builtin_get_tar_commit_id_usage[] =
"git get-tar-commit-id";
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index e280180cac..66202b304d 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -25,7 +25,6 @@
#include "replace-object.h"
#include "promisor-remote.h"
#include "setup.h"
-#include "wrapper.h"
static const char index_pack_usage[] =
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 0d8bd4d721..cb727c826f 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -13,7 +13,6 @@
#include "path.h"
#include "setup.h"
#include "strbuf.h"
-#include "wrapper.h"
static int guess_repository_type(const char *git_dir)
{
diff --git a/builtin/merge.c b/builtin/merge.c
index 06cf6afdcb..404700a35c 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -53,7 +53,6 @@
#include "commit-reach.h"
#include "wt-status.h"
#include "commit-graph.h"
-#include "wrapper.h"
#define DEFAULT_TWOHEAD (1<<0)
#define DEFAULT_OCTOPUS (1<<1)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 8e77638145..8251961042 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -43,7 +43,6 @@
#include "promisor-remote.h"
#include "pack-mtimes.h"
#include "parse-options.h"
-#include "wrapper.h"
/*
* Objects we are going to pack are collected in the `to_pack` structure.
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 1b3f68d9b0..50cb85751f 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -37,7 +37,6 @@
#include "reset.h"
#include "trace2.h"
#include "hook.h"
-#include "wrapper.h"
static char const * const builtin_rebase_usage[] = {
N_("git rebase [-i] [options] [--exec <cmd>] "
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index faa8f84c5a..a7fe8c4d9a 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -40,7 +40,6 @@
#include "worktree.h"
#include "shallow.h"
#include "parse-options.h"
-#include "wrapper.h"
static const char * const receive_pack_usage[] = {
N_("git receive-pack <git-dir>"),
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 0458db9cad..07a9d37275 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -6,7 +6,6 @@
#include "repository.h"
#include "string-list.h"
#include "rerere.h"
-#include "wrapper.h"
#include "xdiff/xdiff.h"
#include "xdiff-interface.h"
#include "pathspec.h"
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 6842a6c499..c129e2bb6c 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -3,7 +3,6 @@
#include "hex.h"
#include "object-name.h"
#include "object-store-ll.h"
-#include "wrapper.h"
static char *create_temp_file(struct object_id *oid)
{
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 7c114d56a3..2ce39b593c 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -24,7 +24,6 @@
#include "submodule.h"
#include "utf8.h"
#include "worktree.h"
-#include "wrapper.h"
#include "quote.h"
#define BUILTIN_WORKTREE_ADD_USAGE \
diff --git a/bulk-checkin.c b/bulk-checkin.c
index e2f71db0f6..fec6816259 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -17,7 +17,6 @@
#include "packfile.h"
#include "object-file.h"
#include "object-store-ll.h"
-#include "wrapper.h"
static int odb_transaction_nesting;
diff --git a/combine-diff.c b/combine-diff.c
index 11e9d7494a..f90f442482 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -17,7 +17,6 @@
#include "userdiff.h"
#include "oid-array.h"
#include "revision.h"
-#include "wrapper.h"
static int compare_paths(const struct combine_diff_path *one,
const struct diff_filespec *two)
diff --git a/commit-graph.c b/commit-graph.c
index f70afccada..38185c8529 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -26,7 +26,6 @@
#include "trace2.h"
#include "tree.h"
#include "chunk-format.h"
-#include "wrapper.h"
void git_test_write_commit_graph_or_die(void)
{
diff --git a/compat/terminal.c b/compat/terminal.c
index d87e321189..83d95e8656 100644
--- a/compat/terminal.c
+++ b/compat/terminal.c
@@ -6,7 +6,6 @@
#include "run-command.h"
#include "string-list.h"
#include "hashmap.h"
-#include "wrapper.h"
#if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE)
diff --git a/config.c b/config.c
index 85c5f35132..59fad84eb7 100644
--- a/config.c
+++ b/config.c
@@ -39,7 +39,6 @@
#include "wildmatch.h"
#include "worktree.h"
#include "ws.h"
-#include "wrapper.h"
#include "write-or-die.h"
struct config_source {
diff --git a/convert.c b/convert.c
index cb64117cc0..a8870baff3 100644
--- a/convert.c
+++ b/convert.c
@@ -16,7 +16,6 @@
#include "trace.h"
#include "utf8.h"
#include "merge-ll.h"
-#include "wrapper.h"
/*
* convert.c - convert a file when checking it out and checking it in.
diff --git a/copy.c b/copy.c
index 882c79cffb..23d84c6c1d 100644
--- a/copy.c
+++ b/copy.c
@@ -1,7 +1,6 @@
#include "git-compat-util.h"
#include "copy.h"
#include "path.h"
-#include "wrapper.h"
int copy_fd(int ifd, int ofd)
{
diff --git a/csum-file.c b/csum-file.c
index daf9b06dff..cd01713244 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -11,7 +11,6 @@
#include "progress.h"
#include "csum-file.h"
#include "hash.h"
-#include "wrapper.h"
static void verify_buffer_or_die(struct hashfile *f,
const void *buf,
diff --git a/daemon.c b/daemon.c
index 3682bfdd08..a7fe89cd2d 100644
--- a/daemon.c
+++ b/daemon.c
@@ -10,7 +10,6 @@
#include "setup.h"
#include "strbuf.h"
#include "string-list.h"
-#include "wrapper.h"
#ifdef NO_INITGROUPS
#define initgroups(x, y) (0) /* nothing */
diff --git a/diff.c b/diff.c
index f265afa6c4..9e4d87a8db 100644
--- a/diff.c
+++ b/diff.c
@@ -43,7 +43,6 @@
#include "setup.h"
#include "strmap.h"
#include "ws.h"
-#include "wrapper.h"
#ifdef NO_FAST_WORKING_DIRECTORY
#define FAST_WORKING_DIRECTORY 0
diff --git a/dir.c b/dir.c
index 3acac7beb1..d270a1be36 100644
--- a/dir.c
+++ b/dir.c
@@ -32,7 +32,6 @@
#include "symlinks.h"
#include "trace2.h"
#include "tree.h"
-#include "wrapper.h"
/*
* Tells read_directory_recursive how a file or directory should be treated.
diff --git a/editor.c b/editor.c
index 38c5dbbb79..b67b802ddf 100644
--- a/editor.c
+++ b/editor.c
@@ -11,7 +11,6 @@
#include "strvec.h"
#include "run-command.h"
#include "sigchain.h"
-#include "wrapper.h"
#ifndef DEFAULT_EDITOR
#define DEFAULT_EDITOR "vi"
diff --git a/entry.c b/entry.c
index f9a7c726a4..43767f9043 100644
--- a/entry.c
+++ b/entry.c
@@ -14,7 +14,6 @@
#include "fsmonitor.h"
#include "entry.h"
#include "parallel-checkout.h"
-#include "wrapper.h"
static void create_directories(const char *path, int path_len,
const struct checkout *state)
diff --git a/environment.c b/environment.c
index 8128104373..a0d1d070d1 100644
--- a/environment.c
+++ b/environment.c
@@ -28,7 +28,6 @@
#include "setup.h"
#include "shallow.h"
#include "trace.h"
-#include "wrapper.h"
#include "write-or-die.h"
int trust_executable_bit = 1;
diff --git a/fetch-pack.c b/fetch-pack.c
index 1e0313a0a6..bb288d47f3 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -34,7 +34,6 @@
#include "commit-graph.h"
#include "sigchain.h"
#include "mergesort.h"
-#include "wrapper.h"
static int transfer_unpack_limit = -1;
static int fetch_unpack_limit = -1;
diff --git a/gpg-interface.c b/gpg-interface.c
index f7c1d385c1..48f43c5a21 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -12,7 +12,6 @@
#include "sigchain.h"
#include "tempfile.h"
#include "alias.h"
-#include "wrapper.h"
#include "environment.h"
static int git_gpg_config(const char *, const char *,
diff --git a/grep.c b/grep.c
index ea38687c8a..0904d55b24 100644
--- a/grep.c
+++ b/grep.c
@@ -12,7 +12,6 @@
#include "commit.h"
#include "quote.h"
#include "help.h"
-#include "wrapper.h"
static int grep_source_load(struct grep_source *gs);
static int grep_source_is_binary(struct grep_source *gs,
diff --git a/http-backend.c b/http-backend.c
index e1969c05dc..25a19c21b9 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -19,7 +19,6 @@
#include "object-store-ll.h"
#include "protocol.h"
#include "date.h"
-#include "wrapper.h"
#include "write-or-die.h"
static const char content_type[] = "Content-Type";
diff --git a/imap-send.c b/imap-send.c
index 3518a4ace6..23c807fced 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -30,7 +30,6 @@
#include "parse-options.h"
#include "setup.h"
#include "strbuf.h"
-#include "wrapper.h"
#if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
typedef void *SSL;
#endif
diff --git a/merge-ll.c b/merge-ll.c
index 95795b70f5..8fcf2d3710 100644
--- a/merge-ll.c
+++ b/merge-ll.c
@@ -13,7 +13,6 @@
#include "merge-ll.h"
#include "quote.h"
#include "strbuf.h"
-#include "wrapper.h"
struct ll_merge_driver;
diff --git a/merge-recursive.c b/merge-recursive.c
index 43f6b2d036..6a4081bb0f 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -38,7 +38,6 @@
#include "tag.h"
#include "tree-walk.h"
#include "unpack-trees.h"
-#include "wrapper.h"
#include "xdiff-interface.h"
struct merge_options_internal {
diff --git a/notes-merge.c b/notes-merge.c
index 071947894e..8799b522a5 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -20,7 +20,6 @@
#include "trace.h"
#include "notes-utils.h"
#include "commit-reach.h"
-#include "wrapper.h"
struct notes_merge_pair {
struct object_id obj, base, local, remote;
diff --git a/object-file.c b/object-file.c
index 8d87720dd5..527b740018 100644
--- a/object-file.c
+++ b/object-file.c
@@ -44,7 +44,6 @@
#include "setup.h"
#include "submodule.h"
#include "fsck.h"
-#include "wrapper.h"
/* The maximum size for an object header. */
#define MAX_HEADER_LEN 32
diff --git a/pack-write.c b/pack-write.c
index af48813a9b..b19ddf15b2 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -12,7 +12,6 @@
#include "pack-revindex.h"
#include "path.h"
#include "strbuf.h"
-#include "wrapper.h"
void reset_pack_idx_option(struct pack_idx_option *opts)
{
diff --git a/packfile.c b/packfile.c
index c2e753ef8f..9126274b37 100644
--- a/packfile.c
+++ b/packfile.c
@@ -24,7 +24,6 @@
#include "commit-graph.h"
#include "pack-revindex.h"
#include "promisor-remote.h"
-#include "wrapper.h"
char *odb_pack_name(struct strbuf *buf,
const unsigned char *hash,
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 602fbf19d3..8637723461 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -15,7 +15,6 @@
#include "symlinks.h"
#include "thread-utils.h"
#include "trace2.h"
-#include "wrapper.h"
struct pc_worker {
struct child_process cp;
diff --git a/path.c b/path.c
index 044a50bad0..67e2690efe 100644
--- a/path.c
+++ b/path.c
@@ -18,7 +18,6 @@
#include "object-store-ll.h"
#include "lockfile.h"
#include "exec-cmd.h"
-#include "wrapper.h"
static int get_st_mode_bits(const char *path, int *mode)
{
diff --git a/pkt-line.c b/pkt-line.c
index 62b4208b66..6e4166132d 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -5,7 +5,6 @@
#include "hex.h"
#include "run-command.h"
#include "trace.h"
-#include "wrapper.h"
#include "write-or-die.h"
char packet_buffer[LARGE_PACKET_MAX];
diff --git a/read-cache.c b/read-cache.c
index b9a995e5a1..140b4f96a0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -46,7 +46,6 @@
#include "csum-file.h"
#include "promisor-remote.h"
#include "hook.h"
-#include "wrapper.h"
/* Mask for the name length in ce_flags in the on-disk index */
diff --git a/rebase-interactive.c b/rebase-interactive.c
index f286404d4b..d9718409b3 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -11,7 +11,6 @@
#include "config.h"
#include "dir.h"
#include "object-name.h"
-#include "wrapper.h"
static const char edit_todo_list_advice[] =
N_("You can fix this with 'git rebase --edit-todo' "
diff --git a/refs.c b/refs.c
index c029f64982..d5e0184ca5 100644
--- a/refs.c
+++ b/refs.c
@@ -30,7 +30,6 @@
#include "date.h"
#include "commit.h"
#include "wildmatch.h"
-#include "wrapper.h"
/*
* List of all available backends
diff --git a/rerere.c b/rerere.c
index e2b8597f88..4227c9612a 100644
--- a/rerere.c
+++ b/rerere.c
@@ -20,7 +20,6 @@
#include "object-store-ll.h"
#include "hash-lookup.h"
#include "strmap.h"
-#include "wrapper.h"
#define RESOLVED 0
#define PUNTED 1
diff --git a/send-pack.c b/send-pack.c
index 9510bef856..89aca9d829 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -15,7 +15,6 @@
#include "quote.h"
#include "transport.h"
#include "version.h"
-#include "wrapper.h"
#include "oid-array.h"
#include "gpg-interface.h"
#include "shallow.h"
diff --git a/sequencer.c b/sequencer.c
index 7e6c556e0a..993dd8efbc 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -49,7 +49,6 @@
#include "rebase-interactive.h"
#include "reset.h"
#include "branch.h"
-#include "wrapper.h"
#define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
diff --git a/server-info.c b/server-info.c
index 382e481a2b..f350713ecf 100644
--- a/server-info.c
+++ b/server-info.c
@@ -14,7 +14,6 @@
#include "object-store-ll.h"
#include "server-info.h"
#include "strbuf.h"
-#include "wrapper.h"
struct update_info_ctx {
FILE *cur_fp;
diff --git a/setup.c b/setup.c
index 8e4b2cd2c3..18927a847b 100644
--- a/setup.c
+++ b/setup.c
@@ -17,7 +17,6 @@
#include "quote.h"
#include "trace2.h"
#include "worktree.h"
-#include "wrapper.h"
static int inside_git_dir = -1;
static int inside_work_tree = -1;
diff --git a/shallow.c b/shallow.c
index f3ef94d4c9..2fad3504b7 100644
--- a/shallow.c
+++ b/shallow.c
@@ -20,7 +20,6 @@
#include "shallow.h"
#include "statinfo.h"
#include "trace.h"
-#include "wrapper.h"
void set_alternate_shallow_file(struct repository *r, const char *path, int override)
{
diff --git a/strbuf.c b/strbuf.c
index b41d343ed0..ab8e52e9b4 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -6,7 +6,6 @@
#include "string-list.h"
#include "utf8.h"
#include "date.h"
-#include "wrapper.h"
int starts_with(const char *str, const char *prefix)
{
diff --git a/streaming.c b/streaming.c
index 49791ab958..10adf625b2 100644
--- a/streaming.c
+++ b/streaming.c
@@ -10,7 +10,6 @@
#include "object-store-ll.h"
#include "replace-object.h"
#include "packfile.h"
-#include "wrapper.h"
typedef int (*open_istream_fn)(struct git_istream *,
struct repository *,
diff --git a/t/helper/test-delta.c b/t/helper/test-delta.c
index e7d134ec25..6bc787a474 100644
--- a/t/helper/test-delta.c
+++ b/t/helper/test-delta.c
@@ -11,7 +11,6 @@
#include "test-tool.h"
#include "git-compat-util.h"
#include "delta.h"
-#include "wrapper.h"
static const char usage_str[] =
"test-tool delta (-d|-p) <from_file> <data_file> <out_file>";
diff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c
index 58d1dc5fc8..8280984d08 100644
--- a/t/helper/test-fsmonitor-client.c
+++ b/t/helper/test-fsmonitor-client.c
@@ -11,7 +11,6 @@
#include "setup.h"
#include "thread-utils.h"
#include "trace2.h"
-#include "wrapper.h"
#ifndef HAVE_FSMONITOR_DAEMON_BACKEND
int cmd__fsmonitor_client(int argc UNUSED, const char **argv UNUSED)
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index 56c2d25f35..1acd362346 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -4,7 +4,6 @@
#include "read-cache-ll.h"
#include "repository.h"
#include "setup.h"
-#include "wrapper.h"
int cmd__read_cache(int argc, const char **argv)
{
diff --git a/tag.c b/tag.c
index c5426484b2..fc3834db46 100644
--- a/tag.c
+++ b/tag.c
@@ -10,7 +10,6 @@
#include "gpg-interface.h"
#include "hex.h"
#include "packfile.h"
-#include "wrapper.h"
const char *tag_type = "tag";
diff --git a/tempfile.c b/tempfile.c
index 6c88a63b42..ecdebf1afb 100644
--- a/tempfile.c
+++ b/tempfile.c
@@ -47,7 +47,6 @@
#include "path.h"
#include "tempfile.h"
#include "sigchain.h"
-#include "wrapper.h"
static VOLATILE_LIST_HEAD(tempfile_list);
diff --git a/trace.c b/trace.c
index 592c141d78..971a68abe8 100644
--- a/trace.c
+++ b/trace.c
@@ -27,7 +27,6 @@
#include "quote.h"
#include "setup.h"
#include "trace.h"
-#include "wrapper.h"
struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
struct trace_key trace_perf_key = TRACE_KEY_INIT(PERFORMANCE);
diff --git a/transport-helper.c b/transport-helper.c
index 5c0bc6a896..49811ef176 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -19,7 +19,6 @@
#include "refspec.h"
#include "transport-internal.h"
#include "protocol.h"
-#include "wrapper.h"
static int debug;
diff --git a/transport.c b/transport.c
index 4dc187a388..0a5794a944 100644
--- a/transport.c
+++ b/transport.c
@@ -30,7 +30,6 @@
#include "object-store-ll.h"
#include "color.h"
#include "bundle-uri.h"
-#include "wrapper.h"
static int transport_use_color = -1;
static char transport_colors[][COLOR_MAXLEN] = {
diff --git a/upload-pack.c b/upload-pack.c
index 946074920a..0970392b41 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -32,7 +32,6 @@
#include "commit-graph.h"
#include "commit-reach.h"
#include "shallow.h"
-#include "wrapper.h"
#include "write-or-die.h"
/* Remember to update object flag allocation in object.h */
diff --git a/usage.c b/usage.c
index 46d99f8bd4..09f0ed509b 100644
--- a/usage.c
+++ b/usage.c
@@ -6,7 +6,6 @@
#include "git-compat-util.h"
#include "gettext.h"
#include "trace2.h"
-#include "wrapper.h"
static void vreportf(const char *prefix, const char *err, va_list params)
{
diff --git a/worktree.c b/worktree.c
index 1b84e3a34d..2ea5d45e1e 100644
--- a/worktree.c
+++ b/worktree.c
@@ -12,7 +12,6 @@
#include "dir.h"
#include "wt-status.h"
#include "config.h"
-#include "wrapper.h"
void free_worktrees(struct worktree **worktrees)
{
diff --git a/wrapper.c b/wrapper.c
index 67f5f5dbe1..22be9812a7 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -9,7 +9,6 @@
#include "repository.h"
#include "strbuf.h"
#include "trace2.h"
-#include "wrapper.h"
static intmax_t count_fsync_writeout_only;
static intmax_t count_fsync_hardware_flush;
diff --git a/write-or-die.c b/write-or-die.c
index cc9e0787a1..d8355c0c3e 100644
--- a/write-or-die.c
+++ b/write-or-die.c
@@ -1,7 +1,6 @@
#include "git-compat-util.h"
#include "config.h"
#include "run-command.h"
-#include "wrapper.h"
#include "write-or-die.h"
/*
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply related
* [PATCH v4 4/6] kwset: move translation table from ctype
From: Calvin Wan @ 2023-06-30 20:23 UTC (permalink / raw)
To: git; +Cc: Calvin Wan, phillip.wood123, jonathantanmy
In-Reply-To: <20230630202237.3069327-1-calvinwan@google.com>
This table was originally introduced to solely be used with kwset
machinery (0f871cf56e), so it would make sense for it to belong in
kwset.[ch] rather than ctype.c and git-compat-util.h. It is only used in
diffcore-pickaxe.c, which already includes kwset.h so no other headers
have to be modified.
Signed-off-by: Calvin Wan <calvinwan@google.com>
---
ctype.c | 36 ------------------------------------
git-compat-util.h | 3 ---
kwset.c | 36 ++++++++++++++++++++++++++++++++++++
kwset.h | 2 ++
4 files changed, 38 insertions(+), 39 deletions(-)
diff --git a/ctype.c b/ctype.c
index fc0225cebd..3451745550 100644
--- a/ctype.c
+++ b/ctype.c
@@ -28,39 +28,3 @@ const unsigned char sane_ctype[256] = {
A, A, A, A, A, A, A, A, A, A, A, R, R, U, P, X, /* 112..127 */
/* Nothing in the 128.. range */
};
-
-/* For case-insensitive kwset */
-const unsigned char tolower_trans_tbl[256] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- ' ', '!', '"', '#', '$', '%', '&', 0x27,
- '(', ')', '*', '+', ',', '-', '.', '/',
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', ':', ';', '<', '=', '>', '?',
- '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
- 'x', 'y', 'z', '[', 0x5c, ']', '^', '_',
- '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
- 'x', 'y', 'z', '{', '|', '}', '~', 0x7f,
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
- 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
- 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
- 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
-};
diff --git a/git-compat-util.h b/git-compat-util.h
index 5f916e1094..1832444fa2 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1152,9 +1152,6 @@ static inline size_t xsize_t(off_t len)
#define HOST_NAME_MAX 256
#endif
-/* in ctype.c, for kwset users */
-extern const unsigned char tolower_trans_tbl[256];
-
#include "sane-ctype.h"
/*
diff --git a/kwset.c b/kwset.c
index 4b14d4f86b..bbfcf815a5 100644
--- a/kwset.c
+++ b/kwset.c
@@ -49,6 +49,42 @@ static void *obstack_chunk_alloc(long size)
#define U(c) ((unsigned char) (c))
+/* For case-insensitive kwset */
+const unsigned char tolower_trans_tbl[256] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ ' ', '!', '"', '#', '$', '%', '&', 0x27,
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', '[', 0x5c, ']', '^', '_',
+ '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', '{', '|', '}', '~', 0x7f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+};
+
/* Balanced tree of edges and labels leaving a given trie node. */
struct tree
{
diff --git a/kwset.h b/kwset.h
index f50ecae573..d42a793a30 100644
--- a/kwset.h
+++ b/kwset.h
@@ -26,6 +26,8 @@
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
+extern const unsigned char tolower_trans_tbl[256];
+
struct kwsmatch
{
int index; /* Index number of matching keyword. */
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply related
* [PATCH v4 3/6] sane-ctype.h: create header for sane-ctype macros
From: Calvin Wan @ 2023-06-30 20:23 UTC (permalink / raw)
To: git; +Cc: Calvin Wan, phillip.wood123, jonathantanmy
In-Reply-To: <20230630202237.3069327-1-calvinwan@google.com>
Splitting these macros from git-compat-util.h cleans up the file and
allows future third-party sources to not use these overrides if they do
not wish to.
Signed-off-by: Calvin Wan <calvinwan@google.com>
---
git-compat-util.h | 62 +-------------------------------------------
sane-ctype.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 61 deletions(-)
create mode 100644 sane-ctype.h
diff --git a/git-compat-util.h b/git-compat-util.h
index 9140f43bbf..5f916e1094 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1155,67 +1155,7 @@ static inline size_t xsize_t(off_t len)
/* in ctype.c, for kwset users */
extern const unsigned char tolower_trans_tbl[256];
-/* Sane ctype - no locale, and works with signed chars */
-#undef isascii
-#undef isspace
-#undef isdigit
-#undef isalpha
-#undef isalnum
-#undef isprint
-#undef islower
-#undef isupper
-#undef tolower
-#undef toupper
-#undef iscntrl
-#undef ispunct
-#undef isxdigit
-
-extern const unsigned char sane_ctype[256];
-extern const signed char hexval_table[256];
-#define GIT_SPACE 0x01
-#define GIT_DIGIT 0x02
-#define GIT_ALPHA 0x04
-#define GIT_GLOB_SPECIAL 0x08
-#define GIT_REGEX_SPECIAL 0x10
-#define GIT_PATHSPEC_MAGIC 0x20
-#define GIT_CNTRL 0x40
-#define GIT_PUNCT 0x80
-#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
-#define isascii(x) (((x) & ~0x7f) == 0)
-#define isspace(x) sane_istest(x,GIT_SPACE)
-#define isdigit(x) sane_istest(x,GIT_DIGIT)
-#define isalpha(x) sane_istest(x,GIT_ALPHA)
-#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
-#define isprint(x) ((x) >= 0x20 && (x) <= 0x7e)
-#define islower(x) sane_iscase(x, 1)
-#define isupper(x) sane_iscase(x, 0)
-#define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)
-#define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL)
-#define iscntrl(x) (sane_istest(x,GIT_CNTRL))
-#define ispunct(x) sane_istest(x, GIT_PUNCT | GIT_REGEX_SPECIAL | \
- GIT_GLOB_SPECIAL | GIT_PATHSPEC_MAGIC)
-#define isxdigit(x) (hexval_table[(unsigned char)(x)] != -1)
-#define tolower(x) sane_case((unsigned char)(x), 0x20)
-#define toupper(x) sane_case((unsigned char)(x), 0)
-#define is_pathspec_magic(x) sane_istest(x,GIT_PATHSPEC_MAGIC)
-
-static inline int sane_case(int x, int high)
-{
- if (sane_istest(x, GIT_ALPHA))
- x = (x & ~0x20) | high;
- return x;
-}
-
-static inline int sane_iscase(int x, int is_lower)
-{
- if (!sane_istest(x, GIT_ALPHA))
- return 0;
-
- if (is_lower)
- return (x & 0x20) != 0;
- else
- return (x & 0x20) == 0;
-}
+#include "sane-ctype.h"
/*
* Like skip_prefix, but compare case-insensitively. Note that the comparison
diff --git a/sane-ctype.h b/sane-ctype.h
new file mode 100644
index 0000000000..cbea1b299b
--- /dev/null
+++ b/sane-ctype.h
@@ -0,0 +1,66 @@
+#ifndef SANE_CTYPE_H
+#define SANE_CTYPE_H
+
+/* Sane ctype - no locale, and works with signed chars */
+#undef isascii
+#undef isspace
+#undef isdigit
+#undef isalpha
+#undef isalnum
+#undef isprint
+#undef islower
+#undef isupper
+#undef tolower
+#undef toupper
+#undef iscntrl
+#undef ispunct
+#undef isxdigit
+
+extern const unsigned char sane_ctype[256];
+extern const signed char hexval_table[256];
+#define GIT_SPACE 0x01
+#define GIT_DIGIT 0x02
+#define GIT_ALPHA 0x04
+#define GIT_GLOB_SPECIAL 0x08
+#define GIT_REGEX_SPECIAL 0x10
+#define GIT_PATHSPEC_MAGIC 0x20
+#define GIT_CNTRL 0x40
+#define GIT_PUNCT 0x80
+#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
+#define isascii(x) (((x) & ~0x7f) == 0)
+#define isspace(x) sane_istest(x,GIT_SPACE)
+#define isdigit(x) sane_istest(x,GIT_DIGIT)
+#define isalpha(x) sane_istest(x,GIT_ALPHA)
+#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
+#define isprint(x) ((x) >= 0x20 && (x) <= 0x7e)
+#define islower(x) sane_iscase(x, 1)
+#define isupper(x) sane_iscase(x, 0)
+#define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)
+#define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL)
+#define iscntrl(x) (sane_istest(x,GIT_CNTRL))
+#define ispunct(x) sane_istest(x, GIT_PUNCT | GIT_REGEX_SPECIAL | \
+ GIT_GLOB_SPECIAL | GIT_PATHSPEC_MAGIC)
+#define isxdigit(x) (hexval_table[(unsigned char)(x)] != -1)
+#define tolower(x) sane_case((unsigned char)(x), 0x20)
+#define toupper(x) sane_case((unsigned char)(x), 0)
+#define is_pathspec_magic(x) sane_istest(x,GIT_PATHSPEC_MAGIC)
+
+static inline int sane_case(int x, int high)
+{
+ if (sane_istest(x, GIT_ALPHA))
+ x = (x & ~0x20) | high;
+ return x;
+}
+
+static inline int sane_iscase(int x, int is_lower)
+{
+ if (!sane_istest(x, GIT_ALPHA))
+ return 0;
+
+ if (is_lower)
+ return (x & 0x20) != 0;
+ else
+ return (x & 0x20) == 0;
+}
+
+#endif
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply related
* [PATCH v4 2/6] git-compat-util: move wrapper.c funcs to its header
From: Calvin Wan @ 2023-06-30 20:23 UTC (permalink / raw)
To: git; +Cc: Calvin Wan, phillip.wood123, jonathantanmy
In-Reply-To: <20230630202237.3069327-1-calvinwan@google.com>
Since the functions in wrapper.c are widely used across the codebase,
include it by default in git-compat-util.h. A future patch will remove
now unnecessary inclusions of wrapper.h from other files.
Signed-off-by: Calvin Wan <calvinwan@google.com>
---
git-compat-util.h | 112 +---------------------------------------------
wrapper.h | 111 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+), 111 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 78a993c604..9140f43bbf 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -627,7 +627,7 @@ static inline int git_has_dir_sep(const char *path)
#include "compat/bswap.h"
-struct strbuf;
+#include "wrapper.h"
/* General helper functions */
NORETURN void usage(const char *err);
@@ -1047,36 +1047,6 @@ static inline int cast_size_t_to_int(size_t a)
# define xalloca(size) (xmalloc(size))
# define xalloca_free(p) (free(p))
#endif
-char *xstrdup(const char *str);
-void *xmalloc(size_t size);
-void *xmallocz(size_t size);
-void *xmallocz_gently(size_t size);
-void *xmemdupz(const void *data, size_t len);
-char *xstrndup(const char *str, size_t len);
-void *xrealloc(void *ptr, size_t size);
-void *xcalloc(size_t nmemb, size_t size);
-void xsetenv(const char *name, const char *value, int overwrite);
-void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
-const char *mmap_os_err(void);
-void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_t offset);
-int xopen(const char *path, int flags, ...);
-ssize_t xread(int fd, void *buf, size_t len);
-ssize_t xwrite(int fd, const void *buf, size_t len);
-ssize_t xpread(int fd, void *buf, size_t len, off_t offset);
-int xdup(int fd);
-FILE *xfopen(const char *path, const char *mode);
-FILE *xfdopen(int fd, const char *mode);
-int xmkstemp(char *temp_filename);
-int xmkstemp_mode(char *temp_filename, int mode);
-char *xgetcwd(void);
-FILE *fopen_for_writing(const char *path);
-FILE *fopen_or_warn(const char *path, const char *mode);
-
-/*
- * Like strncmp, but only return zero if s is NUL-terminated and exactly len
- * characters long. If it is not, consider it greater than t.
- */
-int xstrncmpz(const char *s, const char *t, size_t len);
/*
* FREE_AND_NULL(ptr) is like free(ptr) followed by ptr = NULL. Note
@@ -1178,15 +1148,10 @@ static inline size_t xsize_t(off_t len)
return (size_t) len;
}
-__attribute__((format (printf, 3, 4)))
-int xsnprintf(char *dst, size_t max, const char *fmt, ...);
-
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 256
#endif
-int xgethostname(char *buf, size_t len);
-
/* in ctype.c, for kwset users */
extern const unsigned char tolower_trans_tbl[256];
@@ -1427,72 +1392,6 @@ void bug_fl(const char *file, int line, const char *fmt, ...);
#endif
#endif
-enum fsync_action {
- FSYNC_WRITEOUT_ONLY,
- FSYNC_HARDWARE_FLUSH
-};
-
-/*
- * Issues an fsync against the specified file according to the specified mode.
- *
- * FSYNC_WRITEOUT_ONLY attempts to use interfaces available on some operating
- * systems to flush the OS cache without issuing a flush command to the storage
- * controller. If those interfaces are unavailable, the function fails with
- * ENOSYS.
- *
- * FSYNC_HARDWARE_FLUSH does an OS writeout and hardware flush to ensure that
- * changes are durable. It is not expected to fail.
- */
-int git_fsync(int fd, enum fsync_action action);
-
-/*
- * Writes out trace statistics for fsync using the trace2 API.
- */
-void trace_git_fsync_stats(void);
-
-/*
- * Preserves errno, prints a message, but gives no warning for ENOENT.
- * Returns 0 on success, which includes trying to unlink an object that does
- * not exist.
- */
-int unlink_or_warn(const char *path);
- /*
- * Tries to unlink file. Returns 0 if unlink succeeded
- * or the file already didn't exist. Returns -1 and
- * appends a message to err suitable for
- * 'error("%s", err->buf)' on error.
- */
-int unlink_or_msg(const char *file, struct strbuf *err);
-/*
- * Preserves errno, prints a message, but gives no warning for ENOENT.
- * Returns 0 on success, which includes trying to remove a directory that does
- * not exist.
- */
-int rmdir_or_warn(const char *path);
-/*
- * Calls the correct function out of {unlink,rmdir}_or_warn based on
- * the supplied file mode.
- */
-int remove_or_warn(unsigned int mode, const char *path);
-
-/*
- * Call access(2), but warn for any error except "missing file"
- * (ENOENT or ENOTDIR).
- */
-#define ACCESS_EACCES_OK (1U << 0)
-int access_or_warn(const char *path, int mode, unsigned flag);
-int access_or_die(const char *path, int mode, unsigned flag);
-
-/* Warn on an inaccessible file if errno indicates this is an error */
-int warn_on_fopen_errors(const char *path);
-
-/*
- * Open with O_NOFOLLOW, or equivalent. Note that the fallback equivalent
- * may be racy. Do not use this as protection against an attacker who can
- * simultaneously create paths.
- */
-int open_nofollow(const char *path, int flags);
-
#ifndef SHELL_PATH
# define SHELL_PATH "/bin/sh"
#endif
@@ -1632,13 +1531,4 @@ static inline void *container_of_or_null_offset(void *ptr, size_t offset)
((uintptr_t)&(ptr)->member - (uintptr_t)(ptr))
#endif /* !__GNUC__ */
-void sleep_millisec(int millisec);
-
-/*
- * Generate len bytes from the system cryptographically secure PRNG.
- * Returns 0 on success and -1 on error, setting errno. The inability to
- * satisfy the full request is an error.
- */
-int csprng_bytes(void *buf, size_t len);
-
#endif
diff --git a/wrapper.h b/wrapper.h
index f0c7d0616d..c85b1328d1 100644
--- a/wrapper.h
+++ b/wrapper.h
@@ -1,6 +1,42 @@
#ifndef WRAPPER_H
#define WRAPPER_H
+char *xstrdup(const char *str);
+void *xmalloc(size_t size);
+void *xmallocz(size_t size);
+void *xmallocz_gently(size_t size);
+void *xmemdupz(const void *data, size_t len);
+char *xstrndup(const char *str, size_t len);
+void *xrealloc(void *ptr, size_t size);
+void *xcalloc(size_t nmemb, size_t size);
+void xsetenv(const char *name, const char *value, int overwrite);
+void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
+const char *mmap_os_err(void);
+void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_t offset);
+int xopen(const char *path, int flags, ...);
+ssize_t xread(int fd, void *buf, size_t len);
+ssize_t xwrite(int fd, const void *buf, size_t len);
+ssize_t xpread(int fd, void *buf, size_t len, off_t offset);
+int xdup(int fd);
+FILE *xfopen(const char *path, const char *mode);
+FILE *xfdopen(int fd, const char *mode);
+int xmkstemp(char *temp_filename);
+int xmkstemp_mode(char *temp_filename, int mode);
+char *xgetcwd(void);
+FILE *fopen_for_writing(const char *path);
+FILE *fopen_or_warn(const char *path, const char *mode);
+
+/*
+ * Like strncmp, but only return zero if s is NUL-terminated and exactly len
+ * characters long. If it is not, consider it greater than t.
+ */
+int xstrncmpz(const char *s, const char *t, size_t len);
+
+__attribute__((format (printf, 3, 4)))
+int xsnprintf(char *dst, size_t max, const char *fmt, ...);
+
+int xgethostname(char *buf, size_t len);
+
/* set default permissions by passing mode arguments to open(2) */
int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
int git_mkstemp_mode(char *pattern, int mode);
@@ -33,4 +69,79 @@ void write_file(const char *path, const char *fmt, ...);
/* Return 1 if the file is empty or does not exists, 0 otherwise. */
int is_empty_or_missing_file(const char *filename);
+enum fsync_action {
+ FSYNC_WRITEOUT_ONLY,
+ FSYNC_HARDWARE_FLUSH
+};
+
+/*
+ * Issues an fsync against the specified file according to the specified mode.
+ *
+ * FSYNC_WRITEOUT_ONLY attempts to use interfaces available on some operating
+ * systems to flush the OS cache without issuing a flush command to the storage
+ * controller. If those interfaces are unavailable, the function fails with
+ * ENOSYS.
+ *
+ * FSYNC_HARDWARE_FLUSH does an OS writeout and hardware flush to ensure that
+ * changes are durable. It is not expected to fail.
+ */
+int git_fsync(int fd, enum fsync_action action);
+
+/*
+ * Writes out trace statistics for fsync using the trace2 API.
+ */
+void trace_git_fsync_stats(void);
+
+/*
+ * Preserves errno, prints a message, but gives no warning for ENOENT.
+ * Returns 0 on success, which includes trying to unlink an object that does
+ * not exist.
+ */
+int unlink_or_warn(const char *path);
+ /*
+ * Tries to unlink file. Returns 0 if unlink succeeded
+ * or the file already didn't exist. Returns -1 and
+ * appends a message to err suitable for
+ * 'error("%s", err->buf)' on error.
+ */
+int unlink_or_msg(const char *file, struct strbuf *err);
+/*
+ * Preserves errno, prints a message, but gives no warning for ENOENT.
+ * Returns 0 on success, which includes trying to remove a directory that does
+ * not exist.
+ */
+int rmdir_or_warn(const char *path);
+/*
+ * Calls the correct function out of {unlink,rmdir}_or_warn based on
+ * the supplied file mode.
+ */
+int remove_or_warn(unsigned int mode, const char *path);
+
+/*
+ * Call access(2), but warn for any error except "missing file"
+ * (ENOENT or ENOTDIR).
+ */
+#define ACCESS_EACCES_OK (1U << 0)
+int access_or_warn(const char *path, int mode, unsigned flag);
+int access_or_die(const char *path, int mode, unsigned flag);
+
+/* Warn on an inaccessible file if errno indicates this is an error */
+int warn_on_fopen_errors(const char *path);
+
+/*
+ * Open with O_NOFOLLOW, or equivalent. Note that the fallback equivalent
+ * may be racy. Do not use this as protection against an attacker who can
+ * simultaneously create paths.
+ */
+int open_nofollow(const char *path, int flags);
+
+void sleep_millisec(int millisec);
+
+/*
+ * Generate len bytes from the system cryptographically secure PRNG.
+ * Returns 0 on success and -1 on error, setting errno. The inability to
+ * satisfy the full request is an error.
+ */
+int csprng_bytes(void *buf, size_t len);
+
#endif /* WRAPPER_H */
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply related
* [PATCH v4 1/6] git-compat-util: move strbuf.c funcs to its header
From: Calvin Wan @ 2023-06-30 20:23 UTC (permalink / raw)
To: git; +Cc: Calvin Wan, phillip.wood123, jonathantanmy
In-Reply-To: <20230630202237.3069327-1-calvinwan@google.com>
While functions like starts_with() probably should not belong in the
boundaries of the strbuf library, this commit focuses on first splitting
out headers from git-compat-util.h.
Signed-off-by: Calvin Wan <calvinwan@google.com>
---
builtin/symbolic-ref.c | 1 +
builtin/unpack-objects.c | 1 +
git-compat-util.h | 32 --------------------------------
strbuf.h | 32 ++++++++++++++++++++++++++++++++
versioncmp.c | 1 +
5 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index a61fa3c0f8..c9defe4d2e 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -3,6 +3,7 @@
#include "gettext.h"
#include "refs.h"
#include "parse-options.h"
+#include "strbuf.h"
static const char * const git_symbolic_ref_usage[] = {
N_("git symbolic-ref [-m <reason>] <name> <ref>"),
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 1979532a9d..84b68304ed 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -12,6 +12,7 @@
#include "blob.h"
#include "commit.h"
#include "replace-object.h"
+#include "strbuf.h"
#include "tag.h"
#include "tree.h"
#include "tree-walk.h"
diff --git a/git-compat-util.h b/git-compat-util.h
index ae88291976..78a993c604 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -679,9 +679,6 @@ void set_warn_routine(report_fn routine);
report_fn get_warn_routine(void);
void set_die_is_recursing_routine(int (*routine)(void));
-int starts_with(const char *str, const char *prefix);
-int istarts_with(const char *str, const char *prefix);
-
/*
* If the string "str" begins with the string found in "prefix", return 1.
* The "out" parameter is set to "str + strlen(prefix)" (i.e., to the point in
@@ -710,29 +707,6 @@ static inline int skip_prefix(const char *str, const char *prefix,
return 0;
}
-/*
- * If the string "str" is the same as the string in "prefix", then the "arg"
- * parameter is set to the "def" parameter and 1 is returned.
- * If the string "str" begins with the string found in "prefix" and then a
- * "=" sign, then the "arg" parameter is set to "str + strlen(prefix) + 1"
- * (i.e., to the point in the string right after the prefix and the "=" sign),
- * and 1 is returned.
- *
- * Otherwise, return 0 and leave "arg" untouched.
- *
- * When we accept both a "--key" and a "--key=<val>" option, this function
- * can be used instead of !strcmp(arg, "--key") and then
- * skip_prefix(arg, "--key=", &arg) to parse such an option.
- */
-int skip_to_optional_arg_default(const char *str, const char *prefix,
- const char **arg, const char *def);
-
-static inline int skip_to_optional_arg(const char *str, const char *prefix,
- const char **arg)
-{
- return skip_to_optional_arg_default(str, prefix, arg, "");
-}
-
/*
* Like skip_prefix, but promises never to read past "len" bytes of the input
* buffer, and returns the remaining number of bytes in "out" via "outlen".
@@ -777,12 +751,6 @@ static inline int strip_suffix(const char *str, const char *suffix, size_t *len)
return strip_suffix_mem(str, len, suffix);
}
-static inline int ends_with(const char *str, const char *suffix)
-{
- size_t len;
- return strip_suffix(str, suffix, &len);
-}
-
#define SWAP(a, b) do { \
void *_swap_a_ptr = &(a); \
void *_swap_b_ptr = &(b); \
diff --git a/strbuf.h b/strbuf.h
index 0528ab5010..fd43c46433 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -671,4 +671,36 @@ char *xstrvfmt(const char *fmt, va_list ap);
__attribute__((format (printf, 1, 2)))
char *xstrfmt(const char *fmt, ...);
+int starts_with(const char *str, const char *prefix);
+int istarts_with(const char *str, const char *prefix);
+
+/*
+ * If the string "str" is the same as the string in "prefix", then the "arg"
+ * parameter is set to the "def" parameter and 1 is returned.
+ * If the string "str" begins with the string found in "prefix" and then a
+ * "=" sign, then the "arg" parameter is set to "str + strlen(prefix) + 1"
+ * (i.e., to the point in the string right after the prefix and the "=" sign),
+ * and 1 is returned.
+ *
+ * Otherwise, return 0 and leave "arg" untouched.
+ *
+ * When we accept both a "--key" and a "--key=<val>" option, this function
+ * can be used instead of !strcmp(arg, "--key") and then
+ * skip_prefix(arg, "--key=", &arg) to parse such an option.
+ */
+int skip_to_optional_arg_default(const char *str, const char *prefix,
+ const char **arg, const char *def);
+
+static inline int skip_to_optional_arg(const char *str, const char *prefix,
+ const char **arg)
+{
+ return skip_to_optional_arg_default(str, prefix, arg, "");
+}
+
+static inline int ends_with(const char *str, const char *suffix)
+{
+ size_t len;
+ return strip_suffix(str, suffix, &len);
+}
+
#endif /* STRBUF_H */
diff --git a/versioncmp.c b/versioncmp.c
index 74cc7c43f0..45e676cbca 100644
--- a/versioncmp.c
+++ b/versioncmp.c
@@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "config.h"
+#include "strbuf.h"
#include "string-list.h"
#include "versioncmp.h"
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply related
* [PATCH v4 0/6] git-compat-util cleanups
From: Calvin Wan @ 2023-06-30 20:22 UTC (permalink / raw)
To: git; +Cc: Calvin Wan, phillip.wood123, jonathantanmy
In-Reply-To: <20230606170711.912972-1-calvinwan@google.com>
Changes since v3:
- Dropped patches 5 and 6 since removing the circular dependency in
common.h turns out to be quite difficult
- Patch 8 moves the alloc macros to git-compat-util.h rather than
common.h since that does not exist anymore
Note for the maintainer:
I rebased this series onto both seen and next and they rebased cleanly.
As currently submitted, it is rebased onto next at (38632f3da).
Hopefully this series now doesn't cause any issues with other inflight
series.
Calvin Wan (6):
git-compat-util: move strbuf.c funcs to its header
git-compat-util: move wrapper.c funcs to its header
sane-ctype.h: create header for sane-ctype macros
kwset: move translation table from ctype
treewide: remove unnecessary includes for wrapper.h
common: move alloc macros to common.h
add-patch.c | 1 -
alias.c | 1 -
alloc.h | 75 --------
apply.c | 2 -
archive-tar.c | 1 -
archive.c | 1 -
attr.c | 1 -
builtin/am.c | 1 -
builtin/bisect.c | 1 -
builtin/blame.c | 1 -
builtin/branch.c | 1 -
builtin/bugreport.c | 1 -
builtin/cat-file.c | 1 -
builtin/checkout--worker.c | 1 -
builtin/clone.c | 1 -
builtin/config.c | 2 -
builtin/credential-cache--daemon.c | 1 -
builtin/credential-cache.c | 1 -
builtin/difftool.c | 1 -
builtin/fast-import.c | 1 -
builtin/fetch-pack.c | 1 -
builtin/fmt-merge-msg.c | 1 -
builtin/fsmonitor--daemon.c | 1 -
builtin/gc.c | 1 -
builtin/get-tar-commit-id.c | 1 -
builtin/grep.c | 1 -
builtin/index-pack.c | 2 -
builtin/init-db.c | 1 -
builtin/log.c | 1 -
builtin/merge.c | 2 -
builtin/mktree.c | 1 -
builtin/mv.c | 1 -
builtin/name-rev.c | 1 -
builtin/pack-objects.c | 2 -
builtin/rebase.c | 1 -
builtin/receive-pack.c | 1 -
builtin/repack.c | 1 -
builtin/rerere.c | 1 -
builtin/rev-parse.c | 1 -
builtin/revert.c | 1 -
builtin/rm.c | 1 -
builtin/submodule--helper.c | 1 -
builtin/symbolic-ref.c | 1 +
builtin/unpack-file.c | 1 -
builtin/unpack-objects.c | 1 +
builtin/worktree.c | 1 -
bulk-checkin.c | 2 -
cache-tree.c | 1 -
chunk-format.c | 1 -
combine-diff.c | 1 -
commit-graph.c | 1 -
commit-reach.c | 1 -
compat/terminal.c | 1 -
config.c | 2 -
convert.c | 1 -
copy.c | 1 -
csum-file.c | 1 -
ctype.c | 36 ----
daemon.c | 2 -
delta-islands.c | 1 -
diff.c | 2 -
diffcore-rename.c | 1 -
dir-iterator.c | 1 -
dir.c | 2 -
editor.c | 1 -
entry.c | 1 -
environment.c | 1 -
ewah/bitmap.c | 1 -
ewah/ewah_bitmap.c | 1 -
fetch-pack.c | 2 -
fmt-merge-msg.c | 1 -
fsck.c | 1 -
git-compat-util.h | 284 ++++++++---------------------
gpg-interface.c | 1 -
grep.c | 1 -
help.c | 1 -
http-backend.c | 2 -
imap-send.c | 1 -
kwset.c | 36 ++++
kwset.h | 2 +
line-log.c | 1 -
list-objects-filter-options.c | 1 -
list-objects-filter.c | 1 -
merge-ll.c | 1 -
merge-recursive.c | 1 -
midx.c | 1 -
notes-merge.c | 1 -
object-file.c | 2 -
oid-array.c | 1 -
oidtree.c | 1 -
pack-bitmap-write.c | 1 -
pack-bitmap.c | 1 -
pack-objects.c | 1 -
pack-write.c | 1 -
packfile.c | 2 -
parallel-checkout.c | 2 -
path.c | 1 -
pkt-line.c | 1 -
pretty.c | 1 -
prio-queue.c | 1 -
quote.c | 1 -
read-cache.c | 2 -
rebase-interactive.c | 1 -
ref-filter.c | 1 -
reflog-walk.c | 1 -
refs.c | 2 -
refspec.c | 1 -
remote-curl.c | 1 -
remote.c | 1 -
rerere.c | 2 -
revision.c | 1 -
sane-ctype.h | 66 +++++++
send-pack.c | 1 -
sequencer.c | 2 -
server-info.c | 2 -
setup.c | 1 -
shallow.c | 2 -
sigchain.c | 1 -
sparse-index.c | 1 -
split-index.c | 1 -
strbuf.c | 2 -
strbuf.h | 32 ++++
streaming.c | 1 -
string-list.c | 1 -
strvec.c | 1 -
submodule-config.c | 1 -
submodule.c | 1 -
t/helper/test-delta.c | 1 -
t/helper/test-fsmonitor-client.c | 1 -
t/helper/test-reach.c | 1 -
t/helper/test-read-cache.c | 1 -
tag.c | 1 -
tempfile.c | 1 -
trace.c | 1 -
trace2/tr2_tls.c | 1 -
trailer.c | 1 -
transport-helper.c | 1 -
transport.c | 2 -
tree-walk.c | 1 -
upload-pack.c | 1 -
usage.c | 1 -
userdiff.c | 1 -
versioncmp.c | 1 +
worktree.c | 2 -
wrapper.c | 1 -
wrapper.h | 111 +++++++++++
write-or-die.c | 1 -
147 files changed, 327 insertions(+), 478 deletions(-)
create mode 100644 sane-ctype.h
Range-diff against v3:
1: 03efb2c4b3 < -: ---------- init-db: document existing bug with core.bare in template config
2: 020191c84e < -: ---------- init-db: remove unnecessary global variable
3: 4f2631b200 < -: ---------- init-db, clone: change unnecessary global into passed parameter
4: 40e8349c97 < -: ---------- setup: adopt shared init-db & clone code
5: 8ce842e5e4 < -: ---------- read-cache: move shared commit and ls-files code
6: 9a435193b6 < -: ---------- add: modify add_files_to_cache() to avoid globals
7: f9fb1ec0c5 < -: ---------- read-cache: move shared add/checkout/commit code
8: 193ccad5dd < -: ---------- statinfo: move stat_{data,validity} functions from cache/read-cache
9: 8fb86883ed < -: ---------- run-command.h: move declarations for run-command.c from cache.h
10: 5e579aeeb5 < -: ---------- name-hash.h: move declarations for name-hash.c from cache.h
11: 5c0c5257a6 < -: ---------- sparse-index.h: move declarations for sparse-index.c from cache.h
12: 230b0e9968 < -: ---------- preload-index.h: move declarations for preload-index.c from elsewhere
13: 66327b7465 < -: ---------- diff.h: move declaration for global in diff.c from cache.h
14: 61830c7bfa < -: ---------- merge.h: move declarations for merge.c from cache.h
15: 0979c990b1 < -: ---------- repository.h: move declaration of the_index from cache.h
16: eb2fac9a86 < -: ---------- read-cache*.h: move declarations for read-cache.c functions from cache.h
17: 0cda8f7c94 < -: ---------- cache.h: remove this no-longer-used header
18: 82ce975a19 < -: ---------- log-tree: replace include of revision.h with simple forward declaration
19: 75334a2bc0 < -: ---------- repository: remove unnecessary include of path.h
20: 940ebf92de < -: ---------- diff.h: remove unnecessary include of oidset.h
21: fc12c810dc < -: ---------- list-objects-filter-options.h: remove unneccessary include
22: 8985e07940 < -: ---------- builtin.h: remove unneccessary includes
23: af118e7cf0 < -: ---------- git-compat-util.h: remove unneccessary include of wildmatch.h
24: 7e33c8f9b1 < -: ---------- merge-ll: rename from ll-merge
25: 5e96b1b130 < -: ---------- khash: name the structs that khash declares
26: 2d6aa61e78 < -: ---------- object-store-ll.h: split this header out of object-store.h
27: f6927dd57c < -: ---------- hash-ll, hashmap: move oidhash() to hash-ll
28: 482d3c671e < -: ---------- fsmonitor-ll.h: split this header out of fsmonitor.h
29: aa680f395a < -: ---------- strbuf: clarify API boundary
30: 44b977d1b0 < -: ---------- abspath: move related functions to abspath
31: 99852416e8 < -: ---------- credential-store: move related functions to credential-store file
32: 09aef95f30 < -: ---------- object-name: move related functions to object-name
33: 36048bca4c < -: ---------- path: move related function to path
34: 02a02faf12 < -: ---------- strbuf: clarify dependency
35: 63a933ff2f < -: ---------- strbuf: remove global variable
36: d352eae308 = 1: 144284a8f1 git-compat-util: move strbuf.c funcs to its header
37: fe4fd6f92a = 2: 39913c44e8 git-compat-util: move wrapper.c funcs to its header
38: ec7ea12f7c = 3: c495762940 sane-ctype.h: create header for sane-ctype macros
39: 4f95b4121e = 4: 2750d35e6d kwset: move translation table from ctype
40: 36525e39d5 < -: ---------- common.h: move non-compat specific macros and functions
41: 21f0f31ff3 < -: ---------- git-compat-util: move usage.c funcs to its header
42: 531db31c5c ! 5: b5fb55d235 treewide: remove unnecessary includes for wrapper.h
@@ gpg-interface.c
-#include "wrapper.h"
#include "environment.h"
- static int git_gpg_config(const char *, const char *, void *);
+ static int git_gpg_config(const char *, const char *,
## grep.c ##
@@
43: 98694f7add ! 6: 140d98111f common: move alloc macros to common.h
@@ Commit message
common: move alloc macros to common.h
alloc_nr, ALLOC_GROW, and ALLOC_GROW_BY are commonly used macros for
- dynamic array allocation. Moving these macros to common.h focuses
- alloc.[ch] to allocation for Git objects and additionally allows us to
- remove inclusions to alloc.h from files that solely used the above
- macros.
+ dynamic array allocation. Moving these macros to git-compat-util.h with
+ the other alloc macros focuses alloc.[ch] to allocation for Git objects
+ and additionally allows us to remove inclusions to alloc.h from files
+ that solely used the above macros.
## add-patch.c ##
@@
@@ commit-reach.c
#include "commit-graph.h"
#include "decorate.h"
- ## common.h ##
-@@ common.h: static inline int cast_size_t_to_int(size_t a)
- */
- #define FREE_AND_NULL(p) do { free(p); (p) = NULL; } while (0)
-
-+#define alloc_nr(x) (((x)+16)*3/2)
-+
-+/**
-+ * Dynamically growing an array using realloc() is error prone and boring.
-+ *
-+ * Define your array with:
-+ *
-+ * - a pointer (`item`) that points at the array, initialized to `NULL`
-+ * (although please name the variable based on its contents, not on its
-+ * type);
-+ *
-+ * - an integer variable (`alloc`) that keeps track of how big the current
-+ * allocation is, initialized to `0`;
-+ *
-+ * - another integer variable (`nr`) to keep track of how many elements the
-+ * array currently has, initialized to `0`.
-+ *
-+ * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
-+ * alloc)`. This ensures that the array can hold at least `n` elements by
-+ * calling `realloc(3)` and adjusting `alloc` variable.
-+ *
-+ * ------------
-+ * sometype *item;
-+ * size_t nr;
-+ * size_t alloc
-+ *
-+ * for (i = 0; i < nr; i++)
-+ * if (we like item[i] already)
-+ * return;
-+ *
-+ * // we did not like any existing one, so add one
-+ * ALLOC_GROW(item, nr + 1, alloc);
-+ * item[nr++] = value you like;
-+ * ------------
-+ *
-+ * You are responsible for updating the `nr` variable.
-+ *
-+ * If you need to specify the number of elements to allocate explicitly
-+ * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
-+ *
-+ * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
-+ * added niceties.
-+ *
-+ * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
-+ */
-+#define ALLOC_GROW(x, nr, alloc) \
-+ do { \
-+ if ((nr) > alloc) { \
-+ if (alloc_nr(alloc) < (nr)) \
-+ alloc = (nr); \
-+ else \
-+ alloc = alloc_nr(alloc); \
-+ REALLOC_ARRAY(x, alloc); \
-+ } \
-+ } while (0)
-+
-+/*
-+ * Similar to ALLOC_GROW but handles updating of the nr value and
-+ * zeroing the bytes of the newly-grown array elements.
-+ *
-+ * DO NOT USE any expression with side-effect for any of the
-+ * arguments.
-+ */
-+#define ALLOC_GROW_BY(x, nr, increase, alloc) \
-+ do { \
-+ if (increase) { \
-+ size_t new_nr = nr + (increase); \
-+ if (new_nr < nr) \
-+ BUG("negative growth in ALLOC_GROW_BY"); \
-+ ALLOC_GROW(x, new_nr, alloc); \
-+ memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
-+ nr = new_nr; \
-+ } \
-+ } while (0)
-+
- #define ALLOC_ARRAY(x, alloc) (x) = xmalloc(st_mult(sizeof(*(x)), (alloc)))
- #define CALLOC_ARRAY(x, alloc) (x) = xcalloc((alloc), sizeof(*(x)))
- #define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), st_mult(sizeof(*(x)), (alloc)))
-
## config.c ##
@@
#include "git-compat-util.h"
@@ fsck.c
#include "dir.h"
#include "hex.h"
+ ## git-compat-util.h ##
+@@ git-compat-util.h: static inline void move_array(void *dst, const void *src, size_t n, size_t size)
+ #define FLEXPTR_ALLOC_STR(x, ptrname, str) \
+ FLEXPTR_ALLOC_MEM((x), ptrname, (str), strlen(str))
+
++#define alloc_nr(x) (((x)+16)*3/2)
++
++/**
++ * Dynamically growing an array using realloc() is error prone and boring.
++ *
++ * Define your array with:
++ *
++ * - a pointer (`item`) that points at the array, initialized to `NULL`
++ * (although please name the variable based on its contents, not on its
++ * type);
++ *
++ * - an integer variable (`alloc`) that keeps track of how big the current
++ * allocation is, initialized to `0`;
++ *
++ * - another integer variable (`nr`) to keep track of how many elements the
++ * array currently has, initialized to `0`.
++ *
++ * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
++ * alloc)`. This ensures that the array can hold at least `n` elements by
++ * calling `realloc(3)` and adjusting `alloc` variable.
++ *
++ * ------------
++ * sometype *item;
++ * size_t nr;
++ * size_t alloc
++ *
++ * for (i = 0; i < nr; i++)
++ * if (we like item[i] already)
++ * return;
++ *
++ * // we did not like any existing one, so add one
++ * ALLOC_GROW(item, nr + 1, alloc);
++ * item[nr++] = value you like;
++ * ------------
++ *
++ * You are responsible for updating the `nr` variable.
++ *
++ * If you need to specify the number of elements to allocate explicitly
++ * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
++ *
++ * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
++ * added niceties.
++ *
++ * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
++ */
++#define ALLOC_GROW(x, nr, alloc) \
++ do { \
++ if ((nr) > alloc) { \
++ if (alloc_nr(alloc) < (nr)) \
++ alloc = (nr); \
++ else \
++ alloc = alloc_nr(alloc); \
++ REALLOC_ARRAY(x, alloc); \
++ } \
++ } while (0)
++
++/*
++ * Similar to ALLOC_GROW but handles updating of the nr value and
++ * zeroing the bytes of the newly-grown array elements.
++ *
++ * DO NOT USE any expression with side-effect for any of the
++ * arguments.
++ */
++#define ALLOC_GROW_BY(x, nr, increase, alloc) \
++ do { \
++ if (increase) { \
++ size_t new_nr = nr + (increase); \
++ if (new_nr < nr) \
++ BUG("negative growth in ALLOC_GROW_BY"); \
++ ALLOC_GROW(x, new_nr, alloc); \
++ memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
++ nr = new_nr; \
++ } \
++ } while (0)
++
+ static inline char *xstrdup_or_null(const char *str)
+ {
+ return str ? xstrdup(str) : NULL;
+
## help.c ##
@@
#include "git-compat-util.h"
--
2.41.0.255.g8b1d071c50-goog
^ permalink raw reply
* [ANNOUNCE] Git Rev News edition 100
From: Christian Couder @ 2023-06-30 20:12 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Jakub Narebski, Markus Jansen, Kaartic Sivaraam,
Taylor Blau, Johannes Schindelin,
Ævar Arnfjörð Bjarmason, Victoria Dye, Bruno Brito,
Calvin Wan, Elijah Newren, Phillip Wood, Eric Sunshine, Jeff King,
lwn
Hi everyone,
The 100th edition of Git Rev News is now published:
https://git.github.io/rev_news/2023/06/30/edition-100/
Thanks a lot to Bruno Brito and Victoria Dye who helped this month!
Thanks also to the readers who took the time to take the Reader Survey!
Enjoy,
Christian, Jakub, Markus and Kaartic.
PS: An issue for the next edition is already opened and contributions
are welcome:
https://github.com/git/git.github.io/issues/652
^ permalink raw reply
* Re: [RFC PATCH v3 1/1] unit tests: Add a project plan document
From: Linus Arver @ 2023-06-30 19:31 UTC (permalink / raw)
To: Josh Steadmon
Cc: git, calvinwan, szeder.dev, phillip.wood123, chooglen, avarab,
gitster, sandals
In-Reply-To: <ZJ3uGBEEvYmbPnoQ@google.com>
Josh Steadmon <steadmon@google.com> writes:
> On 2023.06.29 12:42, Linus Arver wrote:
>> I can think of some other metrics to add to the comparison, namely:
>>
>> 1. Age (how old is the framework)
>> 2. Size in KLOC (thousands of lines of code)
>> 3. Adoption rate (which notable C projects already use this framework?)
>> 4. Project health (how active are its developers?)
>>
>> I think for 3 and 4, we could probably mine some data out of GitHub
>> itself.
>
> Interesting, I'll see about adding some of these.
Sorry, one more thing worth considering is the ability to add tests
inline with production code (where the test code can be removed in
production builds). There are a number of benefits to this and, I think
it is a useful feature to have. I saw this feature being advertised for
a C++ testing framework called doctest [1], but I assume it is also
possible in C. Could you include it as another (nice to have?) feature
under the "Developer experience" category? (Or, reject it if this
"inlined tests" style is not possible in C?)
[1] https://github.com/doctest/doctest
^ permalink raw reply
* Re: [RFC PATCH v3 1/1] unit tests: Add a project plan document
From: K Wan @ 2023-06-30 18:47 UTC (permalink / raw)
To: phillip.wood
Cc: Josh Steadmon, git, szeder.dev, chooglen, avarab, gitster,
sandals
In-Reply-To: <a99a5134-3bac-64d4-b4e7-f02e8578090a@gmail.com>
Hi
Pleasure exclude my email from this discussion.
Thank you
> On Jun 30, 2023, at 6:08 AM, Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> Hi Josh
>
> Thanks for putting this together, I think it is really helpful to have a comparison of the various options. Sorry for the slow reply, I was off the list for a couple of weeks.
>
>> On 10/06/2023 00:25, Josh Steadmon wrote:
>> diff --git a/Documentation/technical/unit-tests.txt b/Documentation/technical/unit-tests.txt
>> new file mode 100644
>> index 0000000000..dac8062a43
>> --- /dev/null
>> +++ b/Documentation/technical/unit-tests.txt
>> @@ -0,0 +1,141 @@
>> += Unit Testing
>
> I've deleted the sections I agree with to avoid quoting parts that are not relevant to my comments.
>
>> +== Definitions
>> +
>> +For the purposes of this document, we'll use *test framework* to refer to
>> +projects that support writing test cases and running tests within the context
>> +of a single executable. *Test harness* will refer to projects that manage
>> +running multiple executables (each of which may contain multiple test cases) and
>> +aggregating their results.
>
> Thanks for adding this, it is really helpful to have definitions for what we mean by "test framework" and "test harness" within the git project. It might be worth mentioning somewhere that we already use prove as a test harness when running our integration tests.
>
>> +In reality, these terms are not strictly defined, and many of the projects
>> +discussed below contain features from both categories.
>
>> +
>> +== Choosing a framework & harness
>> +
>> +=== Desired features
>> +
>> [...]
>> +==== Parallel execution
>> +
>> +Ideally, we will build up a significant collection of unit tests cases, most
>> +likely split across multiple executables. It will be necessary to run these
>> +tests in parallel to enable fast develop-test-debug cycles.
>
> This is a good point, though I think it is really a property of the harness rather than the framework so we might want to indicate in the table whether a framework provides parallelism itself or relies on the harness providing it.
>
> > [...]
>> +==== Major platform support
>> +
>> +At a bare minimum, unit-testing must work on Linux, MacOS, and Windows.
>
> I think we'd want to be able to run unit tests on *BSD and NonStop as well, especially as I think some of the platform dependent code probably lends itself to being unit tested. I suspect a framework that covers Linux and MacOS would probably run on those platforms as well (I don't think NonStop has complete POSIX support but it is hard to imagine a test framework doing anything very exotic)
>
>> [...]
>> +==== Mock support
>> +
>> +Unit test authors may wish to test code that interacts with objects that may be
>> +inconvenient to handle in a test (e.g. interacting with a network service).
>> +Mocking allows test authors to provide a fake implementation of these objects
>> +for more convenient tests.
>
> Do we have any idea what sort of thing we're likely to want to mock and what we want that support to look like?
>
>> +==== Signal & exception handling
>> +
>> +The test framework must fail gracefully when test cases are themselves buggy or
>> +when they are interrupted by signals during runtime.
>
> I had assumed that it would be enough for the test harness to detect if a test executable was killed by a signal or exited early due to a bug in the test script. That requires the framework to have robust support for lazy test plans but I'm not sure that we need it to catch and recover from things like SIGSEGV.
>
>> +==== Coverage reports
>> +
>> +It may be convenient to generate coverage reports when running unit tests
>> +(although it may be possible to accomplish this regardless of test framework /
>> +harness support).
>
> I agree this would be useful, though perhaps we should build it on our existing gcov usage.
>
> Related to this do we want timing reports from the harness or the framework?
>
>> +
>> +=== Comparison
>> +
>> +[format="csv",options="header",width="75%"]
>> +|=====
>> +Framework,"TAP support","Diagnostic output","Parallel execution","Vendorable / ubiquitous","Maintainable / extensible","Major platform support","Lazy test planning","Runtime- skippable tests","Scheduling / re-running",Mocks,"Signal & exception handling","Coverage reports"
>> +https://lore.kernel.org/git/c902a166-98ce-afba-93f2-ea6027557176@gmail.com/[Custom Git impl.],[lime-background]#True#,[lime-background]#True#,?,[lime-background]#True#,[lime-background]#True#,[lime-background]#True#,[lime-background]#True#,?,?,[red-background]#False#,?,?
>> +https://cmocka.org/[cmocka],[lime-background]#True#,[lime-background]#True#,?,[red-background]#False#,[yellow-background]#Partial#,[yellow-background]#Partial#,[yellow-background]#Partial#,?,?,[lime-background]#True#,?,?
>> +https://libcheck.github.io/check/[Check],[lime-background]#True#,[lime-background]#True#,?,[red-background]#False#,[yellow-background]#Partial#,[lime-background]#True#,[yellow-background]#Partial#,?,?,[red-background]#False#,?,?
>> +https://github.com/rra/c-tap-harness/[C TAP],[lime-background]#True#,[red-background]#False#,?,[lime-background]#True#,[yellow-background]#Partial#,[yellow-background]#Partial#,[yellow-background]#Partial#,?,?,[red-background]#False#,?,?
>> +https://github.com/silentbicycle/greatest[Greatest],[yellow-background]#Partial#,?,?,[lime-background]#True#,[yellow-background]#Partial#,?,[yellow-background]#Partial#,?,?,[red-background]#False#,?,?
>> +https://github.com/Snaipe/Criterion[Criterion],[lime-background]#True#,?,?,[red-background]#False#,?,[lime-background]#True#,?,?,?,[red-background]#False#,?,?
>> +https://github.com/zorgnax/libtap[libtap],[lime-background]#True#,?,?,?,?,?,?,?,?,?,?,?
>> +https://nemequ.github.io/munit/[µnit],?,?,?,?,?,?,?,?,?,?,?,?
>> +https://github.com/google/cmockery[cmockery],?,?,?,?,?,?,?,?,?,[lime-background]#True#,?,?
>> +https://github.com/lpabon/cmockery2[cmockery2],?,?,?,?,?,?,?,?,?,[lime-background]#True#,?,?
>> +https://github.com/ThrowTheSwitch/Unity[Unity],?,?,?,?,?,?,?,?,?,?,?,?
>> +https://github.com/siu/minunit[minunit],?,?,?,?,?,?,?,?,?,?,?,?
>> +https://cunit.sourceforge.net/[CUnit],?,?,?,?,?,?,?,?,?,?,?,?
>> +https://www.kindahl.net/mytap/doc/index.html[MyTAP],[lime-background]#True#,?,?,?,?,?,?,?,?,?,?,?
>> +|=====
>
> Thanks for going through these projects, hopefully we can use this information to make a decision on a framework soon.
>
> Best Wishes
>
> Phillip
^ permalink raw reply
* Re: "git commit -m" bug
From: Linus Arver @ 2023-06-30 17:38 UTC (permalink / raw)
To: Konstantin Ryabitsev, Ruben Ticehurst-James; +Cc: git, git-security
In-Reply-To: <20230630-staid-welcome-howl-da79f0@meerkat>
Konstantin Ryabitsev <konstantin@linuxfoundation.org> writes:
> On Fri, Jun 30, 2023 at 02:30:55PM +0100, 'Ruben Ticehurst-James' via Git Security wrote:
>> Hello I am reporting a (potential) bug in git:
>>
>> when I use triple exclamation marks in a commit message (for an example):
>>
>> git commit -m “WORKING!!! WOOOO” (command above was git add .)
>>
>> or
>>
>> git commit -m "Checking !!! Git” (command above was ls)
>>
>> It will instead copy over the last command I used. The two above commands produce this output:
>
> This is done by your shell (bash). For example, try this:
>
> echo "hello"
> echo "hello!!"
>
> -K
@Ruben: For completeness, if you use single quotes the exclamantion
points should stay as-is (double quotes expand variables and special
things like `!!`, but single quotes do not).
Cheers,
Linus
^ permalink raw reply
* Review Club cancelled next Wednesday
From: Calvin Wan @ 2023-06-30 17:02 UTC (permalink / raw)
To: Git Mailing List
Our team will be off next Monday and Tuesday for a holiday! See
everyone at the next session on June 19.
- Calvin
^ permalink raw reply
* Re: [PATCH] docs: include "trace.h" in MyFirstObjectWalk.txt
From: Vinayak Dev @ 2023-06-30 16:50 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Elijah Newren, nasamuffin, git
In-Reply-To: <xmqqsfa87w9o.fsf@gitster.g>
On Fri, 30 Jun 2023 at 21:55, Junio C Hamano <gitster@pobox.com> wrote:
Hello again, and thanks for replying!
> Vinayak Dev <vinayakdev.sci@gmail.com> writes:
>
> > That is a good suggestion, but wouldn't the same argument apply to
> > including trace.h itself? It makes it necessary for the code to work
> > that any API changes must involve changing the included headers.
>
> Exactly. That is exactly what I meant by "tone down 'defined in X'
> somehow to hint that these details may change".
>
> IOW, it may allow us to "cop out" of the problem to say "You'd add a
> new file like so, and call this API function, and include headers
> necessary to do so. The codebase may have evolved since this
> tutorial was written, so some details (like names of the API
> functions and in which header files the functions are declared) may
> be different in the code you have."
>
> > Either way, I would be happy to fix my mistake. Should I send out a V2?
>
> Oh, sorry to see you took it that way. I think the change you sent
> as-is is a fine fix for the immediate problem. Everything you
> quoted above is "while the issue is fresh on our minds, what are the
> follow-up improvements we can make" material, so there is no "mistake"
> to fix.
That is certainly nice to hear! However, I must admit that I did make
a mistake in the patch
in that I missed to include "hex.h" down in the file. This is needed
because the tutorial uses
the function oid_to_hex(), which is defined there. I found this while
fixing the code in Emily's
branch to which the tutorial points. I have fixed that there, so maybe
if you think a V2 would be
alright, I would be happy to send it fixing both the problems.
Thanks a lot!
Vinayak
^ permalink raw reply
* Re: SHA256 support not experimental, or?
From: Junio C Hamano @ 2023-06-30 16:45 UTC (permalink / raw)
To: Son Luong Ngoc; +Cc: Adam Majer, Patrick Steinhardt, brian m. carlson, git
In-Reply-To: <CAL3xRKfQLj7Zufy5fMMs=ykeexBn7duqFH1jZ84+WRKKOaEpFA@mail.gmail.com>
Son Luong Ngoc <sluongng@gmail.com> writes:
> Build tools such as Bazel would often need to hash the content of the
> source files to build a dependency graph. And in a FUSE setup, it would
> be ideal if the FUSE server could supply the hash via an xattr, so that
> FUSE client does not need to fetch the whole file content and only the
> metadata.
This is unrelated tangent, but the implementation of virtual
filesystem on top of Git's object store will be able to give such
SHA-256 hash only by computing the hash itself, if the "hash the
content of the source files" has to be exactly SHA-256. Using Git
repository that uses SHA-256 would *not* help.
$ git init --object-format sha256
$ echo hello | git hash-object --stdin
2cf8d83d9ee29543b34a87727421fdecb7e3f3a183d337639025de576db9ebb4
$ echo hello | sha256sum
5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03 -
This is because the object name used by Git is not the hash of the
content. It is a hash of an object header (object type and byte
count) followed by its contents.
$ printf "blob 6\0hello\n" | sha256sum
2cf8d83d9ee29543b34a87727421fdecb7e3f3a183d337639025de576db9ebb4 -
The build systems can choose to tell FUSE server to expose the Git
object names via xattr, but if it needs to see if some contents (not
in FUSE) it has on hand is the same as what is stored in the FUSE
server, it needs to use the "slightly modified SHA-256" that matches
what Git uses. It would still be using some hash that has the same
strength as underlying SHA-256, but it is *not* SHA-256.
^ permalink raw reply
* Re: [PATCH] docs: include "trace.h" in MyFirstObjectWalk.txt
From: Junio C Hamano @ 2023-06-30 16:25 UTC (permalink / raw)
To: Vinayak Dev; +Cc: Elijah Newren, nasamuffin, git
In-Reply-To: <CADE8NapyQJU1rDPvyMcRXcJfz3kzzg_fYXSSEvYJ7dFO+UHGaQ@mail.gmail.com>
Vinayak Dev <vinayakdev.sci@gmail.com> writes:
> That is a good suggestion, but wouldn't the same argument apply to
> including trace.h itself? It makes it necessary for the code to work
> that any API changes must involve changing the included headers.
Exactly. That is exactly what I meant by "tone down 'defined in X'
somehow to hint that these details may change".
IOW, it may allow us to "cop out" of the problem to say "You'd add a
new file like so, and call this API function, and include headers
necessary to do so. The codebase may have evolved since this
tutorial was written, so some details (like names of the API
functions and in which header files the functions are declared) may
be different in the code you have."
> Either way, I would be happy to fix my mistake. Should I send out a V2?
Oh, sorry to see you took it that way. I think the change you sent
as-is is a fine fix for the immediate problem. Everything you
quoted above is "while the issue is fresh on our minds, what are the
follow-up improvements we can make" material, so there is no "mistake"
to fix.
^ permalink raw reply
* Re: Documentation/MyFirstObjectWalk: add #include "trace.h" to use trace_printf()
From: Vinayak Dev @ 2023-06-30 15:39 UTC (permalink / raw)
To: Emily Shaffer, Junio C Hamano, git
In-Reply-To: <CADE8NaqSn7DvvBHzLhGdWwZtwK+sxoKnVWo_G26P30p_WnVXJg@mail.gmail.com>
Hi!
I pulled down walken.c from https://github.com/nasamuffin/git/tree/revwalk
and was able to fix the broken code. I also fixed
Documentation/MyFirstObjectWalk.txt
and have accordingly pushed all the changes to my fork of git:
https://github.com/vinayakdsci/git/tree/revwalk-fixed
I had to remove init_walken_defaults() as I could not trace the
function init_grep_defaults()
which I think has been removed since you wrote the tutorial.
I also didn't find a mention of init_grep_defaults() in the tutorial,
so maybe that is alright.
Also, struct list_objects_filter_options is included inside of
rev_info, so I don't think it requires initialisation
any more.
It would be great if you are able to use this branch to rewrite your own!
Thanks a lot!
Vinayak
^ permalink raw reply
* Re: "git commit -m" bug
From: Konstantin Ryabitsev @ 2023-06-30 14:17 UTC (permalink / raw)
To: Ruben Ticehurst-James; +Cc: git, git-security
In-Reply-To: <5C7CF0D9-4C6F-4207-BA4B-8AC9B472BD75@apple.com>
On Fri, Jun 30, 2023 at 02:30:55PM +0100, 'Ruben Ticehurst-James' via Git Security wrote:
> Hello I am reporting a (potential) bug in git:
>
> when I use triple exclamation marks in a commit message (for an example):
>
> git commit -m “WORKING!!! WOOOO” (command above was git add .)
>
> or
>
> git commit -m "Checking !!! Git” (command above was ls)
>
> It will instead copy over the last command I used. The two above commands produce this output:
This is done by your shell (bash). For example, try this:
echo "hello"
echo "hello!!"
-K
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox