From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yasushi SHOJI Subject: git diff-index with relative git-dir does not work Date: Tue, 09 Feb 2010 20:05:28 +0900 Message-ID: <871vguy8hz.wl@dns1.atmark-techno.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Feb 09 12:13:41 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Neo2E-0006No-OA for gcvg-git-2@lo.gmane.org; Tue, 09 Feb 2010 12:13:39 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754100Ab0BILMq (ORCPT ); Tue, 9 Feb 2010 06:12:46 -0500 Received: from dns1.atmark-techno.com ([210.191.215.170]:45372 "EHLO dns1.atmark-techno.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751819Ab0BILMq (ORCPT ); Tue, 9 Feb 2010 06:12:46 -0500 X-Greylist: delayed 435 seconds by postgrey-1.27 at vger.kernel.org; Tue, 09 Feb 2010 06:12:45 EST Received: from sv-prius.atmark-techno.com (sv-prius.local-network [192.168.10.102]) by dns1.atmark-techno.com (Postfix) with ESMTP id 64F10C2E41 for ; Tue, 9 Feb 2010 20:05:29 +0900 (JST) Received: from wat.atmark-techno.com (unknown [172.16.10.1]) by sv-prius.atmark-techno.com (Postfix) with ESMTP id 510BC132005C; Tue, 9 Feb 2010 20:05:28 +0900 (JST) User-Agent: Wanderlust/2.14.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Hi all, I was just testing --git-dir and --work-tree options and found that the following test code fails with the current next (2ac040d3). diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index 9df3012..1f90f45 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -195,4 +195,8 @@ test_expect_success 'make_relative_path handles double slashes in GIT_DIR' ' git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file ' +test_expect_success 'git diff-index' ' + git --git-dir repo.git --work-tree repo.git/work diff-index HEAD +' + test_done This is because static variable 'base' in sha1_file_name is already assigned _before_ setup_work_tree() from cmd_diff_index() is called. setup_work_tree() eventually chdir to the given work tree dir, but we use the old base to generate object file path. And that cause open(2) to fail because the object file path and the current dir is not in sync any more. So, is it correct to assume that we must call setup_work_tree() _before_ any function which call getter/setter in environment.c? This including open_sha1_file, in this case. Also, would it be a good idea to make all builtin command to _explicitly_ call setup_* functions, so that we can find calling order bug? In that case, we must change the setup functions signature to allow marking "not interested" or something. Any thoughts? -- yashi