Commit Graph

112220 Commits

Author SHA1 Message Date
Johannes Schindelin
8fd36859ea Merge branch 'en/mem-pool'
This merges the `mem_pool` changes (backported on top of v2.28.0) into
Git for Windows' `main` branch early, i.e. before v2.29.0-rc0 is
available, to be able to adjust our `fscache.c` early (which would
otherwise conflict).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-10-06 01:12:47 +02:00
Johannes Schindelin
2b557dc841 Merge branch 'jc/quote-path-cleanup'
This merges the `quote_path()` fixes (backported on top of v2.28.0) into
Git for Windows' `main` branch early, i.e. before v2.29.0-rc0 is
available, to be able to adjust our `builtin/clean.c` changes early
(which would otherwise conflict).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-10-06 01:12:47 +02:00
Johannes Schindelin
b80af2e065 Merge pull request #2823 from dscho/backport-cmake-build
Backport the CMake support
2020-10-06 01:12:47 +02:00
Johannes Schindelin
adde14aa25 Merge branch 'ss/cmake-build'
This is a backport of `ss/cmake-build` so that we can merge it into Git
for Windows early.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-10-06 01:12:46 +02:00
Johannes Schindelin
9911e53d1a cmake: ignore generated files
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-10-06 01:10:04 +02:00
Sibi Siddharthan
1a2e09211d ci: modification of main.yml to use cmake for vs-build job
Teach .github/workflows/main.yml to use CMake for VS builds.

Modified the vs-test step to match windows-test step. This speeds
up the vs-test. Calling git-cmd from powershell and then calling git-bash
to perform the tests slows things down(factor of about 6). So git-bash
is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job
(with respect to path) absolute paths are used in the bin-wrapper
scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of
FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
added to revert to the old behaviour.

In the configuration phase CMake looks for the required libraries for
building git (eg zlib,libiconv). So we extract the libraries before we
configure.

To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
directory of script or path. So we copy the dlls before we configure.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 01:10:04 +02:00
Sibi Siddharthan
fe62bd1254 cmake: support for building git on windows with msvc and clang.
This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because
this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang
because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included.
The reason for this is because by default, Windows calls abort()'s
instead of setting errno=EINVAL when invalid arguments are passed to
standard functions.
This commit explains it in detail:
4b623d80f7

On Windows the default generator is Visual Studio,so for Visual Studio
builds do this:

cmake `relative-path-to-srcdir`

NOTE: Visual Studio generator is a multi config generator, which means
that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=clang cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 01:10:04 +02:00
Sibi Siddharthan
f59c0cac80 cmake: support for building git on windows with mingw
This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows
builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which
conflicts with the definition provided in
git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake `relative-path-to-srcdir` -G "MinGW Makefiles"

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 01:10:04 +02:00
Sibi Siddharthan
79c68049bd cmake: support for testing git when building out of the source tree
This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the
build directory. Also some miscellaneous copies from the source directory
to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity
mergetools/tkdiff needed by t7800-difftool
contrib/completion/git-prompt.sh needed by t9903-bash-prompt
contrib/completion/git-completion.bash needed by t9902-completion
contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during
the build or configure.
The trash directory is still srcdir/t

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 01:10:04 +02:00
Sibi Siddharthan
0609f9c9fa cmake: support for testing git with ctest
This patch provides an alternate way to test git using ctest.
CTest ships with CMake, so there is no additional dependency being
introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests
in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in
`build-directory`/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the
run.

LastTest.log:
This log file contains the log of all the tests that have run.
A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh
10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t
"D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time =   1.11 sec

NOTE: Testing only works when building in source for now.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 01:10:04 +02:00
Sibi Siddharthan
3ba96577f8 cmake: installation support for git
Install the built binaries and scripts using CMake

This is very similar to `make install`.
By default the destination directory(DESTDIR) is /usr/local/ on Linux
To set a custom installation path do this:
cmake `relative-path-to-srcdir`
	-DCMAKE_INSTALL_PREFIX=`preferred-install-path`

Then run `make install`

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 01:10:03 +02:00
Sibi Siddharthan
44ef8381b2 cmake: generate the shell/perl/python scripts and templates, translations
Implement the placeholder substitution to generate scripted
Porcelain commands, e.g. git-request-pull out of
git-request-pull.sh

Generate shell/perl/python scripts and template using CMake instead of
using sed like the build procedure in the Makefile does.

The text translations are only build if `msgfmt` is found in your path.

