<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/read-cache.c, branch v2.30.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.30.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.30.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-01-06T21:53:32Z</updated>
<entry>
<title>read-cache: try not to peek into `struct {lock_,temp}file`</title>
<updated>2021-01-06T21:53:32Z</updated>
<author>
<name>Martin Ågren</name>
<email>martin.agren@gmail.com</email>
</author>
<published>2021-01-05T19:23:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6a8c89d053059b97adb846fce1d22f6d7704c56a'/>
<id>urn:sha1:6a8c89d053059b97adb846fce1d22f6d7704c56a</id>
<content type='text'>
Similar to the previous commits, try to avoid peeking into the `struct
lock_file`. We also have some `struct tempfile`s -- let's avoid looking
into those as well.

Note that `do_write_index()` takes a tempfile and that when we call it,
we either have a tempfile which we can easily hand down, or we have a
lock file, from which we need to somehow obtain the internal tempfile.
So we need to leave that one instance of peeking-into. Nevertheless,
this commit leaves us not relying on exactly how the path of the
tempfile / lock file is stored internally.

Signed-off-by: Martin Ågren &lt;martin.agren@gmail.com&gt;
Reviewed-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>read-cache: fix mem-pool allocation for multi-threaded index loading</title>
<updated>2020-09-06T19:34:12Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2020-09-04T17:33:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bcd2c5eedecf473fa6b15ebda798ce54bb3c75ea'/>
<id>urn:sha1:bcd2c5eedecf473fa6b15ebda798ce54bb3c75ea</id>
<content type='text'>
44c7e1a7e0 (mem-pool: use more standard initialization and finalization,
2020-08-15) moved the allocation of the mem-pool structure to callers.
It also added an allocation to load_cache_entries_threaded(), but for an
unrelated mem-pool.  Fix that by allocating the correct one instead --
the one that is initialized two lines later.

