From: Junio C Hamano <junkio@cox.net>
To: Martin Atukunda <matlads@dsmagic.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/6] Add check_repo_format check for all major operations.
Date: Tue, 22 Nov 2005 16:57:13 -0800 [thread overview]
Message-ID: <7v8xvg89li.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vd5ksefth.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Tue, 22 Nov 2005 09:46:18 -0800")
Junio C Hamano <junkio@cox.net> writes:
> Yes, although that is exactly what I said "this does not quite
> feel right" ;-). Is it hard to arrange things so that a process
> does exactly one check_repo_format() during its lifetime?
Let's back up a bit. I'll deal with only low-level commands
here.
First, the easiest group. The following commands do not look at
the repository (.git directory) at all.
check-ref-format get-tar-commit-id git index-pack mailinfo
mailsplit patch-id shell show-index stripspace verify-pack
We do not need to do anything special about them.
The following three use enter_repo() to the given path (either
from the end user at the command line or over the network):
daemon receive-pack upload-pack
The repo format check should be done at the same place as we
make sure enter_repo() finds the given directory a satisfactory
path. That is, just before putenv(GIT_DIR=.) in enter_repo().
The following use setup_git_directory(), which chdir()s to the
toplevel unless GIT_DIR is set.
cat-file config-set diff-files diff-index diff-stages diff-tree
ls-files name-rev rev-list rev-parse show-branch symbolic-ref
update-index update-ref
Maybe we can have a thin wrapper around setup_git_directory()
and after it returns check "${GIT_DIR-.git}" for repository
format mismatch. What to do when GIT_DIR is set? Then we can
just use it to read the config from "$GIT_DIR/config" and check
the version.
The following commands implicitly assume that they are either
run from the toplevel or GIT_DIR environment tells them where
the .git/ directory is:
apply checkout-index clone-pack commit-tree convert-objects
fetch-pack fsck-objects hash-object http-fetch http-push init-db
local-fetch ls-tree merge-base merge-index mktag pack-objects
pack-redundant peek-remote prune-packed read-tree send-pack
ssh-fetch ssh-upload tar-tree unpack-file unpack-objects
update-server-info var write-tree
With some exceptions, they are pretty much repository wide
commands, so I think it is OK for them to assume they start at
the toplevel (the Porcelain would chdir to the top for them
otherwise). The ones that take paths, namely, checkout-index,
hash-object and ls-tree, may want to use setup_git_directory()
and do the path prefixing.
That means we would need to have some way for the rest of the
commands to check if "${GIT_DIR-.git}" is of the right format
version, and call that *once* per process invocation,
perferrably at the beginning of the main().
We need an access to .git/config file to do the repository
format check anyway, which means we need setup_git_directory()
if we ever want to run them from subdirectories. And running
setup_git_directory() from the toplevel would not hurt, so
perhaps if we add setup_git_directory() at the beginning of
main() for the "implicity toplevel" class, and rewrite
setup_git_directory() like this:
static const char *setup_git_directory_main(void)
{
/* current setup_git_driectory() */
}
const char *setup_git_directory(void)
{
const char *retval = setup_git_directory_main();
check_repository_format_version(); /* dies on mismatch */
return retval;
}
it _might_ be good enough.
I said "it _might_" here, because we need to be careful. Right
now, if you run the "implicitly toplevel" commands from a
subdirectory, they fail. Some Porcelains and scripts may be
relying on that and there will be consequences if things
suddenly start not to fail but do something unexpected in higher
directories.
next prev parent reply other threads:[~2005-11-23 0:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-22 0:28 Git Future Proofing Martin Atukunda
2005-11-22 0:28 ` [PATCH 1/6] Add GIT_REPO_VERSION, and repository_format_version Martin Atukunda
2005-11-22 0:28 ` [PATCH 3/6] Make get_git_dir take a flag that makes it re-read the env. variables Martin Atukunda
2005-11-22 0:28 ` [PATCH 2/6] Make init-db check repo format version if copying a config file Martin Atukunda
2005-11-22 0:28 ` [PATCH 4/6] Add check_repo_format check for all major operations Martin Atukunda
2005-11-22 8:29 ` Junio C Hamano
2005-11-22 12:55 ` Martin Atukunda
2005-11-22 17:46 ` Junio C Hamano
2005-11-23 0:57 ` Junio C Hamano [this message]
2005-11-22 0:28 ` [PATCH 6/6] Add check for downgrading of repo format version via init-db Martin Atukunda
2005-11-22 0:28 ` [PATCH 5/6] Allow Specification of the conf file to read for git_config operations Martin Atukunda
2005-11-22 1:13 ` Git Future Proofing 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=7v8xvg89li.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=matlads@dsmagic.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).