NOTE: The scripts and templates are generated during configuration.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 01:10:03 +02:00
Sibi Siddharthan
476e491ef0 Introduce CMake support for configuring Git
At the moment, the recommended way to configure Git's builds is to
simply run `make`. If that does not work, the recommended strategy is to
look at the top of the `Makefile` to see whether any "Makefile knob" has
to be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.

Alternatively, Git also has an `autoconf` setup which allows configuring
builds via `./configure [<option>...]`.

Both of these options are fine if the developer works on Unix or Linux.
But on Windows, we have to jump through hoops to configure a build
(read: we force the user to install a full Git for Windows SDK, which
occupies around two gigabytes (!) on disk and downloads about three
quarters of a gigabyte worth of Git objects).

The build infrastructure for Git is written around being able to run
make, which is not supported natively on Windows.
To help Windows developers a CMake build script is introduced here.

With a working support CMake, developers on Windows need only install
CMake, configure their build, load the generated Visual Studio solution
and immediately start modifying the code and build their own version of
Git. Likewise, developers on other platforms can use the convenient GUI
tools provided by CMake to configure their build.

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only
allows for configuring builds on the platform that is easiest to
configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h),
whether the functions are present(eg. memmem), whether the funtions work
properly (eg. snprintf) and generate the required compile definitions
for the platform. The script also searches for the required libraries,
if it fails to find the required libraries the respective executables
won't be built.(eg. If libcurl is not found then git-remote-http won't
be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting
in a clean source tree.

Note: this patch asks for the minimum version v3.14 of CMake (which is
not all that old as of time of writing) because that is the first
version to offer a platform-independent way to generate hardlinks as
part of the build. This is needed to generate all those hardlinks for
the built-in commands of Git.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 01:10:03 +02:00
Elijah Newren
494ef88620 mem-pool: use consistent pool variable name
About half the function declarations in mem-pool.h used 'struct mem_pool
*pool', while the other half used 'struct mem_pool *mem_pool'.  Make the
code a bit more consistent by just using 'pool' in preference to
'mem_pool' everywhere.

No behavioral changes included; this is just a mechanical rename (though
a line or two was rewrapped as well).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:18 +02:00
Junio C Hamano
c6cd7d2a91 quote: turn 'nodq' parameter into a set of flags
quote_c_style() and its friend quote_two_c_style() both take an
optional "please omit the double quotes around the quoted body"
parameter.  Turn it into a flag word, assign one bit out of it,
and call it CQUOTE_NODQ bit.

