@@ -129,44 +129,47 @@ end
129
129
130
130
--- Git file status for an absolute path with optional fallback
131
131
--- @param parent_ignored boolean
132
- --- @param status table | nil
132
+ --- @param status table ?
133
133
--- @param path string
134
134
--- @param path_fallback string ?
135
135
--- @return GitStatus
136
136
function M .git_status_file (parent_ignored , status , path , path_fallback )
137
- if parent_ignored then
138
- return { file = " !!" }
139
- end
137
+ --- @type GitStatus
138
+ local st = {}
140
139
141
- if not status or not status .files then
142
- return {}
140
+ if parent_ignored then
141
+ st .file = " !!"
142
+ elseif status and status .files then
143
+ st .file = status .files [path ] or status .files [path_fallback ]
143
144
end
144
145
145
- return {
146
- file = status .files [path ] or status .files [path_fallback ]
147
- }
146
+ return st
148
147
end
149
148
150
149
--- Git file and directory status for an absolute path with optional file fallback
151
150
--- @param parent_ignored boolean
152
- --- @param status table | nil
151
+ --- @param status table ?
153
152
--- @param path string
154
153
--- @param path_file string ? alternative file path when no other file status
155
- --- @return GitStatus | nil
154
+ --- @return GitStatus ?
156
155
function M .git_status_dir (parent_ignored , status , path , path_file )
156
+ --- @type GitStatus ?
157
+ local st
158
+
157
159
if parent_ignored then
158
- return { file = " !!" }
160
+ st = {}
161
+ st .file = " !!"
162
+ elseif status then
163
+ st = {}
164
+ st .file = status .files and (status .files [path ] or status .files [path_file ])
165
+ if status .dirs then
166
+ st .dir = {}
167
+ st .dir .direct = status .dirs .direct and status .dirs .direct [path ]
168
+ st .dir .indirect = status .dirs .indirect and status .dirs .indirect [path ]
169
+ end
159
170
end
160
171
161
- if status then
162
- return {
163
- file = status .files and (status .files [path ] or status .files [path_file ]),
164
- dir = status .dirs and {
165
- direct = status .dirs .direct and status .dirs .direct [path ],
166
- indirect = status .dirs .indirect and status .dirs .indirect [path ],
167
- },
168
- }
169
- end
172
+ return st
170
173
end
171
174
172
175
function M .setup (opts )
0 commit comments