@@ -314,8 +314,8 @@ static int is_atom(const char *atom, const char *s, int slen)
314314 return alen == slen && !memcmp (atom , s , alen );
315315}
316316
317- static void expand_atom (struct strbuf * sb , const char * atom , int len ,
318- struct expand_data * data )
317+ static int expand_atom (struct strbuf * sb , const char * atom , int len ,
318+ struct expand_data * data )
319319{
320320 if (is_atom ("objectname" , atom , len )) {
321321 if (!data -> mark_query )
@@ -347,7 +347,8 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
347347 strbuf_addstr (sb ,
348348 oid_to_hex (& data -> delta_base_oid ));
349349 } else
350- die ("unknown format element: %.*s" , len , atom );
350+ return 0 ;
351+ return 1 ;
351352}
352353
353354static void expand_format (struct strbuf * sb , const char * start ,
@@ -358,12 +359,11 @@ static void expand_format(struct strbuf *sb, const char *start,
358359
359360 if (skip_prefix (start , "%" , & start ) || * start != '(' )
360361 strbuf_addch (sb , '%' );
361- else if (!(end = strchr (start + 1 , ')' )))
362- die ("format element '%s' does not end in ')'" , start );
363- else {
364- expand_atom (sb , start + 1 , end - start - 1 , data );
362+ else if ((end = strchr (start + 1 , ')' )) &&
363+ expand_atom (sb , start + 1 , end - start - 1 , data ))
365364 start = end + 1 ;
366- }
365+ else
366+ strbuf_expand_bad_format (start , "cat-file" );
367367 }
368368}
369369
0 commit comments