<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git-add--interactive.perl, branch gitk-resize-error</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=gitk-resize-error</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=gitk-resize-error'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2021-11-28T23:14:09Z</updated>
<entry>
<title>add -p: avoid use of undefined $key when ReadKey -&gt; EOF</title>
<updated>2021-11-28T23:14:09Z</updated>
<author>
<name>Carlo Marcelo Arenas Belón</name>
<email>carenas@gmail.com</email>
</author>
<published>2021-11-28T17:49:03Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=fc8a8126df822f82ab65135296b5bd569af276c1'/>
<id>urn:sha1:fc8a8126df822f82ab65135296b5bd569af276c1</id>
<content type='text'>
b5cc003253 (add -i: ignore terminal escape sequences, 2011-05-17)
add an additional check to the original code to better handle keys
for escape sequences, but failed to account for the possibility
the first ReadKey call returned undef (ex: stdin closes) and that
was being handled fine by the original code in ca6ac7f135 (add -p:
prompt for single characters, 2009-02-05)

Add a test for undefined and encapsulate the loop and the original
print that relied on it within it.

After this, the following command (in a suitable repository state)
wouldn't print any error:

  $ git -c interactive.singleKey add -p &lt;/dev/null

Signed-off-by: Carlo Marcelo Arenas Belón &lt;carenas@gmail.com&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='http://git.kilabit.info/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='http://git.kilabit.info/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 (Perl version): color header to match the C 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:30Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=0cb8939fb6795c9f94f9184935b6a83aebdfc47a'/>
<id>urn:sha1:0cb8939fb6795c9f94f9184935b6a83aebdfc47a</id>
<content type='text'>
Both versions of `add -i` indent non-flat lists by five spaces. However
when using color the C version prints these spaces after the ANSI color
codes whereas the Perl version prints them before the color codes.
Change the Perl version to match the C version to allow for introducing
a test that verifies that both versions produce the exact same output.

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 'dl/checkout-p-merge-base'</title>
<updated>2020-10-27T22:09:51Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-10-27T22:09:50Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=f3cfeb3078ce4af0ac764515795f7e0849a88931'/>
<id>urn:sha1:f3cfeb3078ce4af0ac764515795f7e0849a88931</id>
<content type='text'>
"git checkout -p A...B [-- &lt;path&gt;]" did not work, even though the
same command without "-p" correctly used the merge-base between
commits A and B.

* dl/checkout-p-merge-base:
  t2016: add a NEEDSWORK about the PERL prerequisite
  add-patch: add NEEDSWORK about comparing commits
  Doc: document "A...B" form for &lt;tree-ish&gt; in checkout and switch
  builtin/checkout: fix `git checkout -p HEAD...` bug
</content>
</entry>
<entry>
<title>add-patch: add NEEDSWORK about comparing commits</title>
<updated>2020-10-07T16:49:06Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2020-10-07T07:56:17Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=f82a9e517fc063bb97063e4df2cdde2fd1f7ffbe'/>
<id>urn:sha1:f82a9e517fc063bb97063e4df2cdde2fd1f7ffbe</id>
<content type='text'>
The two versions of add-patch has special-casing for the literal
revision "HEAD". However, we want to handle other ways of saying "HEAD"
in the same way.[0] Add a NEEDSWORK to the add-patch code that does this
so that it can be addressed later.

[0]: https://lore.kernel.org/git/xmqqsgat7ttf.fsf@gitster.c.googlers.com/

Signed-off-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'pw/add-p-edit-ita-path'</title>
<updated>2020-09-22T19:36:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-09-22T19:36:28Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=458205ff0f43f8f0ffe70aa7f06d314fcce25809'/>
<id>urn:sha1:458205ff0f43f8f0ffe70aa7f06d314fcce25809</id>
<content type='text'>
"add -p" now allows editing paths that were only added in intent.

* pw/add-p-edit-ita-path:
  add -p: fix editing of intent-to-add paths
