removal of some c++ keywords
cover removal of some c++ keywords
A while back there was some discussion of getting our codebase into a state where we could use a c++ compiler if we wanted to (for various reason like leveraging c++ only analysis tools, etc.). Johannes Sixt had a very large patch that achieved this but it wasn't in a state where it could be upstreamed. I took that idea and did some removals of c++ keywords (new, template, try, this, etc) but broke it up into several (well maybe more than several) patches. I don't believe I've captured all of them in this series but this is at least moving a step closer to being able to compile using a c++ compiler.
I don't know if this is something the community still wants to move towards, but if this is something people are still interested in, and this series is wanted, then we can keep doing these sort of conversions in chunks slowly.
Brandon Williams (37):
object_info: change member name from 'typename' to 'type_name'
object: rename function 'typename' to 'type_name'
blame: rename 'this' variables
pack-objects: rename 'this' variables
rev-parse: rename 'this' variable
diff: rename 'this' variables
apply: rename 'try' variables
apply: rename 'new' variables
checkout: rename 'new' variables
help: rename 'new' variables
pack-redundant: rename 'new' variables
reflog: rename 'new' variables
remote: rename 'new' variables
combine-diff: rename 'new' variables
commit: rename 'new' variables
diff-lib: rename 'new' variable
diff: rename 'new' variables
diffcore-delta: rename 'new' variables
entry: rename 'new' variables
http: rename 'new' variables
imap-send: rename 'new' variables
line-log: rename 'new' variables
read-cache: rename 'new' variables
ref-filter: rename 'new' variables
remote: rename 'new' variables
split-index: rename 'new' variables
submodule: rename 'new' variables
trailer: rename 'new' variables
unpack-trees: rename 'new' variables
init-db: rename 'template' variables
environment: rename 'template' variables
diff: rename 'template' variables
environment: rename 'namespace' variables
wrapper: rename 'template' variables
tempfile: rename 'template' variables
trailer: rename 'template' variables
replace: rename 'new' variables
apply.c | 106 ++++++++++++------------- blame.c | 33 ++++---- builtin/cat-file.c | 4 +- builtin/checkout.c | 138 ++++++++++++++++----------------- builtin/diff-tree.c | 2 +- builtin/fast-export.c | 8 +- builtin/fsck.c | 4 +- builtin/grep.c | 2 +- builtin/help.c | 10 +-- builtin/index-pack.c | 12 +-- builtin/init-db.c | 30 +++---- builtin/merge.c | 2 +- builtin/mktree.c | 4 +- builtin/pack-objects.c | 8 +- builtin/pack-redundant.c | 48 ++++++------ builtin/prune.c | 2 +- builtin/reflog.c | 8 +- builtin/remote.c | 44 +++++------ builtin/replace.c | 28 +++---- builtin/rev-parse.c | 34 ++++---- builtin/tag.c | 2 +- builtin/unpack-objects.c | 10 +-- builtin/verify-commit.c | 2 +- bulk-checkin.c | 2 +- cache.h | 4 +- combine-diff.c | 12 +-- commit.c | 20 ++--- contrib/examples/builtin-fetch--tool.c | 2 +- diff-lib.c | 20 ++--- diff.c | 38 ++++----- diffcore-delta.c | 16 ++-- entry.c | 40 +++++----- environment.c | 24 +++--- fast-import.c | 16 ++-- fsck.c | 2 +- git-compat-util.h | 4 +- http-push.c | 2 +- http.c | 10 +-- imap-send.c | 14 ++-- line-log.c | 48 ++++++------ log-tree.c | 2 +- object.c | 6 +- object.h | 2 +- pack-check.c | 2 +- packfile.c | 8 +- reachable.c | 2 +- read-cache.c | 36 ++++----- ref-filter.c | 20 ++--- remote.c | 16 ++-- sequencer.c | 2 +- sha1_file.c | 28 +++---- sha1_name.c | 6 +- split-index.c | 10 +-- split-index.h | 2 +- submodule.c | 16 ++-- submodule.h | 2 +- tag.c | 2 +- tempfile.c | 12 +-- tempfile.h | 34 ++++---- trailer.c | 44 +++++------ unpack-trees.c | 6 +- walker.c | 4 +- wrapper.c | 40 +++++----- 63 files changed, 559 insertions(+), 558 deletions(-)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 1/37 object_info: change member name from 'typename' to 'type_name'
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/cat-file.c | 2 +- cache.h | 2 +- packfile.c | 6 +++--- sha1_file.c | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-)
builtin/cat-file.c +1 -1
@@ -76,7 +76,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, buf =NULL ;switch (opt) {case 't' : - oi.typename = &sb; + oi.type_name = &sb;if (sha1_object_info_extended (oid.hash, &oi, flags) <0 )die ("git cat-file: could not get object info" );if (sb.len) {
cache.h +1 -1
@@ -1744,7 +1744,7 @@ struct object_info {unsigned long *sizep;off_t *disk_sizep;unsigned char *delta_base_sha1; -struct strbuf *typename; +struct strbuf *type_name;void **contentp;/* Response */
packfile.c +3 -3
@@ -1350,16 +1350,16 @@ int packed_object_info(struct packed_git *p, off_t obj_offset, *oi->disk_sizep = revidx[1 ].offset - obj_offset; } -if (oi->typep || oi->typename) { +if (oi->typep || oi->type_name) {enum object_type ptot; ptot =packed_to_object_type (p, obj_offset, type, &w_curs, curpos);if (oi->typep) *oi->typep = ptot; -if (oi->typename) { +if (oi->type_name) {const char *tn =typename (ptot);if (tn) -strbuf_addstr (oi->typename, tn); +strbuf_addstr (oi->type_name, tn); }if (ptot <0 ) { type =OBJ_BAD ;
sha1_file.c +5 -5
@@ -1087,8 +1087,8 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi, } type =type_from_string_gently (type_buf, type_len,1 ); -if (oi->typename) -strbuf_add (oi->typename, type_buf, type_len); +if (oi->type_name) +strbuf_add (oi->type_name, type_buf, type_len);/* * Set type to 0 if its an unknown object and * we're obtaining the type using '--allow-unknown-type'
@@ -1158,7 +1158,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,* return value implicitly indicates whether the * object even exists. */ -if (!oi->typep && !oi->typename && !oi->sizep && !oi->contentp) { +if (!oi->typep && !oi->type_name && !oi->sizep && !oi->contentp) {const char *path;struct stat st;if (stat_sha1_file (sha1, &st, &path) <0 )
@@ -1239,8 +1239,8 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi, *(oi->disk_sizep) =0 ;if (oi->delta_base_sha1)hashclr (oi->delta_base_sha1); -if (oi->typename) -strbuf_addstr (oi->typename,typename (co->type)); +if (oi->type_name) +strbuf_addstr (oi->type_name,typename (co->type));if (oi->contentp) *oi->contentp =xmemdupz (co->buf, co->size); oi->whence =OI_CACHED ;
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 2/37 object: rename function 'typename' to 'type_name'
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/cat-file.c | 2 +- builtin/diff-tree.c | 2 +- builtin/fast-export.c | 8 ++++---- builtin/fsck.c | 4 ++-- builtin/grep.c | 2 +- builtin/index-pack.c | 12 ++++++------ builtin/merge.c | 2 +- builtin/mktree.c | 4 ++-- builtin/prune.c | 2 +- builtin/replace.c | 12 ++++++------ builtin/tag.c | 2 +- builtin/unpack-objects.c | 10 +++++----- builtin/verify-commit.c | 2 +- bulk-checkin.c | 2 +- commit.c | 2 +- contrib/examples/builtin-fetch--tool.c | 2 +- fast-import.c | 16 ++++++++-------- fsck.c | 2 +- http-push.c | 2 +- log-tree.c | 2 +- object.c | 6 +++--- object.h | 2 +- pack-check.c | 2 +- packfile.c | 2 +- reachable.c | 2 +- ref-filter.c | 4 ++-- sequencer.c | 2 +- sha1_file.c | 20 ++++++++++---------- sha1_name.c | 6 +++--- submodule.c | 2 +- tag.c | 2 +- walker.c | 4 ++-- 32 files changed, 73 insertions(+), 73 deletions(-)
builtin/cat-file.c +1 -1
@@ -229,7 +229,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,if (data->mark_query) data->info.typep = &data->type;else -strbuf_addstr (sb,typename (data->type)); +strbuf_addstr (sb,type_name (data->type)); }else if (is_atom ("objectsize" , atom, len)) {if (data->mark_query) data->info.sizep = &data->size;
builtin/diff-tree.c +1 -1
@@ -76,7 +76,7 @@ static int diff_tree_stdin(char *line)if (obj->type ==OBJ_TREE )return stdin_diff_trees ((struct tree *)obj, p);error ("Object %s is a %s, not a commit or tree" , -oid_to_hex (&oid),typename (obj->type)); +oid_to_hex (&oid),type_name (obj->type));return -1 ; }
builtin/fast-export.c +4 -4
@@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid) buf =read_sha1_file (oid->hash, &type, &size);if (!buf)die ("Could not read blob %s" ,oid_to_hex (oid)); -if (check_sha1_signature (oid->hash, buf, size,typename (type)) <0 ) +if (check_sha1_signature (oid->hash, buf, size,type_name (type)) <0 )die ("sha1 mismatch in blob %s" ,oid_to_hex (oid)); object =parse_object_buffer (oid, type, size, buf, &eaten); }
@@ -757,7 +757,7 @@ static void handle_tag(const char *name, struct tag *tag)if (tagged->type !=OBJ_COMMIT ) {die ("Tag %s tags unexported %s!" ,oid_to_hex (&tag->object.oid), -typename (tagged->type)); +type_name (tagged->type)); } p = (struct commit *)tagged;for (;;) {
@@ -839,7 +839,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)if (!commit) {warning ("%s: Unexpected object of type %s, skipping." , e->name, -typename (e->item->type)); +type_name (e->item->type));continue ; }
@@ -851,7 +851,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)continue ;default :/* OBJ_TAG (nested tags) is already handled */ warning ("Tag points to object of unexpected type %s, skipping." , -typename (commit->object.type)); +type_name (commit->object.type));continue ; }
builtin/fsck.c +2 -2
@@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)object_as_type (obj, type,0 ); } - ret =typename (obj->type); + ret =type_name (obj->type);if (!ret) ret ="unknown" ;
@@ -137,7 +137,7 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_optprintf ("broken link from %7s %s\n" ,printable_type (parent),describe_object (parent));printf ("broken link from %7s %s\n" , - (type ==OBJ_ANY ?"unknown" :typename (type)),"unknown" ); + (type ==OBJ_ANY ?"unknown" :type_name (type)),"unknown" ); errors_found |=ERROR_REACHABLE ;return 1 ; }
builtin/grep.c +1 -1
@@ -627,7 +627,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,free (data);return hit; } -die (_ ("unable to grep from object of type %s" ),typename (obj->type)); +die (_ ("unable to grep from object of type %s" ),type_name (obj->type)); } static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
builtin/index-pack.c +6 -6
@@ -228,7 +228,7 @@ static unsigned check_object(struct object *obj)if (type != obj->type)die (_ ("object %s: expected type %s, found %s" ),oid_to_hex (&obj->oid), -typename (obj->type),typename (type)); +type_name (obj->type),type_name (type)); obj->flags |=FLAG_CHECKED ;return 1 ; }
@@ -448,7 +448,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,int hdrlen;if (!is_delta_type (type)) { - hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,typename (type), size) +1 ; + hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (type), size) +1 ;git_SHA1_Init (&c);git_SHA1_Update (&c, hdr, hdrlen); }else
@@ -849,7 +849,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, obj =parse_object_buffer (oid, type, size, buf, &eaten);if (!obj) -die (_ ("invalid %s" ),typename (type)); +die (_ ("invalid %s" ),type_name (type));if (do_fsck_object &&fsck_object (obj, buf, size, &fsck_options))die (_ ("Error in object" ));
@@ -959,7 +959,7 @@ static void resolve_delta(struct object_entry *delta_obj,if (!result->data)bad_object (delta_obj->idx.offset,_ ("failed to apply delta" ));hash_sha1_file (result->data, result->size, -typename (delta_obj->real_type), +type_name (delta_obj->real_type), delta_obj->idx.oid.hash);sha1_object (result->data,NULL , result->size, delta_obj->real_type, &delta_obj->idx.oid);
@@ -1379,7 +1379,7 @@ static void fix_unresolved_deltas(struct sha1file *f)continue ;if (check_sha1_signature (d->sha1, base_obj->data, - base_obj->size,typename (type))) + base_obj->size,type_name (type)))die (_ ("local object %s is corrupt" ),sha1_to_hex (d->sha1)); base_obj->obj =append_obj_to_pack (f, d->sha1, base_obj->data, base_obj->size, type);
@@ -1588,7 +1588,7 @@ static void show_pack_info(int stat_only)continue ;printf ("%s %-6s %lu %lu %" PRIuMAX,oid_to_hex (&obj->idx.oid), -typename (obj->real_type), obj->size, +type_name (obj->real_type), obj->size, (unsigned long )(obj[1 ].idx.offset - obj->idx.offset), (uintmax_t )obj->idx.offset);if (is_delta_type (obj->type)) {
builtin/merge.c +1 -1
@@ -520,7 +520,7 @@ static void merge_name(const char *remote, struct strbuf *msg)if (desc && desc->obj && desc->obj->type ==OBJ_TAG ) {strbuf_addf (msg,"%s\t\t%s '%s'\n" ,oid_to_hex (&desc->obj->oid), -typename (desc->obj->type), +type_name (desc->obj->type), remote); goto cleanup; }
builtin/mktree.c +2 -2
@@ -112,7 +112,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss mode_type =object_type (mode);if (mode_type !=type_from_string (ptr)) {die ("entry '%s' object type (%s) doesn't match mode type (%s)" , - path, ptr,typename (mode_type)); + path, ptr,type_name (mode_type)); }/* Check the type of object identified by sha1 */
@@ -131,7 +131,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss* because the new tree entry will never be correct. */ die ("entry '%s' object %s is a %s but specified type was (%s)" , - path,sha1_to_hex (sha1),typename (obj_type),typename (mode_type)); + path,sha1_to_hex (sha1),type_name (obj_type),type_name (mode_type)); } }
builtin/prune.c +1 -1
@@ -52,7 +52,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,if (show_only || verbose) {enum object_type type =sha1_object_info (oid->hash,NULL );printf ("%s %s\n" ,oid_to_hex (oid), - (type >0 ) ?typename (type) :"unknown" ); + (type >0 ) ?type_name (type) :"unknown" ); }if (!show_only)unlink_or_warn (fullpath);
builtin/replace.c +6 -6
@@ -56,8 +56,8 @@ static int show_reference(const char *refname, const struct object_id *oid, obj_type =sha1_object_info (object.hash,NULL ); repl_type =sha1_object_info (oid->hash,NULL ); -printf ("%s (%s) -> %s (%s)\n" , refname,typename (obj_type), -oid_to_hex (oid),typename (repl_type)); +printf ("%s (%s) -> %s (%s)\n" , refname,type_name (obj_type), +oid_to_hex (oid),type_name (repl_type)); } }
@@ -168,8 +168,8 @@ static int replace_object_oid(const char *object_ref,die ("Objects must be of the same type.\n" "'%s' points to a replaced object of type '%s'\n" "while '%s' points to a replacement object of type '%s'." , - object_ref,typename (obj_type), - replace_ref,typename (repl_type)); + object_ref,type_name (obj_type), + replace_ref,type_name (repl_type));check_ref_valid (object, &prev, &ref, force);
@@ -215,7 +215,7 @@ static void export_object(const struct object_id *oid, enum object_type type,argv_array_push (&cmd.args,"--no-replace-objects" );argv_array_push (&cmd.args,"cat-file" );if (raw) -argv_array_push (&cmd.args,typename (type)); +argv_array_push (&cmd.args,type_name (type));else argv_array_push (&cmd.args,"-p" );argv_array_push (&cmd.args,oid_to_hex (oid));
@@ -355,7 +355,7 @@ static void check_one_mergetag(struct commit *commit,struct tag *tag;int i; -hash_sha1_file (extra->value, extra->len,typename (OBJ_TAG ), tag_oid.hash); +hash_sha1_file (extra->value, extra->len,type_name (OBJ_TAG ), tag_oid.hash); tag =lookup_tag (&tag_oid);if (!tag)die (_ ("bad mergetag in commit '%s'" ), ref);
builtin/tag.c +1 -1
@@ -220,7 +220,7 @@ static void create_tag(const struct object_id *object, const char *tag,"tag %s\n" "tagger %s\n\n" ,oid_to_hex (object), -typename (type), +type_name (type), tag, git_committer_info(IDENT_STRICT));
builtin/unpack-objects.c +5 -5
@@ -172,7 +172,7 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf) {struct object_id oid; -if (write_sha1_file (obj_buf->buffer, obj_buf->size,typename (obj->type), oid.hash) <0 ) +if (write_sha1_file (obj_buf->buffer, obj_buf->size,type_name (obj->type), oid.hash) <0 )die ("failed to write object %s" ,oid_to_hex (&obj->oid)); obj->flags |=FLAG_WRITTEN ; }
@@ -237,14 +237,14 @@ static void write_object(unsigned nr, enum object_type type, void *buf, unsigned long size) {if (!strict) { -if (write_sha1_file (buf, size,typename (type), obj_list[nr].oid.hash) <0 ) +if (write_sha1_file (buf, size,type_name (type), obj_list[nr].oid.hash) <0 )die ("failed to write object" );added_object (nr, type, buf, size);free (buf); obj_list[nr].obj =NULL ; }else if (type ==OBJ_BLOB ) {struct blob *blob; -if (write_sha1_file (buf, size,typename (type), obj_list[nr].oid.hash) <0 ) +if (write_sha1_file (buf, size,type_name (type), obj_list[nr].oid.hash) <0 )die ("failed to write object" );added_object (nr, type, buf, size);free (buf);
@@ -258,12 +258,12 @@ static void write_object(unsigned nr, enum object_type type, }else {struct object *obj;int eaten; -hash_sha1_file (buf, size,typename (type), obj_list[nr].oid.hash); +hash_sha1_file (buf, size,type_name (type), obj_list[nr].oid.hash);added_object (nr, type, buf, size); obj =parse_object_buffer (&obj_list[nr].oid, type, size, buf, &eaten);if (!obj) -die ("invalid %s" ,typename (type)); +die ("invalid %s" ,type_name (type));add_object_buffer (obj, buf, size); obj->flags |=FLAG_OPEN ; obj_list[nr].obj = obj;
builtin/verify-commit.c +1 -1
@@ -49,7 +49,7 @@ static int verify_commit(const char *name, unsigned flags)return error ("%s: unable to read file." , name);if (type !=OBJ_COMMIT )return error ("%s: cannot verify a non-commit object of type %s." , - name,typename (type)); + name,type_name (type)); ret =run_gpg_verify (&oid, buf, size, flags);
bulk-checkin.c +1 -1
@@ -203,7 +203,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,return error ("cannot find the current offset" ); header_len =xsnprintf ((char *)obuf,sizeof (obuf),"%s %" PRIuMAX, -typename (type), (uintmax_t )size) +1 ; +type_name (type), (uintmax_t )size) +1 ;git_SHA1_Init (&ctx);git_SHA1_Update (&ctx, obuf, header_len);
commit.c +1 -1
@@ -274,7 +274,7 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep) oid_to_hex(&commit->object.oid));if (type !=OBJ_COMMIT )die ("expected commit for %s, got %s" , -oid_to_hex (&commit->object.oid),typename (type)); +oid_to_hex (&commit->object.oid),type_name (type));if (sizep) *sizep = size; }
contrib/examples/builtin-fetch--tool.c +1 -1
@@ -15,7 +15,7 @@ static char *get_stdin(void)static void show_new (enum object_type type,unsigned char *sha1_new) { -fprintf (stderr," %s: %s\n" ,typename (type), +fprintf (stderr," %s: %s\n" ,type_name (type),find_unique_abbrev (sha1_new,DEFAULT_ABBREV )); }
fast-import.c +8 -8
@@ -1096,7 +1096,7 @@ static int store_object(git_zstream s; hdrlen =xsnprintf ((char *)hdr,sizeof (hdr),"%s %lu" , -typename (type), (unsigned long )dat->len) +1 ; +type_name (type), (unsigned long )dat->len) +1 ;git_SHA1_Init (&c);git_SHA1_Update (&c, hdr, hdrlen);git_SHA1_Update (&c, dat->buf, dat->len);
@@ -2421,7 +2421,7 @@ static void file_change_m(const char *p, struct branch *b)else if (oe) {if (oe->type !=OBJ_COMMIT )die ("Not a commit (actually a %s): %s" , -typename (oe->type), command_buf.buf); +type_name (oe->type), command_buf.buf); }/* * Accept the sha1 without checking; it expected to be in
@@ -2448,7 +2448,7 @@ static void file_change_m(const char *p, struct branch *b) command_buf.buf);if (type != expected)die ("Not a %s (actually a %s): %s" , -typename (expected),typename (type), +type_name (expected),type_name (type), command_buf.buf); }
@@ -2599,14 +2599,14 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa }else if (oe) {if (oe->type !=OBJ_BLOB )die ("Not a blob (actually a %s): %s" , -typename (oe->type), command_buf.buf); +type_name (oe->type), command_buf.buf); }else if (!is_null_oid (&oid)) {enum object_type type =sha1_object_info (oid.hash,NULL );if (type <0 )die ("Blob not found: %s" , command_buf.buf);if (type !=OBJ_BLOB )die ("Not a blob (actually a %s): %s" , -typename (type), command_buf.buf); +type_name (type), command_buf.buf); }construct_path_with_fanout (oid_to_hex (&commit_oid), *old_fanout, path);
@@ -2914,7 +2914,7 @@ static void parse_new_tag(const char *arg)"object %s\n" "type %s\n" "tag %s\n" , - oid_to_hex(&oid), typename(type), t->name); + oid_to_hex(&oid), type_name(type), t->name);if (tagger)strbuf_addf (&new_data,"tagger %s\n" , tagger);
@@ -2985,10 +2985,10 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)die ("Can't read object %s" ,oid_to_hex (oid));if (type !=OBJ_BLOB )die ("Object %s is a %s but a blob was expected." , -oid_to_hex (oid),typename (type)); +oid_to_hex (oid),type_name (type));strbuf_reset (&line);strbuf_addf (&line,"%s %s %lu\n" ,oid_to_hex (oid), -typename (type), size); +type_name (type), size);cat_blob_write (line.buf, line.len);strbuf_release (&line);cat_blob_write (buf, size);
fsck.c +1 -1
@@ -821,7 +821,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data, ret =report (options, &tag->object,FSCK_MSG_TAG_OBJECT_NOT_TAG ,"expected tag got %s" , -typename (type)); +type_name (type)); goto done; } }
http-push.c +1 -1
@@ -362,7 +362,7 @@ static void start_put(struct transfer_request *request)git_zstream stream; unpacked =read_sha1_file (request->obj->oid.hash, &type, &len); - hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,typename (type), len) +1 ; + hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (type), len) +1 ;/* Set it up */ git_deflate_init (&stream, zlib_compression_level);
log-tree.c +1 -1
@@ -499,7 +499,7 @@ static void show_one_mergetag(struct commit *commit,int status, nth;size_t payload_size, gpg_message_offset; -hash_sha1_file (extra->value, extra->len,typename (OBJ_TAG ), oid.hash); +hash_sha1_file (extra->value, extra->len,type_name (OBJ_TAG ), oid.hash); tag =lookup_tag (&oid);if (!tag)return ;/* error message already given */
object.c +3 -3
@@ -26,7 +26,7 @@ static const char *object_type_strings[] = { "tag", /* OBJ_TAG = 4 */ }; -const char *typename (unsigned int type) +const char *type_name (unsigned int type) {if (type >=ARRAY_SIZE (object_type_strings))return NULL ;
@@ -166,7 +166,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)if (!quiet)error ("object %s is a %s, not a %s" ,oid_to_hex (&obj->oid), -typename (obj->type),typename (type)); +type_name (obj->type),type_name (type));return NULL ; } }
@@ -265,7 +265,7 @@ struct object *parse_object(const struct object_id *oid) buffer =read_sha1_file (oid->hash, &type, &size);if (buffer) { -if (check_sha1_signature (repl, buffer, size,typename (type)) <0 ) { +if (check_sha1_signature (repl, buffer, size,type_name (type)) <0 ) {free (buffer);error ("sha1 mismatch %s" ,sha1_to_hex (repl));return NULL ;
object.h +1 -1
@@ -53,7 +53,7 @@ struct object {struct object_id oid; }; -extern const char *typename (unsigned int type); +extern const char *type_name (unsigned int type);extern int type_from_string_gently (const char *str,ssize_t ,int gentle);#define type_from_string (str) type_from_string_gently(str, -1, 0)
pack-check.c +1 -1
@@ -141,7 +141,7 @@ static int verify_packfile(struct packed_git *p, err =error ("cannot unpack %s from %s at offset %" PRIuMAX"" ,oid_to_hex (entries[i].oid.oid), p->pack_name, (uintmax_t )entries[i].offset); - else if (check_sha1_signature(entries[i].oid.hash, data, size, typename(type))) + else if (check_sha1_signature(entries[i].oid.hash, data, size, type_name(type))) err =error ("packed %s from %s is corrupt" ,oid_to_hex (entries[i].oid.oid), p->pack_name); else if (fn) {
packfile.c +1 -1
@@ -1357,7 +1357,7 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,if (oi->typep) *oi->typep = ptot;if (oi->type_name) { -const char *tn =typename (ptot); +const char *tn =type_name (ptot);if (tn)strbuf_addstr (oi->type_name, tn); }
reachable.c +1 -1
@@ -94,7 +94,7 @@ static void add_recent_object(const struct object_id *oid,break ;default :die ("unknown object type for %s: %s" , -oid_to_hex (oid),typename (type)); +oid_to_hex (oid),type_name (type)); }if (!obj)
ref-filter.c +2 -2
@@ -769,7 +769,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct objectif (deref) name++;if (!strcmp (name,"objecttype" )) - v->s =typename (obj->type); + v->s =type_name (obj->type);else if (!strcmp (name,"objectsize" )) { v->value = sz; v->s =xstrfmt ("%lu" , sz);
@@ -795,7 +795,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *obif (!strcmp (name,"tag" )) v->s = tag->tag;else if (!strcmp (name,"type" ) && tag->tagged) - v->s =typename (tag->tagged->type); + v->s =type_name (tag->tagged->type);else if (!strcmp (name,"object" ) && tag->tagged) v->s =xstrdup (oid_to_hex (&tag->tagged->oid)); }
sequencer.c +1 -1
@@ -2348,7 +2348,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)if (!lookup_commit_reference_gently (&oid,1 )) {enum object_type type =sha1_object_info (oid.hash,NULL );return error (_ ("%s: can't cherry-pick a %s" ), - name,typename (type)); + name,type_name (type)); } }else return error (_ ("%s: bad revision" ), name);
sha1_file.c +10 -10
@@ -805,7 +805,7 @@ int check_sha1_signature(const unsigned char *sha1, void *map,return -1 ;/* Generate the header */ - hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,typename (obj_type), size) +1 ; + hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (obj_type), size) +1 ;/* Sha1.. */ git_SHA1_Init (&c);
@@ -1240,7 +1240,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,if (oi->delta_base_sha1)hashclr (oi->delta_base_sha1);if (oi->type_name) -strbuf_addstr (oi->type_name,typename (co->type)); +strbuf_addstr (oi->type_name,type_name (co->type));if (oi->contentp) *oi->contentp =xmemdupz (co->buf, co->size); oi->whence =OI_CACHED ;
@@ -1317,7 +1317,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type, {struct cached_object *co; -hash_sha1_file (buf, len,typename (type), sha1); +hash_sha1_file (buf, len,type_name (type), sha1);if (has_sha1_file (sha1) ||find_cached_object (sha1))return 0 ;ALLOC_GROW (cached_objects, cached_object_nr +1 , cached_object_alloc);
@@ -1683,7 +1683,7 @@ int force_object_loose(const unsigned char *sha1, time_t mtime) buf =read_object (sha1, &type, &len);if (!buf)return error ("cannot read sha1_file for %s" ,sha1_to_hex (sha1)); - hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,typename (type), len) +1 ; + hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (type), len) +1 ; ret =write_loose_object (sha1, hdr, hdrlen, buf, len, mtime);free (buf);
@@ -1767,9 +1767,9 @@ static int index_mem(struct object_id *oid, void *buf, size_t size, }if (write_object) - ret =write_sha1_file (buf, size,typename (type), oid->hash); + ret =write_sha1_file (buf, size,type_name (type), oid->hash);else - ret =hash_sha1_file (buf, size,typename (type), oid->hash); + ret =hash_sha1_file (buf, size,type_name (type), oid->hash);if (re_allocated)free (buf);return ret;
@@ -1789,10 +1789,10 @@ static int index_stream_convert_blob(struct object_id *oid, int fd, get_safe_crlf(flags));if (write_object) - ret =write_sha1_file (sbuf.buf, sbuf.len,typename (OBJ_BLOB ), + ret =write_sha1_file (sbuf.buf, sbuf.len,type_name (OBJ_BLOB ), oid->hash);else - ret =hash_sha1_file (sbuf.buf, sbuf.len,typename (OBJ_BLOB ), + ret =hash_sha1_file (sbuf.buf, sbuf.len,type_name (OBJ_BLOB ), oid->hash);strbuf_release (&sbuf);return ret;
@@ -1942,7 +1942,7 @@ void assert_sha1_type(const unsigned char *sha1, enum object_type expect)die ("%s is not a valid object" ,sha1_to_hex (sha1));if (type != expect)die ("%s is not a valid '%s' object" ,sha1_to_hex (sha1), -typename (expect)); +type_name (expect)); } int for_each_file_in_obj_subdir(unsigned int subdir_nr,
@@ -2187,7 +2187,7 @@ int read_loose_object(const char *path, goto out; }if (check_sha1_signature (expected_sha1, *contents, - *size,typename (*type))) { + *size,type_name (*type))) {error ("sha1 mismatch for %s (expected %s)" , path,sha1_to_hex (expected_sha1));free (*contents);
sha1_name.c +3 -3
@@ -381,7 +381,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)advise (" %s %s%s" ,find_unique_abbrev (oid->hash,DEFAULT_ABBREV ), -typename (type) ?typename (type) :"unknown type" , +type_name (type) ?type_name (type) :"unknown type" , desc.buf);strbuf_release (&desc);
@@ -901,8 +901,8 @@ struct object *peel_to_type(const char *name, int namelen,if (name)error ("%.*s: expected %s type, but the object " "dereferences to %s type" , - namelen, name,typename (expected_type), -typename (o->type)); + namelen, name,type_name (expected_type), +type_name (o->type));return NULL ; } }
submodule.c +1 -1
@@ -831,7 +831,7 @@ static int check_has_commit(const struct object_id *oid, void *data)return 0 ;default :die (_ ("submodule entry '%s' (%s) is a %s, not a commit" ), - cb->path,oid_to_hex (oid),typename (type)); + cb->path,oid_to_hex (oid),type_name (type)); } }
tag.c +1 -1
@@ -47,7 +47,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report, name_to_report ? name_to_report :find_unique_abbrev (oid->hash,DEFAULT_ABBREV ), - typename(type)); + type_name(type)); buf =read_sha1_file (oid->hash, &type, &size);if (!buf)
walker.c +2 -2
@@ -22,7 +22,7 @@ void walker_say(struct walker *walker, const char *fmt, ...)static void report_missing (const struct object *obj) {fprintf (stderr,"Cannot obtain needed %s %s\n" , - obj->type ?typename (obj->type):"object" , + obj->type ?type_name (obj->type):"object" ,oid_to_hex (&obj->oid));if (!is_null_oid (¤t_commit_oid)) fprintf(stderr, "while processing commit %s.\n",
@@ -134,7 +134,7 @@ static int process_object(struct walker *walker, struct object *obj) }return error ("Unable to determine requirements " "of type %s for %s" , -typename (obj->type),oid_to_hex (&obj->oid)); +type_name (obj->type),oid_to_hex (&obj->oid)); }static int process (struct walker *walker,struct object *obj)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 3/37 blame: rename 'this' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- blame.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
blame.c +17 -16
@@ -998,28 +998,29 @@ unsigned blame_entry_score(struct blame_scoreboard *sb, struct blame_entry *e) }/* -* best_so_far[] and this[] are both a split of an existing blame_entry -* that passes blame to the parent. Maintain best_so_far the best split -* so far, by comparing this and best_so_far and copying this into +* best_so_far[] and potential[] are both a split of an existing blame_entry +* that passes blame to the parent. Maintain best_so_far the best split so +* far, by comparing potential and best_so_far and copying potential into * bst_so_far as needed. */ static void copy_split_if_better (struct blame_scoreboard *sb,struct blame_entry *best_so_far, -struct blame_entry *this) +struct blame_entry *potential) {int i; -if (!this[1 ].suspect) +if (!potential[1 ].suspect)return ;if (best_so_far[1 ].suspect) { -if (blame_entry_score (sb, &this[1 ]) <blame_entry_score (sb, &best_so_far[1 ])) +if (blame_entry_score (sb, &potential[1 ]) < +blame_entry_score (sb, &best_so_far[1 ]))return ; }for (i =0 ; i <3 ; i++) -blame_origin_incref (this[i].suspect); +blame_origin_incref (potential[i].suspect);decref_split (best_so_far); -memcpy (best_so_far, this,sizeof (struct blame_entry [3 ])); +memcpy (best_so_far, potential,sizeof (struct blame_entry [3 ])); }/*
@@ -1046,12 +1047,12 @@ static void handle_split(struct blame_scoreboard *sb,if (ent->num_lines <= tlno)return ;if (tlno < same) { -struct blame_entry this[3 ]; +struct blame_entry potential[3 ]; tlno += ent->s_lno; same += ent->s_lno; -split_overlap (this, ent, tlno, plno, same, parent); -copy_split_if_better (sb, split, this); -decref_split (this); +split_overlap (potential, ent, tlno, plno, same, parent); +copy_split_if_better (sb, split, potential); +decref_split (potential); } }
@@ -1273,7 +1274,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,struct diff_filepair *p = diff_queued_diff.queue[i];struct blame_origin *norigin;mmfile_t file_p; -struct blame_entry this[3 ]; +struct blame_entry potential[3 ];if (!DIFF_FILE_VALID (p->one))continue ;/* does not exist in parent */
@@ -1292,10 +1293,10 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,for (j =0 ; j < num_ents; j++) {find_copy_in_blob (sb, blame_list[j].ent, - norigin, this, &file_p); + norigin, potential, &file_p);copy_split_if_better (sb, blame_list[j].split, - this); -decref_split (this); + potential); +decref_split (potential); }blame_origin_decref (norigin); }
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 4/37 pack-objects: rename 'this' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/pack-objects.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
builtin/pack-objects.c +4 -4
@@ -1376,10 +1376,10 @@ static void cleanup_preferred_base(void) it = pbase_tree; pbase_tree =NULL ;while (it) { -struct pbase_tree *this = it; - it = this->next; -free (this->pcache.tree_data); -free (this); +struct pbase_tree *tmp = it; + it = tmp->next; +free (tmp->pcache.tree_data); +free (tmp); }for (i =0 ; i <ARRAY_SIZE (pbase_tree_cache); i++) {
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 5/37 rev-parse: rename 'this' variable
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/rev-parse.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
builtin/rev-parse.c +17 -17
@@ -243,28 +243,28 @@ static int show_file(const char *arg, int output_prefix)static int try_difference (const char *arg) {char *dotdot; -struct object_id oid; -struct object_id end; -const char *next; -const char *this; +struct object_id start_oid; +struct object_id end_oid; +const char *end; +const char *start;int symmetric;static const char head_by_default[] ="HEAD" ;if (!(dotdot =strstr (arg,".." )))return 0 ; - next = dotdot +2 ; - this = arg; - symmetric = (*next =='.' ); + end = dotdot +2 ; + start = arg; + symmetric = (*end =='.' ); *dotdot =0 ; - next += symmetric; + end += symmetric; -if (!*next) - next = head_by_default; +if (!*end) + end = head_by_default;if (dotdot == arg) - this = head_by_default; + start = head_by_default; -if (this == head_by_default && next == head_by_default && +if (start == head_by_default && end == head_by_default && !symmetric) {/* * Just ".."? That is not a range but the
@@ -274,14 +274,14 @@ static int try_difference(const char *arg)return 0 ; } -if (!get_oid_committish (this, &oid) && !get_oid_committish (next, &end)) { -show_rev (NORMAL , &end, next); -show_rev (symmetric ?NORMAL :REVERSED , &oid, this); +if (!get_oid_committish (start, &start_oid) && !get_oid_committish (end, &end_oid)) { +show_rev (NORMAL , &end_oid, end); +show_rev (symmetric ?NORMAL :REVERSED , &start_oid, start);if (symmetric) {struct commit_list *exclude;struct commit *a, *b; - a =lookup_commit_reference (&oid); - b =lookup_commit_reference (&end); + a =lookup_commit_reference (&start_oid); + b =lookup_commit_reference (&end_oid); exclude =get_merge_bases (a, b);while (exclude) {struct commit *commit =pop_commit (&exclude);
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 6/37 diff: rename 'this' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff.c +4 -4
@@ -2601,7 +2601,7 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,while (dir->nr) {struct dirstat_file *f = dir->files;int namelen =strlen (f->name); -unsigned long this; +unsigned long sum;char *slash;if (namelen < baselen)
@@ -2611,15 +2611,15 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir, slash =strchr (f->name + baselen,'/' );if (slash) {int newbaselen = slash +1 - f->name; - this =gather_dirstat (opt, dir, changed, f->name, newbaselen); + sum =gather_dirstat (opt, dir, changed, f->name, newbaselen); sources++; }else { - this = f->changed; + sum = f->changed; dir->files++; dir->nr--; sources +=2 ; } - this_dir += this; + this_dir += sum; }/*
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 7/37 apply: rename 'try' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- apply.c | 68 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 34 insertions(+), 34 deletions(-)
apply.c +34 -34
@@ -2386,8 +2386,8 @@ static void update_pre_post_images(struct image *preimage,static int line_by_line_fuzzy_match (struct image *img,struct image *preimage,struct image *postimage, -unsigned long try, -int try_lno, +unsigned long current, +int current_lno,int preimage_limit) {int i;
@@ -2404,9 +2404,9 @@ static int line_by_line_fuzzy_match(struct image *img,for (i =0 ; i < preimage_limit; i++) {size_t prelen = preimage->line[i].len; -size_t imglen = img->line[try_lno+i].len; +size_t imglen = img->line[current_lno+i].len; -if (!fuzzy_matchlines (img->buf + try + imgoff, imglen, +if (!fuzzy_matchlines (img->buf + current + imgoff, imglen, preimage->buf + preoff, prelen))return 0 ;if (preimage->line[i].flag &LINE_COMMON )
@@ -2443,7 +2443,7 @@ static int line_by_line_fuzzy_match(struct image *img,*/ extra_chars = preimage_end - preimage_eof;strbuf_init (&fixed, imgoff + extra_chars); -strbuf_add (&fixed, img->buf + try, imgoff); +strbuf_add (&fixed, img->buf + current, imgoff);strbuf_add (&fixed, preimage_eof, extra_chars); fixed_buf =strbuf_detach (&fixed, &fixed_len); update_pre_post_images(preimage, postimage,
@@ -2455,8 +2455,8 @@ static int match_fragment(struct apply_state *state,struct image *img, struct image *preimage, struct image *postimage, - unsigned long try, - int try_lno, + unsigned long current, + int current_lno, unsigned ws_rule, int match_beginning, int match_end) {
@@ -2466,12 +2466,12 @@ static int match_fragment(struct apply_state *state,size_t fixed_len, postlen;int preimage_limit; -if (preimage->nr + try_lno <= img->nr) { +if (preimage->nr + current_lno <= img->nr) {/* * The hunk falls within the boundaries of img. */ preimage_limit = preimage->nr; -if (match_end && (preimage->nr + try_lno != img->nr)) +if (match_end && (preimage->nr + current_lno != img->nr))return 0 ; }else if (state->ws_error_action == correct_ws_error && (ws_rule &WS_BLANK_AT_EOF )) {
@@ -2482,7 +2482,7 @@ static int match_fragment(struct apply_state *state,* match with img, and the remainder of the preimage * must be blank. */ - preimage_limit = img->nr - try_lno; + preimage_limit = img->nr - current_lno; }else {/* * The hunk extends beyond the end of the img and
@@ -2492,27 +2492,27 @@ static int match_fragment(struct apply_state *state,return 0 ; } -if (match_beginning && try_lno) +if (match_beginning && current_lno)return 0 ;/* Quick hash check */ for (i =0 ; i < preimage_limit; i++) -if ((img->line[try_lno + i].flag &LINE_PATCHED ) || - (preimage->line[i].hash != img->line[try_lno + i].hash)) +if ((img->line[current_lno + i].flag &LINE_PATCHED ) || + (preimage->line[i].hash != img->line[current_lno + i].hash))return 0 ;if (preimage_limit == preimage->nr) {/* * Do we have an exact match? If we were told to match -* at the end, size must be exactly at try+fragsize, -* otherwise try+fragsize must be still within the preimage, +* at the end, size must be exactly at current+fragsize, +* otherwise current+fragsize must be still within the preimage, * and either case, the old piece should match the preimage * exactly. */ if ((match_end - ? (try + preimage->len == img->len) - : (try + preimage->len <= img->len)) && - !memcmp (img->buf + try, preimage->buf, preimage->len)) + ? (current + preimage->len == img->len) + : (current + preimage->len <= img->len)) && + !memcmp (img->buf + current, preimage->buf, preimage->len))return 1 ; }else {/*
@@ -2543,7 +2543,7 @@ static int match_fragment(struct apply_state *state,*/ if (state->ws_ignore_action == ignore_ws_change)return line_by_line_fuzzy_match (img, preimage, postimage, - try, try_lno, preimage_limit); + current, current_lno, preimage_limit);if (state->ws_error_action != correct_ws_error)return 0 ;
@@ -2577,10 +2577,10 @@ static int match_fragment(struct apply_state *state,*/ strbuf_init (&fixed, preimage->len +1 ); orig = preimage->buf; - target = img->buf + try; + target = img->buf + current;for (i =0 ; i < preimage_limit; i++) {size_t oldlen = preimage->line[i].len; -size_t tgtlen = img->line[try_lno + i].len; +size_t tgtlen = img->line[current_lno + i].len;size_t fixstart = fixed.len;struct strbuf tgtfix;int match;
@@ -2666,8 +2666,8 @@ static int find_pos(struct apply_state *state, int match_beginning, int match_end) {int i; -unsigned long backwards, forwards, try; -int backwards_lno, forwards_lno, try_lno; +unsigned long backwards, forwards, current; +int backwards_lno, forwards_lno, current_lno;/* * If match_beginning or match_end is specified, there is no
@@ -2687,25 +2687,25 @@ static int find_pos(struct apply_state *state,if ((size_t ) line > img->nr) line = img->nr; - try =0 ; + current =0 ;for (i =0 ; i < line; i++) - try += img->line[i].len; + current += img->line[i].len;/* * There's probably some smart way to do this, but I'll leave * that to the smart and beautiful people. I'm simple and stupid. */ - backwards = try; + backwards = current; backwards_lno = line; - forwards = try; + forwards = current; forwards_lno = line; - try_lno = line; + current_lno = line;for (i =0 ; ; i++) {if (match_fragment (state, img, preimage, postimage, - try, try_lno, ws_rule, + current, current_lno, ws_rule, match_beginning, match_end)) -return try_lno; +return current_lno; again:if (backwards_lno ==0 && forwards_lno == img->nr)
@@ -2718,8 +2718,8 @@ static int find_pos(struct apply_state *state, } backwards_lno--; backwards -= img->line[backwards_lno].len; - try = backwards; - try_lno = backwards_lno; + current = backwards; + current_lno = backwards_lno; }else {if (forwards_lno == img->nr) { i++;
@@ -2727,8 +2727,8 @@ static int find_pos(struct apply_state *state, } forwards += img->line[forwards_lno].len; forwards_lno++; - try = forwards; - try_lno = forwards_lno; + current = forwards; + current_lno = forwards_lno; } }
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 8/37 apply: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- apply.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
apply.c +19 -19
@@ -2301,7 +2301,7 @@ static void update_pre_post_images(struct image *preimage, size_t len, size_t postlen) {int i, ctx, reduced; -char *new, *old, *fixed; +char *new_buf, *old, *fixed;struct image fixed_preimage;/*
@@ -2329,18 +2329,18 @@ static void update_pre_post_images(struct image *preimage,*/ old = postimage->buf;if (postlen) - new = postimage->buf =xmalloc (postlen); + new_buf = postimage->buf =xmalloc (postlen);else - new = old; + new_buf = old; fixed = preimage->buf;for (i = reduced = ctx =0 ; i < postimage->nr; i++) {size_t l_len = postimage->line[i].len;if (!(postimage->line[i].flag &LINE_COMMON )) {/* an added line -- no counterparts in preimage */ -memmove (new, old, l_len); +memmove (new_buf, old, l_len); old += l_len; - new += l_len; + new_buf += l_len;continue ; }
@@ -2365,21 +2365,21 @@ static void update_pre_post_images(struct image *preimage,/* and copy it in, while fixing the line length */ l_len = preimage->line[ctx].len; -memcpy (new, fixed, l_len); - new += l_len; +memcpy (new_buf, fixed, l_len); + new_buf += l_len; fixed += l_len; postimage->line[i].len = l_len; ctx++; }if (postlen - ? postlen < new - postimage->buf - : postimage->len < new - postimage->buf) + ? postlen < new_buf - postimage->buf + : postimage->len < new_buf - postimage->buf)die ("BUG: caller miscounted postlen: asked %d, orig = %d, used = %d" , - (int )postlen, (int ) postimage->len, (int )(new - postimage->buf)); + (int )postlen, (int ) postimage->len, (int )(new_buf - postimage->buf));/* Fix the length of the whole thing */ - postimage->len = new - postimage->buf; + postimage->len = new_buf - postimage->buf; postimage->nr -= reduced; }
@@ -4163,30 +4163,30 @@ static void show_mode_change(struct patch *p, int show_name)static void show_rename_copy (struct patch *p) {const char *renamecopy = p->is_rename ?"rename" :"copy" ; -const char *old, *new; +const char *old, *new_name;/* Find common prefix */ old = p->old_name; - new = p->new_name; + new_name = p->new_name;while (1 ) {const char *slash_old, *slash_new; slash_old =strchr (old,'/' ); - slash_new =strchr (new,'/' ); + slash_new =strchr (new_name,'/' );if (!slash_old || !slash_new || - slash_old - old != slash_new - new || -memcmp (old, new, slash_new - new)) + slash_old - old != slash_new - new_name || +memcmp (old, new_name, slash_new - new_name))break ; old = slash_old +1 ; - new = slash_new +1 ; + new_name = slash_new +1 ; } -/* p->old_name thru old is the common prefix, and old and new +/* p->old_name thru old is the common prefix, and old and new_name * through the end of names are renames */ if (old != p->old_name)printf (" %s %.*s{%s => %s} (%d%%)\n" , renamecopy, (int )(old - p->old_name), p->old_name, - old, new, p->score); + old, new_name, p->score);else printf (" %s %s => %s (%d%%)\n" , renamecopy, p->old_name, p->new_name, p->score);
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 9/37 checkout: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/checkout.c | 138 ++++++++++++++++++++++++++--------------------------- 1 file changed, 69 insertions(+), 69 deletions(-)
builtin/checkout.c +69 -69
@@ -54,14 +54,14 @@ struct checkout_opts {struct tree *source_tree; }; -static int post_checkout_hook (struct commit *old,struct commit *new, +static int post_checkout_hook (struct commit *old,struct commit *new_commit,int changed) {return run_hook_le (NULL ,"post-checkout" ,oid_to_hex (old ? &old->object.oid : &null_oid), -oid_to_hex (new ? &new->object.oid : &null_oid), +oid_to_hex (new_commit ? &new_commit->object.oid : &null_oid), changed ?"1" :"0" ,NULL ); -/* "new" can be NULL when checking out from the index before +/* "new_commit" can be NULL when checking out from the index before a commit exists. */ }
@@ -473,7 +473,7 @@ static void setup_branch_path(struct branch_info *branch)static int merge_working_tree (const struct checkout_opts *opts,struct branch_info *old, -struct branch_info *new, +struct branch_info *new_branch_info,int *writeout_error) {int ret;
@@ -485,7 +485,7 @@ static int merge_working_tree(const struct checkout_opts *opts,resolve_undo_clear ();if (opts->force) { - ret =reset_tree (new->commit->tree, opts,1 , writeout_error); + ret =reset_tree (new_branch_info->commit->tree, opts,1 , writeout_error);if (ret)return ret; }else {
@@ -523,7 +523,7 @@ static int merge_working_tree(const struct checkout_opts *opts, &old->commit->object.oid : the_hash_algo->empty_tree);init_tree_desc (&trees[0 ], tree->buffer, tree->size); - tree =parse_tree_indirect (&new->commit->object.oid); + tree =parse_tree_indirect (&new_branch_info->commit->object.oid);init_tree_desc (&trees[1 ], tree->buffer, tree->size); ret =unpack_trees (2 , trees, &topts);
@@ -571,18 +571,18 @@ static int merge_working_tree(const struct checkout_opts *opts, o.verbosity =0 ; work =write_tree_from_memory (&o); - ret =reset_tree (new->commit->tree, opts,1 , + ret =reset_tree (new_branch_info->commit->tree, opts,1 , writeout_error);if (ret)return ret; o.ancestor = old->name; - o.branch1 = new->name; + o.branch1 = new_branch_info->name; o.branch2 ="local" ; - ret =merge_trees (&o, new->commit->tree, work, + ret =merge_trees (&o, new_branch_info->commit->tree, work, old->commit->tree, &result);if (ret <0 )exit (128 ); - ret =reset_tree (new->commit->tree, opts,0 , + ret =reset_tree (new_branch_info->commit->tree, opts,0 , writeout_error);strbuf_release (&o.obuf);if (ret)
@@ -600,15 +600,15 @@ static int merge_working_tree(const struct checkout_opts *opts,die (_ ("unable to write new index file" ));if (!opts->force && !opts->quiet) -show_local_changes (&new->commit->object, &opts->diff_options); +show_local_changes (&new_branch_info->commit->object, &opts->diff_options);return 0 ; } -static void report_tracking (struct branch_info *new) +static void report_tracking (struct branch_info *new_branch_info) {struct strbuf sb =STRBUF_INIT ; -struct branch *branch =branch_get (new->name); +struct branch *branch =branch_get (new_branch_info->name);if (!format_tracking_info (branch, &sb))return ;
@@ -618,7 +618,7 @@ static void report_tracking(struct branch_info *new)static void update_refs_for_switch (const struct checkout_opts *opts,struct branch_info *old, -struct branch_info *new) +struct branch_info *new_branch_info) {struct strbuf msg =STRBUF_INIT ;const char *old_desc, *reflog_msg;
@@ -645,14 +645,14 @@ static void update_refs_for_switch(const struct checkout_opts *opts,free (refname); }else -create_branch (opts->new_branch, new->name, +create_branch (opts->new_branch, new_branch_info->name, opts->new_branch_force ?1 :0 , opts->new_branch_force ?1 :0 , opts->new_branch_log, opts->quiet, opts->track); - new->name = opts->new_branch; -setup_branch_path (new); + new_branch_info->name = opts->new_branch; +setup_branch_path (new_branch_info); } old_desc = old->name;
@@ -662,40 +662,40 @@ static void update_refs_for_switch(const struct checkout_opts *opts, reflog_msg =getenv ("GIT_REFLOG_ACTION" );if (!reflog_msg)strbuf_addf (&msg,"checkout: moving from %s to %s" , - old_desc ? old_desc :"(invalid)" , new->name); + old_desc ? old_desc :"(invalid)" , new_branch_info->name);else strbuf_insert (&msg,0 , reflog_msg,strlen (reflog_msg)); -if (!strcmp (new->name,"HEAD" ) && !new->path && !opts->force_detach) { +if (!strcmp (new_branch_info->name,"HEAD" ) && !new_branch_info->path && !opts->force_detach) {/* Nothing to do. */ - }else if (opts->force_detach || !new->path) {/* No longer on any branch. */ -update_ref (msg.buf,"HEAD" , &new->commit->object.oid,NULL , + }else if (opts->force_detach || !new_branch_info->path) {/* No longer on any branch. */ +update_ref (msg.buf,"HEAD" , &new_branch_info->commit->object.oid,NULL ,REF_NO_DEREF ,UPDATE_REFS_DIE_ON_ERR );if (!opts->quiet) {if (old->path && advice_detached_head && !opts->force_detach) -detach_advice (new->name); -describe_detached_head (_ ("HEAD is now at" ), new->commit); +detach_advice (new_branch_info->name); +describe_detached_head (_ ("HEAD is now at" ), new_branch_info->commit); } - }else if (new->path) {/* Switch branches. */ -if (create_symref ("HEAD" , new->path, msg.buf) <0 ) + }else if (new_branch_info->path) {/* Switch branches. */ +if (create_symref ("HEAD" , new_branch_info->path, msg.buf) <0 )die (_ ("unable to update HEAD" ));if (!opts->quiet) { -if (old->path && !strcmp (new->path, old->path)) { +if (old->path && !strcmp (new_branch_info->path, old->path)) {if (opts->new_branch_force)fprintf (stderr,_ ("Reset branch '%s'\n" ), - new->name); + new_branch_info->name);else fprintf (stderr,_ ("Already on '%s'\n" ), - new->name); + new_branch_info->name); }else if (opts->new_branch) {if (opts->branch_exists) -fprintf (stderr,_ ("Switched to and reset branch '%s'\n" ), new->name); +fprintf (stderr,_ ("Switched to and reset branch '%s'\n" ), new_branch_info->name);else -fprintf (stderr,_ ("Switched to a new branch '%s'\n" ), new->name); +fprintf (stderr,_ ("Switched to a new branch '%s'\n" ), new_branch_info->name); }else {fprintf (stderr,_ ("Switched to branch '%s'\n" ), - new->name); + new_branch_info->name); } }if (old->path && old->name) {
@@ -706,8 +706,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,remove_branch_state ();strbuf_release (&msg);if (!opts->quiet && - (new->path || (!opts->force_detach && !strcmp (new->name,"HEAD" )))) -report_tracking (new); + (new_branch_info->path || (!opts->force_detach && !strcmp (new_branch_info->name,"HEAD" )))) +report_tracking (new_branch_info); } static int add_pending_uninteresting_ref(const char *refname,
@@ -787,7 +787,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)* HEAD. If it is not reachable from any ref, this is the last chance * for the user to do so without resorting to reflog. */ -static void orphaned_commit_warning (struct commit *old,struct commit *new) +static void orphaned_commit_warning (struct commit *old,struct commit *new_commit) {struct rev_info revs;struct object *object = &old->object;
@@ -799,7 +799,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)add_pending_object (&revs, object,oid_to_hex (&object->oid));for_each_ref (add_pending_uninteresting_ref, &revs); -add_pending_oid (&revs,"HEAD" , &new->object.oid,UNINTERESTING ); +add_pending_oid (&revs,"HEAD" , &new_commit->object.oid,UNINTERESTING );if (prepare_revision_walk (&revs))die (_ ("internal error in revision walk" ));
@@ -813,7 +813,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new) }static int switch_branches (const struct checkout_opts *opts, -struct branch_info *new) +struct branch_info *new_branch_info) {int ret =0 ;struct branch_info old;
@@ -830,26 +830,26 @@ static int switch_branches(const struct checkout_opts *opts,if (old.path)skip_prefix (old.path,"refs/heads/" , &old.name); -if (!new->name) { - new->name ="HEAD" ; - new->commit = old.commit; -if (!new->commit) +if (!new_branch_info->name) { + new_branch_info->name ="HEAD" ; + new_branch_info->commit = old.commit; +if (!new_branch_info->commit)die (_ ("You are on a branch yet to be born" )); -parse_commit_or_die (new->commit); +parse_commit_or_die (new_branch_info->commit); } - ret =merge_working_tree (opts, &old, new, &writeout_error); + ret =merge_working_tree (opts, &old, new_branch_info, &writeout_error);if (ret) {free (path_to_free);return ret; } -if (!opts->quiet && !old.path && old.commit && new->commit != old.commit) -orphaned_commit_warning (old.commit, new->commit); +if (!opts->quiet && !old.path && old.commit && new_branch_info->commit != old.commit) +orphaned_commit_warning (old.commit, new_branch_info->commit); -update_refs_for_switch (opts, &old, new); +update_refs_for_switch (opts, &old, new_branch_info); - ret =post_checkout_hook (old.commit, new->commit,1 ); + ret =post_checkout_hook (old.commit, new_branch_info->commit,1 );free (path_to_free);return ret || writeout_error; }
@@ -870,7 +870,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)static int parse_branchname_arg (int argc,const char **argv,int dwim_new_local_branch_ok, -struct branch_info *new, +struct branch_info *new_branch_info,struct checkout_opts *opts,struct object_id *rev) {
@@ -988,22 +988,22 @@ static int parse_branchname_arg(int argc, const char **argv, argv++; argc--; - new->name = arg; -setup_branch_path (new); + new_branch_info->name = arg; +setup_branch_path (new_branch_info); -if (!check_refname_format (new->path,0 ) && - !read_ref (new->path, &branch_rev)) +if (!check_refname_format (new_branch_info->path,0 ) && + !read_ref (new_branch_info->path, &branch_rev))oidcpy (rev, &branch_rev);else - new->path =NULL ;/* not an existing branch */ + new_branch_info->path =NULL ;/* not an existing branch */ - new->commit =lookup_commit_reference_gently (rev,1 ); -if (!new->commit) { + new_branch_info->commit =lookup_commit_reference_gently (rev,1 ); +if (!new_branch_info->commit) {/* not a commit */ *source_tree =parse_tree_indirect (rev); }else { -parse_commit_or_die (new->commit); - *source_tree = new->commit->tree; +parse_commit_or_die (new_branch_info->commit); + *source_tree = new_branch_info->commit->tree; }if (!*source_tree)/* case (1): want a tree */
@@ -1043,7 +1043,7 @@ static int switch_unborn_to_new_branch(const struct checkout_opts *opts) }static int checkout_branch (struct checkout_opts *opts, -struct branch_info *new) +struct branch_info *new_branch_info) {if (opts->pathspec.nr)die (_ ("paths cannot be used with switching branches" ));
@@ -1072,21 +1072,21 @@ static int checkout_branch(struct checkout_opts *opts, }else if (opts->track ==BRANCH_TRACK_UNSPECIFIED ) opts->track = git_branch_track; -if (new->name && !new->commit) +if (new_branch_info->name && !new_branch_info->commit)die (_ ("Cannot switch branch to a non-commit '%s'" ), - new->name); + new_branch_info->name); -if (new->path && !opts->force_detach && !opts->new_branch && +if (new_branch_info->path && !opts->force_detach && !opts->new_branch && !opts->ignore_other_worktrees) {int flag;char *head_ref =resolve_refdup ("HEAD" ,0 ,NULL , &flag);if (head_ref && - (!(flag &REF_ISSYMREF ) ||strcmp (head_ref, new->path))) -die_if_checked_out (new->path,1 ); + (!(flag &REF_ISSYMREF ) ||strcmp (head_ref, new_branch_info->path))) +die_if_checked_out (new_branch_info->path,1 );free (head_ref); } -if (!new->commit && opts->new_branch) { +if (!new_branch_info->commit && opts->new_branch) {struct object_id rev;int flag;
@@ -1094,13 +1094,13 @@ static int checkout_branch(struct checkout_opts *opts, (flag & REF_ISSYMREF) && is_null_oid(&rev))return switch_unborn_to_new_branch (opts); } -return switch_branches (opts, new); +return switch_branches (opts, new_branch_info); }int cmd_checkout (int argc,const char **argv,const char *prefix) {struct checkout_opts opts; -struct branch_info new; +struct branch_info new_branch_info;char *conflict_style =NULL ;int dwim_new_local_branch =1 ;struct option options[] = {
@@ -1138,7 +1138,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) };memset (&opts,0 ,sizeof (opts)); -memset (&new,0 ,sizeof (new)); +memset (&new_branch_info,0 ,sizeof (new_branch_info)); opts.overwrite_ignore =1 ; opts.prefix = prefix; opts.show_progress =-1 ;
@@ -1210,7 +1210,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) opts.track ==BRANCH_TRACK_UNSPECIFIED && !opts.new_branch;int n =parse_branchname_arg (argc, argv, dwim_ok, - &new, &opts, &rev); + &new_branch_info, &opts, &rev); argv += n; argc -= n; }
@@ -1253,7 +1253,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)UNLEAK (opts);if (opts.patch_mode || opts.pathspec.nr) -return checkout_paths (&opts, new.name); +return checkout_paths (&opts, new_branch_info.name);else -return checkout_branch (&opts, &new); +return checkout_branch (&opts, &new_branch_info); }
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 10/37 help: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/help.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
builtin/help.c +5 -5
@@ -194,11 +194,11 @@ static void do_add_man_viewer_info(const char *name,size_t len, const char *value) { - struct man_viewer_info_list *new; -FLEX_ALLOC_MEM (new, name, name, len); - new->info =xstrdup (value); - new->next = man_viewer_info_list; - man_viewer_info_list = new; + struct man_viewer_info_list *new_man_viewer; +FLEX_ALLOC_MEM (new_man_viewer, name, name, len); + new_man_viewer->info =xstrdup (value); + new_man_viewer->next = man_viewer_info_list; + man_viewer_info_list = new_man_viewer; } static int add_man_viewer_path(const char *name,
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 11/37 pack-redundant: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/pack-redundant.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-)
builtin/pack-redundant.c +24 -24
@@ -48,17 +48,17 @@ static inline void llist_item_put(struct llist_item *item)static inline struct llist_item *llist_item_get (void ) { -struct llist_item *new; +struct llist_item *new_item;if ( free_nodes ) { - new = free_nodes; + new_item = free_nodes; free_nodes = free_nodes->next; }else {int i =1 ; -ALLOC_ARRAY (new,BLKSIZE ); +ALLOC_ARRAY (new_item,BLKSIZE );for (; i <BLKSIZE ; i++) -llist_item_put (&new[i]); +llist_item_put (&new_item[i]); } -return new; +return new_item; }static void llist_free (struct llist *list)
@@ -80,26 +80,26 @@ static inline void llist_init(struct llist **list)static struct llist *llist_copy (struct llist *list) {struct llist *ret; -struct llist_item *new, *old, *prev; +struct llist_item *new_item, *old, *prev;llist_init (&ret);if ((ret->size = list->size) ==0 )return ret; - new = ret->front =llist_item_get (); - new->sha1 = list->front->sha1; + new_item = ret->front =llist_item_get (); + new_item->sha1 = list->front->sha1; old = list->front->next;while (old) { - prev = new; - new =llist_item_get (); - prev->next = new; - new->sha1 = old->sha1; + prev = new_item; + new_item =llist_item_get (); + prev->next = new_item; + new_item->sha1 = old->sha1; old = old->next; } - new->next =NULL ; - ret->back = new; + new_item->next =NULL ; + ret->back = new_item;return ret; }
@@ -108,24 +108,24 @@ static inline struct llist_item *llist_insert(struct llist *list,struct llist_item *after, const unsigned char *sha1) { - struct llist_item *new = llist_item_get(); - new->sha1 = sha1; - new->next =NULL ; + struct llist_item *new_item = llist_item_get(); + new_item->sha1 = sha1; + new_item->next =NULL ;if (after !=NULL ) { - new->next = after->next; - after->next = new; + new_item->next = after->next; + after->next = new_item;if (after == list->back) - list->back = new; + list->back = new_item; }else {/* insert in front */ if (list->size ==0 ) - list->back = new; + list->back = new_item;else - new->next = list->front; - list->front = new; + new_item->next = list->front; + list->front = new_item; } list->size++; -return new; +return new_item; } static inline struct llist_item *llist_insert_back(struct llist *list,
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 12/37 reflog: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/reflog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
builtin/reflog.c +4 -4
@@ -289,20 +289,20 @@ static int should_expire_reflog_ent(struct object_id *ooid, struct object_id *no const char *message, void *cb_data) { struct expire_reflog_policy_cb *cb = cb_data; -struct commit *old, *new; +struct commit *old, *new_commit;if (timestamp < cb->cmd.expire_total)return 1 ; - old = new =NULL ; + old = new_commit =NULL ;if (cb->cmd.stalefix && - (!keep_entry (&old, ooid) || !keep_entry (&new, noid))) + (!keep_entry (&old, ooid) || !keep_entry (&new_commit, noid)))return 1 ;if (timestamp < cb->cmd.expire_unreachable) {if (cb->unreachable_expire_kind ==UE_ALWAYS )return 1 ; -if (unreachable (cb, old, ooid) ||unreachable (cb, new, noid)) +if (unreachable (cb, old, ooid) ||unreachable (cb, new_commit, noid))return 1 ; }
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 13/37 remote: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/remote.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
builtin/remote.c +22 -22
@@ -322,7 +322,7 @@ static void read_branches(void)struct ref_states {struct remote *remote; -struct string_list new, stale, tracked, heads, push; +struct string_list new_refs, stale, tracked, heads, push;int queried; };
@@ -337,12 +337,12 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *statdie (_ ("Could not get fetch map for refspec %s" ), states->remote->fetch_refspec[i]); - states->new.strdup_strings =1 ; + states->new_refs.strdup_strings =1 ; states->tracked.strdup_strings =1 ; states->stale.strdup_strings =1 ;for (ref = fetch_map; ref; ref = ref->next) {if (!ref->peer_ref || !ref_exists (ref->peer_ref->name)) -string_list_append (&states->new,abbrev_branch (ref->name)); +string_list_append (&states->new_refs,abbrev_branch (ref->name));else string_list_append (&states->tracked,abbrev_branch (ref->name)); }
@@ -356,7 +356,7 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *statfree_refs (stale_refs);free_refs (fetch_map); -string_list_sort (&states->new); +string_list_sort (&states->new_refs);string_list_sort (&states->tracked);string_list_sort (&states->stale);
@@ -547,7 +547,7 @@ static int add_branch_for_removal(const char *refname,struct rename_info {const char *old; -const char *new; +const char *new_name;struct string_list *remote_branches; };
@@ -616,33 +616,33 @@ static int mv(int argc, const char **argv)usage_with_options (builtin_remote_rename_usage, options); rename.old = argv[1 ]; - rename.new = argv[2 ]; + rename.new_name = argv[2 ]; rename.remote_branches = &remote_branches; oldremote =remote_get (rename.old);if (!remote_is_configured (oldremote,1 ))die (_ ("No such remote: %s" ), rename.old); -if (!strcmp (rename.old, rename.new) && oldremote->origin !=REMOTE_CONFIG ) +if (!strcmp (rename.old, rename.new_name) && oldremote->origin !=REMOTE_CONFIG )return migrate_file (oldremote); - newremote =remote_get (rename.new); + newremote =remote_get (rename.new_name);if (remote_is_configured (newremote,1 )) -die (_ ("remote %s already exists." ), rename.new); +die (_ ("remote %s already exists." ), rename.new_name); -strbuf_addf (&buf,"refs/heads/test:refs/remotes/%s/test" , rename.new); +strbuf_addf (&buf,"refs/heads/test:refs/remotes/%s/test" , rename.new_name);if (!valid_fetch_refspec (buf.buf)) -die (_ ("'%s' is not a valid remote name" ), rename.new); +die (_ ("'%s' is not a valid remote name" ), rename.new_name);strbuf_reset (&buf);strbuf_addf (&buf,"remote.%s" , rename.old); -strbuf_addf (&buf2,"remote.%s" , rename.new); +strbuf_addf (&buf2,"remote.%s" , rename.new_name);if (git_config_rename_section (buf.buf, buf2.buf) <1 )return error (_ ("Could not rename config section '%s' to '%s'" ), buf.buf, buf2.buf);strbuf_reset (&buf); -strbuf_addf (&buf,"remote.%s.fetch" , rename.new); +strbuf_addf (&buf,"remote.%s.fetch" , rename.new_name);git_config_set_multivar (buf.buf,NULL ,NULL ,1 );strbuf_addf (&old_remote_context,":refs/remotes/%s/" , rename.old);for (i =0 ; i < oldremote->fetch_refspec_nr; i++) {
@@ -655,8 +655,8 @@ static int mv(int argc, const char **argv) refspec_updated =1 ;strbuf_splice (&buf2, ptr-buf2.buf +strlen (":refs/remotes/" ), -strlen (rename.old), rename.new, -strlen (rename.new)); +strlen (rename.old), rename.new_name, +strlen (rename.new_name)); }else warning(_("Not updating non-default fetch refspec\n" "\t%s\n"
@@ -673,7 +673,7 @@ static int mv(int argc, const char **argv)if (info->remote_name && !strcmp (info->remote_name, rename.old)) {strbuf_reset (&buf);strbuf_addf (&buf,"branch.%s.remote" , item->string); -git_config_set (buf.buf, rename.new); +git_config_set (buf.buf, rename.new_name); } }
@@ -704,7 +704,7 @@ static int mv(int argc, const char **argv)strbuf_reset (&buf);strbuf_addstr (&buf, item->string);strbuf_splice (&buf,strlen ("refs/remotes/" ),strlen (rename.old), - rename.new,strlen (rename.new)); + rename.new_name,strlen (rename.new_name));strbuf_reset (&buf2);strbuf_addf (&buf2,"remote: renamed %s to %s" , item->string, buf.buf);
@@ -719,11 +719,11 @@ static int mv(int argc, const char **argv)strbuf_reset (&buf);strbuf_addstr (&buf, item->string);strbuf_splice (&buf,strlen ("refs/remotes/" ),strlen (rename.old), - rename.new,strlen (rename.new)); + rename.new_name,strlen (rename.new_name));strbuf_reset (&buf2);strbuf_addstr (&buf2, item->util);strbuf_splice (&buf2,strlen ("refs/remotes/" ),strlen (rename.old), - rename.new,strlen (rename.new)); + rename.new_name,strlen (rename.new_name));strbuf_reset (&buf3);strbuf_addf (&buf3,"remote: renamed %s to %s" , item->string, buf.buf);
@@ -822,7 +822,7 @@ static void clear_push_info(void *util, const char *string)static void free_remote_ref_states (struct ref_states *states) { -string_list_clear (&states->new,0 ); +string_list_clear (&states->new_refs,0 );string_list_clear (&states->stale,1 );string_list_clear (&states->tracked,0 );string_list_clear (&states->heads,0 );
@@ -907,7 +907,7 @@ static int show_remote_info_item(struct string_list_item *item, void *cb_data)if (states->queried) {const char *fmt ="%s" ;const char *arg ="" ; -if (string_list_has_string (&states->new, name)) { +if (string_list_has_string (&states->new_refs, name)) { fmt =_ (" new (next fetch will store in remotes/%s)" ); arg = states->remote->name; }else if (string_list_has_string (&states->tracked, name))
@@ -1176,7 +1176,7 @@ static int show(int argc, const char **argv)/* remote branch info */ info.width =0 ; -for_each_string_list (&states.new, add_remote_to_show_info, &info); +for_each_string_list (&states.new_refs, add_remote_to_show_info, &info);for_each_string_list (&states.tracked, add_remote_to_show_info, &info);for_each_string_list (&states.stale, add_remote_to_show_info, &info);if (info.list->nr)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 14/37 combine-diff: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- combine-diff.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
combine-diff.c +6 -6
@@ -162,7 +162,7 @@ enum coalesce_direction { MATCH, BASE, NEW };/* Coalesce new lines into base by finding LCS */ static struct lline *coalesce_lines (struct lline *base,int *lenbase, -struct lline *new,int lennew, +struct lline *newline,int lennew,unsigned long parent,long flags) {int **lcs;
@@ -170,12 +170,12 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,struct lline *baseend, *newend =NULL ;int i, j, origbaselen = *lenbase; -if (new ==NULL ) +if (newline ==NULL )return base;if (base ==NULL ) { *lenbase = lennew; -return new; +return newline; }/*
@@ -200,7 +200,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase, directions[0 ][j] =NEW ;for (i =1 , baseend = base; i < origbaselen +1 ; i++) { -for (j =1 , newend = new; j < lennew +1 ; j++) { +for (j =1 , newend = newline; j < lennew +1 ; j++) {if (match_string_spaces (baseend->line, baseend->len, newend->line, newend->len, flags)) { lcs[i][j] = lcs[i -1 ][j -1 ] +1 ;
@@ -241,7 +241,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,if (lline->prev) lline->prev->next = lline->next;else - new = lline->next; + newline = lline->next;if (lline->next) lline->next->prev = lline->prev;
@@ -270,7 +270,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase, } } - newend = new; + newend = newline;while (newend) {struct lline *lline = newend; newend = newend->next;
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 15/37 commit: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- commit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
commit.c +9 -9
@@ -861,19 +861,19 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)commit_list_insert (in->item, &ret);for (i = in->next; i; i = i->next) { -struct commit_list *new =NULL , *end =NULL ; +struct commit_list *new_commits =NULL , *end =NULL ;for (j = ret; j; j = j->next) {struct commit_list *bases; bases =get_merge_bases (i->item, j->item); -if (!new) - new = bases; +if (!new_commits) + new_commits = bases;else end->next = bases;for (k = bases; k; k = k->next) end = k; } - ret = new; + ret = new_commits; }return ret; }
@@ -1617,11 +1617,11 @@ struct commit *get_merge_parent(const char *name)struct commit_list **commit_list_append (struct commit *commit,struct commit_list **next) { -struct commit_list *new =xmalloc (sizeof (struct commit_list )); - new->item = commit; - *next = new; - new->next =NULL ; -return &new->next; +struct commit_list *new_commit =xmalloc (sizeof (struct commit_list )); + new_commit->item = commit; + *next = new_commit; + new_commit->next =NULL ; +return &new_commit->next; }const char *find_commit_header (const char *msg,const char *key,size_t *out_len)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 16/37 diff-lib: rename 'new' variable
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diff-lib.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff-lib.c +10 -10
@@ -302,7 +302,7 @@ static int get_stat_data(const struct cache_entry *ce, }static void show_new_file (struct rev_info *revs, -const struct cache_entry *new, +const struct cache_entry *new_file,int cached,int match_missing) {const struct object_id *oid;
@@ -313,16 +313,16 @@ static void show_new_file(struct rev_info *revs,* New file in the index: it might actually be different in * the working tree. */ -if (get_stat_data (new, &oid, &mode, cached, match_missing, +if (get_stat_data (new_file, &oid, &mode, cached, match_missing, &dirty_submodule, &revs->diffopt) <0 )return ; -diff_index_show_file (revs,"+" , new, oid, !is_null_oid (oid), mode, dirty_submodule); +diff_index_show_file (revs,"+" , new_file, oid, !is_null_oid (oid), mode, dirty_submodule); }static int show_modified (struct rev_info *revs,const struct cache_entry *old, -const struct cache_entry *new, +const struct cache_entry *new_entry,int report_missing,int cached,int match_missing) {
@@ -330,7 +330,7 @@ static int show_modified(struct rev_info *revs,const struct object_id *oid;unsigned dirty_submodule =0 ; -if (get_stat_data (new, &oid, &mode, cached, match_missing, +if (get_stat_data (new_entry, &oid, &mode, cached, match_missing, &dirty_submodule, &revs->diffopt) <0 ) {if (report_missing) diff_index_show_file(revs, "-", old,
@@ -340,21 +340,21 @@ static int show_modified(struct rev_info *revs, }if (revs->combine_merges && !cached && - (oidcmp (oid, &old->oid) ||oidcmp (&old->oid, &new->oid))) { + (oidcmp (oid, &old->oid) ||oidcmp (&old->oid, &new_entry->oid))) {struct combine_diff_path *p; -int pathlen =ce_namelen (new); +int pathlen =ce_namelen (new_entry); p =xmalloc (combine_diff_path_size (2 , pathlen)); p->path = (char *) &p->parent[2 ]; p->next =NULL ; -memcpy (p->path, new->name, pathlen); +memcpy (p->path, new_entry->name, pathlen); p->path[pathlen] =0 ; p->mode = mode;oidclr (&p->oid);memset (p->parent,0 ,2 *sizeof (struct combine_diff_parent )); p->parent[0 ].status =DIFF_STATUS_MODIFIED ; - p->parent[0 ].mode = new->ce_mode; -oidcpy (&p->parent[0 ].oid, &new->oid); + p->parent[0 ].mode = new_entry->ce_mode; +oidcpy (&p->parent[0 ].oid, &new_entry->oid); p->parent[1 ].status =DIFF_STATUS_MODIFIED ; p->parent[1 ].mode = old->ce_mode;oidcpy (&p->parent[1 ].oid, &old->oid);
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 17/37 diff: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diff.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff.c +10 -10
@@ -1504,7 +1504,7 @@ struct diff_words_style_elem {struct diff_words_style {enum diff_words_type type; -struct diff_words_style_elem new, old, ctx; +struct diff_words_style_elem new_word, old, ctx;const char *newline; };
@@ -1660,7 +1660,7 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len) }if (plus_begin != plus_end) {fn_out_diff_words_write_helper (diff_words->opt, - &style->new, style->newline, + &style->new_word, style->newline, plus_end - plus_begin, plus_begin); }
@@ -1884,7 +1884,7 @@ static void init_diff_words_data(struct emit_callback *ecbdata,if (want_color (o->use_color)) {struct diff_words_style *st = ecbdata->diff_words->style; st->old.color =diff_get_color_opt (o,DIFF_FILE_OLD ); - st->new.color =diff_get_color_opt (o,DIFF_FILE_NEW ); + st->new_word.color =diff_get_color_opt (o,DIFF_FILE_NEW ); st->ctx.color =diff_get_color_opt (o,DIFF_CONTEXT ); } }
@@ -2048,7 +2048,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)static char *pprint_rename (const char *a,const char *b) {const char *old = a; -const char *new = b; +const char *new_name = b;struct strbuf name =STRBUF_INIT ;int pfx_length, sfx_length;int pfx_adjust_for_slash;
@@ -2067,16 +2067,16 @@ static char *pprint_rename(const char *a, const char *b)/* Find common prefix */ pfx_length =0 ; -while (*old && *new && *old == *new) { +while (*old && *new_name && *old == *new_name) {if (*old =='/' ) pfx_length = old - a +1 ; old++; - new++; + new_name++; }/* Find common suffix */ old = a + len_a; - new = b + len_b; + new_name = b + len_b; sfx_length =0 ;/* * If there is a common prefix, it must end in a slash. In
@@ -2088,12 +2088,12 @@ static char *pprint_rename(const char *a, const char *b)*/ pfx_adjust_for_slash = (pfx_length ?1 :0 );while (a + pfx_length - pfx_adjust_for_slash <= old && - b + pfx_length - pfx_adjust_for_slash <= new && - *old == *new) { + b + pfx_length - pfx_adjust_for_slash <= new_name && + *old == *new_name) {if (*old =='/' ) sfx_length = len_a - (old - a); old--; - new--; + new_name--; }/*
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 18/37 diffcore-delta: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diffcore-delta.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diffcore-delta.c +8 -8
@@ -48,16 +48,16 @@ struct spanhash_top {static struct spanhash_top *spanhash_rehash (struct spanhash_top *orig) { -struct spanhash_top *new; +struct spanhash_top *new_spanhash;int i;int osz =1 << orig->alloc_log2;int sz = osz <<1 ; - new =xmalloc (st_add (sizeof (*orig), + new_spanhash =xmalloc (st_add (sizeof (*orig),st_mult (sizeof (struct spanhash ), sz))); - new->alloc_log2 = orig->alloc_log2 +1 ; - new->free =INITIAL_FREE (new->alloc_log2); -memset (new->data,0 ,sizeof (struct spanhash ) * sz); + new_spanhash->alloc_log2 = orig->alloc_log2 +1 ; + new_spanhash->free =INITIAL_FREE (new_spanhash->alloc_log2); +memset (new_spanhash->data,0 ,sizeof (struct spanhash ) * sz);for (i =0 ; i < osz; i++) {struct spanhash *o = &(orig->data[i]);int bucket;
@@ -65,11 +65,11 @@ static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig)continue ; bucket = o->hashval & (sz -1 );while (1 ) { -struct spanhash *h = &(new->data[bucket++]); +struct spanhash *h = &(new_spanhash->data[bucket++]);if (!h->cnt) { h->hashval = o->hashval; h->cnt = o->cnt; - new->free--; + new_spanhash->free--;break ; }if (sz <= bucket)
@@ -77,7 +77,7 @@ static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig) } }free (orig); -return new; +return new_spanhash; } static struct spanhash_top *add_spanhash(struct spanhash_top *top,
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 19/37 entry: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- entry.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
entry.c +20 -20
@@ -85,12 +85,12 @@ static int create_file(const char *path, unsigned int mode)static void *read_blob_entry (const struct cache_entry *ce,unsigned long *size) {enum object_type type; -void *new =read_sha1_file (ce->oid.hash, &type, size); +void *blob_data =read_sha1_file (ce->oid.hash, &type, size); -if (new) { +if (blob_data) {if (type ==OBJ_BLOB ) -return new; -free (new); +return blob_data; +free (blob_data); }return NULL ; }
@@ -256,7 +256,7 @@ static int write_entry(struct cache_entry *ce,unsigned int ce_mode_s_ifmt = ce->ce_mode &S_IFMT ;struct delayed_checkout *dco = state->delayed_checkout;int fd, ret, fstat_done =0 ; -char *new; +char *new_blob;struct strbuf buf =STRBUF_INIT ;unsigned long size;ssize_t wrote;
@@ -276,8 +276,8 @@ static int write_entry(struct cache_entry *ce,switch (ce_mode_s_ifmt) {case S_IFLNK : - new =read_blob_entry (ce, &size); -if (!new) + new_blob =read_blob_entry (ce, &size); +if (!new_blob)return error ("unable to read sha1 file of %s (%s)" , path,oid_to_hex (&ce->oid));
@@ -288,8 +288,8 @@ static int write_entry(struct cache_entry *ce,if (!has_symlinks || to_tempfile) goto write_file_entry; - ret =symlink (new, path); -free (new); + ret =symlink (new_blob, path); +free (new_blob);if (ret)return error_errno ("unable to create symlink %s" , path);break ;
@@ -300,11 +300,11 @@ static int write_entry(struct cache_entry *ce,* bother reading it at all. */ if (dco && dco->state ==CE_RETRY ) { - new =NULL ; + new_blob =NULL ; size =0 ; }else { - new =read_blob_entry (ce, &size); -if (!new) + new_blob =read_blob_entry (ce, &size); +if (!new_blob)return error ("unable to read sha1 file of %s (%s)" , path,oid_to_hex (&ce->oid)); }
@@ -313,18 +313,18 @@ static int write_entry(struct cache_entry *ce,* Convert from git internal format to working tree format */ if (dco && dco->state !=CE_NO_DELAY ) { - ret =async_convert_to_working_tree (ce->name, new, + ret =async_convert_to_working_tree (ce->name, new_blob, size, &buf, dco);if (ret &&string_list_has_string (&dco->paths, ce->name)) { -free (new); +free (new_blob); goto delayed; } }else - ret =convert_to_working_tree (ce->name, new, size, &buf); + ret =convert_to_working_tree (ce->name, new_blob, size, &buf);if (ret) { -free (new); - new =strbuf_detach (&buf, &newsize); +free (new_blob); + new_blob =strbuf_detach (&buf, &newsize); size = newsize; }/*
@@ -336,15 +336,15 @@ static int write_entry(struct cache_entry *ce, write_file_entry: fd =open_output_fd (path, ce, to_tempfile);if (fd <0 ) { -free (new); +free (new_blob);return error_errno ("unable to create file %s" , path); } - wrote =write_in_full (fd, new, size); + wrote =write_in_full (fd, new_blob, size);if (!to_tempfile) fstat_done =fstat_output (fd, state, &st);close (fd); -free (new); +free (new_blob);if (wrote <0 )return error ("unable to write file %s" , path);break ;
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 20/37 http: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- http.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
http.c +5 -5
@@ -1194,14 +1194,14 @@ static struct fill_chain *fill_cfg;void add_fill_function (void *data,int (*fill)(void *)) { -struct fill_chain *new =xmalloc (sizeof (*new)); +struct fill_chain *new_fill =xmalloc (sizeof (*new_fill));struct fill_chain **linkp = &fill_cfg; - new->data = data; - new->fill = fill; - new->next =NULL ; + new_fill->data = data; + new_fill->fill = fill; + new_fill->next =NULL ;while (*linkp) linkp = &(*linkp)->next; - *linkp = new; + *linkp = new_fill; }void fill_active_slots (void )
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 21/37 imap-send: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- imap-send.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
imap-send.c +7 -7
@@ -1189,11 +1189,11 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f*/ static void lf_to_crlf (struct strbuf *msg) { -char *new; +char *new_msg;size_t i, j;char lastc; -/* First pass: tally, in j, the size of the new string: */ +/* First pass: tally, in j, the size of the new_msg string: */ for (i = j =0 , lastc ='\0' ; i < msg->len; i++) {if (msg->buf[i] =='\n' && lastc !='\r' ) j++;/* a CR will need to be added here */
@@ -1201,18 +1201,18 @@ static void lf_to_crlf(struct strbuf *msg) j++; } - new =xmallocz (j); + new_msg =xmallocz (j);/* -* Second pass: write the new string. Note that this loop is +* Second pass: write the new_msg string. Note that this loop is * otherwise identical to the first pass. */ for (i = j =0 , lastc ='\0' ; i < msg->len; i++) {if (msg->buf[i] =='\n' && lastc !='\r' ) - new[j++] ='\r' ; - lastc = new[j++] = msg->buf[i]; + new_msg[j++] ='\r' ; + lastc = new_msg[j++] = msg->buf[i]; } -strbuf_attach (msg, new, j, j +1 ); +strbuf_attach (msg, new_msg, j, j +1 ); }/*
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 22/37 line-log: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- line-log.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-)
line-log.c +24 -24
@@ -151,29 +151,29 @@ static void range_set_union(struct range_set *out,assert (out->nr ==0 );while (i < a->nr || j < b->nr) { -struct range *new; +struct range *new_range;if (i < a->nr && j < b->nr) {if (ra[i].start < rb[j].start) - new = &ra[i++]; + new_range = &ra[i++];else if (ra[i].start > rb[j].start) - new = &rb[j++]; + new_range = &rb[j++];else if (ra[i].end < rb[j].end) - new = &ra[i++]; + new_range = &ra[i++];else - new = &rb[j++]; + new_range = &rb[j++]; }else if (i < a->nr)/* b exhausted */ - new = &ra[i++]; + new_range = &ra[i++];else /* a exhausted */ - new = &rb[j++]; -if (new->start == new->end) + new_range = &rb[j++]; +if (new_range->start == new_range->end) ;/* empty range */ -else if (!out->nr || out->ranges[out->nr-1 ].end < new->start) { +else if (!out->nr || out->ranges[out->nr-1 ].end < new_range->start) {range_set_grow (out,1 ); - out->ranges[out->nr].start = new->start; - out->ranges[out->nr].end = new->end; + out->ranges[out->nr].start = new_range->start; + out->ranges[out->nr].end = new_range->end; out->nr++; - }else if (out->ranges[out->nr-1 ].end < new->end) { - out->ranges[out->nr-1 ].end = new->end; + }else if (out->ranges[out->nr-1 ].end < new_range->end) { + out->ranges[out->nr-1 ].end = new_range->end; } } }
@@ -697,17 +697,17 @@ static void add_line_range(struct rev_info *revs, struct commit *commit, struct line_log_data *range) {struct line_log_data *old =NULL ; -struct line_log_data *new =NULL ; +struct line_log_data *new_line =NULL ; old =lookup_decoration (&revs->line_log_data, &commit->object);if (old && range) { - new =line_log_data_merge (old, range); + new_line =line_log_data_merge (old, range);free_line_log_data (old); }else if (range) - new =line_log_data_copy (range); + new_line =line_log_data_copy (range); -if (new) -add_decoration (&revs->line_log_data, &commit->object, new); +if (new_line) +add_decoration (&revs->line_log_data, &commit->object, new_line); }static void clear_commit_line_range (struct rev_info *revs,struct commit *commit)
@@ -1042,12 +1042,12 @@ static int process_diff_filepair(struct rev_info *rev,static struct diff_filepair *diff_filepair_dup (struct diff_filepair *pair) { -struct diff_filepair *new =xmalloc (sizeof (struct diff_filepair )); - new->one = pair->one; - new->two = pair->two; - new->one->count++; - new->two->count++; -return new; +struct diff_filepair *new_filepair =xmalloc (sizeof (struct diff_filepair )); + new_filepair->one = pair->one; + new_filepair->two = pair->two; + new_filepair->one->count++; + new_filepair->two->count++; +return new_filepair; }static void free_diffqueues (int n,struct diff_queue_struct *dq)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 23/37 read-cache: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- read-cache.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
read-cache.c +18 -18
@@ -70,20 +70,20 @@ static void replace_index_entry(struct index_state *istate, int nr, struct cachevoid rename_index_entry_at (struct index_state *istate,int nr,const char *new_name) { -struct cache_entry *old = istate->cache[nr], *new; +struct cache_entry *old = istate->cache[nr], *new_entry;int namelen =strlen (new_name); - new =xmalloc (cache_entry_size (namelen)); -copy_cache_entry (new, old); - new->ce_flags &= ~CE_HASHED ; - new->ce_namelen = namelen; - new->index =0 ; -memcpy (new->name, new_name, namelen +1 ); + new_entry =xmalloc (cache_entry_size (namelen)); +copy_cache_entry (new_entry, old); + new_entry->ce_flags &= ~CE_HASHED ; + new_entry->ce_namelen = namelen; + new_entry->index =0 ; +memcpy (new_entry->name, new_name, namelen +1 );cache_tree_invalidate_path (istate, old->name);untracked_cache_remove_from_index (istate, old->name);remove_index_entry_at (istate, nr); -add_index_entry (istate, new,ADD_CACHE_OK_TO_ADD |ADD_CACHE_OK_TO_REPLACE ); +add_index_entry (istate, new_entry,ADD_CACHE_OK_TO_ADD |ADD_CACHE_OK_TO_REPLACE ); }void fill_stat_data (struct stat_data *sd,struct stat *st)
@@ -615,18 +615,18 @@ static struct cache_entry *create_alias_ce(struct index_state *istate, struct cache_entry *alias) {int len; -struct cache_entry *new; +struct cache_entry *new_entry;if (alias->ce_flags &CE_ADDED )die ("Will not add file alias '%s' ('%s' already exists in index)" , ce->name, alias->name);/* Ok, create the new entry using the name of the existing alias */ len =ce_namelen (alias); - new =xcalloc (1 ,cache_entry_size (len)); -memcpy (new->name, alias->name, len); -copy_cache_entry (new, ce); + new_entry =xcalloc (1 ,cache_entry_size (len)); +memcpy (new_entry->name, alias->name, len); +copy_cache_entry (new_entry, ce);save_or_free_index_entry (istate, ce); -return new; +return new_entry; }void set_object_name_for_intent_to_add_entry (struct cache_entry *ce)
@@ -1379,7 +1379,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, added_fmt = (in_porcelain ?"A\t%s\n" :"%s needs update\n" ); unmerged_fmt = (in_porcelain ?"U\t%s\n" :"%s: needs merge\n" );for (i =0 ; i < istate->cache_nr; i++) { -struct cache_entry *ce, *new; +struct cache_entry *ce, *new_entry;int cache_errno =0 ;int changed =0 ;int filtered =0 ;
@@ -1408,10 +1408,10 @@ int refresh_index(struct index_state *istate, unsigned int flags,if (filtered)continue ; - new =refresh_cache_ent (istate, ce, options, &cache_errno, &changed); -if (new == ce) + new_entry =refresh_cache_ent (istate, ce, options, &cache_errno, &changed); +if (new_entry == ce)continue ; -if (!new) { +if (!new_entry) {const char *fmt;if (really && cache_errno ==EINVAL ) {
@@ -1440,7 +1440,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,continue ; } -replace_index_entry (istate, i, new); +replace_index_entry (istate, i, new_entry); }return has_errors; }
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 24/37 ref-filter: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- ref-filter.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
ref-filter.c +8 -8
@@ -529,12 +529,12 @@ static void end_align_handler(struct ref_formatting_stack **stack)static void align_atom_handler (struct atom_value *atomv,struct ref_formatting_state *state) { -struct ref_formatting_stack *new; +struct ref_formatting_stack *new_stack;push_stack_element (&state->stack); - new = state->stack; - new->at_end = end_align_handler; - new->at_end_data = &atomv->atom->u.align; + new_stack = state->stack; + new_stack->at_end = end_align_handler; + new_stack->at_end_data = &atomv->atom->u.align; }static void if_then_else_handler (struct ref_formatting_stack **stack)
@@ -574,16 +574,16 @@ static void if_then_else_handler(struct ref_formatting_stack **stack)static void if_atom_handler (struct atom_value *atomv,struct ref_formatting_state *state) { -struct ref_formatting_stack *new; +struct ref_formatting_stack *new_stack;struct if_then_else *if_then_else =xcalloc (sizeof (struct if_then_else ),1 ); if_then_else->str = atomv->atom->u.if_then_else.str; if_then_else->cmp_status = atomv->atom->u.if_then_else.cmp_status;push_stack_element (&state->stack); - new = state->stack; - new->at_end = if_then_else_handler; - new->at_end_data = if_then_else; + new_stack = state->stack; + new_stack->at_end = if_then_else_handler; + new_stack->at_end_data = if_then_else; }static int is_empty (const char *s)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 25/37 remote: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- remote.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
remote.c +8 -8
@@ -1970,12 +1970,12 @@ static void unmark_and_free(struct commit_list *list, unsigned int mark)int ref_newer (const struct object_id *new_oid,const struct object_id *old_oid) {struct object *o; -struct commit *old, *new; +struct commit *old, *new_commit;struct commit_list *list, *used;int found =0 ;/* -* Both new and old must be commit-ish and new is descendant of +* Both new_commit and old must be commit-ish and new_commit is descendant of * old. Otherwise we require --force. */ o =deref_tag (parse_object (old_oid),NULL ,0 );
@@ -1986,17 +1986,17 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid) o =deref_tag (parse_object (new_oid),NULL ,0 );if (!o || o->type !=OBJ_COMMIT )return 0 ; - new = (struct commit *) o; + new_commit = (struct commit *) o; -if (parse_commit (new) <0 ) +if (parse_commit (new_commit) <0 )return 0 ; used = list =NULL ; -commit_list_insert (new, &list); +commit_list_insert (new_commit, &list);while (list) { - new =pop_most_recent_commit (&list,TMP_MARK ); -commit_list_insert (new, &used); -if (new == old) { + new_commit =pop_most_recent_commit (&list,TMP_MARK ); +commit_list_insert (new_commit, &used); +if (new_commit == old) { found =1 ;break ; }
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 26/37 split-index: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- split-index.c | 10 +++++----- split-index.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
split-index.c +5 -5
@@ -304,16 +304,16 @@ void save_or_free_index_entry(struct index_state *istate, struct cache_entry *cevoid replace_index_entry_in_base (struct index_state *istate,struct cache_entry *old, -struct cache_entry *new) +struct cache_entry *new_entry) {if (old->index && istate->split_index && istate->split_index->base && old->index <= istate->split_index->base->cache_nr) { - new->index = old->index; -if (old != istate->split_index->base->cache[new->index -1 ]) -free (istate->split_index->base->cache[new->index -1 ]); - istate->split_index->base->cache[new->index -1 ] = new; + new_entry->index = old->index; +if (old != istate->split_index->base->cache[new_entry->index -1 ]) +free (istate->split_index->base->cache[new_entry->index -1 ]); + istate->split_index->base->cache[new_entry->index -1 ] = new_entry; } }
split-index.h +1 -1
@@ -21,7 +21,7 @@ struct split_index *init_split_index(struct index_state *istate);void save_or_free_index_entry (struct index_state *istate,struct cache_entry *ce);void replace_index_entry_in_base (struct index_state *istate,struct cache_entry *old, -struct cache_entry *new); +struct cache_entry *new_entry);int read_link_extension (struct index_state *istate,const void *data,unsigned long sz); int write_link_extension(struct strbuf *sb,
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 27/37 submodule: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- submodule.c | 14 +++++++------- submodule.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-)
submodule.c +7 -7
@@ -590,7 +590,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, struct object_id *one, struct object_id *two, unsigned dirty_submodule) { - const struct object_id *old = the_hash_algo->empty_tree, *new = the_hash_algo->empty_tree; + const struct object_id *old = the_hash_algo->empty_tree, *new_oid = the_hash_algo->empty_tree;struct commit *left =NULL , *right =NULL ;struct commit_list *merge_bases =NULL ;struct child_process cp =CHILD_PROCESS_INIT ;
@@ -607,7 +607,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,if (left) old = one;if (right) - new = two; + new_oid = two; cp.git_cmd =1 ; cp.dir = path;
@@ -638,7 +638,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,* haven't yet been committed to the submodule yet. */ if (!(dirty_submodule &DIRTY_SUBMODULE_MODIFIED )) -argv_array_push (&cp.args,oid_to_hex (new)); +argv_array_push (&cp.args,oid_to_hex (new_oid));prepare_submodule_repo_env (&cp.env_array);if (start_command (&cp))
@@ -1579,7 +1579,7 @@ static void submodule_reset_index(const char *path)*/ int submodule_move_head (const char *path,const char *old, -const char *new, +const char *new_head,unsigned flags) {int ret =0 ;
@@ -1660,7 +1660,7 @@ int submodule_move_head(const char *path,if (!(flags &SUBMODULE_MOVE_HEAD_FORCE ))argv_array_push (&cp.args, old ? old :EMPTY_TREE_SHA1_HEX ); -argv_array_push (&cp.args, new ? new :EMPTY_TREE_SHA1_HEX ); +argv_array_push (&cp.args, new_head ? new_head :EMPTY_TREE_SHA1_HEX );if (run_command (&cp)) { ret =-1 ;
@@ -1668,7 +1668,7 @@ int submodule_move_head(const char *path, }if (!(flags &SUBMODULE_MOVE_HEAD_DRY_RUN )) { -if (new) { +if (new_head) {child_process_init (&cp);/* also set the HEAD accordingly */ cp.git_cmd =1 ;
@@ -1677,7 +1677,7 @@ int submodule_move_head(const char *path,prepare_submodule_repo_env (&cp.env_array);argv_array_pushl (&cp.args,"update-ref" ,"HEAD" , -"--no-deref" , new,NULL ); +"--no-deref" , new_head,NULL );if (run_command (&cp)) { ret =-1 ;
submodule.h +1 -1
@@ -117,7 +117,7 @@ int submodule_to_gitdir(struct strbuf *buf, const char *submodule);#define SUBMODULE_MOVE_HEAD_FORCE (1<<1)extern int submodule_move_head (const char *path,const char *old, -const char *new, +const char *new_head,unsigned flags);/*
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 28/37 trailer: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- trailer.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
trailer.c +17 -17
@@ -174,12 +174,12 @@ static void print_all(FILE *outfile, struct list_head *head,static struct trailer_item *trailer_from_arg (struct arg_item *arg_tok) { -struct trailer_item *new =xcalloc (sizeof (*new),1 ); - new->token = arg_tok->token; - new->value = arg_tok->value; +struct trailer_item *new_item =xcalloc (sizeof (*new_item),1 ); + new_item->token = arg_tok->token; + new_item->value = arg_tok->value; arg_tok->token = arg_tok->value =NULL ;free_arg_item (arg_tok); -return new; +return new_item; } static void add_arg_to_input_list(struct trailer_item *on_tok,
@@ -666,30 +666,30 @@ static void parse_trailer(struct strbuf *tok, struct strbuf *val,static struct trailer_item *add_trailer_item (struct list_head *head,char *tok,char *val) { -struct trailer_item *new =xcalloc (sizeof (*new),1 ); - new->token = tok; - new->value = val; -list_add_tail (&new->list, head); -return new; +struct trailer_item *new_item =xcalloc (sizeof (*new_item),1 ); + new_item->token = tok; + new_item->value = val; +list_add_tail (&new_item->list, head); +return new_item; }static void add_arg_item (struct list_head *arg_head,char *tok,char *val,const struct conf_info *conf,const struct new_trailer_item *new_trailer_item) { -struct arg_item *new =xcalloc (sizeof (*new),1 ); - new->token = tok; - new->value = val; -duplicate_conf (&new->conf, conf); +struct arg_item *new_item =xcalloc (sizeof (*new_item),1 ); + new_item->token = tok; + new_item->value = val; +duplicate_conf (&new_item->conf, conf);if (new_trailer_item) {if (new_trailer_item->where !=WHERE_DEFAULT ) - new->conf.where = new_trailer_item->where; + new_item->conf.where = new_trailer_item->where;if (new_trailer_item->if_exists !=EXISTS_DEFAULT ) - new->conf.if_exists = new_trailer_item->if_exists; + new_item->conf.if_exists = new_trailer_item->if_exists;if (new_trailer_item->if_missing !=MISSING_DEFAULT ) - new->conf.if_missing = new_trailer_item->if_missing; + new_item->conf.if_missing = new_trailer_item->if_missing; } -list_add_tail (&new->list, arg_head); +list_add_tail (&new_item->list, arg_head); } static void process_command_line_args(struct list_head *arg_head,
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 29/37 unpack-trees: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- unpack-trees.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
unpack-trees.c +3 -3
@@ -194,10 +194,10 @@ static int do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,static struct cache_entry *dup_entry (const struct cache_entry *ce) {unsigned int size =ce_size (ce); -struct cache_entry *new =xmalloc (size); +struct cache_entry *new_entry =xmalloc (size); -memcpy (new, ce, size); -return new; +memcpy (new_entry, ce, size); +return new_entry; } static void add_entry(struct unpack_trees_options *o,
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 30/37 init-db: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/init-db.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
builtin/init-db.c +15 -15
@@ -24,11 +24,11 @@ static int init_is_bare_repository = 0;static int init_shared_repository =-1 ;static const char *init_db_template_dir; -static void copy_templates_1 (struct strbuf *path,struct strbuf *template, +static void copy_templates_1 (struct strbuf *path,struct strbuf *template_path,DIR *dir) {size_t path_baselen = path->len; -size_t template_baselen = template->len; +size_t template_baselen = template_path->len;struct dirent *de;/* Note: if ".git/hooks" file exists in the repository being
@@ -44,12 +44,12 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template,int exists =0 ;strbuf_setlen (path, path_baselen); -strbuf_setlen (template, template_baselen); +strbuf_setlen (template_path, template_baselen);if (de->d_name[0 ] =='.' )continue ;strbuf_addstr (path, de->d_name); -strbuf_addstr (template, de->d_name); +strbuf_addstr (template_path, de->d_name);if (lstat (path->buf, &st_git)) {if (errno !=ENOENT )die_errno (_ ("cannot stat '%s'" ), path->buf);
@@ -57,36 +57,36 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template,else exists =1 ; -if (lstat (template->buf, &st_template)) -die_errno (_ ("cannot stat template '%s'" ), template->buf); +if (lstat (template_path->buf, &st_template)) +die_errno (_ ("cannot stat template '%s'" ), template_path->buf);if (S_ISDIR (st_template.st_mode)) { -DIR *subdir =opendir (template->buf); +DIR *subdir =opendir (template_path->buf);if (!subdir) -die_errno (_ ("cannot opendir '%s'" ), template->buf); +die_errno (_ ("cannot opendir '%s'" ), template_path->buf);strbuf_addch (path,'/' ); -strbuf_addch (template,'/' ); -copy_templates_1 (path, template, subdir); +strbuf_addch (template_path,'/' ); +copy_templates_1 (path, template_path, subdir);closedir (subdir); }else if (exists)continue ;else if (S_ISLNK (st_template.st_mode)) {struct strbuf lnk =STRBUF_INIT ; -if (strbuf_readlink (&lnk, template->buf,0 ) <0 ) -die_errno (_ ("cannot readlink '%s'" ), template->buf); +if (strbuf_readlink (&lnk, template_path->buf,0 ) <0 ) +die_errno (_ ("cannot readlink '%s'" ), template_path->buf);if (symlink (lnk.buf, path->buf))die_errno (_ ("cannot symlink '%s' '%s'" ), lnk.buf, path->buf);strbuf_release (&lnk); }else if (S_ISREG (st_template.st_mode)) { -if (copy_file (path->buf, template->buf, st_template.st_mode)) +if (copy_file (path->buf, template_path->buf, st_template.st_mode))die_errno (_ ("cannot copy '%s' to '%s'" ), - template->buf, path->buf); + template_path->buf, path->buf); }else -error (_ ("ignoring template %s" ), template->buf); +error (_ ("ignoring template %s" ), template_path->buf); } }
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 31/37 environment: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- cache.h | 2 +- environment.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
cache.h +1 -1
@@ -1673,7 +1673,7 @@ struct pack_entry {* usual "XXXXXX" trailer, and the resulting filename is written into the * "template" buffer. Returns the open descriptor. */ -extern int odb_mkstemp (struct strbuf *template,const char *pattern); +extern int odb_mkstemp (struct strbuf *temp_filename,const char *pattern);/* * Create a pack .keep file named "name" (which should generally be the output
environment.c +7 -7
@@ -247,7 +247,7 @@ char *get_object_directory(void)return the_repository->objectdir; } -int odb_mkstemp (struct strbuf *template,const char *pattern) +int odb_mkstemp (struct strbuf *temp_filename,const char *pattern) {int fd;/*
@@ -255,16 +255,16 @@ int odb_mkstemp(struct strbuf *template, const char *pattern)* restrictive except to remove write permission. */ int mode =0444 ; -git_path_buf (template,"objects/%s" , pattern); - fd =git_mkstemp_mode (template->buf, mode); +git_path_buf (temp_filename,"objects/%s" , pattern); + fd =git_mkstemp_mode (temp_filename->buf, mode);if (0 <= fd)return fd;/* slow path */ -/* some mkstemp implementations erase template on failure */ -git_path_buf (template,"objects/%s" , pattern); -safe_create_leading_directories (template->buf); -return xmkstemp_mode (template->buf, mode); +/* some mkstemp implementations erase temp_filename on failure */ +git_path_buf (temp_filename,"objects/%s" , pattern); +safe_create_leading_directories (temp_filename->buf); +return xmkstemp_mode (temp_filename->buf, mode); }int odb_pack_keep (const char *name)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 32/37 diff: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diff.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff.c +5 -5
@@ -3660,15 +3660,15 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp, int mode) {struct strbuf buf =STRBUF_INIT ; -struct strbuf template =STRBUF_INIT ; +struct strbuf tempfile =STRBUF_INIT ;char *path_dup =xstrdup (path);const char *base =basename (path_dup);/* Generate "XXXXXX_basename.ext" */ -strbuf_addstr (&template,"XXXXXX_" ); -strbuf_addstr (&template, base); +strbuf_addstr (&tempfile,"XXXXXX_" ); +strbuf_addstr (&tempfile, base); - temp->tempfile =mks_tempfile_ts (template.buf,strlen (base) +1 ); + temp->tempfile =mks_tempfile_ts (tempfile.buf,strlen (base) +1 );if (!temp->tempfile)die_errno ("unable to create temp-file" ); if (convert_to_working_tree(path,
@@ -3683,7 +3683,7 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,oid_to_hex_r (temp->hex, oid);xsnprintf (temp->mode,sizeof (temp->mode),"%06o" , mode);strbuf_release (&buf); -strbuf_release (&template); +strbuf_release (&tempfile);free (path_dup); }
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 33/37 environment: rename 'namespace' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- environment.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
environment.c +5 -5
@@ -98,7 +98,7 @@ int ignore_untracked_cache_config;/* This is set by setup_git_dir_gently() and/or git_default_config() */ char *git_work_tree_cfg; -static char *namespace; +static char *git_namespace;static const char *super_prefix;
@@ -156,8 +156,8 @@ void setup_git_env(void)free (git_replace_ref_base); git_replace_ref_base =xstrdup (replace_ref_base ? replace_ref_base :"refs/replace/" ); -free (namespace); - namespace =expand_namespace (getenv (GIT_NAMESPACE_ENVIRONMENT )); +free (git_namespace); + git_namespace =expand_namespace (getenv (GIT_NAMESPACE_ENVIRONMENT )); shallow_file =getenv (GIT_SHALLOW_FILE_ENVIRONMENT );if (shallow_file)set_alternate_shallow_file (shallow_file,0 );
@@ -191,9 +191,9 @@ const char *get_git_common_dir(void)const char *get_git_namespace (void ) { -if (!namespace) +if (!git_namespace)BUG ("git environment hasn't been setup" ); -return namespace; +return git_namespace; }const char *strip_namespace (const char *namespaced_ref)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 34/37 wrapper: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- git-compat-util.h | 4 ++-- wrapper.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 22 deletions(-)
git-compat-util.h +2 -2
@@ -826,8 +826,8 @@ extern ssize_t xpread(int fd, void *buf, size_t len, off_t offset);extern int xdup (int fd);extern FILE *xfopen (const char *path,const char *mode);extern FILE *xfdopen (int fd,const char *mode); -extern int xmkstemp (char *template); -extern int xmkstemp_mode (char *template,int mode); +extern int xmkstemp (char *temp_filename); +extern int xmkstemp_mode (char *temp_filename,int mode);extern char *xgetcwd (void );extern FILE *fopen_for_writing (const char *path);extern FILE *fopen_or_warn (const char *path,const char *mode);
wrapper.c +20 -20
@@ -445,21 +445,21 @@ FILE *fopen_or_warn(const char *path, const char *mode)return NULL ; } -int xmkstemp (char *template) +int xmkstemp (char *filename_template) {int fd;char origtemplate[PATH_MAX ]; -strlcpy (origtemplate, template,sizeof (origtemplate)); +strlcpy (origtemplate, filename_template,sizeof (origtemplate)); - fd =mkstemp (template); + fd =mkstemp (filename_template);if (fd <0 ) {int saved_errno = errno;const char *nonrelative_template; -if (strlen (template) !=strlen (origtemplate)) - template = origtemplate; +if (strlen (filename_template) !=strlen (origtemplate)) + filename_template = origtemplate; - nonrelative_template =absolute_path (template); + nonrelative_template =absolute_path (filename_template); errno = saved_errno;die_errno ("Unable to create temporary file '%s'" , nonrelative_template);
@@ -481,7 +481,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)static const int num_letters =62 ;uint64_t value;struct timeval tv; -char *template; +char *filename_template;size_t len;int fd, count;
@@ -503,16 +503,16 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)*/ gettimeofday (&tv,NULL ); value = ((size_t )(tv.tv_usec <<16 )) ^ tv.tv_sec ^getpid (); - template = &pattern[len -6 - suffix_len]; + filename_template = &pattern[len -6 - suffix_len];for (count =0 ; count <TMP_MAX ; ++count) {uint64_t v = value;/* Fill in the random bits. */ - template[0 ] = letters[v % num_letters]; v /= num_letters; - template[1 ] = letters[v % num_letters]; v /= num_letters; - template[2 ] = letters[v % num_letters]; v /= num_letters; - template[3 ] = letters[v % num_letters]; v /= num_letters; - template[4 ] = letters[v % num_letters]; v /= num_letters; - template[5 ] = letters[v % num_letters]; v /= num_letters; + filename_template[0 ] = letters[v % num_letters]; v /= num_letters; + filename_template[1 ] = letters[v % num_letters]; v /= num_letters; + filename_template[2 ] = letters[v % num_letters]; v /= num_letters; + filename_template[3 ] = letters[v % num_letters]; v /= num_letters; + filename_template[4 ] = letters[v % num_letters]; v /= num_letters; + filename_template[5 ] = letters[v % num_letters]; v /= num_letters; fd =open (pattern,O_CREAT |O_EXCL |O_RDWR , mode);if (fd >=0 )
@@ -541,21 +541,21 @@ int git_mkstemp_mode(char *pattern, int mode)return git_mkstemps_mode (pattern,0 , mode); } -int xmkstemp_mode (char *template,int mode) +int xmkstemp_mode (char *filename_template,int mode) {int fd;char origtemplate[PATH_MAX ]; -strlcpy (origtemplate, template,sizeof (origtemplate)); +strlcpy (origtemplate, filename_template,sizeof (origtemplate)); - fd =git_mkstemp_mode (template, mode); + fd =git_mkstemp_mode (filename_template, mode);if (fd <0 ) {int saved_errno = errno;const char *nonrelative_template; -if (!template[0 ]) - template = origtemplate; +if (!filename_template[0 ]) + filename_template = origtemplate; - nonrelative_template =absolute_path (template); + nonrelative_template =absolute_path (filename_template); errno = saved_errno;die_errno ("Unable to create temporary file '%s'" , nonrelative_template);
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 35/37 tempfile: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- tempfile.c | 12 ++++++------ tempfile.h | 34 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 23 deletions(-)
tempfile.c +6 -6
@@ -165,11 +165,11 @@ struct tempfile *register_tempfile(const char *path)return tempfile; } -struct tempfile *mks_tempfile_sm (const char *template,int suffixlen,int mode) +struct tempfile *mks_tempfile_sm (const char *filename_template,int suffixlen,int mode) {struct tempfile *tempfile =new_tempfile (); -strbuf_add_absolute_path (&tempfile->filename, template); +strbuf_add_absolute_path (&tempfile->filename, filename_template); tempfile->fd =git_mkstemps_mode (tempfile->filename.buf, suffixlen, mode);if (tempfile->fd <0 ) {deactivate_tempfile (tempfile);
@@ -179,7 +179,7 @@ struct tempfile *mks_tempfile_sm(const char *template, int suffixlen, int mode)return tempfile; } -struct tempfile *mks_tempfile_tsm (const char *template,int suffixlen,int mode) +struct tempfile *mks_tempfile_tsm (const char *filename_template,int suffixlen,int mode) {struct tempfile *tempfile =new_tempfile ();const char *tmpdir;
@@ -188,7 +188,7 @@ struct tempfile *mks_tempfile_tsm(const char *template, int suffixlen, int mode)if (!tmpdir) tmpdir ="/tmp" ; -strbuf_addf (&tempfile->filename,"%s/%s" , tmpdir, template); +strbuf_addf (&tempfile->filename,"%s/%s" , tmpdir, filename_template); tempfile->fd =git_mkstemps_mode (tempfile->filename.buf, suffixlen, mode);if (tempfile->fd <0 ) {deactivate_tempfile (tempfile);
@@ -198,12 +198,12 @@ struct tempfile *mks_tempfile_tsm(const char *template, int suffixlen, int mode)return tempfile; } -struct tempfile *xmks_tempfile_m (const char *template,int mode) +struct tempfile *xmks_tempfile_m (const char *filename_template,int mode) {struct tempfile *tempfile;struct strbuf full_template =STRBUF_INIT ; -strbuf_add_absolute_path (&full_template, template); +strbuf_add_absolute_path (&full_template, filename_template); tempfile =mks_tempfile_m (full_template.buf, mode);if (!tempfile) die_errno("Unable to create temporary file '%s'",
tempfile.h +17 -17
@@ -135,58 +135,58 @@ extern struct tempfile *register_tempfile(const char *path);*/ /* See "mks_tempfile functions" above. */ -extern struct tempfile *mks_tempfile_sm (const char *template, +extern struct tempfile *mks_tempfile_sm (const char *filename_template,int suffixlen,int mode);/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_s (const char *template, +static inline struct tempfile *mks_tempfile_s (const char *filename_template,int suffixlen) { -return mks_tempfile_sm (template, suffixlen,0600 ); +return mks_tempfile_sm (filename_template, suffixlen,0600 ); }/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_m (const char *template,int mode) +static inline struct tempfile *mks_tempfile_m (const char *filename_template,int mode) { -return mks_tempfile_sm (template,0 , mode); +return mks_tempfile_sm (filename_template,0 , mode); }/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile (const char *template) +static inline struct tempfile *mks_tempfile (const char *filename_template) { -return mks_tempfile_sm (template,0 ,0600 ); +return mks_tempfile_sm (filename_template,0 ,0600 ); }/* See "mks_tempfile functions" above. */ -extern struct tempfile *mks_tempfile_tsm (const char *template, +extern struct tempfile *mks_tempfile_tsm (const char *filename_template,int suffixlen,int mode);/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_ts (const char *template, +static inline struct tempfile *mks_tempfile_ts (const char *filename_template,int suffixlen) { -return mks_tempfile_tsm (template, suffixlen,0600 ); +return mks_tempfile_tsm (filename_template, suffixlen,0600 ); }/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_tm (const char *template,int mode) +static inline struct tempfile *mks_tempfile_tm (const char *filename_template,int mode) { -return mks_tempfile_tsm (template,0 , mode); +return mks_tempfile_tsm (filename_template,0 , mode); }/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_t (const char *template) +static inline struct tempfile *mks_tempfile_t (const char *filename_template) { -return mks_tempfile_tsm (template,0 ,0600 ); +return mks_tempfile_tsm (filename_template,0 ,0600 ); }/* See "mks_tempfile functions" above. */ -extern struct tempfile *xmks_tempfile_m (const char *template,int mode); +extern struct tempfile *xmks_tempfile_m (const char *filename_template,int mode);/* See "mks_tempfile functions" above. */ -static inline struct tempfile *xmks_tempfile (const char *template) +static inline struct tempfile *xmks_tempfile (const char *filename_template) { -return xmks_tempfile_m (template,0600 ); +return xmks_tempfile_m (filename_template,0600 ); }/*
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 36/37 trailer: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- trailer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
trailer.c +5 -5
@@ -1000,7 +1000,7 @@ static struct tempfile *trailers_tempfile;static FILE *create_in_place_tempfile (const char *file) {struct stat st; -struct strbuf template =STRBUF_INIT ; +struct strbuf filename_template =STRBUF_INIT ;const char *tail;FILE *outfile;
@@ -1014,11 +1014,11 @@ static FILE *create_in_place_tempfile(const char *file)/* Create temporary file in the same directory as the original */ tail =strrchr (file,'/' );if (tail !=NULL ) -strbuf_add (&template, file, tail - file +1 ); -strbuf_addstr (&template,"git-interpret-trailers-XXXXXX" ); +strbuf_add (&filename_template, file, tail - file +1 ); +strbuf_addstr (&filename_template,"git-interpret-trailers-XXXXXX" ); - trailers_tempfile =xmks_tempfile_m (template.buf, st.st_mode); -strbuf_release (&template); + trailers_tempfile =xmks_tempfile_m (filename_template.buf, st.st_mode); +strbuf_release (&filename_template); outfile =fdopen_tempfile (trailers_tempfile,"w" );if (!outfile)die_errno (_ ("could not open temporary file" ));
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
PATCH 37/37 replace: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/replace.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
builtin/replace.c +8 -8
@@ -284,7 +284,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw) {char *tmpfile =git_pathdup ("REPLACE_EDITOBJ" );enum object_type type; -struct object_id old, new, prev; +struct object_id old, new_oid, prev;struct strbuf ref =STRBUF_INIT ;if (get_oid (object_ref, &old) <0 )
@@ -300,14 +300,14 @@ static int edit_and_replace(const char *object_ref, int force, int raw)export_object (&old, type, raw, tmpfile);if (launch_editor (tmpfile,NULL ,NULL ) <0 )die ("editing object file failed" ); -import_object (&new, type, raw, tmpfile); +import_object (&new_oid, type, raw, tmpfile);free (tmpfile); -if (!oidcmp (&old, &new)) +if (!oidcmp (&old, &new_oid))return error ("new object is the same as the old one: '%s'" ,oid_to_hex (&old)); -return replace_object_oid (object_ref, &old,"replacement" , &new, force); +return replace_object_oid (object_ref, &old,"replacement" , &new_oid, force); }static void replace_parents (struct strbuf *buf,int argc,const char **argv)
@@ -386,7 +386,7 @@ static void check_mergetags(struct commit *commit, int argc, const char **argv)static int create_graft (int argc,const char **argv,int force) { -struct object_id old, new; +struct object_id old, new_oid;const char *old_ref = argv[0 ];struct commit *commit;struct strbuf buf =STRBUF_INIT ;
@@ -410,15 +410,15 @@ static int create_graft(int argc, const char **argv, int force)check_mergetags (commit, argc, argv); -if (write_sha1_file (buf.buf, buf.len, commit_type, new.hash)) +if (write_sha1_file (buf.buf, buf.len, commit_type, new_oid.hash))die (_ ("could not write replacement commit for: '%s'" ), old_ref);strbuf_release (&buf); -if (!oidcmp (&old, &new)) +if (!oidcmp (&old, &new_oid))return error ("new commit is the same as the old one: '%s'" ,oid_to_hex (&old)); -return replace_object_oid (old_ref, &old,"replacement" , &new, force); +return replace_object_oid (old_ref, &old,"replacement" , &new_oid, force); }int cmd_replace (int argc,const char **argv,const char *prefix)
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
Re: [PATCH 37/37] replace: rename 'new' variables
Quoted 13 lines · Brandon Williams
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
Signed-off-by Brandon Williams <[email protected]>--- builtin/replace.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)builtin/replace.c +0
-0
builtin/replace.c static int edit_and_replace(const char *object_ref, int force, int raw) · line 287
Quoted 5 lines
builtin/replace.c +1
-1@@ -284,7 +284,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw) {char *tmpfile =git_pathdup ("REPLACE_EDITOBJ" );enum object_type type; -struct object_id old, new, prev; +struct object_id old, new_oid, prev;
new is a keyword that often comes with a counterpart, here old. So while at it, also rename old to old_oid ?
Do we care about the symmetry enough to warrant additional churn for this?
Stefan
Re: [PATCH 37/37] replace: rename 'new' variables
Quoted 9 lines · Stefan Beller
Quoted 8 lines · Brandon Williams
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
Signed-off-by Brandon Williams <[email protected]>--- builtin/replace.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Quoted 14 lines
builtin/replace.c static int edit_and_replace(const char *object_ref, int force, int raw) · line 287
Quoted 10 lines
builtin/replace.c +1
-1@@ -284,7 +284,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw) {char *tmpfile =git_pathdup ("REPLACE_EDITOBJ" );enum object_type type; -struct object_id old, new, prev; +struct object_id old, new_oid, prev;new is a keyword that often comes with a counterpart, here
old. So while at it, also rename old toold_oid?
Do we care about the symmetry enough to warrant additional churn for this?
Absolutely. That is one of the reasons why the "hacky" approach is so attractive---it does not force those who are doing conversion to think. With this approach, "new" in this context gets replaced with new_oid (because this is about oid; in another codepath, "new" and "old" might have been referring to a file and the new names for them would have been "new_file" vs "old_file") after some thought, and the same thought process should realize "old" must become "old_oid".
Very good point.
Quoted 3 lines · Brandon Williams
A while back there was some discussion of getting our codebase into a state where we could use a c++ compiler if we wanted to (for various reason like leveraging c++ only analysis tools, etc.). Johannes Sixt had a very large
I would be more convinced if I knew exactly what leverage we could have here (e.g. what tool, how many problems it caught...).
Quoted 5 lines
patch that achieved this but it wasn't in a state where it could be upstreamed. I took that idea and did some removals of c++ keywords (new, template, try, this, etc) but broke it up into several (well maybe more than several) patches. I don't believe I've captured all of them in this series but this is at least moving a step closer to being able to compile using a c++ compiler.
Is it simpler (though hacky) to just do
#ifdef __cplusplus
#define new not_new
#define try really_try
...
somewhere in git-compat-util.h?
Do we use any C features that are incompatible with C++? (or do we not need to care?)
Quoted 3 lines
I don't know if this is something the community still wants to move towards, but if this is something people are still interested in, and this series is wanted, then we can keep doing these sort of conversions in chunks slowly.
You're going to need to setup C++ build job on Travis or something to catch new C++ keywords from entering the code base as well if you move this to the end.
Signature · 1 line
Duy
Quoted 8 lines · Duy Nguyen
Is it simpler (though hacky) to just do
#ifdef
__cplusplus
#define newnot_new
#define tryreally_try
...somewhere in
git-compat-util.h?
Very tempting, especially given that your approach automatically would cover topics in flight without any merge conflict ;-)
I agree that it is hacky and somewhat ugly, but the hackiness somehow does not bother me too much in this case; perhaps because attempting to use a C++ compiler may already be hacky in the first place?
It probably depends on the reason why we are doing this topic. If a report about our source code coming from the C++ oriented tool cite the symbol names seen by machines, then the "hacky" approach will give us "not_new" where Brandon's patch may give us "new_oid", or whatever symbol that is more appropriate for the context it appears than such an automated cute name.
Quoted 2 lines
Do we use any C features that are incompatible with C++? (or do we not need to care?)
Good question.
Quoted 26 lines · Junio C Hamano
Quoted 8 lines · Duy Nguyen
Is it simpler (though hacky) to just do
#ifdef
__cplusplus
#define newnot_new
#define tryreally_try
...somewhere in
git-compat-util.h?Very tempting, especially given that your approach automatically would cover topics in flight without any merge conflict ;-)
I agree that it is hacky and somewhat ugly, but the hackiness somehow does not bother me too much in this case; perhaps because attempting to use a C++ compiler may already be hacky in the first place?
It probably depends on the reason why we are doing this topic. If a report about our source code coming from the C++ oriented tool cite the symbol names seen by machines, then the "hacky" approach will give us "
not_new" where Brandon's patch may give us "new_oid", or whatever symbol that is more appropriate for the context it appears than such an automated cute name.
Quoted 4 lines
Quoted 2 lines
Do we use any C features that are incompatible with C++? (or do we not need to care?)
Good question.
implicit casts from void?
e.g. xmalloc returns a void pointer, not the type requested.
https://embeddedartistry.com/blog/2017/2/28/c-casting-or-oh-no-we-broke-malloc
Quoted 20 lines · Stefan Beller
Quoted 19 lines · Junio C Hamano
Quoted 8 lines · Duy Nguyen
Is it simpler (though hacky) to just do
#ifdef
__cplusplus
#define newnot_new
#define tryreally_try
...somewhere in
git-compat-util.h?Very tempting, especially given that your approach automatically would cover topics in flight without any merge conflict ;-)
I agree that it is hacky and somewhat ugly, but the hackiness somehow does not bother me too much in this case; perhaps because attempting to use a C++ compiler may already be hacky in the first place?
Quoted 6 lines
Quoted 6 lines
It probably depends on the reason why we are doing this topic. If a report about our source code coming from the C++ oriented tool cite the symbol names seen by machines, then the "hacky" approach will give us "
not_new" where Brandon's patch may give us "new_oid", or whatever symbol that is more appropriate for the context it appears than such an automated cute name.
Well. the world after post processing is always ugly. But we could try "#define new new__" to get the not so ugly names. new_oid is definitely better regardless of c/c++ though so I could see that as a good cleanup.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Do we use any C features that are incompatible with C++? (or do we not need to care?)
Good question.
implicit casts from void?
e.g. xmalloc returns a void pointer, not the type requested.
https://embeddedartistry.com/blog/2017/2/28/c-casting-or-oh-no-we-broke-malloc
That causes lots of warnings but not errors (I bit the bullet and tried to compile git with g++). The next set of changes would be to reorganize nested enum/struct declarations. Even if nested, C considers these flat while C++ sees them in namespaces. There's some warnings about confusion with the new cool feature string literals, but that's easy to fix.
There's also C99 designator in builtin/clean.c (I thought we avoided C99, I can start using this specific feature more now :D)
I was stuck at the thread_local thing in index-pack.c and gave up. So I don't know what else we would need to change.
Signature · 1 line
Duy
Quoted 36 lines · Duy Nguyen
Quoted 20 lines · Stefan Beller
Quoted 19 lines · Junio C Hamano
Quoted 8 lines · Duy Nguyen
Is it simpler (though hacky) to just do
#ifdef
__cplusplus
#define newnot_new
#define tryreally_try
...somewhere in
git-compat-util.h?Very tempting, especially given that your approach automatically would cover topics in flight without any merge conflict ;-)
I agree that it is hacky and somewhat ugly, but the hackiness somehow does not bother me too much in this case; perhaps because attempting to use a C++ compiler may already be hacky in the first place?
Quoted 6 lines
Quoted 6 lines
It probably depends on the reason why we are doing this topic. If a report about our source code coming from the C++ oriented tool cite the symbol names seen by machines, then the "hacky" approach will give us "
not_new" where Brandon's patch may give us "new_oid", or whatever symbol that is more appropriate for the context it appears than such an automated cute name.Well. the world after post processing is always ugly. But we could try "#define new
new__" to get the not so ugly names.new_oidis definitely better regardless of c/c++ though so I could see that as a good cleanup.Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Do we use any C features that are incompatible with C++? (or do we not need to care?)
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Good question.
implicit casts from void?
e.g. xmalloc returns a void pointer, not the type requested.
https://embeddedartistry.com/blog/2017/2/28/c-casting-or-oh-no-we-broke-mallocThat causes lots of warnings but not errors (I bit the bullet and tried to compile git with g++).
And for g++ there is a flag to disable this specific set of warnings. I think the value of using C++ analysis tools is in the LLVM/clang world, not GNU.
Quoted 8 lines
The next set of changes would be to
reorganize nested enum/struct declarations. Even if nested, C considers these flat while C++ sees them in namespaces. There's some warnings about confusion with the new cool feature string literals, but that's easy to fix.There's also C99 designator in
builtin/clean.c(I thought we avoided C99, I can start using this specific feature more now :D)
That was a test balloon? See 512f41cfac
(clean.c: use designated initializer, 2017-07-14)
One of the big advantages would be stricter type checking, such as signed/unsigned confusion, that we occasionally have. e.g. 61d36330b4 (prefer "!=" when checking read_in_full() result, 2017-09-27) or what is referenced from there 561598cfcf (read_pack_header: handle signed/unsigned comparison in read result, 2017-09-13).
The bugs resulting in these patches could have been caught more easily with C++ checking IMHO.
Quoted 2 lines
I was stuck at the
thread_localthing inindex-pack.cand gave up. So I don't know what else we would need to change.
Thanks for experimenting!
Stefan
Quoted 2 lines
--
Duy
Quoted 5 lines · Stefan Beller
Quoted 2 lines
There's also C99 designator in
builtin/clean.c(I thought we avoided C99, I can start using this specific feature more now :D)That was a test balloon? See
512f41cfac
(clean.c: use designated initializer, 2017-07-14)
Aww.. I thought it was in there since forever and it should be safe to use now...
Quoted 6 lines
One of the big advantages would be stricter type checking, such as signed/unsigned confusion, that we occasionally have. e.g.
61d36330b4(prefer "!=" when checkingread_in_full()result, 2017-09-27) or what is referenced from there561598cfcf(read_pack_header: handle signed/unsigned comparison in read result, 2017-09-13).
We can do that even with C (at least with gcc and I guess clang as well). The problem is it looks so bad right now that I have to turn it off with -Wno-sign-compare
Quoted 2 lines
The bugs resulting in these patches could have been caught more easily with C++ checking IMHO.
Signature · 1 line
Duy
Am 29.01.2018 um 23:36 schrieb Brandon Williams:
Quoted 8 lines
A while back there was some discussion of getting our codebase into a state where we could use a c++ compiler if we wanted to (for various reason like leveraging c++ only analysis tools, etc.). Johannes Sixt had a very large patch that achieved this but it wasn't in a state where it could be upstreamed. I took that idea and did some removals of c++ keywords (new, template, try, this, etc) but broke it up into several (well maybe more than several) patches. I don't believe I've captured all of them in this series but this is at least moving a step closer to being able to compile using a c++ compiler.
Cool! The patches all look reasonable. Some keywords remain: 'delete', 'private', 'thread_local', 'not', 'xor', 'explicit', 'export'.
Quoted 3 lines
I don't know if this is something the community still wants to move towards, but if this is something people are still interested in, and this series is wanted, then we can keep doing these sort of conversions in chunks slowly.
I've rebased my patches on top of this series. They are available from
https://github.com/j6t/git.git c-plus-plus
-- Hannes
v2 cover removal of some c++ keywords
In reply to Brandon WilliamsOne person was interested enough for me to go back through and also rename all the paired 'old' variables to match the new names for the variables which were named 'new'.
Brandon Williams (37):
object_info: change member name from 'typename' to 'type_name'
object: rename function 'typename' to 'type_name'
blame: rename 'this' variables
pack-objects: rename 'this' variables
rev-parse: rename 'this' variable
diff: rename 'this' variables
apply: rename 'try' variables
apply: rename 'new' variables
checkout: rename 'new' variables
help: rename 'new' variables
pack-redundant: rename 'new' variables
reflog: rename 'new' variables
remote: rename 'new' variables
combine-diff: rename 'new' variables
commit: rename 'new' variables
diff-lib: rename 'new' variable
diff: rename 'new' variables
diffcore-delta: rename 'new' variables
entry: rename 'new' variables
http: rename 'new' variables
imap-send: rename 'new' variables
line-log: rename 'new' variables
read-cache: rename 'new' variables
ref-filter: rename 'new' variables
remote: rename 'new' variables
split-index: rename 'new' variables
submodule: rename 'new' variables
trailer: rename 'new' variables
unpack-trees: rename 'new' variables
init-db: rename 'template' variables
environment: rename 'template' variables
diff: rename 'template' variables
environment: rename 'namespace' variables
wrapper: rename 'template' variables
tempfile: rename 'template' variables
trailer: rename 'template' variables
replace: rename 'new' variables
apply.c | 122 +++++++-------- blame.c | 33 +++-- builtin/cat-file.c | 4 +- builtin/checkout.c | 196 ++++++++++++------------- builtin/diff-tree.c | 2 +- builtin/fast-export.c | 8 +- builtin/fsck.c | 4 +- builtin/grep.c | 2 +- builtin/help.c | 10 +- builtin/index-pack.c | 12 +- builtin/init-db.c | 30 ++-- builtin/merge.c | 2 +- builtin/mktree.c | 4 +- builtin/pack-objects.c | 8 +- builtin/pack-redundant.c | 54 +++---- builtin/prune.c | 2 +- builtin/reflog.c | 8 +- builtin/remote.c | 66 ++++----- builtin/replace.c | 46 +++--- builtin/rev-parse.c | 34 ++--- builtin/tag.c | 2 +- builtin/unpack-objects.c | 10 +- builtin/verify-commit.c | 2 +- bulk-checkin.c | 2 +- cache.h | 4 +- combine-diff.c | 12 +- commit.c | 20 +-- contrib/examples/builtin-fetch--tool.c | 2 +- diff-lib.c | 38 ++--- diff.c | 62 ++++---- diffcore-delta.c | 16 +- entry.c | 40 ++--- environment.c | 24 +-- fast-import.c | 16 +- fsck.c | 2 +- git-compat-util.h | 4 +- http-push.c | 2 +- http.c | 10 +- imap-send.c | 14 +- line-log.c | 56 +++---- log-tree.c | 2 +- object.c | 6 +- object.h | 2 +- pack-check.c | 2 +- packfile.c | 8 +- reachable.c | 2 +- read-cache.c | 40 ++--- ref-filter.c | 20 +-- remote.c | 20 +-- sequencer.c | 2 +- sha1_file.c | 28 ++-- sha1_name.c | 6 +- split-index.c | 16 +- split-index.h | 2 +- submodule.c | 32 ++-- submodule.h | 2 +- tag.c | 2 +- tempfile.c | 12 +- tempfile.h | 34 ++--- trailer.c | 44 +++--- unpack-trees.c | 6 +- walker.c | 4 +- wrapper.c | 40 ++--- 63 files changed, 659 insertions(+), 658 deletions(-)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 1/37 object_info: change member name from 'typename' to 'type_name'
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/cat-file.c | 2 +- cache.h | 2 +- packfile.c | 6 +++--- sha1_file.c | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-)
builtin/cat-file.c +1 -1
@@ -76,7 +76,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, buf =NULL ;switch (opt) {case 't' : - oi.typename = &sb; + oi.type_name = &sb;if (sha1_object_info_extended (oid.hash, &oi, flags) <0 )die ("git cat-file: could not get object info" );if (sb.len) {
cache.h +1 -1
@@ -1744,7 +1744,7 @@ struct object_info {unsigned long *sizep;off_t *disk_sizep;unsigned char *delta_base_sha1; -struct strbuf *typename; +struct strbuf *type_name;void **contentp;/* Response */
packfile.c +3 -3
@@ -1350,16 +1350,16 @@ int packed_object_info(struct packed_git *p, off_t obj_offset, *oi->disk_sizep = revidx[1 ].offset - obj_offset; } -if (oi->typep || oi->typename) { +if (oi->typep || oi->type_name) {enum object_type ptot; ptot =packed_to_object_type (p, obj_offset, type, &w_curs, curpos);if (oi->typep) *oi->typep = ptot; -if (oi->typename) { +if (oi->type_name) {const char *tn =typename (ptot);if (tn) -strbuf_addstr (oi->typename, tn); +strbuf_addstr (oi->type_name, tn); }if (ptot <0 ) { type =OBJ_BAD ;
sha1_file.c +5 -5
@@ -1087,8 +1087,8 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi, } type =type_from_string_gently (type_buf, type_len,1 ); -if (oi->typename) -strbuf_add (oi->typename, type_buf, type_len); +if (oi->type_name) +strbuf_add (oi->type_name, type_buf, type_len);/* * Set type to 0 if its an unknown object and * we're obtaining the type using '--allow-unknown-type'
@@ -1158,7 +1158,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,* return value implicitly indicates whether the * object even exists. */ -if (!oi->typep && !oi->typename && !oi->sizep && !oi->contentp) { +if (!oi->typep && !oi->type_name && !oi->sizep && !oi->contentp) {const char *path;struct stat st;if (stat_sha1_file (sha1, &st, &path) <0 )
@@ -1239,8 +1239,8 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi, *(oi->disk_sizep) =0 ;if (oi->delta_base_sha1)hashclr (oi->delta_base_sha1); -if (oi->typename) -strbuf_addstr (oi->typename,typename (co->type)); +if (oi->type_name) +strbuf_addstr (oi->type_name,typename (co->type));if (oi->contentp) *oi->contentp =xmemdupz (co->buf, co->size); oi->whence =OI_CACHED ;
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 2/37 object: rename function 'typename' to 'type_name'
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/cat-file.c | 2 +- builtin/diff-tree.c | 2 +- builtin/fast-export.c | 8 ++++---- builtin/fsck.c | 4 ++-- builtin/grep.c | 2 +- builtin/index-pack.c | 12 ++++++------ builtin/merge.c | 2 +- builtin/mktree.c | 4 ++-- builtin/prune.c | 2 +- builtin/replace.c | 12 ++++++------ builtin/tag.c | 2 +- builtin/unpack-objects.c | 10 +++++----- builtin/verify-commit.c | 2 +- bulk-checkin.c | 2 +- commit.c | 2 +- contrib/examples/builtin-fetch--tool.c | 2 +- fast-import.c | 16 ++++++++-------- fsck.c | 2 +- http-push.c | 2 +- log-tree.c | 2 +- object.c | 6 +++--- object.h | 2 +- pack-check.c | 2 +- packfile.c | 2 +- reachable.c | 2 +- ref-filter.c | 4 ++-- sequencer.c | 2 +- sha1_file.c | 20 ++++++++++---------- sha1_name.c | 6 +++--- submodule.c | 2 +- tag.c | 2 +- walker.c | 4 ++-- 32 files changed, 73 insertions(+), 73 deletions(-)
builtin/cat-file.c +1 -1
@@ -229,7 +229,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,if (data->mark_query) data->info.typep = &data->type;else -strbuf_addstr (sb,typename (data->type)); +strbuf_addstr (sb,type_name (data->type)); }else if (is_atom ("objectsize" , atom, len)) {if (data->mark_query) data->info.sizep = &data->size;
builtin/diff-tree.c +1 -1
@@ -76,7 +76,7 @@ static int diff_tree_stdin(char *line)if (obj->type ==OBJ_TREE )return stdin_diff_trees ((struct tree *)obj, p);error ("Object %s is a %s, not a commit or tree" , -oid_to_hex (&oid),typename (obj->type)); +oid_to_hex (&oid),type_name (obj->type));return -1 ; }
builtin/fast-export.c +4 -4
@@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid) buf =read_sha1_file (oid->hash, &type, &size);if (!buf)die ("Could not read blob %s" ,oid_to_hex (oid)); -if (check_sha1_signature (oid->hash, buf, size,typename (type)) <0 ) +if (check_sha1_signature (oid->hash, buf, size,type_name (type)) <0 )die ("sha1 mismatch in blob %s" ,oid_to_hex (oid)); object =parse_object_buffer (oid, type, size, buf, &eaten); }
@@ -757,7 +757,7 @@ static void handle_tag(const char *name, struct tag *tag)if (tagged->type !=OBJ_COMMIT ) {die ("Tag %s tags unexported %s!" ,oid_to_hex (&tag->object.oid), -typename (tagged->type)); +type_name (tagged->type)); } p = (struct commit *)tagged;for (;;) {
@@ -839,7 +839,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)if (!commit) {warning ("%s: Unexpected object of type %s, skipping." , e->name, -typename (e->item->type)); +type_name (e->item->type));continue ; }
@@ -851,7 +851,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)continue ;default :/* OBJ_TAG (nested tags) is already handled */ warning ("Tag points to object of unexpected type %s, skipping." , -typename (commit->object.type)); +type_name (commit->object.type));continue ; }
builtin/fsck.c +2 -2
@@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)object_as_type (obj, type,0 ); } - ret =typename (obj->type); + ret =type_name (obj->type);if (!ret) ret ="unknown" ;
@@ -137,7 +137,7 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_optprintf ("broken link from %7s %s\n" ,printable_type (parent),describe_object (parent));printf ("broken link from %7s %s\n" , - (type ==OBJ_ANY ?"unknown" :typename (type)),"unknown" ); + (type ==OBJ_ANY ?"unknown" :type_name (type)),"unknown" ); errors_found |=ERROR_REACHABLE ;return 1 ; }
builtin/grep.c +1 -1
@@ -627,7 +627,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,free (data);return hit; } -die (_ ("unable to grep from object of type %s" ),typename (obj->type)); +die (_ ("unable to grep from object of type %s" ),type_name (obj->type)); } static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
builtin/index-pack.c +6 -6
@@ -228,7 +228,7 @@ static unsigned check_object(struct object *obj)if (type != obj->type)die (_ ("object %s: expected type %s, found %s" ),oid_to_hex (&obj->oid), -typename (obj->type),typename (type)); +type_name (obj->type),type_name (type)); obj->flags |=FLAG_CHECKED ;return 1 ; }
@@ -448,7 +448,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,int hdrlen;if (!is_delta_type (type)) { - hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,typename (type), size) +1 ; + hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (type), size) +1 ;git_SHA1_Init (&c);git_SHA1_Update (&c, hdr, hdrlen); }else
@@ -849,7 +849,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, obj =parse_object_buffer (oid, type, size, buf, &eaten);if (!obj) -die (_ ("invalid %s" ),typename (type)); +die (_ ("invalid %s" ),type_name (type));if (do_fsck_object &&fsck_object (obj, buf, size, &fsck_options))die (_ ("Error in object" ));
@@ -959,7 +959,7 @@ static void resolve_delta(struct object_entry *delta_obj,if (!result->data)bad_object (delta_obj->idx.offset,_ ("failed to apply delta" ));hash_sha1_file (result->data, result->size, -typename (delta_obj->real_type), +type_name (delta_obj->real_type), delta_obj->idx.oid.hash);sha1_object (result->data,NULL , result->size, delta_obj->real_type, &delta_obj->idx.oid);
@@ -1379,7 +1379,7 @@ static void fix_unresolved_deltas(struct sha1file *f)continue ;if (check_sha1_signature (d->sha1, base_obj->data, - base_obj->size,typename (type))) + base_obj->size,type_name (type)))die (_ ("local object %s is corrupt" ),sha1_to_hex (d->sha1)); base_obj->obj =append_obj_to_pack (f, d->sha1, base_obj->data, base_obj->size, type);
@@ -1588,7 +1588,7 @@ static void show_pack_info(int stat_only)continue ;printf ("%s %-6s %lu %lu %" PRIuMAX,oid_to_hex (&obj->idx.oid), -typename (obj->real_type), obj->size, +type_name (obj->real_type), obj->size, (unsigned long )(obj[1 ].idx.offset - obj->idx.offset), (uintmax_t )obj->idx.offset);if (is_delta_type (obj->type)) {
builtin/merge.c +1 -1
@@ -520,7 +520,7 @@ static void merge_name(const char *remote, struct strbuf *msg)if (desc && desc->obj && desc->obj->type ==OBJ_TAG ) {strbuf_addf (msg,"%s\t\t%s '%s'\n" ,oid_to_hex (&desc->obj->oid), -typename (desc->obj->type), +type_name (desc->obj->type), remote); goto cleanup; }
builtin/mktree.c +2 -2
@@ -112,7 +112,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss mode_type =object_type (mode);if (mode_type !=type_from_string (ptr)) {die ("entry '%s' object type (%s) doesn't match mode type (%s)" , - path, ptr,typename (mode_type)); + path, ptr,type_name (mode_type)); }/* Check the type of object identified by sha1 */
@@ -131,7 +131,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss* because the new tree entry will never be correct. */ die ("entry '%s' object %s is a %s but specified type was (%s)" , - path,sha1_to_hex (sha1),typename (obj_type),typename (mode_type)); + path,sha1_to_hex (sha1),type_name (obj_type),type_name (mode_type)); } }
builtin/prune.c +1 -1
@@ -52,7 +52,7 @@ static int prune_object(const struct object_id *oid, const char *fullpath,if (show_only || verbose) {enum object_type type =sha1_object_info (oid->hash,NULL );printf ("%s %s\n" ,oid_to_hex (oid), - (type >0 ) ?typename (type) :"unknown" ); + (type >0 ) ?type_name (type) :"unknown" ); }if (!show_only)unlink_or_warn (fullpath);
builtin/replace.c +6 -6
@@ -56,8 +56,8 @@ static int show_reference(const char *refname, const struct object_id *oid, obj_type =sha1_object_info (object.hash,NULL ); repl_type =sha1_object_info (oid->hash,NULL ); -printf ("%s (%s) -> %s (%s)\n" , refname,typename (obj_type), -oid_to_hex (oid),typename (repl_type)); +printf ("%s (%s) -> %s (%s)\n" , refname,type_name (obj_type), +oid_to_hex (oid),type_name (repl_type)); } }
@@ -168,8 +168,8 @@ static int replace_object_oid(const char *object_ref,die ("Objects must be of the same type.\n" "'%s' points to a replaced object of type '%s'\n" "while '%s' points to a replacement object of type '%s'." , - object_ref,typename (obj_type), - replace_ref,typename (repl_type)); + object_ref,type_name (obj_type), + replace_ref,type_name (repl_type));check_ref_valid (object, &prev, &ref, force);
@@ -215,7 +215,7 @@ static void export_object(const struct object_id *oid, enum object_type type,argv_array_push (&cmd.args,"--no-replace-objects" );argv_array_push (&cmd.args,"cat-file" );if (raw) -argv_array_push (&cmd.args,typename (type)); +argv_array_push (&cmd.args,type_name (type));else argv_array_push (&cmd.args,"-p" );argv_array_push (&cmd.args,oid_to_hex (oid));
@@ -355,7 +355,7 @@ static void check_one_mergetag(struct commit *commit,struct tag *tag;int i; -hash_sha1_file (extra->value, extra->len,typename (OBJ_TAG ), tag_oid.hash); +hash_sha1_file (extra->value, extra->len,type_name (OBJ_TAG ), tag_oid.hash); tag =lookup_tag (&tag_oid);if (!tag)die (_ ("bad mergetag in commit '%s'" ), ref);
builtin/tag.c +1 -1
@@ -220,7 +220,7 @@ static void create_tag(const struct object_id *object, const char *tag,"tag %s\n" "tagger %s\n\n" ,oid_to_hex (object), -typename (type), +type_name (type), tag, git_committer_info(IDENT_STRICT));
builtin/unpack-objects.c +5 -5
@@ -172,7 +172,7 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf) {struct object_id oid; -if (write_sha1_file (obj_buf->buffer, obj_buf->size,typename (obj->type), oid.hash) <0 ) +if (write_sha1_file (obj_buf->buffer, obj_buf->size,type_name (obj->type), oid.hash) <0 )die ("failed to write object %s" ,oid_to_hex (&obj->oid)); obj->flags |=FLAG_WRITTEN ; }
@@ -237,14 +237,14 @@ static void write_object(unsigned nr, enum object_type type, void *buf, unsigned long size) {if (!strict) { -if (write_sha1_file (buf, size,typename (type), obj_list[nr].oid.hash) <0 ) +if (write_sha1_file (buf, size,type_name (type), obj_list[nr].oid.hash) <0 )die ("failed to write object" );added_object (nr, type, buf, size);free (buf); obj_list[nr].obj =NULL ; }else if (type ==OBJ_BLOB ) {struct blob *blob; -if (write_sha1_file (buf, size,typename (type), obj_list[nr].oid.hash) <0 ) +if (write_sha1_file (buf, size,type_name (type), obj_list[nr].oid.hash) <0 )die ("failed to write object" );added_object (nr, type, buf, size);free (buf);
@@ -258,12 +258,12 @@ static void write_object(unsigned nr, enum object_type type, }else {struct object *obj;int eaten; -hash_sha1_file (buf, size,typename (type), obj_list[nr].oid.hash); +hash_sha1_file (buf, size,type_name (type), obj_list[nr].oid.hash);added_object (nr, type, buf, size); obj =parse_object_buffer (&obj_list[nr].oid, type, size, buf, &eaten);if (!obj) -die ("invalid %s" ,typename (type)); +die ("invalid %s" ,type_name (type));add_object_buffer (obj, buf, size); obj->flags |=FLAG_OPEN ; obj_list[nr].obj = obj;
builtin/verify-commit.c +1 -1
@@ -49,7 +49,7 @@ static int verify_commit(const char *name, unsigned flags)return error ("%s: unable to read file." , name);if (type !=OBJ_COMMIT )return error ("%s: cannot verify a non-commit object of type %s." , - name,typename (type)); + name,type_name (type)); ret =run_gpg_verify (&oid, buf, size, flags);
bulk-checkin.c +1 -1
@@ -203,7 +203,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,return error ("cannot find the current offset" ); header_len =xsnprintf ((char *)obuf,sizeof (obuf),"%s %" PRIuMAX, -typename (type), (uintmax_t )size) +1 ; +type_name (type), (uintmax_t )size) +1 ;git_SHA1_Init (&ctx);git_SHA1_Update (&ctx, obuf, header_len);
commit.c +1 -1
@@ -274,7 +274,7 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep) oid_to_hex(&commit->object.oid));if (type !=OBJ_COMMIT )die ("expected commit for %s, got %s" , -oid_to_hex (&commit->object.oid),typename (type)); +oid_to_hex (&commit->object.oid),type_name (type));if (sizep) *sizep = size; }
contrib/examples/builtin-fetch--tool.c +1 -1
@@ -15,7 +15,7 @@ static char *get_stdin(void)static void show_new (enum object_type type,unsigned char *sha1_new) { -fprintf (stderr," %s: %s\n" ,typename (type), +fprintf (stderr," %s: %s\n" ,type_name (type),find_unique_abbrev (sha1_new,DEFAULT_ABBREV )); }
fast-import.c +8 -8
@@ -1096,7 +1096,7 @@ static int store_object(git_zstream s; hdrlen =xsnprintf ((char *)hdr,sizeof (hdr),"%s %lu" , -typename (type), (unsigned long )dat->len) +1 ; +type_name (type), (unsigned long )dat->len) +1 ;git_SHA1_Init (&c);git_SHA1_Update (&c, hdr, hdrlen);git_SHA1_Update (&c, dat->buf, dat->len);
@@ -2421,7 +2421,7 @@ static void file_change_m(const char *p, struct branch *b)else if (oe) {if (oe->type !=OBJ_COMMIT )die ("Not a commit (actually a %s): %s" , -typename (oe->type), command_buf.buf); +type_name (oe->type), command_buf.buf); }/* * Accept the sha1 without checking; it expected to be in
@@ -2448,7 +2448,7 @@ static void file_change_m(const char *p, struct branch *b) command_buf.buf);if (type != expected)die ("Not a %s (actually a %s): %s" , -typename (expected),typename (type), +type_name (expected),type_name (type), command_buf.buf); }
@@ -2599,14 +2599,14 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa }else if (oe) {if (oe->type !=OBJ_BLOB )die ("Not a blob (actually a %s): %s" , -typename (oe->type), command_buf.buf); +type_name (oe->type), command_buf.buf); }else if (!is_null_oid (&oid)) {enum object_type type =sha1_object_info (oid.hash,NULL );if (type <0 )die ("Blob not found: %s" , command_buf.buf);if (type !=OBJ_BLOB )die ("Not a blob (actually a %s): %s" , -typename (type), command_buf.buf); +type_name (type), command_buf.buf); }construct_path_with_fanout (oid_to_hex (&commit_oid), *old_fanout, path);
@@ -2914,7 +2914,7 @@ static void parse_new_tag(const char *arg)"object %s\n" "type %s\n" "tag %s\n" , - oid_to_hex(&oid), typename(type), t->name); + oid_to_hex(&oid), type_name(type), t->name);if (tagger)strbuf_addf (&new_data,"tagger %s\n" , tagger);
@@ -2985,10 +2985,10 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)die ("Can't read object %s" ,oid_to_hex (oid));if (type !=OBJ_BLOB )die ("Object %s is a %s but a blob was expected." , -oid_to_hex (oid),typename (type)); +oid_to_hex (oid),type_name (type));strbuf_reset (&line);strbuf_addf (&line,"%s %s %lu\n" ,oid_to_hex (oid), -typename (type), size); +type_name (type), size);cat_blob_write (line.buf, line.len);strbuf_release (&line);cat_blob_write (buf, size);
fsck.c +1 -1
@@ -821,7 +821,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data, ret =report (options, &tag->object,FSCK_MSG_TAG_OBJECT_NOT_TAG ,"expected tag got %s" , -typename (type)); +type_name (type)); goto done; } }
http-push.c +1 -1
@@ -362,7 +362,7 @@ static void start_put(struct transfer_request *request)git_zstream stream; unpacked =read_sha1_file (request->obj->oid.hash, &type, &len); - hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,typename (type), len) +1 ; + hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (type), len) +1 ;/* Set it up */ git_deflate_init (&stream, zlib_compression_level);
log-tree.c +1 -1
@@ -499,7 +499,7 @@ static void show_one_mergetag(struct commit *commit,int status, nth;size_t payload_size, gpg_message_offset; -hash_sha1_file (extra->value, extra->len,typename (OBJ_TAG ), oid.hash); +hash_sha1_file (extra->value, extra->len,type_name (OBJ_TAG ), oid.hash); tag =lookup_tag (&oid);if (!tag)return ;/* error message already given */
object.c +3 -3
@@ -26,7 +26,7 @@ static const char *object_type_strings[] = { "tag", /* OBJ_TAG = 4 */ }; -const char *typename (unsigned int type) +const char *type_name (unsigned int type) {if (type >=ARRAY_SIZE (object_type_strings))return NULL ;
@@ -166,7 +166,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)if (!quiet)error ("object %s is a %s, not a %s" ,oid_to_hex (&obj->oid), -typename (obj->type),typename (type)); +type_name (obj->type),type_name (type));return NULL ; } }
@@ -265,7 +265,7 @@ struct object *parse_object(const struct object_id *oid) buffer =read_sha1_file (oid->hash, &type, &size);if (buffer) { -if (check_sha1_signature (repl, buffer, size,typename (type)) <0 ) { +if (check_sha1_signature (repl, buffer, size,type_name (type)) <0 ) {free (buffer);error ("sha1 mismatch %s" ,sha1_to_hex (repl));return NULL ;
object.h +1 -1
@@ -53,7 +53,7 @@ struct object {struct object_id oid; }; -extern const char *typename (unsigned int type); +extern const char *type_name (unsigned int type);extern int type_from_string_gently (const char *str,ssize_t ,int gentle);#define type_from_string (str) type_from_string_gently(str, -1, 0)
pack-check.c +1 -1
@@ -141,7 +141,7 @@ static int verify_packfile(struct packed_git *p, err =error ("cannot unpack %s from %s at offset %" PRIuMAX"" ,oid_to_hex (entries[i].oid.oid), p->pack_name, (uintmax_t )entries[i].offset); - else if (check_sha1_signature(entries[i].oid.hash, data, size, typename(type))) + else if (check_sha1_signature(entries[i].oid.hash, data, size, type_name(type))) err =error ("packed %s from %s is corrupt" ,oid_to_hex (entries[i].oid.oid), p->pack_name); else if (fn) {
packfile.c +1 -1
@@ -1357,7 +1357,7 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,if (oi->typep) *oi->typep = ptot;if (oi->type_name) { -const char *tn =typename (ptot); +const char *tn =type_name (ptot);if (tn)strbuf_addstr (oi->type_name, tn); }
reachable.c +1 -1
@@ -94,7 +94,7 @@ static void add_recent_object(const struct object_id *oid,break ;default :die ("unknown object type for %s: %s" , -oid_to_hex (oid),typename (type)); +oid_to_hex (oid),type_name (type)); }if (!obj)
ref-filter.c +2 -2
@@ -769,7 +769,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct objectif (deref) name++;if (!strcmp (name,"objecttype" )) - v->s =typename (obj->type); + v->s =type_name (obj->type);else if (!strcmp (name,"objectsize" )) { v->value = sz; v->s =xstrfmt ("%lu" , sz);
@@ -795,7 +795,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *obif (!strcmp (name,"tag" )) v->s = tag->tag;else if (!strcmp (name,"type" ) && tag->tagged) - v->s =typename (tag->tagged->type); + v->s =type_name (tag->tagged->type);else if (!strcmp (name,"object" ) && tag->tagged) v->s =xstrdup (oid_to_hex (&tag->tagged->oid)); }
sequencer.c +1 -1
@@ -2348,7 +2348,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)if (!lookup_commit_reference_gently (&oid,1 )) {enum object_type type =sha1_object_info (oid.hash,NULL );return error (_ ("%s: can't cherry-pick a %s" ), - name,typename (type)); + name,type_name (type)); } }else return error (_ ("%s: bad revision" ), name);
sha1_file.c +10 -10
@@ -805,7 +805,7 @@ int check_sha1_signature(const unsigned char *sha1, void *map,return -1 ;/* Generate the header */ - hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,typename (obj_type), size) +1 ; + hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (obj_type), size) +1 ;/* Sha1.. */ git_SHA1_Init (&c);
@@ -1240,7 +1240,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,if (oi->delta_base_sha1)hashclr (oi->delta_base_sha1);if (oi->type_name) -strbuf_addstr (oi->type_name,typename (co->type)); +strbuf_addstr (oi->type_name,type_name (co->type));if (oi->contentp) *oi->contentp =xmemdupz (co->buf, co->size); oi->whence =OI_CACHED ;
@@ -1317,7 +1317,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type, {struct cached_object *co; -hash_sha1_file (buf, len,typename (type), sha1); +hash_sha1_file (buf, len,type_name (type), sha1);if (has_sha1_file (sha1) ||find_cached_object (sha1))return 0 ;ALLOC_GROW (cached_objects, cached_object_nr +1 , cached_object_alloc);
@@ -1683,7 +1683,7 @@ int force_object_loose(const unsigned char *sha1, time_t mtime) buf =read_object (sha1, &type, &len);if (!buf)return error ("cannot read sha1_file for %s" ,sha1_to_hex (sha1)); - hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,typename (type), len) +1 ; + hdrlen =xsnprintf (hdr,sizeof (hdr),"%s %lu" ,type_name (type), len) +1 ; ret =write_loose_object (sha1, hdr, hdrlen, buf, len, mtime);free (buf);
@@ -1767,9 +1767,9 @@ static int index_mem(struct object_id *oid, void *buf, size_t size, }if (write_object) - ret =write_sha1_file (buf, size,typename (type), oid->hash); + ret =write_sha1_file (buf, size,type_name (type), oid->hash);else - ret =hash_sha1_file (buf, size,typename (type), oid->hash); + ret =hash_sha1_file (buf, size,type_name (type), oid->hash);if (re_allocated)free (buf);return ret;
@@ -1789,10 +1789,10 @@ static int index_stream_convert_blob(struct object_id *oid, int fd, get_safe_crlf(flags));if (write_object) - ret =write_sha1_file (sbuf.buf, sbuf.len,typename (OBJ_BLOB ), + ret =write_sha1_file (sbuf.buf, sbuf.len,type_name (OBJ_BLOB ), oid->hash);else - ret =hash_sha1_file (sbuf.buf, sbuf.len,typename (OBJ_BLOB ), + ret =hash_sha1_file (sbuf.buf, sbuf.len,type_name (OBJ_BLOB ), oid->hash);strbuf_release (&sbuf);return ret;
@@ -1942,7 +1942,7 @@ void assert_sha1_type(const unsigned char *sha1, enum object_type expect)die ("%s is not a valid object" ,sha1_to_hex (sha1));if (type != expect)die ("%s is not a valid '%s' object" ,sha1_to_hex (sha1), -typename (expect)); +type_name (expect)); } int for_each_file_in_obj_subdir(unsigned int subdir_nr,
@@ -2187,7 +2187,7 @@ int read_loose_object(const char *path, goto out; }if (check_sha1_signature (expected_sha1, *contents, - *size,typename (*type))) { + *size,type_name (*type))) {error ("sha1 mismatch for %s (expected %s)" , path,sha1_to_hex (expected_sha1));free (*contents);
sha1_name.c +3 -3
@@ -381,7 +381,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)advise (" %s %s%s" ,find_unique_abbrev (oid->hash,DEFAULT_ABBREV ), -typename (type) ?typename (type) :"unknown type" , +type_name (type) ?type_name (type) :"unknown type" , desc.buf);strbuf_release (&desc);
@@ -901,8 +901,8 @@ struct object *peel_to_type(const char *name, int namelen,if (name)error ("%.*s: expected %s type, but the object " "dereferences to %s type" , - namelen, name,typename (expected_type), -typename (o->type)); + namelen, name,type_name (expected_type), +type_name (o->type));return NULL ; } }
submodule.c +1 -1
@@ -831,7 +831,7 @@ static int check_has_commit(const struct object_id *oid, void *data)return 0 ;default :die (_ ("submodule entry '%s' (%s) is a %s, not a commit" ), - cb->path,oid_to_hex (oid),typename (type)); + cb->path,oid_to_hex (oid),type_name (type)); } }
tag.c +1 -1
@@ -47,7 +47,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report, name_to_report ? name_to_report :find_unique_abbrev (oid->hash,DEFAULT_ABBREV ), - typename(type)); + type_name(type)); buf =read_sha1_file (oid->hash, &type, &size);if (!buf)
walker.c +2 -2
@@ -22,7 +22,7 @@ void walker_say(struct walker *walker, const char *fmt, ...)static void report_missing (const struct object *obj) {fprintf (stderr,"Cannot obtain needed %s %s\n" , - obj->type ?typename (obj->type):"object" , + obj->type ?type_name (obj->type):"object" ,oid_to_hex (&obj->oid));if (!is_null_oid (¤t_commit_oid)) fprintf(stderr, "while processing commit %s.\n",
@@ -134,7 +134,7 @@ static int process_object(struct walker *walker, struct object *obj) }return error ("Unable to determine requirements " "of type %s for %s" , -typename (obj->type),oid_to_hex (&obj->oid)); +type_name (obj->type),oid_to_hex (&obj->oid)); }static int process (struct walker *walker,struct object *obj)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 3/37 blame: rename 'this' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- blame.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
blame.c +17 -16
@@ -998,28 +998,29 @@ unsigned blame_entry_score(struct blame_scoreboard *sb, struct blame_entry *e) }/* -* best_so_far[] and this[] are both a split of an existing blame_entry -* that passes blame to the parent. Maintain best_so_far the best split -* so far, by comparing this and best_so_far and copying this into +* best_so_far[] and potential[] are both a split of an existing blame_entry +* that passes blame to the parent. Maintain best_so_far the best split so +* far, by comparing potential and best_so_far and copying potential into * bst_so_far as needed. */ static void copy_split_if_better (struct blame_scoreboard *sb,struct blame_entry *best_so_far, -struct blame_entry *this) +struct blame_entry *potential) {int i; -if (!this[1 ].suspect) +if (!potential[1 ].suspect)return ;if (best_so_far[1 ].suspect) { -if (blame_entry_score (sb, &this[1 ]) <blame_entry_score (sb, &best_so_far[1 ])) +if (blame_entry_score (sb, &potential[1 ]) < +blame_entry_score (sb, &best_so_far[1 ]))return ; }for (i =0 ; i <3 ; i++) -blame_origin_incref (this[i].suspect); +blame_origin_incref (potential[i].suspect);decref_split (best_so_far); -memcpy (best_so_far, this,sizeof (struct blame_entry [3 ])); +memcpy (best_so_far, potential,sizeof (struct blame_entry [3 ])); }/*
@@ -1046,12 +1047,12 @@ static void handle_split(struct blame_scoreboard *sb,if (ent->num_lines <= tlno)return ;if (tlno < same) { -struct blame_entry this[3 ]; +struct blame_entry potential[3 ]; tlno += ent->s_lno; same += ent->s_lno; -split_overlap (this, ent, tlno, plno, same, parent); -copy_split_if_better (sb, split, this); -decref_split (this); +split_overlap (potential, ent, tlno, plno, same, parent); +copy_split_if_better (sb, split, potential); +decref_split (potential); } }
@@ -1273,7 +1274,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,struct diff_filepair *p = diff_queued_diff.queue[i];struct blame_origin *norigin;mmfile_t file_p; -struct blame_entry this[3 ]; +struct blame_entry potential[3 ];if (!DIFF_FILE_VALID (p->one))continue ;/* does not exist in parent */
@@ -1292,10 +1293,10 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,for (j =0 ; j < num_ents; j++) {find_copy_in_blob (sb, blame_list[j].ent, - norigin, this, &file_p); + norigin, potential, &file_p);copy_split_if_better (sb, blame_list[j].split, - this); -decref_split (this); + potential); +decref_split (potential); }blame_origin_decref (norigin); }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 4/37 pack-objects: rename 'this' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/pack-objects.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
builtin/pack-objects.c +4 -4
@@ -1376,10 +1376,10 @@ static void cleanup_preferred_base(void) it = pbase_tree; pbase_tree =NULL ;while (it) { -struct pbase_tree *this = it; - it = this->next; -free (this->pcache.tree_data); -free (this); +struct pbase_tree *tmp = it; + it = tmp->next; +free (tmp->pcache.tree_data); +free (tmp); }for (i =0 ; i <ARRAY_SIZE (pbase_tree_cache); i++) {
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 5/37 rev-parse: rename 'this' variable
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/rev-parse.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
builtin/rev-parse.c +17 -17
@@ -243,28 +243,28 @@ static int show_file(const char *arg, int output_prefix)static int try_difference (const char *arg) {char *dotdot; -struct object_id oid; -struct object_id end; -const char *next; -const char *this; +struct object_id start_oid; +struct object_id end_oid; +const char *end; +const char *start;int symmetric;static const char head_by_default[] ="HEAD" ;if (!(dotdot =strstr (arg,".." )))return 0 ; - next = dotdot +2 ; - this = arg; - symmetric = (*next =='.' ); + end = dotdot +2 ; + start = arg; + symmetric = (*end =='.' ); *dotdot =0 ; - next += symmetric; + end += symmetric; -if (!*next) - next = head_by_default; +if (!*end) + end = head_by_default;if (dotdot == arg) - this = head_by_default; + start = head_by_default; -if (this == head_by_default && next == head_by_default && +if (start == head_by_default && end == head_by_default && !symmetric) {/* * Just ".."? That is not a range but the
@@ -274,14 +274,14 @@ static int try_difference(const char *arg)return 0 ; } -if (!get_oid_committish (this, &oid) && !get_oid_committish (next, &end)) { -show_rev (NORMAL , &end, next); -show_rev (symmetric ?NORMAL :REVERSED , &oid, this); +if (!get_oid_committish (start, &start_oid) && !get_oid_committish (end, &end_oid)) { +show_rev (NORMAL , &end_oid, end); +show_rev (symmetric ?NORMAL :REVERSED , &start_oid, start);if (symmetric) {struct commit_list *exclude;struct commit *a, *b; - a =lookup_commit_reference (&oid); - b =lookup_commit_reference (&end); + a =lookup_commit_reference (&start_oid); + b =lookup_commit_reference (&end_oid); exclude =get_merge_bases (a, b);while (exclude) {struct commit *commit =pop_commit (&exclude);
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 6/37 diff: rename 'this' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff.c +4 -4
@@ -2601,7 +2601,7 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,while (dir->nr) {struct dirstat_file *f = dir->files;int namelen =strlen (f->name); -unsigned long this; +unsigned long sum;char *slash;if (namelen < baselen)
@@ -2611,15 +2611,15 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir, slash =strchr (f->name + baselen,'/' );if (slash) {int newbaselen = slash +1 - f->name; - this =gather_dirstat (opt, dir, changed, f->name, newbaselen); + sum =gather_dirstat (opt, dir, changed, f->name, newbaselen); sources++; }else { - this = f->changed; + sum = f->changed; dir->files++; dir->nr--; sources +=2 ; } - this_dir += this; + this_dir += sum; }/*
Signature · 1 line
2.16.1.291.g4437f3f132-goog
Re: [PATCH v2 06/37] diff: rename 'this' variables
Quoted 5 lines · Brandon Williams
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
Signed-off-by Brandon Williams <[email protected]>---
The patch is not as bad as renaming "this" and leaving "that" behind but in the original, "this" and "this_dir" were treated as a pair. "this" was a score for a single item in the directory, "this_dir" was the sum of these scores for entries in the directory.
So renaming "this" to "sum" and leaving "this_dir" as-is looks like readability regression. Perhaps replace "this_dir" with "sum_changes" and "this" with "changes" instead, or something like that?
Quoted 35 lines
diff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)diff.c +4
-4@@ -2601,7 +2601,7 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,while (dir->nr) {struct dirstat_file *f = dir->files;int namelen =strlen (f->name); -unsigned long this; +unsigned long sum;char *slash;if (namelen < baselen)@@ -2611,15 +2611,15 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir, slash =strchr (f->name + baselen,'/' );if (slash) {int newbaselen = slash +1 - f->name; - this =gather_dirstat (opt, dir, changed, f->name, newbaselen); + sum =gather_dirstat (opt, dir, changed, f->name, newbaselen); sources++; }else { - this = f->changed; + sum = f->changed; dir->files++; dir->nr--; sources +=2 ; } - this_dir += this; + this_dir += sum; }/*
Re: [PATCH v2 06/37] diff: rename 'this' variables
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Brandon Williams
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
Signed-off-by Brandon Williams <[email protected]>---
Quoted 8 lines
The patch is not as bad as renaming "this" and leaving "that" behind but in the original, "this" and "
this_dir" were treated as a pair. "this" was a score for a single item in the directory, "this_dir" was the sum of these scores for entries in the directory.So renaming "this" to "sum" and leaving "
this_dir" as-is looks like readability regression. Perhaps replace "this_dir" with "sum_changes" and "this" with "changes" instead, or something like that?
100% agree. I tried to spend time on each of these changes to come up with a meaningful name, but sometimes wasn't able to understand the section of code (with the limited context I had with some areas) and wasn't able to come up with the best name. I'll change this.
Quoted 36 lines
Quoted 36 lines
diff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)diff.c +4
-4@@ -2601,7 +2601,7 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,while (dir->nr) {struct dirstat_file *f = dir->files;int namelen =strlen (f->name); -unsigned long this; +unsigned long sum;char *slash;if (namelen < baselen)@@ -2611,15 +2611,15 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir, slash =strchr (f->name + baselen,'/' );if (slash) {int newbaselen = slash +1 - f->name; - this =gather_dirstat (opt, dir, changed, f->name, newbaselen); + sum =gather_dirstat (opt, dir, changed, f->name, newbaselen); sources++; }else { - this = f->changed; + sum = f->changed; dir->files++; dir->nr--; sources +=2 ; } - this_dir += this; + this_dir += sum; }/*
Signature · 1 line
Brandon Williams
PATCH v2 7/37 apply: rename 'try' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- apply.c | 68 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 34 deletions(-)
apply.c +34 -34
@@ -2386,8 +2386,8 @@ static void update_pre_post_images(struct image *preimage,static int line_by_line_fuzzy_match (struct image *img,struct image *preimage,struct image *postimage, -unsigned long try, -int try_lno, +unsigned long current, +int current_lno,int preimage_limit) {int i;
@@ -2404,9 +2404,9 @@ static int line_by_line_fuzzy_match(struct image *img,for (i =0 ; i < preimage_limit; i++) {size_t prelen = preimage->line[i].len; -size_t imglen = img->line[try_lno+i].len; +size_t imglen = img->line[current_lno+i].len; -if (!fuzzy_matchlines (img->buf + try + imgoff, imglen, +if (!fuzzy_matchlines (img->buf + current + imgoff, imglen, preimage->buf + preoff, prelen))return 0 ;if (preimage->line[i].flag &LINE_COMMON )
@@ -2443,7 +2443,7 @@ static int line_by_line_fuzzy_match(struct image *img,*/ extra_chars = preimage_end - preimage_eof;strbuf_init (&fixed, imgoff + extra_chars); -strbuf_add (&fixed, img->buf + try, imgoff); +strbuf_add (&fixed, img->buf + current, imgoff);strbuf_add (&fixed, preimage_eof, extra_chars); fixed_buf =strbuf_detach (&fixed, &fixed_len); update_pre_post_images(preimage, postimage,
@@ -2455,8 +2455,8 @@ static int match_fragment(struct apply_state *state,struct image *img, struct image *preimage, struct image *postimage, - unsigned long try, - int try_lno, + unsigned long current, + int current_lno, unsigned ws_rule, int match_beginning, int match_end) {
@@ -2466,12 +2466,12 @@ static int match_fragment(struct apply_state *state,size_t fixed_len, postlen;int preimage_limit; -if (preimage->nr + try_lno <= img->nr) { +if (preimage->nr + current_lno <= img->nr) {/* * The hunk falls within the boundaries of img. */ preimage_limit = preimage->nr; -if (match_end && (preimage->nr + try_lno != img->nr)) +if (match_end && (preimage->nr + current_lno != img->nr))return 0 ; }else if (state->ws_error_action == correct_ws_error && (ws_rule &WS_BLANK_AT_EOF )) {
@@ -2482,7 +2482,7 @@ static int match_fragment(struct apply_state *state,* match with img, and the remainder of the preimage * must be blank. */ - preimage_limit = img->nr - try_lno; + preimage_limit = img->nr - current_lno; }else {/* * The hunk extends beyond the end of the img and
@@ -2492,27 +2492,27 @@ static int match_fragment(struct apply_state *state,return 0 ; } -if (match_beginning && try_lno) +if (match_beginning && current_lno)return 0 ;/* Quick hash check */ for (i =0 ; i < preimage_limit; i++) -if ((img->line[try_lno + i].flag &LINE_PATCHED ) || - (preimage->line[i].hash != img->line[try_lno + i].hash)) +if ((img->line[current_lno + i].flag &LINE_PATCHED ) || + (preimage->line[i].hash != img->line[current_lno + i].hash))return 0 ;if (preimage_limit == preimage->nr) {/* * Do we have an exact match? If we were told to match -* at the end, size must be exactly at try+fragsize, -* otherwise try+fragsize must be still within the preimage, +* at the end, size must be exactly at current+fragsize, +* otherwise current+fragsize must be still within the preimage, * and either case, the old piece should match the preimage * exactly. */ if ((match_end - ? (try + preimage->len == img->len) - : (try + preimage->len <= img->len)) && - !memcmp (img->buf + try, preimage->buf, preimage->len)) + ? (current + preimage->len == img->len) + : (current + preimage->len <= img->len)) && + !memcmp (img->buf + current, preimage->buf, preimage->len))return 1 ; }else {/*
@@ -2543,7 +2543,7 @@ static int match_fragment(struct apply_state *state,*/ if (state->ws_ignore_action == ignore_ws_change)return line_by_line_fuzzy_match (img, preimage, postimage, - try, try_lno, preimage_limit); + current, current_lno, preimage_limit);if (state->ws_error_action != correct_ws_error)return 0 ;
@@ -2577,10 +2577,10 @@ static int match_fragment(struct apply_state *state,*/ strbuf_init (&fixed, preimage->len +1 ); orig = preimage->buf; - target = img->buf + try; + target = img->buf + current;for (i =0 ; i < preimage_limit; i++) {size_t oldlen = preimage->line[i].len; -size_t tgtlen = img->line[try_lno + i].len; +size_t tgtlen = img->line[current_lno + i].len;size_t fixstart = fixed.len;struct strbuf tgtfix;int match;
@@ -2666,8 +2666,8 @@ static int find_pos(struct apply_state *state, int match_beginning, int match_end) {int i; -unsigned long backwards, forwards, try; -int backwards_lno, forwards_lno, try_lno; +unsigned long backwards, forwards, current; +int backwards_lno, forwards_lno, current_lno;/* * If match_beginning or match_end is specified, there is no
@@ -2687,25 +2687,25 @@ static int find_pos(struct apply_state *state,if ((size_t ) line > img->nr) line = img->nr; - try =0 ; + current =0 ;for (i =0 ; i < line; i++) - try += img->line[i].len; + current += img->line[i].len;/* * There's probably some smart way to do this, but I'll leave * that to the smart and beautiful people. I'm simple and stupid. */ - backwards = try; + backwards = current; backwards_lno = line; - forwards = try; + forwards = current; forwards_lno = line; - try_lno = line; + current_lno = line;for (i =0 ; ; i++) {if (match_fragment (state, img, preimage, postimage, - try, try_lno, ws_rule, + current, current_lno, ws_rule, match_beginning, match_end)) -return try_lno; +return current_lno; again:if (backwards_lno ==0 && forwards_lno == img->nr)
@@ -2718,8 +2718,8 @@ static int find_pos(struct apply_state *state, } backwards_lno--; backwards -= img->line[backwards_lno].len; - try = backwards; - try_lno = backwards_lno; + current = backwards; + current_lno = backwards_lno; }else {if (forwards_lno == img->nr) { i++;
@@ -2727,8 +2727,8 @@ static int find_pos(struct apply_state *state, } forwards += img->line[forwards_lno].len; forwards_lno++; - try = forwards; - try_lno = forwards_lno; + current = forwards; + current_lno = forwards_lno; } }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 8/37 apply: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- apply.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
apply.c +27 -27
@@ -2301,7 +2301,7 @@ static void update_pre_post_images(struct image *preimage, size_t len, size_t postlen) {int i, ctx, reduced; -char *new, *old, *fixed; +char *new_buf, *old_buf, *fixed;struct image fixed_preimage;/*
@@ -2327,25 +2327,25 @@ static void update_pre_post_images(struct image *preimage,* We trust the caller to tell us if the update can be done * in place (postlen==0) or not. */ - old = postimage->buf; + old_buf = postimage->buf;if (postlen) - new = postimage->buf =xmalloc (postlen); + new_buf = postimage->buf =xmalloc (postlen);else - new = old; + new_buf = old_buf; fixed = preimage->buf;for (i = reduced = ctx =0 ; i < postimage->nr; i++) {size_t l_len = postimage->line[i].len;if (!(postimage->line[i].flag &LINE_COMMON )) {/* an added line -- no counterparts in preimage */ -memmove (new, old, l_len); - old += l_len; - new += l_len; +memmove (new_buf, old_buf, l_len); + old_buf += l_len; + new_buf += l_len;continue ; }/* a common context -- skip it in the original postimage */ - old += l_len; + old_buf += l_len;/* and find the corresponding one in the fixed preimage */ while (ctx < preimage->nr &&
@@ -2365,21 +2365,21 @@ static void update_pre_post_images(struct image *preimage,/* and copy it in, while fixing the line length */ l_len = preimage->line[ctx].len; -memcpy (new, fixed, l_len); - new += l_len; +memcpy (new_buf, fixed, l_len); + new_buf += l_len; fixed += l_len; postimage->line[i].len = l_len; ctx++; }if (postlen - ? postlen < new - postimage->buf - : postimage->len < new - postimage->buf) + ? postlen < new_buf - postimage->buf + : postimage->len < new_buf - postimage->buf)die ("BUG: caller miscounted postlen: asked %d, orig = %d, used = %d" , - (int )postlen, (int ) postimage->len, (int )(new - postimage->buf)); + (int )postlen, (int ) postimage->len, (int )(new_buf - postimage->buf));/* Fix the length of the whole thing */ - postimage->len = new - postimage->buf; + postimage->len = new_buf - postimage->buf; postimage->nr -= reduced; }
@@ -4163,30 +4163,30 @@ static void show_mode_change(struct patch *p, int show_name)static void show_rename_copy (struct patch *p) {const char *renamecopy = p->is_rename ?"rename" :"copy" ; -const char *old, *new; +const char *old_name, *new_name;/* Find common prefix */ - old = p->old_name; - new = p->new_name; + old_name = p->old_name; + new_name = p->new_name;while (1 ) {const char *slash_old, *slash_new; - slash_old =strchr (old,'/' ); - slash_new =strchr (new,'/' ); + slash_old =strchr (old_name,'/' ); + slash_new =strchr (new_name,'/' );if (!slash_old || !slash_new || - slash_old - old != slash_new - new || -memcmp (old, new, slash_new - new)) + slash_old - old_name != slash_new - new_name || +memcmp (old_name, new_name, slash_new - new_name))break ; - old = slash_old +1 ; - new = slash_new +1 ; + old_name = slash_old +1 ; + new_name = slash_new +1 ; } -/* p->old_name thru old is the common prefix, and old and new +/* p->old_name thru old_name is the common prefix, and old_name and new_name * through the end of names are renames */ -if (old != p->old_name) +if (old_name != p->old_name)printf (" %s %.*s{%s => %s} (%d%%)\n" , renamecopy, - (int )(old - p->old_name), p->old_name, - old, new, p->score); + (int )(old_name - p->old_name), p->old_name, + old_name, new_name, p->score);else printf (" %s %s => %s (%d%%)\n" , renamecopy, p->old_name, p->new_name, p->score);
Signature · 1 line
2.16.1.291.g4437f3f132-goog
Re: [PATCH v2 08/37] apply: rename 'new' variables
Quoted 13 lines · Brandon Williams
Rename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
Signed-off-by Brandon Williams <[email protected]>--- apply.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-)apply.c +0
-0
apply.c static void update_pre_post_images(struct image *preimage, · line 2304
Quoted 5 lines
apply.c +1
-1@@ -2301,7 +2301,7 @@ static void update_pre_post_images(struct image *preimage, size_t len, size_t postlen) {int i, ctx, reduced; -char *new, *old, *fixed; +char *new_buf, *old_buf, *fixed;
*_buf makes it sound like it could be a strbuf at first, but it is just a buffer. That is ok, as we take over a buffer from 'postimage->buf'. I was suggesting a new name, but given that reuse of "buf", I guess this is fine.
PATCH v2 9/37 checkout: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/checkout.c | 196 ++++++++++++++++++++++----------------------- 1 file changed, 98 insertions(+), 98 deletions(-)
builtin/checkout.c +98 -98
@@ -54,14 +54,14 @@ struct checkout_opts {struct tree *source_tree; }; -static int post_checkout_hook (struct commit *old,struct commit *new, +static int post_checkout_hook (struct commit *old_commit,struct commit *new_commit,int changed) {return run_hook_le (NULL ,"post-checkout" , -oid_to_hex (old ? &old->object.oid : &null_oid), -oid_to_hex (new ? &new->object.oid : &null_oid), +oid_to_hex (old_commit ? &old_commit->object.oid : &null_oid), +oid_to_hex (new_commit ? &new_commit->object.oid : &null_oid), changed ?"1" :"0" ,NULL ); -/* "new" can be NULL when checking out from the index before +/* "new_commit" can be NULL when checking out from the index before a commit exists. */ }
@@ -472,8 +472,8 @@ static void setup_branch_path(struct branch_info *branch) }static int merge_working_tree (const struct checkout_opts *opts, -struct branch_info *old, -struct branch_info *new, +struct branch_info *old_branch_info, +struct branch_info *new_branch_info,int *writeout_error) {int ret;
@@ -485,7 +485,7 @@ static int merge_working_tree(const struct checkout_opts *opts,resolve_undo_clear ();if (opts->force) { - ret =reset_tree (new->commit->tree, opts,1 , writeout_error); + ret =reset_tree (new_branch_info->commit->tree, opts,1 , writeout_error);if (ret)return ret; }else {
@@ -511,7 +511,7 @@ static int merge_working_tree(const struct checkout_opts *opts, topts.initial_checkout =is_cache_unborn (); topts.update =1 ; topts.merge =1 ; - topts.gently = opts->merge && old->commit; + topts.gently = opts->merge && old_branch_info->commit; topts.verbose_update = opts->show_progress; topts.fn = twoway_merge;if (opts->overwrite_ignore) {
@@ -519,11 +519,11 @@ static int merge_working_tree(const struct checkout_opts *opts, topts.dir->flags |=DIR_SHOW_IGNORED ;setup_standard_excludes (topts.dir); } - tree =parse_tree_indirect (old->commit ? - &old->commit->object.oid : + tree =parse_tree_indirect (old_branch_info->commit ? + &old_branch_info->commit->object.oid : the_hash_algo->empty_tree);init_tree_desc (&trees[0 ], tree->buffer, tree->size); - tree =parse_tree_indirect (&new->commit->object.oid); + tree =parse_tree_indirect (&new_branch_info->commit->object.oid);init_tree_desc (&trees[1 ], tree->buffer, tree->size); ret =unpack_trees (2 , trees, &topts);
@@ -540,10 +540,10 @@ static int merge_working_tree(const struct checkout_opts *opts,return 1 ;/* -* Without old->commit, the below is the same as +* Without old_branch_info->commit, the below is the same as * the two-tree unpack we already tried and failed. */ -if (!old->commit) +if (!old_branch_info->commit)return 1 ;/* Do more real merge */
@@ -571,18 +571,18 @@ static int merge_working_tree(const struct checkout_opts *opts, o.verbosity =0 ; work =write_tree_from_memory (&o); - ret =reset_tree (new->commit->tree, opts,1 , + ret =reset_tree (new_branch_info->commit->tree, opts,1 , writeout_error);if (ret)return ret; - o.ancestor = old->name; - o.branch1 = new->name; + o.ancestor = old_branch_info->name; + o.branch1 = new_branch_info->name; o.branch2 ="local" ; - ret =merge_trees (&o, new->commit->tree, work, - old->commit->tree, &result); + ret =merge_trees (&o, new_branch_info->commit->tree, work, + old_branch_info->commit->tree, &result);if (ret <0 )exit (128 ); - ret =reset_tree (new->commit->tree, opts,0 , + ret =reset_tree (new_branch_info->commit->tree, opts,0 , writeout_error);strbuf_release (&o.obuf);if (ret)
@@ -600,15 +600,15 @@ static int merge_working_tree(const struct checkout_opts *opts,die (_ ("unable to write new index file" ));if (!opts->force && !opts->quiet) -show_local_changes (&new->commit->object, &opts->diff_options); +show_local_changes (&new_branch_info->commit->object, &opts->diff_options);return 0 ; } -static void report_tracking (struct branch_info *new) +static void report_tracking (struct branch_info *new_branch_info) {struct strbuf sb =STRBUF_INIT ; -struct branch *branch =branch_get (new->name); +struct branch *branch =branch_get (new_branch_info->name);if (!format_tracking_info (branch, &sb))return ;
@@ -617,8 +617,8 @@ static void report_tracking(struct branch_info *new) }static void update_refs_for_switch (const struct checkout_opts *opts, -struct branch_info *old, -struct branch_info *new) +struct branch_info *old_branch_info, +struct branch_info *new_branch_info) {struct strbuf msg =STRBUF_INIT ;const char *old_desc, *reflog_msg;
@@ -645,69 +645,69 @@ static void update_refs_for_switch(const struct checkout_opts *opts,free (refname); }else -create_branch (opts->new_branch, new->name, +create_branch (opts->new_branch, new_branch_info->name, opts->new_branch_force ?1 :0 , opts->new_branch_force ?1 :0 , opts->new_branch_log, opts->quiet, opts->track); - new->name = opts->new_branch; -setup_branch_path (new); + new_branch_info->name = opts->new_branch; +setup_branch_path (new_branch_info); } - old_desc = old->name; -if (!old_desc && old->commit) - old_desc =oid_to_hex (&old->commit->object.oid); + old_desc = old_branch_info->name; +if (!old_desc && old_branch_info->commit) + old_desc =oid_to_hex (&old_branch_info->commit->object.oid); reflog_msg =getenv ("GIT_REFLOG_ACTION" );if (!reflog_msg)strbuf_addf (&msg,"checkout: moving from %s to %s" , - old_desc ? old_desc :"(invalid)" , new->name); + old_desc ? old_desc :"(invalid)" , new_branch_info->name);else strbuf_insert (&msg,0 , reflog_msg,strlen (reflog_msg)); -if (!strcmp (new->name,"HEAD" ) && !new->path && !opts->force_detach) { +if (!strcmp (new_branch_info->name,"HEAD" ) && !new_branch_info->path && !opts->force_detach) {/* Nothing to do. */ - }else if (opts->force_detach || !new->path) {/* No longer on any branch. */ -update_ref (msg.buf,"HEAD" , &new->commit->object.oid,NULL , + }else if (opts->force_detach || !new_branch_info->path) {/* No longer on any branch. */ +update_ref (msg.buf,"HEAD" , &new_branch_info->commit->object.oid,NULL ,REF_NO_DEREF ,UPDATE_REFS_DIE_ON_ERR );if (!opts->quiet) { -if (old->path && +if (old_branch_info->path && advice_detached_head && !opts->force_detach) -detach_advice (new->name); -describe_detached_head (_ ("HEAD is now at" ), new->commit); +detach_advice (new_branch_info->name); +describe_detached_head (_ ("HEAD is now at" ), new_branch_info->commit); } - }else if (new->path) {/* Switch branches. */ -if (create_symref ("HEAD" , new->path, msg.buf) <0 ) + }else if (new_branch_info->path) {/* Switch branches. */ +if (create_symref ("HEAD" , new_branch_info->path, msg.buf) <0 )die (_ ("unable to update HEAD" ));if (!opts->quiet) { -if (old->path && !strcmp (new->path, old->path)) { +if (old_branch_info->path && !strcmp (new_branch_info->path, old_branch_info->path)) {if (opts->new_branch_force)fprintf (stderr,_ ("Reset branch '%s'\n" ), - new->name); + new_branch_info->name);else fprintf (stderr,_ ("Already on '%s'\n" ), - new->name); + new_branch_info->name); }else if (opts->new_branch) {if (opts->branch_exists) -fprintf (stderr,_ ("Switched to and reset branch '%s'\n" ), new->name); +fprintf (stderr,_ ("Switched to and reset branch '%s'\n" ), new_branch_info->name);else -fprintf (stderr,_ ("Switched to a new branch '%s'\n" ), new->name); +fprintf (stderr,_ ("Switched to a new branch '%s'\n" ), new_branch_info->name); }else {fprintf (stderr,_ ("Switched to branch '%s'\n" ), - new->name); + new_branch_info->name); } } -if (old->path && old->name) { -if (!ref_exists (old->path) &&reflog_exists (old->path)) -delete_reflog (old->path); +if (old_branch_info->path && old_branch_info->name) { +if (!ref_exists (old_branch_info->path) &&reflog_exists (old_branch_info->path)) +delete_reflog (old_branch_info->path); } }remove_branch_state ();strbuf_release (&msg);if (!opts->quiet && - (new->path || (!opts->force_detach && !strcmp (new->name,"HEAD" )))) -report_tracking (new); + (new_branch_info->path || (!opts->force_detach && !strcmp (new_branch_info->name,"HEAD" )))) +report_tracking (new_branch_info); } static int add_pending_uninteresting_ref(const char *refname,
@@ -787,10 +787,10 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)* HEAD. If it is not reachable from any ref, this is the last chance * for the user to do so without resorting to reflog. */ -static void orphaned_commit_warning (struct commit *old,struct commit *new) +static void orphaned_commit_warning (struct commit *old_commit,struct commit *new_commit) {struct rev_info revs; -struct object *object = &old->object; +struct object *object = &old_commit->object;init_revisions (&revs,NULL );setup_revisions (0 ,NULL , &revs,NULL );
@@ -799,57 +799,57 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)add_pending_object (&revs, object,oid_to_hex (&object->oid));for_each_ref (add_pending_uninteresting_ref, &revs); -add_pending_oid (&revs,"HEAD" , &new->object.oid,UNINTERESTING ); +add_pending_oid (&revs,"HEAD" , &new_commit->object.oid,UNINTERESTING );if (prepare_revision_walk (&revs))die (_ ("internal error in revision walk" )); -if (!(old->object.flags &UNINTERESTING )) -suggest_reattach (old, &revs); +if (!(old_commit->object.flags &UNINTERESTING )) +suggest_reattach (old_commit, &revs);else -describe_detached_head (_ ("Previous HEAD position was" ), old); +describe_detached_head (_ ("Previous HEAD position was" ), old_commit);/* Clean up objects used, as they will be reused. */ clear_commit_marks_all (ALL_REV_FLAGS ); }static int switch_branches (const struct checkout_opts *opts, -struct branch_info *new) +struct branch_info *new_branch_info) {int ret =0 ; -struct branch_info old; +struct branch_info old_branch_info;void *path_to_free;struct object_id rev;int flag, writeout_error =0 ; -memset (&old,0 ,sizeof (old)); - old.path = path_to_free =resolve_refdup ("HEAD" ,0 , &rev, &flag); -if (old.path) - old.commit =lookup_commit_reference_gently (&rev,1 ); +memset (&old_branch_info,0 ,sizeof (old_branch_info)); + old_branch_info.path = path_to_free =resolve_refdup ("HEAD" ,0 , &rev, &flag); +if (old_branch_info.path) + old_branch_info.commit =lookup_commit_reference_gently (&rev,1 );if (!(flag &REF_ISSYMREF )) - old.path =NULL ; + old_branch_info.path =NULL ; -if (old.path) -skip_prefix (old.path,"refs/heads/" , &old.name); +if (old_branch_info.path) +skip_prefix (old_branch_info.path,"refs/heads/" , &old_branch_info.name); -if (!new->name) { - new->name ="HEAD" ; - new->commit = old.commit; -if (!new->commit) +if (!new_branch_info->name) { + new_branch_info->name ="HEAD" ; + new_branch_info->commit = old_branch_info.commit; +if (!new_branch_info->commit)die (_ ("You are on a branch yet to be born" )); -parse_commit_or_die (new->commit); +parse_commit_or_die (new_branch_info->commit); } - ret =merge_working_tree (opts, &old, new, &writeout_error); + ret =merge_working_tree (opts, &old_branch_info, new_branch_info, &writeout_error);if (ret) {free (path_to_free);return ret; } -if (!opts->quiet && !old.path && old.commit && new->commit != old.commit) -orphaned_commit_warning (old.commit, new->commit); +if (!opts->quiet && !old_branch_info.path && old_branch_info.commit && new_branch_info->commit != old_branch_info.commit) +orphaned_commit_warning (old_branch_info.commit, new_branch_info->commit); -update_refs_for_switch (opts, &old, new); +update_refs_for_switch (opts, &old_branch_info, new_branch_info); - ret =post_checkout_hook (old.commit, new->commit,1 ); + ret =post_checkout_hook (old_branch_info.commit, new_branch_info->commit,1 );free (path_to_free);return ret || writeout_error; }
@@ -870,7 +870,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)static int parse_branchname_arg (int argc,const char **argv,int dwim_new_local_branch_ok, -struct branch_info *new, +struct branch_info *new_branch_info,struct checkout_opts *opts,struct object_id *rev) {
@@ -988,22 +988,22 @@ static int parse_branchname_arg(int argc, const char **argv, argv++; argc--; - new->name = arg; -setup_branch_path (new); + new_branch_info->name = arg; +setup_branch_path (new_branch_info); -if (!check_refname_format (new->path,0 ) && - !read_ref (new->path, &branch_rev)) +if (!check_refname_format (new_branch_info->path,0 ) && + !read_ref (new_branch_info->path, &branch_rev))oidcpy (rev, &branch_rev);else - new->path =NULL ;/* not an existing branch */ + new_branch_info->path =NULL ;/* not an existing branch */ - new->commit =lookup_commit_reference_gently (rev,1 ); -if (!new->commit) { + new_branch_info->commit =lookup_commit_reference_gently (rev,1 ); +if (!new_branch_info->commit) {/* not a commit */ *source_tree =parse_tree_indirect (rev); }else { -parse_commit_or_die (new->commit); - *source_tree = new->commit->tree; +parse_commit_or_die (new_branch_info->commit); + *source_tree = new_branch_info->commit->tree; }if (!*source_tree)/* case (1): want a tree */
@@ -1043,7 +1043,7 @@ static int switch_unborn_to_new_branch(const struct checkout_opts *opts) }static int checkout_branch (struct checkout_opts *opts, -struct branch_info *new) +struct branch_info *new_branch_info) {if (opts->pathspec.nr)die (_ ("paths cannot be used with switching branches" ));
@@ -1072,21 +1072,21 @@ static int checkout_branch(struct checkout_opts *opts, }else if (opts->track ==BRANCH_TRACK_UNSPECIFIED ) opts->track = git_branch_track; -if (new->name && !new->commit) +if (new_branch_info->name && !new_branch_info->commit)die (_ ("Cannot switch branch to a non-commit '%s'" ), - new->name); + new_branch_info->name); -if (new->path && !opts->force_detach && !opts->new_branch && +if (new_branch_info->path && !opts->force_detach && !opts->new_branch && !opts->ignore_other_worktrees) {int flag;char *head_ref =resolve_refdup ("HEAD" ,0 ,NULL , &flag);if (head_ref && - (!(flag &REF_ISSYMREF ) ||strcmp (head_ref, new->path))) -die_if_checked_out (new->path,1 ); + (!(flag &REF_ISSYMREF ) ||strcmp (head_ref, new_branch_info->path))) +die_if_checked_out (new_branch_info->path,1 );free (head_ref); } -if (!new->commit && opts->new_branch) { +if (!new_branch_info->commit && opts->new_branch) {struct object_id rev;int flag;
@@ -1094,13 +1094,13 @@ static int checkout_branch(struct checkout_opts *opts, (flag & REF_ISSYMREF) && is_null_oid(&rev))return switch_unborn_to_new_branch (opts); } -return switch_branches (opts, new); +return switch_branches (opts, new_branch_info); }int cmd_checkout (int argc,const char **argv,const char *prefix) {struct checkout_opts opts; -struct branch_info new; +struct branch_info new_branch_info;char *conflict_style =NULL ;int dwim_new_local_branch =1 ;struct option options[] = {
@@ -1138,7 +1138,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) };memset (&opts,0 ,sizeof (opts)); -memset (&new,0 ,sizeof (new)); +memset (&new_branch_info,0 ,sizeof (new_branch_info)); opts.overwrite_ignore =1 ; opts.prefix = prefix; opts.show_progress =-1 ;
@@ -1210,7 +1210,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) opts.track ==BRANCH_TRACK_UNSPECIFIED && !opts.new_branch;int n =parse_branchname_arg (argc, argv, dwim_ok, - &new, &opts, &rev); + &new_branch_info, &opts, &rev); argv += n; argc -= n; }
@@ -1253,7 +1253,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)UNLEAK (opts);if (opts.patch_mode || opts.pathspec.nr) -return checkout_paths (&opts, new.name); +return checkout_paths (&opts, new_branch_info.name);else -return checkout_branch (&opts, &new); +return checkout_branch (&opts, &new_branch_info); }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 10/37 help: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/help.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
builtin/help.c +5 -5
@@ -194,11 +194,11 @@ static void do_add_man_viewer_info(const char *name,size_t len, const char *value) { - struct man_viewer_info_list *new; -FLEX_ALLOC_MEM (new, name, name, len); - new->info =xstrdup (value); - new->next = man_viewer_info_list; - man_viewer_info_list = new; + struct man_viewer_info_list *new_man_viewer; +FLEX_ALLOC_MEM (new_man_viewer, name, name, len); + new_man_viewer->info =xstrdup (value); + new_man_viewer->next = man_viewer_info_list; + man_viewer_info_list = new_man_viewer; } static int add_man_viewer_path(const char *name,
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 11/37 pack-redundant: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/pack-redundant.c | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
builtin/pack-redundant.c +27 -27
@@ -48,17 +48,17 @@ static inline void llist_item_put(struct llist_item *item)static inline struct llist_item *llist_item_get (void ) { -struct llist_item *new; +struct llist_item *new_item;if ( free_nodes ) { - new = free_nodes; + new_item = free_nodes; free_nodes = free_nodes->next; }else {int i =1 ; -ALLOC_ARRAY (new,BLKSIZE ); +ALLOC_ARRAY (new_item,BLKSIZE );for (; i <BLKSIZE ; i++) -llist_item_put (&new[i]); +llist_item_put (&new_item[i]); } -return new; +return new_item; }static void llist_free (struct llist *list)
@@ -80,26 +80,26 @@ static inline void llist_init(struct llist **list)static struct llist *llist_copy (struct llist *list) {struct llist *ret; -struct llist_item *new, *old, *prev; +struct llist_item *new_item, *old_item, *prev;llist_init (&ret);if ((ret->size = list->size) ==0 )return ret; - new = ret->front =llist_item_get (); - new->sha1 = list->front->sha1; + new_item = ret->front =llist_item_get (); + new_item->sha1 = list->front->sha1; - old = list->front->next; -while (old) { - prev = new; - new =llist_item_get (); - prev->next = new; - new->sha1 = old->sha1; - old = old->next; + old_item = list->front->next; +while (old_item) { + prev = new_item; + new_item =llist_item_get (); + prev->next = new_item; + new_item->sha1 = old_item->sha1; + old_item = old_item->next; } - new->next =NULL ; - ret->back = new; + new_item->next =NULL ; + ret->back = new_item;return ret; }
@@ -108,24 +108,24 @@ static inline struct llist_item *llist_insert(struct llist *list,struct llist_item *after, const unsigned char *sha1) { - struct llist_item *new = llist_item_get(); - new->sha1 = sha1; - new->next =NULL ; + struct llist_item *new_item = llist_item_get(); + new_item->sha1 = sha1; + new_item->next =NULL ;if (after !=NULL ) { - new->next = after->next; - after->next = new; + new_item->next = after->next; + after->next = new_item;if (after == list->back) - list->back = new; + list->back = new_item; }else {/* insert in front */ if (list->size ==0 ) - list->back = new; + list->back = new_item;else - new->next = list->front; - list->front = new; + new_item->next = list->front; + list->front = new_item; } list->size++; -return new; +return new_item; } static inline struct llist_item *llist_insert_back(struct llist *list,
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 12/37 reflog: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/reflog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
builtin/reflog.c +4 -4
@@ -289,20 +289,20 @@ static int should_expire_reflog_ent(struct object_id *ooid, struct object_id *no const char *message, void *cb_data) { struct expire_reflog_policy_cb *cb = cb_data; -struct commit *old, *new; +struct commit *old_commit, *new_commit;if (timestamp < cb->cmd.expire_total)return 1 ; - old = new =NULL ; + old_commit = new_commit =NULL ;if (cb->cmd.stalefix && - (!keep_entry (&old, ooid) || !keep_entry (&new, noid))) + (!keep_entry (&old_commit, ooid) || !keep_entry (&new_commit, noid)))return 1 ;if (timestamp < cb->cmd.expire_unreachable) {if (cb->unreachable_expire_kind ==UE_ALWAYS )return 1 ; -if (unreachable (cb, old, ooid) ||unreachable (cb, new, noid)) +if (unreachable (cb, old_commit, ooid) ||unreachable (cb, new_commit, noid))return 1 ; }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 13/37 remote: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/remote.c | 66 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-)
builtin/remote.c +33 -33
@@ -322,7 +322,7 @@ static void read_branches(void)struct ref_states {struct remote *remote; -struct string_list new, stale, tracked, heads, push; +struct string_list new_refs, stale, tracked, heads, push;int queried; };
@@ -337,12 +337,12 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *statdie (_ ("Could not get fetch map for refspec %s" ), states->remote->fetch_refspec[i]); - states->new.strdup_strings =1 ; + states->new_refs.strdup_strings =1 ; states->tracked.strdup_strings =1 ; states->stale.strdup_strings =1 ;for (ref = fetch_map; ref; ref = ref->next) {if (!ref->peer_ref || !ref_exists (ref->peer_ref->name)) -string_list_append (&states->new,abbrev_branch (ref->name)); +string_list_append (&states->new_refs,abbrev_branch (ref->name));else string_list_append (&states->tracked,abbrev_branch (ref->name)); }
@@ -356,7 +356,7 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *statfree_refs (stale_refs);free_refs (fetch_map); -string_list_sort (&states->new); +string_list_sort (&states->new_refs);string_list_sort (&states->tracked);string_list_sort (&states->stale);
@@ -546,8 +546,8 @@ static int add_branch_for_removal(const char *refname, }struct rename_info { -const char *old; -const char *new; +const char *old_name; +const char *new_name;struct string_list *remote_branches; };
@@ -560,7 +560,7 @@ static int read_remote_branches(const char *refname,int flag;const char *symref; -strbuf_addf (&buf,"refs/remotes/%s/" , rename->old); +strbuf_addf (&buf,"refs/remotes/%s/" , rename->old_name);if (starts_with (refname, buf.buf)) { item =string_list_append (rename->remote_branches,xstrdup (refname)); symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
@@ -615,36 +615,36 @@ static int mv(int argc, const char **argv)if (argc !=3 )usage_with_options (builtin_remote_rename_usage, options); - rename.old = argv[1 ]; - rename.new = argv[2 ]; + rename.old_name = argv[1 ]; + rename.new_name = argv[2 ]; rename.remote_branches = &remote_branches; - oldremote =remote_get (rename.old); + oldremote =remote_get (rename.old_name);if (!remote_is_configured (oldremote,1 )) -die (_ ("No such remote: %s" ), rename.old); +die (_ ("No such remote: %s" ), rename.old_name); -if (!strcmp (rename.old, rename.new) && oldremote->origin !=REMOTE_CONFIG ) +if (!strcmp (rename.old_name, rename.new_name) && oldremote->origin !=REMOTE_CONFIG )return migrate_file (oldremote); - newremote =remote_get (rename.new); + newremote =remote_get (rename.new_name);if (remote_is_configured (newremote,1 )) -die (_ ("remote %s already exists." ), rename.new); +die (_ ("remote %s already exists." ), rename.new_name); -strbuf_addf (&buf,"refs/heads/test:refs/remotes/%s/test" , rename.new); +strbuf_addf (&buf,"refs/heads/test:refs/remotes/%s/test" , rename.new_name);if (!valid_fetch_refspec (buf.buf)) -die (_ ("'%s' is not a valid remote name" ), rename.new); +die (_ ("'%s' is not a valid remote name" ), rename.new_name);strbuf_reset (&buf); -strbuf_addf (&buf,"remote.%s" , rename.old); -strbuf_addf (&buf2,"remote.%s" , rename.new); +strbuf_addf (&buf,"remote.%s" , rename.old_name); +strbuf_addf (&buf2,"remote.%s" , rename.new_name);if (git_config_rename_section (buf.buf, buf2.buf) <1 )return error (_ ("Could not rename config section '%s' to '%s'" ), buf.buf, buf2.buf);strbuf_reset (&buf); -strbuf_addf (&buf,"remote.%s.fetch" , rename.new); +strbuf_addf (&buf,"remote.%s.fetch" , rename.new_name);git_config_set_multivar (buf.buf,NULL ,NULL ,1 ); -strbuf_addf (&old_remote_context,":refs/remotes/%s/" , rename.old); +strbuf_addf (&old_remote_context,":refs/remotes/%s/" , rename.old_name);for (i =0 ; i < oldremote->fetch_refspec_nr; i++) {char *ptr;
@@ -655,8 +655,8 @@ static int mv(int argc, const char **argv) refspec_updated =1 ;strbuf_splice (&buf2, ptr-buf2.buf +strlen (":refs/remotes/" ), -strlen (rename.old), rename.new, -strlen (rename.new)); +strlen (rename.old_name), rename.new_name, +strlen (rename.new_name)); }else warning(_("Not updating non-default fetch refspec\n" "\t%s\n"
@@ -670,10 +670,10 @@ static int mv(int argc, const char **argv)for (i =0 ; i < branch_list.nr; i++) {struct string_list_item *item = branch_list.items + i;struct branch_info *info = item->util; -if (info->remote_name && !strcmp (info->remote_name, rename.old)) { +if (info->remote_name && !strcmp (info->remote_name, rename.old_name)) {strbuf_reset (&buf);strbuf_addf (&buf,"branch.%s.remote" , item->string); -git_config_set (buf.buf, rename.new); +git_config_set (buf.buf, rename.new_name); } }
@@ -703,8 +703,8 @@ static int mv(int argc, const char **argv)continue ;strbuf_reset (&buf);strbuf_addstr (&buf, item->string); -strbuf_splice (&buf,strlen ("refs/remotes/" ),strlen (rename.old), - rename.new,strlen (rename.new)); +strbuf_splice (&buf,strlen ("refs/remotes/" ),strlen (rename.old_name), + rename.new_name,strlen (rename.new_name));strbuf_reset (&buf2);strbuf_addf (&buf2,"remote: renamed %s to %s" , item->string, buf.buf);
@@ -718,12 +718,12 @@ static int mv(int argc, const char **argv)continue ;strbuf_reset (&buf);strbuf_addstr (&buf, item->string); -strbuf_splice (&buf,strlen ("refs/remotes/" ),strlen (rename.old), - rename.new,strlen (rename.new)); +strbuf_splice (&buf,strlen ("refs/remotes/" ),strlen (rename.old_name), + rename.new_name,strlen (rename.new_name));strbuf_reset (&buf2);strbuf_addstr (&buf2, item->util); -strbuf_splice (&buf2,strlen ("refs/remotes/" ),strlen (rename.old), - rename.new,strlen (rename.new)); +strbuf_splice (&buf2,strlen ("refs/remotes/" ),strlen (rename.old_name), + rename.new_name,strlen (rename.new_name));strbuf_reset (&buf3);strbuf_addf (&buf3,"remote: renamed %s to %s" , item->string, buf.buf);
@@ -822,7 +822,7 @@ static void clear_push_info(void *util, const char *string)static void free_remote_ref_states (struct ref_states *states) { -string_list_clear (&states->new,0 ); +string_list_clear (&states->new_refs,0 );string_list_clear (&states->stale,1 );string_list_clear (&states->tracked,0 );string_list_clear (&states->heads,0 );
@@ -907,7 +907,7 @@ static int show_remote_info_item(struct string_list_item *item, void *cb_data)if (states->queried) {const char *fmt ="%s" ;const char *arg ="" ; -if (string_list_has_string (&states->new, name)) { +if (string_list_has_string (&states->new_refs, name)) { fmt =_ (" new (next fetch will store in remotes/%s)" ); arg = states->remote->name; }else if (string_list_has_string (&states->tracked, name))
@@ -1176,7 +1176,7 @@ static int show(int argc, const char **argv)/* remote branch info */ info.width =0 ; -for_each_string_list (&states.new, add_remote_to_show_info, &info); +for_each_string_list (&states.new_refs, add_remote_to_show_info, &info);for_each_string_list (&states.tracked, add_remote_to_show_info, &info);for_each_string_list (&states.stale, add_remote_to_show_info, &info);if (info.list->nr)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 14/37 combine-diff: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- combine-diff.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
combine-diff.c +6 -6
@@ -162,7 +162,7 @@ enum coalesce_direction { MATCH, BASE, NEW };/* Coalesce new lines into base by finding LCS */ static struct lline *coalesce_lines (struct lline *base,int *lenbase, -struct lline *new,int lennew, +struct lline *newline,int lennew,unsigned long parent,long flags) {int **lcs;
@@ -170,12 +170,12 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,struct lline *baseend, *newend =NULL ;int i, j, origbaselen = *lenbase; -if (new ==NULL ) +if (newline ==NULL )return base;if (base ==NULL ) { *lenbase = lennew; -return new; +return newline; }/*
@@ -200,7 +200,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase, directions[0 ][j] =NEW ;for (i =1 , baseend = base; i < origbaselen +1 ; i++) { -for (j =1 , newend = new; j < lennew +1 ; j++) { +for (j =1 , newend = newline; j < lennew +1 ; j++) {if (match_string_spaces (baseend->line, baseend->len, newend->line, newend->len, flags)) { lcs[i][j] = lcs[i -1 ][j -1 ] +1 ;
@@ -241,7 +241,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,if (lline->prev) lline->prev->next = lline->next;else - new = lline->next; + newline = lline->next;if (lline->next) lline->next->prev = lline->prev;
@@ -270,7 +270,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase, } } - newend = new; + newend = newline;while (newend) {struct lline *lline = newend; newend = newend->next;
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 15/37 commit: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- commit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
commit.c +9 -9
@@ -861,19 +861,19 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)commit_list_insert (in->item, &ret);for (i = in->next; i; i = i->next) { -struct commit_list *new =NULL , *end =NULL ; +struct commit_list *new_commits =NULL , *end =NULL ;for (j = ret; j; j = j->next) {struct commit_list *bases; bases =get_merge_bases (i->item, j->item); -if (!new) - new = bases; +if (!new_commits) + new_commits = bases;else end->next = bases;for (k = bases; k; k = k->next) end = k; } - ret = new; + ret = new_commits; }return ret; }
@@ -1617,11 +1617,11 @@ struct commit *get_merge_parent(const char *name)struct commit_list **commit_list_append (struct commit *commit,struct commit_list **next) { -struct commit_list *new =xmalloc (sizeof (struct commit_list )); - new->item = commit; - *next = new; - new->next =NULL ; -return &new->next; +struct commit_list *new_commit =xmalloc (sizeof (struct commit_list )); + new_commit->item = commit; + *next = new_commit; + new_commit->next =NULL ; +return &new_commit->next; }const char *find_commit_header (const char *msg,const char *key,size_t *out_len)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 16/37 diff-lib: rename 'new' variable
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diff-lib.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
diff-lib.c +19 -19
@@ -302,7 +302,7 @@ static int get_stat_data(const struct cache_entry *ce, }static void show_new_file (struct rev_info *revs, -const struct cache_entry *new, +const struct cache_entry *new_file,int cached,int match_missing) {const struct object_id *oid;
@@ -313,16 +313,16 @@ static void show_new_file(struct rev_info *revs,* New file in the index: it might actually be different in * the working tree. */ -if (get_stat_data (new, &oid, &mode, cached, match_missing, +if (get_stat_data (new_file, &oid, &mode, cached, match_missing, &dirty_submodule, &revs->diffopt) <0 )return ; -diff_index_show_file (revs,"+" , new, oid, !is_null_oid (oid), mode, dirty_submodule); +diff_index_show_file (revs,"+" , new_file, oid, !is_null_oid (oid), mode, dirty_submodule); }static int show_modified (struct rev_info *revs, -const struct cache_entry *old, -const struct cache_entry *new, +const struct cache_entry *old_entry, +const struct cache_entry *new_entry,int report_missing,int cached,int match_missing) {
@@ -330,47 +330,47 @@ static int show_modified(struct rev_info *revs,const struct object_id *oid;unsigned dirty_submodule =0 ; -if (get_stat_data (new, &oid, &mode, cached, match_missing, +if (get_stat_data (new_entry, &oid, &mode, cached, match_missing, &dirty_submodule, &revs->diffopt) <0 ) {if (report_missing) -diff_index_show_file (revs,"-" , old, - &old->oid,1 , old->ce_mode, +diff_index_show_file (revs,"-" , old_entry, + &old_entry->oid,1 , old_entry->ce_mode,0 );return -1 ; }if (revs->combine_merges && !cached && - (oidcmp (oid, &old->oid) ||oidcmp (&old->oid, &new->oid))) { + (oidcmp (oid, &old_entry->oid) ||oidcmp (&old_entry->oid, &new_entry->oid))) {struct combine_diff_path *p; -int pathlen =ce_namelen (new); +int pathlen =ce_namelen (new_entry); p =xmalloc (combine_diff_path_size (2 , pathlen)); p->path = (char *) &p->parent[2 ]; p->next =NULL ; -memcpy (p->path, new->name, pathlen); +memcpy (p->path, new_entry->name, pathlen); p->path[pathlen] =0 ; p->mode = mode;oidclr (&p->oid);memset (p->parent,0 ,2 *sizeof (struct combine_diff_parent )); p->parent[0 ].status =DIFF_STATUS_MODIFIED ; - p->parent[0 ].mode = new->ce_mode; -oidcpy (&p->parent[0 ].oid, &new->oid); + p->parent[0 ].mode = new_entry->ce_mode; +oidcpy (&p->parent[0 ].oid, &new_entry->oid); p->parent[1 ].status =DIFF_STATUS_MODIFIED ; - p->parent[1 ].mode = old->ce_mode; -oidcpy (&p->parent[1 ].oid, &old->oid); + p->parent[1 ].mode = old_entry->ce_mode; +oidcpy (&p->parent[1 ].oid, &old_entry->oid);show_combined_diff (p,2 , revs->dense_combined_merges, revs);free (p);return 0 ; } - oldmode = old->ce_mode; -if (mode == oldmode && !oidcmp (oid, &old->oid) && !dirty_submodule && + oldmode = old_entry->ce_mode; +if (mode == oldmode && !oidcmp (oid, &old_entry->oid) && !dirty_submodule && !revs->diffopt.flags.find_copies_harder)return 0 ;diff_change (&revs->diffopt, oldmode, mode, - &old->oid, oid,1 , !is_null_oid (oid), - old->name,0 , dirty_submodule); + &old_entry->oid, oid,1 , !is_null_oid (oid), + old_entry->name,0 , dirty_submodule);return 0 ; }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 17/37 diff: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diff.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
diff.c +22 -22
@@ -1504,7 +1504,7 @@ struct diff_words_style_elem {struct diff_words_style {enum diff_words_type type; -struct diff_words_style_elem new, old, ctx; +struct diff_words_style_elem new_word, old_word, ctx;const char *newline; };
@@ -1655,12 +1655,12 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len) }if (minus_begin != minus_end) {fn_out_diff_words_write_helper (diff_words->opt, - &style->old, style->newline, + &style->old_word, style->newline, minus_end - minus_begin, minus_begin); }if (plus_begin != plus_end) {fn_out_diff_words_write_helper (diff_words->opt, - &style->new, style->newline, + &style->new_word, style->newline, plus_end - plus_begin, plus_begin); }
@@ -1758,7 +1758,7 @@ static void diff_words_show(struct diff_words_data *diff_words)emit_diff_symbol (diff_words->opt,DIFF_SYMBOL_WORD_DIFF , line_prefix,strlen (line_prefix),0 );fn_out_diff_words_write_helper (diff_words->opt, - &style->old, style->newline, + &style->old_word, style->newline, diff_words->minus.text.size, diff_words->minus.text.ptr); diff_words->minus.text.size =0 ;
@@ -1883,8 +1883,8 @@ static void init_diff_words_data(struct emit_callback *ecbdata, }if (want_color (o->use_color)) {struct diff_words_style *st = ecbdata->diff_words->style; - st->old.color =diff_get_color_opt (o,DIFF_FILE_OLD ); - st->new.color =diff_get_color_opt (o,DIFF_FILE_NEW ); + st->old_word.color =diff_get_color_opt (o,DIFF_FILE_OLD ); + st->new_word.color =diff_get_color_opt (o,DIFF_FILE_NEW ); st->ctx.color =diff_get_color_opt (o,DIFF_CONTEXT ); } }
@@ -2047,8 +2047,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)static char *pprint_rename (const char *a,const char *b) { -const char *old = a; -const char *new = b; +const char *old_name = a; +const char *new_name = b;struct strbuf name =STRBUF_INIT ;int pfx_length, sfx_length;int pfx_adjust_for_slash;
@@ -2067,16 +2067,16 @@ static char *pprint_rename(const char *a, const char *b)/* Find common prefix */ pfx_length =0 ; -while (*old && *new && *old == *new) { -if (*old =='/' ) - pfx_length = old - a +1 ; - old++; - new++; +while (*old_name && *new_name && *old_name == *new_name) { +if (*old_name =='/' ) + pfx_length = old_name - a +1 ; + old_name++; + new_name++; }/* Find common suffix */ - old = a + len_a; - new = b + len_b; + old_name = a + len_a; + new_name = b + len_b; sfx_length =0 ;/* * If there is a common prefix, it must end in a slash. In
@@ -2087,13 +2087,13 @@ static char *pprint_rename(const char *a, const char *b)* underrun the input strings. */ pfx_adjust_for_slash = (pfx_length ?1 :0 ); -while (a + pfx_length - pfx_adjust_for_slash <= old && - b + pfx_length - pfx_adjust_for_slash <= new && - *old == *new) { -if (*old =='/' ) - sfx_length = len_a - (old - a); - old--; - new--; +while (a + pfx_length - pfx_adjust_for_slash <= old_name && + b + pfx_length - pfx_adjust_for_slash <= new_name && + *old_name == *new_name) { +if (*old_name =='/' ) + sfx_length = len_a - (old_name - a); + old_name--; + new_name--; }/*
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 18/37 diffcore-delta: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diffcore-delta.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diffcore-delta.c +8 -8
@@ -48,16 +48,16 @@ struct spanhash_top {static struct spanhash_top *spanhash_rehash (struct spanhash_top *orig) { -struct spanhash_top *new; +struct spanhash_top *new_spanhash;int i;int osz =1 << orig->alloc_log2;int sz = osz <<1 ; - new =xmalloc (st_add (sizeof (*orig), + new_spanhash =xmalloc (st_add (sizeof (*orig),st_mult (sizeof (struct spanhash ), sz))); - new->alloc_log2 = orig->alloc_log2 +1 ; - new->free =INITIAL_FREE (new->alloc_log2); -memset (new->data,0 ,sizeof (struct spanhash ) * sz); + new_spanhash->alloc_log2 = orig->alloc_log2 +1 ; + new_spanhash->free =INITIAL_FREE (new_spanhash->alloc_log2); +memset (new_spanhash->data,0 ,sizeof (struct spanhash ) * sz);for (i =0 ; i < osz; i++) {struct spanhash *o = &(orig->data[i]);int bucket;
@@ -65,11 +65,11 @@ static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig)continue ; bucket = o->hashval & (sz -1 );while (1 ) { -struct spanhash *h = &(new->data[bucket++]); +struct spanhash *h = &(new_spanhash->data[bucket++]);if (!h->cnt) { h->hashval = o->hashval; h->cnt = o->cnt; - new->free--; + new_spanhash->free--;break ; }if (sz <= bucket)
@@ -77,7 +77,7 @@ static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig) } }free (orig); -return new; +return new_spanhash; } static struct spanhash_top *add_spanhash(struct spanhash_top *top,
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 19/37 entry: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- entry.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
entry.c +20 -20
@@ -85,12 +85,12 @@ static int create_file(const char *path, unsigned int mode)static void *read_blob_entry (const struct cache_entry *ce,unsigned long *size) {enum object_type type; -void *new =read_sha1_file (ce->oid.hash, &type, size); +void *blob_data =read_sha1_file (ce->oid.hash, &type, size); -if (new) { +if (blob_data) {if (type ==OBJ_BLOB ) -return new; -free (new); +return blob_data; +free (blob_data); }return NULL ; }
@@ -256,7 +256,7 @@ static int write_entry(struct cache_entry *ce,unsigned int ce_mode_s_ifmt = ce->ce_mode &S_IFMT ;struct delayed_checkout *dco = state->delayed_checkout;int fd, ret, fstat_done =0 ; -char *new; +char *new_blob;struct strbuf buf =STRBUF_INIT ;unsigned long size;ssize_t wrote;
@@ -276,8 +276,8 @@ static int write_entry(struct cache_entry *ce,switch (ce_mode_s_ifmt) {case S_IFLNK : - new =read_blob_entry (ce, &size); -if (!new) + new_blob =read_blob_entry (ce, &size); +if (!new_blob)return error ("unable to read sha1 file of %s (%s)" , path,oid_to_hex (&ce->oid));
@@ -288,8 +288,8 @@ static int write_entry(struct cache_entry *ce,if (!has_symlinks || to_tempfile) goto write_file_entry; - ret =symlink (new, path); -free (new); + ret =symlink (new_blob, path); +free (new_blob);if (ret)return error_errno ("unable to create symlink %s" , path);break ;
@@ -300,11 +300,11 @@ static int write_entry(struct cache_entry *ce,* bother reading it at all. */ if (dco && dco->state ==CE_RETRY ) { - new =NULL ; + new_blob =NULL ; size =0 ; }else { - new =read_blob_entry (ce, &size); -if (!new) + new_blob =read_blob_entry (ce, &size); +if (!new_blob)return error ("unable to read sha1 file of %s (%s)" , path,oid_to_hex (&ce->oid)); }
@@ -313,18 +313,18 @@ static int write_entry(struct cache_entry *ce,* Convert from git internal format to working tree format */ if (dco && dco->state !=CE_NO_DELAY ) { - ret =async_convert_to_working_tree (ce->name, new, + ret =async_convert_to_working_tree (ce->name, new_blob, size, &buf, dco);if (ret &&string_list_has_string (&dco->paths, ce->name)) { -free (new); +free (new_blob); goto delayed; } }else - ret =convert_to_working_tree (ce->name, new, size, &buf); + ret =convert_to_working_tree (ce->name, new_blob, size, &buf);if (ret) { -free (new); - new =strbuf_detach (&buf, &newsize); +free (new_blob); + new_blob =strbuf_detach (&buf, &newsize); size = newsize; }/*
@@ -336,15 +336,15 @@ static int write_entry(struct cache_entry *ce, write_file_entry: fd =open_output_fd (path, ce, to_tempfile);if (fd <0 ) { -free (new); +free (new_blob);return error_errno ("unable to create file %s" , path); } - wrote =write_in_full (fd, new, size); + wrote =write_in_full (fd, new_blob, size);if (!to_tempfile) fstat_done =fstat_output (fd, state, &st);close (fd); -free (new); +free (new_blob);if (wrote <0 )return error ("unable to write file %s" , path);break ;
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 20/37 http: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- http.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
http.c +5 -5
@@ -1194,14 +1194,14 @@ static struct fill_chain *fill_cfg;void add_fill_function (void *data,int (*fill)(void *)) { -struct fill_chain *new =xmalloc (sizeof (*new)); +struct fill_chain *new_fill =xmalloc (sizeof (*new_fill));struct fill_chain **linkp = &fill_cfg; - new->data = data; - new->fill = fill; - new->next =NULL ; + new_fill->data = data; + new_fill->fill = fill; + new_fill->next =NULL ;while (*linkp) linkp = &(*linkp)->next; - *linkp = new; + *linkp = new_fill; }void fill_active_slots (void )
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 21/37 imap-send: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- imap-send.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
imap-send.c +7 -7
@@ -1189,11 +1189,11 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f*/ static void lf_to_crlf (struct strbuf *msg) { -char *new; +char *new_msg;size_t i, j;char lastc; -/* First pass: tally, in j, the size of the new string: */ +/* First pass: tally, in j, the size of the new_msg string: */ for (i = j =0 , lastc ='\0' ; i < msg->len; i++) {if (msg->buf[i] =='\n' && lastc !='\r' ) j++;/* a CR will need to be added here */
@@ -1201,18 +1201,18 @@ static void lf_to_crlf(struct strbuf *msg) j++; } - new =xmallocz (j); + new_msg =xmallocz (j);/* -* Second pass: write the new string. Note that this loop is +* Second pass: write the new_msg string. Note that this loop is * otherwise identical to the first pass. */ for (i = j =0 , lastc ='\0' ; i < msg->len; i++) {if (msg->buf[i] =='\n' && lastc !='\r' ) - new[j++] ='\r' ; - lastc = new[j++] = msg->buf[i]; + new_msg[j++] ='\r' ; + lastc = new_msg[j++] = msg->buf[i]; } -strbuf_attach (msg, new, j, j +1 ); +strbuf_attach (msg, new_msg, j, j +1 ); }/*
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 22/37 line-log: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- line-log.c | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-)
line-log.c +28 -28
@@ -151,29 +151,29 @@ static void range_set_union(struct range_set *out,assert (out->nr ==0 );while (i < a->nr || j < b->nr) { -struct range *new; +struct range *new_range;if (i < a->nr && j < b->nr) {if (ra[i].start < rb[j].start) - new = &ra[i++]; + new_range = &ra[i++];else if (ra[i].start > rb[j].start) - new = &rb[j++]; + new_range = &rb[j++];else if (ra[i].end < rb[j].end) - new = &ra[i++]; + new_range = &ra[i++];else - new = &rb[j++]; + new_range = &rb[j++]; }else if (i < a->nr)/* b exhausted */ - new = &ra[i++]; + new_range = &ra[i++];else /* a exhausted */ - new = &rb[j++]; -if (new->start == new->end) + new_range = &rb[j++]; +if (new_range->start == new_range->end) ;/* empty range */ -else if (!out->nr || out->ranges[out->nr-1 ].end < new->start) { +else if (!out->nr || out->ranges[out->nr-1 ].end < new_range->start) {range_set_grow (out,1 ); - out->ranges[out->nr].start = new->start; - out->ranges[out->nr].end = new->end; + out->ranges[out->nr].start = new_range->start; + out->ranges[out->nr].end = new_range->end; out->nr++; - }else if (out->ranges[out->nr-1 ].end < new->end) { - out->ranges[out->nr-1 ].end = new->end; + }else if (out->ranges[out->nr-1 ].end < new_range->end) { + out->ranges[out->nr-1 ].end = new_range->end; } } }
@@ -696,18 +696,18 @@ static struct line_log_data *line_log_data_merge(struct line_log_data *a,static void add_line_range (struct rev_info *revs,struct commit *commit,struct line_log_data *range) { -struct line_log_data *old =NULL ; -struct line_log_data *new =NULL ; +struct line_log_data *old_line =NULL ; +struct line_log_data *new_line =NULL ; - old =lookup_decoration (&revs->line_log_data, &commit->object); -if (old && range) { - new =line_log_data_merge (old, range); -free_line_log_data (old); + old_line =lookup_decoration (&revs->line_log_data, &commit->object); +if (old_line && range) { + new_line =line_log_data_merge (old_line, range); +free_line_log_data (old_line); }else if (range) - new =line_log_data_copy (range); + new_line =line_log_data_copy (range); -if (new) -add_decoration (&revs->line_log_data, &commit->object, new); +if (new_line) +add_decoration (&revs->line_log_data, &commit->object, new_line); }static void clear_commit_line_range (struct rev_info *revs,struct commit *commit)
@@ -1042,12 +1042,12 @@ static int process_diff_filepair(struct rev_info *rev,static struct diff_filepair *diff_filepair_dup (struct diff_filepair *pair) { -struct diff_filepair *new =xmalloc (sizeof (struct diff_filepair )); - new->one = pair->one; - new->two = pair->two; - new->one->count++; - new->two->count++; -return new; +struct diff_filepair *new_filepair =xmalloc (sizeof (struct diff_filepair )); + new_filepair->one = pair->one; + new_filepair->two = pair->two; + new_filepair->one->count++; + new_filepair->two->count++; +return new_filepair; }static void free_diffqueues (int n,struct diff_queue_struct *dq)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 23/37 read-cache: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- read-cache.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
read-cache.c +20 -20
@@ -70,20 +70,20 @@ static void replace_index_entry(struct index_state *istate, int nr, struct cachevoid rename_index_entry_at (struct index_state *istate,int nr,const char *new_name) { -struct cache_entry *old = istate->cache[nr], *new; +struct cache_entry *old_entry = istate->cache[nr], *new_entry;int namelen =strlen (new_name); - new =xmalloc (cache_entry_size (namelen)); -copy_cache_entry (new, old); - new->ce_flags &= ~CE_HASHED ; - new->ce_namelen = namelen; - new->index =0 ; -memcpy (new->name, new_name, namelen +1 ); + new_entry =xmalloc (cache_entry_size (namelen)); +copy_cache_entry (new_entry, old_entry); + new_entry->ce_flags &= ~CE_HASHED ; + new_entry->ce_namelen = namelen; + new_entry->index =0 ; +memcpy (new_entry->name, new_name, namelen +1 ); -cache_tree_invalidate_path (istate, old->name); -untracked_cache_remove_from_index (istate, old->name); +cache_tree_invalidate_path (istate, old_entry->name); +untracked_cache_remove_from_index (istate, old_entry->name);remove_index_entry_at (istate, nr); -add_index_entry (istate, new,ADD_CACHE_OK_TO_ADD |ADD_CACHE_OK_TO_REPLACE ); +add_index_entry (istate, new_entry,ADD_CACHE_OK_TO_ADD |ADD_CACHE_OK_TO_REPLACE ); }void fill_stat_data (struct stat_data *sd,struct stat *st)
@@ -615,18 +615,18 @@ static struct cache_entry *create_alias_ce(struct index_state *istate, struct cache_entry *alias) {int len; -struct cache_entry *new; +struct cache_entry *new_entry;if (alias->ce_flags &CE_ADDED )die ("Will not add file alias '%s' ('%s' already exists in index)" , ce->name, alias->name);/* Ok, create the new entry using the name of the existing alias */ len =ce_namelen (alias); - new =xcalloc (1 ,cache_entry_size (len)); -memcpy (new->name, alias->name, len); -copy_cache_entry (new, ce); + new_entry =xcalloc (1 ,cache_entry_size (len)); +memcpy (new_entry->name, alias->name, len); +copy_cache_entry (new_entry, ce);save_or_free_index_entry (istate, ce); -return new; +return new_entry; }void set_object_name_for_intent_to_add_entry (struct cache_entry *ce)
@@ -1379,7 +1379,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, added_fmt = (in_porcelain ?"A\t%s\n" :"%s needs update\n" ); unmerged_fmt = (in_porcelain ?"U\t%s\n" :"%s: needs merge\n" );for (i =0 ; i < istate->cache_nr; i++) { -struct cache_entry *ce, *new; +struct cache_entry *ce, *new_entry;int cache_errno =0 ;int changed =0 ;int filtered =0 ;
@@ -1408,10 +1408,10 @@ int refresh_index(struct index_state *istate, unsigned int flags,if (filtered)continue ; - new =refresh_cache_ent (istate, ce, options, &cache_errno, &changed); -if (new == ce) + new_entry =refresh_cache_ent (istate, ce, options, &cache_errno, &changed); +if (new_entry == ce)continue ; -if (!new) { +if (!new_entry) {const char *fmt;if (really && cache_errno ==EINVAL ) {
@@ -1440,7 +1440,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,continue ; } -replace_index_entry (istate, i, new); +replace_index_entry (istate, i, new_entry); }return has_errors; }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 24/37 ref-filter: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- ref-filter.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
ref-filter.c +8 -8
@@ -529,12 +529,12 @@ static void end_align_handler(struct ref_formatting_stack **stack)static void align_atom_handler (struct atom_value *atomv,struct ref_formatting_state *state) { -struct ref_formatting_stack *new; +struct ref_formatting_stack *new_stack;push_stack_element (&state->stack); - new = state->stack; - new->at_end = end_align_handler; - new->at_end_data = &atomv->atom->u.align; + new_stack = state->stack; + new_stack->at_end = end_align_handler; + new_stack->at_end_data = &atomv->atom->u.align; }static void if_then_else_handler (struct ref_formatting_stack **stack)
@@ -574,16 +574,16 @@ static void if_then_else_handler(struct ref_formatting_stack **stack)static void if_atom_handler (struct atom_value *atomv,struct ref_formatting_state *state) { -struct ref_formatting_stack *new; +struct ref_formatting_stack *new_stack;struct if_then_else *if_then_else =xcalloc (sizeof (struct if_then_else ),1 ); if_then_else->str = atomv->atom->u.if_then_else.str; if_then_else->cmp_status = atomv->atom->u.if_then_else.cmp_status;push_stack_element (&state->stack); - new = state->stack; - new->at_end = if_then_else_handler; - new->at_end_data = if_then_else; + new_stack = state->stack; + new_stack->at_end = if_then_else_handler; + new_stack->at_end_data = if_then_else; }static int is_empty (const char *s)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 25/37 remote: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- remote.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
remote.c +10 -10
@@ -1970,33 +1970,33 @@ static void unmark_and_free(struct commit_list *list, unsigned int mark)int ref_newer (const struct object_id *new_oid,const struct object_id *old_oid) {struct object *o; -struct commit *old, *new; +struct commit *old_commit, *new_commit;struct commit_list *list, *used;int found =0 ;/* -* Both new and old must be commit-ish and new is descendant of -* old. Otherwise we require --force. +* Both new_commit and old_commit must be commit-ish and new_commit is descendant of +* old_commit. Otherwise we require --force. */ o =deref_tag (parse_object (old_oid),NULL ,0 );if (!o || o->type !=OBJ_COMMIT )return 0 ; - old = (struct commit *) o; + old_commit = (struct commit *) o; o =deref_tag (parse_object (new_oid),NULL ,0 );if (!o || o->type !=OBJ_COMMIT )return 0 ; - new = (struct commit *) o; + new_commit = (struct commit *) o; -if (parse_commit (new) <0 ) +if (parse_commit (new_commit) <0 )return 0 ; used = list =NULL ; -commit_list_insert (new, &list); +commit_list_insert (new_commit, &list);while (list) { - new =pop_most_recent_commit (&list,TMP_MARK ); -commit_list_insert (new, &used); -if (new == old) { + new_commit =pop_most_recent_commit (&list,TMP_MARK ); +commit_list_insert (new_commit, &used); +if (new_commit == old_commit) { found =1 ;break ; }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 26/37 split-index: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- split-index.c | 16 ++++++++-------- split-index.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-)
split-index.c +8 -8
@@ -303,17 +303,17 @@ void save_or_free_index_entry(struct index_state *istate, struct cache_entry *ce }void replace_index_entry_in_base (struct index_state *istate, -struct cache_entry *old, -struct cache_entry *new) +struct cache_entry *old_entry, +struct cache_entry *new_entry) { -if (old->index && +if (old_entry->index && istate->split_index && istate->split_index->base && - old->index <= istate->split_index->base->cache_nr) { - new->index = old->index; -if (old != istate->split_index->base->cache[new->index -1 ]) -free (istate->split_index->base->cache[new->index -1 ]); - istate->split_index->base->cache[new->index -1 ] = new; + old_entry->index <= istate->split_index->base->cache_nr) { + new_entry->index = old_entry->index; +if (old_entry != istate->split_index->base->cache[new_entry->index -1 ]) +free (istate->split_index->base->cache[new_entry->index -1 ]); + istate->split_index->base->cache[new_entry->index -1 ] = new_entry; } }
split-index.h +1 -1
@@ -21,7 +21,7 @@ struct split_index *init_split_index(struct index_state *istate);void save_or_free_index_entry (struct index_state *istate,struct cache_entry *ce);void replace_index_entry_in_base (struct index_state *istate,struct cache_entry *old, -struct cache_entry *new); +struct cache_entry *new_entry);int read_link_extension (struct index_state *istate,const void *data,unsigned long sz); int write_link_extension(struct strbuf *sb,
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 27/37 submodule: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- submodule.c | 30 +++++++++++++++--------------- submodule.h | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-)
submodule.c +15 -15
@@ -590,7 +590,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, struct object_id *one, struct object_id *two, unsigned dirty_submodule) { - const struct object_id *old = the_hash_algo->empty_tree, *new = the_hash_algo->empty_tree; + const struct object_id *old_oid = the_hash_algo->empty_tree, *new_oid = the_hash_algo->empty_tree;struct commit *left =NULL , *right =NULL ;struct commit_list *merge_bases =NULL ;struct child_process cp =CHILD_PROCESS_INIT ;
@@ -605,9 +605,9 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, goto done;if (left) - old = one; + old_oid = one;if (right) - new = two; + new_oid = two; cp.git_cmd =1 ; cp.dir = path;
@@ -630,7 +630,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,argv_array_pushf (&cp.args,"--dst-prefix=%s%s/" , o->b_prefix, path); } -argv_array_push (&cp.args,oid_to_hex (old)); +argv_array_push (&cp.args,oid_to_hex (old_oid));/* * If the submodule has modified content, we will diff against the * work tree, under the assumption that the user has asked for the
@@ -638,7 +638,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,* haven't yet been committed to the submodule yet. */ if (!(dirty_submodule &DIRTY_SUBMODULE_MODIFIED )) -argv_array_push (&cp.args,oid_to_hex (new)); +argv_array_push (&cp.args,oid_to_hex (new_oid));prepare_submodule_repo_env (&cp.env_array);if (start_command (&cp))
@@ -1578,8 +1578,8 @@ static void submodule_reset_index(const char *path)* pass NULL for old or new respectively. */ int submodule_move_head (const char *path, -const char *old, -const char *new, +const char *old_head, +const char *new_head,unsigned flags) {int ret =0 ;
@@ -1600,7 +1600,7 @@ int submodule_move_head(const char *path,else error_code_ptr =NULL ; -if (old && !is_submodule_populated_gently (path, error_code_ptr)) +if (old_head && !is_submodule_populated_gently (path, error_code_ptr))return 0 ; sub =submodule_from_path (&null_oid, path);
@@ -1608,14 +1608,14 @@ int submodule_move_head(const char *path,if (!sub)die ("BUG: could not get submodule information for '%s'" , path); -if (old && !(flags &SUBMODULE_MOVE_HEAD_FORCE )) { +if (old_head && !(flags &SUBMODULE_MOVE_HEAD_FORCE )) {/* Check if the submodule has a dirty index. */ if (submodule_has_dirty_index (sub))return error (_ ("submodule '%s' has dirty index" ), path); }if (!(flags &SUBMODULE_MOVE_HEAD_DRY_RUN )) { -if (old) { +if (old_head) {if (!submodule_uses_gitfile (path))absorb_git_dir_into_superproject ("" , path,ABSORB_GITDIR_RECURSE_SUBMODULES );
@@ -1629,7 +1629,7 @@ int submodule_move_head(const char *path,submodule_reset_index (path); } -if (old && (flags &SUBMODULE_MOVE_HEAD_FORCE )) { +if (old_head && (flags &SUBMODULE_MOVE_HEAD_FORCE )) {char *gitdir =xstrfmt ("%s/modules/%s" ,get_git_common_dir (), sub->name);connect_work_tree_and_git_dir (path, gitdir);
@@ -1658,9 +1658,9 @@ int submodule_move_head(const char *path,argv_array_push (&cp.args,"-m" );if (!(flags &SUBMODULE_MOVE_HEAD_FORCE )) -argv_array_push (&cp.args, old ? old :EMPTY_TREE_SHA1_HEX ); +argv_array_push (&cp.args, old_head ? old_head :EMPTY_TREE_SHA1_HEX ); -argv_array_push (&cp.args, new ? new :EMPTY_TREE_SHA1_HEX ); +argv_array_push (&cp.args, new_head ? new_head :EMPTY_TREE_SHA1_HEX );if (run_command (&cp)) { ret =-1 ;
@@ -1668,7 +1668,7 @@ int submodule_move_head(const char *path, }if (!(flags &SUBMODULE_MOVE_HEAD_DRY_RUN )) { -if (new) { +if (new_head) {child_process_init (&cp);/* also set the HEAD accordingly */ cp.git_cmd =1 ;
@@ -1677,7 +1677,7 @@ int submodule_move_head(const char *path,prepare_submodule_repo_env (&cp.env_array);argv_array_pushl (&cp.args,"update-ref" ,"HEAD" , -"--no-deref" , new,NULL ); +"--no-deref" , new_head,NULL );if (run_command (&cp)) { ret =-1 ;
submodule.h +1 -1
@@ -117,7 +117,7 @@ int submodule_to_gitdir(struct strbuf *buf, const char *submodule);#define SUBMODULE_MOVE_HEAD_FORCE (1<<1)extern int submodule_move_head (const char *path,const char *old, -const char *new, +const char *new_head,unsigned flags);/*
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 28/37 trailer: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- trailer.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
trailer.c +17 -17
@@ -174,12 +174,12 @@ static void print_all(FILE *outfile, struct list_head *head,static struct trailer_item *trailer_from_arg (struct arg_item *arg_tok) { -struct trailer_item *new =xcalloc (sizeof (*new),1 ); - new->token = arg_tok->token; - new->value = arg_tok->value; +struct trailer_item *new_item =xcalloc (sizeof (*new_item),1 ); + new_item->token = arg_tok->token; + new_item->value = arg_tok->value; arg_tok->token = arg_tok->value =NULL ;free_arg_item (arg_tok); -return new; +return new_item; } static void add_arg_to_input_list(struct trailer_item *on_tok,
@@ -666,30 +666,30 @@ static void parse_trailer(struct strbuf *tok, struct strbuf *val,static struct trailer_item *add_trailer_item (struct list_head *head,char *tok,char *val) { -struct trailer_item *new =xcalloc (sizeof (*new),1 ); - new->token = tok; - new->value = val; -list_add_tail (&new->list, head); -return new; +struct trailer_item *new_item =xcalloc (sizeof (*new_item),1 ); + new_item->token = tok; + new_item->value = val; +list_add_tail (&new_item->list, head); +return new_item; }static void add_arg_item (struct list_head *arg_head,char *tok,char *val,const struct conf_info *conf,const struct new_trailer_item *new_trailer_item) { -struct arg_item *new =xcalloc (sizeof (*new),1 ); - new->token = tok; - new->value = val; -duplicate_conf (&new->conf, conf); +struct arg_item *new_item =xcalloc (sizeof (*new_item),1 ); + new_item->token = tok; + new_item->value = val; +duplicate_conf (&new_item->conf, conf);if (new_trailer_item) {if (new_trailer_item->where !=WHERE_DEFAULT ) - new->conf.where = new_trailer_item->where; + new_item->conf.where = new_trailer_item->where;if (new_trailer_item->if_exists !=EXISTS_DEFAULT ) - new->conf.if_exists = new_trailer_item->if_exists; + new_item->conf.if_exists = new_trailer_item->if_exists;if (new_trailer_item->if_missing !=MISSING_DEFAULT ) - new->conf.if_missing = new_trailer_item->if_missing; + new_item->conf.if_missing = new_trailer_item->if_missing; } -list_add_tail (&new->list, arg_head); +list_add_tail (&new_item->list, arg_head); } static void process_command_line_args(struct list_head *arg_head,
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 29/37 unpack-trees: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- unpack-trees.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
unpack-trees.c +3 -3
@@ -194,10 +194,10 @@ static int do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,static struct cache_entry *dup_entry (const struct cache_entry *ce) {unsigned int size =ce_size (ce); -struct cache_entry *new =xmalloc (size); +struct cache_entry *new_entry =xmalloc (size); -memcpy (new, ce, size); -return new; +memcpy (new_entry, ce, size); +return new_entry; } static void add_entry(struct unpack_trees_options *o,
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 30/37 init-db: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/init-db.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
builtin/init-db.c +15 -15
@@ -24,11 +24,11 @@ static int init_is_bare_repository = 0;static int init_shared_repository =-1 ;static const char *init_db_template_dir; -static void copy_templates_1 (struct strbuf *path,struct strbuf *template, +static void copy_templates_1 (struct strbuf *path,struct strbuf *template_path,DIR *dir) {size_t path_baselen = path->len; -size_t template_baselen = template->len; +size_t template_baselen = template_path->len;struct dirent *de;/* Note: if ".git/hooks" file exists in the repository being
@@ -44,12 +44,12 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template,int exists =0 ;strbuf_setlen (path, path_baselen); -strbuf_setlen (template, template_baselen); +strbuf_setlen (template_path, template_baselen);if (de->d_name[0 ] =='.' )continue ;strbuf_addstr (path, de->d_name); -strbuf_addstr (template, de->d_name); +strbuf_addstr (template_path, de->d_name);if (lstat (path->buf, &st_git)) {if (errno !=ENOENT )die_errno (_ ("cannot stat '%s'" ), path->buf);
@@ -57,36 +57,36 @@ static void copy_templates_1(struct strbuf *path, struct strbuf *template,else exists =1 ; -if (lstat (template->buf, &st_template)) -die_errno (_ ("cannot stat template '%s'" ), template->buf); +if (lstat (template_path->buf, &st_template)) +die_errno (_ ("cannot stat template '%s'" ), template_path->buf);if (S_ISDIR (st_template.st_mode)) { -DIR *subdir =opendir (template->buf); +DIR *subdir =opendir (template_path->buf);if (!subdir) -die_errno (_ ("cannot opendir '%s'" ), template->buf); +die_errno (_ ("cannot opendir '%s'" ), template_path->buf);strbuf_addch (path,'/' ); -strbuf_addch (template,'/' ); -copy_templates_1 (path, template, subdir); +strbuf_addch (template_path,'/' ); +copy_templates_1 (path, template_path, subdir);closedir (subdir); }else if (exists)continue ;else if (S_ISLNK (st_template.st_mode)) {struct strbuf lnk =STRBUF_INIT ; -if (strbuf_readlink (&lnk, template->buf,0 ) <0 ) -die_errno (_ ("cannot readlink '%s'" ), template->buf); +if (strbuf_readlink (&lnk, template_path->buf,0 ) <0 ) +die_errno (_ ("cannot readlink '%s'" ), template_path->buf);if (symlink (lnk.buf, path->buf))die_errno (_ ("cannot symlink '%s' '%s'" ), lnk.buf, path->buf);strbuf_release (&lnk); }else if (S_ISREG (st_template.st_mode)) { -if (copy_file (path->buf, template->buf, st_template.st_mode)) +if (copy_file (path->buf, template_path->buf, st_template.st_mode))die_errno (_ ("cannot copy '%s' to '%s'" ), - template->buf, path->buf); + template_path->buf, path->buf); }else -error (_ ("ignoring template %s" ), template->buf); +error (_ ("ignoring template %s" ), template_path->buf); } }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 31/37 environment: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- cache.h | 2 +- environment.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
cache.h +1 -1
@@ -1673,7 +1673,7 @@ struct pack_entry {* usual "XXXXXX" trailer, and the resulting filename is written into the * "template" buffer. Returns the open descriptor. */ -extern int odb_mkstemp (struct strbuf *template,const char *pattern); +extern int odb_mkstemp (struct strbuf *temp_filename,const char *pattern);/* * Create a pack .keep file named "name" (which should generally be the output
environment.c +7 -7
@@ -247,7 +247,7 @@ char *get_object_directory(void)return the_repository->objectdir; } -int odb_mkstemp (struct strbuf *template,const char *pattern) +int odb_mkstemp (struct strbuf *temp_filename,const char *pattern) {int fd;/*
@@ -255,16 +255,16 @@ int odb_mkstemp(struct strbuf *template, const char *pattern)* restrictive except to remove write permission. */ int mode =0444 ; -git_path_buf (template,"objects/%s" , pattern); - fd =git_mkstemp_mode (template->buf, mode); +git_path_buf (temp_filename,"objects/%s" , pattern); + fd =git_mkstemp_mode (temp_filename->buf, mode);if (0 <= fd)return fd;/* slow path */ -/* some mkstemp implementations erase template on failure */ -git_path_buf (template,"objects/%s" , pattern); -safe_create_leading_directories (template->buf); -return xmkstemp_mode (template->buf, mode); +/* some mkstemp implementations erase temp_filename on failure */ +git_path_buf (temp_filename,"objects/%s" , pattern); +safe_create_leading_directories (temp_filename->buf); +return xmkstemp_mode (temp_filename->buf, mode); }int odb_pack_keep (const char *name)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 32/37 diff: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- diff.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff.c +5 -5
@@ -3660,15 +3660,15 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp, int mode) {struct strbuf buf =STRBUF_INIT ; -struct strbuf template =STRBUF_INIT ; +struct strbuf tempfile =STRBUF_INIT ;char *path_dup =xstrdup (path);const char *base =basename (path_dup);/* Generate "XXXXXX_basename.ext" */ -strbuf_addstr (&template,"XXXXXX_" ); -strbuf_addstr (&template, base); +strbuf_addstr (&tempfile,"XXXXXX_" ); +strbuf_addstr (&tempfile, base); - temp->tempfile =mks_tempfile_ts (template.buf,strlen (base) +1 ); + temp->tempfile =mks_tempfile_ts (tempfile.buf,strlen (base) +1 );if (!temp->tempfile)die_errno ("unable to create temp-file" ); if (convert_to_working_tree(path,
@@ -3683,7 +3683,7 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,oid_to_hex_r (temp->hex, oid);xsnprintf (temp->mode,sizeof (temp->mode),"%06o" , mode);strbuf_release (&buf); -strbuf_release (&template); +strbuf_release (&tempfile);free (path_dup); }
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 33/37 environment: rename 'namespace' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- environment.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
environment.c +5 -5
@@ -98,7 +98,7 @@ int ignore_untracked_cache_config;/* This is set by setup_git_dir_gently() and/or git_default_config() */ char *git_work_tree_cfg; -static char *namespace; +static char *git_namespace;static const char *super_prefix;
@@ -156,8 +156,8 @@ void setup_git_env(void)free (git_replace_ref_base); git_replace_ref_base =xstrdup (replace_ref_base ? replace_ref_base :"refs/replace/" ); -free (namespace); - namespace =expand_namespace (getenv (GIT_NAMESPACE_ENVIRONMENT )); +free (git_namespace); + git_namespace =expand_namespace (getenv (GIT_NAMESPACE_ENVIRONMENT )); shallow_file =getenv (GIT_SHALLOW_FILE_ENVIRONMENT );if (shallow_file)set_alternate_shallow_file (shallow_file,0 );
@@ -191,9 +191,9 @@ const char *get_git_common_dir(void)const char *get_git_namespace (void ) { -if (!namespace) +if (!git_namespace)BUG ("git environment hasn't been setup" ); -return namespace; +return git_namespace; }const char *strip_namespace (const char *namespaced_ref)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 34/37 wrapper: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- git-compat-util.h | 4 ++-- wrapper.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 22 deletions(-)
git-compat-util.h +2 -2
@@ -826,8 +826,8 @@ extern ssize_t xpread(int fd, void *buf, size_t len, off_t offset);extern int xdup (int fd);extern FILE *xfopen (const char *path,const char *mode);extern FILE *xfdopen (int fd,const char *mode); -extern int xmkstemp (char *template); -extern int xmkstemp_mode (char *template,int mode); +extern int xmkstemp (char *temp_filename); +extern int xmkstemp_mode (char *temp_filename,int mode);extern char *xgetcwd (void );extern FILE *fopen_for_writing (const char *path);extern FILE *fopen_or_warn (const char *path,const char *mode);
wrapper.c +20 -20
@@ -445,21 +445,21 @@ FILE *fopen_or_warn(const char *path, const char *mode)return NULL ; } -int xmkstemp (char *template) +int xmkstemp (char *filename_template) {int fd;char origtemplate[PATH_MAX ]; -strlcpy (origtemplate, template,sizeof (origtemplate)); +strlcpy (origtemplate, filename_template,sizeof (origtemplate)); - fd =mkstemp (template); + fd =mkstemp (filename_template);if (fd <0 ) {int saved_errno = errno;const char *nonrelative_template; -if (strlen (template) !=strlen (origtemplate)) - template = origtemplate; +if (strlen (filename_template) !=strlen (origtemplate)) + filename_template = origtemplate; - nonrelative_template =absolute_path (template); + nonrelative_template =absolute_path (filename_template); errno = saved_errno;die_errno ("Unable to create temporary file '%s'" , nonrelative_template);
@@ -481,7 +481,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)static const int num_letters =62 ;uint64_t value;struct timeval tv; -char *template; +char *filename_template;size_t len;int fd, count;
@@ -503,16 +503,16 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)*/ gettimeofday (&tv,NULL ); value = ((size_t )(tv.tv_usec <<16 )) ^ tv.tv_sec ^getpid (); - template = &pattern[len -6 - suffix_len]; + filename_template = &pattern[len -6 - suffix_len];for (count =0 ; count <TMP_MAX ; ++count) {uint64_t v = value;/* Fill in the random bits. */ - template[0 ] = letters[v % num_letters]; v /= num_letters; - template[1 ] = letters[v % num_letters]; v /= num_letters; - template[2 ] = letters[v % num_letters]; v /= num_letters; - template[3 ] = letters[v % num_letters]; v /= num_letters; - template[4 ] = letters[v % num_letters]; v /= num_letters; - template[5 ] = letters[v % num_letters]; v /= num_letters; + filename_template[0 ] = letters[v % num_letters]; v /= num_letters; + filename_template[1 ] = letters[v % num_letters]; v /= num_letters; + filename_template[2 ] = letters[v % num_letters]; v /= num_letters; + filename_template[3 ] = letters[v % num_letters]; v /= num_letters; + filename_template[4 ] = letters[v % num_letters]; v /= num_letters; + filename_template[5 ] = letters[v % num_letters]; v /= num_letters; fd =open (pattern,O_CREAT |O_EXCL |O_RDWR , mode);if (fd >=0 )
@@ -541,21 +541,21 @@ int git_mkstemp_mode(char *pattern, int mode)return git_mkstemps_mode (pattern,0 , mode); } -int xmkstemp_mode (char *template,int mode) +int xmkstemp_mode (char *filename_template,int mode) {int fd;char origtemplate[PATH_MAX ]; -strlcpy (origtemplate, template,sizeof (origtemplate)); +strlcpy (origtemplate, filename_template,sizeof (origtemplate)); - fd =git_mkstemp_mode (template, mode); + fd =git_mkstemp_mode (filename_template, mode);if (fd <0 ) {int saved_errno = errno;const char *nonrelative_template; -if (!template[0 ]) - template = origtemplate; +if (!filename_template[0 ]) + filename_template = origtemplate; - nonrelative_template =absolute_path (template); + nonrelative_template =absolute_path (filename_template); errno = saved_errno;die_errno ("Unable to create temporary file '%s'" , nonrelative_template);
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 35/37 tempfile: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- tempfile.c | 12 ++++++------ tempfile.h | 34 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 23 deletions(-)
tempfile.c +6 -6
@@ -165,11 +165,11 @@ struct tempfile *register_tempfile(const char *path)return tempfile; } -struct tempfile *mks_tempfile_sm (const char *template,int suffixlen,int mode) +struct tempfile *mks_tempfile_sm (const char *filename_template,int suffixlen,int mode) {struct tempfile *tempfile =new_tempfile (); -strbuf_add_absolute_path (&tempfile->filename, template); +strbuf_add_absolute_path (&tempfile->filename, filename_template); tempfile->fd =git_mkstemps_mode (tempfile->filename.buf, suffixlen, mode);if (tempfile->fd <0 ) {deactivate_tempfile (tempfile);
@@ -179,7 +179,7 @@ struct tempfile *mks_tempfile_sm(const char *template, int suffixlen, int mode)return tempfile; } -struct tempfile *mks_tempfile_tsm (const char *template,int suffixlen,int mode) +struct tempfile *mks_tempfile_tsm (const char *filename_template,int suffixlen,int mode) {struct tempfile *tempfile =new_tempfile ();const char *tmpdir;
@@ -188,7 +188,7 @@ struct tempfile *mks_tempfile_tsm(const char *template, int suffixlen, int mode)if (!tmpdir) tmpdir ="/tmp" ; -strbuf_addf (&tempfile->filename,"%s/%s" , tmpdir, template); +strbuf_addf (&tempfile->filename,"%s/%s" , tmpdir, filename_template); tempfile->fd =git_mkstemps_mode (tempfile->filename.buf, suffixlen, mode);if (tempfile->fd <0 ) {deactivate_tempfile (tempfile);
@@ -198,12 +198,12 @@ struct tempfile *mks_tempfile_tsm(const char *template, int suffixlen, int mode)return tempfile; } -struct tempfile *xmks_tempfile_m (const char *template,int mode) +struct tempfile *xmks_tempfile_m (const char *filename_template,int mode) {struct tempfile *tempfile;struct strbuf full_template =STRBUF_INIT ; -strbuf_add_absolute_path (&full_template, template); +strbuf_add_absolute_path (&full_template, filename_template); tempfile =mks_tempfile_m (full_template.buf, mode);if (!tempfile) die_errno("Unable to create temporary file '%s'",
tempfile.h +17 -17
@@ -135,58 +135,58 @@ extern struct tempfile *register_tempfile(const char *path);*/ /* See "mks_tempfile functions" above. */ -extern struct tempfile *mks_tempfile_sm (const char *template, +extern struct tempfile *mks_tempfile_sm (const char *filename_template,int suffixlen,int mode);/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_s (const char *template, +static inline struct tempfile *mks_tempfile_s (const char *filename_template,int suffixlen) { -return mks_tempfile_sm (template, suffixlen,0600 ); +return mks_tempfile_sm (filename_template, suffixlen,0600 ); }/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_m (const char *template,int mode) +static inline struct tempfile *mks_tempfile_m (const char *filename_template,int mode) { -return mks_tempfile_sm (template,0 , mode); +return mks_tempfile_sm (filename_template,0 , mode); }/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile (const char *template) +static inline struct tempfile *mks_tempfile (const char *filename_template) { -return mks_tempfile_sm (template,0 ,0600 ); +return mks_tempfile_sm (filename_template,0 ,0600 ); }/* See "mks_tempfile functions" above. */ -extern struct tempfile *mks_tempfile_tsm (const char *template, +extern struct tempfile *mks_tempfile_tsm (const char *filename_template,int suffixlen,int mode);/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_ts (const char *template, +static inline struct tempfile *mks_tempfile_ts (const char *filename_template,int suffixlen) { -return mks_tempfile_tsm (template, suffixlen,0600 ); +return mks_tempfile_tsm (filename_template, suffixlen,0600 ); }/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_tm (const char *template,int mode) +static inline struct tempfile *mks_tempfile_tm (const char *filename_template,int mode) { -return mks_tempfile_tsm (template,0 , mode); +return mks_tempfile_tsm (filename_template,0 , mode); }/* See "mks_tempfile functions" above. */ -static inline struct tempfile *mks_tempfile_t (const char *template) +static inline struct tempfile *mks_tempfile_t (const char *filename_template) { -return mks_tempfile_tsm (template,0 ,0600 ); +return mks_tempfile_tsm (filename_template,0 ,0600 ); }/* See "mks_tempfile functions" above. */ -extern struct tempfile *xmks_tempfile_m (const char *template,int mode); +extern struct tempfile *xmks_tempfile_m (const char *filename_template,int mode);/* See "mks_tempfile functions" above. */ -static inline struct tempfile *xmks_tempfile (const char *template) +static inline struct tempfile *xmks_tempfile (const char *filename_template) { -return xmks_tempfile_m (template,0600 ); +return xmks_tempfile_m (filename_template,0600 ); }/*
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 36/37 trailer: rename 'template' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- trailer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
trailer.c +5 -5
@@ -1000,7 +1000,7 @@ static struct tempfile *trailers_tempfile;static FILE *create_in_place_tempfile (const char *file) {struct stat st; -struct strbuf template =STRBUF_INIT ; +struct strbuf filename_template =STRBUF_INIT ;const char *tail;FILE *outfile;
@@ -1014,11 +1014,11 @@ static FILE *create_in_place_tempfile(const char *file)/* Create temporary file in the same directory as the original */ tail =strrchr (file,'/' );if (tail !=NULL ) -strbuf_add (&template, file, tail - file +1 ); -strbuf_addstr (&template,"git-interpret-trailers-XXXXXX" ); +strbuf_add (&filename_template, file, tail - file +1 ); +strbuf_addstr (&filename_template,"git-interpret-trailers-XXXXXX" ); - trailers_tempfile =xmks_tempfile_m (template.buf, st.st_mode); -strbuf_release (&template); + trailers_tempfile =xmks_tempfile_m (filename_template.buf, st.st_mode); +strbuf_release (&filename_template); outfile =fdopen_tempfile (trailers_tempfile,"w" );if (!outfile)die_errno (_ ("could not open temporary file" ));
Signature · 1 line
2.16.1.291.g4437f3f132-goog
PATCH v2 37/37 replace: rename 'new' variables
In reply to Brandon WilliamsRename C++ keyword in order to bring the codebase closer to being able to be compiled with a C++ compiler.
--- builtin/replace.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
builtin/replace.c +17 -17
@@ -284,30 +284,30 @@ static int edit_and_replace(const char *object_ref, int force, int raw) {char *tmpfile =git_pathdup ("REPLACE_EDITOBJ" );enum object_type type; -struct object_id old, new, prev; +struct object_id old_oid, new_oid, prev;struct strbuf ref =STRBUF_INIT ; -if (get_oid (object_ref, &old) <0 ) +if (get_oid (object_ref, &old_oid) <0 )die ("Not a valid object name: '%s'" , object_ref); - type =sha1_object_info (old.hash,NULL ); + type =sha1_object_info (old_oid.hash,NULL );if (type <0 ) -die ("unable to get object type for %s" ,oid_to_hex (&old)); +die ("unable to get object type for %s" ,oid_to_hex (&old_oid)); -check_ref_valid (&old, &prev, &ref, force); +check_ref_valid (&old_oid, &prev, &ref, force);strbuf_release (&ref); -export_object (&old, type, raw, tmpfile); +export_object (&old_oid, type, raw, tmpfile);if (launch_editor (tmpfile,NULL ,NULL ) <0 )die ("editing object file failed" ); -import_object (&new, type, raw, tmpfile); +import_object (&new_oid, type, raw, tmpfile);free (tmpfile); -if (!oidcmp (&old, &new)) -return error ("new object is the same as the old one: '%s'" ,oid_to_hex (&old)); +if (!oidcmp (&old_oid, &new_oid)) +return error ("new object is the same as the old one: '%s'" ,oid_to_hex (&old_oid)); -return replace_object_oid (object_ref, &old,"replacement" , &new, force); +return replace_object_oid (object_ref, &old_oid,"replacement" , &new_oid, force); }static void replace_parents (struct strbuf *buf,int argc,const char **argv)
@@ -386,16 +386,16 @@ static void check_mergetags(struct commit *commit, int argc, const char **argv)static int create_graft (int argc,const char **argv,int force) { -struct object_id old, new; +struct object_id old_oid, new_oid;const char *old_ref = argv[0 ];struct commit *commit;struct strbuf buf =STRBUF_INIT ;const char *buffer;unsigned long size; -if (get_oid (old_ref, &old) <0 ) +if (get_oid (old_ref, &old_oid) <0 )die (_ ("Not a valid object name: '%s'" ), old_ref); - commit =lookup_commit_or_die (&old, old_ref); + commit =lookup_commit_or_die (&old_oid, old_ref); buffer =get_commit_buffer (commit, &size);strbuf_add (&buf, buffer, size);
@@ -410,15 +410,15 @@ static int create_graft(int argc, const char **argv, int force)check_mergetags (commit, argc, argv); -if (write_sha1_file (buf.buf, buf.len, commit_type, new.hash)) +if (write_sha1_file (buf.buf, buf.len, commit_type, new_oid.hash))die (_ ("could not write replacement commit for: '%s'" ), old_ref);strbuf_release (&buf); -if (!oidcmp (&old, &new)) -return error ("new commit is the same as the old one: '%s'" ,oid_to_hex (&old)); +if (!oidcmp (&old_oid, &new_oid)) +return error ("new commit is the same as the old one: '%s'" ,oid_to_hex (&old_oid)); -return replace_object_oid (old_ref, &old,"replacement" , &new, force); +return replace_object_oid (old_ref, &old_oid,"replacement" , &new_oid, force); }int cmd_replace (int argc,const char **argv,const char *prefix)
Signature · 1 line
2.16.1.291.g4437f3f132-goog
Quoted 3 lines · Brandon Williams
One person was interested enough for me to go back through and also rename all the paired 'old' variables to match the new names for the variables which were named 'new'.
The patches are:
(apart from the 'this' nit Junio had)