@@ -1001,7 +1001,8 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
1001
1001
*/
1002
1002
static struct cache_entry * refresh_cache_ent (struct index_state * istate ,
1003
1003
struct cache_entry * ce ,
1004
- unsigned int options , int * err )
1004
+ unsigned int options , int * err ,
1005
+ int * changed_ret )
1005
1006
{
1006
1007
struct stat st ;
1007
1008
struct cache_entry * updated ;
@@ -1033,6 +1034,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
1033
1034
}
1034
1035
1035
1036
changed = ie_match_stat (istate , ce , & st , options );
1037
+ if (changed_ret )
1038
+ * changed_ret = changed ;
1036
1039
if (!changed ) {
1037
1040
/*
1038
1041
* The path is unchanged. If we were told to ignore
@@ -1102,14 +1105,21 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
1102
1105
int first = 1 ;
1103
1106
int in_porcelain = (flags & REFRESH_IN_PORCELAIN );
1104
1107
unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0 ;
1105
- const char * needs_update_fmt ;
1106
- const char * needs_merge_fmt ;
1107
-
1108
- needs_update_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n" );
1109
- needs_merge_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n" );
1108
+ const char * modified_fmt ;
1109
+ const char * deleted_fmt ;
1110
+ const char * typechange_fmt ;
1111
+ const char * added_fmt ;
1112
+ const char * unmerged_fmt ;
1113
+
1114
+ modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n" );
1115
+ deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n" );
1116
+ typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n" );
1117
+ added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n" );
1118
+ unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n" );
1110
1119
for (i = 0 ; i < istate -> cache_nr ; i ++ ) {
1111
1120
struct cache_entry * ce , * new ;
1112
1121
int cache_errno = 0 ;
1122
+ int changed = 0 ;
1113
1123
1114
1124
ce = istate -> cache [i ];
1115
1125
if (ignore_submodules && S_ISGITLINK (ce -> ce_mode ))
@@ -1122,18 +1132,20 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
1122
1132
i -- ;
1123
1133
if (allow_unmerged )
1124
1134
continue ;
1125
- show_file (needs_merge_fmt , ce -> name , in_porcelain , & first , header_msg );
1135
+ show_file (unmerged_fmt , ce -> name , in_porcelain , & first , header_msg );
1126
1136
has_errors = 1 ;
1127
1137
continue ;
1128
1138
}
1129
1139
1130
1140
if (pathspec && !match_pathspec (pathspec , ce -> name , strlen (ce -> name ), 0 , seen ))
1131
1141
continue ;
1132
1142
1133
- new = refresh_cache_ent (istate , ce , options , & cache_errno );
1143
+ new = refresh_cache_ent (istate , ce , options , & cache_errno , & changed );
1134
1144
if (new == ce )
1135
1145
continue ;
1136
1146
if (!new ) {
1147
+ const char * fmt ;
1148
+
1137
1149
if (not_new && cache_errno == ENOENT )
1138
1150
continue ;
1139
1151
if (really && cache_errno == EINVAL ) {
@@ -1145,7 +1157,17 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
1145
1157
}
1146
1158
if (quiet )
1147
1159
continue ;
1148
- show_file (needs_update_fmt , ce -> name , in_porcelain , & first , header_msg );
1160
+
1161
+ if (cache_errno == ENOENT )
1162
+ fmt = deleted_fmt ;
1163
+ else if (ce -> ce_flags & CE_INTENT_TO_ADD )
1164
+ fmt = added_fmt ; /* must be before other checks */
1165
+ else if (changed & TYPE_CHANGED )
1166
+ fmt = typechange_fmt ;
1167
+ else
1168
+ fmt = modified_fmt ;
1169
+ show_file (fmt ,
1170
+ ce -> name , in_porcelain , & first , header_msg );
1149
1171
has_errors = 1 ;
1150
1172
continue ;
1151
1173
}
@@ -1157,7 +1179,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
1157
1179
1158
1180
static struct cache_entry * refresh_cache_entry (struct cache_entry * ce , int really )
1159
1181
{
1160
- return refresh_cache_ent (& the_index , ce , really , NULL );
1182
+ return refresh_cache_ent (& the_index , ce , really , NULL , NULL );
1161
1183
}
1162
1184
1163
1185
static int verify_hdr (struct cache_header * hdr , unsigned long size )
0 commit comments