From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pb-smtp1.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A302083CD5 for ; Tue, 24 Sep 2024 21:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.108.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727213682; cv=none; b=HbU65xt27DsPQa0NIWKszToHvO3gx2H9ePIPaHua0XDFCdaVQFHowyBMUuEZDh1+UdB259SdCm8ZrKYDBJybqbnnUYftTtPgKOLsoJ+aO8RAzYuAbvwkMTVWuYisB+yYjfj7U7Z73goS8o39GIiT5tbzK6OKwKx5zwlETGeJM2M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727213682; c=relaxed/simple; bh=hWUPUbVUgNPZuebqMzPc/by4cM5xQwUugJ5GsrOFjwM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=PiQQQ+5sC/P83Kh8oy4MD55OaXBDrBXBW2qJlZocJKzGE3+yrj5lt/jxv3emHOjYeBymdnWgjP8T6NnvdNawC+xw/BO/T2a5tCsRSnbRfisAZOIxqY5tSCjW+7+CfgQMiHofZ+vs2flSiY+0rKYH4TccKsULGYDXVjyd8NgiSaU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b=CBaGb/cd; arc=none smtp.client-ip=64.147.108.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="CBaGb/cd" Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 7FD491A51D; Tue, 24 Sep 2024 17:34:39 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=hWUPUbVUgNPZuebqMzPc/by4cM5xQwUugJ5Gsr OFjwM=; b=CBaGb/cdzapDz5wq8YbH1unqWaVIJ6s7sBwmJfESlSsKZ6IY7diGJV ax/JNvX/w9H5yDnNJ1aKuvtpX5jFXxkfO1JWjtzM64+86PscKVKIp/2vIMdqScUW 0+rTS+PP+KG//UBTCgx1gAgbzWRKBfJ0qd9YJKgF0FvfOdujCFTpY= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 779F01A51C; Tue, 24 Sep 2024 17:34:39 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.125.108.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id DD3361A51A; Tue, 24 Sep 2024 17:34:38 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: Taylor Blau Cc: git@vger.kernel.org, Jeff King , "brian m. carlson" , Elijah Newren , Patrick Steinhardt Subject: Re: [PATCH v4 4/8] pack-objects: use finalize_object_file() to rename pack/idx/etc In-Reply-To: <3cc7f7b1f67fe823834c36f3be20be8ee56e16a4.1727199118.git.me@ttaylorr.com> (Taylor Blau's message of "Tue, 24 Sep 2024 13:32:21 -0400") References: <3cc7f7b1f67fe823834c36f3be20be8ee56e16a4.1727199118.git.me@ttaylorr.com> Date: Tue, 24 Sep 2024 14:34:37 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: CD57F206-7ABC-11EF-8125-2BAEEB2EC81B-77302942!pb-smtp1.pobox.com Taylor Blau writes: > This has some test and real-world fallout, as seen in the adjustment to > t5303 below. That test script assumes that we can "fix" corruption by > repacking into a good state, including when the pack generated by that > repack operation collides with a (corrupted) pack with the same hash. > This violates our assumption from the previous adjustments to > finalize_object_file() that if we're moving a new file over an existing > one, that since their checksums match, so too must their contents. > > This makes "fixing" corruption like this a more explicit operation, > since the test (and users, who may fix real-life corruption using a > similar technique) must first move the broken contents out of the way. Nicely described. > @@ -528,9 +529,9 @@ static void rename_tmp_packfile(struct strbuf *name_prefix, const char *source, > size_t name_prefix_len = name_prefix->len; > > strbuf_addstr(name_prefix, ext); > - if (rename(source, name_prefix->buf)) > - die_errno("unable to rename temporary file to '%s'", > - name_prefix->buf); > + if (finalize_object_file(source, name_prefix->buf)) > + die("unable to rename temporary file to '%s'", > + name_prefix->buf); > strbuf_setlen(name_prefix, name_prefix_len); > } Looking good. Thanks.