<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/add-interactive.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-03-19T22:25:39Z</updated>
<entry>
<title>Merge branch 'rs/xcalloc-takes-nelem-first'</title>
<updated>2021-03-19T22:25:39Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-03-19T22:25:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bfcc6e2a68b95ee71fc606a2e3917af78f1130f9'/>
<id>urn:sha1:bfcc6e2a68b95ee71fc606a2e3917af78f1130f9</id>
<content type='text'>
Code cleanup.

* rs/xcalloc-takes-nelem-first:
  fix xcalloc() argument order
</content>
</entry>
<entry>
<title>use CALLOC_ARRAY</title>
<updated>2021-03-14T00:00:09Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2021-03-13T16:17:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ca56dadb4b65ccaeab809d80db80a312dc00941a'/>
<id>urn:sha1:ca56dadb4b65ccaeab809d80db80a312dc00941a</id>
<content type='text'>
Add and apply a semantic patch for converting code that open-codes
CALLOC_ARRAY to use it instead.  It shortens the code and infers the
element size automatically.

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>fix xcalloc() argument order</title>
<updated>2021-03-08T17:45:04Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2021-03-06T11:26:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1'/>
<id>urn:sha1:241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1</id>
<content type='text'>
Pass the number of elements first and ther size second, as expected
by xcalloc().  Provide a semantic patch, which was actually used to
generate the rest of this patch.

The semantic patch would generate flip-flop diffs if both arguments
are sizeofs.  We don't have such a case, and it's hard to imagine
the usefulness of such an allocation.  If it ever occurs then we
could deal with it by duplicating the rule in the semantic patch to
make it cancel itself out, or we could change the code to use
CALLOC_ARRAY.

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/add-i-color-fix'</title>
<updated>2020-12-08T23:11:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-12-08T23:11:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e0d25686e33396621c484ce5c936c9e49874d8d8'/>
<id>urn:sha1:e0d25686e33396621c484ce5c936c9e49874d8d8</id>
<content type='text'>
"git add -i" failed to honor custom colors configured to show
patches, which has been corrected.

* js/add-i-color-fix:
  add -i: verify in the tests that colors can be overridden
  add -p: prefer color.diff.context over color.diff.plain
  add -i (Perl version): color header to match the C version
  add -i (built-in): use the same indentation as the Perl version
  add -p (built-in): do not color the progress indicator separately
  add -i (built-in): use correct names to load color.diff.* config
  add -i (built-in): prevent the `reset` "color" from being configured
  add -i: use `reset_color` consistently
  add -p (built-in): imitate `xdl_format_hunk_hdr()` generating hunk headers
  add -i (built-in): send error messages to stderr
  add -i (built-in): do show an error message for incorrect inputs
</content>
</entry>
<entry>
<title>add -p: prefer color.diff.context over color.diff.plain</title>
<updated>2020-11-16T23:59:02Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-11-16T16:08:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=890b68b2637fcadb4b1017ecf50248d616c96b8b'/>
<id>urn:sha1:890b68b2637fcadb4b1017ecf50248d616c96b8b</id>
<content type='text'>
Git's diff machinery allows users to override the colors to use in
diffs, even the plain-colored context lines. As of 8dbf3eb6850 (diff.h:
rename DIFF_PLAIN color slot to DIFF_CONTEXT, 2015-05-27), the preferred
name of the config setting is `color.diff.context`, although Git still
allows `color.diff.plain`.

In the context of `git add -p`, this logic is a bit hard to replicate:
`git_diff_basic_config()` reads all config values sequentially and if it
sees _any_ `color.diff.context` or `color.diff.plain`, it accepts the
new color. The Perl version of `git add -p` needs to go through `git
config --get-color`, though, which allows only one key to be specified.
The same goes for the built-in version of `git add -p`, which has to go
through `repo_config_get_value()`.

The best we can do here is to look for `.context` and if none is found,
fall back to looking for `.plain`, and if still not found, fall back to
the hard-coded default (which in this case is simply the empty string,
as context lines are typically rendered without colored).

