<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/builtin/check-ref-format.c, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-01-17T21:30:03Z</updated>
<entry>
<title>builtin: send usage() help text to standard output</title>
<updated>2025-01-17T21:30:03Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-01-16T21:35:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f66d1423f528403a33e8984f765801deb1b9cb97'/>
<id>urn:sha1:f66d1423f528403a33e8984f765801deb1b9cb97</id>
<content type='text'>
Using the show_usage_and_exit_if_asked() helper we introduced
earlier, fix callers of usage() that want to show the help text when
explicitly asked by the end-user.  The help text now goes to the
standard output stream for them.

These are the bog standard "if we got only '-h', then that is a
request for help" callers.  Their

	if (argc == 2 &amp;&amp; !strcmp(argv[1], "-h"))
		usage(message);

are simply replaced with

	show_usage_and_exit_if_asked(argc, argv, message);

With this, the built-ins tested by t0012 all send their help text to
their standard output stream, so the check in t0012 that was half
tightened earlier is now fully tightened to insist on standard error
stream being empty.

Acked-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: drop strbuf_ prefix from helpers</title>
<updated>2024-12-03T03:38:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-12-03T02:32:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=93e5e048f84138a632b239632c9b45ae238cdf1c'/>
<id>urn:sha1:93e5e048f84138a632b239632c9b45ae238cdf1c</id>
<content type='text'>
The helper functions (strbuf_branchname, strbuf_check_branch_ref,
and strbuf_check_tag_ref) are about handling branch and tag names,
and it is a non-essential fact that these functions use strbuf to
hold these names.  Rename them to make it clarify that these are
more about "ref".

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin: remove USE_THE_REPOSITORY for those without the_repository</title>
<updated>2024-09-13T21:33:30Z</updated>
<author>
<name>John Cai</name>
<email>johncai86@gmail.com</email>
</author>
<published>2024-09-13T21:16:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=49d2434664b5b4cb44460d16578039fcd198c40a'/>
<id>urn:sha1:49d2434664b5b4cb44460d16578039fcd198c40a</id>
<content type='text'>
For builtins that do not operate on a repository, remove
the #define USE_THE_REPOSITORY.

