@@ -992,13 +992,15 @@ static void diagnose_invalid_index_path(int stage,
992992 pos = cache_name_pos (filename , namelen );
993993 if (pos < 0 )
994994 pos = - pos - 1 ;
995- ce = active_cache [pos ];
996- if (ce_namelen (ce ) == namelen &&
997- !memcmp (ce -> name , filename , namelen ))
998- die ("Path '%s' is in the index, but not at stage %d.\n"
999- "Did you mean ':%d:%s'?" ,
1000- filename , stage ,
1001- ce_stage (ce ), filename );
995+ if (pos < active_nr ) {
996+ ce = active_cache [pos ];
997+ if (ce_namelen (ce ) == namelen &&
998+ !memcmp (ce -> name , filename , namelen ))
999+ die ("Path '%s' is in the index, but not at stage %d.\n"
1000+ "Did you mean ':%d:%s'?" ,
1001+ filename , stage ,
1002+ ce_stage (ce ), filename );
1003+ }
10021004
10031005 /* Confusion between relative and absolute filenames? */
10041006 fullnamelen = namelen + strlen (prefix );
@@ -1008,13 +1010,15 @@ static void diagnose_invalid_index_path(int stage,
10081010 pos = cache_name_pos (fullname , fullnamelen );
10091011 if (pos < 0 )
10101012 pos = - pos - 1 ;
1011- ce = active_cache [pos ];
1012- if (ce_namelen (ce ) == fullnamelen &&
1013- !memcmp (ce -> name , fullname , fullnamelen ))
1014- die ("Path '%s' is in the index, but not '%s'.\n"
1015- "Did you mean ':%d:%s'?" ,
1016- fullname , filename ,
1017- ce_stage (ce ), fullname );
1013+ if (pos < active_nr ) {
1014+ ce = active_cache [pos ];
1015+ if (ce_namelen (ce ) == fullnamelen &&
1016+ !memcmp (ce -> name , fullname , fullnamelen ))
1017+ die ("Path '%s' is in the index, but not '%s'.\n"
1018+ "Did you mean ':%d:%s'?" ,
1019+ fullname , filename ,
1020+ ce_stage (ce ), fullname );
1021+ }
10181022
10191023 if (!lstat (filename , & st ))
10201024 die ("Path '%s' exists on disk, but not in the index." , filename );
0 commit comments