aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cache-tree.c27
-rw-r--r--cache-tree.h2
-rw-r--r--pack-write.c17
-rwxr-xr-xt/t2107-update-index-basic.sh31
-rwxr-xr-xt/t5329-pack-objects-cruft.sh4
5 files changed, 34 insertions, 47 deletions
diff --git a/cache-tree.c b/cache-tree.c
index ff794d940f..56db0b5026 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -101,33 +101,6 @@ struct cache_tree_sub *cache_tree_sub(struct cache_tree *it, const char *path)
return find_subtree(it, path, pathlen, 1);
}
-struct cache_tree *cache_tree_find_path(struct cache_tree *it, const char *path)
-{
- const char *slash;
- int namelen;
- struct cache_tree_sub it_sub = {
- .cache_tree = it,
- };
- struct cache_tree_sub *down = &it_sub;
-
- while (down) {
- slash = strchrnul(path, '/');
- namelen = slash - path;
- down->cache_tree->entry_count = -1;
- if (!*slash) {
- int pos;
- pos = cache_tree_subtree_pos(down->cache_tree, path, namelen);
- if (0 <= pos)
- return down->cache_tree->down[pos]->cache_tree;
- return NULL;
- }
- down = find_subtree(it, path, namelen, 0);
- path = slash + 1;
- }
-
- return NULL;
-}
-
static int do_invalidate_path(struct cache_tree *it, const char *path)
{
/* a/b/c
diff --git a/cache-tree.h b/cache-tree.h
index f75f8e74dc..8efeccebfc 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -29,8 +29,6 @@ struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);
int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen);
-struct cache_tree *cache_tree_find_path(struct cache_tree *it, const char *path);
-
void cache_tree_write(struct strbuf *, struct cache_tree *root);
struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
diff --git a/pack-write.c b/pack-write.c
index 23c0342018..00787e306d 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -310,26 +310,21 @@ static void write_mtimes_trailer(struct hashfile *f, const unsigned char *hash)
hashwrite(f, hash, the_hash_algo->rawsz);
}
-static const char *write_mtimes_file(const char *mtimes_name,
- struct packing_data *to_pack,
+static const char *write_mtimes_file(struct packing_data *to_pack,
struct pack_idx_entry **objects,
uint32_t nr_objects,
const unsigned char *hash)
{
+ struct strbuf tmp_file = STRBUF_INIT;
+ const char *mtimes_name;
struct hashfile *f;
int fd;
if (!to_pack)
BUG("cannot call write_mtimes_file with NULL packing_data");
- if (!mtimes_name) {
- struct strbuf tmp_file = STRBUF_INIT;
- fd = odb_mkstemp(&tmp_file, "pack/tmp_mtimes_XXXXXX");
- mtimes_name = strbuf_detach(&tmp_file, NULL);
- } else {
- unlink(mtimes_name);
- fd = xopen(mtimes_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
- }
+ fd = odb_mkstemp(&tmp_file, "pack/tmp_mtimes_XXXXXX");
+ mtimes_name = strbuf_detach(&tmp_file, NULL);
f = hashfd(fd, mtimes_name);
write_mtimes_header(f);
@@ -561,7 +556,7 @@ void stage_tmp_packfiles(struct strbuf *name_buffer,
pack_idx_opts->flags);
if (pack_idx_opts->flags & WRITE_MTIMES) {
- mtimes_tmp_name = write_mtimes_file(NULL, to_pack, written_list,
+ mtimes_tmp_name = write_mtimes_file(to_pack, written_list,
nr_written,
hash);
}
diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh
index a30b7ca6bc..07e6de84e6 100755
--- a/t/t2107-update-index-basic.sh
+++ b/t/t2107-update-index-basic.sh
@@ -36,9 +36,14 @@ test_expect_success '--cacheinfo does not accept blob null sha1' '
echo content >file &&
git add file &&
git rev-parse :file >expect &&
- test_must_fail git update-index --cacheinfo 100644 $ZERO_OID file &&
+ test_must_fail git update-index --verbose --cacheinfo 100644 $ZERO_OID file >out &&
git rev-parse :file >actual &&
- test_cmp expect actual
+ test_cmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ add '\''file'\''
+ EOF
+ test_cmp expect out
'
test_expect_success '--cacheinfo does not accept gitlink null sha1' '
@@ -59,9 +64,14 @@ test_expect_success '--cacheinfo mode,sha1,path (new syntax)' '
git rev-parse :file >actual &&
test_cmp expect actual &&
- git update-index --add --cacheinfo "100644,$(cat expect),elif" &&
+ git update-index --add --verbose --cacheinfo "100644,$(cat expect),elif" >out &&
git rev-parse :elif >actual &&
- test_cmp expect actual
+ test_cmp expect actual &&
+
+ cat >expect <<-\EOF &&
+ add '\''elif'\''
+ EOF
+ test_cmp expect out
'
test_expect_success '.lock files cleaned up' '
@@ -74,7 +84,8 @@ test_expect_success '.lock files cleaned up' '
git config core.worktree ../../worktree &&
# --refresh triggers late setup_work_tree,
# active_cache_changed is zero, rollback_lock_file fails
- git update-index --refresh &&
+ git update-index --refresh --verbose >out &&
+ test_must_be_empty out &&
! test -f .git/index.lock
)
'
@@ -83,7 +94,15 @@ test_expect_success '--chmod=+x and chmod=-x in the same argument list' '
>A &&
>B &&
git add A B &&
- git update-index --chmod=+x A --chmod=-x B &&
+ git update-index --verbose --chmod=+x A --chmod=-x B >out &&
+ cat >expect <<-\EOF &&
+ add '\''A'\''
+ chmod +x '\''A'\''
+ add '\''B'\''
+ chmod -x '\''B'\''
+ EOF
+ test_cmp expect out &&
+
cat >expect <<-EOF &&
100755 $EMPTY_BLOB 0 A
100644 $EMPTY_BLOB 0 B
diff --git a/t/t5329-pack-objects-cruft.sh b/t/t5329-pack-objects-cruft.sh
index b481224b93..8968f7a08d 100755
--- a/t/t5329-pack-objects-cruft.sh
+++ b/t/t5329-pack-objects-cruft.sh
@@ -451,11 +451,13 @@ test_expect_success 'expiring cruft objects with git gc' '
sort <reachable.raw >reachable &&
comm -13 reachable objects >unreachable &&
- git repack --cruft -d &&
+ # Write a cruft pack containing all unreachable objects.
+ git gc --cruft --prune="01-01-1980" &&
mtimes=$(ls .git/objects/pack/pack-*.mtimes) &&
test_path_is_file $mtimes &&
+ # Prune all unreachable objects from the cruft pack.
git gc --cruft --prune=now &&
git cat-file --batch-all-objects --batch-check="%(objectname)" >objects &&