Skip to content

Commit 4483be3

Browse files
KarthikNayakgitster
authored andcommitted
refs: add committer_info to ref_transaction_add_update()
The `ref_transaction_add_update()` creates the `ref_update` struct. To facilitate addition of reflogs in the next commit, the function needs to accommodate setting the `committer_info` field in the struct. So modify the function to also take `committer_info` as an argument and set it accordingly. Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent add2c4f commit 4483be3

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

refs.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ struct ref_update *ref_transaction_add_update(
11661166
const struct object_id *new_oid,
11671167
const struct object_id *old_oid,
11681168
const char *new_target, const char *old_target,
1169+
const char *committer_info,
11691170
const char *msg)
11701171
{
11711172
struct ref_update *update;
@@ -1190,8 +1191,10 @@ struct ref_update *ref_transaction_add_update(
11901191
oidcpy(&update->new_oid, new_oid);
11911192
if ((flags & REF_HAVE_OLD) && old_oid)
11921193
oidcpy(&update->old_oid, old_oid);
1193-
if (!(flags & REF_SKIP_CREATE_REFLOG))
1194+
if (!(flags & REF_SKIP_CREATE_REFLOG)) {
1195+
update->committer_info = xstrdup_or_null(committer_info);
11941196
update->msg = normalize_reflog_message(msg);
1197+
}
11951198

11961199
return update;
11971200
}
@@ -1253,7 +1256,7 @@ int ref_transaction_update(struct ref_transaction *transaction,
12531256

12541257
ref_transaction_add_update(transaction, refname, flags,
12551258
new_oid, old_oid, new_target,
1256-
old_target, msg);
1259+
old_target, NULL, msg);
12571260
return 0;
12581261
}
12591262

refs/files-backend.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ static void prune_ref(struct files_ref_store *refs, struct ref_to_prune *r)
12701270
ref_transaction_add_update(
12711271
transaction, r->name,
12721272
REF_NO_DEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_IS_PRUNING,
1273-
null_oid(), &r->oid, NULL, NULL, NULL);
1273+
null_oid(), &r->oid, NULL, NULL, NULL, NULL);
12741274
if (ref_transaction_commit(transaction, &err))
12751275
goto cleanup;
12761276

@@ -2417,7 +2417,7 @@ static int split_head_update(struct ref_update *update,
24172417
transaction, "HEAD",
24182418
update->flags | REF_LOG_ONLY | REF_NO_DEREF,
24192419
&update->new_oid, &update->old_oid,
2420-
NULL, NULL, update->msg);
2420+
NULL, NULL, update->committer_info, update->msg);
24212421

24222422
/*
24232423
* Add "HEAD". This insertion is O(N) in the transaction
@@ -2481,7 +2481,8 @@ static int split_symref_update(struct ref_update *update,
24812481
transaction, referent, new_flags,
24822482
update->new_target ? NULL : &update->new_oid,
24832483
update->old_target ? NULL : &update->old_oid,
2484-
update->new_target, update->old_target, update->msg);
2484+
update->new_target, update->old_target, NULL,
2485+
update->msg);
24852486

24862487
new_update->parent_update = update;
24872488

@@ -2914,7 +2915,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
29142915
packed_transaction, update->refname,
29152916
REF_HAVE_NEW | REF_NO_DEREF,
29162917
&update->new_oid, NULL,
2917-
NULL, NULL, NULL);
2918+
NULL, NULL, NULL, NULL);
29182919
}
29192920
}
29202921

@@ -3094,12 +3095,13 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
30943095
ref_transaction_add_update(loose_transaction, update->refname,
30953096
update->flags & ~REF_HAVE_OLD,
30963097
update->new_target ? NULL : &update->new_oid, NULL,
3097-
update->new_target, NULL, NULL);
3098+
update->new_target, NULL, update->committer_info,
3099+
NULL);
30983100
} else {
30993101
ref_transaction_add_update(packed_transaction, update->refname,
31003102
update->flags & ~REF_HAVE_OLD,
31013103
&update->new_oid, &update->old_oid,
3102-
NULL, NULL, NULL);
3104+
NULL, NULL, update->committer_info, NULL);
31033105
}
31043106
}
31053107

refs/refs-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ struct ref_update *ref_transaction_add_update(
162162
const struct object_id *new_oid,
163163
const struct object_id *old_oid,
164164
const char *new_target, const char *old_target,
165+
const char *committer_info,
165166
const char *msg);
166167

167168
/*

refs/reftable-backend.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,8 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
10781078
new_update = ref_transaction_add_update(
10791079
transaction, "HEAD",
10801080
u->flags | REF_LOG_ONLY | REF_NO_DEREF,
1081-
&u->new_oid, &u->old_oid, NULL, NULL, u->msg);
1081+
&u->new_oid, &u->old_oid, NULL, NULL, NULL,
1082+
u->msg);
10821083
string_list_insert(&affected_refnames, new_update->refname);
10831084
}
10841085

@@ -1161,7 +1162,8 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,
11611162
transaction, referent.buf, new_flags,
11621163
u->new_target ? NULL : &u->new_oid,
11631164
u->old_target ? NULL : &u->old_oid,
1164-
u->new_target, u->old_target, u->msg);
1165+
u->new_target, u->old_target,
1166+
u->committer_info, u->msg);
11651167

11661168
new_update->parent_update = u;
11671169

0 commit comments

Comments
 (0)