<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/add-interactive.c, branch v2.25.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.25.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.25.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2020-03-17T22:02:20Z</updated>
<entry>
<title>Merge branch 'js/builtin-add-i-cmds' into maint</title>
<updated>2020-03-17T22:02:20Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-03-17T22:02:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f0c344ce578f71aeeee7d40cc01e66f74506ecf9'/>
<id>urn:sha1:f0c344ce578f71aeeee7d40cc01e66f74506ecf9</id>
<content type='text'>
Minor bugfixes to "git add -i" that has recently been rewritten in C.

* js/builtin-add-i-cmds:
  built-in add -i: accept open-ended ranges again
  built-in add -i: do not try to `patch`/`diff` an empty list of files
</content>
</entry>
<entry>
<title>built-in add -i: accept open-ended ranges again</title>
<updated>2020-01-16T22:10:23Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-01-16T08:33:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=849e43cc18a8aef639b92c5df9b66af3eb983b2a'/>
<id>urn:sha1:849e43cc18a8aef639b92c5df9b66af3eb983b2a</id>
<content type='text'>
The interactive `add` command allows selecting multiple files for some
of its sub-commands, via unique prefixes, indices or index ranges.

When re-implementing `git add -i` in C, we even added a code comment
talking about ranges with a missing end index, such as `2-`, but the
code did not actually accept those, as pointed out in
https://github.com/git-for-windows/git/issues/2466#issuecomment-574142760.

Let's fix this, and add a test case to verify that this stays fixed
forever.

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>built-in add -i: do not try to `patch`/`diff` an empty list of files</title>
<updated>2020-01-16T22:10:21Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-01-16T08:33:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d660a30ceb9d8bd9940be82d240901c87999186b'/>
<id>urn:sha1:d660a30ceb9d8bd9940be82d240901c87999186b</id>
<content type='text'>
When the user does not select any files to `patch` or `diff`, there is
no need to call `run_add_p()` on them.

Even worse: we _have_ to avoid calling `parse_pathspec()` with an empty
list because that would trigger this error:

	BUG: pathspec.c:557: PATHSPEC_PREFER_CWD requires arguments

So let's avoid doing any work on a list of files that is empty anyway.

This fixes https://github.com/git-for-windows/git/issues/2466.

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>built-in add -p: implement hunk editing</title>
<updated>2019-12-13T20:37:14Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-12-13T08:08:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bcdd297b782b19782d8e09b18682ec61d7c36897'/>
<id>urn:sha1:bcdd297b782b19782d8e09b18682ec61d7c36897</id>
<content type='text'>
Just like `git add --edit` allows the user to edit the diff before it is
being applied to the index, this feature allows the user to edit the
diff *hunk*.

Naturally, it gets a bit more complicated here because the result has
to play well with the remaining hunks of the overall diff. Therefore,
we have to do a loop in which we let the user edit the hunk, then test
whether the result would work, and if not, drop the edits and let the
user decide whether to try editing the hunk again.

Note: in contrast to the Perl version, we use the same diff
"coalescing" (i.e. merging overlapping hunks into a single one) also for
the check after editing, and we introduce a new flag for that purpose
that asks the `reassemble_patch()` function to pretend that all hunks
were selected for use.

This allows us to continue to run `git apply` *without* the
`--allow-overlap` option (unlike the Perl version), and it also fixes
two known breakages in `t3701-add-interactive.sh` (which we cannot mark
as resolved so far because the Perl script version is still the default
and continues to have those breakages).

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>built-in add -p: adjust hunk headers as needed</title>
<updated>2019-12-13T20:37:13Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-12-13T08:07:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=25ea47af494c5ec086aae102d358c4001c9a1459'/>
<id>urn:sha1:25ea47af494c5ec086aae102d358c4001c9a1459</id>
<content type='text'>
When skipping a hunk that adds a different number of lines than it
removes, we need to adjust the subsequent hunk headers of non-skipped
hunks: in pathological cases, the context is not enough to determine
precisely where the patch should be applied.

This problem was identified in 23fea4c240 (t3701: add failing test for
pathological context lines, 2018-03-01) and fixed in the Perl version in
fecc6f3a68 (add -p: adjust offsets of subsequent hunks when one is
skipped, 2018-03-01).

