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
This commit is contained in:
		@ -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;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -174,6 +174,13 @@ test_expect_success 'do not move directory over existing directory' '
 | 
			
		||||
	test_must_fail git mv path2 path0
 | 
			
		||||
'
 | 
			
		||||
 | 
			
		||||
test_expect_success 'rename directory to non-existing directory' '
 | 
			
		||||
	mkdir dir-a &&
 | 
			
		||||
	>dir-a/f &&
 | 
			
		||||
	git add dir-a &&
 | 
			
		||||
	git mv dir-a non-existing-dir
 | 
			
		||||
'
 | 
			
		||||
 | 
			
		||||
test_expect_success 'move into "."' '
 | 
			
		||||
	git mv path1/path2/ .
 | 
			
		||||
'
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user