@@ -1212,19 +1212,6 @@ static const char *allowed_bare_repo_to_string(
1212
1212
return NULL ;
1213
1213
}
1214
1214
1215
- enum discovery_result {
1216
- GIT_DIR_NONE = 0 ,
1217
- GIT_DIR_EXPLICIT ,
1218
- GIT_DIR_DISCOVERED ,
1219
- GIT_DIR_BARE ,
1220
- /* these are errors */
1221
- GIT_DIR_HIT_CEILING = -1 ,
1222
- GIT_DIR_HIT_MOUNT_POINT = -2 ,
1223
- GIT_DIR_INVALID_GITFILE = -3 ,
1224
- GIT_DIR_INVALID_OWNERSHIP = -4 ,
1225
- GIT_DIR_DISALLOWED_BARE = -5 ,
1226
- };
1227
-
1228
1215
/*
1229
1216
* We cannot decide in this function whether we are in the work tree or
1230
1217
* not, since the config can only be read _after_ this function was called.
@@ -1376,21 +1363,22 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
1376
1363
}
1377
1364
}
1378
1365
1379
- int discover_git_directory (struct strbuf * commondir ,
1380
- struct strbuf * gitdir )
1366
+ enum discovery_result discover_git_directory_reason (struct strbuf * commondir ,
1367
+ struct strbuf * gitdir )
1381
1368
{
1382
1369
struct strbuf dir = STRBUF_INIT , err = STRBUF_INIT ;
1383
1370
size_t gitdir_offset = gitdir -> len , cwd_len ;
1384
1371
size_t commondir_offset = commondir -> len ;
1385
1372
struct repository_format candidate = REPOSITORY_FORMAT_INIT ;
1373
+ enum discovery_result result ;
1386
1374
1387
1375
if (strbuf_getcwd (& dir ))
1388
- return -1 ;
1376
+ return GIT_DIR_CWD_FAILURE ;
1389
1377
1390
1378
cwd_len = dir .len ;
1391
- if (setup_git_directory_gently_1 (& dir , gitdir , NULL , 0 ) <= 0 ) {
1379
+ if (( result = setup_git_directory_gently_1 (& dir , gitdir , NULL , 0 ) ) <= 0 ) {
1392
1380
strbuf_release (& dir );
1393
- return -1 ;
1381
+ return result ;
1394
1382
}
1395
1383
1396
1384
/*
@@ -1420,7 +1408,7 @@ int discover_git_directory(struct strbuf *commondir,
1420
1408
strbuf_setlen (commondir , commondir_offset );
1421
1409
strbuf_setlen (gitdir , gitdir_offset );
1422
1410
clear_repository_format (& candidate );
1423
- return -1 ;
1411
+ return GIT_DIR_INVALID_FORMAT ;
1424
1412
}
1425
1413
1426
1414
/* take ownership of candidate.partial_clone */
@@ -1429,7 +1417,7 @@ int discover_git_directory(struct strbuf *commondir,
1429
1417
candidate .partial_clone = NULL ;
1430
1418
1431
1419
clear_repository_format (& candidate );
1432
- return 0 ;
1420
+ return result ;
1433
1421
}
1434
1422
1435
1423
const char * setup_git_directory_gently (int * nongit_ok )
@@ -1521,9 +1509,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
1521
1509
* nongit_ok = 1 ;
1522
1510
break ;
1523
1511
case GIT_DIR_NONE :
1512
+ case GIT_DIR_CWD_FAILURE :
1513
+ case GIT_DIR_INVALID_FORMAT :
1524
1514
/*
1525
1515
* As a safeguard against setup_git_directory_gently_1 returning
1526
- * this value , fallthrough to BUG. Otherwise it is possible to
1516
+ * these values , fallthrough to BUG. Otherwise it is possible to
1527
1517
* set startup_info->have_repository to 1 when we did nothing to
1528
1518
* find a repository.
1529
1519
*/
0 commit comments