<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/builtin/remote.c, branch v2.32.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.32.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.32.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-04-07T23:54:08Z</updated>
<entry>
<title>Merge branch 'ah/plugleaks'</title>
<updated>2021-04-07T23:54:08Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-04-07T23:54:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=642a40019c99a42f5f4ed4f3e52b9ab92cd75fe7'/>
<id>urn:sha1:642a40019c99a42f5f4ed4f3e52b9ab92cd75fe7</id>
<content type='text'>
Plug or annotate remaining leaks that trigger while running the
very basic set of tests.

* ah/plugleaks:
  transport: also free remote_refs in transport_disconnect()
  parse-options: don't leak alias help messages
  parse-options: convert bitfield values to use binary shift
  init-db: silence template_dir leak when converting to absolute path
  init: remove git_init_db_config() while fixing leaks
  worktree: fix leak in dwim_branch()
  clone: free or UNLEAK further pointers when finished
  reset: free instead of leaking unneeded ref
  symbolic-ref: don't leak shortened refname in check_symref()
</content>
</entry>
<entry>
<title>transport: also free remote_refs in transport_disconnect()</title>
<updated>2021-03-21T21:39:10Z</updated>
<author>
<name>Andrzej Hunt</name>
<email>ajrhunt@google.com</email>
</author>
<published>2021-03-21T16:58:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=68ffe095a25b4aba1d6aa1386318ddc8dadcf8c2'/>
<id>urn:sha1:68ffe095a25b4aba1d6aa1386318ddc8dadcf8c2</id>
<content type='text'>
transport_get_remote_refs() can populate the transport struct's
remote_refs. transport_disconnect() is already responsible for most of
transport's cleanup - therefore we also take care of freeing remote_refs
there.

There are 2 locations where transport_disconnect() is called before
we're done using the returned remote_refs. This patch changes those
callsites to only call transport_disconnect() after the returned refs
are no longer being used - which is necessary to safely be able to
free remote_refs during transport_disconnect().

This commit fixes the following leak which was found while running
t0000, but is expected to also fix the same pattern of leak in all
locations that use transport_get_remote_refs():

Direct leak of 165 byte(s) in 1 object(s) allocated from:
    #0 0x49a6b2 in calloc /home/abuild/rpmbuild/BUILD/llvm-11.0.0.src/build/../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:154:3
    #1 0x9a72f2 in xcalloc /home/ahunt/oss-fuzz/git/wrapper.c:140:8
    #2 0x8ce203 in alloc_ref_with_prefix /home/ahunt/oss-fuzz/git/remote.c:867:20
    #3 0x8ce1a2 in alloc_ref /home/ahunt/oss-fuzz/git/remote.c:875:9
    #4 0x72f63e in process_ref_v2 /home/ahunt/oss-fuzz/git/connect.c:426:8
    #5 0x72f21a in get_remote_refs /home/ahunt/oss-fuzz/git/connect.c:525:8
    #6 0x979ab7 in handshake /home/ahunt/oss-fuzz/git/transport.c:305:4
    #7 0x97872d in get_refs_via_connect /home/ahunt/oss-fuzz/git/transport.c:339:9
    #8 0x9774b5 in transport_get_remote_refs /home/ahunt/oss-fuzz/git/transport.c:1388:4
    #9 0x51cf80 in cmd_clone /home/ahunt/oss-fuzz/git/builtin/clone.c:1271:9
    #10 0x4cd60d in run_builtin /home/ahunt/oss-fuzz/git/git.c:453:11
    #11 0x4cb2da in handle_builtin /home/ahunt/oss-fuzz/git/git.c:704:3
    #12 0x4ccc37 in run_argv /home/ahunt/oss-fuzz/git/git.c:771:4
    #13 0x4cac29 in cmd_main /home/ahunt/oss-fuzz/git/git.c:902:19
    #14 0x69c45e in main /home/ahunt/oss-fuzz/git/common-main.c:52:11
    #15 0x7f6a459d5349 in __libc_start_main (/lib64/libc.so.6+0x24349)

Signed-off-by: Andrzej Hunt &lt;ajrhunt@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>remote: write camel-cased *.pushRemote on rename</title>
<updated>2021-02-25T03:03:00Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-02-25T01:21:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0f1da600e6864e8b4fe97aea72a3b68c227a709c'/>
<id>urn:sha1:0f1da600e6864e8b4fe97aea72a3b68c227a709c</id>
<content type='text'>
When a remote is renamed don't change the canonical "*.pushRemote"
form to "*.pushremote". Fixes and tests for a minor bug in
923d4a5ca4f (remote rename/remove: handle branch.&lt;name&gt;.pushRemote
config values, 2020-01-27). See the preceding commit for why this does
&amp; doesn't matter.

While we're at it let's also test that we handle the "*.pushDefault"
key correctly. The code to handle that was added in
b3fd6cbf294 (remote rename/remove: gently handle remote.pushDefault
config, 2020-02-01) and does the right thing, but nothing tested that
we wrote out the canonical camel-cased form.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>remote: add camel-cased *.tagOpt key, like clone</title>
<updated>2021-02-25T03:02:58Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-02-25T01:21:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bfa9148ff7df2ee5213c6467e3410ba134591178'/>
<id>urn:sha1:bfa9148ff7df2ee5213c6467e3410ba134591178</id>
<content type='text'>
Change "git remote add" so that it adds a *.tagOpt key, and not the
lower-cased *.tagopt on "git remote add --no-tags", just as "git clone
--no-tags" would do.

This doesn't matter for anything that reads the config. It's just
prettier if we write config keys in their documented camelCase form to
user-readable config files.

