MCPcopy Create free account
hub / github.com/git/git / write_patterns_and_update

Function write_patterns_and_update

builtin/sparse-checkout.c:330–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330static int write_patterns_and_update(struct repository *repo,
331 struct pattern_list *pl)
332{
333 char *sparse_filename;
334 FILE *fp;
335 struct lock_file lk = LOCK_INIT;
336 int result;
337 struct repo_config_values *cfg = repo_config_values(the_repository);
338
339 sparse_filename = get_sparse_checkout_filename();
340
341 if (safe_create_leading_directories(repo, sparse_filename))
342 die(_("failed to create directory for sparse-checkout file"));
343
344 hold_lock_file_for_update(&lk, sparse_filename, LOCK_DIE_ON_ERROR);
345
346 result = update_working_directory(repo, pl);
347 if (result) {
348 rollback_lock_file(&lk);
349 update_working_directory(repo, NULL);
350 goto out;
351 }
352
353 fp = fdopen_lock_file(&lk, "w");
354 if (!fp)
355 die_errno(_("unable to fdopen %s"), get_lock_file_path(&lk));
356
357 if (cfg->core_sparse_checkout_cone)
358 write_cone_to_file(fp, pl);
359 else
360 write_patterns_to_file(fp, pl);
361
362 if (commit_lock_file(&lk))
363 die_errno(_("unable to write %s"), sparse_filename);
364
365out:
366 clear_pattern_list(pl);
367 free(sparse_filename);
368 return result;
369}
370
371enum sparse_checkout_mode {
372 MODE_NO_PATTERNS = 0,

Callers 2

sparse_checkout_initFunction · 0.85
modify_pattern_listFunction · 0.85

Calls 14

update_working_directoryFunction · 0.85
rollback_lock_fileFunction · 0.85
fdopen_lock_fileFunction · 0.85
die_errnoFunction · 0.85
get_lock_file_pathFunction · 0.85
write_cone_to_fileFunction · 0.85
write_patterns_to_fileFunction · 0.85
commit_lock_fileFunction · 0.85
clear_pattern_listFunction · 0.85

Tested by

no test coverage detected