Skip to content

Commit b35acb5

Browse files
committed
Merge branch 'maint'
* maint: Break down no-lstat() condition checks in verify_uptodate() t7400: fix bogus test failure with symlinked trash Documentation: clarify the invalidated tree entry format
2 parents 4db0d0d + d5b6629 commit b35acb5

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

Documentation/technical/index-format.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ GIT index format
147147
- 160-bit object name for the object that would result from writing
148148
this span of index as a tree.
149149

150-
An entry can be in an invalidated state and is represented by having -1
151-
in the entry_count field.
150+
An entry can be in an invalidated state and is represented by having
151+
-1 in the entry_count field. In this case, there is no object name
152+
and the next entry starts immediately after the newline.
152153

153154
The entries are written out in the top-down, depth-first order. The
154155
first entry represents the root level of the repository, followed by the

t/t7400-submodule-basic.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ test_expect_success 'setup - repository to add submodules to' '
4747
'
4848

4949
# The 'submodule add' tests need some repository to add as a submodule.
50-
# The trash directory is a good one as any.
51-
submodurl=$TRASH_DIRECTORY
50+
# The trash directory is a good one as any. We need to canonicalize
51+
# the name, though, as some tests compare it to the absolute path git
52+
# generates, which will expand symbolic links.
53+
submodurl=$(pwd -P)
5254

5355
listbranches() {
5456
git for-each-ref --format='%(refname)' 'refs/heads/*'

unpack-trees.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,11 +1168,22 @@ static int verify_uptodate_1(struct cache_entry *ce,
11681168
{
11691169
struct stat st;
11701170

1171-
if (o->index_only || (!((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) && (o->reset || ce_uptodate(ce))))
1171+
if (o->index_only)
1172+
return 0;
1173+
1174+
/*
1175+
* CE_VALID and CE_SKIP_WORKTREE cheat, we better check again
1176+
* if this entry is truly up-to-date because this file may be
1177+
* overwritten.
1178+
*/
1179+
if ((ce->ce_flags & CE_VALID) || ce_skip_worktree(ce))
1180+
; /* keep checking */
1181+
else if (o->reset || ce_uptodate(ce))
11721182
return 0;
11731183

11741184
if (!lstat(ce->name, &st)) {
1175-
unsigned changed = ie_match_stat(o->src_index, ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
1185+
int flags = CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE;
1186+
unsigned changed = ie_match_stat(o->src_index, ce, &st, flags);
11761187
if (!changed)
11771188
return 0;
11781189
/*

0 commit comments

Comments
 (0)