core icon indicating copy to clipboard operation
core copied to clipboard

important bug in file tree: dragging file into dir and selecting "Copy New File" adds everything to git!

Open rcoreilly opened this issue 3 years ago • 4 comments

Need to check the git add command that is being run -- it is not correct. This may happen in other situations so probably add a wrapper for all such calls to prevent this. You can undo with git reset but it is a pain if you don't notice in time!

Also the Copy New File itself doesn't quite seem to work..

rcoreilly avatar Jan 13 '22 05:01 rcoreilly

the offending code is in filetree/file.go:392 -- it is doing nfn.AddtoVCS() where nfn is supposed to be the target path, but apparently isn't quite somehow..

rcoreilly avatar Feb 19 '24 09:02 rcoreilly

added a check that path == tpath -- hopefully will allow catching the bug -- wasn't able to reproduce in various testing on a dummy repo..

2a1f1175e65b666f2da557ad330c44e8be3ec81b

rcoreilly avatar Feb 19 '24 09:02 rcoreilly

Given that this issue cannot currently be reproduced, I will close it. If it ever comes up again in the future, this issue can be reopened.

kkoreilly avatar Feb 22 '24 06:02 kkoreilly

I had this happen again at some point. I think another place where this can happen is in the vcs/git.go code:

// Move moves updates the repo with the rename
func (gr *GitRepo) Move(oldpath, newpath string) error {
	out, err := gr.RunFromDir("git", "mv", RelPath(gr, oldpath), RelPath(gr, newpath))
	// if err != nil {
	// 	log.Println(string(out))
	// 	fmt.Printf("%s\n", out)
	// 	return err
	// }
	out, err = gr.RunFromDir("git", "add", RelPath(gr, newpath))
	if err != nil {
		log.Println(string(out))
		return err
	}
	return nil
}

it is generating some kind of error there (why the error printing is commented out) and then the add is probably adding everything under a directory.

rcoreilly avatar Apr 26 '24 02:04 rcoreilly

This was fixed in 311f773de

rcoreilly avatar Mar 19 '25 20:03 rcoreilly