From: Matthias Lederhofer <matled@gmx.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] make git barf when an alias changes environment variables
Date: Wed, 13 Jun 2007 07:41:36 +0200 [thread overview]
Message-ID: <20070613054136.GA27476@moooo.ath.cx> (raw)
In-Reply-To: <7vejkgh1jf.fsf@assigned-by-dhcp.pobox.com>
Junio C Hamano <gitster@pobox.com> wrote:
> What does this patch do when you do this?
>
> : Because I usually work with this repository...
> $ GIT_DIR=$some_repository
> $ export GIT_DIR
>
> : Then much later, I happen to visit another repository
> : to take a peek...
> $ cd $somewhere_else
> $ git --git-dir .git some-command
>
This one has no alias involved as far as I see, so there is no change.
The patch makes git barf when an alias changes the environment (i.e.
an alias uses --git-dir/--work-tree/--bare). When git has read the
configuration file to find out about aliases setup_git_env has been
called and a pointer returned by getenv("GIT_DIR") is already stored
in a static pointer. If the environment variable is changed
afterwards git might or might not use the new value depending on the
implementation.
That is what my example shows: FreeBSD libc reuses the old memory
location if the new value of an environment variable fits in the old
place. Because setup_git_env uses xstrdup on the object dir and some
other directories the old value is used for those but the new one is
used for git_dir (which is just a pointer returned by getenv). This
way HEAD is read from the new repository but objects are searched in
the old repository.
prev parent reply other threads:[~2007-06-13 5:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-08 20:57 [PATCH] make git barf when an alias changes environment variables Matthias Lederhofer
2007-06-13 5:21 ` Junio C Hamano
2007-06-13 5:41 ` Matthias Lederhofer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070613054136.GA27476@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).