Signed-off-by: John Cai &lt;johncai86@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.h</title>
<updated>2024-09-13T21:32:24Z</updated>
<author>
<name>John Cai</name>
<email>johncai86@gmail.com</email>
</author>
<published>2024-09-13T21:16:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=03eae9afb447ad4add2f18a1adb3589f050d596f'/>
<id>urn:sha1:03eae9afb447ad4add2f18a1adb3589f050d596f</id>
<content type='text'>
Instead of including USE_THE_REPOSITORY_VARIABLE by default on every
builtin, remove it from builtin.h and add it to all the builtins that
include builtin.h (by definition, that means all builtins/*.c).

Also, remove the include statement for repository.h since it gets
brought in through builtin.h.

The next step will be to migrate each builtin
from having to use the_repository.

Signed-off-by: John Cai &lt;johncai86@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin: add a repository parameter for builtin functions</title>
<updated>2024-09-13T21:27:08Z</updated>
<author>
<name>John Cai</name>
<email>johncai86@gmail.com</email>
</author>
<published>2024-09-13T21:16:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9b1cb5070ffb581798763eaee85cec10da969e90'/>
<id>urn:sha1:9b1cb5070ffb581798763eaee85cec10da969e90</id>
<content type='text'>
In order to reduce the usage of the global the_repository, add a
parameter to builtin functions that will get passed a repository
variable.

This commit uses UNUSED on most of the builtin functions, as subsequent
commits will modify the actual builtins to pass the repository parameter
down.

Signed-off-by: John Cai &lt;johncai86@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>cache.h: remove this no-longer-used header</title>
<updated>2023-06-21T20:39:53Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-05-16T06:33:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bc5c5ec0446895f5c4139cd470066beb3c4ac6d5'/>
<id>urn:sha1:bc5c5ec0446895f5c4139cd470066beb3c4ac6d5</id>
<content type='text'>
Since this header showed up in some places besides just #include
statements, update/clean-up/remove those other places as well.

Note that compat/fsmonitor/fsm-path-utils-darwin.c previously got
away with violating the rule that all files must start with an include
of git-compat-util.h (or a short-list of alternate headers that happen
to include it first).  This change exposed the violation and caused it
to stop building correctly; fix it by having it include
git-compat-util.h first, as per policy.

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>Merge branch 'en/header-split-cleanup'</title>
<updated>2023-04-06T20:38:31Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-04-06T20:38:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6047b28eb7e1a0b0061c5310034f7b5683ea401a'/>
<id>urn:sha1:6047b28eb7e1a0b0061c5310034f7b5683ea401a</id>
<content type='text'>
Split key function and data structure definitions out of cache.h to
new header files and adjust the users.

* en/header-split-cleanup:
  csum-file.h: remove unnecessary inclusion of cache.h
  write-or-die.h: move declarations for write-or-die.c functions from cache.h
  treewide: remove cache.h inclusion due to setup.h changes
  setup.h: move declarations for setup.c functions from cache.h
  treewide: remove cache.h inclusion due to environment.h changes
  environment.h: move declarations for environment.c functions from cache.h
  treewide: remove unnecessary includes of cache.h
  wrapper.h: move declarations for wrapper.c functions from cache.h
  path.h: move function declarations for path.c functions from cache.h
  cache.h: remove expand_user_path()
  abspath.h: move absolute path functions from cache.h
  environment: move comment_line_char from cache.h
  treewide: remove unnecessary cache.h inclusion from several sources
  treewide: remove unnecessary inclusion of gettext.h
  treewide: be explicit about dependence on gettext.h
  treewide: remove unnecessary cache.h inclusion from a few headers
</content>
</entry>
<entry>
<title>builtins: annotate always-empty prefix parameters</title>
<updated>2023-03-28T21:11:24Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2023-03-28T20:55:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=79156913774ef7c5f72264067e0764a1447a1bb3'/>
<id>urn:sha1:79156913774ef7c5f72264067e0764a1447a1bb3</id>
<content type='text'>
It's usually a bad idea for a builtin's cmd_foo() to ignore the "prefix"
argument it gets, as it needs to prepend that string when accessing any
paths given by the user.

But if a builtin does not ask for the git wrapper to run repository
setup (via the RUN_SETUP or RUN_SETUP_GENTLY flags), then we know the
prefix will always be NULL (it is adjusting for the chdir() done during
repo setup, but there cannot be one if we did not set up the repo). In
those cases it's OK to ignore "prefix", but it's worth annotating for a
few reasons:

  1. It serves as documentation to somebody reading the code about what
     we expect.

  2. If the flags in git.c ever change, the run-time assertion may help
     detect the problem (though only if the command is run from a
     subdirectory of the repository).

  3. It notes to the compiler that we are OK ignoring "prefix". In
     particular, this silences -Wunused-parameter. It _could_ also help
     the compiler generate better code (because it will know the prefix
     is NULL), but in practice this is quite unlikely to matter.

Note that I've only added this annotation to commands which triggered
-Wunused-parameter. It would be correct to add it to any builtin which
doesn't ask for RUN_SETUP, but most of the rest of them do the sensible
thing with "prefix" by passing it to parse_options(). So they're much
more likely to just work if they ever switched to RUN_SETUP, and aren't
worth annotating.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>setup.h: move declarations for setup.c functions from cache.h</title>
<updated>2023-03-21T17:56:54Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-03-21T06:26:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e38da487cc50ce4b5b48085eebcab8268c541579'/>
<id>urn:sha1:e38da487cc50ce4b5b48085eebcab8268c541579</id>
<content type='text'>
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>check-ref-format: fix trivial memory leak</title>
<updated>2022-07-01T18:43:42Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-07-01T10:42:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=99b6c45d8f846ed055ba814d985084733d36dabc'/>
<id>urn:sha1:99b6c45d8f846ed055ba814d985084733d36dabc</id>
<content type='text'>
Fix a memory leak in "git check-ref-format" that's been present in the
code in one form or another since 38eedc634bc (git check-ref-format
--print, 2009-10-12), the code got substantially refactored in
cfbe22f03f9 (check-ref-format: handle subcommands in separate
functions, 2010-08-05).

As a result we can mark a test as passing with SANITIZE=leak using
"TEST_PASSES_SANITIZE_LEAK=true".

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>
</feed>