This still leads to inconsistencies when both config names are used: the
initial diff will be colored by the diff machinery. Once edited by a
user, a hunk has to be re-colored by `git add -p`, though, which would
then use the other setting to color the context lines.

In practice, this is not _all_ that bad. The `git config` manual says
this in the `color.diff.&lt;slot&gt;`:

	`context` (context text - `plain` is a historical synonym)

We should therefore assume that users use either one or the other, but
not both names. Besides, it is relatively uncommon to look at a hunk
after editing it because it is immediately staged by default.

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>add -i (built-in): use the same indentation as the Perl version</title>
<updated>2020-11-16T23:59:02Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-11-16T16:08:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=afae3cb6b036e8fb218e5699c8ad3c18b6d4b992'/>
<id>urn:sha1:afae3cb6b036e8fb218e5699c8ad3c18b6d4b992</id>
<content type='text'>
When copying the spaces used to indent non-flat lists in `git add -i`,
one space was appended by mistake. This makes the output of the built-in
version of `git add -i` inconsistent with the Perl version. Let's adjust
the built-in version to produce the same output as the Perl version.

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>add -i (built-in): use correct names to load color.diff.* config</title>
<updated>2020-11-11T17:07:53Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-11-11T12:28:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=25d9e5ccba3fbcdb4109b6b2b2a7e721b0af6d77'/>
<id>urn:sha1:25d9e5ccba3fbcdb4109b6b2b2a7e721b0af6d77</id>
<content type='text'>
The builtin version of add-interactive mistakenly loads diff colors from
color.interactive.* instead of color.diff.*. It also accidentally spells
`frag` as `fraginfo`.

Let's fix that.

Note also that we don't respect the historical `diff.color.*`. The perl
version never did, and those have been deprecated since 2007.

Reported-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Co-authored-by: Jeff King &lt;peff@peff.net&gt;
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>add -i (built-in): prevent the `reset` "color" from being configured</title>
<updated>2020-11-11T17:07:53Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-11-11T12:28:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c62cd1720f5c9cf57955a78576ba7e862b7352e6'/>
<id>urn:sha1:c62cd1720f5c9cf57955a78576ba7e862b7352e6</id>
<content type='text'>
The Perl version of that command sneakily uses `git config --get-color`
to figure out the ANSI sequence to reset the color, but passes the empty
string and therefore cannot actually match any config entry.

This was missed when re-implementing the command as a built-in command.
Let's fix this, preventing the `reset` sequence from being overridden
via the config.

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>add -i (built-in): send error messages to stderr</title>
<updated>2020-11-11T01:00:15Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-11-10T23:42:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cb581b16ef947a00f8e83f17c9fbe5b5aeed1d65'/>
<id>urn:sha1:cb581b16ef947a00f8e83f17c9fbe5b5aeed1d65</id>
<content type='text'>
The Perl version of that command already does that since a301973641f
(add -p: print errors in separate color, 2009-02-05). The built-in
version's development started by reimplementing the initial version from
5cde71d64af (git-add --interactive, 2006-12-10) for simplicity, though,
which still printed error messages to stdout.

Let's fix that by imitating the Perl version's behavior in the built-in
version of that command.

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>add -i (built-in): do show an error message for incorrect inputs</title>
<updated>2020-11-11T01:00:15Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-11-10T23:42:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d34e4502fa540ed0654df7dd75b3689c48015f1a'/>
<id>urn:sha1:d34e4502fa540ed0654df7dd75b3689c48015f1a</id>
<content type='text'>
There is a neat feature in `git add -i` where it allows users to select
items via unique prefixes.

In the built-in version of `git add -i`, we specifically sort the items
(unless they are already sorted) and then perform a binary search to
figure out whether the input constitutes a unique prefix. Unfortunately,
by mistake this code misidentifies matches even if the input string is
not actually a prefix of any item.

For example, in the initial menu, where there is a `status` and an
`update` command, the input `tadaa` was mistaken as a prefix of
`update`.

Let's fix this by looking a bit closer whether the input is actually a
prefix of the item at the found insert index.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
