ls-files: convert write_eolinfo to take an index
authorBrandon Williams <bmwill@google.com>
Mon, 12 Jun 2017 22:13:59 +0000 (15:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Jun 2017 18:40:51 +0000 (11:40 -0700)
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/ls-files.c
index a78b291abdf52057cba561e8c26594fb07acb71e..8c3f3d8cac91c5b7ce9def93fdf1b1c1c4e2cf80 100644 (file)
@@ -53,17 +53,16 @@ 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)
+static void write_eolinfo(const struct index_state *istate,
+                         const struct cache_entry *ce, const char *path)
 {
-       if (!show_eol)
-               return;
-       else {
+       if (show_eol) {
                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(&the_index,
+                       i_txt = get_cached_convert_stats_ascii(istate,
                                                               ce->name);
                if (!lstat(path, &st) && S_ISREG(st.st_mode))
                        w_txt = get_wt_convert_stats_ascii(path);
@@ -105,7 +104,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)
                return;
 
        fputs(tag, stdout);
-       write_eolinfo(NULL, ent->name);
+       write_eolinfo(NULL, NULL, ent->name);
        write_name(ent->name);
 }
 
@@ -275,7 +274,7 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
                               find_unique_abbrev(ce->oid.hash, abbrev),
                               ce_stage(ce));
                }
-               write_eolinfo(ce, ce->name);
+               write_eolinfo(&the_index, ce, ce->name);
                write_name(ce->name);
                if (debug_mode) {
                        const struct stat_data *sd = &ce->ce_stat_data;