No behaviour change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Elijah Newren
758f41d5e9 mem-pool: use more standard initialization and finalization
A typical memory type, such as strbuf, hashmap, or string_list can be
stored on the stack or embedded within another structure.  mem_pool
cannot be, because of how mem_pool_init() and mem_pool_discard() are
written.  mem_pool_init() does essentially the following (simplified
for purposes of explanation here):

    void mem_pool_init(struct mem_pool **pool...)
    {
        *pool = xcalloc(1, sizeof(*pool));

It seems weird to require that mem_pools can only be accessed through a
pointer.  It also seems slightly dangerous: unlike strbuf_release() or
strbuf_reset() or string_list_clear(), all of which put the data
structure into a state where it can be re-used after the call,
mem_pool_discard(pool) will leave pool pointing at free'd memory.
read-cache (and split-index) are the only current users of mem_pools,
and they haven't fallen into a use-after-free mistake here, but it seems
likely to be problematic for future users especially since several of
the current callers of mem_pool_init() will only call it when the
mem_pool* is not already allocated (i.e. is NULL).

This type of mechanism also prevents finding synchronization
points where one can free existing memory and then resume more
operations.  It would be natural at such points to run something like
    mem_pool_discard(pool...);
and, if necessary,
    mem_pool_init(&pool...);
and then carry on continuing to use the pool.  However, this fails badly
if several objects had a copy of the value of pool from before these
commands; in such a case, those objects won't get the updated value of
pool that mem_pool_init() overwrites pool with and they'll all instead
be reading and writing from free'd memory.

Modify mem_pool_init()/mem_pool_discard() to behave more like
   strbuf_init()/strbuf_release()
or
   string_list_init()/string_list_clear()
In particular: (1) make mem_pool_init() just take a mem_pool* and have
it only worry about allocating struct mp_blocks, not the struct mem_pool
itself, (2) make mem_pool_discard() free the memory that the pool was
responsible for, but leave it in a state where it can be used to
allocate more memory afterward (without the need to call mem_pool_init()
again).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Junio C Hamano
e4b856ef26 quote: rename misnamed sq_lookup[] to cq_lookup[]
This table is used to see if each byte needs quoting when responding
to a request to C-quote the string, not quoting with single-quote in
the shell style.  Similarly, sq_must_quote() is fed each byte from
the string being C-quoted.

No behaviour change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Elijah Newren
ca1186ae01 mem-pool: add convenience functions for strdup and strndup
fast-import had a special mem_pool_strdup() convenience function that I
want to be able to use from the new merge algorithm I am writing.  Move
it from fast-import to mem-pool, and also add a mem_pool_strndup()
while at it that I also want to use.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Junio C Hamano
fa07070173 wt-status: consistently quote paths in "status --short" output
Tracked paths with SP in them were cquoted in "git status --short"
output, but untracked, ignored, and unmerged paths weren't.

The test was stolen from a patch to fix output for the 'untracked'
paths by brian m. carlson, with similar tests added for 'ignored'
ones.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Junio C Hamano
d3891ca59a quote_path: code clarification
The implementation we moved from wt-status to enclose a pathname
that has a SP in it inside a dq-pair is a bit convoluted.  It lets
quote_c_style_counted() do its escaping and then

 (1) if the input string got escaped, which is checked by seeing if
     the result begins with a double-quote, declare that we are
     done.  If there wasn't any SP in the input, that is OK, and if
     there was, the result is quoted already so it is OK, too.

 (2) if the input string did not get escaped, and the result has SP
     in it, enclose the whole thing in a dq-pair ourselves.

Instead we can scan the path upfront to see if the input has SP in
it.  If so, we tell quote_c_style_counted() not to enclose its
output in a dq-pair, and we add a dq-pair ourselves.  Whether the
input had bytes that quote_c_style_counted() uses backslash quoting,
this would give us a desired quoted string.  If the input does not
have SP in it, we just let quote_c_style_counted() do its thing as
usual, which would enclose the result in a dq-pair only when needed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Junio C Hamano
3f44924985 quote_path: optionally allow quoting a path with SP in it
Some code in wt-status.c special case a path with SP in it, which
usually does not have to be c-quoted, and ensure that such a path
does get quoted.  Move the logic to quote_path() and give it a bit
in the flags word, QUOTE_PATH_QUOTE_SP.

No behaviour change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Junio C Hamano
1f00ff4aad quote_path: give flags parameter to quote_path()
The quote_path() function computes a path (relative to its base
directory) and c-quotes the result if necessary.  Teach it to take a
flags parameter to allow its behaviour to be enriched later.

No behaviour change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Junio C Hamano
f6abad071a quote_path: rename quote_path_relative() to quote_path()
There is no quote_path_absolute() or anything that causes confusion,
and one of the two large consumers already rename the long name
locally with a preprocessor macro.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-10-06 00:33:17 +02:00
Johannes Schindelin
a40ce9235b Start the merging-rebase to v2.28.0
As a last step before v2.29.0-rc0, let's clean up Git for Windows'
branch thicket a bit, in particular reintroducing the
`ready-for-upstream` sub-thicket, and replacing the scattered FSCache
topics with a somewhat consolidated version.

This commit starts the rebase of e62b20a1d3 to 4c8bcdda4d6 and does not
introduce any changes relative to 47ae905ffb.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-10-05 23:59:40 +02:00
Johannes Schindelin
e782f50662 Merge pull request #2725 from native-api/homedir_seclogons
Ignore Vista+ HOMEDRIVE/HOMEPATH default for non-shell logons
2020-10-02 18:25:20 +02:00
Johannes Schindelin
8209d434b9 Merge pull request #2834 from dscho/lctype-should-adapt-to-console-code-page
fixup! mingw: ensure valid CTYPE
2020-09-29 18:13:27 +02:00
Johannes Schindelin
8a1fdd6938 fixup! mingw: ensure valid CTYPE
Originally, the intention was to set `LC_CTYPE=C.UTF-8`, but that
elicited some bug report. Sadly, the to-be-fixed-up commit's message
does not record this properly. Having searched for a while, it would
appear to this developer that the issue was ConEmu, as mentioned here:

    https://groups.google.com/g/git-for-windows/c/9_abrdlqi48/m/S9pJE56ZDgAJ

This was a long time ago, and re-testing with a current ConEmu failed to
reproduce the original issue.

So let's just go ahead and set `LC_CTYPE=C.UTF-8` (unless something else
was _already_ specified via `LANG`, `LC_ALL` or `LC_CTYPE`).

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-29 12:07:39 +02:00
Johannes Schindelin
bcabfe850c squash! mingw: lstat: compute correct size for symlinks
Move this, and "fscache: compute correct symlink size in `lstat()`",
into "kblees/kb/symlinks".

