<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/environment.c, branch v2.8.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.8.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.8.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2016-03-07T01:17:37Z</updated>
<entry>
<title>setup: make startup_info available everywhere</title>
<updated>2016-03-07T01:17:37Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-03-05T22:10:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=46c3cd44d7a1e8a33ad66c017ac9e3575cc88c00'/>
<id>urn:sha1:46c3cd44d7a1e8a33ad66c017ac9e3575cc88c00</id>
<content type='text'>
Commit a60645f (setup: remember whether repository was
found, 2010-08-05) introduced the startup_info structure,
which records some parts of the setup_git_directory()
process (notably, whether we actually found a repository or
not).

One of the uses of this data is for functions to behave
appropriately based on whether we are in a repo. But the
startup_info struct is just a pointer to storage provided by
the main program, and the only program that sets it up is
the git.c wrapper. Thus builtins have access to
startup_info, but externally linked programs do not.

Worse, library code which is accessible from both has to be
careful about accessing startup_info. This can be used to
trigger a die("BUG") via get_sha1():

	$ git fast-import &lt;&lt;-\EOF
	tag foo
	from HEAD:./whatever
	EOF

	fatal: BUG: startup_info struct is not initialized.

Obviously that's fairly nonsensical input to feed to
fast-import, but we should never hit a die("BUG"). And there
may be other ways to trigger it if other non-builtins
resolve sha1s.

So let's point the storage for startup_info to a static
variable in setup.c, making it available to all users of the
library code. We _could_ turn startup_info into a regular
extern struct, but doing so would mean tweaking all of the
existing use sites. So let's leave the pointer indirection
in place.  We can, however, drop any checks for NULL, as
they will always be false (and likewise, we can drop the
test covering this case, which was a rather artificial
situation using one of the test-* programs).

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>Merge branch 'cc/untracked'</title>
<updated>2016-02-10T22:20:06Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-02-10T22:20:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0e35fcb412965f855e5ac6f469343e2f8e28d5ae'/>
<id>urn:sha1:0e35fcb412965f855e5ac6f469343e2f8e28d5ae</id>
<content type='text'>
Update the untracked cache subsystem and change its primary UI from
"git update-index" to "git config".

* cc/untracked:
  t7063: add tests for core.untrackedCache
  test-dump-untracked-cache: don't modify the untracked cache
  config: add core.untrackedCache
  dir: simplify untracked cache "ident" field
  dir: add remove_untracked_cache()
  dir: add {new,add}_untracked_cache()
  update-index: move 'uc' var declaration
  update-index: add untracked cache notifications
  update-index: add --test-untracked-cache
  update-index: use enum for untracked cache options
  dir: free untracked cache when removing it
</content>
</entry>
<entry>
<title>test-dump-untracked-cache: don't modify the untracked cache</title>
<updated>2016-01-27T20:30:07Z</updated>
<author>
<name>Christian Couder</name>
<email>christian.couder@gmail.com</email>
</author>
<published>2016-01-27T06:58:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dae6c322fa106d72dabd7551f388715e6a9f2ebf'/>
<id>urn:sha1:dae6c322fa106d72dabd7551f388715e6a9f2ebf</id>
<content type='text'>
To correctly perform its testing function,
test-dump-untracked-cache should not change the state of the
untracked cache in the index.

As a previous patch makes read_index_from() change the state of
the untracked cache and as test-dump-untracked-cache indirectly
calls this function, we need a mechanism to prevent
read_index_from() from changing the untracked cache state when
it's called from test-dump-untracked-cache.

Signed-off-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'nd/stop-setenv-work-tree'</title>
<updated>2016-01-12T23:16:53Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-01-12T23:16:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d82d093456284e1a60db6c91f01a99b47880277f'/>
<id>urn:sha1:d82d093456284e1a60db6c91f01a99b47880277f</id>
<content type='text'>
An earlier change in 2.5.x-era broke users' hooks and aliases by
exporting GIT_WORK_TREE to point at the root of the working tree,
interfering when they tried to use a different working tree without
setting GIT_WORK_TREE environment themselves.

* nd/stop-setenv-work-tree:
  Revert "setup: set env $GIT_WORK_TREE when work tree is set, like $GIT_DIR"
</content>
</entry>
<entry>
<title>Revert "setup: set env $GIT_WORK_TREE when work tree is set, like $GIT_DIR"</title>
<updated>2015-12-22T21:36:47Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2015-12-21T10:22:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=df1e6ea87a58fc8d029efb3041d851f7d6653a1d'/>
<id>urn:sha1:df1e6ea87a58fc8d029efb3041d851f7d6653a1d</id>
<content type='text'>
This reverts d95138e6 (setup: set env $GIT_WORK_TREE when work tree
is set, like $GIT_DIR, 2015-06-26).

It has caused three regression reports so far.

  http://article.gmane.org/gmane.comp.version-control.git/281608
  http://article.gmane.org/gmane.comp.version-control.git/281979
  http://article.gmane.org/gmane.comp.version-control.git/282691