When I added support for "clone -no-tags" in 0dab2468ee5 (clone: add a
--no-tags option to clone without tags, 2017-04-26) I made it use
the *.tagOpt form, but the older "git remote add" added in
111fb858654 (remote add: add a --[no-]tags option, 2010-04-20) has
been using *.tagopt all this time.

It's easy enough to add a test for this, so let's do that. We can't
use "git config -l" there, because it'll normalize the keys to their
lower-cased form. Let's add the test for "git clone" too for good
measure, not just to the "git remote" codepath we're fixing.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>config: convert multi_replace to flags</title>
<updated>2020-11-25T22:43:47Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2020-11-25T22:12:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=504ee1290e38fb1ff0d76f940b124e21ab57a99f'/>
<id>urn:sha1:504ee1290e38fb1ff0d76f940b124e21ab57a99f</id>
<content type='text'>
We will extend the flexibility of the config API. Before doing so, let's
take an existing 'int multi_replace' parameter and replace it with a new
'unsigned flags' parameter that can take multiple options as a bit field.

Update all callers that specified multi_replace to now specify the
CONFIG_FLAGS_MULTI_REPLACE flag. To add more clarity, extend the
documentation of git_config_set_multivar_in_file() including a clear
labeling of its arguments. Other config API methods in config.h require
only a change of the final parameter from 'int' to 'unsigned'.

Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ab/git-remote-exit-code'</title>
<updated>2020-11-09T22:06:26Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-11-09T22:06:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ecf95d938b390e1ee7c1df78b9ebe3a59ffd44c9'/>
<id>urn:sha1:ecf95d938b390e1ee7c1df78b9ebe3a59ffd44c9</id>
<content type='text'>
Exit codes from "git remote add" etc. were not usable by scripted
callers.

* ab/git-remote-exit-code:
  remote: add meaningful exit code on missing/existing
</content>
</entry>
<entry>
<title>Merge branch 'sb/clone-origin'</title>
<updated>2020-10-27T22:09:50Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-10-27T22:09:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=40696c67274305d6258539de5a36649cf833f712'/>
<id>urn:sha1:40696c67274305d6258539de5a36649cf833f712</id>
<content type='text'>
"git clone" learned clone.defaultremotename configuration variable
to customize what nickname to use to call the remote the repository
was cloned from.

* sb/clone-origin:
  clone: allow configurable default for `-o`/`--origin`
  clone: read new remote name from remote_name instead of option_origin
  clone: validate --origin option before use
  refs: consolidate remote name validation
  remote: add tests for add and rename with invalid names
  clone: use more conventional config/option layering
  clone: add tests for --template and some disallowed option pairs
</content>
</entry>
<entry>
<title>remote: add meaningful exit code on missing/existing</title>
<updated>2020-10-27T18:40:33Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2020-10-27T09:41:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9144ba4cf52bb0e891d7c10a331fc32c1d3e8f64'/>
<id>urn:sha1:9144ba4cf52bb0e891d7c10a331fc32c1d3e8f64</id>
<content type='text'>
Change the exit code for the likes of "git remote add/rename" to exit
with 2 if the remote in question doesn't exist, and 3 if it
does. Before we'd just die() and exit with the general 128 exit code.

This changes the output message from e.g.:

    fatal: remote origin already exists.

To:

    error: remote origin already exists.

Which I believe is a feature, since we generally use "fatal" for the
generic errors, and "error" for the more specific ones with a custom
exit code, but this part of the change may break code that already
relies on stderr parsing (not that we ever supported that...).

The motivation for this is a discussion around some code in GitLab's
gitaly which wanted to check this, and had to parse stderr to do so:
https://gitlab.com/gitlab-org/gitaly/-/merge_requests/2695

It's worth noting as an aside that a method of checking this that
doesn't rely on that is to check with "git config" whether the value
in question does or doesn't exist. That introduces a TOCTOU race
condition, but on the other hand this code (e.g. "git remote add")
already has a TOCTOU race.

We go through the config.lock for the actual setting of the config,
but the pseudocode logic is:

    read_config();
    check_config_and_arg_sanity();
    save_config();

So e.g. if a sleep() is added right after the remote_is_configured()
check in add() we'll clobber remote.NAME.url, and add another (usually
duplicate) remote.NAME.fetch entry (and other values, depending on
invocation).

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: consolidate remote name validation</title>
<updated>2020-10-01T05:09:13Z</updated>
<author>
<name>Sean Barag</name>
<email>sean@barag.org</email>
</author>
<published>2020-10-01T03:46:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f2c6fda88624370fda1fc706a0f2ceda7d50d6ab'/>
<id>urn:sha1:f2c6fda88624370fda1fc706a0f2ceda7d50d6ab</id>
<content type='text'>
In preparation for a future patch, extract from remote.c a function that
validates possible remote names so that its rules can be used
consistently in other places.

Helped-by: Derrick Stolee &lt;stolee@gmail.com&gt;
Signed-off-by: Sean Barag &lt;sean@barag.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'cs/don-t-pretend-a-failed-remote-set-head-succeeded'</title>
<updated>2020-09-22T19:36:32Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-09-22T19:36:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=39149df36426ee106367c701feb5a8c8662c9f74'/>
<id>urn:sha1:39149df36426ee106367c701feb5a8c8662c9f74</id>
<content type='text'>
"git remote set-head" that failed still said something that hints
the operation went through, which was misleading.

* cs/don-t-pretend-a-failed-remote-set-head-succeeded:
  remote: don't show success message when set-head fails
</content>
</entry>
</feed>