Maybe even squash it into the appropriate commits, e.g. "mingw: teach
fscache and dirent about symlinks"?

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-24 21:56:10 +02:00
Johannes Schindelin
87c86a26de Merge pull request #2831 from dscho/prepare-for-v2.29.0-rc0
Prepare for v2.29.0-rc0
2020-09-23 15:51:38 +02:00
Johannes Schindelin
edc387f0e6 fixup! fscache: teach fscache to use mempool
Needed for the recent mem-pool changes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-23 15:03:46 +02:00
Johannes Schindelin
29be755d4f Merge branch 'en/mem-pool'
This merges the `mem_pool` changes (backported on top of v2.28.0) into
Git for Windows' `main` branch early, i.e. before v2.29.0-rc0 is
available, to be able to adjust our `fscache.c` early (which would
otherwise conflict).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-23 15:00:07 +02:00
Johannes Schindelin
6d05883f95 fixup! clean: remove mount points when possible
Accommodating for Junio's changes to the path quoting machinery.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-23 14:57:52 +02:00
Johannes Schindelin
ab8c9c83a2 Merge branch 'jc/quote-path-cleanup'
This merges the `quote_path()` fixes (backported on top of v2.28.0) into
Git for Windows' `main` branch early, i.e. before v2.29.0-rc0 is
available, to be able to adjust our `builtin/clean.c` changes early
(which would otherwise conflict).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-23 14:56:06 +02:00
Elijah Newren
30373b6c6c mem-pool: use consistent pool variable name
About half the function declarations in mem-pool.h used 'struct mem_pool
*pool', while the other half used 'struct mem_pool *mem_pool'.  Make the
code a bit more consistent by just using 'pool' in preference to
'mem_pool' everywhere.

No behavioral changes included; this is just a mechanical rename (though
a line or two was rewrapped as well).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:04 +02:00
Junio C Hamano
d33371e91a quote: turn 'nodq' parameter into a set of flags
quote_c_style() and its friend quote_two_c_style() both take an
optional "please omit the double quotes around the quoted body"
parameter.  Turn it into a flag word, assign one bit out of it,
and call it CQUOTE_NODQ bit.

