MCPcopy Index your code
hub / github.com/git/git / stack_compact_locked

Function stack_compact_locked

reftable/stack.c:1066–1130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1064}
1065
1066static int stack_compact_locked(struct reftable_stack *st,
1067 size_t first, size_t last,
1068 struct reftable_log_expiry_config *config,
1069 struct reftable_tmpfile *tab_file_out)
1070{
1071 struct reftable_buf next_name = REFTABLE_BUF_INIT;
1072 struct reftable_buf tab_file_path = REFTABLE_BUF_INIT;
1073 struct reftable_writer *wr = NULL;
1074 struct fd_writer writer= {
1075 .opts = &st->opts,
1076 };
1077 struct reftable_tmpfile tab_file = REFTABLE_TMPFILE_INIT;
1078 int err = 0;
1079
1080 err = format_name(&next_name, reftable_table_min_update_index(st->tables[first]),
1081 reftable_table_max_update_index(st->tables[last]));
1082 if (err < 0)
1083 goto done;
1084
1085 err = stack_filename(&tab_file_path, st, next_name.buf);
1086 if (err < 0)
1087 goto done;
1088
1089 err = reftable_buf_addstr(&tab_file_path, ".temp.XXXXXX");
1090 if (err < 0)
1091 goto done;
1092
1093 err = tmpfile_from_pattern(&tab_file, tab_file_path.buf);
1094 if (err < 0)
1095 goto done;
1096
1097 if (st->opts.default_permissions &&
1098 chmod(tab_file.path, st->opts.default_permissions) < 0) {
1099 err = REFTABLE_IO_ERROR;
1100 goto done;
1101 }
1102
1103 writer.fd = tab_file.fd;
1104 err = reftable_writer_new(&wr, fd_writer_write, fd_writer_flush,
1105 &writer, &st->opts);
1106 if (err < 0)
1107 goto done;
1108
1109 err = stack_write_compact(st, wr, first, last, config);
1110 if (err < 0)
1111 goto done;
1112
1113 err = reftable_writer_close(wr);
1114 if (err < 0)
1115 goto done;
1116
1117 err = tmpfile_close(&tab_file);
1118 if (err < 0)
1119 goto done;
1120
1121 *tab_file_out = tab_file;
1122 tab_file = REFTABLE_TMPFILE_INIT;
1123

Callers 1

stack_compact_rangeFunction · 0.85

Calls 13

format_nameFunction · 0.85
stack_filenameFunction · 0.85
reftable_buf_addstrFunction · 0.85
tmpfile_from_patternFunction · 0.85
reftable_writer_newFunction · 0.85
stack_write_compactFunction · 0.85
reftable_writer_closeFunction · 0.85
tmpfile_closeFunction · 0.85
tmpfile_deleteFunction · 0.85
reftable_writer_freeFunction · 0.85

Tested by

no test coverage detected