diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-08-15 10:19:47 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-08-15 10:19:47 -0700 |
commit | 8e12aaa7ceb83c9229b392079ed9e38c36e82b81 (patch) | |
tree | 70ab537d344e98f2f8c6a31265c001912ce0f3e3 /builtin | |
parent | cecd6a5ffce2c35f18e8ac537c9e2f71ac99932b (diff) | |
parent | 72695d8214791161a943086e894874b4fd71ba9f (diff) |
Merge branch 'st/mv-lstat-fix'
Correct use of lstat() that assumed a failing call would not
clobber the statbuf.
* st/mv-lstat-fix:
mv: handle lstat() failure correctly
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/mv.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/mv.c b/builtin/mv.c index fa84fcb20d..05e7156034 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -184,7 +184,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) int src_dir_nr = 0, src_dir_alloc = 0; struct strbuf a_src_dir = STRBUF_INIT; enum update_mode *modes, dst_mode = 0; - struct stat st; + struct stat st, dest_st; struct string_list src_for_dst = STRING_LIST_INIT_NODUP; struct lock_file lock_file = LOCK_INIT; struct cache_entry *ce; @@ -304,7 +304,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) goto act_on_entry; } if (S_ISDIR(st.st_mode) - && lstat(dst, &st) == 0) { + && lstat(dst, &dest_st) == 0) { bad = _("cannot move directory over file"); goto act_on_entry; } |