git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] Move worktree setup out of setup_git_directory*
Date: Sun, 24 Feb 2008 17:13:52 -0800	[thread overview]
Message-ID: <7vr6f1sur3.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20080224044650.GA25343@laptop> (Nguyễn Thái Ngọc Duy's message of "Sun, 24 Feb 2008 11:46:51 +0700")

Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:

> setup_git_directory* now work as if there is no worktree.  It may set
> some worktree-related variables but its prefix (and current directory)
> should not be affected by worktree settings.
> ...
> setup_work_tree() will now take the role of recalculating prefix when
> worktree is required.

This definitely needs documented in-tree, Documentation/technical/.

I think we have a good understanding from the end-user point-of-view
how these things work:

 - If you have GIT_DIR exported, then no discovery is attempted.
   We use the GIT_DIR you set it, and the repository lives
   there.  $GIT_DIR/config is the repository config.

 - Otherwise we do the usual discovery going up to find the
   repository.

 - If you have GIT_WORK_TREE exported, or otherwise if the
   config has core.worktree, that's where your worktree is.
   Otherwise, if you have GIT_DIR exported, you do not have a
   worktree.  Else one level above your $GIT_DIR is the toplevel
   of your worktree.

We would need a set of rules for application writers, written
like this (here is just an example of _how_ the rules might be
written, I do not think the contents are correct):

 - At startup:

   - If the command always need to run from a repository, call
     setup_git_directory(), which would complain and die if you
     are outside.

   - If the command can optionally run in a repository, use
     setup_git_directory_gently(&nongit_ok); it won't complain
     but sets nongit_ok to true if run outside a repository.

   In either case, they return prefix string to be used for
   setup_work_tree() later.

   In either case, there is no chdir() done at this point.

 - After calling setup_git_directory(), or you made sure you are
   in a repository after callilng setup_git_directory_gently(),
   call setup_work_tree().  This will chdir to the top of the
   work tree.

 - When you need to know where $GIT_DIR is, call get_git_dir().
   When you need to know where the work tree is, call
   get_git_work_tree().  However, it is an error to call these
   functions before calling setup_git_directory and
   setup_work_tree.

  reply	other threads:[~2008-02-25  1:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-24  4:46 [PATCH] Move worktree setup out of setup_git_directory* Nguyễn Thái Ngọc Duy
2008-02-25  1:13 ` Junio C Hamano [this message]
2008-02-25 13:17   ` Nguyen Thai Ngoc Duy
2008-02-25 19:01     ` Junio C Hamano

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=7vr6f1sur3.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.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).