Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
upload-pack: move rev-list code out of check_non_tip()
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 12 Jun 2016 10:53:52 +0000
(17:53 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 13 Jun 2016 21:38:16 +0000
(14:38 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
7fcbd37
)
diff --git
a/upload-pack.c
b/upload-pack.c
index 7ce97ecd90f275ff5f5ed9e052ceafea95791069..93c05229cb2c451365b6c18be26af600d704b1f8 100644
(file)
--- a/
upload-pack.c
+++ b/
upload-pack.c
@@
-451,7
+451,7
@@
static int is_our_ref(struct object *o)
return o->flags & ((allow_hidden_ref ? HIDDEN_REF : 0) | OUR_REF);
}
return o->flags & ((allow_hidden_ref ? HIDDEN_REF : 0) | OUR_REF);
}
-static
void check_non_tip(void
)
+static
int has_unreachable(struct object_array *src
)
{
static const char *argv[] = {
"rev-list", "--stdin", NULL,
{
static const char *argv[] = {
"rev-list", "--stdin", NULL,
@@
-461,14
+461,6
@@
static void check_non_tip(void)
char namebuf[42]; /* ^ + SHA-1 + LF */
int i;
char namebuf[42]; /* ^ + SHA-1 + LF */
int i;
- /*
- * In the normal in-process case without
- * uploadpack.allowReachableSHA1InWant,
- * non-tip requests can never happen.
- */
- if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1))
- goto error;
-
cmd.argv = argv;
cmd.git_cmd = 1;
cmd.no_stderr = 1;
cmd.argv = argv;
cmd.git_cmd = 1;
cmd.no_stderr = 1;
@@
-498,8
+490,8
@@
static void check_non_tip(void)
goto error;
}
namebuf[40] = '\n';
goto error;
}
namebuf[40] = '\n';
- for (i = 0; i <
want_obj.
nr; i++) {
- o =
want_obj.
objects[i].item;
+ for (i = 0; i <
src->
nr; i++) {
+ o =
src->
objects[i].item;
if (is_our_ref(o))
continue;
memcpy(namebuf, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
if (is_our_ref(o))
continue;
memcpy(namebuf, oid_to_hex(&o->oid), GIT_SHA1_HEXSZ);
@@
-530,7
+522,7
@@
static void check_non_tip(void)
sigchain_pop(SIGPIPE);
/* All the non-tip ones are ancestors of what we advertised */
sigchain_pop(SIGPIPE);
/* All the non-tip ones are ancestors of what we advertised */
- return;
+ return
0
;
error:
sigchain_pop(SIGPIPE);
error:
sigchain_pop(SIGPIPE);
@@
-539,10
+531,28
@@
static void check_non_tip(void)
close(cmd.in);
if (cmd.out >= 0)
close(cmd.out);
close(cmd.in);
if (cmd.out >= 0)
close(cmd.out);
+ return 1;
+}
+static void check_non_tip(void)
+{
+ int i;
+
+ /*
+ * In the normal in-process case without
+ * uploadpack.allowReachableSHA1InWant,
+ * non-tip requests can never happen.
+ */
+ if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1))
+ goto error;
+ if (!has_unreachable(&want_obj))
+ /* All the non-tip ones are ancestors of what we advertised */
+ return;
+
+error:
/* Pick one of them (we know there at least is one) */
for (i = 0; i < want_obj.nr; i++) {
/* Pick one of them (we know there at least is one) */
for (i = 0; i < want_obj.nr; i++) {
- o = want_obj.objects[i].item;
+
struct object *
o = want_obj.objects[i].item;
if (!is_our_ref(o))
die("git upload-pack: not our ref %s",
oid_to_hex(&o->oid));
if (!is_our_ref(o))
die("git upload-pack: not our ref %s",
oid_to_hex(&o->oid));