11
11
#include "builtin.h"
12
12
#include "tree.h"
13
13
#include "parse-options.h"
14
+ #include "resolve-undo.h"
15
+ #include "string-list.h"
14
16
15
17
static int abbrev ;
16
18
static int show_deleted ;
17
19
static int show_cached ;
18
20
static int show_others ;
19
21
static int show_stage ;
20
22
static int show_unmerged ;
23
+ static int show_resolve_undo ;
21
24
static int show_modified ;
22
25
static int show_killed ;
23
26
static int show_valid_bit ;
@@ -37,6 +40,7 @@ static const char *tag_removed = "";
37
40
static const char * tag_other = "" ;
38
41
static const char * tag_killed = "" ;
39
42
static const char * tag_modified = "" ;
43
+ static const char * tag_resolve_undo = "" ;
40
44
41
45
static void show_dir_entry (const char * tag , struct dir_entry * ent )
42
46
{
@@ -155,6 +159,38 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
155
159
write_name_quoted (ce -> name + offset , stdout , line_terminator );
156
160
}
157
161
162
+ static int show_one_ru (struct string_list_item * item , void * cbdata )
163
+ {
164
+ int offset = prefix_offset ;
165
+ const char * path = item -> string ;
166
+ struct resolve_undo_info * ui = item -> util ;
167
+ int i , len ;
168
+
169
+ len = strlen (path );
170
+ if (len < prefix_len )
171
+ return 0 ; /* outside of the prefix */
172
+ if (!match_pathspec (pathspec , path , len , prefix_len , ps_matched ))
173
+ return 0 ; /* uninterested */
174
+ for (i = 0 ; i < 3 ; i ++ ) {
175
+ if (!ui -> mode [i ])
176
+ continue ;
177
+ printf ("%s%06o %s %d\t" , tag_resolve_undo , ui -> mode [i ],
178
+ abbrev
179
+ ? find_unique_abbrev (ui -> sha1 [i ], abbrev )
180
+ : sha1_to_hex (ui -> sha1 [i ]),
181
+ i + 1 );
182
+ write_name_quoted (path + offset , stdout , line_terminator );
183
+ }
184
+ return 0 ;
185
+ }
186
+
187
+ static void show_ru_info (const char * prefix )
188
+ {
189
+ if (!the_index .resolve_undo )
190
+ return ;
191
+ for_each_string_list (show_one_ru , the_index .resolve_undo , NULL );
192
+ }
193
+
158
194
static void show_files (struct dir_struct * dir , const char * prefix )
159
195
{
160
196
int i ;
@@ -454,6 +490,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
454
490
DIR_HIDE_EMPTY_DIRECTORIES ),
455
491
OPT_BOOLEAN ('u' , "unmerged" , & show_unmerged ,
456
492
"show unmerged files in the output" ),
493
+ OPT_BOOLEAN (0 , "resolve-undo" , & show_resolve_undo ,
494
+ "show resolve-undo information" ),
457
495
{ OPTION_CALLBACK , 'x' , "exclude" , & dir .exclude_list [EXC_CMDL ], "pattern" ,
458
496
"skip files matching pattern" ,
459
497
0 , option_parse_exclude },
@@ -490,6 +528,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
490
528
tag_modified = "C " ;
491
529
tag_other = "? " ;
492
530
tag_killed = "K " ;
531
+ tag_resolve_undo = "U " ;
493
532
}
494
533
if (show_modified || show_others || show_deleted || (dir .flags & DIR_SHOW_IGNORED ) || show_killed )
495
534
require_work_tree = 1 ;
@@ -529,7 +568,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
529
568
530
569
/* With no flags, we default to showing the cached files */
531
570
if (!(show_stage | show_deleted | show_others | show_unmerged |
532
- show_killed | show_modified ))
571
+ show_killed | show_modified | show_resolve_undo ))
533
572
show_cached = 1 ;
534
573
535
574
if (prefix )
@@ -544,6 +583,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
544
583
overlay_tree_on_cache (with_tree , prefix );
545
584
}
546
585
show_files (& dir , prefix );
586
+ if (show_resolve_undo )
587
+ show_ru_info (prefix );
547
588
548
589
if (ps_matched ) {
549
590
int bad ;
0 commit comments