Skip to content

Commit a88f4ed

Browse files
authored
Merge branch 'git:master' into changed-paths-config
2 parents a42d730 + 79cf913 commit a88f4ed

39 files changed

+535
-421
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ SpaceBeforeCaseColon: false
149149
# f();
150150
# }
151151
# }
152-
SpaceBeforeParens: ControlStatements
152+
SpaceBeforeParens: ControlStatementsExceptControlMacros
153153

154154
# Don't insert spaces inside empty '()'
155155
SpaceInEmptyParentheses: false

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Jon Loeliger <[email protected]> <[email protected]>
126126
127127
128128
Jonathan del Strother <[email protected]> <[email protected]>
129+
129130
130131
131132

Documentation/RelNotes/2.52.0.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ including security updates, are included in this release.
280280
updated.
281281
(merge 54a60e5b38 kh/you-still-use-whatchanged-fix later to maint).
282282

283+
* Clang-format update to let our control macros formatted the way we
284+
had them traditionally, e.g., "for_each_string_list_item()" without
285+
space before the parentheses.
286+
(merge 3721541d35 jt/clang-format-foreach-wo-space-before-parenthesis later to maint).
287+
288+
* A few places where an size_t value was cast to curl_off_t without
289+
checking has been updated to use the existing helper function.
290+
(merge ecc5749578 js/curl-off-t-fixes later to maint).
291+
283292
* Other code cleanup, docfix, build fix, etc.
284293
(merge 823d537fa7 kh/doc-git-log-markup-fix later to maint).
285294
(merge cf7efa4f33 rj/t6137-cygwin-fix later to maint).
@@ -305,3 +314,4 @@ including security updates, are included in this release.
305314
(merge ac7096723b jc/doc-includeif-hasconfig-remote-url-fix later to maint).
306315
(merge fafc9b08b8 ag/doc-sendmail-gmail-example-update later to maint).
307316
(merge a66fc22bf9 rs/get-oid-with-flags-cleanup later to maint).
317+
(merge e1d062e8ba ps/odb-clean-stale-wrappers later to maint).

Documentation/git-push.adoc

Lines changed: 103 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -55,96 +55,66 @@ OPTIONS[[OPTIONS]]
5555

