@@ -105,8 +105,6 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
105105 if (!all ) {
106106 if (!prio )
107107 return 0 ;
108- if (!tags && prio < 2 )
109- return 0 ;
110108 }
111109 add_to_known_names (all ? path + 5 : path + 10 , commit , prio , sha1 );
112110 return 0 ;
@@ -193,6 +191,7 @@ static void describe(const char *arg, int last_one)
193191 struct possible_tag all_matches [MAX_TAGS ];
194192 unsigned int match_cnt = 0 , annotated_cnt = 0 , cur_match ;
195193 unsigned long seen_commits = 0 ;
194+ unsigned int unannotated_cnt = 0 ;
196195
197196 if (get_sha1 (arg , sha1 ))
198197 die ("Not a valid object name %s" , arg );
@@ -228,7 +227,9 @@ static void describe(const char *arg, int last_one)
228227 seen_commits ++ ;
229228 n = c -> util ;
230229 if (n ) {
231- if (match_cnt < max_candidates ) {
230+ if (!tags && !all && n -> prio < 2 ) {
231+ unannotated_cnt ++ ;
232+ } else if (match_cnt < max_candidates ) {
232233 struct possible_tag * t = & all_matches [match_cnt ++ ];
233234 t -> name = n ;
234235 t -> depth = seen_commits - 1 ;
@@ -273,7 +274,14 @@ static void describe(const char *arg, int last_one)
273274 printf ("\n" );
274275 return ;
275276 }
276- die ("cannot describe '%s'" , sha1_to_hex (sha1 ));
277+ if (unannotated_cnt )
278+ die ("No annotated tags can describe '%s'.\n"
279+ "However, there were unannotated tags: try --tags." ,
280+ sha1_to_hex (sha1 ));
281+ else
282+ die ("No tags can describe '%s'.\n"
283+ "Try --always, or create some tags." ,
284+ sha1_to_hex (sha1 ));
277285 }
278286
279287 qsort (all_matches , match_cnt , sizeof (all_matches [0 ]), compare_pt );
0 commit comments