diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2019-01-10 19:36:45 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-01-10 22:53:35 (GMT) |
commit | bd0b42aed3084bf66557485fd7d87e975a4f6d4e (patch) | |
tree | 3687936d9bd551986a68a23e665ec169e08194bd /shallow.c | |
parent | ecbdaf0899161c067986e9d9d564586d4b045d62 (diff) | |
download | git-bd0b42aed3084bf66557485fd7d87e975a4f6d4e.zip git-bd0b42aed3084bf66557485fd7d87e975a4f6d4e.tar.gz git-bd0b42aed3084bf66557485fd7d87e975a4f6d4e.tar.bz2 |
fetch-pack: do not take shallow lock unnecessarily
When fetching using protocol v2, the remote may send a "shallow-info"
section if the client is shallow. If so, Git as the client currently
takes the shallow file lock, even if the "shallow-info" section is
empty.
This is not a problem except that Git does not support taking the
shallow file lock after modifying the shallow file, because
is_repository_shallow() stores information that is never cleared. And
this take-after-modify occurs when Git does a tag-following fetch from a
shallow repository on a transport that does not support tag following
(since in this case, 2 fetches are performed).
To solve this issue, take the shallow file lock (and perform all other
shallow processing) only if the "shallow-info" section is non-empty;
otherwise, behave as if it were empty.
A full solution (probably, ensuring that any action of committing
shallow file locks also includes clearing the information stored by
is_repository_shallow()) would solve the issue without need for this
patch, but this patch is independently useful (as an optimization to
prevent writing a file in an unnecessary case), hence why I wrote it. I
have included a NEEDSWORK outlining the full solution.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'shallow.c')
-rw-r--r-- | shallow.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -43,6 +43,13 @@ int register_shallow(struct repository *r, const struct object_id *oid) int is_repository_shallow(struct repository *r) { + /* + * NEEDSWORK: This function updates + * r->parsed_objects->{is_shallow,shallow_stat} as a side effect but + * there is no corresponding function to clear them when the shallow + * file is updated. + */ + FILE *fp; char buf[1024]; const char *path = r->parsed_objects->alternate_shallow_file; |