5656
<refspec>...::
5757
Specify what destination ref to update with what source object.
58-
The format of a <refspec> parameter is an optional plus
59-
`+`, followed by the source object <src>, followed
60-
by a colon `:`, followed by the destination ref <dst>.
61-
+
62-
The <src> is often the name of the branch you would want to push, but
63-
it can be any arbitrary "SHA-1 expression", such as `master~4` or
64-
`HEAD` (see linkgit:gitrevisions[7]).
65-
+
66-
The <dst> tells which ref on the remote side is updated with this
67-
push. Arbitrary expressions cannot be used here, an actual ref must
68-
be named.
69-
If `git push [<repository>]` without any `<refspec>` argument is set to
70-
update some ref at the destination with `<src>` with
71-
`remote.<repository>.push` configuration variable, `:<dst>` part can
72-
be omitted--such a push will update a ref that `<src>` normally updates
73-
without any `<refspec>` on the command line. Otherwise, missing
74-
`:<dst>` means to update the same ref as the `<src>`.
75-
+
76-
If <dst> doesn't start with `refs/` (e.g. `refs/heads/master`) we will
77-
try to infer where in `refs/*` on the destination <repository> it
78-
belongs based on the type of <src> being pushed and whether <dst>
79-
is ambiguous.
8058
+
81-
--
82-
* If <dst> unambiguously refers to a ref on the <repository> remote,
83-
then push to that ref.
84-
85-
* If <src> resolves to a ref starting with refs/heads/ or refs/tags/,
86-
then prepend that to <dst>.
87-
88-
* Other ambiguity resolutions might be added in the future, but for
89-
now any other cases will error out with an error indicating what we
90-
tried, and depending on the `advice.pushUnqualifiedRefname`
91-
configuration (see linkgit:git-config[1]) suggest what refs/
92-
namespace you may have wanted to push to.
93-
94-
--
95-
+
96-
The object referenced by <src> is used to update the <dst> reference
97-
on the remote side. Whether this is allowed depends on where in
98-
`refs/*` the <dst> reference lives as described in detail below, in
99-
those sections "update" means any modifications except deletes, which
100-
as noted after the next few sections are treated differently.
101-
+
102-
The `refs/heads/*` namespace will only accept commit objects, and
103-
updates only if they can be fast-forwarded.
104-
+
105-
The `refs/tags/*` namespace will accept any kind of object (as
106-
commits, trees and blobs can be tagged), and any updates to them will
107-
be rejected.
108-
+
109-
It's possible to push any type of object to any namespace outside of
110-
`refs/{tags,heads}/*`. In the case of tags and commits, these will be
111-
treated as if they were the commits inside `refs/heads/*` for the
112-
purposes of whether the update is allowed.
113-
+
114-
I.e. a fast-forward of commits and tags outside `refs/{tags,heads}/*`
115-
is allowed, even in cases where what's being fast-forwarded is not a
116-
commit, but a tag object which happens to point to a new commit which
117-
is a fast-forward of the commit the last tag (or commit) it's
118-
replacing. Replacing a tag with an entirely different tag is also
119-
allowed, if it points to the same commit, as well as pushing a peeled
120-
tag, i.e. pushing the commit that existing tag object points to, or a
121-
new tag object which an existing commit points to.
122-
+
123-
Tree and blob objects outside of `refs/{tags,heads}/*` will be treated
124-
the same way as if they were inside `refs/tags/*`, any update of them
125-
will be rejected.
126-
+
127-
All of the rules described above about what's not allowed as an update
128-
can be overridden by adding an the optional leading `+` to a refspec
129-
(or using `--force` command line option). The only exception to this
130-
is that no amount of forcing will make the `refs/heads/*` namespace
131-
accept a non-commit object. Hooks and configuration can also override
132-
or amend these rules, see e.g. `receive.denyNonFastForwards` in
133-
linkgit:git-config[1] and `pre-receive` and `update` in
134-
linkgit:githooks[5].
135-
+
136-
Pushing an empty <src> allows you to delete the <dst> ref from the
137-
remote repository. Deletions are always accepted without a leading `+`
138-
in the refspec (or `--force`), except when forbidden by configuration
139-
or hooks. See `receive.denyDeletes` in linkgit:git-config[1] and
140-
`pre-receive` and `update` in linkgit:githooks[5].
141-
+
142-
The special refspec `:` (or `+:` to allow non-fast-forward updates)
143-
directs Git to push "matching" branches: for every branch that exists on
144-
the local side, the remote side is updated if a branch of the same name
145-
already exists on the remote side.
146-
+
147-
`tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
59+
The format for a refspec is [+]<src>[:<dst>], for example `main`,
60+
`main:other`, or `HEAD^:refs/heads/main`.
61+
+
62+
The `<src>` is often the name of the local branch to push, but it can be
63+
any arbitrary "SHA-1 expression" (see linkgit:gitrevisions[7]).
64+
+
65+
The `<dst>` determines what ref to update on the remote side. It must be the
66+
name of a branch, tag, or other ref, not an arbitrary expression.
67+
+
68+
The `+` is optional and does the same thing as `--force`.
69+
+
70+
You can write a refspec using the fully expanded form (for
71+
example `refs/heads/main:refs/heads/main`) which specifies the exact source
72+
and destination, or with a shorter form (for example `main` or
73+
`main:other`). Here are the rules for how refspecs are expanded,
74+
as well as various other special refspec forms:
75+
+
76+
* `<src>` without a `:<dst>` means to update the same ref as the
77+
`<src>`, unless the `remote.<repository>.push` configuration specifies a
78+
different <dst>. For example, if `main` is a branch, then the refspec
79+
`main` expands to `main:refs/heads/main`.
80+
* If `<dst>` unambiguously refers to a ref on the <repository> remote,
81+
then expand it to that ref. For example, if `v1.0` is a tag on the
82+
remote, then `HEAD:v1.0` expands to `HEAD:refs/tags/v1.0`.
83+
* If `<src>` resolves to a ref starting with `refs/heads/` or `refs/tags/`,
84+
then prepend that to <dst>. For example, if `main` is a branch, then
85+
`main:other` expands to `main:refs/heads/other`
86+
* The special refspec `:` (or `+:` to allow non-fast-forward updates)
87+
directs Git to push "matching" branches: for every branch that exists on
88+
the local side, the remote side is updated if a branch of the same name
89+
already exists on the remote side.
90+
* <src> may contain a * to indicate a simple pattern match.
91+
This works like a glob that matches any ref matching the pattern.
92+
There must be only one * in both the `<src>` and `<dst>`.
93+
It will map refs to the destination by replacing the * with the
94+
contents matched from the source. For example, `refs/heads/*:refs/heads/*`
95+
will push all branches.
96+
* A refspec starting with `^` is a negative refspec.
97+
This specifies refs to exclude. A ref will be considered to
98+
match if it matches at least one positive refspec, and does not
99+
match any negative refspec. Negative refspecs can be pattern refspecs.
100+
They must only contain a `<src>`.
101+
Fully spelled out hex object names are also not supported.
102+
For example, `git push origin 'refs/heads/*' '^refs/heads/dev-*'`
103+
will push all branches except for those starting with `dev-`
104+
* If `<src>` is empty, it deletes the `<dst>` ref from the remote
105+
repository. For example, `git push origin :dev` will
106+
delete the `dev` branch.
107+
* `tag <tag>` expands to `refs/tags/<tag>:refs/tags/<tag>`.
108+
This is technically a special syntax for `git push` and not a refspec,
109+
since in `git push origin tag v1.0` the arguments `tag` and `v1.0`
110+
are separate.
111+
* If the refspec can't be expanded unambiguously, error out
112+
with an error indicating what was tried, and depending
113+
on the `advice.pushUnqualifiedRefname` configuration (see
114+
linkgit:git-config[1]) suggest what refs/ namespace you may have
115+
wanted to push to.
116+
117+
Not all updates are allowed: see PUSH RULES below for the details.
148118

149119
--all::
150120
--branches::
@@ -335,14 +305,12 @@ allowing a forced update.
335305

336306
-f::
337307
--force::
338-
Usually, the command refuses to update a remote ref that is
339-
not an ancestor of the local ref used to overwrite it.
340-
Also, when `--force-with-lease` option is used, the command refuses
341-
to update a remote ref whose current value does not match
342-
what is expected.
308+
Usually, `git push` will refuse to update a branch that is not an
309+
ancestor of the commit being pushed.
343310
+
344-
This flag disables these checks, and can cause the remote repository
345-
to lose commits; use it with care.
311+
This flag disables that check, the other safety checks in PUSH RULES
312+
below, and the checks in --force-with-lease. It can cause the remote
313+
repository to lose commits; use it with care.
346314
+
347315
Note that `--force` applies to all the refs that are pushed, hence
348316
using it with `push.default` set to `matching` or with multiple push
@@ -514,6 +482,45 @@ reason::
514482
refs, no explanation is needed. For a failed ref, the reason for
515483
failure is described.
516484

485+
PUSH RULES
486+
----------
487+
488+
As a safety feature, the `git push` command only allows certain kinds of
489+
updates to prevent you from accidentally losing data on the remote.
490+
491+
Because branches and tags are intended to be used differently, the
492+
safety rules for pushing to a branch are different from the rules
493+
for pushing to a tag. In the following rules "update" means any
494+
modifications except deletions and creations. Deletions and creations
495+
are always allowed, except when forbidden by configuration or hooks.
496+
497+
1. If the push destination is a **branch** (`refs/heads/*`): only
498+
fast-forward updates are allowed, which means the destination must be
499+
an ancestor of the source commit. The source must be a commit.
500+
2. If the push destination is a **tag** (`refs/tags/*`): all updates will
501+
be rejected. The source can be any object.
502+
3. If the push destination is not a branch or tag:
503+
* If the source is a tree or blob object, any updates will be rejected
504+
* If the source is a tag or commit object, any fast-forward update
505+
is allowed, even in cases where what's being fast-forwarded is not a
506+
commit, but a tag object which happens to point to a new commit which
507+
is a fast-forward of the commit the last tag (or commit) it's
508+
replacing. Replacing a tag with an entirely different tag is also
509+
allowed, if it points to the same commit, as well as pushing a peeled
510+
tag, i.e. pushing the commit that existing tag object points to, or a
511+
new tag object which an existing commit points to.
512+
513+
You can override these rules by passing `--force` or by adding the
514+
optional leading `+` to a refspec. The only exceptions are that no
515+
amount of forcing will make a branch accept a non-commit object,
516+
and forcing won't make the remote repository accept a push that it's
517+
configured to deny.
518+
519+
Hooks and configuration can also override or amend these rules,
520+
see e.g. `receive.denyNonFastForwards` and `receive.denyDeletes`
521+
in linkgit:git-config[1] and `pre-receive` and `update` in
522+
linkgit:githooks[5].
523+
517524
NOTE ABOUT FAST-FORWARDS
518525
------------------------
519526

builtin/backfill.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void download_batch(struct backfill_context *ctx)
5353
* We likely have a new packfile. Add it to the packed list to
5454
* avoid possible duplicate downloads of the same objects.
5555
*/
56-
reprepare_packed_git(ctx->repo);
56+
odb_reprepare(ctx->repo->objects);
5757
}
5858

