git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 0/4] git_connect: add some flexibility

From
Mike Hommey <mh@glandium.org>
Date
Apr 28, 2016, 14:12 UTC
Message-ID
<1461852759-28429-1-git-send-email-mh@glandium.org>

As you may be aware, I'm working on a git remote helper to access mercurial repositories (https://github.com/glandium/git-cinnabar/).

At the moment, a small part is written in C, relying on the git code base, but eventually, there would be more C.

As I want to get rid of the dependency on Mercurial itself, I'm planning to implement the wire protocol parts in git-cinnabar. And while at it, I figured I'd evaluate if I can't just rely on some git internals, from C code. So I've turned to the git_connect function, that implements the niceties around GIT_SSH and GIT_SSH_COMMAND, and also handles ssh client specificities. (I'd rather not have to copy the code or reimplement it). It also turns out to be a convenient wrapper around start_command() for local urls.

The git commands that git_connect is invoked for all take the repository
path as their last argument. In mercurial's case, the command is:
  hg -R $path serve --stdio

which doesn't match that pattern. So one hack I was thinking about was scan the url on my end, extract the path, replace it with "--stdio", and pass "hg -R $path serve" as command. Unfortunately, parse_connect_url is static, which means I'd either have to change connect.c to expose it, or copy it. Since I'd rather avoid copying code, I figured that since I was going to have to change connect.c, I might as well go with something less hacky, assuming it's accepted mainline.

So following here are four patches that allow me to connect, via ssh, to hg.mozilla.org, and access mercurial repositories there using:

  git_connect(fd, url, "hg -R %s serve --stdio",
              CONNECT_RELATIVE_SSH | CONNECT_WANT_STDERR)
And this works for local urls too, invoking `hg serve` locally.

Note that what the second patch does could be done in sq_quote_buf instead, arguably.

I'm certainly open to any better ideas as long as they can make it to mainline :).

Mike Hommey (4):
  git_connect: extend to take a pseudo format string for the program to
    run
  git_connect: avoid quoting the path on the command line when it's not
    necessary
  git_connect: allow a file descriptor to be allocated for stderr
  git_connect: add a flag to consider the path part of ssh urls relative
 connect.c | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
 connect.h |  2 ++
 2 files changed, 46 insertions(+), 8 deletions(-)
-- 
2.8.1.5.g18c8a48
Next: Mike Hommey
Message 1 of 15 in “git_connect: add some flexibility”
  1. 0/4 git_connect: add some flexibilityMike Hommey, Apr 28, 2016
  2. 1/4 git_connect: extend to take a pseudo format string for the program to runMike Hommey, Apr 28, 2016
  3. 2/4 git_connect: avoid quoting the path on the command line when it's not necessaryMike Hommey, Apr 28, 2016
  4. Stefan BellerApr 28, 2016
  5. 3/4 git_connect: allow a file descriptor to be allocated for stderrMike Hommey, Apr 28, 2016
  6. 4/4 git_connect: add a flag to consider the path part of ssh urls relativeMike Hommey, Apr 28, 2016
  7. Junio C HamanoApr 28, 2016
  8. Mike HommeyApr 28, 2016
  9. 1/3 connect: make parse_connect_url publicMike Hommey, Apr 29, 2016
  10. 2/3 connect: group CONNECT_DIAG_URL handling codeMike Hommey, Apr 29, 2016
  11. Junio C HamanoApr 29, 2016
  12. Junio C HamanoApr 29, 2016
  13. Torsten BögershausenApr 29, 2016
  14. 3/3 connect: move ssh command line preparation to a separate (public) functionMike Hommey, Apr 29, 2016
  15. Junio C HamanoApr 29, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.