#define ERROR_OBJECT 01
#define ERROR_REACHABLE 02
#define ERROR_PACK 04
+#define ERROR_REFS 010
- #ifdef NO_D_INO_IN_DIRENT
- #define SORT_DIRENT 0
- #define DIRENT_SORT_HINT(de) 0
- #else
- #define SORT_DIRENT 1
- #define DIRENT_SORT_HINT(de) ((de)->d_ino)
- #endif
-
static int fsck_config(const char *var, const char *value, void *cb)
{
if (strcmp(var, "fsck.skiplist") == 0) {
const char *fmt, va_list args)
{
const char *git_dir;
+ struct strbuf git_submodule_common_dir = STRBUF_INIT;
+ struct strbuf git_submodule_dir = STRBUF_INIT;
strbuf_addstr(buf, path);
- if (buf->len && buf->buf[buf->len - 1] != '/')
- strbuf_addch(buf, '/');
+ strbuf_complete(buf, '/');
strbuf_addstr(buf, ".git");
git_dir = read_gitfile(buf->buf);
}
if (!suffix[i])
return NULL;
- gitfile = read_gitfile(used_path);
- if (gitfile)
- strcpy(used_path, gitfile);
- if (chdir(used_path))
- gitfile = read_gitfile(used_path.buf) ;
++ gitfile = read_gitfile(used_path.buf);
+ if (gitfile) {
+ strbuf_reset(&used_path);
+ strbuf_addstr(&used_path, gitfile);
+ }
+ if (chdir(used_path.buf))
return NULL;
- path = validated_path;
+ path = validated_path.buf;
}
- else if (chdir(path))
- return NULL;
+ else {
+ const char *gitfile = read_gitfile(path);
+ if (gitfile)
+ path = gitfile;
+ if (chdir(path))
+ return NULL;
+ }
- if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
- validate_headref("HEAD") == 0) {
+ if (is_git_directory(".")) {
set_git_dir(".");
check_repository_format();
return path;
struct strbuf objects_directory = STRBUF_INIT;
struct alternate_object_database *alt_odb;
int ret = 0;
- const char *git_dir;
+ int alloc;
- strbuf_addf(&objects_directory, "%s/.git", path);
- git_dir = read_gitfile(objects_directory.buf);
- if (git_dir) {
- strbuf_reset(&objects_directory);
- strbuf_addstr(&objects_directory, git_dir);
- }
- strbuf_addstr(&objects_directory, "/objects/");
+ strbuf_git_path_submodule(&objects_directory, path, "objects/");
if (!is_directory(objects_directory.buf)) {
ret = -1;
goto done;