diff options
author | Jeff King <peff@peff.net> | 2016-03-11 17:37:07 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-03-11 15:02:23 -0800 |
commit | 2cc7c2c737f2af16915b3d6cb6245111e1349609 (patch) | |
tree | a1940e2efd97afff6a2c881b4254b3a0d23e7bba /builtin/worktree.c | |
parent | config: drop git_config_early (diff) | |
download | tgif-2cc7c2c737f2af16915b3d6cb6245111e1349609.tar.xz |
setup: refactor repo format reading and verification
When we want to know if we're in a git repository of
reasonable vintage, we can call check_repository_format_gently(),
which does three things:
1. Reads the config from the .git/config file.
2. Verifies that the version info we read is sane.
3. Writes some global variables based on this.
There are a few things we could improve here.
One is that steps 1 and 3 happen together. So if the
verification in step 2 fails, we still clobber the global
variables. This is especially bad if we go on to try another
repository directory; we may end up with a state of mixed
config variables.
The second is there's no way to ask about the repository
version for anything besides the main repository we're in.
git-init wants to do this, and it's possible that we would
want to start doing so for submodules (e.g., to find out
which ref backend they're using).
We can improve both by splitting the first two steps into
separate functions. Now check_repository_format_gently()
calls out to steps 1 and 2, and does 3 only if step 2
succeeds.
Note that the public interface for read_repository_format()
and what check_repository_format_gently() needs from it are
not quite the same, leading us to have an extra
read_repository_format_1() helper. The extra needs from
check_repository_format_gently() will go away in a future
patch, and we can simplify this then to just the public
interface.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/worktree.c')
0 files changed, 0 insertions, 0 deletions