5959
static int fill_missing_blobs(const char *path UNUSED,

builtin/cat-file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,10 @@ static void batch_each_object(struct batch_options *opt,
852852

853853
if (bitmap && !for_each_bitmapped_object(bitmap, &opt->objects_filter,
854854
batch_one_object_bitmapped, &payload)) {
855+
struct packfile_store *packs = the_repository->objects->packfiles;
855856
struct packed_git *pack;
856857

857-
for (pack = get_all_packs(the_repository); pack; pack = pack->next) {
858+
for (pack = packfile_store_get_all_packs(packs); pack; pack = pack->next) {
858859
if (bitmap_index_contains_pack(bitmap, pack) ||
859860
open_pack_index(pack))
860861
continue;

builtin/count-objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,15 @@ int cmd_count_objects(int argc,
122122
count_loose, count_cruft, NULL, NULL);
123123

124124
if (verbose) {
125+
struct packfile_store *packs = the_repository->objects->packfiles;
125126
struct packed_git *p;
126127
unsigned long num_pack = 0;
127128
off_t size_pack = 0;
128129
struct strbuf loose_buf = STRBUF_INIT;
129130
struct strbuf pack_buf = STRBUF_INIT;
130131
struct strbuf garbage_buf = STRBUF_INIT;
131132

132-
for (p = get_all_packs(the_repository); p; p = p->next) {
133+
for (p = packfile_store_get_all_packs(packs); p; p = p->next) {
133134
if (!p->pack_local)
134135
continue;
135136
if (open_pack_index(p))

builtin/fast-import.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,11 @@ static void end_packfile(void)
899899
idx_name = keep_pack(create_index());
900900

901901
/* Register the packfile with core git's machinery. */
902-
new_p = add_packed_git(pack_data->repo, idx_name, strlen(idx_name), 1);
902+
new_p = packfile_store_load_pack(pack_data->repo->objects->packfiles,
903+
idx_name, 1);
903904
if (!new_p)
904905
die("core git rejected index %s", idx_name);
905906
all_packs[pack_id] = new_p;
906-
install_packed_git(the_repository, new_p);
907907
free(idx_name);
908908

909909
/* Print the boundary */
@@ -954,6 +954,7 @@ static int store_object(
954954
struct object_id *oidout,
955955
uintmax_t mark)
956956
{
957+
struct packfile_store *packs = the_repository->objects->packfiles;
957958
void *out, *delta;
958959
struct object_entry *e;
959960
unsigned char hdr[96];
@@ -977,7 +978,7 @@ static int store_object(
977978
if (e->idx.offset) {
978979
duplicate_count_by_type[type]++;
979980
return 1;
980-
} else if (find_oid_pack(&oid, get_all_packs(the_repository))) {
981+
} else if (find_oid_pack(&oid, packfile_store_get_all_packs(packs))) {
981982
e->type = type;
982983
e->pack_id = MAX_PACK_ID;
983984
e->idx.offset = 1; /* just not zero! */
@@ -1094,6 +1095,7 @@ static void truncate_pack(struct hashfile_checkpoint *checkpoint)
10941095

10951096
static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
10961097
{
1098+
struct packfile_store *packs = the_repository->objects->packfiles;
10971099
size_t in_sz = 64 * 1024, out_sz = 64 * 1024;
10981100
unsigned char *in_buf = xmalloc(in_sz);
10991101
unsigned char *out_buf = xmalloc(out_sz);
@@ -1177,7 +1179,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
11771179
duplicate_count_by_type[OBJ_BLOB]++;
11781180
truncate_pack(&checkpoint);
11791181

1180-
} else if (find_oid_pack(&oid, get_all_packs(the_repository))) {
1182+
} else if (find_oid_pack(&oid, packfile_store_get_all_packs(packs))) {
11811183
e->type = OBJ_BLOB;
11821184
e->pack_id = MAX_PACK_ID;
11831185
e->idx.offset = 1; /* just not zero! */

builtin/fsck.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -867,19 +867,20 @@ static int mark_packed_for_connectivity(const struct object_id *oid,
867867

868868
static int check_pack_rev_indexes(struct repository *r, int show_progress)
869869
{
870+
struct packfile_store *packs = r->objects->packfiles;
870871
struct progress *progress = NULL;
871872
uint32_t pack_count = 0;
872873
int res = 0;
873874

874875
if (show_progress) {
875-
for (struct packed_git *p = get_all_packs(r); p; p = p->next)
876+
for (struct packed_git *p = packfile_store_get_all_packs(packs); p; p = p->next)
876877
pack_count++;
877878
progress = start_delayed_progress(the_repository,
878879
"Verifying reverse pack-indexes", pack_count);
879880
pack_count = 0;
880881
}
881882

882-
for (struct packed_git *p = get_all_packs(r); p; p = p->next) {
883+
for (struct packed_git *p = packfile_store_get_all_packs(packs); p; p = p->next) {
883884
int load_error = load_pack_revindex_from_disk(p);
884885

885886
if (load_error < 0) {
@@ -999,6 +1000,8 @@ int cmd_fsck(int argc,
9991000
for_each_packed_object(the_repository,
10001001
mark_packed_for_connectivity, NULL, 0);
10011002
} else {
1003+
struct packfile_store *packs = the_repository->objects->packfiles;
1004+
10021005
odb_prepare_alternates(the_repository->objects);
10031006
for (source = the_repository->objects->sources; source; source = source->next)
10041007
fsck_source(source);
@@ -1009,7 +1012,7 @@ int cmd_fsck(int argc,
10091012
struct progress *progress = NULL;
10101013

10111014
if (show_progress) {
1012-
for (p = get_all_packs(the_repository); p;
1015+
for (p = packfile_store_get_all_packs(packs); p;
10131016
p = p->next) {
10141017
if (open_pack_index(p))
10151018
continue;
@@ -1019,7 +1022,7 @@ int cmd_fsck(int argc,
10191022
progress = start_progress(the_repository,
10201023
_("Checking objects"), total);
10211024
}
1022-
for (p = get_all_packs(the_repository); p;
1025+
for (p = packfile_store_get_all_packs(packs); p;
10231026
p = p->next) {
10241027
/* verify gives error messages itself */
10251028
if (verify_pack(the_repository,

0 commit comments

Comments
 (0)