@@ -361,17 +361,19 @@ static void run_service(const char **argv)
361
361
static int show_text_ref (const char * name , const unsigned char * sha1 ,
362
362
int flag , void * cb_data )
363
363
{
364
+ const char * name_nons = strip_namespace (name );
364
365
struct strbuf * buf = cb_data ;
365
366
struct object * o = parse_object (sha1 );
366
367
if (!o )
367
368
return 0 ;
368
369
369
- strbuf_addf (buf , "%s\t%s\n" , sha1_to_hex (sha1 ), name );
370
+ strbuf_addf (buf , "%s\t%s\n" , sha1_to_hex (sha1 ), name_nons );
370
371
if (o -> type == OBJ_TAG ) {
371
372
o = deref_tag (o , name , 0 );
372
373
if (!o )
373
374
return 0 ;
374
- strbuf_addf (buf , "%s\t%s^{}\n" , sha1_to_hex (o -> sha1 ), name );
375
+ strbuf_addf (buf , "%s\t%s^{}\n" , sha1_to_hex (o -> sha1 ),
376
+ name_nons );
375
377
}
376
378
return 0 ;
377
379
}
@@ -402,12 +404,40 @@ static void get_info_refs(char *arg)
402
404
403
405
} else {
404
406
select_getanyfile ();
405
- for_each_ref (show_text_ref , & buf );
407
+ for_each_namespaced_ref (show_text_ref , & buf );
406
408
send_strbuf ("text/plain" , & buf );
407
409
}
408
410
strbuf_release (& buf );
409
411
}
410
412
413
+ static int show_head_ref (const char * name , const unsigned char * sha1 ,
414
+ int flag , void * cb_data )
415
+ {
416
+ struct strbuf * buf = cb_data ;
417
+
418
+ if (flag & REF_ISSYMREF ) {
419
+ unsigned char sha1 [20 ];
420
+ const char * target = resolve_ref_unsafe (name , sha1 , 1 , NULL );
421
+ const char * target_nons = strip_namespace (target );
422
+
423
+ strbuf_addf (buf , "ref: %s\n" , target_nons );
424
+ } else {
425
+ strbuf_addf (buf , "%s\n" , sha1_to_hex (sha1 ));
426
+ }
427
+
428
+ return 0 ;
429
+ }
430
+
431
+ static void get_head (char * arg )
432
+ {
433
+ struct strbuf buf = STRBUF_INIT ;
434
+
435
+ select_getanyfile ();
436
+ head_ref_namespaced (show_head_ref , & buf );
437
+ send_strbuf ("text/plain" , & buf );
438
+ strbuf_release (& buf );
439
+ }
440
+
411
441
static void get_info_packs (char * arg )
412
442
{
413
443
size_t objdirlen = strlen (get_object_directory ());
@@ -520,7 +550,7 @@ static struct service_cmd {
520
550
const char * pattern ;
521
551
void (* imp )(char * );
522
552
} services [] = {
523
- {"GET" , "/HEAD$" , get_text_file },
553
+ {"GET" , "/HEAD$" , get_head },
524
554
{"GET" , "/info/refs$" , get_info_refs },
525
555
{"GET" , "/objects/info/alternates$" , get_text_file },
526
556
{"GET" , "/objects/info/http-alternates$" , get_text_file },
0 commit comments