From e44b6df90cfd6ccbf35c3d147ff5a0e4e22fb17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 26 Jul 2011 14:27:57 +0200 Subject: Documentation: clarify the invalidated tree entry format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the entry_count is -1, the tree is invalidated and therefore has not associated hash (or object name). Explicitly state that the next entry starts after the newline. Signed-off-by: Carlos Martín Nieto Signed-off-by: Junio C Hamano --- Documentation/technical/index-format.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/technical/index-format.txt b/Documentation/technical/index-format.txt index 7b233ca196..8930b3fabc 100644 --- a/Documentation/technical/index-format.txt +++ b/Documentation/technical/index-format.txt @@ -147,8 +147,9 @@ GIT index format - 160-bit object name for the object that would result from writing this span of index as a tree. - An entry can be in an invalidated state and is represented by having -1 - in the entry_count field. + An entry can be in an invalidated state and is represented by having + -1 in the entry_count field. In this case, there is no object name + and the next entry starts immediately after the newline. The entries are written out in the top-down, depth-first order. The first entry represents the root level of the repository, followed by the -- cgit v1.2.3 From dd008b3b11286804bc7880bac10c34a76355fe92 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 30 Jul 2011 09:05:54 -0600 Subject: t7400: fix bogus test failure with symlinked trash One of the tests in t7400 fails if the trash directory has a symlink anywhere in its path. E.g.: $ mkdir /tmp/git-test $ mkdir /tmp/git-test/real $ ln -s real /tmp/git-test/link $ ./t7400-submodule-basic --root=/tmp/git-test/real ... # passed all 44 test(s) $ ./t7400-submodule-basic --root=/tmp/git-test/link ... not ok - 41 use superproject as upstream when path is relative and no url is set there The failing test does: git submodule add ../repo relative && ... git submodule sync relative && test "$(git config submodule.relative.url)" = "$submodurl/repo" where $submodurl comes from the $TRASH_DIRECTORY the user gave us. However, git will resolve symlinks when converting the relative path into an absolute one, leading them to be textually different (even though they point to the same directory). Fix this by asking pwd to canonicalize the name of the trash directory for us. Signed-off-by: Jeff King Acked-by: Jens Lehmann Signed-off-by: Junio C Hamano --- t/t7400-submodule-basic.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 874279e32d..3f115d9ca9 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -47,8 +47,10 @@ test_expect_success 'setup - repository to add submodules to' ' ' # The 'submodule add' tests need some repository to add as a submodule. -# The trash directory is a good one as any. -submodurl=$TRASH_DIRECTORY +# The trash directory is a good one as any. We need to canonicalize +# the name, though, as some tests compare it to the absolute path git +# generates, which will expand symbolic links. +submodurl=$(pwd -P) listbranches() { git for-each-ref --format='%(refname)' 'refs/heads/*' -- cgit v1.2.3 From d5b66299040969706dd675c021f4336a26a6cc82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 30 Jul 2011 10:55:05 +0700 Subject: Break down no-lstat() condition checks in verify_uptodate() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make it easier to grok under what conditions we can skip lstat(). While at there, shorten ie_match_stat() line for the sake of my eyes. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- unpack-trees.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/unpack-trees.c b/unpack-trees.c index 07f8364244..e22b9ec408 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1166,11 +1166,22 @@ static int verify_uptodate_1(struct cache_entry *ce, { struct stat st; - if (o->index_only || (!((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) && (o->reset || ce_uptodate(ce)))) + if (o->index_only) + return 0; + + /* + * CE_VALID and CE_SKIP_WORKTREE cheat, we better check again + * if this entry is truly up-to-date because this file may be + * overwritten. + */ + if ((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) + ; /* keep checking */ + else if (o->reset || ce_uptodate(ce)) return 0; if (!lstat(ce->name, &st)) { - unsigned changed = ie_match_stat(o->src_index, ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE); + int flags = CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE; + unsigned changed = ie_match_stat(o->src_index, ce, &st, flags); if (!changed) return 0; /* -- cgit v1.2.3