[PATCH v15 00/10] set-head/fetch remote/HEAD updates
From: Bence Ferdinandy <hidden>
Date: 2024-11-22 12:32:39
2/10: use test_must_fail and test_when_finished
3/10: whitespace fix
Bence Ferdinandy (10):
t/t5505-remote: set default branch to main
t/t5505-remote: test failure of set-head
refs: standardize output of refs_read_symbolic_ref
refs: atomically record overwritten ref in update_symref
remote set-head: refactor for readability
remote set-head: better output for --auto
refs: add TRANSACTION_CREATE_EXISTS error
refs: add create_only option to refs_update_symref_extended
fetch: set remote/HEAD if it does not exist
fetch set_head: handle mirrored bare repositories
builtin/fetch.c | 74 +++++++++++++++++++++
builtin/remote.c | 72 +++++++++++++++------
refs.c | 47 ++++++++++++--
refs.h | 19 +++++-
refs/files-backend.c | 31 +++++----
refs/refs-internal.h | 5 ++
refs/reftable-backend.c | 12 ++--
t/t4207-log-decoration-colors.sh | 3 +-
t/t5505-remote.sh | 107 +++++++++++++++++++++++++++++--
t/t5510-fetch.sh | 24 +++++++
t/t5512-ls-remote.sh | 2 +
t/t5514-fetch-multiple.sh | 17 ++++-
t/t5516-fetch-push.sh | 3 +-
t/t5527-fetch-odd-refs.sh | 3 +-
t/t7900-maintenance.sh | 3 +-
t/t9210-scalar.sh | 5 +-
t/t9211-scalar-clone.sh | 6 +-
t/t9902-completion.sh | 65 +++++++++++++++++++
18 files changed, 439 insertions(+), 59 deletions(-)
Range-diff against v14:
1: 49cfd222d5 = 1: 2e1d001d1a t/t5505-remote: set default branch to main
2: 54bf9c7fff ! 2: d24e62035a t/t5505-remote: test failure of set-head
@@ Commit message
## Notes ##
v14: new patch
+ v15: - use test_must_fail and test_when_finished
+
## builtin/remote.c ##
@@ builtin/remote.c: static int set_head(int argc, const char **argv, const char *prefix)
if (!refs_ref_exists(get_main_ref_store(the_repository), buf2.buf))
@@ t/t5505-remote.sh: test_expect_success 'set-head --auto' '
'
+test_expect_success REFFILES 'set-head --auto failure' '
++ test_when_finished "rm -f test/.git/refs/remotes/origin/HEAD.lock" &&
+ (
+ cd test &&
+ touch .git/refs/remotes/origin/HEAD.lock &&
-+ git remote set-head --auto origin 2>errormsg ||
-+ tail -n1 errormsg >output &&
-+ rm .git/refs/remotes/origin/HEAD.lock &&
++ test_must_fail git remote set-head --auto origin 2>err &&
++ tail -n1 err >output &&
+ echo "error: Could not set up refs/remotes/origin/HEAD" >expect &&
+ test_cmp expect output
+ )
3: c95362236e ! 3: 1218d521e5 refs: standardize output of refs_read_symbolic_ref
@@ Notes
- rewrote comment in refs-internal.h to point to the one in refs.h
- created NOT_A_SYMREF=-2 constant
+ v15: fix whitespace issues
+
## refs.h ##
@@ refs.h: int refs_read_ref_full(struct ref_store *refs, const char *refname,
@@ refs/reftable-backend.c: static int reftable_be_read_symbolic_ref(struct ref_sto
ret = reftable_stack_read_ref(stack, refname, &ref);
- if (ret == 0 && ref.value_type == REFTABLE_REF_SYMREF)
-+ if (ret)
-+ ret = -1;
-+ else if (ref.value_type == REFTABLE_REF_SYMREF)
++ if (ret)
++ ret = -1;
++ else if (ref.value_type == REFTABLE_REF_SYMREF)
strbuf_addstr(referent, ref.value.symref);
-- else
+ else
- ret = -1;
-+ else
-+ ret = NOT_A_SYMREF;
++ ret = NOT_A_SYMREF;
reftable_ref_record_release(&ref);
return ret;
4: 21533e0e6b ! 4: 4d5f3f4f01 refs: atomically record overwritten ref in update_symref
@@ Notes
- the returned error code by the above was also incorrect and now
is -2 (and uses NOT_A_SYMREF now)
+ v15: no change
+
## refs.c ##
@@ refs.c: int peel_iterated_oid(struct repository *r, const struct object_id *base, struct
5: 2455768c24 ! 5: 6f2cb51b0b remote set-head: refactor for readability
@@ Notes
v14: no change
+ v15: no change
+
## builtin/remote.c ##
@@ builtin/remote.c: static int show(int argc, const char **argv, const char *prefix)
static int set_head(int argc, const char **argv, const char *prefix)
6: 396537a598 ! 6: ca8687bae1 remote set-head: better output for --auto
@@ Notes
v14: - fixed badly named variable
- fixed not reporting errors correctly
+ v15: no change
+
## builtin/remote.c ##
@@ builtin/remote.c: static int show(int argc, const char **argv, const char *prefix)
return result;
7: 05e97155d1 ! 7: 45bcb33b52 refs: add TRANSACTION_CREATE_EXISTS error
@@ Notes
v14: no change
+ v15: no change
+
## refs.h ##
@@ refs.h: int ref_transaction_verify(struct ref_transaction *transaction,
8: 3ea8b1b8b6 ! 8: a8a522a089 refs: add create_only option to refs_update_symref_extended
@@ Notes
v14: no change
+ v15: no change
+
## builtin/remote.c ##
@@ builtin/remote.c: static int set_head(int argc, const char **argv, const char *prefix)
goto cleanup;
9: 287c25b801 ! 9: ff294461d8 fetch: set remote/HEAD if it does not exist
@@ Notes
created with an opt out, and the configuration for this will be added in
a later patch
+ v15: no change
+
## builtin/fetch.c ##
@@ builtin/fetch.c: static int backfill_tags(struct display_state *display_state,
return retcode;
10: 05d8526399 ! 10: 0e96260ab6 fetch set_head: handle mirrored bare repositories
@@ Notes
v14: no change
+ v15: no change
+
## builtin/fetch.c ##
@@ builtin/fetch.c: static const char *strip_refshead(const char *name){
--
2.47.0.298.g52a96ec17b