All of them are about spawning git subprocesses, where the new
presence of GIT_WORK_TREE either changes command behaviour (git-init
or git-clone), or how repo/worktree is detected (from aliases), with
or without $GIT_DIR.

The original bug will be re-fixed another way.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/repository-extension'</title>
<updated>2015-10-26T22:55:25Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-10-26T22:55:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fa46579555583a9799d8495f632b14cddd65db6e'/>
<id>urn:sha1:fa46579555583a9799d8495f632b14cddd65db6e</id>
<content type='text'>
Prepare for Git on-disk repository representation to undergo
backward incompatible changes by introducing a new repository
format version "1", with an extension mechanism.

* jk/repository-extension:
  introduce "preciousObjects" repository extension
  introduce "extensions" form of core.repositoryformatversion
</content>
</entry>
<entry>
<title>replace trivial malloc + sprintf / strcpy calls with xstrfmt</title>
<updated>2015-09-25T17:18:18Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-09-24T21:07:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=75faa45ae0230b321bf72027b2274315d7e14e34'/>
<id>urn:sha1:75faa45ae0230b321bf72027b2274315d7e14e34</id>
<content type='text'>
It's a common pattern to do:

  foo = xmalloc(strlen(one) + strlen(two) + 1 + 1);
  sprintf(foo, "%s %s", one, two);

(or possibly some variant with strcpy()s or a more
complicated length computation).  We can switch these to use
xstrfmt, which is shorter, involves less error-prone manual
computation, and removes many sprintf and strcpy calls which
make it harder to audit the code for real buffer overflows.

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>Merge branch 'nd/export-worktree'</title>
<updated>2015-08-03T18:01:14Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-08-03T18:01:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a3f4eb1b40457d85ab63168b621e71eaf73bb3c4'/>
<id>urn:sha1:a3f4eb1b40457d85ab63168b621e71eaf73bb3c4</id>
<content type='text'>
Running an aliased command from a subdirectory when the .git thing
in the working tree is a gitfile pointing elsewhere did not work.

* nd/export-worktree:
  setup: set env $GIT_WORK_TREE when work tree is set, like $GIT_DIR
</content>
</entry>
<entry>
<title>setup: set env $GIT_WORK_TREE when work tree is set, like $GIT_DIR</title>
<updated>2015-06-26T18:52:26Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2015-06-26T10:37:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d95138e695d99d32dcad528a2a7974f434c51e79'/>
<id>urn:sha1:d95138e695d99d32dcad528a2a7974f434c51e79</id>
<content type='text'>
In the test case, we run setup_git_dir_gently() the first time to read
$GIT_DIR/config so that we can resolve aliases. We'll enter
setup_discovered_git_dir() and may or may not call set_git_dir() near
the end of the function, depending on whether the detected git dir is
".git" or not. This set_git_dir() will set env var $GIT_DIR.

For normal repo, git dir detected via setup_discovered_git_dir() will be
".git", and set_git_dir() is not called. If .git file is used however,
the git dir can't be ".git" and set_git_dir() is called and $GIT_DIR
set. This is the key of this problem.

If we expand an alias (or autocorrect command names), then
setup_git_dir_gently() is run the second time. If $GIT_DIR is not set in
the first run, we run the same setup_discovered_git_dir() as before.
Nothing to see. If it is, however, we'll enter setup_explicit_git_dir()
this time.

This is where the "fun" is.  If $GIT_WORK_TREE is not set but
$GIT_DIR is, you are supposed to be at the root level of the
worktree.  But if you are in a subdir "foo/bar" (real worktree's top
is "foo"), this rule bites you: your detected worktree is now
"foo/bar", even though the first run correctly detected worktree as
"foo". You get "internal error: work tree has already been set" as a
result.

Bottom line is, when $GIT_DIR is set, $GIT_WORK_TREE should be set too
unless there's no work tree. But setting $GIT_WORK_TREE inside
set_git_dir() may backfire. We don't know at that point if work tree is
already configured by the caller. So set it when work tree is
detected. It does not harm if $GIT_WORK_TREE is set while $GIT_DIR is
not.

Reported-by: Bjørnar Snoksrud &lt;snoksrud@gmail.com&gt;
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>introduce "preciousObjects" repository extension</title>
<updated>2015-06-25T00:09:35Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-06-23T10:54:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=067fbd4105c5aa8260a73cc6961854be0e93fa03'/>
<id>urn:sha1:067fbd4105c5aa8260a73cc6961854be0e93fa03</id>
<content type='text'>
If this extension is used in a repository, then no
operations should run which may drop objects from the object
storage. This can be useful if you are sharing that storage
with other repositories whose refs you cannot see.

For instance, if you do:

  $ git clone -s parent child
  $ git -C parent config extensions.preciousObjects true
  $ git -C parent config core.repositoryformatversion 1

you now have additional safety when running git in the
parent repository. Prunes and repacks will bail with an
error, and `git gc` will skip those operations (it will
continue to pack refs and do other non-object operations).
Older versions of git, when run in the repository, will
fail on every operation.

Note that we do not set the preciousObjects extension by
default when doing a "clone -s", as doing so breaks
backwards compatibility. It is a decision the user should
make explicitly.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
