From 1a77f1c00e12e8460f39098ec3289c5433d32512 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 26 Oct 2020 20:31:54 -0400 Subject: [PATCH] Recover from deleted temp script Closes https://github.com/tpope/vim-fugitive/issues/1616 --- autoload/fugitive.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index c613142..d2a100f 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -146,11 +146,13 @@ endif function! s:TempScript(...) abort let body = join(a:000, "\n") if !has_key(s:temp_scripts, body) - let temp = tempname() . '.sh' - call writefile(['#!/bin/sh'] + a:000, temp) - let s:temp_scripts[body] = temp + let s:temp_scripts[body] = tempname() . '.sh' endif - return FugitiveGitPath(s:temp_scripts[body]) + let temp = s:temp_scripts[body] + if !filereadable(temp) + call writefile(['#!/bin/sh'] + a:000, temp) + endif + return FugitiveGitPath(temp) endfunction function! s:DoAutocmd(cmd) abort