</content>
</entry>
<entry>
<title>add -p: fix editing of intent-to-add paths</title>
<updated>2020-09-09T19:49:01Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2020-09-09T13:58:52Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=75a009dc29d943554b39233286f02d34ead9a666'/>
<id>urn:sha1:75a009dc29d943554b39233286f02d34ead9a666</id>
<content type='text'>
A popular way of partially staging a new file is to run `git add -N
&lt;path&gt;` and then use the hunk editing of `git add -p` to select the
part of the file that the user wishes to stage. Since
85953a3187 ("diff-files --raw: show correct post-image of
intent-to-add files", 2020-07-01) this has stopped working as
intent-to-add paths are now show as new files rather than changes to
an empty blob and `git apply` refused to apply a creation patch for a
path that was marked as intent-to-add. 7cfde3fa0f ("apply: allow "new
file" patches on i-t-a entries", 2020-08-06) fixed the problem with
apply but it still wasn't possible to edit the added hunk properly.

2c8bd8471a ("checkout -p: handle new files correctly", 2020-05-27)
had previously changed `add -p` to handle new files but it did not
implement patch editing correctly. The perl version simply forbade
editing and the C version opened the editor with the full diff rather
that just the hunk which meant that the user had to edit the hunk
header manually to get it to work.

The root cause of the problem is that added files store the diff header
with the hunk data rather than separating the two as we do for other
changes. Changing added files to store the diff header separately
fixes the editing problem at the expense of having to special case
empty additions as they no longer have any hunks associated with them,
only the diff header.

The changes move some existing code into a conditional changing the
indentation, they are best viewed with
--color-moved-ws=allow-indentation-change (or --ignore-space-change
works well to get an overview of the changes)

Signed-off-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&gt;
Reported-by: Thomas Sullivan &lt;tom@msbit.com.au&gt;
Reported-by: Yuchen Ying &lt;ych@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add--interactive.perl: specify --no-color explicitly</title>
<updated>2020-09-08T21:49:11Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2020-09-07T08:17:39Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=1c6ffb546bf5d31c2cef2fefc86317658fda59e0'/>
<id>urn:sha1:1c6ffb546bf5d31c2cef2fefc86317658fda59e0</id>
<content type='text'>
Our color tests of "git add -p" do something a bit different from how a
normal user would behave: we pretend there's a pager in use, so that Git
thinks it's OK to write color to a non-tty stdout.  This comes from
8539b46534 (t3701: avoid depending on the TTY prerequisite, 2019-12-06),
which allows us to avoid a lot of complicated mock-tty code.

However, those environment variables also make their way down to
sub-processes of add--interactive, including the "diff-files" we run to
generate the patches. As a result, it thinks it should output color,
too. So in t3701.50, for example, the machine-readable version of the
diff we get unexpectedly has color in it. We fail to parse it as a diff
and think there are zero hunks.

The test does still pass, though, because even with zero hunks we'll
dump the diff header (and we consider those unparseable bits to be part
of the header!), and so the output still has the expected color codes in
it. We don't notice that the command was totally broken and failed to
apply anything.

And in fact we're not really testing what we think we are about the
color, either. While add--interactive does correctly show the version we
got from running "diff-files --color", we'd also pass the test if we had
accidentally shown the machine-readable version, too, since it
(erroneously) has color codes in it.

One could argue that the test isn't very realistic; it's setting up this
"pretend there's a pager" situation to get around the tty restrictions
of the test environment. So one option would be to move back towards
using a real tty. But the behavior of add--interactive really is
user-visible here. If a user, for whatever reason, did run "git
--paginate add --patch" (perhaps because their pager is really a filter
or something), the command would totally fail to do anything useful.

Since we know that we don't want color in this output, let's just make
add--interactive more defensive, and say "--no-color" explicitly. It
doesn't hurt anything in the common case, but it fixes this odd case and
lets our test function properly again.

Note that the C builtin run_add_p() already passes --no-color, so it
doesn't need a similar fix. That will eventually replace this perl code
anyway, but the test change here will be valuable for ensuring that.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Acked-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>checkout -p: handle new files correctly</title>
<updated>2020-05-27T21:50:20Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-05-27T21:09:06Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=2c8bd8471a6abc68064dafc743362547fc730f77'/>
<id>urn:sha1:2c8bd8471a6abc68064dafc743362547fc730f77</id>
<content type='text'>
The original patch selection code was written for `git add -p`, and the
fundamental unit on which it works is a hunk.

We hacked around that to handle deletions back in 24ab81ae4d
(add-interactive: handle deletion of empty files, 2009-10-27). But `git
add -p` would never see a new file, since we only consider the set of
tracked files in the index.

However, since the same machinery was used for `git checkout -p` &amp;
friends, we can see new files.

Handle this case specifically, adding a new prompt for it that is
modeled after the `deleted file` case.

This also fixes the problem where added _empty_ files could not be
staged via `git checkout -p`.

Reported-by: Merlin Büge &lt;toni@bluenox07.de&gt;
Helped-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>
</feed>
