Skip to content

Commit c12eca7

Browse files
committed
Merge branch 'jk/smart-http-hide-refs'
The transfer.hiderefs support did not quite work for smart-http transport. * jk/smart-http-hide-refs: upload-pack: do not check NULL return of lookup_unknown_object upload-pack: fix transfer.hiderefs over smart-http
2 parents a633651 + 8ddf3ca commit c12eca7

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

t/t5551-http-fetch-smart.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,17 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
213213
test_cmp expect_cookies.txt cookies_tail.txt
214214
'
215215

216+
test_expect_success 'transfer.hiderefs works over smart-http' '
217+
test_commit hidden &&
218+
test_commit visible &&
219+
git push public HEAD^:refs/heads/a HEAD:refs/heads/b &&
220+
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
221+
config transfer.hiderefs refs/heads/a &&
222+
git clone --bare "$HTTPD_URL/smart/repo.git" hidden.git &&
223+
test_must_fail git -C hidden.git rev-parse --verify a &&
224+
git -C hidden.git rev-parse --verify b
225+
'
226+
216227
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
217228
(
218229
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&

upload-pack.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,20 +681,24 @@ static void receive_needs(void)
681681
}
682682

683683
/* return non-zero if the ref is hidden, otherwise 0 */
684-
static int mark_our_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
684+
static int mark_our_ref(const char *refname, const unsigned char *sha1)
685685
{
686686
struct object *o = lookup_unknown_object(sha1);
687687

688688
if (ref_is_hidden(refname)) {
689689
o->flags |= HIDDEN_REF;
690690
return 1;
691691
}
692-
if (!o)
693-
die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
694692
o->flags |= OUR_REF;
695693
return 0;
696694
}
697695

696+
static int check_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
697+
{
698+
mark_our_ref(refname, sha1);
699+
return 0;
700+
}
701+
698702
static void format_symref_info(struct strbuf *buf, struct string_list *symref)
699703
{
700704
struct string_list_item *item;
@@ -713,7 +717,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
713717
const char *refname_nons = strip_namespace(refname);
714718
unsigned char peeled[20];
715719

716-
if (mark_our_ref(refname, sha1, flag, NULL))
720+
if (mark_our_ref(refname, sha1))
717721
return 0;
718722

719723
if (capabilities) {
@@ -767,8 +771,8 @@ static void upload_pack(void)
767771
advertise_shallow_grafts(1);
768772
packet_flush(1);
769773
} else {
770-
head_ref_namespaced(mark_our_ref, NULL);
771-
for_each_namespaced_ref(mark_our_ref, NULL);
774+
head_ref_namespaced(check_ref, NULL);
775+
for_each_namespaced_ref(check_ref, NULL);
772776
}
773777
string_list_clear(&symref, 1);
774778
if (advertise_refs)

0 commit comments

Comments
 (0)