Re: [PATCH v4 04/10] setup_git_directory_1(): avoid changing global state
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 7, 2017, 23:24 UTC
- Message-ID
- <xmqqtw744qmm.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <2c8ab22700fb40c9e4e9b46f4981b45db7f2dcf2.1488897111.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 32 quoted lines
> + switch (setup_git_directory_gently_1(&dir, &gitdir)) {
> + case GIT_DIR_NONE:
> + prefix = NULL;
> + break;
> + case GIT_DIR_EXPLICIT:
> + prefix = setup_explicit_git_dir(gitdir.buf, &cwd, nongit_ok);
> + break;
> + case GIT_DIR_DISCOVERED:
> + if (dir.len < cwd.len && chdir(dir.buf))
> + die(_("Cannot change to '%s'"), dir.buf);
> + prefix = setup_discovered_git_dir(gitdir.buf, &cwd, dir.len,
> + nongit_ok);
> + break;
> + case GIT_DIR_BARE:
> + if (dir.len < cwd.len && chdir(dir.buf))
> + die(_("Cannot change to '%s'"), dir.buf);
> + prefix = setup_bare_git_dir(&cwd, dir.len, nongit_ok);
> + break;
> + case GIT_DIR_HIT_CEILING:
> + prefix = setup_nongit(cwd.buf, nongit_ok);
> + break;
> + case GIT_DIR_HIT_MOUNT_POINT:
> + if (nongit_ok) {
> + *nongit_ok = 1;
> + return NULL;
> + }
> + die(_("Not a git repository (or any parent up to mount point %s)\n"
> + "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."),
> + dir.buf);
> + default:
> + die("BUG: unhandled setup_git_directory_1() result");
> + }I _might_ find niggles in other patches (and other parts of this patch) that enables the above clean implementation, but this switch() statement speaks of the value of this entire series ;-)
Very nicely done.