<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git.c, branch v2.8.1</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v2.8.1</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v2.8.1'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2016-02-26T21:37:16Z</updated>
<entry>
<title>Merge branch 'jk/tighten-alloc'</title>
<updated>2016-02-26T21:37:16Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-02-26T21:37:16Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=11529ecec914d2f0d7575e6d443c2d5a6ff75424'/>
<id>urn:sha1:11529ecec914d2f0d7575e6d443c2d5a6ff75424</id>
<content type='text'>
Update various codepaths to avoid manually-counted malloc().

* jk/tighten-alloc: (22 commits)
  ewah: convert to REALLOC_ARRAY, etc
  convert ewah/bitmap code to use xmalloc
  diff_populate_gitlink: use a strbuf
  transport_anonymize_url: use xstrfmt
  git-compat-util: drop mempcpy compat code
  sequencer: simplify memory allocation of get_message
  test-path-utils: fix normalize_path_copy output buffer size
  fetch-pack: simplify add_sought_entry
  fast-import: simplify allocation in start_packfile
  write_untracked_extension: use FLEX_ALLOC helper
  prepare_{git,shell}_cmd: use argv_array
  use st_add and st_mult for allocation size computation
  convert trivial cases to FLEX_ARRAY macros
  use xmallocz to avoid size arithmetic
  convert trivial cases to ALLOC_ARRAY
  convert manual allocations to argv_array
  argv-array: add detach function
  add helpers for allocating flex-array structs
  harden REALLOC_ARRAY and xcalloc against size_t overflow
  tree-diff: catch integer overflow in combine_diff_path allocation
  ...
</content>
</entry>
<entry>
<title>Merge branch 'ak/git-strip-extension-from-dashed-command'</title>
<updated>2016-02-26T21:37:13Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-02-26T21:37:13Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=dede29612a723a7da9f489fecbdf02500a018430'/>
<id>urn:sha1:dede29612a723a7da9f489fecbdf02500a018430</id>
<content type='text'>
Code simplification.

* ak/git-strip-extension-from-dashed-command:
  git.c: simplify stripping extension of a file in handle_builtin()