Reported-by: Sandor Bodo-Merle &lt;sbodomerle@gmail.com&gt;
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Reviewed-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mem-pool: use more standard initialization and finalization</title>
<updated>2020-08-18T19:16:06Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2020-08-15T17:37:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=44c7e1a7e08c0863c4156869364cb5751a23784e'/>
<id>urn:sha1:44c7e1a7e08c0863c4156869364cb5751a23784e</id>
<content type='text'>
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(&amp;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 &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>read-cache: remove bogus shortcut</title>
<updated>2020-07-16T17:42:52Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2020-07-16T17:11:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a98f7fb36679a98caa0b804d567b6b2fa8f8ef41'/>
<id>urn:sha1:a98f7fb36679a98caa0b804d567b6b2fa8f8ef41</id>
<content type='text'>
has_dir_name() has some optimizations for the case where entries are
added to an index in the correct order.  They kick in if the new entry
sorts after the last one.  One of them exits early if the last entry has
a longer name than the directory of the new entry.  Here's its comment:

/*
 * The directory prefix lines up with part of
 * a longer file or directory name, but sorts
 * after it, so this sub-directory cannot
 * collide with a file.
 *
 * last: xxx/yy-file (because '-' sorts before '/')
 * this: xxx/yy/abc
 */

However, a file named xxx/yy would be sorted before xxx/yy-file because
'-' sorts after NUL, so the length check against the last entry is not
sufficient to rule out a collision.  Remove it.

Reported-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Suggested-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'js/mingw-loosen-overstrict-tree-entry-checks'</title>
<updated>2020-01-10T22:45:27Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-01-10T22:45:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1cf4836865670cadc5d72dc36cdececcb5b32a77'/>
<id>urn:sha1:1cf4836865670cadc5d72dc36cdececcb5b32a77</id>
<content type='text'>
Further tweak to a "no backslash in indexed paths" for Windows port
we applied earlier.

* js/mingw-loosen-overstrict-tree-entry-checks:
  mingw: safeguard better against backslashes in file names
</content>
</entry>
<entry>
<title>mingw: safeguard better against backslashes in file names</title>
<updated>2020-01-10T20:29:07Z</updated>
<author>
<name>Johannes Schindelin via GitGitGadget</name>
<email>gitgitgadget@gmail.com</email>
</author>
<published>2020-01-09T13:30:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=49e268e23e313e8c6b009cd8ebbbaae4316cf6cc'/>
<id>urn:sha1:49e268e23e313e8c6b009cd8ebbbaae4316cf6cc</id>
<content type='text'>
In 224c7d70fa1 (mingw: only test index entries for backslashes, not tree
entries, 2019-12-31), we relaxed the check for backslashes in tree
entries to check only index entries.

However, the code change was incorrect: it was added to
`add_index_entry_with_check()`, not to `add_index_entry()`, so under
certain circumstances it was possible to side-step the protection.

Besides, the description of that commit purported that all index entries
would be checked when in fact they were only checked when being added to
the index (there are code paths that do not do that, constructing
"transient" index entries).

In any case, it was pointed out in one insightful review at
https://github.com/git-for-windows/git/pull/2437#issuecomment-566771835
that it would be a much better idea to teach `verify_path()` to perform
the check for a backslash. This is safer, even if it comes with two
notable drawbacks:

- `verify_path()` cannot say _what_ is wrong with the path, therefore
  the user will no longer be told that there was a backslash in the
  path, only that the path was invalid.

- The `git apply` command also calls the `verify_path()` function, and
  might have been able to handle Windows-style paths (i.e. with
  backslashes instead of forward slashes). This will no longer be
  possible unless the user (temporarily) sets `core.protectNTFS=false`.

Note that `git add &lt;windows-path&gt;` will _still_ work because
`normalize_path_copy_len()` will convert the backslashes to forward
slashes before hitting the code path that creates an index entry.

The clear advantage is that `verify_path()`'s purpose is to check the
validity of the file name, therefore we naturally tap into all the code
paths that need safeguarding, also implicitly into future code paths.

The benefits of that approach outweigh the downsides, so let's move the
check from `add_index_entry_with_check()` to `verify_path()`.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'js/mingw-loosen-overstrict-tree-entry-checks'</title>
<updated>2020-01-06T22:17:50Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-01-06T22:17:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a578ef9e63a2f53ada00beb9d75b23e68061b331'/>
<id>urn:sha1:a578ef9e63a2f53ada00beb9d75b23e68061b331</id>
<content type='text'>
An earlier update to Git for Windows declared that a tree object is
invalid if it has a path component with backslash in it, which was
overly strict, which has been corrected.  The only protection the
Windows users need is to prevent such path (or any path that their
filesystem cannot check out) from entering the index.

* js/mingw-loosen-overstrict-tree-entry-checks:
  mingw: only test index entries for backslashes, not tree entries
</content>
</entry>
<entry>
<title>mingw: only test index entries for backslashes, not tree entries</title>
<updated>2020-01-02T20:56:08Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-12-31T22:53:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=224c7d70fa14ed44d8e7e3ce1e165e05b7b23725'/>
<id>urn:sha1:224c7d70fa14ed44d8e7e3ce1e165e05b7b23725</id>
<content type='text'>
During a clone of a repository that contained a file with a backslash in
its name in the past, as of v2.24.1(2), Git for Windows prints errors
like this:

	error: filename in tree entry contains backslash: '\'

The idea is to prevent Git from even trying to write files with
backslashes in their file names: while these characters are valid in
file names on other platforms, on Windows it is interpreted as directory
separator (which would obviously lead to ambiguities, e.g. when there is
a file `a\b` and there is also a file `a/b`).

Arguably, this is the wrong layer for that error: As long as the user
never checks out the files whose names contain backslashes, there should
not be any problem in the first place.

So let's loosen the requirements: we now leave tree entries with
backslashes in their file names alone, but we do require any entries
that are added to the Git index to contain no backslashes on Windows.

Note: just as before, the check is guarded by `core.protectNTFS` (to
allow overriding the check by toggling that config setting), and it
is _only_ performed on Windows, as the backslash is not a directory
separator elsewhere, even when writing to NTFS-formatted volumes.

An alternative approach would be to try to prevent creating files with
backslashes in their file names. However, that comes with its own set of
problems. For example, `git config -f C:\ProgramData\Git\config ...` is
a very valid way to specify a custom config location, and we obviously
do _not_ want to prevent that. Therefore, the approach chosen in this
patch would appear to be better.

This addresses https://github.com/git-for-windows/git/issues/2435

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Sync with Git 2.24.1</title>
<updated>2019-12-10T06:17:55Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-12-10T06:17:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7034cd094bda4edbcdff7fad1a28fcaaf9b9a040'/>
<id>urn:sha1:7034cd094bda4edbcdff7fad1a28fcaaf9b9a040</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Sync with 2.23.1</title>
<updated>2019-12-06T15:31:39Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-12-04T22:09:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=67af91c47a6672b99e1f742123415f96cbafd19a'/>
<id>urn:sha1:67af91c47a6672b99e1f742123415f96cbafd19a</id>
<content type='text'>
* maint-2.23: (44 commits)
  Git 2.23.1
  Git 2.22.2
  Git 2.21.1
  mingw: sh arguments need quoting in more circumstances
  mingw: fix quoting of empty arguments for `sh`
  mingw: use MSYS2 quoting even when spawning shell scripts
  mingw: detect when MSYS2's sh is to be spawned more robustly
  t7415: drop v2.20.x-specific work-around
  Git 2.20.2
  t7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x
  Git 2.19.3
  Git 2.18.2
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  ...
</content>
</entry>
</feed>
