@@ -378,8 +378,8 @@ static int alt_odb_usable(struct raw_object_store *o,
378378
379379 /* Detect cases where alternate disappeared */
380380 if (!is_directory (path -> buf )) {
381- error ("object directory %s does not exist; "
382- "check .git/objects/info/alternates" ,
381+ error (_ ( "object directory %s does not exist; "
382+ "check .git/objects/info/alternates" ) ,
383383 path -> buf );
384384 return 0 ;
385385 }
@@ -429,7 +429,7 @@ static int link_alt_odb_entry(struct repository *r, const char *entry,
429429 strbuf_addstr (& pathbuf , entry );
430430
431431 if (strbuf_normalize_path (& pathbuf ) < 0 && relative_base ) {
432- error ("unable to normalize alternate object path: %s" ,
432+ error (_ ( "unable to normalize alternate object path: %s" ) ,
433433 pathbuf .buf );
434434 strbuf_release (& pathbuf );
435435 return -1 ;
@@ -500,14 +500,14 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,
500500 return ;
501501
502502 if (depth > 5 ) {
503- error ("%s: ignoring alternate object stores, nesting too deep." ,
503+ error (_ ( "%s: ignoring alternate object stores, nesting too deep" ) ,
504504 relative_base );
505505 return ;
506506 }
507507
508508 strbuf_add_absolute_path (& objdirbuf , r -> objects -> objectdir );
509509 if (strbuf_normalize_path (& objdirbuf ) < 0 )
510- die ("unable to normalize object directory: %s" ,
510+ die (_ ( "unable to normalize object directory: %s" ) ,
511511 objdirbuf .buf );
512512
513513 while (* alt ) {
@@ -562,7 +562,7 @@ void add_to_alternates_file(const char *reference)
562562 hold_lock_file_for_update (& lock , alts , LOCK_DIE_ON_ERROR );
563563 out = fdopen_lock_file (& lock , "w" );
564564 if (!out )
565- die_errno ("unable to fdopen alternates lockfile" );
565+ die_errno (_ ( "unable to fdopen alternates lockfile" ) );
566566
567567 in = fopen (alts , "r" );
568568 if (in ) {
@@ -580,14 +580,14 @@ void add_to_alternates_file(const char *reference)
580580 fclose (in );
581581 }
582582 else if (errno != ENOENT )
583- die_errno ("unable to read alternates file" );
583+ die_errno (_ ( "unable to read alternates file" ) );
584584
585585 if (found ) {
586586 rollback_lock_file (& lock );
587587 } else {
588588 fprintf_or_die (out , "%s\n" , reference );
589589 if (commit_lock_file (& lock ))
590- die_errno ("unable to move new alternates file into place" );
590+ die_errno (_ ( "unable to move new alternates file into place" ) );
591591 if (the_repository -> objects -> alt_odb_tail )
592592 link_alt_odb_entries (the_repository , reference ,
593593 '\n' , NULL , 0 );
@@ -778,7 +778,7 @@ static void mmap_limit_check(size_t length)
778778 limit = SIZE_MAX ;
779779 }
780780 if (length > limit )
781- die ("attempting to mmap %" PRIuMAX " over limit %" PRIuMAX ,
781+ die (_ ( "attempting to mmap %" PRIuMAX " over limit %" PRIuMAX ) ,
782782 (uintmax_t )length , (uintmax_t )limit );
783783}
784784
@@ -803,7 +803,7 @@ void *xmmap(void *start, size_t length,
803803{
804804 void * ret = xmmap_gently (start , length , prot , flags , fd , offset );
805805 if (ret == MAP_FAILED )
806- die_errno ("mmap failed" );
806+ die_errno (_ ( "mmap failed" ) );
807807 return ret ;
808808}
809809
@@ -970,7 +970,7 @@ static void *map_sha1_file_1(struct repository *r, const char *path,
970970 * size = xsize_t (st .st_size );
971971 if (!* size ) {
972972 /* mmap() is forbidden on empty files */
973- error ("object file %s is empty" , path );
973+ error (_ ( "object file %s is empty" ) , path );
974974 return NULL ;
975975 }
976976 map = xmmap (NULL , * size , PROT_READ , MAP_PRIVATE , fd , 0 );
@@ -1090,9 +1090,9 @@ static void *unpack_sha1_rest(git_zstream *stream, void *buffer, unsigned long s
10901090 }
10911091
10921092 if (status < 0 )
1093- error ("corrupt loose object '%s'" , sha1_to_hex (sha1 ));
1093+ error (_ ( "corrupt loose object '%s'" ) , sha1_to_hex (sha1 ));
10941094 else if (stream -> avail_in )
1095- error ("garbage at end of loose object '%s'" ,
1095+ error (_ ( "garbage at end of loose object '%s'" ) ,
10961096 sha1_to_hex (sha1 ));
10971097 free (buf );
10981098 return NULL ;
@@ -1134,7 +1134,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,
11341134 if ((flags & OBJECT_INFO_ALLOW_UNKNOWN_TYPE ) && (type < 0 ))
11351135 type = 0 ;
11361136 else if (type < 0 )
1137- die ("invalid object type" );
1137+ die (_ ( "invalid object type" ) );
11381138 if (oi -> typep )
11391139 * oi -> typep = type ;
11401140
@@ -1216,19 +1216,19 @@ static int sha1_loose_object_info(struct repository *r,
12161216 * oi -> disk_sizep = mapsize ;
12171217 if ((flags & OBJECT_INFO_ALLOW_UNKNOWN_TYPE )) {
12181218 if (unpack_sha1_header_to_strbuf (& stream , map , mapsize , hdr , sizeof (hdr ), & hdrbuf ) < 0 )
1219- status = error ("unable to unpack %s header with --allow-unknown-type" ,
1219+ status = error (_ ( "unable to unpack %s header with --allow-unknown-type" ) ,
12201220 sha1_to_hex (sha1 ));
12211221 } else if (unpack_sha1_header (& stream , map , mapsize , hdr , sizeof (hdr )) < 0 )
1222- status = error ("unable to unpack %s header" ,
1222+ status = error (_ ( "unable to unpack %s header" ) ,
12231223 sha1_to_hex (sha1 ));
12241224 if (status < 0 )
12251225 ; /* Do nothing */
12261226 else if (hdrbuf .len ) {
12271227 if ((status = parse_sha1_header_extended (hdrbuf .buf , oi , flags )) < 0 )
1228- status = error ("unable to parse %s header with --allow-unknown-type" ,
1228+ status = error (_ ( "unable to parse %s header with --allow-unknown-type" ) ,
12291229 sha1_to_hex (sha1 ));
12301230 } else if ((status = parse_sha1_header_extended (hdr , oi , flags )) < 0 )
1231- status = error ("unable to parse %s header" , sha1_to_hex (sha1 ));
1231+ status = error (_ ( "unable to parse %s header" ) , sha1_to_hex (sha1 ));
12321232
12331233 if (status >= 0 && oi -> contentp ) {
12341234 * oi -> contentp = unpack_sha1_rest (& stream , hdr ,
@@ -1419,19 +1419,19 @@ void *read_object_file_extended(const struct object_id *oid,
14191419 return data ;
14201420
14211421 if (errno && errno != ENOENT )
1422- die_errno ("failed to read object %s" , oid_to_hex (oid ));
1422+ die_errno (_ ( "failed to read object %s" ) , oid_to_hex (oid ));
14231423
14241424 /* die if we replaced an object with one that does not exist */
14251425 if (repl != oid )
1426- die ("replacement %s not found for %s" ,
1426+ die (_ ( "replacement %s not found for %s" ) ,
14271427 oid_to_hex (repl ), oid_to_hex (oid ));
14281428
14291429 if (!stat_sha1_file (the_repository , repl -> hash , & st , & path ))
1430- die ("loose object %s (stored in %s) is corrupt" ,
1430+ die (_ ( "loose object %s (stored in %s) is corrupt" ) ,
14311431 oid_to_hex (repl ), path );
14321432
14331433 if ((p = has_packed_and_bad (repl -> hash )) != NULL )
1434- die ("packed object %s (stored in %s) is corrupt" ,
1434+ die (_ ( "packed object %s (stored in %s) is corrupt" ) ,
14351435 oid_to_hex (repl ), p -> pack_name );
14361436
14371437 return NULL ;
@@ -1533,21 +1533,21 @@ int finalize_object_file(const char *tmpfile, const char *filename)
15331533 unlink_or_warn (tmpfile );
15341534 if (ret ) {
15351535 if (ret != EEXIST ) {
1536- return error_errno ("unable to write sha1 filename %s" , filename );
1536+ return error_errno (_ ( "unable to write sha1 filename %s" ) , filename );
15371537 }
15381538 /* FIXME!!! Collision check here ? */
15391539 }
15401540
15411541out :
15421542 if (adjust_shared_perm (filename ))
1543- return error ("unable to set permission to '%s'" , filename );
1543+ return error (_ ( "unable to set permission to '%s'" ) , filename );
15441544 return 0 ;
15451545}
15461546
15471547static int write_buffer (int fd , const void * buf , size_t len )
15481548{
15491549 if (write_in_full (fd , buf , len ) < 0 )
1550- return error_errno ("file write error" );
1550+ return error_errno (_ ( "file write error" ) );
15511551 return 0 ;
15521552}
15531553
@@ -1566,7 +1566,7 @@ static void close_sha1_file(int fd)
15661566 if (fsync_object_files )
15671567 fsync_or_die (fd , "sha1 file" );
15681568 if (close (fd ) != 0 )
1569- die_errno ("error when closing sha1 file" );
1569+ die_errno (_ ( "error when closing sha1 file" ) );
15701570}
15711571
15721572/* Size of directory component, including the ending '/' */
@@ -1632,9 +1632,9 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
16321632 fd = create_tmpfile (& tmp_file , filename .buf );
16331633 if (fd < 0 ) {
16341634 if (errno == EACCES )
1635- return error ("insufficient permission for adding an object to repository database %s" , get_object_directory ());
1635+ return error (_ ( "insufficient permission for adding an object to repository database %s" ) , get_object_directory ());
16361636 else
1637- return error_errno ("unable to create temporary file" );
1637+ return error_errno (_ ( "unable to create temporary file" ) );
16381638 }
16391639
16401640 /* Set it up */
@@ -1658,21 +1658,21 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
16581658 ret = git_deflate (& stream , Z_FINISH );
16591659 the_hash_algo -> update_fn (& c , in0 , stream .next_in - in0 );
16601660 if (write_buffer (fd , compressed , stream .next_out - compressed ) < 0 )
1661- die ("unable to write sha1 file" );
1661+ die (_ ( "unable to write sha1 file" ) );
16621662 stream .next_out = compressed ;
16631663 stream .avail_out = sizeof (compressed );
16641664 } while (ret == Z_OK );
16651665
16661666 if (ret != Z_STREAM_END )
1667- die ("unable to deflate new object %s (%d)" , oid_to_hex (oid ),
1667+ die (_ ( "unable to deflate new object %s (%d)" ) , oid_to_hex (oid ),
16681668 ret );
16691669 ret = git_deflate_end_gently (& stream );
16701670 if (ret != Z_OK )
1671- die ("deflateEnd on object %s failed (%d)" , oid_to_hex (oid ),
1671+ die (_ ( "deflateEnd on object %s failed (%d)" ) , oid_to_hex (oid ),
16721672 ret );
16731673 the_hash_algo -> final_fn (parano_oid .hash , & c );
16741674 if (oidcmp (oid , & parano_oid ) != 0 )
1675- die ("confused by unstable object source data for %s" ,
1675+ die (_ ( "confused by unstable object source data for %s" ) ,
16761676 oid_to_hex (oid ));
16771677
16781678 close_sha1_file (fd );
@@ -1682,7 +1682,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
16821682 utb .actime = mtime ;
16831683 utb .modtime = mtime ;
16841684 if (utime (tmp_file .buf , & utb ) < 0 )
1685- warning_errno ("failed utime() on %s" , tmp_file .buf );
1685+ warning_errno (_ ( "failed utime() on %s" ) , tmp_file .buf );
16861686 }
16871687
16881688 return finalize_object_file (tmp_file .buf , filename .buf );
@@ -1757,7 +1757,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
17571757 return 0 ;
17581758 buf = read_object (oid -> hash , & type , & len );
17591759 if (!buf )
1760- return error ("cannot read sha1_file for %s" , oid_to_hex (oid ));
1760+ return error (_ ( "cannot read sha1_file for %s" ) , oid_to_hex (oid ));
17611761 hdrlen = xsnprintf (hdr , sizeof (hdr ), "%s %lu" , type_name (type ), len ) + 1 ;
17621762 ret = write_loose_object (oid , hdr , hdrlen , buf , len , mtime );
17631763 free (buf );
@@ -1802,15 +1802,15 @@ static void check_commit(const void *buf, size_t size)
18021802 struct commit c ;
18031803 memset (& c , 0 , sizeof (c ));
18041804 if (parse_commit_buffer (& c , buf , size , 0 ))
1805- die ("corrupt commit" );
1805+ die (_ ( "corrupt commit" ) );
18061806}
18071807
18081808static void check_tag (const void * buf , size_t size )
18091809{
18101810 struct tag t ;
18111811 memset (& t , 0 , sizeof (t ));
18121812 if (parse_tag_buffer (& t , buf , size ))
1813- die ("corrupt tag" );
1813+ die (_ ( "corrupt tag" ) );
18141814}
18151815
18161816static int index_mem (struct object_id * oid , void * buf , size_t size ,
@@ -1903,10 +1903,10 @@ static int index_core(struct object_id *oid, int fd, size_t size,
19031903 char * buf = xmalloc (size );
19041904 ssize_t read_result = read_in_full (fd , buf , size );
19051905 if (read_result < 0 )
1906- ret = error_errno ("read error while indexing %s" ,
1906+ ret = error_errno (_ ( "read error while indexing %s" ) ,
19071907 path ? path : "<unknown>" );
19081908 else if (read_result != size )
1909- ret = error ("short read while indexing %s" ,
1909+ ret = error (_ ( "short read while indexing %s" ) ,
19101910 path ? path : "<unknown>" );
19111911 else
19121912 ret = index_mem (oid , buf , size , type , path , flags );
@@ -1977,7 +1977,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
19771977 if (fd < 0 )
19781978 return error_errno ("open(\"%s\")" , path );
19791979 if (index_fd (oid , fd , st , OBJ_BLOB , path , flags ) < 0 )
1980- return error ("%s: failed to insert into database" ,
1980+ return error (_ ( "%s: failed to insert into database" ) ,
19811981 path );
19821982 break ;
19831983 case S_IFLNK :
@@ -1986,13 +1986,13 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
19861986 if (!(flags & HASH_WRITE_OBJECT ))
19871987 hash_object_file (sb .buf , sb .len , blob_type , oid );
19881988 else if (write_object_file (sb .buf , sb .len , blob_type , oid ))
1989- rc = error ("%s: failed to insert into database" , path );
1989+ rc = error (_ ( "%s: failed to insert into database" ) , path );
19901990 strbuf_release (& sb );
19911991 break ;
19921992 case S_IFDIR :
19931993 return resolve_gitlink_ref (path , "HEAD" , oid );
19941994 default :
1995- return error ("%s: unsupported file type" , path );
1995+ return error (_ ( "%s: unsupported file type" ) , path );
19961996 }
19971997 return rc ;
19981998}
@@ -2016,9 +2016,9 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)
20162016{
20172017 enum object_type type = oid_object_info (the_repository , oid , NULL );
20182018 if (type < 0 )
2019- die ("%s is not a valid object" , oid_to_hex (oid ));
2019+ die (_ ( "%s is not a valid object" ) , oid_to_hex (oid ));
20202020 if (type != expect )
2021- die ("%s is not a valid '%s' object" , oid_to_hex (oid ),
2021+ die (_ ( "%s is not a valid '%s' object" ) , oid_to_hex (oid ),
20222022 type_name (expect ));
20232023}
20242024
@@ -2045,7 +2045,7 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
20452045 dir = opendir (path -> buf );
20462046 if (!dir ) {
20472047 if (errno != ENOENT )
2048- r = error_errno ("unable to open %s" , path -> buf );
2048+ r = error_errno (_ ( "unable to open %s" ) , path -> buf );
20492049 strbuf_setlen (path , origlen );
20502050 return r ;
20512051 }
@@ -2202,18 +2202,18 @@ static int check_stream_sha1(git_zstream *stream,
22022202 git_inflate_end (stream );
22032203
22042204 if (status != Z_STREAM_END ) {
2205- error ("corrupt loose object '%s'" , sha1_to_hex (expected_sha1 ));
2205+ error (_ ( "corrupt loose object '%s'" ) , sha1_to_hex (expected_sha1 ));
22062206 return -1 ;
22072207 }
22082208 if (stream -> avail_in ) {
2209- error ("garbage at end of loose object '%s'" ,
2209+ error (_ ( "garbage at end of loose object '%s'" ) ,
22102210 sha1_to_hex (expected_sha1 ));
22112211 return -1 ;
22122212 }
22132213
22142214 the_hash_algo -> final_fn (real_sha1 , & c );
22152215 if (hashcmp (expected_sha1 , real_sha1 )) {
2216- error ("sha1 mismatch for %s (expected %s)" , path ,
2216+ error (_ ( "sha1 mismatch for %s (expected %s)" ) , path ,
22172217 sha1_to_hex (expected_sha1 ));
22182218 return -1 ;
22192219 }
@@ -2237,18 +2237,18 @@ int read_loose_object(const char *path,
22372237
22382238 map = map_sha1_file_1 (the_repository , path , NULL , & mapsize );
22392239 if (!map ) {
2240- error_errno ("unable to mmap %s" , path );
2240+ error_errno (_ ( "unable to mmap %s" ) , path );
22412241 goto out ;
22422242 }
22432243
22442244 if (unpack_sha1_header (& stream , map , mapsize , hdr , sizeof (hdr )) < 0 ) {
2245- error ("unable to unpack header of %s" , path );
2245+ error (_ ( "unable to unpack header of %s" ) , path );
22462246 goto out ;
22472247 }
22482248
22492249 * type = parse_sha1_header (hdr , size );
22502250 if (* type < 0 ) {
2251- error ("unable to parse header of %s" , path );
2251+ error (_ ( "unable to parse header of %s" ) , path );
22522252 git_inflate_end (& stream );
22532253 goto out ;
22542254 }
@@ -2259,13 +2259,13 @@ int read_loose_object(const char *path,
22592259 } else {
22602260 * contents = unpack_sha1_rest (& stream , hdr , * size , expected_oid -> hash );
22612261 if (!* contents ) {
2262- error ("unable to unpack contents of %s" , path );
2262+ error (_ ( "unable to unpack contents of %s" ) , path );
22632263 git_inflate_end (& stream );
22642264 goto out ;
22652265 }
22662266 if (check_object_signature (expected_oid , * contents ,
22672267 * size , type_name (* type ))) {
2268- error ("sha1 mismatch for %s (expected %s)" , path ,
2268+ error (_ ( "sha1 mismatch for %s (expected %s)" ) , path ,
22692269 oid_to_hex (expected_oid ));
22702270 free (* contents );
22712271 goto out ;
0 commit comments