git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: git@vger.kernel.org
Subject: Standardized escaping to store a .git in git?
Date: Wed, 19 May 2021 14:00:52 -0700	[thread overview]
Message-ID: <YKV8hEAxIzolnROX@localhost> (raw)

On rare occasions, a project may need to store and version a .git
directory in a git repository. For instance, a project that interacts
with git repositories may need test cases. Or, a project using git to
store backups may also want to back up git repositories. `.git` is the
only filename that git can't transparently store and version.

I've seen projects take different approaches to work around this. For
instance, the libgit2 project renames the `.git` directory to `.gitted`,
and then their test framework copies that to a temporary directory as
`.git`.

Would it make sense to have a standardized escaping mechanism for this,
that git could then standardize the handling of in a safe way (taking
both project configuration and local configuration into account)? Such a
mechanism would not, by default, result in git checking out a `.git`
directory verbatim, as that wouldn't be safe (due to hook scripts and
due to searches for .git directories), but a user could configure their
own system to do so for a specific project, tools like `git archive`
could have a way to un-escape the directory in a generated archive, and
references to objects within a treeish could use such paths.
Standardizing this would allow tools to interoperate rather than each
inventing their own convention.

(Note that today, git *can* successfully check in, version, update, and
check out a bare repo.git directory, just not a non-bare .git
directory.)

As one possible escaping (absolutely subject to bikeshedding):

- Reserve names starting with a specified character (e.g. \x01); call
  that escape character E.
- Encode filenames that actually start with E to start with EE
- Encode .git as E.git
- Require an opt-in to interpret this escaping; tools that don't
  interpret this escaping will still be able to operate on the files, in
  much the same way that it's possible to operate on a symlink as if it
  were a file containing the target path.

There are tradeoffs here: using a more type-able escape character would
be convenient if a user ever had to deal with the raw name, but on the
other hand, using a more type-able escape character would make the need
to escape the escape character come up more often.

Regardless of the specific approach to escaping `.git`, does the general
idea of standardizing such escaping across tools seem like something git
could potentially do, to allow transparently storing *any* file or
directory in a git repository?

- Josh Triplett

             reply	other threads:[~2021-05-19 21:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 21:00 Josh Triplett [this message]
2021-05-19 21:31 ` Standardized escaping to store a .git in git? Jonathan Nieder
2021-05-19 22:08   ` Josh Triplett
2021-05-19 22:37     ` Jonathan Nieder
2021-05-20  3:26       ` Josh Triplett

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=YKV8hEAxIzolnROX@localhost \
    --to=josh@joshtriplett.org \
    --cc=git@vger.kernel.org \
    /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).