Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Aug 1, 2011
2 parents 4db0d0d + d5b6629 commit b35acb5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Documentation/technical/index-format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions t/t7400-submodule-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*'
Expand Down
15 changes: 13 additions & 2 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,11 +1168,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;
/*
Expand Down

0 comments on commit b35acb5

Please sign in to comment.