From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Haggerty Subject: [PATCH 16/33] t3210: test for spurious error messages for dangling packed refs Date: Sun, 14 Apr 2013 14:54:31 +0200 Message-ID: <1365944088-10588-17-git-send-email-mhagger@alum.mit.edu> References: <1365944088-10588-1-git-send-email-mhagger@alum.mit.edu> Cc: git@vger.kernel.org, Michael Haggerty To: Junio C Hamano , Jeff King , Heiko Voigt X-From: git-owner@vger.kernel.org Sun Apr 14 15:03:30 2013 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1URMad-0004pI-LJ for gcvg-git-2@plane.gmane.org; Sun, 14 Apr 2013 15:03:27 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751804Ab3DNNDX (ORCPT ); Sun, 14 Apr 2013 09:03:23 -0400 Received: from ALUM-MAILSEC-SCANNER-2.MIT.EDU ([18.7.68.13]:59222 "EHLO alum-mailsec-scanner-2.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561Ab3DNNDW (ORCPT ); Sun, 14 Apr 2013 09:03:22 -0400 X-Greylist: delayed 461 seconds by postgrey-1.27 at vger.kernel.org; Sun, 14 Apr 2013 09:03:22 EDT X-AuditID: 1207440d-b7fd06d000000905-6a-516aa74cef46 Received: from outgoing-alum.mit.edu (OUTGOING-ALUM.MIT.EDU [18.7.68.33]) by alum-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id A5.1F.02309.C47AA615; Sun, 14 Apr 2013 08:55:41 -0400 (EDT) Received: from michael.fritz.box (p57A24996.dip.t-dialin.net [87.162.73.150]) (authenticated bits=0) (User authenticated as mhagger@ALUM.MIT.EDU) by outgoing-alum.mit.edu (8.13.8/8.12.4) with ESMTP id r3ECtAkD007029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 14 Apr 2013 08:55:39 -0400 X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1365944088-10588-1-git-send-email-mhagger@alum.mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixO6iqOu7PCvQoOsqk0XXlW4mi4beK8wW Kx/fZba4vWI+s8WPlh5mB1aPv+8/MHm0v3/H7PGsdw+jx8VLyh6fN8kFsEZx2yQllpQFZ6bn 6dslcGdMm3WCpeCecMWSXyvZGxi/83cxcnBICJhITG4w6mLkBDLFJC7cW8/WxcjFISRwmVFi 5u4NjBDOWSaJg1+es4FUsQnoSizqaWYCaRYRyJbYvVYeJMws4CCx+XMjI4gtLBAuMWP5YlYQ m0VAVWL33yPMIDavgKvE0e6J7BDLFCSOb98GVs8JFJ/+/BhYXEjARWLW5tmsExh5FzAyrGKU S8wpzdXNTczMKU5N1i1OTszLSy3SNdLLzSzRS00p3cQICSjeHYz/18kcYhTgYFTi4X3BmBUo xJpYVlyZe4hRkoNJSZS3ZxlQiC8pP6UyI7E4I76oNCe1+BCjBAezkgivYytQjjclsbIqtSgf JiXNwaIkzqu2RN1PSCA9sSQ1OzW1ILUIJivDwaEkwft6KVCjYFFqempFWmZOCUKaiYMTRHCB bOAB2vAWpJC3uCAxtzgzHaLoFKOilDhvCshZAiCJjNI8uAGw2H/FKA70jzDvU5B2HmDagOt+ BTSYCWiwz950kMEliQgpqQbGlgzOd/m6AR2dltO6uh+K7Dy6+UGjToyhRb3q5NQ131TdDrBM V8340j15z7m1zKUXLp+7/i34nNakVr6plXP2fjv0NmVfrqllrMZSlqJnVxllZ5x65P2qMOfM 4pUfZ00RUfFp7fo/uzrs2Zb/673Utqgtsspa8eHan/oPgmKaOrl/Ts5iOH7lqxJL Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: A packed reference can be overridden by a loose reference, in which case the packed reference is obsolete and is never used. The object pointed to by such a reference can be garbage collected. Since d66da478f2, this could lead to the emission of a spurious error message: error: refs/heads/master does not point to a valid object! The error is generated by repack_without_ref() if there is an obsolete dangling packed reference in packed-refs when the packed-refs file has to be rewritten due to the deletion of another packed reference. Add a failing test demonstrating this problem and some passing tests of related scenarios. Signed-off-by: Michael Haggerty --- How can I get rid of the sleeps in these tests? I couldn't find another portable way of reliably ensuring that commits get garbage-collected. (Some other tests use similar code without the sleeps, but empirically the sleeps are necessary to get the tests to work reliably. Perhaps the other tests are not doing what they think.) t/t3210-pack-refs.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index cd04361..c032d88 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -118,4 +118,40 @@ test_expect_success 'pack, prune and repack' ' test_cmp all-of-them again ' +test_expect_success 'explicit pack-refs with dangling packed reference' ' + git commit --allow-empty -m "soon to be garbage-collected" && + git pack-refs --all && + git reset --hard HEAD^ && + sleep 1 && + git reflog expire --expire=now --all && + git prune --expire=now && + git pack-refs --all 2>result && + test_cmp /dev/null result +' + +test_expect_success 'delete ref with dangling packed version' ' + git checkout -b lamb && + git commit --allow-empty -m "future garbage" && + git pack-refs --all && + git reset --hard HEAD^ && + git checkout master && + sleep 1 && + git reflog expire --expire=now --all && + git prune --expire=now && + git branch -d lamb 2>result && + test_cmp /dev/null result +' + +test_expect_failure 'delete ref while another dangling packed ref' ' + git branch lamb && + git commit --allow-empty -m "future garbage" && + git pack-refs --all && + git reset --hard HEAD^ && + sleep 1 && + git reflog expire --expire=now --all && + git prune --expire=now && + git branch -d lamb 2>result && + test_cmp /dev/null result +' + test_done -- 1.8.2.1