@@ -73,3 +73,56 @@ void test_object_tree_read__two(void)
7373 git_object_free (obj );
7474 git_tree_free (tree );
7575}
76+
77+ #define BIGFILE "bigfile"
78+ #define BIGFILE_SIZE (off_t)4 * 1024 * 1024 * 1024 /* 4 GiB */
79+
80+ void test_object_tree_read__largefile (void )
81+ {
82+ git_reference * ref ;
83+ git_commit * commit ;
84+ git_tree * tree ;
85+ git_oid oid ;
86+ const git_tree_entry * entry ;
87+ git_object * object ;
88+ git_buf file = GIT_BUF_INIT ;
89+ int fd ;
90+ git_index * idx ;
91+
92+ #ifdef GIT_WIN32
93+ cl_skip ();
94+ #endif
95+
96+ if (!cl_is_env_set ("GITTEST_INVASIVE_FS_SIZE" ))
97+ cl_skip ();
98+
99+ cl_git_pass (git_reference_lookup (& ref , g_repo , "refs/heads/master" ));
100+ cl_git_pass (git_repository_index (& idx , g_repo ));
101+
102+ cl_git_pass (git_buf_puts (& file , git_repository_workdir (g_repo )));
103+ cl_git_pass (git_buf_joinpath (& file , file .ptr , BIGFILE ));
104+
105+ fd = p_open (git_buf_cstr (& file ), O_CREAT |O_RDWR , 0644 );
106+ cl_assert_ (fd >= 0 , "invalid file descriptor" );
107+
108+ cl_must_pass (p_fallocate (fd , 0 , BIGFILE_SIZE ));
109+ cl_must_pass (p_close (fd ));
110+
111+ cl_git_pass (git_index_add_bypath (idx , BIGFILE ));
112+ cl_repo_commit_from_index (& oid , g_repo , NULL , 0 , "bigfile" );
113+
114+ cl_git_pass (git_commit_lookup (& commit , g_repo , & oid ));
115+ cl_git_pass (git_commit_tree (& tree , commit ));
116+
117+ entry = git_tree_entry_byname (tree , BIGFILE );
118+ cl_assert_ (entry , "entry was NULL" );
119+
120+ cl_git_pass (git_tree_entry_to_object (& object , g_repo , entry ));
121+
122+ git_buf_dispose (& file );
123+ git_object_free (object );
124+ git_tree_free (tree );
125+ git_index_free (idx );
126+ git_commit_free (commit );
127+ git_reference_free (ref );
128+ }
0 commit comments