Merge branch 'mg/mingw-test-fix'
[gitweb.git] / builtin / ls-files.c
index 467699bcf5edad871784384cb6a5db178d0dc6d6..f02e3d23bb71a39dfd9f6eddf40aa84da896b650 100644 (file)
@@ -27,6 +27,7 @@ static int show_killed;
 static int show_valid_bit;
 static int line_terminator = '\n';
 static int debug_mode;
+static int show_eol;
 
 static const char *prefix;
 static int max_prefix_len;
@@ -47,6 +48,23 @@ static const char *tag_modified = "";
 static const char *tag_skip_worktree = "";
 static const char *tag_resolve_undo = "";
 
+static void write_eolinfo(const struct cache_entry *ce, const char *path)
+{
+       if (!show_eol)
+               return;
+       else {
+               struct stat st;
+               const char *i_txt = "";
+               const char *w_txt = "";
+               const char *a_txt = get_convert_attr_ascii(path);
+               if (ce && S_ISREG(ce->ce_mode))
+                       i_txt = get_cached_convert_stats_ascii(ce->name);
+               if (!lstat(path, &st) && S_ISREG(st.st_mode))
+                       w_txt = get_wt_convert_stats_ascii(path);
+               printf("i/%-5s w/%-5s attr/%-17s\t", i_txt, w_txt, a_txt);
+       }
+}
+
 static void write_name(const char *name)
 {
        /*
@@ -68,6 +86,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)
                return;
 
        fputs(tag, stdout);
+       write_eolinfo(NULL, ent->name);
        write_name(ent->name);
 }
 
@@ -170,6 +189,7 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
                       find_unique_abbrev(ce->sha1,abbrev),
                       ce_stage(ce));
        }
+       write_eolinfo(ce, ce->name);
        write_name(ce->name);
        if (debug_mode) {
                const struct stat_data *sd = &ce->ce_stat_data;
@@ -425,6 +445,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
                OPT_BIT(0, "directory", &dir.flags,
                        N_("show 'other' directories' names only"),
                        DIR_SHOW_OTHER_DIRECTORIES),
+               OPT_BOOL(0, "eol", &show_eol, N_("show line endings of files")),
                OPT_NEGBIT(0, "empty-directory", &dir.flags,
                        N_("don't show empty directories"),
                        DIR_HIDE_EMPTY_DIRECTORIES),