----
advertised-refs = (no-refs / list-of-refs)
+ *shallow
flush-pkt
no-refs = PKT-LINE(zero-id SP "capabilities^{}"
other-tip = obj-id SP refname LF
other-peeled = obj-id SP refname "^{}" LF
+ shallow = PKT-LINE("shallow" SP obj-id)
+
capability-list = capability *(SP capability)
capability = 1*(LC_ALPHA / DIGIT / "-" / "_")
LC_ALPHA = %x61-7A
if (!sent_capabilities)
show_ref("capabilities^{}", null_sha1);
+ advertise_shallow_grafts(1);
+
/* EOF */
packet_flush(1);
}
if (!enter_repo(dir, 0))
die("'%s' does not appear to be a git repository", dir);
- if (is_repository_shallow())
+ if (is_repository_shallow() && stateless_rpc)
die("attempt to push into a shallow repository");
git_config(receive_pack_config, NULL);
extern void setup_alternate_shallow(struct lock_file *shallow_lock,
const char **alternate_shallow_file);
extern char *setup_temporary_shallow(void);
+extern void advertise_shallow_grafts(int);
int is_descendant_of(struct commit *, struct commit_list *);
int in_merge_bases(struct commit *, struct commit *);
*alternate_shallow_file = "";
strbuf_release(&sb);
}
+
+static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *cb)
+{
+ int fd = *(int *)cb;
+ if (graft->nr_parent == -1)
+ packet_write(fd, "shallow %s\n", sha1_to_hex(graft->sha1));
+ return 0;
+}
+
+void advertise_shallow_grafts(int fd)
+{
+ if (!is_repository_shallow())
+ return;
+ for_each_commit_graft(advertise_shallow_grafts_cb, &fd);
+}
reset_timeout();
head_ref_namespaced(send_ref, &symref);
for_each_namespaced_ref(send_ref, &symref);
+ advertise_shallow_grafts(1);
packet_flush(1);
} else {
head_ref_namespaced(mark_our_ref, NULL);
if (!enter_repo(dir, strict))
die("'%s' does not appear to be a git repository", dir);
- if (is_repository_shallow())
- die("attempt to fetch/clone from a shallow repository");
+ if (is_repository_shallow() && stateless_rpc)
+ die("attempt to push into a shallow repository");
+
git_config(upload_pack_config, NULL);
upload_pack();
return 0;