All of lore.kernel.org
 help / color / mirror / Atom feed
* Standardized escaping to store a .git in git?
@ 2021-05-19 21:00 Josh Triplett
  2021-05-19 21:31 ` Jonathan Nieder
  0 siblings, 1 reply; 5+ messages in thread
From: Josh Triplett @ 2021-05-19 21:00 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-20  3:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 21:00 Standardized escaping to store a .git in git? Josh Triplett
2021-05-19 21:31 ` Jonathan Nieder
2021-05-19 22:08   ` Josh Triplett
2021-05-19 22:37     ` Jonathan Nieder
2021-05-20  3:26       ` Josh Triplett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.