Coverage Report

Created: 2026-10-17 07:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/git/odb/transaction.c
Line
Count
Source
1
#include "git-compat-util.h"
2
#include "gettext.h"
3
#include "odb/source.h"
4
#include "odb/transaction.h"
5
6
int odb_transaction_begin(struct object_database *odb,
7
        struct odb_transaction **out,
8
        enum odb_transaction_flags flags)
9
0
{
10
0
  int ret;
11
12
0
  if (odb->transaction)
13
0
    return error(_("object database transaction already pending"));
14
15
0
  ret = odb_source_begin_transaction(odb->sources, out, flags);
16
0
  if (!ret)
17
0
    odb->transaction = *out;
18
19
0
  return ret;
20
0
}
21
22
int odb_transaction_commit(struct odb_transaction *transaction)
23
0
{
24
0
  int ret;
25
26
0
  if (!transaction)
27
0
    return 0;
28
29
  /*
30
   * Ensure the transaction ending matches the pending transaction.
31
   */
32
0
  ASSERT(transaction == transaction->source->odb->transaction);
33
34
0
  ret = transaction->commit(transaction);
35
0
  transaction->source->odb->transaction = NULL;
36
37
0
  return ret;
38
0
}
39
40
int odb_transaction_finalize(struct odb_transaction *transaction)
41
0
{
42
0
  int ret = 0;
43
44
0
  if (!transaction)
45
0
    return 0;
46
47
0
  if (transaction->finalize)
48
0
    ret = transaction->finalize(transaction);
49
50
0
  free(transaction);
51
52
0
  return ret;
53
0
}
54
55
int odb_transaction_write_object_stream(struct odb_transaction *transaction,
56
          struct odb_stream *stream,
57
          struct object_id *oid)
58
0
{
59
0
  return transaction->write_object_stream(transaction, stream, oid);
60
0
}
61
62
int odb_transaction_write_pack(struct odb_transaction *transaction, int pack_fd,
63
             struct strbuf *err_msg,
64
             const struct odb_transaction_write_pack_opts *opts)
65
0
{
66
0
  return transaction->write_pack(transaction, pack_fd, err_msg, opts);
67
0
}
68
69
int odb_transaction_env(struct odb_transaction *transaction, struct strvec *env)
70
0
{
71
0
  if (!transaction)
72
0
    return 0;
73
74
0
  return transaction->env(transaction, env);
75
0
}