File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -137,26 +137,31 @@ function FileEntry:validate_stage_buffers(adapter, stat)
137137 if not cached_stat or cached_stat .mtime < stat .mtime .sec then
138138 for _ , f in ipairs (self .layout :files ()) do
139139 if f .rev .type == RevType .STAGE and f :is_valid () then
140- if f .rev .stage == 0 then
140+ if f .rev .stage > 0 then
141+ -- We only care about stage 0 here
142+ f :dispose_buffer ()
143+ else
141144 local is_modified = vim .bo [f .bufnr ].modified
142145
143146 if f .blob_hash then
144147 local new_hash = f .adapter :file_blob_hash (f .path )
145- if new_hash and new_hash ~= f .blob_hash and is_modified then
146- utils .warn ((
147- " A file was changed in the index since you started editing it!"
148- .. " Be careful not to lose any staged changes when writing to this buffer: %s"
149- ):format (api .nvim_buf_get_name (f .bufnr )))
148+
149+ if new_hash and new_hash ~= f .blob_hash then
150+ if is_modified then
151+ utils .warn ((
152+ " A file was changed in the index since you started editing it!"
153+ .. " Be careful not to lose any staged changes when writing to this buffer: %s"
154+ ):format (api .nvim_buf_get_name (f .bufnr )))
155+ else
156+ f :dispose_buffer ()
157+ end
150158 end
151159 elseif not is_modified then
152160 -- Should be very rare that we don't have an index-buffer's blob
153161 -- hash. But in that case, we can't warn the user when a file
154162 -- changes in the index while they're editing its index buffer.
155163 f :dispose_buffer ()
156164 end
157-
158- else
159- f :dispose_buffer ()
160165 end
161166 end
162167 end
Original file line number Diff line number Diff line change @@ -1081,11 +1081,12 @@ function GitAdapter:file_blob_hash(path, rev_arg)
10811081 " rev-parse" ,
10821082 " --revs-only" ,
10831083 (" %s:%s" ):format (rev_arg or " " , path )
1084- }, self .ctx .toplevel )
1084+ }, {
1085+ cwd = self .ctx .toplevel ,
1086+ retry_on_empty = 2 ,
1087+ })
10851088
1086- if code ~= 0 then
1087- return
1088- end
1089+ if code ~= 0 then return end
10891090
10901091 return vim .trim (out [1 ])
10911092end
You can’t perform that action at this time.
0 commit comments