<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/add-patch.c, branch v2.29.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.29.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.29.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2020-09-22T19:36:28Z</updated>
<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='https://git.shady.money/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>Merge branch 'jk/add-i-fixes'</title>
<updated>2020-09-19T00:58:04Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-09-19T00:58:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=694e517778243256b748819cc60eff6011238a0a'/>
<id>urn:sha1:694e517778243256b748819cc60eff6011238a0a</id>
<content type='text'>
"add -i/-p" fixes.

* jk/add-i-fixes:
  add--interactive.perl: specify --no-color explicitly
  add-patch: fix inverted return code of repo_read_index()
</content>
</entry>
<entry>
<title>Merge branch 'pw/add-p-leakfix'</title>
<updated>2020-09-19T00:58:03Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-09-19T00:58:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3ad8d3e4f9855de6444b081e59328a55de1def80'/>
<id>urn:sha1:3ad8d3e4f9855de6444b081e59328a55de1def80</id>
<content type='text'>
Leakfix.

* pw/add-p-leakfix:
  add -p: fix memory leak
</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='https://git.shady.money/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 -p: fix memory leak</title>
<updated>2020-09-08T21:51:38Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2020-09-07T15:04:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=324efcf6b6d30d43b98e76c7beac90ecfb40d637'/>
<id>urn:sha1:324efcf6b6d30d43b98e76c7beac90ecfb40d637</id>
<content type='text'>
asan reports that the C version of `add -p` is not freeing all the
memory it allocates. Fix this by introducing a function to clear
`struct add_p_state` and use it instead of freeing individual members.

Signed-off-by: Phillip Wood &lt;phillip.wood@dunelm.org.uk&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>add-patch: fix inverted return code of repo_read_index()</title>
<updated>2020-09-08T21:48:29Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2020-09-07T08:08:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dc6264157236fb729ad072e18f14d89549c08555'/>
<id>urn:sha1:dc6264157236fb729ad072e18f14d89549c08555</id>
<content type='text'>
After applying hunks to a file with "add -p", the C patch_update_file()
function tries to refresh the index (just like the perl version does).
We can only refresh the index if we're able to read it in, so we first
check the return value of repo_read_index(). But unlike many functions,
where "0" is success, that function is documented to return the number
of entries in the index.  Hence we should be checking for success with a
non-negative return value.

Neither the tests nor any users seem to have noticed this, probably due
to a combination of:

  - this affects only the C version, which is not yet the default

  - following it up with any porcelain command like "git diff" or "git
    commit" would refresh the index automatically.

But you can see the problem by running the plumbing "git diff-files"
immediately after "add -p" stages all hunks. Running the new test with
GIT_TEST_ADD_I_USE_BUILTIN=1 fails without the matching code change.

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>Merge branch 'pw/add-p-allowed-options-fix'</title>
<updated>2020-09-03T19:37:02Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-09-03T19:37:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cce5178c305439a2b7b05dcd88aafbaf0a89a59f'/>
<id>urn:sha1:cce5178c305439a2b7b05dcd88aafbaf0a89a59f</id>
<content type='text'>
"git add -p" update.

* pw/add-p-allowed-options-fix:
  add -p: fix checking of user input
  add -p: use ALLOC_GROW_BY instead of ALLOW_GROW
</content>
</entry>
<entry>
<title>add -p: fix checking of user input</title>
<updated>2020-08-17T18:44:42Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2020-08-17T13:23:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ce910287e727e5b534d806df725c68a8dfc4790a'/>
<id>urn:sha1:ce910287e727e5b534d806df725c68a8dfc4790a</id>
<content type='text'>
When a file has been deleted the C version of add -p allows the user
to edit a hunk even though 'e' is not in the list of allowed
responses. (I think 'e' is disallowed because if the file is edited it
is no longer a deletion and we're not set up to rewrite the diff
header).

The invalid response was allowed because the test that determines
whether to display 'e' was not duplicated correctly in the code that
processes the user's choice. Fix this by using flags that are set when
constructing the prompt and checked when processing the user's choice
rather than repeating the check itself.

Signed-off-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>add -p: use ALLOC_GROW_BY instead of ALLOW_GROW</title>
<updated>2020-08-17T18:41:50Z</updated>
<author>
<name>Phillip Wood</name>
<email>phillip.wood@dunelm.org.uk</email>
</author>
<published>2020-08-17T13:23:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2ebe436c5531319e820571d04024f7bcae383450'/>
<id>urn:sha1:2ebe436c5531319e820571d04024f7bcae383450</id>
<content type='text'>
This simplifies the code slightly, especially the third case where
hunk_nr was incremented a few lines before ALLOC_GROW().

Signed-off-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 'jk/strvec'</title>
<updated>2020-08-10T17:23:57Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-08-10T17:23:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=46b225f15308c8f77379f864189bed95c273d29f'/>
<id>urn:sha1:46b225f15308c8f77379f864189bed95c273d29f</id>
<content type='text'>
The argv_array API is useful for not just managing argv but any
"vector" (NULL-terminated array) of strings, and has seen adoption
to a certain degree.  It has been renamed to "strvec" to reduce the
barrier to adoption.

* jk/strvec:
  strvec: rename struct fields
  strvec: drop argv_array compatibility layer
  strvec: update documention to avoid argv_array
  strvec: fix indentation in renamed calls
  strvec: convert remaining callers away from argv_array name
  strvec: convert more callers away from argv_array name
  strvec: convert builtin/ callers away from argv_array name
  quote: rename sq_dequote_to_argv_array to mention strvec
  strvec: rename files from argv-array to strvec
  argv-array: rename to strvec
  argv-array: use size_t for count and alloc
</content>
</entry>
</feed>
