<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/advice.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-09-17T00:59:53Z</updated>
<entry>
<title>color: use git_colorbool enum type to store colorbools</title>
<updated>2025-09-17T00:59:53Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2025-09-16T23:13:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e9330ae4b820147c98e723399e9438c8bee60a80'/>
<id>urn:sha1:e9330ae4b820147c98e723399e9438c8bee60a80</id>
<content type='text'>
We traditionally used "int" to store and pass around the values defined
by "enum git_colorbool" (which were originally just #define macros).
Using an int doesn't produce incorrect results, but using the actual
enum makes the intent of the code more clear.

It would be nice if the compiler could catch cases where we used the
enum and an int interchangeably, since it's very easy to accidentally
check the boolean true/false of a colorbool like:

  if (branch_use_color)

This is wrong because GIT_COLOR_UNKNOWN and GIT_COLOR_AUTO evaluate to
true in C, even though we may ultimately decide not to use color. But C
is pretty happy to convert between ints and enums (even with various
-Wenum-* warnings). So this sadly doesn't protect us from such mistakes,
but it hopefully does make the code easier to read.

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>color: use GIT_COLOR_* instead of numeric constants</title>
<updated>2025-09-16T20:37:03Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2025-09-16T20:13:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3c3e9b830383364316ba07730aecbc47a680b513'/>
<id>urn:sha1:3c3e9b830383364316ba07730aecbc47a680b513</id>
<content type='text'>
Long ago Git's decision to show color for a subsytem was stored in a
tri-state variable: it could be true (1), false (0), or unknown (-1).
But since daa0c3d971 (color: delay auto-color decision until point of
use, 2011-08-17) we want to carry around a new state, "auto", which
bases the decision on the tty-ness of stdout (rather than collapsing
that "auto" state to a true/false immediately).

That commit introduced a set of GIT_COLOR_* defines to represent each
state: UNKNOWN, ALWAYS, NEVER, and AUTO. But it only used the AUTO
value, and left alone code using bare 0/1/-1 values. And of course since
then we've grown many new spots that use those bare values.

Let's switch all of these to use the named constants. That should make
the code a bit easier to read, as it is more obvious that we're
representing a color decision.

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>advice: allow disabling default branch name advice</title>
<updated>2025-03-25T23:09:28Z</updated>
<author>
<name>Justin Tobler</name>
<email>jltobler@gmail.com</email>
</author>
<published>2025-03-25T00:51:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ec0f362e869fc74c3c9f011ae2097daa1c938833'/>
<id>urn:sha1:ec0f362e869fc74c3c9f011ae2097daa1c938833</id>
<content type='text'>
The default branch name advice message is displayed when
`repo_default_branch_name()` is invoked and the `init.defaultBranch`
config is not set. In this scenario, the advice message is always shown
even if the `--no-advice` option is used.

Adapt `repo_default_branch_name()` to allow the default branch name
advice message to be disabled with the `--no-advice` option and
corresponding configuration.

Signed-off-by: Justin Tobler &lt;jltobler@gmail.com&gt;
Acked-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ps/build-sign-compare'</title>
<updated>2024-12-23T17:32:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-12-23T17:32:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4156b6a741c7fb15a4eccb320612fb6e453f439c'/>
<id>urn:sha1:4156b6a741c7fb15a4eccb320612fb6e453f439c</id>
<content type='text'>
Start working to make the codebase buildable with -Wsign-compare.

* ps/build-sign-compare:
  t/helper: don't depend on implicit wraparound
  scalar: address -Wsign-compare warnings
  builtin/patch-id: fix type of `get_one_patchid()`
  builtin/blame: fix type of `length` variable when emitting object ID
  gpg-interface: address -Wsign-comparison warnings
  daemon: fix type of `max_connections`
  daemon: fix loops that have mismatching integer types
  global: trivial conversions to fix `-Wsign-compare` warnings
  pkt-line: fix -Wsign-compare warning on 32 bit platform
  csum-file: fix -Wsign-compare warning on 32-bit platform
  diff.h: fix index used to loop through unsigned integer
  config.mak.dev: drop `-Wno-sign-compare`
  global: mark code units that generate warnings with `-Wsign-compare`
  compat/win32: fix -Wsign-compare warning in "wWinMain()"
  compat/regex: explicitly ignore "-Wsign-compare" warnings
  git-compat-util: introduce macros to disable "-Wsign-compare" warnings
</content>
</entry>
<entry>
<title>Merge branch 'bf/fetch-set-head-config'</title>
<updated>2024-12-19T18:58:30Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-12-19T18:58:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a1f34d5955035dc64f2e25da0ba2cc0a0c73c21c'/>
<id>urn:sha1:a1f34d5955035dc64f2e25da0ba2cc0a0c73c21c</id>
<content type='text'>
"git fetch" honors "remote.&lt;remote&gt;.followRemoteHEAD" settings to
tweak the remote-tracking HEAD in "refs/remotes/&lt;remote&gt;/HEAD".

* bf/fetch-set-head-config:
  remote set-head: set followRemoteHEAD to "warn" if "always"
  fetch set_head: add warn-if-not-$branch option
  fetch set_head: move warn advice into advise_if_enabled
  fetch: add configuration for set_head behaviour
</content>
</entry>
<entry>
<title>global: trivial conversions to fix `-Wsign-compare` warnings</title>
<updated>2024-12-06T11:20:04Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=80c9e70ebe871f0826bc101142c66ff783405100'/>
<id>urn:sha1:80c9e70ebe871f0826bc101142c66ff783405100</id>
<content type='text'>
We have a bunch of loops which iterate up to an unsigned boundary using
a signed index, which generates warnigs because we compare a signed and
unsigned value in the loop condition. Address these sites for trivial
cases and enable `-Wsign-compare` warnings for these code units.

This patch only adapts those code units where we can drop the
`DISABLE_SIGN_COMPARE_WARNINGS` macro in the same step.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>global: mark code units that generate warnings with `-Wsign-compare`</title>
<updated>2024-12-06T11:20:02Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=41f43b8243f42b9df2e98be8460646d4c0100ad3'/>
<id>urn:sha1:41f43b8243f42b9df2e98be8460646d4c0100ad3</id>
<content type='text'>
Mark code units that generate warnings with `-Wsign-compare`. This
allows for a structured approach to get rid of all such warnings over
time in a way that can be easily measured.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>advice: suggest using subcommand "git config set"</title>
<updated>2024-12-06T02:24:21Z</updated>
<author>
<name>Bence Ferdinandy</name>
<email>bence@ferdinandy.com</email>
</author>
<published>2024-12-05T12:21:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6c397d01046251b4d26f2aded07a695ada196962'/>
<id>urn:sha1:6c397d01046251b4d26f2aded07a695ada196962</id>
<content type='text'>
The advice message currently suggests using "git config advice..." to
disable advice messages, but since

00bbdde141 (builtin/config: introduce "set" subcommand, 2024-05-06)

we have the "set" subcommand for config. Since using the subcommand is
more in-line with the modern interface, any advice should be promoting
its usage. Change the disable advice message to use the subcommand
instead. Change all uses of "git config advice" in the tests to use the
subcommand.

Signed-off-by: Bence Ferdinandy &lt;bence@ferdinandy.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fetch set_head: move warn advice into advise_if_enabled</title>
<updated>2024-12-05T17:59:16Z</updated>
<author>
<name>Bence Ferdinandy</name>
<email>bence@ferdinandy.com</email>
</author>
<published>2024-12-05T12:16:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ad739f525eec917198887055f1a815e78d7c66be'/>
<id>urn:sha1:ad739f525eec917198887055f1a815e78d7c66be</id>
<content type='text'>
Advice about what to do when getting a warning is typed out explicitly
twice and is printed as regular output. The output is also tested for.
Extract the advice message into a single place and use a wrapper
function, so if later the advice is made more chatty the signature only
needs to be changed in once place. Remove the testing for the advice
output in the tests.

Signed-off-by: Bence Ferdinandy &lt;bence@ferdinandy.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ds/advice-sparse-index-expansion'</title>
<updated>2024-07-16T18:18:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-07-16T18:18:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5d71940ddab3196e071dab466d456fd0297056d9'/>
<id>urn:sha1:5d71940ddab3196e071dab466d456fd0297056d9</id>
<content type='text'>
A new warning message is issued when a command has to expand a
sparse index to handle working tree cruft that are outside of the
sparse checkout.

* ds/advice-sparse-index-expansion:
  advice: warn when sparse index expands
</content>
</entry>
</feed>
