Re: Untracked working tree files

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Wednesday, October 15, 2008 - 1:08 pm

On Wed, 15 Oct 2008, Andrew Morton wrote:

Ok. 


Is "git checkout -f" part of the scripting? Or "git reset --hard"?

So what I could imagine is happening is:

 - you have a lot of automated merging

 - a merge goes south with a data conflict, and since it's all automated, 
   you just want to throw it away. So you do "git reset --force" to do 
   that.

 - but what "git reset --hard" means is to basically ignore all error 
   cases, including any unmerged entries that it just basically ignores.

 - so it did set the tree back, but the whole point of "--hard" is that it 
   ignores error cases, and doesn't really touch them.

Now, I don't think we ever really deeply thought about what the error 
cases should do when they are ignored. Should the file that is in some 
state we don't like be removed? Or should we just ignore the error and 
return without removing the file? Generally git tries to avoid touching 
things it doesn't understand, but I do think this may explain some pain 
for you, and it may not be the right thing in this case.

(And when I say "this case", I don't really know whether you use "git 
checkout -f" or "git reset --hard" or something else, so I'm not even 
going to say I'm sure exactly _which_ case "this case" actually us :)

Of course, the cheesy way for you to fix this may be to just add a

	git clean -dqfx

to directly after whatever point where you decide to reset and revert to 
an earlier stage. That just says "force remove all files I don't know 
about, including any I might ignore". IOW, "git reset --hard" will 
guarantee that all _tracked_ files are reset, but if you worry about some 
other crud that could have happened due to a failed merge, that additional 
"git clean" may be called for.

Of course, it's going to read the whole directory tree and that's not 
really cheap, but especially if you only do this for error cases, it's 
probably not going to be any worse. And I'm assuming you're not compiling 
in that tree, so you probably don't want to save object files (you can 
remove the "x" part, but then you could still at least in theory get a 
filename clash with something that is ignored and thus didn't get cleaned 
up).

			Linus
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Untracked working tree files, Andrew Morton, (Wed Oct 15, 11:56 am)
Re: Untracked working tree files, david, (Wed Oct 15, 12:09 pm)
Re: Untracked working tree files, david, (Wed Oct 15, 12:14 pm)
Re: Untracked working tree files, Andrew Morton, (Wed Oct 15, 12:24 pm)
Re: Untracked working tree files, Andrew Morton, (Wed Oct 15, 12:26 pm)
Re: Untracked working tree files, Linus Torvalds, (Wed Oct 15, 12:31 pm)
Re: Untracked working tree files, Nicolas Pitre, (Wed Oct 15, 12:32 pm)
Re: Untracked working tree files, Nicolas Pitre, (Wed Oct 15, 12:34 pm)
Re: Untracked working tree files, david, (Wed Oct 15, 12:42 pm)
Re: Untracked working tree files, Andrew Morton, (Wed Oct 15, 12:49 pm)
Re: Untracked working tree files, Linus Torvalds, (Wed Oct 15, 12:56 pm)
Re: Untracked working tree files, Linus Torvalds, (Wed Oct 15, 1:08 pm)
Re: Untracked working tree files, david, (Wed Oct 15, 1:17 pm)
Re: Untracked working tree files, Andrew Morton, (Wed Oct 15, 1:23 pm)
Re: Untracked working tree files, Linus Torvalds, (Wed Oct 15, 1:23 pm)
Re: Untracked working tree files, Andrew Morton, (Wed Oct 15, 1:30 pm)
Re: Untracked working tree files, Junio C Hamano, (Wed Oct 15, 3:06 pm)
Re: Untracked working tree files, Paolo Ciarrocchi, (Thu Oct 16, 1:42 am)
Re: Untracked working tree files, Andrew Morton, (Thu Oct 16, 2:32 am)