Re: fetching packs and storing them as packs

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Friday, October 27, 2006 - 1:22 pm

On Thu, 26 Oct 2006, Eran Tromer wrote:

(I note that there's a whole thread on this, but I was off doing other 
things, so I probably missed part of it)

We really should _never_ create a pack in-place with the final name.

The way to fix the race is to simply not create the patch as

	.git/objects/packed/pack-xyz.{pack|idx}

in the first place, but simply "mv" them into place later. If you do that 
after you've written the temporary pointer to it, there is no race (the 
temporary pointer may not be usable, of course, but that's a separate 
issue).

That said, I think some of the "git repack -d" logic is also unnecessarily 
fragile. In particular, it shouldn't just do

	existing=$(find . -type f \( -name '*.pack' -o -name '*.idx' \))

like it does to generate the "existing" list, it should probably only ever 
remove a pack-file and index file _pair_, ie it should do something like

	existing=$(find . -type f -name '*.pack')

and then do

	for pack in $existing
	do
		index="$(basename $pack).idx"
		if [ -f $index ] && [ "$pack"!= "$newpack" ]
		then
			rm -f "$pack" "$index"
		fi
	done

etc, exactly so that it would never remove anything that is getting 
indexed or is otherwise half-way done, regardless of any other issues.

Hmm?

		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:
fetching packs and storing them as packs, Nicolas Pitre, (Wed Oct 25, 8:44 pm)
Re: fetching packs and storing them as packs, Eran Tromer, (Thu Oct 26, 7:45 am)
Re: fetching packs and storing them as packs, Linus Torvalds, (Fri Oct 27, 1:22 pm)
Re: fetching packs and storing them as packs, Junio C Hamano, (Fri Oct 27, 2:53 pm)
Re: fetching packs and storing them as packs, Shawn Pearce, (Fri Oct 27, 8:42 pm)
Re: fetching packs and storing them as packs, Junio C Hamano, (Fri Oct 27, 9:09 pm)
Re: fetching packs and storing them as packs, Linus Torvalds, (Fri Oct 27, 9:18 pm)
Re: fetching packs and storing them as packs, Junio C Hamano, (Fri Oct 27, 10:42 pm)
Re: fetching packs and storing them as packs, Shawn Pearce, (Sat Oct 28, 12:21 am)
Re: fetching packs and storing them as packs, Shawn Pearce, (Sat Oct 28, 1:40 am)
Re: fetching packs and storing them as packs, Linus Torvalds, (Sat Oct 28, 10:59 am)
Re: fetching packs and storing them as packs, Junio C Hamano, (Sat Oct 28, 11:34 am)
Re: fetching packs and storing them as packs, Junio C Hamano, (Sat Oct 28, 12:15 pm)
Re: fetching packs and storing them as packs, Eran Tromer, (Sat Oct 28, 3:31 pm)
Re: fetching packs and storing them as packs, Shawn Pearce, (Sat Oct 28, 8:38 pm)
Re: fetching packs and storing them as packs, Shawn Pearce, (Sat Oct 28, 8:50 pm)
Re: fetching packs and storing them as packs, Junio C Hamano, (Sat Oct 28, 9:29 pm)
Re: fetching packs and storing them as packs, Shawn Pearce, (Sat Oct 28, 9:38 pm)
Re: fetching packs and storing them as packs, Junio C Hamano, (Sat Oct 28, 10:16 pm)
Re: fetching packs and storing them as packs, Shawn Pearce, (Sat Oct 28, 10:21 pm)