And this patch fixes it in the C version of `git add -p`.

In contrast to the Perl version, we try to keep the extra text on the
hunk header (which typically contains the signature of the function
whose code is changed in the hunk) intact.

Note: while the C version does not support staging mode changes at this
stage, we already prepare for this by simply skipping the hunk header if
both old and new offset is 0 (this cannot happen for regular hunks, and
we will use this as an indicator that we are looking at a special hunk).

Likewise, we already prepare for hunk splitting by handling the absence
of extra text in the hunk header gracefully: only the first split hunk
will have that text, the others will not (indicated by an empty extra
text start/end range). Preparing for hunk splitting already at this
stage avoids an indentation change of the entire hunk header-printing
block later, and is almost as easy to review as without that handling.

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>built-in add -i: wire up the new C code for the `patch` command</title>
<updated>2019-12-13T20:37:13Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-12-13T08:07:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1942ee44e8b1715a2e0555a0ea432ea6ab488f4e'/>
<id>urn:sha1:1942ee44e8b1715a2e0555a0ea432ea6ab488f4e</id>
<content type='text'>
The code in `git-add--interactive.perl` that takes care of the `patch`
command can look quite intimidating. There are so many modes in which it
can be called, for example.

But for the `patch` command in `git add -i`, only one mode is relevant:
the `stage` mode. And we just implemented the beginnings of that mode in
C so far. So let's use it when `add.interactive.useBuiltin=true`.

Now, while the code in `add-patch.c` is far from reaching feature parity
with the code in `git-add--interactive.perl` (color is not implemented,
the diff algorithm cannot be configured, the colored diff cannot be
post-processed via `interactive.diffFilter`, many commands are
unimplemented yet, etc), hooking it all up with the part of `git add -i`
that is already converted to C makes it easier to test and develop it.

Note: at this stage, both the `add.interactive.useBuiltin` config
setting is still safely opt-in, and will probably be fore quite some
time, to allow for thorough testing "in the wild" without adversely
affecting existing users.

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>built-in add -i: offer the `quit` command</title>
<updated>2019-12-01T15:30:54Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-11-29T21:11:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2e697ced9d647d6998d70f010d582ba8019fe3af'/>
<id>urn:sha1:2e697ced9d647d6998d70f010d582ba8019fe3af</id>
<content type='text'>
We do not really want to `exit()` here, of course, as this is safely
libified code.

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>built-in add -i: re-implement the `diff` command</title>
<updated>2019-12-01T15:30:54Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-11-29T21:11:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d7633578b5ecf0d75e2793b01aa2e9afe645c186'/>
<id>urn:sha1:d7633578b5ecf0d75e2793b01aa2e9afe645c186</id>
<content type='text'>
It is not only laziness that we simply spawn `git diff -p --cached`
here: this command needs to use the pager, and the pager needs to exit
when the diff is done. Currently we do not have any way to make that
happen if we run the diff in-process. So let's just spawn.

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>built-in add -i: implement the `patch` command</title>
<updated>2019-12-01T15:30:54Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-11-29T21:11:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8746e07277cb548185a33efa0037c313a06001f8'/>
<id>urn:sha1:8746e07277cb548185a33efa0037c313a06001f8</id>
<content type='text'>
Well, it is not a full implementation yet. In the interest of making
this easy to review (and easy to keep bugs out), we still hand off to
the Perl script to do the actual work.

The `patch` functionality actually makes up for more than half of the
1,800+ lines of `git-add--interactive.perl`. It will be ported from Perl
to C incrementally, later.

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>built-in add -i: re-implement `add-untracked` in C</title>
<updated>2019-12-01T15:30:54Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-11-29T21:11:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ab1e1cccaf6252e2fb47b1bfbc5bc8d3d678bfe1'/>
<id>urn:sha1:ab1e1cccaf6252e2fb47b1bfbc5bc8d3d678bfe1</id>
<content type='text'>
This is yet another command, ported to C. It builds nicely on the
support functions introduced for other commands, with the notable
difference that only names are displayed for untracked files, no
file type or diff summary.

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>
