Skip to content

Commit 6ddd76f

Browse files
committed
Merge branch 'ps/ref-transaction-hook'
Code simplification by removing ineffective optimization. * ps/ref-transaction-hook: refs: remove lookup cache for reference-transaction hook
2 parents cacab0c + 0a0fbbe commit 6ddd76f

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

refs.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,24 +1950,17 @@ int ref_update_reject_duplicates(struct string_list *refnames,
19501950
return 0;
19511951
}
19521952

1953-
static const char hook_not_found;
1954-
static const char *hook;
1955-
19561953
static int run_transaction_hook(struct ref_transaction *transaction,
19571954
const char *state)
19581955
{
19591956
struct child_process proc = CHILD_PROCESS_INIT;
19601957
struct strbuf buf = STRBUF_INIT;
1958+
const char *hook;
19611959
int ret = 0, i;
19621960

1963-
if (hook == &hook_not_found)
1964-
return ret;
1961+
hook = find_hook("reference-transaction");
19651962
if (!hook)
1966-
hook = xstrdup_or_null(find_hook("reference-transaction"));
1967-
if (!hook) {
1968-
hook = &hook_not_found;
19691963
return ret;
1970-
}
19711964

19721965
strvec_pushl(&proc.args, hook, state, NULL);
19731966
proc.in = -1;

t/perf/p1400-update-ref.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ test_description="Tests performance of update-ref"
77
test_perf_fresh_repo
88

99
test_expect_success "setup" '
10+
git init --bare target-repo.git &&
1011
test_commit PRE &&
1112
test_commit POST &&
1213
printf "create refs/heads/%d PRE\n" $(test_seq 1000) >create &&
1314
printf "update refs/heads/%d POST PRE\n" $(test_seq 1000) >update &&
14-
printf "delete refs/heads/%d POST\n" $(test_seq 1000) >delete
15+
printf "delete refs/heads/%d POST\n" $(test_seq 1000) >delete &&
16+
git update-ref --stdin <create
1517
'
1618

1719
test_perf "update-ref" '
@@ -24,9 +26,14 @@ test_perf "update-ref" '
2426
'
2527

2628
test_perf "update-ref --stdin" '
27-
git update-ref --stdin <create &&
2829
git update-ref --stdin <update &&
29-
git update-ref --stdin <delete
30+
git update-ref --stdin <delete &&
31+
git update-ref --stdin <create
32+
'
33+
34+
test_perf "nonatomic push" '
35+
git push ./target-repo.git $(test_seq 1000) &&
36+
git push --delete ./target-repo.git $(test_seq 1000)
3037
'
3138

3239
test_done

0 commit comments

Comments
 (0)