</content>
</entry>
<entry>
<title>convert manual allocations to argv_array</title>
<updated>2016-02-22T22:50:32Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-02-22T22:44:21Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=850d2fec53ee188bab9e458f77906041ac7f1904'/>
<id>urn:sha1:850d2fec53ee188bab9e458f77906041ac7f1904</id>
<content type='text'>
There are many manual argv allocations that predate the
argv_array API. Switching to that API brings a few
advantages:

  1. We no longer have to manually compute the correct final
     array size (so it's one less thing we can screw up).

  2. In many cases we had to make a separate pass to count,
     then allocate, then fill in the array. Now we can do it
     in one pass, making the code shorter and easier to
     follow.

  3. argv_array handles memory ownership for us, making it
     more obvious when things should be free()d and and when
     not.

Most of these cases are pretty straightforward. In some, we
switch from "run_command_v" to "run_command" which lets us
directly use the argv_array embedded in "struct
child_process".

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>git.c: simplify stripping extension of a file in handle_builtin()</title>
<updated>2016-02-22T07:52:43Z</updated>
<author>
<name>Alexander Kuleshov</name>
<email>kuleshovmail@gmail.com</email>
</author>
<published>2016-02-22T07:18:29Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=63ca1c099c36e61b0e9cd7fa0b912c0b9d89b628'/>
<id>urn:sha1:63ca1c099c36e61b0e9cd7fa0b912c0b9d89b628</id>
<content type='text'>
The handle_builtin() starts from stripping of command extension if
STRIP_EXTENSION is enabled. Actually STRIP_EXTENSION does not used
anywhere else.

This patch introduces strip_extension() helper to strip STRIP_EXTENSION
extension from argv[0] with the strip_suffix() instead of manually
stripping.

Signed-off-by: Alexander Kuleshov &lt;kuleshovmail@gmail.com&gt;
Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'nd/clear-gitenv-upon-use-of-alias'</title>
<updated>2016-02-17T18:13:31Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-02-17T18:13:31Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=dbda66b0e283494c35958316c9b1c47b6e6c9f59'/>
<id>urn:sha1:dbda66b0e283494c35958316c9b1c47b6e6c9f59</id>
<content type='text'>
The automatic typo correction applied to an alias was broken
with a recent change already in 'master'.

* nd/clear-gitenv-upon-use-of-alias:
  restore_env(): free the saved environment variable once we are done
  git: simplify environment save/restore logic
  git: protect against unbalanced calls to {save,restore}_env()
  git: remove an early return from save_env_before_alias()
</content>
</entry>
<entry>
<title>restore_env(): free the saved environment variable once we are done</title>
<updated>2016-02-02T23:42:59Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-02-02T23:42:59Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=8384c139cb9409fb3cf5ef70afff263917581258'/>
<id>urn:sha1:8384c139cb9409fb3cf5ef70afff263917581258</id>
<content type='text'>
Just like we free orig_cwd, which is the value of the original
working directory saved in save_env_before_alias(), once we are
done with it, the contents of orig_env[] array, saved in the
save_env_before_alias() function should be freed; otherwise,
the second and subsequent calls to save/restore pair will leak
the memory allocated in save_env_before_alias().

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git: simplify environment save/restore logic</title>
<updated>2016-01-27T23:45:55Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-01-27T06:52:02Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=441981bc85ea2b648d7ffb2515b371071208e657'/>
<id>urn:sha1:441981bc85ea2b648d7ffb2515b371071208e657</id>
<content type='text'>
The only code that cares about the value of the global variable
saved_env_before_alias after the previous fix is handle_builtin()
that turns into a glorified no-op when the variable is true, so the
logic could safely be lifted to its caller, i.e. the caller can
refrain from calling it when the variable is set.

This variable tells us if save_env_before_alias() was called (with
or without matching restore_env()), but the sole caller of the
function, handle_alias(), always calls it as the first thing, so we
can consider that the variable essentially keeps track of the fact
that handle_alias() has ever been called.

It turns out that handle_builtin() and handle_alias() are called
only from one function in a way that the value of the variable
matters, which is run_argv(), and it already keeps track of the
fact that it already called handle_alias().

So we can simplify the whole thing by:

- Change handle_builtin() to always make a direct call to the
  builtin implementation it finds, and make sure the caller
  refrains from calling it if handle_alias() has ever been
  called;

- Remove saved_env_before_alias variable, and instead use the
  local "done_alias" variable maintained inside run_argv() to
  make the same decision.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git: protect against unbalanced calls to {save,restore}_env()</title>
<updated>2016-01-27T23:19:03Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-01-27T06:50:27Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=2e1175d43d05e83fe836e1c8c8e7c25b7ee659ae'/>
<id>urn:sha1:2e1175d43d05e83fe836e1c8c8e7c25b7ee659ae</id>
<content type='text'>
We made sure that save_env_before_alias() does not skip saving the
environment when asked to (which led to use-after-free of orig_cwd
in restore_env() in the buggy version) with the previous step.

Protect against future breakage where somebody adds new callers of
these functions in an unbalanced fashion.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git: remove an early return from save_env_before_alias()</title>
<updated>2016-01-27T23:12:37Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-01-26T19:46:53Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=9d1d2b7fad9bec6320a2058c625787c835864960'/>
<id>urn:sha1:9d1d2b7fad9bec6320a2058c625787c835864960</id>
<content type='text'>
When help.autocorrect is in effect, an attempt to auto-execute an
uniquely corrected result of a misspelt alias will result in an
irrelevant error message.  The codepath that causes this calls
save_env_before_alias() and restore_env() in handle_alias(), and
that happens twice.  A global variable orig_cwd is allocated to hold
the return value of getcwd() in save_env_before_alias(), which is
then used in restore_env() to go back to that directory and finally
free(3)'d there.

However, save_env_before_alias() is not prepared to be called twice.
It returns early when it knows it has already been called, leaving
orig_cwd undefined, which is then checked in the second call to
restore_env(), and by that time, the memory that used to hold the
contents of orig_cwd is either freed or reused to hold something
else, and this is fed to chdir(2), causing it to fail.  Even if it
did not fail (i.e. reading of the already free'd piece of memory
yielded a directory path that we can chdir(2) to), it then gets
free(3)'d.

Fix this by making sure save_env() does do the saving when called.

While at it, add a minimal test for help.autocorrect facility.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'nd/clear-gitenv-upon-use-of-alias'</title>
<updated>2016-01-20T19:43:26Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-01-20T19:43:26Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=5135d1c3d2a2c8c6c9701bd0cbcf57ce587f750d'/>
<id>urn:sha1:5135d1c3d2a2c8c6c9701bd0cbcf57ce587f750d</id>
<content type='text'>
d95138e6 (setup: set env $GIT_WORK_TREE when work tree is set, like
$GIT_DIR, 2015-06-26) attempted to work around a glitch in alias
handling by overwriting GIT_WORK_TREE environment variable to
affect subprocesses when set_git_work_tree() gets called, which
resulted in a rather unpleasant regression to "clone" and "init".
Try to address the same issue by always restoring the environment
and respawning the real underlying command when handling alias.

* nd/clear-gitenv-upon-use-of-alias:
  run-command: don't warn on SIGPIPE deaths
  git.c: make sure we do not leak GIT_* to alias scripts
  setup.c: re-fix d95138e (setup: set env $GIT_WORK_TREE when ..
  git.c: make it clear save_env() is for alias handling only
</content>
</entry>
</feed>