No behaviour change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:04 +02:00
Elijah Newren
7188a39e52 mem-pool: use more standard initialization and finalization
A typical memory type, such as strbuf, hashmap, or string_list can be
stored on the stack or embedded within another structure.  mem_pool
cannot be, because of how mem_pool_init() and mem_pool_discard() are
written.  mem_pool_init() does essentially the following (simplified
for purposes of explanation here):

    void mem_pool_init(struct mem_pool **pool...)
    {
        *pool = xcalloc(1, sizeof(*pool));

It seems weird to require that mem_pools can only be accessed through a
pointer.  It also seems slightly dangerous: unlike strbuf_release() or
strbuf_reset() or string_list_clear(), all of which put the data
structure into a state where it can be re-used after the call,
mem_pool_discard(pool) will leave pool pointing at free'd memory.
read-cache (and split-index) are the only current users of mem_pools,
and they haven't fallen into a use-after-free mistake here, but it seems
likely to be problematic for future users especially since several of
the current callers of mem_pool_init() will only call it when the
mem_pool* is not already allocated (i.e. is NULL).

This type of mechanism also prevents finding synchronization
points where one can free existing memory and then resume more
operations.  It would be natural at such points to run something like
    mem_pool_discard(pool...);
and, if necessary,
    mem_pool_init(&pool...);
and then carry on continuing to use the pool.  However, this fails badly
if several objects had a copy of the value of pool from before these
commands; in such a case, those objects won't get the updated value of
pool that mem_pool_init() overwrites pool with and they'll all instead
be reading and writing from free'd memory.

Modify mem_pool_init()/mem_pool_discard() to behave more like
   strbuf_init()/strbuf_release()
or
   string_list_init()/string_list_clear()
In particular: (1) make mem_pool_init() just take a mem_pool* and have
it only worry about allocating struct mp_blocks, not the struct mem_pool
itself, (2) make mem_pool_discard() free the memory that the pool was
responsible for, but leave it in a state where it can be used to
allocate more memory afterward (without the need to call mem_pool_init()
again).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:04 +02:00
Elijah Newren
5966a5bb40 mem-pool: add convenience functions for strdup and strndup
fast-import had a special mem_pool_strdup() convenience function that I
want to be able to use from the new merge algorithm I am writing.  Move
it from fast-import to mem-pool, and also add a mem_pool_strndup()
while at it that I also want to use.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:04 +02:00
Junio C Hamano
d76055c843 quote: rename misnamed sq_lookup[] to cq_lookup[]
This table is used to see if each byte needs quoting when responding
to a request to C-quote the string, not quoting with single-quote in
the shell style.  Similarly, sq_must_quote() is fed each byte from
the string being C-quoted.

No behaviour change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:03 +02:00
Junio C Hamano
2752ee2648 wt-status: consistently quote paths in "status --short" output
Tracked paths with SP in them were cquoted in "git status --short"
output, but untracked, ignored, and unmerged paths weren't.

The test was stolen from a patch to fix output for the 'untracked'
paths by brian m. carlson, with similar tests added for 'ignored'
ones.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:03 +02:00
Junio C Hamano
57fb202d8c quote_path: code clarification
The implementation we moved from wt-status to enclose a pathname
that has a SP in it inside a dq-pair is a bit convoluted.  It lets
quote_c_style_counted() do its escaping and then

 (1) if the input string got escaped, which is checked by seeing if
     the result begins with a double-quote, declare that we are
     done.  If there wasn't any SP in the input, that is OK, and if
     there was, the result is quoted already so it is OK, too.

 (2) if the input string did not get escaped, and the result has SP
     in it, enclose the whole thing in a dq-pair ourselves.

Instead we can scan the path upfront to see if the input has SP in
it.  If so, we tell quote_c_style_counted() not to enclose its
output in a dq-pair, and we add a dq-pair ourselves.  Whether the
input had bytes that quote_c_style_counted() uses backslash quoting,
this would give us a desired quoted string.  If the input does not
have SP in it, we just let quote_c_style_counted() do its thing as
usual, which would enclose the result in a dq-pair only when needed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:03 +02:00
Junio C Hamano
40393f2a9e quote_path: optionally allow quoting a path with SP in it
Some code in wt-status.c special case a path with SP in it, which
usually does not have to be c-quoted, and ensure that such a path
does get quoted.  Move the logic to quote_path() and give it a bit
in the flags word, QUOTE_PATH_QUOTE_SP.

No behaviour change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:03 +02:00
Junio C Hamano
0df065fe61 quote_path: give flags parameter to quote_path()
The quote_path() function computes a path (relative to its base
directory) and c-quotes the result if necessary.  Teach it to take a
flags parameter to allow its behaviour to be enriched later.

No behaviour change intended.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:03 +02:00
Junio C Hamano
5f1e0d87f3 quote_path: rename quote_path_relative() to quote_path()
There is no quote_path_absolute() or anything that causes confusion,
and one of the two large consumers already rename the long name
locally with a preprocessor macro.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23 14:56:03 +02:00
Johannes Schindelin
568c2f1745 Merge pull request #2827 from dscho/rename-t7421-to-make-room
Rename a test to prepare for v2.29.0
2020-09-22 21:48:23 +02:00
Johannes Schindelin
abe59836be fixup! pack-objects (mingw): demonstrate a segmentation fault with large deltas
Just another test number conflict in the upcoming v2.29.0.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-21 23:19:53 +02:00
Johannes Schindelin
77ac695227 Merge pull request #2823 from dscho/backport-cmake-build
Backport the CMake support
2020-09-21 23:16:08 +02:00
Johannes Schindelin
17600b195c cmake: ignore generated files
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-18 10:50:58 +02:00
Johannes Schindelin
574d15a990 fixup! mingw: add a cache below mingw's lstat and dirent implementations
Since we're using CMake in the CI builds now, we were conveniently
notified that the `fscache.c` file needs to be added to the
Windows-specific source files.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-18 10:50:58 +02:00
Johannes Schindelin
efeaea150a Merge branch 'ss/cmake-build'
This is a backport of `ss/cmake-build` so that we can merge it into Git
for Windows early.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-09-18 10:50:58 +02:00
Sibi Siddharthan
4ffaff0848 ci: modification of main.yml to use cmake for vs-build job
Teach .github/workflows/main.yml to use CMake for VS builds.

Modified the vs-test step to match windows-test step. This speeds
up the vs-test. Calling git-cmd from powershell and then calling git-bash
to perform the tests slows things down(factor of about 6). So git-bash
is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job
(with respect to path) absolute paths are used in the bin-wrapper
scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of
FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
added to revert to the old behaviour.

In the configuration phase CMake looks for the required libraries for
building git (eg zlib,libiconv). So we extract the libraries before we
configure.

To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
directory of script or path. So we copy the dlls before we configure.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-18 10:50:56 +02:00