@@ -2578,8 +2578,15 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
2578
2578
* If it is a tag object, see if we use the peeled value. If we do,
2579
2579
* grab the peeled OID.
2580
2580
*/
2581
- if (need_tagged && peel_iterated_oid (the_repository , & obj -> oid , & oi_deref .oid ))
2582
- die ("bad tag" );
2581
+ if (need_tagged ) {
2582
+ if (!is_null_oid (& ref -> peeled_oid )) {
2583
+ oidcpy (& oi_deref .oid , & ref -> peeled_oid );
2584
+ } else if (!peel_object (the_repository , & obj -> oid , & oi_deref .oid )) {
2585
+ /* We managed to peel the object ourselves. */
2586
+ } else {
2587
+ die ("bad tag" );
2588
+ }
2589
+ }
2583
2590
2584
2591
return get_object (ref , 1 , & obj , & oi_deref , err );
2585
2592
}
@@ -2807,12 +2814,15 @@ static int match_points_at(struct oid_array *points_at,
2807
2814
* Callers can then fill in other struct members at their leisure.
2808
2815
*/
2809
2816
static struct ref_array_item * new_ref_array_item (const char * refname ,
2810
- const struct object_id * oid )
2817
+ const struct object_id * oid ,
2818
+ const struct object_id * peeled_oid )
2811
2819
{
2812
2820
struct ref_array_item * ref ;
2813
2821
2814
2822
FLEX_ALLOC_STR (ref , refname , refname );
2815
2823
oidcpy (& ref -> objectname , oid );
2824
+ if (peeled_oid )
2825
+ oidcpy (& ref -> peeled_oid , peeled_oid );
2816
2826
ref -> rest = NULL ;
2817
2827
2818
2828
return ref ;
@@ -2826,9 +2836,10 @@ static void ref_array_append(struct ref_array *array, struct ref_array_item *ref
2826
2836
2827
2837
struct ref_array_item * ref_array_push (struct ref_array * array ,
2828
2838
const char * refname ,
2829
- const struct object_id * oid )
2839
+ const struct object_id * oid ,
2840
+ const struct object_id * peeled_oid )
2830
2841
{
2831
- struct ref_array_item * ref = new_ref_array_item (refname , oid );
2842
+ struct ref_array_item * ref = new_ref_array_item (refname , oid , peeled_oid );
2832
2843
ref_array_append (array , ref );
2833
2844
return ref ;
2834
2845
}
@@ -2871,25 +2882,25 @@ static int filter_ref_kind(struct ref_filter *filter, const char *refname)
2871
2882
return ref_kind_from_refname (refname );
2872
2883
}
2873
2884
2874
- static struct ref_array_item * apply_ref_filter (const char * refname , const char * referent , const struct object_id * oid ,
2875
- int flag , struct ref_filter * filter )
2885
+ static struct ref_array_item * apply_ref_filter (const struct reference * ref ,
2886
+ struct ref_filter * filter )
2876
2887
{
2877
- struct ref_array_item * ref ;
2888
+ struct ref_array_item * item ;
2878
2889
struct commit * commit = NULL ;
2879
2890
unsigned int kind ;
2880
2891
2881
- if (flag & REF_BAD_NAME ) {
2882
- warning (_ ("ignoring ref with broken name %s" ), refname );
2892
+ if (ref -> flags & REF_BAD_NAME ) {
2893
+ warning (_ ("ignoring ref with broken name %s" ), ref -> name );
2883
2894
return NULL ;
2884
2895
}
2885
2896
2886
- if (flag & REF_ISBROKEN ) {
2887
- warning (_ ("ignoring broken ref %s" ), refname );
2897
+ if (ref -> flags & REF_ISBROKEN ) {
2898
+ warning (_ ("ignoring broken ref %s" ), ref -> name );
2888
2899
return NULL ;
2889
2900
}
2890
2901
2891
2902
/* Obtain the current ref kind from filter_ref_kind() and ignore unwanted refs. */
2892
- kind = filter_ref_kind (filter , refname );
2903
+ kind = filter_ref_kind (filter , ref -> name );
2893
2904
2894
2905
/*
2895
2906
* Generally HEAD refs are printed with special description denoting a rebase,
@@ -2902,13 +2913,13 @@ static struct ref_array_item *apply_ref_filter(const char *refname, const char *
2902
2913
else if (!(kind & filter -> kind ))
2903
2914
return NULL ;
2904
2915
2905
- if (!filter_pattern_match (filter , refname ))
2916
+ if (!filter_pattern_match (filter , ref -> name ))
2906
2917
return NULL ;
2907
2918
2908
- if (filter_exclude_match (filter , refname ))
2919
+ if (filter_exclude_match (filter , ref -> name ))
2909
2920
return NULL ;
2910
2921
2911
- if (filter -> points_at .nr && !match_points_at (& filter -> points_at , oid , refname ))
2922
+ if (filter -> points_at .nr && !match_points_at (& filter -> points_at , ref -> oid , ref -> name ))
2912
2923
return NULL ;
2913
2924
2914
2925
/*
@@ -2918,7 +2929,7 @@ static struct ref_array_item *apply_ref_filter(const char *refname, const char *
2918
2929
*/
2919
2930
if (filter -> reachable_from || filter -> unreachable_from ||
2920
2931
filter -> with_commit || filter -> no_commit || filter -> verbose ) {
2921
- commit = lookup_commit_reference_gently (the_repository , oid , 1 );
2932
+ commit = lookup_commit_reference_gently (the_repository , ref -> oid , 1 );
2922
2933
if (!commit )
2923
2934
return NULL ;
2924
2935
/* We perform the filtering for the '--contains' option... */
@@ -2936,13 +2947,13 @@ static struct ref_array_item *apply_ref_filter(const char *refname, const char *
2936
2947
* to do its job and the resulting list may yet to be pruned
2937
2948
* by maxcount logic.
2938
2949
*/
2939
- ref = new_ref_array_item (refname , oid );
2940
- ref -> commit = commit ;
2941
- ref -> flag = flag ;
2942
- ref -> kind = kind ;
2943
- ref -> symref = xstrdup_or_null (referent );
2950
+ item = new_ref_array_item (ref -> name , ref -> oid , ref -> peeled_oid );
2951
+ item -> commit = commit ;
2952
+ item -> flag = ref -> flags ;
2953
+ item -> kind = kind ;
2954
+ item -> symref = xstrdup_or_null (ref -> target );
2944
2955
2945
- return ref ;
2956
+ return item ;
2946
2957
}
2947
2958
2948
2959
struct ref_filter_cbdata {
@@ -2959,8 +2970,7 @@ static int filter_one(const struct reference *ref, void *cb_data)
2959
2970
struct ref_filter_cbdata * ref_cbdata = cb_data ;
2960
2971
struct ref_array_item * item ;
2961
2972
2962
- item = apply_ref_filter (ref -> name , ref -> target , ref -> oid ,
2963
- ref -> flags , ref_cbdata -> filter );
2973
+ item = apply_ref_filter (ref , ref_cbdata -> filter );
2964
2974
if (item )
2965
2975
ref_array_append (ref_cbdata -> array , item );
2966
2976
@@ -2997,8 +3007,7 @@ static int filter_and_format_one(const struct reference *ref, void *cb_data)
2997
3007
struct ref_array_item * item ;
2998
3008
struct strbuf output = STRBUF_INIT , err = STRBUF_INIT ;
2999
3009
3000
- item = apply_ref_filter (ref -> name , ref -> target , ref -> oid ,
3001
- ref -> flags , ref_cbdata -> filter );
3010
+ item = apply_ref_filter (ref , ref_cbdata -> filter );
3002
3011
if (!item )
3003
3012
return 0 ;
3004
3013
@@ -3585,13 +3594,14 @@ void print_formatted_ref_array(struct ref_array *array, struct ref_format *forma
3585
3594
}
3586
3595
3587
3596
void pretty_print_ref (const char * name , const struct object_id * oid ,
3597
+ const struct object_id * peeled_oid ,
3588
3598
struct ref_format * format )
3589
3599
{
3590
3600
struct ref_array_item * ref_item ;
3591
3601
struct strbuf output = STRBUF_INIT ;
3592
3602
struct strbuf err = STRBUF_INIT ;
3593
3603
3594
- ref_item = new_ref_array_item (name , oid );
3604
+ ref_item = new_ref_array_item (name , oid , peeled_oid );
3595
3605
ref_item -> kind = ref_kind_from_refname (name );
3596
3606
if (format_ref_array_item (ref_item , format , & output , & err ))
3597
3607
die ("%s" , err .buf );
0 commit comments