git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Dmitry Ivankov <divanorama@gmail.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	Ramkumar Ramachandra <artagnon@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Johan Herland <johan@herland.net>,
	"Shawn O. Pearce" <spearce@spearce.org>,
	Dmitry Ivankov <divanorama@gmail.com>,
	Sverre Rabbelier <srabbelier@gmail.com>
Subject: Re: [PATCH v2 3/3] remote-helpers: export GIT_DIR variable to helpers
Date: Wed, 13 Jul 2011 23:14:31 +0600	[thread overview]
Message-ID: <CA+gfSn8=kLvYzFcdB-caNLfK3RQtOP8V=-jdFtDgQ41KG0ngOQ@mail.gmail.com> (raw)
In-Reply-To: <1310577055-6347-3-git-send-email-divanorama@gmail.com>

+Sverre
Sorry for the noise.

On Wed, Jul 13, 2011 at 11:10 PM, Dmitry Ivankov <divanorama@gmail.com> wrote:
> The gitdir capability is recognized by git and can be used to tell
> the helper where the .git directory is. But it is not mentioned in
> the documentation and considered worse than if gitdir was passed
> via GIT_DIR environment variable.
>
> Do export GIT_DIR for a remote helper. Switch testgit to use env
> instead of less favoured capability gitdir.
>
> Mention it's possible uses in documentation: data storage, auxiliary
> git commands needed by a helper.
>
> Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
> ---
> Instead of documenting capability gitdir export GIT_DIR. Turned out
> to be quite straightforward.
>
>  Documentation/git-remote-helpers.txt |   18 ++++++++++++++++++
>  git-remote-testgit.py                |   14 +-------------
>  transport-helper.c                   |   10 ++++++++++
>  3 files changed, 29 insertions(+), 13 deletions(-)
>
> diff --git a/Documentation/git-remote-helpers.txt b/Documentation/git-remote-helpers.txt
> index 58f6ad4..394fc8e 100644
> --- a/Documentation/git-remote-helpers.txt
> +++ b/Documentation/git-remote-helpers.txt
> @@ -47,6 +47,9 @@ arguments. The first argument specifies a remote repository as in git;
>  it is either the name of a configured remote or a URL. The second
>  argument specifies a URL; it is usually of the form
>  '<transport>://<address>', but any arbitrary string is possible.
> +'GIT_DIR' environment variable is set up for the remote helper and
> +can be used to store some additional data or to invoke auxiliary git
> +commands.
>
>  When git encounters a URL of the form '<transport>://<address>', where
>  '<transport>' is a protocol that it cannot handle natively, it
> @@ -159,6 +162,14 @@ Supported if the helper has the "import" capability.
>  +
>  Supported if the helper has the "connect" capability.
>
> +'gitdir' <path>::
> +       Tells helper the location of current repository .git
> +       directory. The path is absolute. The command is issued
> +       immediately after "gitdir" capability line is read by
> +       the caller.
> ++
> +Supported if the helper has the "gitdir" capability.
> +
>  If a fatal error occurs, the program writes the error message to
>  stderr and exits. The caller should expect that a suitable error
>  message has been printed if the child closes the connection without
> @@ -175,6 +186,7 @@ CAPABILITIES
>  'push'::
>  'import'::
>  'connect'::
> +'gitdir'::
>        This helper supports the corresponding command with the same name.
>
>  'refspec' 'spec'::
> @@ -187,6 +199,12 @@ CAPABILITIES
>        all, it must cover all refs reported by the list command; if
>        it is not used, it is effectively "{asterisk}:{asterisk}"
>
> +'gitdir'::
> +       The helper wants to know .git directory location. The gitdir
> +       command is sent immediately after reading this capability.
> +       The helper can read it immediately too or it can proceed with
> +       reporting other capabilities and read it as a next command.
> +
>  REF LIST ATTRIBUTES
>  -------------------
>
> diff --git a/git-remote-testgit.py b/git-remote-testgit.py
> index df9d512..df3e37f 100644
> --- a/git-remote-testgit.py
> +++ b/git-remote-testgit.py
> @@ -35,7 +35,7 @@ def get_repo(alias, url):
>     prefix = 'refs/testgit/%s/' % alias
>     debug("prefix: '%s'", prefix)
>
> -    repo.gitdir = ""
> +    repo.gitdir = os.environ["GIT_DIR"]
>     repo.alias = alias
>     repo.prefix = prefix
>
> @@ -70,7 +70,6 @@ def do_capabilities(repo, args):
>
>     print "import"
>     print "export"
> -    print "gitdir"
>     print "refspec refs/heads/*:%s*" % repo.prefix
>
>     print # end capabilities
> @@ -150,22 +149,11 @@ def do_export(repo, args):
>     repo.non_local.push(repo.gitdir)
>
>
> -def do_gitdir(repo, args):
> -    """Stores the location of the gitdir.
> -    """
> -
> -    if not args:
> -        die("gitdir needs an argument")
> -
> -    repo.gitdir = ' '.join(args)
> -
> -
>  COMMANDS = {
>     'capabilities': do_capabilities,
>     'list': do_list,
>     'import': do_import,
>     'export': do_export,
> -    'gitdir': do_gitdir,
>  }
>
>
> diff --git a/transport-helper.c b/transport-helper.c
> index 660147f..3282693 100644
> --- a/transport-helper.c
> +++ b/transport-helper.c
> @@ -105,6 +105,12 @@ static struct child_process *get_helper(struct transport *transport)
>        int refspec_alloc = 0;
>        int duped;
>        int code;
> +       char git_dir_buf[sizeof(GIT_DIR_ENVIRONMENT) + PATH_MAX + 1];
> +       const char *helper_env[] = {
> +               git_dir_buf,
> +               NULL
> +       };
> +
>
>        if (data->helper)
>                return data->helper;
> @@ -120,6 +126,10 @@ static struct child_process *get_helper(struct transport *transport)
>        helper->argv[2] = remove_ext_force(transport->url);
>        helper->git_cmd = 0;
>        helper->silent_exec_failure = 1;
> +
> +       snprintf(git_dir_buf, sizeof(git_dir_buf), "%s=%s", GIT_DIR_ENVIRONMENT, get_git_dir());
> +       helper->env = helper_env;
> +
>        code = start_command(helper);
>        if (code < 0 && errno == ENOENT)
>                die("Unable to find remote helper for '%s'", data->name);
> --
> 1.7.3.4
>
>

  reply	other threads:[~2011-07-13 17:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-12 15:10 [PATCH 0/3] doc/{fast-import,remote-helpers}: few clarifications Dmitry Ivankov
2011-07-12 15:10 ` [PATCH 1/3] doc/fast-import: clarify notemodify command Dmitry Ivankov
2011-07-12 15:10 ` [PATCH 2/3] doc/fast-import: document feature import-marks-if-exists Dmitry Ivankov
2011-07-12 17:00   ` Junio C Hamano
2011-07-13 10:27   ` Ramkumar Ramachandra
2011-07-12 15:10 ` [PATCH 3/3] doc/remote-helpers: document the gitdir feature Dmitry Ivankov
2011-07-13 12:04   ` Sverre Rabbelier
2011-07-13 17:10 ` [PATCH v2 1/3] doc/fast-import: clarify notemodify command Dmitry Ivankov
2011-07-22 19:32   ` Johan Herland
2011-07-13 17:10 ` [PATCH v2 2/3] doc/fast-import: document feature import-marks-if-exists Dmitry Ivankov
2011-07-13 17:10 ` [PATCH v2 3/3] remote-helpers: export GIT_DIR variable to helpers Dmitry Ivankov
2011-07-13 17:14   ` Dmitry Ivankov [this message]
2011-07-13 17:36   ` Sverre Rabbelier
2011-07-13 18:10     ` Dmitry Ivankov

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+gfSn8=kLvYzFcdB-caNLfK3RQtOP8V=-jdFtDgQ41KG0ngOQ@mail.gmail.com' \
    --to=divanorama@gmail.com \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johan@herland.net \
    --cc=jrnieder@gmail.com \
    --cc=spearce@spearce.org \
    --cc=srabbelier@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).