@@ -1205,19 +1205,6 @@ static const char *allowed_bare_repo_to_string(
1205
1205
return NULL ;
1206
1206
}
1207
1207
1208
- enum discovery_result {
1209
- GIT_DIR_NONE = 0 ,
1210
- GIT_DIR_EXPLICIT ,
1211
- GIT_DIR_DISCOVERED ,
1212
- GIT_DIR_BARE ,
1213
- /* these are errors */
1214
- GIT_DIR_HIT_CEILING = -1 ,
1215
- GIT_DIR_HIT_MOUNT_POINT = -2 ,
1216
- GIT_DIR_INVALID_GITFILE = -3 ,
1217
- GIT_DIR_INVALID_OWNERSHIP = -4 ,
1218
- GIT_DIR_DISALLOWED_BARE = -5 ,
1219
- };
1220
-
1221
1208
/*
1222
1209
* We cannot decide in this function whether we are in the work tree or
1223
1210
* not, since the config can only be read _after_ this function was called.
@@ -1368,21 +1355,22 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
1368
1355
}
1369
1356
}
1370
1357
1371
- int discover_git_directory (struct strbuf * commondir ,
1372
- struct strbuf * gitdir )
1358
+ enum discovery_result discover_git_directory_reason (struct strbuf * commondir ,
1359
+ struct strbuf * gitdir )
1373
1360
{
1374
1361
struct strbuf dir = STRBUF_INIT , err = STRBUF_INIT ;
1375
1362
size_t gitdir_offset = gitdir -> len , cwd_len ;
1376
1363
size_t commondir_offset = commondir -> len ;
1377
1364
struct repository_format candidate = REPOSITORY_FORMAT_INIT ;
1365
+ enum discovery_result result ;
1378
1366
1379
1367
if (strbuf_getcwd (& dir ))
1380
- return -1 ;
1368
+ return GIT_DIR_CWD_FAILURE ;
1381
1369
1382
1370
cwd_len = dir .len ;
1383
- if (setup_git_directory_gently_1 (& dir , gitdir , NULL , 0 ) <= 0 ) {
1371
+ if (( result = setup_git_directory_gently_1 (& dir , gitdir , NULL , 0 ) ) <= 0 ) {
1384
1372
strbuf_release (& dir );
1385
- return -1 ;
1373
+ return result ;
1386
1374
}
1387
1375
1388
1376
/*
@@ -1412,7 +1400,7 @@ int discover_git_directory(struct strbuf *commondir,
1412
1400
strbuf_setlen (commondir , commondir_offset );
1413
1401
strbuf_setlen (gitdir , gitdir_offset );
1414
1402
clear_repository_format (& candidate );
1415
- return -1 ;
1403
+ return GIT_DIR_INVALID_FORMAT ;
1416
1404
}
1417
1405
1418
1406
/* take ownership of candidate.partial_clone */
@@ -1421,7 +1409,7 @@ int discover_git_directory(struct strbuf *commondir,
1421
1409
candidate .partial_clone = NULL ;
1422
1410
1423
1411
clear_repository_format (& candidate );
1424
- return 0 ;
1412
+ return result ;
1425
1413
}
1426
1414
1427
1415
const char * setup_git_directory_gently (int * nongit_ok )
@@ -1513,9 +1501,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
1513
1501
* nongit_ok = 1 ;
1514
1502
break ;
1515
1503
case GIT_DIR_NONE :
1504
+ case GIT_DIR_CWD_FAILURE :
1505
+ case GIT_DIR_INVALID_FORMAT :
1516
1506
/*
1517
1507
* As a safeguard against setup_git_directory_gently_1 returning
1518
- * this value , fallthrough to BUG. Otherwise it is possible to
1508
+ * these values , fallthrough to BUG. Otherwise it is possible to
1519
1509
* set startup_info->have_repository to 1 when we did nothing to
1520
1510
* find a repository.
1521
1511
*/
0 commit comments