Thread (7 messages) flat view 7 messages, 4 authors, 2016-06-15

Re: git-mv is not able to handle directory with one file in it

From: Andreas Ericsson <hidden>
Date: 2016-06-15 22:42:13

Alexander Litvinov wrote:
I have found one error during directory movig: If I move directory with one 
file somewhere in it this script will try to add target directory instead of 
file.
Are you saying this setup
	foodir/somefile.c     <--file
	newdir/               <--directory

with this command
	git-mv foodir/ newdir

tries to create
	newdir/foodir/somefile.c  <-- directory

or does it create
	newdir/somefile.c         <-- file

?

It should create
	newdir/foodir/somefile.c  <-- file

Otherwise it's misbehaving.

Try running it with the -v switch to make it shout out loud what it's 
trying to do, and then paste the output here.
Commenting lines starting from 190 solve this error. But I don't 
understand what is the logic behind this case ? Why do target directory 
checked instead of target file ? Should we replace $dst my $destfiles[0] ?

at line 190 in git-mv:
    if (scalar @srcfiles == 1) {
	if ($overwritten{$dst} ==1) {
	    push @changedfiles, $dst;
	} else {
	    push @addedfiles, $dst;
	}
    }
    else {
	push @addedfiles, @dstfiles;
    }
This is broken. It only checks if there's just one source-file 
regardless of whether or not it resided in a subdirectory. I'm not 
exactly fluent in perl so I can't submit a patch, but the src option 
needs to be directory aware, traverse all source directories and then 
move the files axing everything but the bottom-most dirname to the 
destination directory.

Any takers?

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help