{"thread":{"id":"60925","subject":"[PATCH] use C99 declaration of variable in for() loop","startedAt":"2024-02-15T09:43:01Z","lastAt":"2024-02-15T23:43:33Z","messageCount":8,"participants":["Elia Pinto","Junio C Hamano","Christian Couder","brian m. carlson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"488714","messageId":"20240215094243.147057-1-gitter.spiros@gmail.com","threadId":"60925","inReplyTo":null,"subject":"[PATCH] use C99 declaration of variable in for() loop","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2024-02-15T09:42:42Z","receivedAt":"2024-02-15T09:43:01Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"With the exception of cbtree.c, which would need initial\nreworking to remove the usage of goto, it expands the\nuse of variable scope reduction in for loops as\npermitted by the C99 standard, which was first introduced\nin the git codebase with commit 44ba10d6.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\nBased on top of next 049e64211f79bdc0639badd06a79810dd7b3b85c\n\n add-interactive.c                    | 29 ++++-----\n add-patch.c                          | 16 +++--\n advice.c                             | 11 ++--\n apply.c                              | 39 +++++-------\n archive-tar.c                        | 10 ++-\n archive.c                            | 11 +---\n attr.c                               | 24 +++----\n base85.c                             |  3 +-\n bisect.c                             | 23 +++----\n blame.c                              | 92 ++++++++++-----------------\n bloom.c                              | 17 ++---\n branch.c                             |  3 +-\n builtin/add.c                        | 15 +++--\n builtin/am.c                         |  3 +-\n builtin/annotate.c                   |  3 +-\n builtin/archive.c                    |  4 +-\n builtin/bisect.c                     |  7 +--\n builtin/blame.c                      | 14 ++---\n builtin/branch.c                     | 15 ++---\n builtin/bugreport.c                  |  4 +-\n builtin/cat-file.c                   |  8 +--\n builtin/check-attr.c                 |  3 +-\n builtin/check-ignore.c               |  4 +-\n builtin/check-mailmap.c              |  3 +-\n builtin/checkout--worker.c           |  4 +-\n builtin/checkout-index.c             |  7 +--\n builtin/checkout.c                   |  6 +-\n builtin/clean.c                      | 17 +++--\n builtin/clone.c                      | 17 ++---\n builtin/commit-tree.c                |  3 +-\n builtin/commit.c                     | 11 ++--\n builtin/config.c                     |  3 +-\n builtin/count-objects.c              |  3 +-\n builtin/credential-cache--daemon.c   |  8 +--\n builtin/describe.c                   |  4 +-\n builtin/diff-index.c                 |  3 +-\n builtin/diff.c                       |  7 +--\n builtin/fast-export.c                | 24 +++----\n builtin/fast-import.c                | 56 +++++++----------\n builtin/fetch-pack.c                 |  4 +-\n builtin/fetch.c                      | 39 ++++--------\n builtin/for-each-repo.c              |  7 +--\n builtin/fsck.c                       | 22 +++----\n builtin/fsmonitor--daemon.c          | 14 +----\n builtin/gc.c                         | 28 +++------\n builtin/grep.c                       | 24 +++----\n builtin/hash-object.c                |  3 +-\n builtin/help.c                       | 14 ++---\n builtin/hook.c                       |  3 +-\n builtin/index-pack.c                 | 13 ++--\n builtin/interpret-trailers.c         |  3 +-\n builtin/log.c                        | 17 ++---\n builtin/ls-files.c                   | 14 ++---\n builtin/ls-tree.c                    |  8 +--\n builtin/mailsplit.c                  |  6 +-\n builtin/merge-base.c                 | 20 +++---\n builtin/merge-index.c                |  3 +-\n builtin/merge-tree.c                 |  9 +--\n builtin/merge.c                      | 36 +++++------\n builtin/name-rev.c                   | 11 ++--\n builtin/notes.c                      |  4 +-\n builtin/pack-objects.c               | 49 +++++----------\n builtin/pack-redundant.c             |  3 +-\n builtin/pull.c                       |  6 +-\n builtin/push.c                       |  4 +-\n builtin/range-diff.c                 |  4 +-\n builtin/read-tree.c                  |  4 +-\n builtin/receive-pack.c               | 46 +++++---------\n builtin/reflog.c                     | 16 +++--\n builtin/remote.c                     | 37 +++++------\n builtin/repack.c                     | 24 +++----\n builtin/replace.c                    | 10 ++-\n builtin/replay.c                     |  4 +-\n builtin/rerere.c                     |  3 +-\n builtin/reset.c                      |  7 +--\n builtin/rev-list.c                   |  3 +-\n builtin/rm.c                         | 10 ++-\n builtin/send-pack.c                  |  3 +-\n builtin/shortlog.c                   |  4 +-\n builtin/show-branch.c                |  4 +-\n builtin/sparse-checkout.c            | 11 ++--\n builtin/stash.c                      | 27 +++-----\n builtin/submodule--helper.c          | 40 +++++-------\n builtin/tag.c                        |  3 +-\n builtin/unpack-objects.c             |  9 +--\n builtin/update-index.c               |  9 +--\n builtin/var.c                        |  6 +-\n builtin/verify-pack.c                |  3 +-\n builtin/worktree.c                   | 12 ++--\n bulk-checkin.c                       |  7 +--\n bundle-uri.c                         |  6 +-\n bundle.c                             | 21 +++----\n cache-tree.c                         | 21 +++----\n chunk-format.c                       |  4 +-\n color.c                              |  9 +--\n column.c                             | 22 +++----\n combine-diff.c                       | 18 +++---\n commit-graph.c                       | 52 ++++++----------\n commit-reach.c                       | 26 +++-----\n commit.c                             | 23 +++----\n compat/fsmonitor/fsm-health-win32.c  |  4 +-\n compat/fsmonitor/fsm-listen-darwin.c |  8 +--\n compat/mingw.c                       |  6 +-\n compat/simple-ipc/ipc-unix-socket.c  | 11 +---\n compat/simple-ipc/ipc-win32.c        |  3 +-\n compat/strcasestr.c                  |  7 +--\n compat/terminal.c                    |  7 +--\n compat/unsetenv.c                    |  4 +-\n config.c                             | 15 ++---\n connect.c                            | 15 ++---\n connected.c                          |  4 +-\n convert.c                            | 18 ++----\n credential.c                         | 12 +---\n daemon.c                             | 21 +++----\n date.c                               |  3 +-\n decorate.c                           |  6 +-\n delta-islands.c                      | 27 +++-----\n diagnose.c                           |  3 +-\n diff-delta.c                         |  6 +-\n diff-lib.c                           |  4 +-\n diff.c                               | 93 ++++++++++------------------\n diff.h                               |  4 +-\n diffcore-break.c                     |  7 +--\n diffcore-delta.c                     |  3 +-\n diffcore-order.c                     | 11 ++--\n diffcore-rename.c                    | 17 +++--\n dir.c                                | 57 +++++++----------\n entry.c                              |  4 +-\n environment.c                        |  4 +-\n ewah/bitmap.c                        | 21 +++----\n ewah/ewah_io.c                       |  3 +-\n fetch-pack.c                         | 40 ++++--------\n fmt-merge-msg.c                      | 14 ++---\n fsck.c                               | 19 ++----\n fsmonitor.c                          |  9 ++-\n git.c                                | 16 ++---\n gpg-interface.c                      | 20 +++---\n graph.c                              | 51 +++++----------\n grep.c                               | 21 +++----\n hash-lookup.c                        |  4 +-\n hashmap.c                            |  4 +-\n help.c                               | 34 ++++------\n hex.c                                |  9 +--\n http-backend.c                       | 10 ++-\n http-push.c                          | 10 +--\n http-walker.c                        |  3 +-\n http.c                               | 13 ++--\n ident.c                              | 12 +---\n imap-send.c                          |  4 +-\n json-writer.c                        | 15 ++---\n khash.h                              |  8 +--\n line-log.c                           | 43 +++++--------\n linear-assignment.c                  |  4 +-\n list-objects-filter-options.c        | 11 +---\n list-objects-filter.c                | 14 ++---\n list-objects.c                       | 17 ++---\n log-tree.c                           | 10 ++-\n ls-refs.c                            |  4 +-\n mailinfo.c                           | 25 +++-----\n mem-pool.c                           |  5 +-\n merge-ll.c                           | 10 ++-\n merge-ort.c                          | 62 +++++++------------\n merge-recursive.c                    | 27 +++-----\n merge.c                              |  8 +--\n midx.c                               | 62 ++++++-------------\n name-hash.c                          | 19 ++----\n negotiator/skipping.c                |  3 +-\n notes-merge.c                        | 11 ++--\n notes-utils.c                        |  6 +-\n notes.c                              | 30 +++------\n object-file.c                        | 40 ++++--------\n object-name.c                        | 55 +++++-----------\n object.c                             | 42 ++++---------\n oid-array.c                          | 14 ++---\n pack-bitmap-write.c                  | 25 +++-----\n pack-bitmap.c                        | 51 ++++++---------\n pack-objects.c                       | 12 ++--\n pack-revindex.c                      |  8 +--\n pack-write.c                         | 13 ++--\n packfile.c                           | 82 ++++++++----------------\n pager.c                              |  3 +-\n parallel-checkout.c                  |  7 +--\n parse-options.c                      |  8 +--\n path.c                               | 11 ++--\n pathspec.c                           | 26 ++++----\n pkt-line.c                           |  3 +-\n pretty.c                             | 25 +++-----\n prio-queue.c                         | 12 ++--\n promisor-remote.c                    |  6 +-\n quote.c                              | 11 +---\n reachable.c                          |  3 +-\n read-cache.c                         | 62 ++++++-------------\n ref-filter.c                         | 50 +++++----------\n reflog-walk.c                        | 15 ++---\n refs.c                               | 58 ++++++-----------\n refs/debug.c                         |  3 +-\n refs/files-backend.c                 | 15 ++---\n refs/packed-backend.c                |  9 +--\n refs/ref-cache.c                     | 16 +----\n refs/reftable-backend.c              |  7 +--\n refspec.c                            |  6 +-\n reftable/basics.c                    |  3 +-\n reftable/block.c                     |  3 +-\n reftable/merged_test.c               |  3 +-\n reftable/pq_test.c                   |  3 +-\n reftable/readwrite_test.c            | 16 ++---\n reftable/record.c                    |  4 +-\n reftable/record_test.c               |  4 +-\n reftable/refname_test.c              |  3 +-\n reftable/stack.c                     | 12 ++--\n reftable/stack_test.c                | 28 ++++-----\n remote-curl.c                        |  6 +-\n remote.c                             | 84 +++++++++----------------\n rerere.c                             | 17 ++---\n revision.c                           | 69 +++++++--------------\n run-command.c                        | 21 ++-----\n scalar.c                             |  7 +--\n send-pack.c                          | 10 ++-\n sequencer.c                          | 40 +++++-------\n serve.c                              |  7 +--\n server-info.c                        | 12 ++--\n setup.c                              | 11 +---\n shallow.c                            | 13 ++--\n shell.c                              |  3 +-\n sideband.c                           | 11 +---\n sparse-index.c                       | 10 +--\n split-index.c                        | 16 +----\n strbuf.c                             | 20 +++---\n string-list.c                        | 12 ++--\n strvec.c                             |  3 +-\n submodule.c                          | 28 +++------\n t/helper/test-bloom.c                |  7 +--\n t/helper/test-dump-cache-tree.c      |  3 +-\n t/helper/test-dump-fsmonitor.c       |  3 +-\n t/helper/test-dump-split-index.c     |  3 +-\n t/helper/test-example-decorate.c     |  4 +-\n t/helper/test-fake-ssh.c             |  3 +-\n t/helper/test-find-pack.c            |  3 +-\n t/helper/test-fsmonitor-client.c     |  3 +-\n t/helper/test-lazy-init-name-hash.c  |  4 +-\n t/helper/test-mergesort.c            | 25 +++-----\n t/helper/test-pack-mtimes.c          |  3 +-\n t/helper/test-parse-options.c        |  3 +-\n t/helper/test-parse-pathspec-file.c  |  4 +-\n t/helper/test-path-utils.c           | 12 ++--\n t/helper/test-pkt-line.c             |  3 +-\n t/helper/test-proc-receive.c         |  4 +-\n t/helper/test-reach.c                | 10 ++-\n t/helper/test-read-cache.c           |  4 +-\n t/helper/test-read-midx.c            |  3 +-\n t/helper/test-ref-store.c            |  3 +-\n t/helper/test-repository.c           |  3 +-\n t/helper/test-rot13-filter.c         | 10 ++-\n t/helper/test-run-command.c          |  4 +-\n t/helper/test-simple-ipc.c           | 18 ++----\n t/helper/test-string-list.c          |  3 +-\n t/helper/test-submodule.c            |  3 +-\n t/helper/test-tool.c                 |  7 +--\n t/helper/test-trace2.c               | 16 ++---\n t/helper/test-wildmatch.c            |  3 +-\n t/helper/test-write-cache.c          |  4 +-\n t/unit-tests/test-lib.c              |  4 +-\n tmp-objdir.c                         |  3 +-\n trace2/tr2_cfg.c                     |  6 +-\n trace2/tr2_ctr.c                     | 15 +----\n trace2/tr2_sid.c                     |  3 +-\n trace2/tr2_sysenv.c                  |  8 +--\n trace2/tr2_tmr.c                     | 15 +----\n trailer.c                            | 28 +++------\n transport-helper.c                   | 31 ++++------\n transport.c                          | 29 +++------\n tree-diff.c                          |  3 +-\n tree-walk.c                          | 11 ++--\n unpack-trees.c                       | 48 +++++---------\n upload-pack.c                        | 33 +++-------\n userdiff.c                           |  3 +-\n version.c                            |  3 +-\n versioncmp.c                         |  6 +-\n walker.c                             |  4 +-\n worktree.c                           |  8 +--\n wrapper.c                            |  4 +-\n ws.c                                 |  3 +-\n wt-status.c                          | 51 ++++++---------\n xdiff-interface.c                    |  6 +-\n xdiff/xdiffi.c                       | 19 ++----\n xdiff/xemit.c                        |  8 +--\n xdiff/xhistogram.c                   |  4 +-\n xdiff/xmerge.c                       |  3 +-\n xdiff/xpatience.c                    |  3 +-\n 289 files changed, 1452 insertions(+), 2766 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 6bf87e7ae7..58ad10be10 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -233,7 +233,7 @@ struct list_options {\n static void list(struct add_i_state *s, struct string_list *list, int *selected,\n \t\t struct list_options *opts)\n {\n-\tint i, last_lf = 0;\n+\tint last_lf = 0;\n \n \tif (!list->nr)\n \t\treturn;\n@@ -242,7 +242,7 @@ static void list(struct add_i_state *s, struct string_list *list, int *selected,\n \t\tcolor_fprintf_ln(stdout, s->header_color,\n \t\t\t\t \"%s\", opts->header);\n \n-\tfor (i = 0; i < list->nr; i++) {\n+\tfor (int i = 0; i < list->nr; i++) {\n \t\topts->print_item(i, selected ? selected[i] : 0, list->items + i,\n \t\t\t\t opts->print_item_data);\n \n@@ -467,14 +467,13 @@ static void collect_changes_cb(struct diff_queue_struct *q,\n {\n \tstruct collection_status *s = data;\n \tstruct diffstat_t stat = { 0 };\n-\tint i;\n \n \tif (!q->nr)\n \t\treturn;\n \n \tcompute_diffstat(options, &stat, q);\n \n-\tfor (i = 0; i < stat.nr; i++) {\n+\tfor (int i = 0; i < stat.nr; i++) {\n \t\tconst char *name = stat.files[i]->name;\n \t\tint hash = strhash(name);\n \t\tstruct pathname_entry *entry;\n@@ -535,7 +534,6 @@ static int get_modified_files(struct repository *r,\n \tint is_initial = !resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING,\n \t\t\t\t\t     &head_oid, NULL);\n \tstruct collection_status s = { 0 };\n-\tint i;\n \n \tdiscard_index(r->index);\n \tif (repo_read_index_preload(r, ps, 0) < 0)\n@@ -545,7 +543,7 @@ static int get_modified_files(struct repository *r,\n \ts.files = &files->items;\n \thashmap_init(&s.file_map, pathname_entry_cmp, NULL, 0);\n \n-\tfor (i = 0; i < 2; i++) {\n+\tfor (int i = 0; i < 2; i++) {\n \t\tstruct rev_info rev;\n \t\tstruct setup_revision_opt opt = { 0 };\n \n@@ -678,7 +676,7 @@ static int run_update(struct add_i_state *s, const struct pathspec *ps,\n \t\t      struct list_and_choose_options *opts)\n {\n \tint res = 0, fd;\n-\tsize_t count, i;\n+\tsize_t count;\n \tstruct lock_file index_lock;\n \n \tif (get_modified_files(s->r, WORKTREE_ONLY, files, ps, NULL, NULL) < 0)\n@@ -702,7 +700,7 @@ static int run_update(struct add_i_state *s, const struct pathspec *ps,\n \t\treturn -1;\n \t}\n \n-\tfor (i = 0; i < files->items.nr; i++) {\n+\tfor (size_t i = 0; i < files->items.nr; i++) {\n \t\tconst char *name = files->items.items[i].string;\n \t\tstruct stat st;\n \n@@ -733,9 +731,9 @@ static int run_update(struct add_i_state *s, const struct pathspec *ps,\n static void revert_from_diff(struct diff_queue_struct *q,\n \t\t\t     struct diff_options *opt, void *data UNUSED)\n {\n-\tint i, add_flags = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE;\n+\tint add_flags = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE;\n \n-\tfor (i = 0; i < q->nr; i++) {\n+\tfor (int i = 0; i < q->nr; i++) {\n \t\tstruct diff_filespec *one = q->queue[i]->one;\n \t\tstruct cache_entry *ce;\n \n@@ -758,7 +756,7 @@ static int run_revert(struct add_i_state *s, const struct pathspec *ps,\n \t\t      struct list_and_choose_options *opts)\n {\n \tint res = 0, fd;\n-\tsize_t count, i, j;\n+\tsize_t count, j;\n \n \tstruct object_id oid;\n \tint is_initial = !resolve_ref_unsafe(\"HEAD\", RESOLVE_REF_READING, &oid,\n@@ -799,7 +797,7 @@ static int run_revert(struct add_i_state *s, const struct pathspec *ps,\n \t}\n \n \tALLOC_ARRAY(paths, count + 1);\n-\tfor (i = j = 0; i < files->items.nr; i++)\n+\tfor (size_t i = j = 0; i < files->items.nr; i++)\n \t\tif (files->selected[i])\n \t\t\tpaths[j++] = files->items.items[i].string;\n \tpaths[j] = NULL;\n@@ -843,7 +841,6 @@ static int get_untracked_files(struct repository *r,\n \t\t\t       const struct pathspec *ps)\n {\n \tstruct dir_struct dir = { 0 };\n-\tsize_t i;\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tif (repo_read_index(r) < 0)\n@@ -854,7 +851,7 @@ static int get_untracked_files(struct repository *r,\n \tadd_pattern_list(&dir, EXC_CMDL, \"--exclude option\");\n \tfill_directory(&dir, r->index, ps);\n \n-\tfor (i = 0; i < dir.nr; i++) {\n+\tfor (size_t i = 0; i < dir.nr; i++) {\n \t\tstruct dir_entry *ent = dir.entries[i];\n \n \t\tif (index_name_is_other(r->index, ent->name, ent->len)) {\n@@ -874,7 +871,7 @@ static int run_add_untracked(struct add_i_state *s, const struct pathspec *ps,\n {\n \tstruct print_file_item_data *d = opts->list_opts.print_item_data;\n \tint res = 0, fd;\n-\tsize_t count, i;\n+\tsize_t count;\n \tstruct lock_file index_lock;\n \n \tif (get_untracked_files(s->r, files, ps) < 0)\n@@ -898,7 +895,7 @@ static int run_add_untracked(struct add_i_state *s, const struct pathspec *ps,\n \t\tgoto finish_add_untracked;\n \t}\n \n-\tfor (i = 0; i < files->items.nr; i++) {\n+\tfor (size_t i = 0; i < files->items.nr; i++) {\n \t\tconst char *name = files->items.items[i].string;\n \t\tif (files->selected[i] &&\n \t\t    add_file_to_index(s->r->index, name, 0) < 0) {\ndiff --git a/add-patch.c b/add-patch.c\nindex 68f525b35c..219bcc9c9d 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -275,13 +275,11 @@ struct add_p_state {\n \n static void add_p_state_clear(struct add_p_state *s)\n {\n-\tsize_t i;\n-\n \tstrbuf_release(&s->answer);\n \tstrbuf_release(&s->buf);\n \tstrbuf_release(&s->plain);\n \tstrbuf_release(&s->colored);\n-\tfor (i = 0; i < s->file_diff_nr; i++)\n+\tfor (size_t i = 0; i < s->file_diff_nr; i++)\n \t\tfree(s->file_diff[i].hunk);\n \tfree(s->file_diff);\n \tclear_add_i_state(&s->s);\n@@ -407,7 +405,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)\n \tstruct strbuf *plain = &s->plain, *colored = NULL;\n \tstruct child_process cp = CHILD_PROCESS_INIT;\n \tchar *p, *pend, *colored_p = NULL, *colored_pend = NULL, marker = '\\0';\n-\tsize_t file_diff_alloc = 0, i, color_arg_index;\n+\tsize_t file_diff_alloc = 0, color_arg_index;\n \tstruct file_diff *file_diff = NULL;\n \tstruct hunk *hunk = NULL;\n \tint res;\n@@ -427,7 +425,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)\n \t/* Use `--no-color` explicitly, just in case `diff.color = always`. */\n \tstrvec_pushl(&args, \"--no-color\", \"--ignore-submodules=dirty\", \"-p\",\n \t\t     \"--\", NULL);\n-\tfor (i = 0; i < ps->nr; i++)\n+\tfor (size_t i = 0; i < ps->nr; i++)\n \t\tstrvec_push(&args, ps->items[i].original);\n \n \tsetup_child_process(s, &cp, NULL);\n@@ -878,12 +876,12 @@ static void reassemble_patch(struct add_p_state *s,\n \t\t\t     struct strbuf *out)\n {\n \tstruct hunk *hunk;\n-\tsize_t save_len = s->plain.len, i;\n+\tsize_t save_len = s->plain.len;\n \tssize_t delta = 0;\n \n \trender_diff_header(s, file_diff, 0, out);\n \n-\tfor (i = file_diff->mode_change; i < file_diff->hunk_nr; i++) {\n+\tfor (size_t i = file_diff->mode_change; i < file_diff->hunk_nr; i++) {\n \t\tstruct hunk merged = { 0 };\n \n \t\thunk = file_diff->hunk + i;\n@@ -1722,7 +1720,7 @@ int run_add_p(struct repository *r, enum add_p_mode mode,\n \tstruct add_p_state s = {\n \t\t{ r }, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT\n \t};\n-\tsize_t i, binary_count = 0;\n+\tsize_t binary_count = 0;\n \n \tinit_add_i_state(&s.s, r);\n \n@@ -1761,7 +1759,7 @@ int run_add_p(struct repository *r, enum add_p_mode mode,\n \t\treturn -1;\n \t}\n \n-\tfor (i = 0; i < s.file_diff_nr; i++)\n+\tfor (size_t i = 0; i < s.file_diff_nr; i++)\n \t\tif (s.file_diff[i].binary && !s.file_diff[i].hunk_nr)\n \t\t\tbinary_count++;\n \t\telse if (patch_update_file(&s, s.file_diff + i))\ndiff --git a/advice.c b/advice.c\nindex 6e9098ff08..e1606a0afd 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -93,14 +93,14 @@ static void vadvise(const char *advice, int display_instructions,\n \t\t    const char *key, va_list params)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tconst char *cp, *np;\n+\tconst char *np;\n \n \tstrbuf_vaddf(&buf, advice, params);\n \n \tif (display_instructions)\n \t\tstrbuf_addf(&buf, turn_off_instructions, key);\n \n-\tfor (cp = buf.buf; *cp; cp = np) {\n+\tfor (const char *cp = buf.buf; *cp; cp = np) {\n \t\tnp = strchrnul(cp, '\\n');\n \t\tfprintf(stderr,\t_(\"%shint: %.*s%s\\n\"),\n \t\t\tadvise_get_color(ADVICE_COLOR_HINT),\n@@ -147,7 +147,6 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...)\n int git_default_advice_config(const char *var, const char *value)\n {\n \tconst char *k, *slot_name;\n-\tint i;\n \n \tif (!strcmp(var, \"color.advice\")) {\n \t\tadvice_use_color = git_config_colorbool(var, value);\n@@ -166,7 +165,7 @@ int git_default_advice_config(const char *var, const char *value)\n \tif (!skip_prefix(var, \"advice.\", &k))\n \t\treturn 0;\n \n-\tfor (i = 0; i < ARRAY_SIZE(advice_setting); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(advice_setting); i++) {\n \t\tif (strcasecmp(k, advice_setting[i].key))\n \t\t\tcontinue;\n \t\tadvice_setting[i].level = git_config_bool(var, value)\n@@ -180,9 +179,7 @@ int git_default_advice_config(const char *var, const char *value)\n \n void list_config_advices(struct string_list *list, const char *prefix)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < ARRAY_SIZE(advice_setting); i++)\n+\tfor (int i = 0; i < ARRAY_SIZE(advice_setting); i++)\n \t\tlist_config_item(list, prefix, advice_setting[i].key);\n }\n \ndiff --git a/apply.c b/apply.c\nindex 355e2b0f2f..2b1582fa0e 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -504,7 +504,7 @@ static char *find_name_gnu(struct strbuf *root,\n \n static size_t sane_tz_len(const char *line, size_t len)\n {\n-\tconst char *tz, *p;\n+\tconst char *tz;\n \n \tif (len < strlen(\" +0500\") || line[len-strlen(\" +0500\")] != ' ')\n \t\treturn 0;\n@@ -513,7 +513,7 @@ static size_t sane_tz_len(const char *line, size_t len)\n \tif (tz[1] != '+' && tz[1] != '-')\n \t\treturn 0;\n \n-\tfor (p = tz + 2; p != line + len; p++)\n+\tfor (const char *p = tz + 2; p != line + len; p++)\n \t\tif (!isdigit(*p))\n \t\t\treturn 0;\n \n@@ -801,13 +801,13 @@ static int has_epoch_timestamp(const char *nameline)\n \t\t\"^[0-2][0-9]:([0-5][0-9]):00(\\\\.0+)?\"\n \t\t\" \"\n \t\t\"([-+][0-2][0-9]:?[0-5][0-9])\\n\";\n-\tconst char *timestamp = NULL, *cp, *colon;\n+\tconst char *timestamp = NULL, *colon;\n \tstatic regex_t *stamp;\n \tregmatch_t m[10];\n \tint zoneoffset, epoch_hour, hour, minute;\n \tint status;\n \n-\tfor (cp = nameline; *cp != '\\n'; cp++) {\n+\tfor (const char *cp = nameline; *cp != '\\n'; cp++) {\n \t\tif (*cp == '\\t')\n \t\t\ttimestamp = cp + 1;\n \t}\n@@ -1144,13 +1144,12 @@ static const char *skip_tree_prefix(int p_value,\n \t\t\t\t    int llen)\n {\n \tint nslash;\n-\tint i;\n \n \tif (!p_value)\n \t\treturn (llen && line[0] == '/') ? NULL : line;\n \n \tnslash = p_value;\n-\tfor (i = 0; i < llen; i++) {\n+\tfor (int i = 0; i < llen; i++) {\n \t\tint ch = line[i];\n \t\tif (ch == '/' && --nslash <= 0)\n \t\t\treturn (i == 0) ? NULL : &line[i + 1];\n@@ -1550,14 +1549,15 @@ static int find_header(struct apply_state *state,\n \t\t       int *hdrsize,\n \t\t       struct patch *patch)\n {\n-\tunsigned long offset, len;\n+\tunsigned long len;\n \n \tpatch->is_toplevel_relative = 0;\n \tpatch->is_rename = patch->is_copy = 0;\n \tpatch->is_new = patch->is_delete = -1;\n \tpatch->old_mode = patch->new_mode = 0;\n \tpatch->old_name = patch->new_name = NULL;\n-\tfor (offset = 0; size > 0; offset += len, size -= len, line += len, state->linenr++) {\n+\tfor (unsigned long offset = 0; size > 0; offset += len, size -= len,\n+\t     line += len, state->linenr++) {\n \t\tunsigned long nextlen;\n \n \t\tlen = linelen(line, size);\n@@ -2100,7 +2100,6 @@ static void add_name_limit(struct apply_state *state,\n static int use_patch(struct apply_state *state, struct patch *p)\n {\n \tconst char *pathname = p->new_name ? p->new_name : p->old_name;\n-\tint i;\n \n \t/* Paths outside are not touched regardless of \"--include\" */\n \tif (state->prefix && *state->prefix) {\n@@ -2110,7 +2109,7 @@ static int use_patch(struct apply_state *state, struct patch *p)\n \t}\n \n \t/* See if it matches any of exclude/include rule */\n-\tfor (i = 0; i < state->limit_by_name.nr; i++) {\n+\tfor (int i = 0; i < state->limit_by_name.nr; i++) {\n \t\tstruct string_list_item *it = &state->limit_by_name.items[i];\n \t\tif (!wildmatch(it->string, pathname, 0))\n \t\t\treturn (it->util != NULL);\n@@ -2186,8 +2185,7 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si\n \t\t\t\t\"Files \",\n \t\t\t\tNULL,\n \t\t\t};\n-\t\t\tint i;\n-\t\t\tfor (i = 0; binhdr[i]; i++) {\n+\t\t\tfor (int i = 0; binhdr[i]; i++) {\n \t\t\t\tint len = strlen(binhdr[i]);\n \t\t\t\tif (len < size - hd &&\n \t\t\t\t    !memcmp(binhdr[i], buffer + hd, len)) {\n@@ -4131,7 +4129,6 @@ static int preimage_oid_in_gitlink_patch(struct patch *p, struct object_id *oid)\n /* Build an index that contains just the files needed for a 3way merge */\n static int build_fake_ancestor(struct apply_state *state, struct patch *list)\n {\n-\tstruct patch *patch;\n \tstruct index_state result = INDEX_STATE_INIT(state->repo);\n \tstruct lock_file lock = LOCK_INIT;\n \tint res;\n@@ -4139,7 +4136,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)\n \t/* Once we start supporting the reverse patch, it may be\n \t * worth showing the new sha1 prefix, but until then...\n \t */\n-\tfor (patch = list; patch; patch = patch->next) {\n+\tfor (struct patch *patch = list; patch; patch = patch->next) {\n \t\tstruct object_id oid;\n \t\tstruct cache_entry *ce;\n \t\tconst char *name;\n@@ -4270,9 +4267,7 @@ static void show_rename_copy(struct patch *p)\n \n static void summary_patch_list(struct patch *patch)\n {\n-\tstruct patch *p;\n-\n-\tfor (p = patch; p; p = p->next) {\n+\tfor (struct patch *p = patch; p; p = p->next) {\n \t\tif (p->is_new)\n \t\t\tshow_file_mode_name(\"create\", p->new_mode, p->new_name);\n \t\telse if (p->is_delete)\n@@ -4524,7 +4519,7 @@ static int create_one_file(struct apply_state *state,\n static int add_conflicted_stages_file(struct apply_state *state,\n \t\t\t\t       struct patch *patch)\n {\n-\tint stage, namelen;\n+\tint namelen;\n \tunsigned mode;\n \tstruct cache_entry *ce;\n \n@@ -4534,7 +4529,7 @@ static int add_conflicted_stages_file(struct apply_state *state,\n \tmode = patch->new_mode ? patch->new_mode : (S_IFREG | 0644);\n \n \tremove_file_from_index(state->repo->index, patch->new_name);\n-\tfor (stage = 1; stage < 4; stage++) {\n+\tfor (int stage = 1; stage < 4; stage++) {\n \t\tif (is_null_oid(&patch->threeway_stage[stage - 1]))\n \t\t\tcontinue;\n \t\tce = make_empty_cache_entry(state->repo->index, namelen);\n@@ -4690,12 +4685,11 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)\n  */\n static int write_out_results(struct apply_state *state, struct patch *list)\n {\n-\tint phase;\n \tint errs = 0;\n \tstruct patch *l;\n \tstruct string_list cpath = STRING_LIST_INIT_DUP;\n \n-\tfor (phase = 0; phase < 2; phase++) {\n+\tfor (int phase = 0; phase < 2; phase++) {\n \t\tl = list;\n \t\twhile (l) {\n \t\t\tif (l->rejected)\n@@ -4967,12 +4961,11 @@ int apply_all_patches(struct apply_state *state,\n \t\t      const char **argv,\n \t\t      int options)\n {\n-\tint i;\n \tint res;\n \tint errs = 0;\n \tint read_stdin = 1;\n \n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \t\tchar *to_free = NULL;\n \t\tint fd;\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 8ae30125f8..d5dcc342cd 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -157,11 +157,11 @@ static void strbuf_append_ext_header(struct strbuf *sb, const char *keyword,\n \t\t\t\t     const char *value, size_t valuelen)\n {\n \tsize_t orig_len = sb->len;\n-\tsize_t len, tmp;\n+\tsize_t len;\n \n \t/* \"%u %s=%s\\n\" */\n \tlen = 1 + 1 + strlen(keyword) + 1 + valuelen + 1;\n-\tfor (tmp = 1; len / 10 >= tmp; tmp *= 10)\n+\tfor (size_t tmp = 1; len / 10 >= tmp; tmp *= 10)\n \t\tlen++;\n \n \tstrbuf_grow(sb, len);\n@@ -362,8 +362,7 @@ static int alloc_tar_filters;\n \n static struct archiver *find_tar_filter(const char *name, size_t len)\n {\n-\tint i;\n-\tfor (i = 0; i < nr_tar_filters; i++) {\n+\tfor (int i = 0; i < nr_tar_filters; i++) {\n \t\tstruct archiver *ar = tar_filters[i];\n \t\tif (!xstrncmpz(ar->name, name, len))\n \t\t\treturn ar;\n@@ -531,7 +530,6 @@ static struct archiver tar_archiver = {\n \n void init_tar_archiver(void)\n {\n-\tint i;\n \tregister_archiver(&tar_archiver);\n \n \ttar_filter_config(\"tar.tgz.command\", internal_gzip_command, NULL);\n@@ -539,7 +537,7 @@ void init_tar_archiver(void)\n \ttar_filter_config(\"tar.tar.gz.command\", internal_gzip_command, NULL);\n \ttar_filter_config(\"tar.tar.gz.remote\", \"true\", NULL);\n \tgit_config(git_tar_config, NULL);\n-\tfor (i = 0; i < nr_tar_filters; i++) {\n+\tfor (int i = 0; i < nr_tar_filters; i++) {\n \t\t/* omit any filters that never had a command configured */\n \t\tif (tar_filters[i]->filter_command)\n \t\t\tregister_archiver(tar_filters[i]);\ndiff --git a/archive.c b/archive.c\nindex a6730bebfa..ea30af9ffb 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -308,7 +308,6 @@ int write_archive_entries(struct archiver_args *args,\n \tstruct strbuf path_in_archive = STRBUF_INIT;\n \tstruct strbuf content = STRBUF_INIT;\n \tstruct object_id fake_oid;\n-\tint i;\n \n \toidcpy(&fake_oid, null_oid());\n \n@@ -357,7 +356,7 @@ int write_archive_entries(struct archiver_args *args,\n \t\tcontext.bottom = next;\n \t}\n \n-\tfor (i = 0; i < args->extra_files.nr; i++) {\n+\tfor (int i = 0; i < args->extra_files.nr; i++) {\n \t\tstruct string_list_item *item = args->extra_files.items + i;\n \t\tchar *path = item->string;\n \t\tstruct extra_file_info *info = item->util;\n@@ -396,12 +395,10 @@ int write_archive_entries(struct archiver_args *args,\n \n static const struct archiver *lookup_archiver(const char *name)\n {\n-\tint i;\n-\n \tif (!name)\n \t\treturn NULL;\n \n-\tfor (i = 0; i < nr_archivers; i++) {\n+\tfor (int i = 0; i < nr_archivers; i++) {\n \t\tif (!strcmp(name, archivers[i]->name))\n \t\t\treturn archivers[i];\n \t}\n@@ -784,9 +781,7 @@ static int match_extension(const char *filename, const char *ext)\n \n const char *archive_format_from_filename(const char *filename)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < nr_archivers; i++)\n+\tfor (int i = 0; i < nr_archivers; i++)\n \t\tif (match_extension(filename, archivers[i]->name))\n \t\t\treturn archivers[i]->name;\n \treturn NULL;\ndiff --git a/attr.c b/attr.c\nindex 679e42258c..af70c6a73f 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -142,7 +142,6 @@ struct all_attrs_item {\n  */\n static void all_attrs_init(struct attr_hashmap *map, struct attr_check *check)\n {\n-\tint i;\n \tunsigned int size;\n \n \thashmap_lock(map);\n@@ -178,7 +177,7 @@ static void all_attrs_init(struct attr_hashmap *map, struct attr_check *check)\n \t * This re-initialization can live outside of the locked region since\n \t * the attribute dictionary is no longer being accessed.\n \t */\n-\tfor (i = 0; i < check->all_attrs_nr; i++) {\n+\tfor (int i = 0; i < check->all_attrs_nr; i++) {\n \t\tcheck->all_attrs[i].value = ATTR__UNKNOWN;\n \t\tcheck->all_attrs[i].macro = NULL;\n \t}\n@@ -471,9 +470,8 @@ struct attr_stack {\n \n static void attr_stack_free(struct attr_stack *e)\n {\n-\tunsigned i;\n \tfree(e->origin);\n-\tfor (i = 0; i < e->num_matches; i++) {\n+\tfor (unsigned i = 0; i < e->num_matches; i++) {\n \t\tstruct match_attr *a = e->attrs[i];\n \t\tsize_t j;\n \n@@ -558,11 +556,9 @@ static void check_vector_remove(struct attr_check *check)\n /* Iterate through all attr_check instances and drop their stacks */\n static void drop_all_attr_stacks(void)\n {\n-\tint i;\n-\n \tvector_lock();\n \n-\tfor (i = 0; i < check_vector.nr; i++) {\n+\tfor (int i = 0; i < check_vector.nr; i++) {\n \t\tdrop_attr_stack(&check_vector.checks[i]->stack);\n \t}\n \n@@ -1102,9 +1098,7 @@ static int macroexpand_one(struct all_attrs_item *all_attrs, int nr, int rem);\n static int fill_one(struct all_attrs_item *all_attrs,\n \t\t    const struct match_attr *a, int rem)\n {\n-\tsize_t i;\n-\n-\tfor (i = a->num_attr; rem > 0 && i > 0; i--) {\n+\tfor (size_t i = a->num_attr; rem > 0 && i > 0; i--) {\n \t\tconst struct git_attr *attr = a->state[i - 1].attr;\n \t\tconst char **n = &(all_attrs[attr->attr_nr].value);\n \t\tconst char *v = a->state[i - 1].setto;\n@@ -1262,9 +1256,7 @@ static const char *interned_mode_string(unsigned int mode)\n \t\t{ .val = 0120000 },\n \t\t{ .val = 0160000 },\n \t};\n-\tint i;\n-\n-\tfor (i = 0; i < ARRAY_SIZE(mode_string); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(mode_string); i++) {\n \t\tif (mode_string[i].val != mode)\n \t\t\tcontinue;\n \t\tif (!*mode_string[i].str)\n@@ -1333,12 +1325,11 @@ void git_check_attr(struct index_state *istate,\n \t\t    const char *path,\n \t\t    struct attr_check *check)\n {\n-\tint i;\n \tconst struct object_id *tree_oid = default_attr_source();\n \n \tcollect_some_attrs(istate, tree_oid, path, check);\n \n-\tfor (i = 0; i < check->nr; i++) {\n+\tfor (int i = 0; i < check->nr; i++) {\n \t\tunsigned int n = check->items[i].attr->attr_nr;\n \t\tconst char *value = check->all_attrs[n].value;\n \t\tif (value == ATTR__UNKNOWN)\n@@ -1350,13 +1341,12 @@ void git_check_attr(struct index_state *istate,\n void git_all_attrs(struct index_state *istate,\n \t\t   const char *path, struct attr_check *check)\n {\n-\tint i;\n \tconst struct object_id *tree_oid = default_attr_source();\n \n \tattr_check_reset(check);\n \tcollect_some_attrs(istate, tree_oid, path, check);\n \n-\tfor (i = 0; i < check->all_attrs_nr; i++) {\n+\tfor (int i = 0; i < check->all_attrs_nr; i++) {\n \t\tconst char *name = check->all_attrs[i].attr->name;\n \t\tconst char *value = check->all_attrs[i].value;\n \t\tstruct attr_check_item *item;\ndiff --git a/base85.c b/base85.c\nindex bbacdca31b..0598e1c626 100644\n--- a/base85.c\n+++ b/base85.c\n@@ -29,10 +29,9 @@ static const char en85[] = {\n static char de85[256];\n static void prep_base85(void)\n {\n-\tint i;\n \tif (de85['Z'])\n \t\treturn;\n-\tfor (i = 0; i < ARRAY_SIZE(en85); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(en85); i++) {\n \t\tint ch = en85[i];\n \t\tde85[ch] = i + 1;\n \t}\ndiff --git a/bisect.c b/bisect.c\nindex f75e50c339..fe2d57c908 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -139,14 +139,12 @@ static inline int approx_halfway(struct commit_list *p, int nr)\n static void show_list(const char *debug, int counted, int nr,\n \t\t      struct commit_list *list)\n {\n-\tstruct commit_list *p;\n-\n \tif (!DEBUG_BISECT)\n \t\treturn;\n \n \tfprintf(stderr, \"%s (%d/%d)\\n\", debug, counted, nr);\n \n-\tfor (p = list; p; p = p->next) {\n+\tfor (struct commit_list *p = list; p; p = p->next) {\n \t\tstruct commit_list *pp;\n \t\tstruct commit *commit = p->item;\n \t\tunsigned commit_flags = commit->object.flags;\n@@ -183,11 +181,11 @@ static void show_list(const char *debug, int counted, int nr,\n \n static struct commit_list *best_bisection(struct commit_list *list, int nr)\n {\n-\tstruct commit_list *p, *best;\n+\tstruct commit_list *best;\n \tint best_distance = -1;\n \n \tbest = list;\n-\tfor (p = list; p; p = p->next) {\n+\tfor (struct commit_list *p = list; p; p = p->next) {\n \t\tint distance;\n \t\tunsigned commit_flags = p->item->object.flags;\n \n@@ -500,9 +498,7 @@ static void read_bisect_paths(struct strvec *array)\n static char *join_oid_array_hex(struct oid_array *array, char delim)\n {\n \tstruct strbuf joined_hexs = STRBUF_INIT;\n-\tint i;\n-\n-\tfor (i = 0; i < array->nr; i++) {\n+\tfor (int i = 0; i < array->nr; i++) {\n \t\tstrbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));\n \t\tif (i + 1 < array->nr)\n \t\t\tstrbuf_addch(&joined_hexs, delim);\n@@ -611,7 +607,7 @@ static int sqrti(int val)\n static struct commit_list *skip_away(struct commit_list *list, int count)\n {\n \tstruct commit_list *cur, *previous;\n-\tint prn, index, i;\n+\tint prn, index;\n \n \tprn = get_prn(count);\n \tindex = (count * prn / PRN_MODULO) * sqrti(prn) / sqrti(PRN_MODULO);\n@@ -619,7 +615,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count)\n \tcur = list;\n \tprevious = NULL;\n \n-\tfor (i = 0; cur; cur = cur->next, i++) {\n+\tfor (int i = 0; cur; cur = cur->next, i++) {\n \t\tif (i == index) {\n \t\t\tif (!oideq(&cur->item->object.oid, current_bad_oid))\n \t\t\t\treturn cur;\n@@ -660,7 +656,6 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,\n \tstruct setup_revision_opt opt = {\n \t\t.free_removed_argv_elements = 1,\n \t};\n-\tint i;\n \n \trepo_init_revisions(r, revs, prefix);\n \trevs->abbrev = 0;\n@@ -669,7 +664,7 @@ static void bisect_rev_setup(struct repository *r, struct rev_info *revs,\n \t/* rev_argv.argv[0] will be ignored by setup_revisions */\n \tstrvec_push(rev_argv, \"bisect_rev_setup\");\n \tstrvec_pushf(rev_argv, bad_format, oid_to_hex(current_bad_oid));\n-\tfor (i = 0; i < good_revs.nr; i++)\n+\tfor (int i = 0; i < good_revs.nr; i++)\n \t\tstrvec_pushf(rev_argv, good_format,\n \t\t\t     oid_to_hex(good_revs.oid + i));\n \tstrvec_push(rev_argv, \"--\");\n@@ -763,11 +758,11 @@ static struct commit **get_bad_and_good_commits(struct repository *r,\n \t\t\t\t\t\tint *rev_nr)\n {\n \tstruct commit **rev;\n-\tint i, n = 0;\n+\tint n = 0;\n \n \tALLOC_ARRAY(rev, 1 + good_revs.nr);\n \trev[n++] = get_commit_reference(r, current_bad_oid);\n-\tfor (i = 0; i < good_revs.nr; i++)\n+\tfor (int i = 0; i < good_revs.nr; i++)\n \t\trev[n++] = get_commit_reference(r, good_revs.oid + i);\n \t*rev_nr = n;\n \ndiff --git a/blame.c b/blame.c\nindex 1a16d4eb6a..c15162591e 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -41,12 +41,13 @@ static void set_blame_suspects(struct commit *commit, struct blame_origin *origi\n void blame_origin_decref(struct blame_origin *o)\n {\n \tif (o && --o->refcnt <= 0) {\n-\t\tstruct blame_origin *p, *l = NULL;\n+\t\tstruct blame_origin *l = NULL;\n \t\tif (o->previous)\n \t\t\tblame_origin_decref(o->previous);\n \t\tfree(o->file.ptr);\n \t\t/* Should be present exactly once in commit chain */\n-\t\tfor (p = get_blame_suspects(o->commit); p; l = p, p = p->next) {\n+\t\tfor (struct blame_origin *p = get_blame_suspects(o->commit); p; l = p,\n+\t\t     p = p->next) {\n \t\t\tif (p == o) {\n \t\t\t\tif (l)\n \t\t\t\t\tl->next = p->next;\n@@ -104,10 +105,9 @@ static struct blame_origin *get_origin(struct commit *commit, const char *path)\n static void verify_working_tree_path(struct repository *r,\n \t\t\t\t     struct commit *work_tree, const char *path)\n {\n-\tstruct commit_list *parents;\n \tint pos;\n \n-\tfor (parents = work_tree->parents; parents; parents = parents->next) {\n+\tfor (struct commit_list *parents = work_tree->parents; parents; parents = parents->next) {\n \t\tconst struct object_id *commit_oid = &parents->item->object.oid;\n \t\tstruct object_id blob_oid;\n \t\tunsigned short mode;\n@@ -190,7 +190,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n {\n \tstruct commit *commit;\n \tstruct blame_origin *origin;\n-\tstruct commit_list **parent_tail, *parent;\n+\tstruct commit_list **parent_tail;\n \tstruct strbuf buf = STRBUF_INIT;\n \tconst char *ident;\n \ttime_t now;\n@@ -219,7 +219,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,\n \t\tident = fmt_ident(\"Not Committed Yet\", \"not.committed.yet\",\n \t\t\t\t  WANT_BLANK_IDENT, NULL, 0);\n \tstrbuf_addstr(&msg, \"tree 0000000000000000000000000000000000000000\\n\");\n-\tfor (parent = commit->parents; parent; parent = parent->next)\n+\tfor (struct commit_list *parent = commit->parents; parent; parent = parent->next)\n \t\tstrbuf_addf(&msg, \"parent %s\\n\",\n \t\t\t    oid_to_hex(&parent->item->object.oid));\n \tstrbuf_addf(&msg,\n@@ -407,7 +407,6 @@ static void get_fingerprint(struct fingerprint *result,\n \t\t\t    const char *line_end)\n {\n \tunsigned int hash, c0 = 0, c1;\n-\tconst char *p;\n \tint max_map_entry_count = 1 + line_end - line_begin;\n \tstruct fingerprint_entry *entry = xcalloc(max_map_entry_count,\n \t\tsizeof(struct fingerprint_entry));\n@@ -415,7 +414,7 @@ static void get_fingerprint(struct fingerprint *result,\n \n \thashmap_init(&result->map, NULL, NULL, max_map_entry_count);\n \tresult->entries = entry;\n-\tfor (p = line_begin; p <= line_end; ++p, c0 = c1) {\n+\tfor (const char *p = line_begin; p <= line_end; ++p, c0 = c1) {\n \t\t/* Always terminate the string with whitespace.\n \t\t * Normalise whitespace to 0, and normalise letters to\n \t\t * lower case. This won't work for multibyte characters but at\n@@ -503,11 +502,10 @@ static void get_line_fingerprints(struct fingerprint *fingerprints,\n \t\t\t\t  const char *content, const int *line_starts,\n \t\t\t\t  long first_line, long line_count)\n {\n-\tint i;\n \tconst char *linestart, *lineend;\n \n \tline_starts += first_line;\n-\tfor (i = 0; i < line_count; ++i) {\n+\tfor (int i = 0; i < line_count; ++i) {\n \t\tlinestart = content + line_starts[i];\n \t\tlineend = content + line_starts[i + 1];\n \t\tget_fingerprint(fingerprints + i, linestart, lineend);\n@@ -517,9 +515,7 @@ static void get_line_fingerprints(struct fingerprint *fingerprints,\n static void free_line_fingerprints(struct fingerprint *fingerprints,\n \t\t\t\t   int nr_fingerprints)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < nr_fingerprints; i++)\n+\tfor (int i = 0; i < nr_fingerprints; i++)\n \t\tfree_fingerprint(&fingerprints[i]);\n }\n \n@@ -644,7 +640,7 @@ static void find_best_line_matches(\n \tconst struct line_number_mapping *map_line_number_in_b_to_a)\n {\n \n-\tint i, search_start, search_end, closest_local_line_a, *similarity,\n+\tint search_start, search_end, closest_local_line_a, *similarity,\n \t\tbest_similarity = 0, second_best_similarity = 0,\n \t\tbest_similarity_index = 0, second_best_similarity_index = 0;\n \n@@ -663,7 +659,7 @@ static void find_best_line_matches(\n \tif (search_end > length_a)\n \t\tsearch_end = length_a;\n \n-\tfor (i = search_start; i < search_end; ++i) {\n+\tfor (int i = search_start; i < search_end; ++i) {\n \t\tsimilarity = get_similarity(similarities,\n \t\t\t\t\t    i, local_line_b,\n \t\t\t\t\t    closest_local_line_a,\n@@ -1158,9 +1154,7 @@ static int compare_commits_by_reverse_commit_date(const void *a,\n static void sanity_check_refcnt(struct blame_scoreboard *sb)\n {\n \tint baa = 0;\n-\tstruct blame_entry *ent;\n-\n-\tfor (ent = sb->ent; ent; ent = ent->next) {\n+\tfor (struct blame_entry *ent = sb->ent; ent; ent = ent->next) {\n \t\t/* Nobody should have zero or negative refcnt */\n \t\tif (ent->suspect->refcnt <= 0) {\n \t\t\tfprintf(stderr, \"%s in %s has negative refcnt %d\\n\",\n@@ -1181,9 +1175,9 @@ static void sanity_check_refcnt(struct blame_scoreboard *sb)\n  */\n void blame_coalesce(struct blame_scoreboard *sb)\n {\n-\tstruct blame_entry *ent, *next;\n+\tstruct blame_entry *next;\n \n-\tfor (ent = sb->ent; ent && (next = ent->next); ent = next) {\n+\tfor (struct blame_entry *ent = sb->ent; ent && (next = ent->next); ent = next) {\n \t\tif (ent->suspect == next->suspect &&\n \t\t    ent->s_lno + ent->num_lines == next->s_lno &&\n \t\t    ent->lno + ent->num_lines == next->lno &&\n@@ -1214,8 +1208,7 @@ static void queue_blames(struct blame_scoreboard *sb, struct blame_origin *porig\n \tif (porigin->suspects)\n \t\tporigin->suspects = blame_merge(porigin->suspects, sorted);\n \telse {\n-\t\tstruct blame_origin *o;\n-\t\tfor (o = get_blame_suspects(porigin->commit); o; o = o->next) {\n+\t\tfor (struct blame_origin *o = get_blame_suspects(porigin->commit); o; o = o->next) {\n \t\t\tif (o->suspects) {\n \t\t\t\tporigin->suspects = sorted;\n \t\t\t\treturn;\n@@ -1269,7 +1262,6 @@ static int maybe_changed_path(struct repository *r,\n \t\t\t      struct blame_origin *origin,\n \t\t\t      struct blame_bloom_data *bd)\n {\n-\tint i;\n \tstruct bloom_filter *filter;\n \n \tif (!bd)\n@@ -1284,7 +1276,7 @@ static int maybe_changed_path(struct repository *r,\n \t\treturn 1;\n \n \tbloom_count_queries++;\n-\tfor (i = 0; i < bd->nr; i++) {\n+\tfor (int i = 0; i < bd->nr; i++) {\n \t\tif (bloom_filter_contains(filter,\n \t\t\t\t\t  bd->keys[i],\n \t\t\t\t\t  bd->settings))\n@@ -1372,15 +1364,8 @@ static struct blame_origin *find_origin(struct repository *r,\n \t\toidcpy(&porigin->blob_oid, &origin->blob_oid);\n \t\tporigin->mode = origin->mode;\n \t} else {\n-\t\t/*\n-\t\t * Since origin->path is a pathspec, if the parent\n-\t\t * commit had it as a directory, we will see a whole\n-\t\t * bunch of deletion of files in the directory that we\n-\t\t * do not care about.\n-\t\t */\n-\t\tint i;\n \t\tstruct diff_filepair *p = NULL;\n-\t\tfor (i = 0; i < diff_queued_diff.nr; i++) {\n+\t\tfor (int i = 0; i < diff_queued_diff.nr; i++) {\n \t\t\tconst char *name;\n \t\t\tp = diff_queued_diff.queue[i];\n \t\t\tname = p->one->path ? p->one->path : p->two->path;\n@@ -1419,7 +1404,6 @@ static struct blame_origin *find_rename(struct repository *r,\n {\n \tstruct blame_origin *porigin = NULL;\n \tstruct diff_options diff_opts;\n-\tint i;\n \n \trepo_diff_setup(r, &diff_opts);\n \tdiff_opts.flags.recursive = 1;\n@@ -1436,7 +1420,7 @@ static struct blame_origin *find_rename(struct repository *r,\n \t\t\t      \"\", &diff_opts);\n \tdiffcore_std(&diff_opts);\n \n-\tfor (i = 0; i < diff_queued_diff.nr; i++) {\n+\tfor (int i = 0; i < diff_queued_diff.nr; i++) {\n \t\tstruct diff_filepair *p = diff_queued_diff.queue[i];\n \t\tif ((p->status == 'R' || p->status == 'C') &&\n \t\t    !strcmp(p->two->path, origin->path)) {\n@@ -1507,10 +1491,9 @@ static void split_overlap(struct blame_entry *split,\n \t\t\t  struct blame_origin *parent)\n {\n \tint chunk_end_lno;\n-\tint i;\n \tmemset(split, 0, sizeof(struct blame_entry [3]));\n \n-\tfor (i = 0; i < 3; i++) {\n+\tfor (int i = 0; i < 3; i++) {\n \t\tsplit[i].ignored = e->ignored;\n \t\tsplit[i].unblamable = e->unblamable;\n \t}\n@@ -1594,9 +1577,7 @@ static void split_blame(struct blame_entry ***blamed,\n  */\n static void decref_split(struct blame_entry *split)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < 3; i++)\n+\tfor (int i = 0; i < 3; i++)\n \t\tblame_origin_decref(split[i].suspect);\n }\n \n@@ -1661,12 +1642,12 @@ static int scan_parent_range(struct fingerprint *p_fps,\n \t\t\t     struct fingerprint *t_fps, int t_idx,\n \t\t\t     int from, int nr_lines)\n {\n-\tint sim, p_idx;\n+\tint sim;\n \t#define FINGERPRINT_FILE_THRESHOLD\t10\n \tint best_sim_val = FINGERPRINT_FILE_THRESHOLD;\n \tint best_sim_idx = -1;\n \n-\tfor (p_idx = from; p_idx < from + nr_lines; p_idx++) {\n+\tfor (int p_idx = from; p_idx < from + nr_lines; p_idx++) {\n \t\tsim = fingerprint_similarity(&t_fps[t_idx], &p_fps[p_idx]);\n \t\tif (sim < best_sim_val)\n \t\t\tcontinue;\n@@ -1691,14 +1672,14 @@ static void guess_line_blames(struct blame_origin *parent,\n \t\t\t      int tlno, int offset, int same, int parent_len,\n \t\t\t      struct blame_line_tracker *line_blames)\n {\n-\tint i, best_idx, target_idx;\n+\tint best_idx, target_idx;\n \tint parent_slno = tlno + offset;\n \tint *fuzzy_matches;\n \n \tfuzzy_matches = fuzzy_find_matching_lines(parent, target,\n \t\t\t\t\t\t  tlno, parent_slno, same,\n \t\t\t\t\t\t  parent_len);\n-\tfor (i = 0; i < same - tlno; i++) {\n+\tfor (int i = 0; i < same - tlno; i++) {\n \t\ttarget_idx = tlno + i;\n \t\tif (fuzzy_matches && fuzzy_matches[i] >= 0) {\n \t\t\tbest_idx = fuzzy_matches[i];\n@@ -1735,7 +1716,7 @@ static void ignore_blame_entry(struct blame_entry *e,\n \t\t\t       struct blame_entry **ignoredp,\n \t\t\t       struct blame_line_tracker *line_blames)\n {\n-\tint entry_len, nr_lines, i;\n+\tint entry_len, nr_lines;\n \n \t/*\n \t * We carve new entries off the front of e.  Each entry comes from a\n@@ -1744,7 +1725,7 @@ static void ignore_blame_entry(struct blame_entry *e,\n \t */\n \tentry_len = 1;\n \tnr_lines = e->num_lines;\t/* e changes in the loop */\n-\tfor (i = 0; i < nr_lines; i++) {\n+\tfor (int i = 0; i < nr_lines; i++) {\n \t\tstruct blame_entry *next = NULL;\n \n \t\t/*\n@@ -2012,8 +1993,6 @@ static void copy_split_if_better(struct blame_scoreboard *sb,\n \t\t\t\t struct blame_entry *best_so_far,\n \t\t\t\t struct blame_entry *potential)\n {\n-\tint i;\n-\n \tif (!potential[1].suspect)\n \t\treturn;\n \tif (best_so_far[1].suspect) {\n@@ -2022,7 +2001,7 @@ static void copy_split_if_better(struct blame_scoreboard *sb,\n \t\t\treturn;\n \t}\n \n-\tfor (i = 0; i < 3; i++)\n+\tfor (int i = 0; i < 3; i++)\n \t\tblame_origin_incref(potential[i].suspect);\n \tdecref_split(best_so_far);\n \tmemcpy(best_so_far, potential, sizeof(struct blame_entry[3]));\n@@ -2335,7 +2314,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n static void pass_whole_blame(struct blame_scoreboard *sb,\n \t\t\t     struct blame_origin *origin, struct blame_origin *porigin)\n {\n-\tstruct blame_entry *e, *suspects;\n+\tstruct blame_entry *suspects;\n \n \tif (!porigin->file.ptr && origin->file.ptr) {\n \t\t/* Steal its file */\n@@ -2344,7 +2323,7 @@ static void pass_whole_blame(struct blame_scoreboard *sb,\n \t}\n \tsuspects = origin->suspects;\n \torigin->suspects = NULL;\n-\tfor (e = suspects; e; e = e->next) {\n+\tfor (struct blame_entry *e = suspects; e; e = e->next) {\n \t\tblame_origin_incref(porigin);\n \t\tblame_origin_decref(e->suspect);\n \t\te->suspect = porigin;\n@@ -2409,7 +2388,7 @@ typedef struct blame_origin *(*blame_find_alg)(struct repository *,\n static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin, int opt)\n {\n \tstruct rev_info *revs = sb->revs;\n-\tint i, pass, num_sg;\n+\tint i, num_sg;\n \tstruct commit *commit = origin->commit;\n \tstruct commit_list *sg;\n \tstruct blame_origin *sg_buf[MAXSG];\n@@ -2429,7 +2408,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,\n \t * The first pass looks for unrenamed path to optimize for\n \t * common cases, then we look for renames in the second pass.\n \t */\n-\tfor (pass = 0; pass < 2 - sb->no_whole_file_rename; pass++) {\n+\tfor (int pass = 0; pass < 2 - sb->no_whole_file_rename; pass++) {\n \t\tblame_find_alg find = pass ? find_rename : find_origin;\n \n \t\tfor (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);\n@@ -2656,11 +2635,10 @@ static int prepare_lines(struct blame_scoreboard *sb)\n static struct commit *find_single_final(struct rev_info *revs,\n \t\t\t\t\tconst char **name_p)\n {\n-\tint i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \n-\tfor (i = 0; i < revs->pending.nr; i++) {\n+\tfor (int i = 0; i < revs->pending.nr; i++) {\n \t\tstruct object *obj = revs->pending.objects[i].item;\n \t\tif (obj->flags & UNINTERESTING)\n \t\t\tcontinue;\n@@ -2719,7 +2697,6 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,\n static struct commit *find_single_initial(struct rev_info *revs,\n \t\t\t\t\t  const char **name_p)\n {\n-\tint i;\n \tstruct commit *found = NULL;\n \tconst char *name = NULL;\n \n@@ -2727,7 +2704,7 @@ static struct commit *find_single_initial(struct rev_info *revs,\n \t * There must be one and only one negative commit, and it must be\n \t * the boundary.\n \t */\n-\tfor (i = 0; i < revs->pending.nr; i++) {\n+\tfor (int i = 0; i < revs->pending.nr; i++) {\n \t\tstruct object *obj = revs->pending.objects[i].item;\n \t\tif (!(obj->flags & UNINTERESTING))\n \t\t\tcontinue;\n@@ -2929,8 +2906,7 @@ void setup_blame_bloom_data(struct blame_scoreboard *sb)\n void cleanup_scoreboard(struct blame_scoreboard *sb)\n {\n \tif (sb->bloom_data) {\n-\t\tint i;\n-\t\tfor (i = 0; i < sb->bloom_data->nr; i++) {\n+\t\tfor (int i = 0; i < sb->bloom_data->nr; i++) {\n \t\t\tfree(sb->bloom_data->keys[i]->hashes);\n \t\t\tfree(sb->bloom_data->keys[i]);\n \t\t}\ndiff --git a/bloom.c b/bloom.c\nindex e529f7605c..58bb79e62c 100644\n--- a/bloom.c\n+++ b/bloom.c\n@@ -107,14 +107,13 @@ uint32_t murmur3_seeded(uint32_t seed, const char *data, size_t len)\n \tconst uint32_t r2 = 13;\n \tconst uint32_t m = 5;\n \tconst uint32_t n = 0xe6546b64;\n-\tint i;\n \tuint32_t k1 = 0;\n \tconst char *tail;\n \n \tint len4 = len / sizeof(uint32_t);\n \n \tuint32_t k;\n-\tfor (i = 0; i < len4; i++) {\n+\tfor (int i = 0; i < len4; i++) {\n \t\tuint32_t byte1 = (uint32_t)data[4*i];\n \t\tuint32_t byte2 = ((uint32_t)data[4*i + 1]) << 8;\n \t\tuint32_t byte3 = ((uint32_t)data[4*i + 2]) << 16;\n@@ -161,14 +160,13 @@ void fill_bloom_key(const char *data,\n \t\t    struct bloom_key *key,\n \t\t    const struct bloom_filter_settings *settings)\n {\n-\tint i;\n \tconst uint32_t seed0 = 0x293ae76f;\n \tconst uint32_t seed1 = 0x7e646e2c;\n \tconst uint32_t hash0 = murmur3_seeded(seed0, data, len);\n \tconst uint32_t hash1 = murmur3_seeded(seed1, data, len);\n \n \tkey->hashes = (uint32_t *)xcalloc(settings->num_hashes, sizeof(uint32_t));\n-\tfor (i = 0; i < settings->num_hashes; i++)\n+\tfor (int i = 0; i < settings->num_hashes; i++)\n \t\tkey->hashes[i] = hash0 + i * hash1;\n }\n \n@@ -181,10 +179,9 @@ void add_key_to_filter(const struct bloom_key *key,\n \t\t       struct bloom_filter *filter,\n \t\t       const struct bloom_filter_settings *settings)\n {\n-\tint i;\n \tuint64_t mod = filter->len * BITS_PER_WORD;\n \n-\tfor (i = 0; i < settings->num_hashes; i++) {\n+\tfor (int i = 0; i < settings->num_hashes; i++) {\n \t\tuint64_t hash_mod = key->hashes[i] % mod;\n \t\tuint64_t block_pos = hash_mod / BITS_PER_WORD;\n \n@@ -224,7 +221,6 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,\n \t\t\t\t\t\t enum bloom_filter_computed *computed)\n {\n \tstruct bloom_filter *filter;\n-\tint i;\n \tstruct diff_options diffopt;\n \n \tif (computed)\n@@ -267,7 +263,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,\n \t\tstruct pathmap_hash_entry *e;\n \t\tstruct hashmap_iter iter;\n \n-\t\tfor (i = 0; i < diff_queued_diff.nr; i++) {\n+\t\tfor (int i = 0; i < diff_queued_diff.nr; i++) {\n \t\t\tconst char *path = diff_queued_diff.queue[i]->two->path;\n \n \t\t\t/*\n@@ -323,7 +319,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,\n \tcleanup:\n \t\thashmap_clear_and_free(&pathmap, struct pathmap_hash_entry, entry);\n \t} else {\n-\t\tfor (i = 0; i < diff_queued_diff.nr; i++)\n+\t\tfor (int i = 0; i < diff_queued_diff.nr; i++)\n \t\t\tdiff_free_filepair(diff_queued_diff.queue[i]);\n \t\tinit_truncated_large_filter(filter);\n \n@@ -344,13 +340,12 @@ int bloom_filter_contains(const struct bloom_filter *filter,\n \t\t\t  const struct bloom_key *key,\n \t\t\t  const struct bloom_filter_settings *settings)\n {\n-\tint i;\n \tuint64_t mod = filter->len * BITS_PER_WORD;\n \n \tif (!mod)\n \t\treturn -1;\n \n-\tfor (i = 0; i < settings->num_hashes; i++) {\n+\tfor (int i = 0; i < settings->num_hashes; i++) {\n \t\tuint64_t hash_mod = key->hashes[i] % mod;\n \t\tuint64_t block_pos = hash_mod / BITS_PER_WORD;\n \t\tif (!(filter->data[block_pos] & get_bitmask(hash_mod)))\ndiff --git a/branch.c b/branch.c\nindex 6719a181bd..a2b56f701a 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -216,7 +216,6 @@ static int inherit_tracking(struct tracking *tracking, const char *orig_ref)\n {\n \tconst char *bare_ref;\n \tstruct branch *branch;\n-\tint i;\n \n \tbare_ref = orig_ref;\n \tskip_prefix(orig_ref, \"refs/heads/\", &bare_ref);\n@@ -235,7 +234,7 @@ static int inherit_tracking(struct tracking *tracking, const char *orig_ref)\n \t}\n \n \ttracking->remote = branch->remote_name;\n-\tfor (i = 0; i < branch->merge_nr; i++)\n+\tfor (int i = 0; i < branch->merge_nr; i++)\n \t\tstring_list_append(tracking->srcs, branch->merge_name[i]);\n \treturn 0;\n }\ndiff --git a/builtin/add.c b/builtin/add.c\nindex ada7719561..07052ef827 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -38,9 +38,9 @@ static const char *pathspec_from_file;\n \n static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n {\n-\tint i, ret = 0;\n+\tint ret = 0;\n \n-\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\tfor (int i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\n \t\tint err;\n \n@@ -66,9 +66,9 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)\n \n static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)\n {\n-\tint i, retval = 0;\n+\tint retval = 0;\n \n-\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\tfor (int i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\n \n \t\tif (!include_sparse &&\n@@ -112,7 +112,7 @@ static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec,\n static int refresh(int verbose, const struct pathspec *pathspec)\n {\n \tchar *seen;\n-\tint i, ret = 0;\n+\tint ret = 0;\n \tchar *skip_worktree_seen = NULL;\n \tstruct string_list only_match_skip_worktree = STRING_LIST_INIT_NODUP;\n \tint flags = REFRESH_IGNORE_SKIP_WORKTREE |\n@@ -121,7 +121,7 @@ static int refresh(int verbose, const struct pathspec *pathspec)\n \tseen = xcalloc(pathspec->nr, 1);\n \trefresh_index(&the_index, flags, pathspec, seen,\n \t\t      _(\"Unstaged changes after refreshing the index:\"));\n-\tfor (i = 0; i < pathspec->nr; i++) {\n+\tfor (int i = 0; i < pathspec->nr; i++) {\n \t\tif (!seen[i]) {\n \t\t\tconst char *path = pathspec->items[i].original;\n \n@@ -485,7 +485,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (pathspec.nr) {\n-\t\tint i;\n \t\tchar *skip_worktree_seen = NULL;\n \t\tstruct string_list only_match_skip_worktree = STRING_LIST_INIT_NODUP;\n \n@@ -504,7 +503,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\t\t       PATHSPEC_EXCLUDE |\n \t\t\t       PATHSPEC_ATTR);\n \n-\t\tfor (i = 0; i < pathspec.nr; i++) {\n+\t\tfor (int i = 0; i < pathspec.nr; i++) {\n \t\t\tconst char *path = pathspec.items[i].match;\n \n \t\t\tif (pathspec.items[i].magic & PATHSPEC_EXCLUDE)\ndiff --git a/builtin/am.c b/builtin/am.c\nindex d1990d7edc..512e2a150d 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -2445,7 +2445,6 @@ int cmd_am(int argc, const char **argv, const char *prefix)\n \t\t\tam_append_signoff(&state);\n \t} else {\n \t\tstruct strvec paths = STRVEC_INIT;\n-\t\tint i;\n \n \t\t/*\n \t\t * Handle stray state directory in the independent-run case. In\n@@ -2467,7 +2466,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)\n \t\tif (resume_mode)\n \t\t\tdie(_(\"Resolve operation not in progress, we are not resuming.\"));\n \n-\t\tfor (i = 0; i < argc; i++) {\n+\t\tfor (int i = 0; i < argc; i++) {\n \t\t\tif (is_absolute_path(argv[i]) || !prefix)\n \t\t\t\tstrvec_push(&paths, argv[i]);\n \t\t\telse\ndiff --git a/builtin/annotate.c b/builtin/annotate.c\nindex 58ff977a23..a940f50573 100644\n--- a/builtin/annotate.c\n+++ b/builtin/annotate.c\n@@ -10,11 +10,10 @@\n int cmd_annotate(int argc, const char **argv, const char *prefix)\n {\n \tstruct strvec args = STRVEC_INIT;\n-\tint i;\n \n \tstrvec_pushl(&args, \"annotate\", \"-c\", NULL);\n \n-\tfor (i = 1; i < argc; i++) {\n+\tfor (int i = 1; i < argc; i++) {\n \t\tstrvec_push(&args, argv[i]);\n \t}\n \ndiff --git a/builtin/archive.c b/builtin/archive.c\nindex 15ee1ec7bb..34db16787e 100644\n--- a/builtin/archive.c\n+++ b/builtin/archive.c\n@@ -25,7 +25,7 @@ static int run_remote_archiver(int argc, const char **argv,\n \t\t\t       const char *remote, const char *exec,\n \t\t\t       const char *name_hint)\n {\n-\tint fd[2], i, rv;\n+\tint fd[2], rv;\n \tstruct transport *transport;\n \tstruct remote *_remote;\n \tstruct packet_reader reader;\n@@ -47,7 +47,7 @@ static int run_remote_archiver(int argc, const char **argv,\n \t\tif (format)\n \t\t\tpacket_write_fmt(fd[1], \"argument --format=%s\\n\", format);\n \t}\n-\tfor (i = 1; i < argc; i++)\n+\tfor (int i = 1; i < argc; i++)\n \t\tpacket_write_fmt(fd[1], \"argument %s\\n\", argv[i]);\n \tpacket_flush(fd[1]);\n \ndiff --git a/builtin/bisect.c b/builtin/bisect.c\nindex f69c3f7e43..74a417f334 100644\n--- a/builtin/bisect.c\n+++ b/builtin/bisect.c\n@@ -916,7 +916,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,\n \t\t\t\t      const char **argv)\n {\n \tconst char *state;\n-\tint i, verify_expected = 1;\n+\tint verify_expected = 1;\n \tstruct object_id oid, expected;\n \tstruct oid_array revs = OID_ARRAY_INIT;\n \n@@ -975,7 +975,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,\n \tif (read_ref(\"BISECT_EXPECTED_REV\", &expected))\n \t\tverify_expected = 0; /* Ignore invalid file contents */\n \n-\tfor (i = 0; i < revs.nr; i++) {\n+\tfor (int i = 0; i < revs.nr; i++) {\n \t\tif (bisect_write(state, oid_to_hex(&revs.oid[i]), terms, 0)) {\n \t\t\toid_array_clear(&revs);\n \t\t\treturn BISECT_FAILED;\n@@ -1083,13 +1083,12 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f\n static enum bisect_error bisect_skip(struct bisect_terms *terms, int argc,\n \t\t\t\t     const char **argv)\n {\n-\tint i;\n \tenum bisect_error res;\n \tstruct strvec argv_state = STRVEC_INIT;\n \n \tstrvec_push(&argv_state, \"skip\");\n \n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tconst char *dotdot = strstr(argv[i], \"..\");\n \n \t\tif (dotdot) {\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex db1f56de61..b36e9bee72 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -313,7 +313,6 @@ static const char *format_time(timestamp_t time, const char *tz_str,\n \t}\n \telse {\n \t\tconst char *time_str;\n-\t\tsize_t time_width;\n \t\tint tz;\n \t\ttz = atoi(tz_str);\n \t\ttime_str = show_date(time, tz, &blame_date_mode);\n@@ -322,9 +321,7 @@ static const char *format_time(timestamp_t time, const char *tz_str,\n \t\t * Add space paddings to time_buf to display a fixed width\n \t\t * string, and use time_width for display width calibration.\n \t\t */\n-\t\tfor (time_width = utf8_strwidth(time_str);\n-\t\t     time_width < blame_date_width;\n-\t\t     time_width++)\n+\t\tfor (size_t time_width = utf8_strwidth(time_str); time_width < blame_date_width; time_width++)\n \t\t\tstrbuf_addch(&time_buf, ' ');\n \t}\n \treturn time_buf.buf;\n@@ -354,7 +351,6 @@ static void emit_porcelain(struct blame_scoreboard *sb, struct blame_entry *ent,\n \t\t\t   int opt)\n {\n \tint repeat = opt & OUTPUT_LINE_PORCELAIN;\n-\tint cnt;\n \tconst char *cp;\n \tstruct blame_origin *suspect = ent->suspect;\n \tchar hex[GIT_MAX_HEXSZ + 1];\n@@ -368,7 +364,7 @@ static void emit_porcelain(struct blame_scoreboard *sb, struct blame_entry *ent,\n \temit_porcelain_details(suspect, repeat);\n \n \tcp = blame_nth_line(sb, ent->lno);\n-\tfor (cnt = 0; cnt < ent->num_lines; cnt++) {\n+\tfor (int cnt = 0; cnt < ent->num_lines; cnt++) {\n \t\tchar ch;\n \t\tif (cnt) {\n \t\t\tprintf(\"%s %d %d\\n\", hex,\n@@ -447,7 +443,6 @@ static void determine_line_heat(struct commit_info *ci, const char **dest_color)\n \n static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int opt)\n {\n-\tint cnt;\n \tconst char *cp;\n \tstruct blame_origin *suspect = ent->suspect;\n \tstruct commit_info ci = COMMIT_INFO_INIT;\n@@ -466,7 +461,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int\n \t\treset = GIT_COLOR_RESET;\n \t}\n \n-\tfor (cnt = 0; cnt < ent->num_lines; cnt++) {\n+\tfor (int cnt = 0; cnt < ent->num_lines; cnt++) {\n \t\tchar ch;\n \t\tint length = (opt & OUTPUT_LONG_OBJECT_NAME) ? the_hash_algo->hexsz : abbrev;\n \n@@ -625,11 +620,10 @@ static void find_alignment(struct blame_scoreboard *sb, int *option)\n \tint longest_src_lines = 0;\n \tint longest_dst_lines = 0;\n \tunsigned largest_score = 0;\n-\tstruct blame_entry *e;\n \tint compute_auto_abbrev = (abbrev < 0);\n \tint auto_abbrev = DEFAULT_ABBREV;\n \n-\tfor (e = sb->ent; e; e = e->next) {\n+\tfor (struct blame_entry *e = sb->ent; e; e = e->next) {\n \t\tstruct blame_origin *suspect = e->suspect;\n \t\tint num;\n \ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex cfb63cce5f..774e213461 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -216,7 +216,6 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \tstruct object_id oid;\n \tchar *name = NULL;\n \tconst char *fmt;\n-\tint i;\n \tint ret = 0;\n \tint remote_branch = 0;\n \tstruct strbuf bname = STRBUF_INIT;\n@@ -247,7 +246,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \tif (!force)\n \t\thead_rev = lookup_commit_reference(the_repository, &head_oid);\n \n-\tfor (i = 0; i < argc; i++, strbuf_reset(&bname)) {\n+\tfor (int i = 0; i < argc; i++, strbuf_reset(&bname)) {\n \t\tchar *target = NULL;\n \t\tint flags = 0;\n \n@@ -339,8 +338,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \n static int calc_maxwidth(struct ref_array *refs, int remote_bonus)\n {\n-\tint i, max = 0;\n-\tfor (i = 0; i < refs->nr; i++) {\n+\tint max = 0;\n+\tfor (int i = 0; i < refs->nr; i++) {\n \t\tstruct ref_array_item *it = refs->items[i];\n \t\tconst char *desc = it->refname;\n \t\tint w;\n@@ -508,9 +507,7 @@ static void print_current_branch_name(void)\n static void reject_rebase_or_bisect_branch(struct worktree **worktrees,\n \t\t\t\t\t   const char *target)\n {\n-\tint i;\n-\n-\tfor (i = 0; worktrees[i]; i++) {\n+\tfor (int i = 0; worktrees[i]; i++) {\n \t\tstruct worktree *wt = worktrees[i];\n \n \t\tif (!wt->is_detached)\n@@ -536,9 +533,7 @@ static int replace_each_worktree_head_symref(struct worktree **worktrees,\n \t\t\t\t\t     const char *logmsg)\n {\n \tint ret = 0;\n-\tint i;\n-\n-\tfor (i = 0; worktrees[i]; i++) {\n+\tfor (int i = 0; worktrees[i]; i++) {\n \t\tstruct ref_store *refs;\n \n \t\tif (worktrees[i]->is_detached)\ndiff --git a/builtin/bugreport.c b/builtin/bugreport.c\nindex 3106e56a13..cff8e1624b 100644\n--- a/builtin/bugreport.c\n+++ b/builtin/bugreport.c\n@@ -47,15 +47,13 @@ static void get_system_info(struct strbuf *sys_info)\n \n static void get_populated_hooks(struct strbuf *hook_info, int nongit)\n {\n-\tconst char **p;\n-\n \tif (nongit) {\n \t\tstrbuf_addstr(hook_info,\n \t\t\t_(\"not run from a git repository - no hooks to show\\n\"));\n \t\treturn;\n \t}\n \n-\tfor (p = hook_name_list; *p; p++) {\n+\tfor (const char **p = hook_name_list; *p; p++) {\n \t\tconst char *hook = *p;\n \n \t\tif (hook_exists(hook))\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex bbf851138e..82b6d4f2c0 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -662,12 +662,10 @@ static void dispatch_calls(struct batch_options *opt,\n \t\tstruct queued_cmd *cmd,\n \t\tint nr)\n {\n-\tint i;\n-\n \tif (!opt->buffer_output)\n \t\tdie(_(\"flush is only for --buffer mode\"));\n \n-\tfor (i = 0; i < nr; i++)\n+\tfor (int i = 0; i < nr; i++)\n \t\tcmd[i].fn(opt, cmd[i].line, output, data);\n \n \tfflush(stdout);\n@@ -675,9 +673,7 @@ static void dispatch_calls(struct batch_options *opt,\n \n static void free_cmds(struct queued_cmd *cmd, size_t *nr)\n {\n-\tsize_t i;\n-\n-\tfor (i = 0; i < *nr; i++)\n+\tfor (size_t i = 0; i < *nr; i++)\n \t\tFREE_AND_NULL(cmd[i].line);\n \n \t*nr = 0;\ndiff --git a/builtin/check-attr.c b/builtin/check-attr.c\nindex c1da1d184e..1ea30c0670 100644\n--- a/builtin/check-attr.c\n+++ b/builtin/check-attr.c\n@@ -35,10 +35,9 @@ static const struct option check_attr_options[] = {\n \n static void output_attr(struct attr_check *check, const char *file)\n {\n-\tint j;\n \tint cnt = check->nr;\n \n-\tfor (j = 0; j < cnt; j++) {\n+\tfor (int j = 0; j < cnt; j++) {\n \t\tconst char *value = check->items[j].value;\n \n \t\tif (ATTR_TRUE(value))\ndiff --git a/builtin/check-ignore.c b/builtin/check-ignore.c\nindex 906cd96753..f146e3d254 100644\n--- a/builtin/check-ignore.c\n+++ b/builtin/check-ignore.c\n@@ -75,7 +75,7 @@ static int check_ignore(struct dir_struct *dir,\n {\n \tconst char *full_path;\n \tchar *seen;\n-\tint num_ignored = 0, i;\n+\tint num_ignored = 0;\n \tstruct path_pattern *pattern;\n \tstruct pathspec pathspec;\n \n@@ -104,7 +104,7 @@ static int check_ignore(struct dir_struct *dir,\n \t */\n \tseen = find_pathspecs_matching_against_index(&pathspec, &the_index,\n \t\t\t\t\t\t     PS_HEED_SKIP_WORKTREE);\n-\tfor (i = 0; i < pathspec.nr; i++) {\n+\tfor (int i = 0; i < pathspec.nr; i++) {\n \t\tfull_path = pathspec.items[i].match;\n \t\tpattern = NULL;\n \t\tif (!seen[i]) {\ndiff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c\nindex b8a05b8e07..294905528e 100644\n--- a/builtin/check-mailmap.c\n+++ b/builtin/check-mailmap.c\n@@ -42,7 +42,6 @@ static void check_mailmap(struct string_list *mailmap, const char *contact)\n \n int cmd_check_mailmap(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tstruct string_list mailmap = STRING_LIST_INIT_NODUP;\n \n \tgit_config(git_default_config, NULL);\n@@ -53,7 +52,7 @@ int cmd_check_mailmap(int argc, const char **argv, const char *prefix)\n \n \tread_mailmap(&mailmap);\n \n-\tfor (i = 0; i < argc; ++i)\n+\tfor (int i = 0; i < argc; ++i)\n \t\tcheck_mailmap(&mailmap, argv[i]);\n \tmaybe_flush_or_die(stdout, \"stdout\");\n \ndiff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c\nindex 6b62b5375b..44264dbbe2 100644\n--- a/builtin/checkout--worker.c\n+++ b/builtin/checkout--worker.c\n@@ -81,7 +81,7 @@ static void release_pc_item_data(struct parallel_checkout_item *pc_item)\n static void worker_loop(struct checkout *state)\n {\n \tstruct parallel_checkout_item *items = NULL;\n-\tsize_t i, nr = 0, alloc = 0;\n+\tsize_t nr = 0, alloc = 0;\n \n \twhile (1) {\n \t\tint len = packet_read(0, packet_buffer, sizeof(packet_buffer),\n@@ -96,7 +96,7 @@ static void worker_loop(struct checkout *state)\n \t\tpacket_to_pc_item(packet_buffer, len, &items[nr++]);\n \t}\n \n-\tfor (i = 0; i < nr; i++) {\n+\tfor (size_t i = 0; i < nr; i++) {\n \t\tstruct parallel_checkout_item *pc_item = &items[i];\n \t\twrite_pc_item(pc_item, state);\n \t\treport_result(pc_item);\ndiff --git a/builtin/checkout-index.c b/builtin/checkout-index.c\nindex 2e086a204d..bb3ffc27ab 100644\n--- a/builtin/checkout-index.c\n+++ b/builtin/checkout-index.c\n@@ -137,10 +137,10 @@ static int checkout_file(const char *name, const char *prefix)\n \n static int checkout_all(const char *prefix, int prefix_length)\n {\n-\tint i, errs = 0;\n+\tint errs = 0;\n \tstruct cache_entry *last_ce = NULL;\n \n-\tfor (i = 0; i < the_index.cache_nr ; i++) {\n+\tfor (int i = 0; i < the_index.cache_nr; i++) {\n \t\tstruct cache_entry *ce = the_index.cache[i];\n \n \t\tif (S_ISSPARSEDIR(ce->ce_mode)) {\n@@ -210,7 +210,6 @@ static int option_parse_stage(const struct option *opt,\n \n int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tstruct lock_file lock_file = LOCK_INIT;\n \tint all = 0;\n \tint read_from_stdin = 0;\n@@ -290,7 +289,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)\n \t\tinit_parallel_checkout();\n \n \t/* Check out named files first */\n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \t\tchar *p;\n \ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 067c251933..1f5e2560a6 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -382,7 +382,6 @@ static int checkout_worktree(const struct checkout_opts *opts,\n \tstruct checkout state = CHECKOUT_INIT;\n \tint nr_checkouts = 0, nr_unmerged = 0;\n \tint errs = 0;\n-\tint pos;\n \tint pc_workers, pc_threshold;\n \tstruct mem_pool ce_mem_pool;\n \n@@ -401,7 +400,7 @@ static int checkout_worktree(const struct checkout_opts *opts,\n \tif (pc_workers > 1)\n \t\tinit_parallel_checkout();\n \n-\tfor (pos = 0; pos < the_index.cache_nr; pos++) {\n+\tfor (int pos = 0; pos < the_index.cache_nr; pos++) {\n \t\tstruct cache_entry *ce = the_index.cache[pos];\n \t\tif (ce->ce_flags & CE_MATCHED) {\n \t\t\tif (!ce_stage(ce)) {\n@@ -1290,7 +1289,6 @@ static int parse_branchname_arg(int argc, const char **argv,\n \tconst char *arg;\n \tint dash_dash_pos;\n \tint has_dash_dash = 0;\n-\tint i;\n \n \t/*\n \t * case 1: git checkout <ref> -- [<paths>]\n@@ -1344,7 +1342,7 @@ static int parse_branchname_arg(int argc, const char **argv,\n \n \targ = argv[0];\n \tdash_dash_pos = -1;\n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tif (opts->accept_pathspec && !strcmp(argv[i], \"--\")) {\n \t\t\tdash_dash_pos = i;\n \t\t\tbreak;\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex d90766cad3..2e681f2e67 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -277,8 +277,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,\n \t}\n \n \tif (!*dir_gone && !quiet) {\n-\t\tint i;\n-\t\tfor (i = 0; i < dels.nr; i++)\n+\t\tfor (int i = 0; i < dels.nr; i++)\n \t\t\tprintf(dry_run ?  _(msg_would_remove) : _(msg_remove), dels.items[i].string);\n \t}\n out:\n@@ -408,7 +407,7 @@ static int find_unique(const char *choice, struct menu_stuff *menu_stuff)\n {\n \tstruct menu_item *menu_item;\n \tstruct string_list_item *string_list_item;\n-\tint i, len, found = 0;\n+\tint len, found = 0;\n \n \tlen = strlen(choice);\n \tswitch (menu_stuff->type) {\n@@ -417,7 +416,7 @@ static int find_unique(const char *choice, struct menu_stuff *menu_stuff)\n \tcase MENU_STUFF_TYPE_MENU_ITEM:\n \n \t\tmenu_item = (struct menu_item *)menu_stuff->stuff;\n-\t\tfor (i = 0; i < menu_stuff->nr; i++, menu_item++) {\n+\t\tfor (int i = 0; i < menu_stuff->nr; i++, menu_item++) {\n \t\t\tif (len == 1 && *choice == menu_item->hotkey) {\n \t\t\t\tfound = i + 1;\n \t\t\t\tbreak;\n@@ -439,7 +438,7 @@ static int find_unique(const char *choice, struct menu_stuff *menu_stuff)\n \t\tbreak;\n \tcase MENU_STUFF_TYPE_STRING_LIST:\n \t\tstring_list_item = ((struct string_list *)menu_stuff->stuff)->items;\n-\t\tfor (i = 0; i < menu_stuff->nr; i++, string_list_item++) {\n+\t\tfor (int i = 0; i < menu_stuff->nr; i++, string_list_item++) {\n \t\t\tif (!strncasecmp(choice, string_list_item->string, len)) {\n \t\t\t\tif (found) {\n \t\t\t\t\tfound = 0;\n@@ -479,7 +478,7 @@ static int parse_choice(struct menu_stuff *menu_stuff,\n \t\t\tstruct strbuf input,\n \t\t\tint **chosen)\n {\n-\tstruct strbuf **choice_list, **ptr;\n+\tstruct strbuf **choice_list;\n \tint nr = 0;\n \tint i;\n \n@@ -494,7 +493,7 @@ static int parse_choice(struct menu_stuff *menu_stuff,\n \t\tchoice_list = strbuf_split_max(&input, ' ', 0);\n \t}\n \n-\tfor (ptr = choice_list; *ptr; ptr++) {\n+\tfor (struct strbuf **ptr = choice_list; *ptr; ptr++) {\n \t\tchar *p;\n \t\tint choose = 1;\n \t\tint bottom = 0, top = 0;\n@@ -886,9 +885,9 @@ static void interactive_main_loop(void)\n \n static void correct_untracked_entries(struct dir_struct *dir)\n {\n-\tint src, dst, ign;\n+\tint dst, ign;\n \n-\tfor (src = dst = ign = 0; src < dir->nr; src++) {\n+\tfor (int src = dst = ign = 0; src < dir->nr; src++) {\n \t\t/* skip paths in ignored[] that cannot be inside entries[src] */\n \t\twhile (ign < dir->ignored_nr &&\n \t\t       0 <= cmp_dir_entry(&dir->entries[src], &dir->ignored[ign]))\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex bad1b70ce8..a1abcbdf31 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -511,8 +511,7 @@ static struct ref *wanted_peer_refs(const struct ref *refs,\n \t\t\twarning(_(\"Could not find remote branch %s to clone.\"),\n \t\t\t\toption_branch);\n \t\telse {\n-\t\t\tint i;\n-\t\t\tfor (i = 0; i < refspec->nr; i++)\n+\t\t\tfor (int i = 0; i < refspec->nr; i++)\n \t\t\t\tget_fetch_map(remote_head, &refspec->items[i],\n \t\t\t\t\t      &tail, 0);\n \n@@ -521,8 +520,7 @@ static struct ref *wanted_peer_refs(const struct ref *refs,\n \t\t}\n \t\tfree_refs(remote_head);\n \t} else {\n-\t\tint i;\n-\t\tfor (i = 0; i < refspec->nr; i++)\n+\t\tfor (int i = 0; i < refspec->nr; i++)\n \t\t\tget_fetch_map(refs, &refspec->items[i], &tail, 0);\n \t}\n \n@@ -534,8 +532,6 @@ static struct ref *wanted_peer_refs(const struct ref *refs,\n \n static void write_remote_refs(const struct ref *local_refs)\n {\n-\tconst struct ref *r;\n-\n \tstruct ref_transaction *t;\n \tstruct strbuf err = STRBUF_INIT;\n \n@@ -543,7 +539,7 @@ static void write_remote_refs(const struct ref *local_refs)\n \tif (!t)\n \t\tdie(\"%s\", err.buf);\n \n-\tfor (r = local_refs; r; r = r->next) {\n+\tfor (const struct ref *r = local_refs; r; r = r->next) {\n \t\tif (!r->peer_ref)\n \t\t\tcontinue;\n \t\tif (ref_transaction_create(t, r->peer_ref->name, &r->old_oid,\n@@ -560,8 +556,7 @@ static void write_remote_refs(const struct ref *local_refs)\n \n static void write_followtags(const struct ref *refs, const char *msg)\n {\n-\tconst struct ref *ref;\n-\tfor (ref = refs; ref; ref = ref->next) {\n+\tfor (const struct ref *ref = refs; ref; ref = ref->next) {\n \t\tif (!starts_with(ref->name, \"refs/tags/\"))\n \t\t\tcontinue;\n \t\tif (ends_with(ref->name, \"^{}\"))\n@@ -826,9 +821,7 @@ static int write_one_config(const char *key, const char *value,\n \n static void write_config(struct string_list *config)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < config->nr; i++) {\n+\tfor (int i = 0; i < config->nr; i++) {\n \t\tif (git_config_parse_parameter(config->items[i].string,\n \t\t\t\t\t       write_one_config, NULL) < 0)\n \t\t\tdie(_(\"unable to write parameters to config file\"));\ndiff --git a/builtin/commit-tree.c b/builtin/commit-tree.c\nindex 1bb7819839..4dacdefa2f 100644\n--- a/builtin/commit-tree.c\n+++ b/builtin/commit-tree.c\n@@ -25,8 +25,7 @@ static const char *sign_commit;\n static void new_parent(struct commit *parent, struct commit_list **parents_p)\n {\n \tstruct object_id *oid = &parent->object.oid;\n-\tstruct commit_list *parents;\n-\tfor (parents = *parents_p; parents; parents = parents->next) {\n+\tfor (struct commit_list *parents = *parents_p; parents; parents = parents->next) {\n \t\tif (parents->item == parent) {\n \t\t\terror(_(\"duplicate parent %s ignored\"), oid_to_hex(oid));\n \t\t\treturn;\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 6d1fa71676..1782909eef 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -256,7 +256,7 @@ static int commit_index_files(void)\n static int list_paths(struct string_list *list, const char *with_tree,\n \t\t      const struct pathspec *pattern)\n {\n-\tint i, ret;\n+\tint ret;\n \tchar *m;\n \n \tif (!pattern->nr)\n@@ -272,7 +272,7 @@ static int list_paths(struct string_list *list, const char *with_tree,\n \n \t/* TODO: audit for interaction with sparse-index. */\n \tensure_full_index(&the_index);\n-\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\tfor (int i = 0; i < the_index.cache_nr; i++) {\n \t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tstruct string_list_item *item;\n \n@@ -292,8 +292,7 @@ static int list_paths(struct string_list *list, const char *with_tree,\n \n static void add_remove_files(struct string_list *list)\n {\n-\tint i;\n-\tfor (i = 0; i < list->nr; i++) {\n+\tfor (int i = 0; i < list->nr; i++) {\n \t\tstruct stat st;\n \t\tstruct string_list_item *p = &(list->items[i]);\n \n@@ -1001,11 +1000,11 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\tparent = \"HEAD^1\";\n \n \t\tif (repo_get_oid(the_repository, parent, &oid)) {\n-\t\t\tint i, ita_nr = 0;\n+\t\t\tint ita_nr = 0;\n \n \t\t\t/* TODO: audit for interaction with sparse-index. */\n \t\t\tensure_full_index(&the_index);\n-\t\t\tfor (i = 0; i < the_index.cache_nr; i++)\n+\t\t\tfor (int i = 0; i < the_index.cache_nr; i++)\n \t\t\t\tif (ce_intent_to_add(the_index.cache[i]))\n \t\t\t\t\tita_nr++;\n \t\t\tcommittable = the_index.cache_nr - ita_nr > 0;\ndiff --git a/builtin/config.c b/builtin/config.c\nindex b55bfae7d6..10a181daec 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -333,7 +333,6 @@ static int get_value(const char *key_, const char *regex_, unsigned flags)\n {\n \tint ret = CONFIG_GENERIC_ERROR;\n \tstruct strbuf_list values = {NULL};\n-\tint i;\n \n \tif (use_key_regexp) {\n \t\tchar *tl;\n@@ -402,7 +401,7 @@ static int get_value(const char *key_, const char *regex_, unsigned flags)\n \n \tret = !values.nr;\n \n-\tfor (i = 0; i < values.nr; i++) {\n+\tfor (int i = 0; i < values.nr; i++) {\n \t\tstruct strbuf *buf = values.items + i;\n \t\tif (do_all || i == values.nr - 1)\n \t\t\tfwrite(buf->buf, 1, buf->len, stdout);\ndiff --git a/builtin/count-objects.c b/builtin/count-objects.c\nindex 2d4bb5e8d0..5e8731d3f4 100644\n--- a/builtin/count-objects.c\n+++ b/builtin/count-objects.c\n@@ -120,14 +120,13 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)\n \t\t\t\t      count_loose, count_cruft, NULL, NULL);\n \n \tif (verbose) {\n-\t\tstruct packed_git *p;\n \t\tunsigned long num_pack = 0;\n \t\toff_t size_pack = 0;\n \t\tstruct strbuf loose_buf = STRBUF_INIT;\n \t\tstruct strbuf pack_buf = STRBUF_INIT;\n \t\tstruct strbuf garbage_buf = STRBUF_INIT;\n \n-\t\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\t\tfor (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {\n \t\t\tif (!p->pack_local)\n \t\t\t\tcontinue;\n \t\t\tif (open_pack_index(p))\ndiff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c\nindex 3a6a750a8e..09a30ceafc 100644\n--- a/builtin/credential-cache--daemon.c\n+++ b/builtin/credential-cache--daemon.c\n@@ -34,8 +34,7 @@ static void cache_credential(struct credential *c, int timeout)\n \n static struct credential_cache_entry *lookup_credential(const struct credential *c)\n {\n-\tint i;\n-\tfor (i = 0; i < entries_nr; i++) {\n+\tfor (int i = 0; i < entries_nr; i++) {\n \t\tstruct credential *e = &entries[i].item;\n \t\tif (credential_match(c, e, 0))\n \t\t\treturn &entries[i];\n@@ -45,10 +44,7 @@ static struct credential_cache_entry *lookup_credential(const struct credential\n \n static void remove_credential(const struct credential *c, int match_password)\n {\n-\tstruct credential_cache_entry *e;\n-\n-\tint i;\n-\tfor (i = 0; i < entries_nr; i++) {\n+\tstruct credential_cache_entry *e;for (int i = 0; i < entries_nr; i++) {\n \t\te = &entries[i];\n \t\tif (credential_match(c, &e->item, match_password))\n \t\t\te->expiration = 0;\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex d6c77a714f..59b22e27c3 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -450,8 +450,8 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)\n \tif (debug) {\n \t\tstatic int label_width = -1;\n \t\tif (label_width < 0) {\n-\t\t\tint i, w;\n-\t\t\tfor (i = 0; i < ARRAY_SIZE(prio_names); i++) {\n+\t\t\tint w;\n+\t\t\tfor (int i = 0; i < ARRAY_SIZE(prio_names); i++) {\n \t\t\t\tw = strlen(_(prio_names[i]));\n \t\t\t\tif (label_width < w)\n \t\t\t\t\tlabel_width = w;\ndiff --git a/builtin/diff-index.c b/builtin/diff-index.c\nindex 3e05260ac0..2b47986df4 100644\n--- a/builtin/diff-index.c\n+++ b/builtin/diff-index.c\n@@ -18,7 +18,6 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n {\n \tstruct rev_info rev;\n \tunsigned int option = 0;\n-\tint i;\n \tint result;\n \n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n@@ -36,7 +35,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n \tdiff_merges_suppress_m_parsing();\n \n \targc = setup_revisions(argc, argv, &rev, NULL);\n-\tfor (i = 1; i < argc; i++) {\n+\tfor (int i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n \t\tif (!strcmp(arg, \"--cached\"))\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 6e196e0c7d..f9779a4c8d 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -211,7 +211,6 @@ static void builtin_diff_combined(struct rev_info *revs,\n \t\t\t\t  int ents, int first_non_parent)\n {\n \tstruct oid_array parents = OID_ARRAY_INIT;\n-\tint i;\n \n \tif (argc > 1)\n \t\tusage(builtin_diff_usage);\n@@ -223,7 +222,7 @@ static void builtin_diff_combined(struct rev_info *revs,\n \n \tdiff_merges_set_dense_combined_if_unset(revs);\n \n-\tfor (i = 0; i < ents; i++) {\n+\tfor (int i = 0; i < ents; i++) {\n \t\tif (i != first_non_parent)\n \t\t\toid_array_append(&parents, &ent[i].item->oid);\n \t}\n@@ -313,7 +312,7 @@ struct symdiff {\n  */\n static void symdiff_prepare(struct rev_info *rev, struct symdiff *sym)\n {\n-\tint i, is_symdiff = 0, basecount = 0, othercount = 0;\n+\tint is_symdiff = 0, basecount = 0, othercount = 0;\n \tint lpos = -1, rpos = -1, basepos = -1;\n \tstruct bitmap *map = NULL;\n \n@@ -332,7 +331,7 @@ static void symdiff_prepare(struct rev_info *rev, struct symdiff *sym)\n \t * so we must check for SYMMETRIC_LEFT too.  The two arrays\n \t * rev->pending.objects and rev->cmdline.rev are parallel.\n \t */\n-\tfor (i = 0; i < rev->cmdline.nr; i++) {\n+\tfor (int i = 0; i < rev->cmdline.nr; i++) {\n \t\tstruct object *obj = rev->pending.objects[i].item;\n \t\tswitch (rev->cmdline.rev[i].whence) {\n \t\tcase REV_CMD_MERGE_BASE:\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 4693d18cc9..6cebf8f4ab 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -430,7 +430,6 @@ static const char *anonymize_oid(const char *oid_hex)\n static void show_filemodify(struct diff_queue_struct *q,\n \t\t\t    struct diff_options *options UNUSED, void *data)\n {\n-\tint i;\n \tstruct string_list *changed = data;\n \n \t/*\n@@ -439,7 +438,7 @@ static void show_filemodify(struct diff_queue_struct *q,\n \t */\n \tQSORT(q->queue, q->nr, depth_first);\n \n-\tfor (i = 0; i < q->nr; i++) {\n+\tfor (int i = 0; i < q->nr; i++) {\n \t\tstruct diff_filespec *ospec = q->queue[i]->one;\n \t\tstruct diff_filespec *spec = q->queue[i]->two;\n \n@@ -543,10 +542,9 @@ static const char *anonymize_refname(const char *refname)\n \t};\n \tstatic struct hashmap refs;\n \tstatic struct strbuf anon = STRBUF_INIT;\n-\tint i;\n \n \tstrbuf_reset(&anon);\n-\tfor (i = 0; i < ARRAY_SIZE(prefixes); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(prefixes); i++) {\n \t\tif (skip_prefix(refname, prefixes[i], &refname)) {\n \t\t\tstrbuf_addstr(&anon, prefixes[i]);\n \t\t\tbreak;\n@@ -926,9 +924,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)\n \n static void get_tags_and_duplicates(struct rev_cmdline_info *info)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < info->nr; i++) {\n+\tfor (int i = 0; i < info->nr; i++) {\n \t\tstruct rev_cmdline_entry *e = info->rev + i;\n \t\tstruct object_id oid;\n \t\tstruct commit *commit;\n@@ -988,9 +984,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)\n static void handle_tags_and_duplicates(struct string_list *extras)\n {\n \tstruct commit *commit;\n-\tint i;\n-\n-\tfor (i = extras->nr - 1; i >= 0; i--) {\n+\tfor (int i = extras->nr - 1; i >= 0; i--) {\n \t\tconst char *name = extras->items[i].string;\n \t\tstruct object *object = extras->items[i].util;\n \t\tint mark;\n@@ -1050,7 +1044,6 @@ static void handle_tags_and_duplicates(struct string_list *extras)\n \n static void export_marks(char *file)\n {\n-\tunsigned int i;\n \tuint32_t mark;\n \tstruct decoration_entry *deco = idnums.entries;\n \tFILE *f;\n@@ -1060,7 +1053,7 @@ static void export_marks(char *file)\n \tif (!f)\n \t\tdie_errno(\"Unable to open marks file %s for writing.\", file);\n \n-\tfor (i = 0; i < idnums.size; i++) {\n+\tfor (unsigned int i = 0; i < idnums.size; i++) {\n \t\tif (deco->base && deco->base->type == 1) {\n \t\t\tmark = ptr_to_mark(deco->decoration);\n \t\t\tif (fprintf(f, \":%\"PRIu32\" %s\\n\", mark,\n@@ -1135,8 +1128,7 @@ static void import_marks(char *input_file, int check_exists)\n \n static void handle_deletes(void)\n {\n-\tint i;\n-\tfor (i = 0; i < refspecs.nr; i++) {\n+\tfor (int i = 0; i < refspecs.nr; i++) {\n \t\tstruct refspec_item *refspec = &refspecs.items[i];\n \t\tif (*refspec->src)\n \t\t\tcontinue;\n@@ -1247,9 +1239,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"the option '%s' requires '%s'\"), \"--anonymize-map\", \"--anonymize\");\n \n \tif (refspecs_list.nr) {\n-\t\tint i;\n-\n-\t\tfor (i = 0; i < refspecs_list.nr; i++)\n+\t\tfor (int i = 0; i < refspecs_list.nr; i++)\n \t\t\trefspec_append(&refspecs, refspecs_list.items[i].string);\n \n \t\tstring_list_clear(&refspecs_list, 1);\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex 92eda20683..4fd4b9284a 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -273,14 +273,13 @@ static void parse_ls(const char *p, struct branch *b);\n \n static void for_each_mark(struct mark_set *m, uintmax_t base, each_mark_fn_t callback, void *p)\n {\n-\tuintmax_t k;\n \tif (m->shift) {\n-\t\tfor (k = 0; k < 1024; k++) {\n+\t\tfor (uintmax_t k = 0; k < 1024; k++) {\n \t\t\tif (m->data.sets[k])\n \t\t\t\tfor_each_mark(m->data.sets[k], base + (k << m->shift), callback, p);\n \t\t}\n \t} else {\n-\t\tfor (k = 0; k < 1024; k++) {\n+\t\tfor (uintmax_t k = 0; k < 1024; k++) {\n \t\t\tif (m->data.marked[k])\n \t\t\t\tcallback(base + k, m->data.marked[k], p);\n \t\t}\n@@ -328,7 +327,6 @@ static void write_crash_report(const char *err)\n \tFILE *rpt = fopen(loc, \"w\");\n \tstruct branch *b;\n \tunsigned long lu;\n-\tstruct recent_command *rc;\n \n \tif (!rpt) {\n \t\terror_errno(\"can't write crash report %s\", loc);\n@@ -351,7 +349,7 @@ static void write_crash_report(const char *err)\n \tfputc('\\n', rpt);\n \tfputs(\"Most Recent Commands Before Crash\\n\", rpt);\n \tfputs(\"---------------------------------\\n\", rpt);\n-\tfor (rc = cmd_hist.next; rc != &cmd_hist; rc = rc->next) {\n+\tfor (struct recent_command *rc = cmd_hist.next; rc != &cmd_hist; rc = rc->next) {\n \t\tif (rc->next == &cmd_hist)\n \t\t\tfputs(\"* \", rpt);\n \t\telse\n@@ -382,11 +380,10 @@ static void write_crash_report(const char *err)\n \t}\n \n \tif (first_tag) {\n-\t\tstruct tag *tg;\n \t\tfputc('\\n', rpt);\n \t\tfputs(\"Annotated Tags\\n\", rpt);\n \t\tfputs(\"--------------\\n\", rpt);\n-\t\tfor (tg = first_tag; tg; tg = tg->next_tag) {\n+\t\tfor (struct tag *tg = first_tag; tg; tg = tg->next_tag) {\n \t\t\tfputs(oid_to_hex(&tg->oid), rpt);\n \t\t\tfputc(' ', rpt);\n \t\t\tfputs(tg->name, rpt);\n@@ -511,8 +508,6 @@ static struct object_entry *insert_object(struct object_id *oid)\n \n static void invalidate_pack_id(unsigned int id)\n {\n-\tunsigned long lu;\n-\tstruct tag *t;\n \tstruct hashmap_iter iter;\n \tstruct object_entry *e;\n \n@@ -521,7 +516,7 @@ static void invalidate_pack_id(unsigned int id)\n \t\t\te->pack_id = MAX_PACK_ID;\n \t}\n \n-\tfor (lu = 0; lu < branch_table_sz; lu++) {\n+\tfor (unsigned long lu = 0; lu < branch_table_sz; lu++) {\n \t\tstruct branch *b;\n \n \t\tfor (b = branch_table[lu]; b; b = b->table_next_branch)\n@@ -529,7 +524,7 @@ static void invalidate_pack_id(unsigned int id)\n \t\t\t\tb->pack_id = MAX_PACK_ID;\n \t}\n \n-\tfor (t = first_tag; t; t = t->next_tag)\n+\tfor (struct tag *t = first_tag; t; t = t->next_tag)\n \t\tif (t->pack_id == id)\n \t\t\tt->pack_id = MAX_PACK_ID;\n }\n@@ -606,9 +601,7 @@ static struct atom_str *to_atom(const char *s, unsigned short len)\n static struct branch *lookup_branch(const char *name)\n {\n \tunsigned int hc = hc_str(name, strlen(name)) % branch_table_sz;\n-\tstruct branch *b;\n-\n-\tfor (b = branch_table[hc]; b; b = b->table_next_branch)\n+\tfor (struct branch *b = branch_table[hc]; b; b = b->table_next_branch)\n \t\tif (!strcmp(name, b->name))\n \t\t\treturn b;\n \treturn NULL;\n@@ -681,8 +674,7 @@ static void release_tree_content(struct tree_content *t)\n \n static void release_tree_content_recursive(struct tree_content *t)\n {\n-\tunsigned int i;\n-\tfor (i = 0; i < t->entry_count; i++)\n+\tfor (unsigned int i = 0; i < t->entry_count; i++)\n \t\trelease_tree_entry(t->entries[i]);\n \trelease_tree_content(t);\n }\n@@ -732,12 +724,11 @@ static struct tree_content *dup_tree_content(struct tree_content *s)\n {\n \tstruct tree_content *d;\n \tstruct tree_entry *a, *b;\n-\tunsigned int i;\n \n \tif (!s)\n \t\treturn NULL;\n \td = new_tree_content(s->entry_count);\n-\tfor (i = 0; i < s->entry_count; i++) {\n+\tfor (unsigned int i = 0; i < s->entry_count; i++) {\n \t\ta = s->entries[i];\n \t\tb = new_tree_entry();\n \t\tmemcpy(b, a, sizeof(*a));\n@@ -780,12 +771,11 @@ static const char *create_index(void)\n \tconst char *tmpfile;\n \tstruct pack_idx_entry **idx, **c, **last;\n \tstruct object_entry *e;\n-\tstruct object_entry_pool *o;\n \n \t/* Build the table of object IDs. */\n \tALLOC_ARRAY(idx, object_count);\n \tc = idx;\n-\tfor (o = blocks; o; o = o->next_pool)\n+\tfor (struct object_entry_pool *o = blocks; o; o = o->next_pool)\n \t\tfor (e = o->next_free; e-- != o->entries;)\n \t\t\tif (pack_id == e->pack_id)\n \t\t\t\t*c++ = &e->idx;\n@@ -827,9 +817,7 @@ static char *keep_pack(const char *curr_index_name)\n static void unkeep_all_packs(void)\n {\n \tstruct strbuf name = STRBUF_INIT;\n-\tint k;\n-\n-\tfor (k = 0; k < pack_id; k++) {\n+\tfor (int k = 0; k < pack_id; k++) {\n \t\tstruct packed_git *p = all_packs[k];\n \t\todb_pack_name(&name, p->hash, \"keep\");\n \t\tunlink_or_warn(name.buf);\n@@ -1416,7 +1404,7 @@ static int tree_content_set(\n {\n \tstruct tree_content *t;\n \tconst char *slash1;\n-\tunsigned int i, n;\n+\tunsigned int n;\n \tstruct tree_entry *e;\n \n \tslash1 = strchrnul(p, '/');\n@@ -1429,7 +1417,7 @@ static int tree_content_set(\n \tif (!root->tree)\n \t\tload_tree(root);\n \tt = root->tree;\n-\tfor (i = 0; i < t->entry_count; i++) {\n+\tfor (unsigned int i = 0; i < t->entry_count; i++) {\n \t\te = t->entries[i];\n \t\tif (e->name->str_len == n && !fspathncmp(p, e->name->str_dat, n)) {\n \t\t\tif (!*slash1) {\n@@ -1504,7 +1492,7 @@ static int tree_content_remove(\n {\n \tstruct tree_content *t;\n \tconst char *slash1;\n-\tunsigned int i, n;\n+\tunsigned int n;\n \tstruct tree_entry *e;\n \n \tslash1 = strchrnul(p, '/');\n@@ -1519,7 +1507,7 @@ static int tree_content_remove(\n \t}\n \n \tt = root->tree;\n-\tfor (i = 0; i < t->entry_count; i++) {\n+\tfor (unsigned int i = 0; i < t->entry_count; i++) {\n \t\te = t->entries[i];\n \t\tif (e->name->str_len == n && !fspathncmp(p, e->name->str_dat, n)) {\n \t\t\tif (*slash1 && !S_ISDIR(e->versions[1].mode))\n@@ -1569,7 +1557,7 @@ static int tree_content_get(\n {\n \tstruct tree_content *t;\n \tconst char *slash1;\n-\tunsigned int i, n;\n+\tunsigned int n;\n \tstruct tree_entry *e;\n \n \tslash1 = strchrnul(p, '/');\n@@ -1586,7 +1574,7 @@ static int tree_content_get(\n \t}\n \n \tt = root->tree;\n-\tfor (i = 0; i < t->entry_count; i++) {\n+\tfor (unsigned int i = 0; i < t->entry_count; i++) {\n \t\te = t->entries[i];\n \t\tif (e->name->str_len == n && !fspathncmp(p, e->name->str_dat, n)) {\n \t\t\tif (!*slash1)\n@@ -1658,10 +1646,9 @@ static int update_branch(struct branch *b)\n \n static void dump_branches(void)\n {\n-\tunsigned int i;\n \tstruct branch *b;\n \n-\tfor (i = 0; i < branch_table_sz; i++) {\n+\tfor (unsigned int i = 0; i < branch_table_sz; i++) {\n \t\tfor (b = branch_table[i]; b; b = b->table_next_branch)\n \t\t\tfailure |= update_branch(b);\n \t}\n@@ -1670,7 +1657,6 @@ static void dump_branches(void)\n static void dump_tags(void)\n {\n \tstatic const char *msg = \"fast-import\";\n-\tstruct tag *t;\n \tstruct strbuf ref_name = STRBUF_INIT;\n \tstruct strbuf err = STRBUF_INIT;\n \tstruct ref_transaction *transaction;\n@@ -1680,7 +1666,7 @@ static void dump_tags(void)\n \t\tfailure |= error(\"%s\", err.buf);\n \t\tgoto cleanup;\n \t}\n-\tfor (t = first_tag; t; t = t->next_tag) {\n+\tfor (struct tag *t = first_tag; t; t = t->next_tag) {\n \t\tstrbuf_reset(&ref_name);\n \t\tstrbuf_addf(&ref_name, \"refs/tags/%s\", t->name);\n \n@@ -2105,7 +2091,7 @@ static uintmax_t do_change_note_fanout(\n {\n \tstruct tree_content *t;\n \tstruct tree_entry *e, leaf;\n-\tunsigned int i, tmp_hex_oid_len, tmp_fullpath_len;\n+\tunsigned int tmp_hex_oid_len, tmp_fullpath_len;\n \tuintmax_t num_notes = 0;\n \tstruct object_id oid;\n \t/* hex oid + '/' between each pair of hex digits + NUL */\n@@ -2116,7 +2102,7 @@ static uintmax_t do_change_note_fanout(\n \t\tload_tree(root);\n \tt = root->tree;\n \n-\tfor (i = 0; t && i < t->entry_count; i++) {\n+\tfor (unsigned int i = 0; t && i < t->entry_count; i++) {\n \t\te = t->entries[i];\n \t\ttmp_hex_oid_len = hex_oid_len + e->name->str_len;\n \t\ttmp_fullpath_len = fullpath_len;\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 44c05ee86c..577d2d0db9 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -242,11 +242,9 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix UNUSED)\n \tref = fetch_pack(&args, fd, ref, sought, nr_sought,\n \t\t\t &shallow, pack_lockfiles_ptr, version);\n \tif (pack_lockfiles.nr) {\n-\t\tint i;\n-\n \t\tprintf(\"lock %s\\n\", pack_lockfiles.items[0].string);\n \t\tfflush(stdout);\n-\t\tfor (i = 1; i < pack_lockfiles.nr; i++)\n+\t\tfor (int i = 1; i < pack_lockfiles.nr; i++)\n \t\t\twarning(_(\"Lockfile created but not reported: %s\"),\n \t\t\t\tpack_lockfiles.items[i].string);\n \t}\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 3aedfd1bb6..08ebb55d0d 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -210,9 +210,7 @@ static void add_merge_config(struct ref **head,\n \t\t           struct branch *branch,\n \t\t           struct ref ***tail)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < branch->merge_nr; i++) {\n+\tfor (int i = 0; i < branch->merge_nr; i++) {\n \t\tstruct ref *rm, **old_tail = *tail;\n \t\tstruct refspec_item refspec;\n \n@@ -331,7 +329,6 @@ static void find_non_local_tags(const struct ref *refs,\n \tstruct oidset fetch_oids = OIDSET_INIT;\n \tstruct string_list remote_refs_list = STRING_LIST_INIT_NODUP;\n \tstruct string_list_item *remote_ref_item;\n-\tconst struct ref *ref;\n \tstruct refname_hash_entry *item = NULL;\n \tconst int quick_flags = OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n@@ -350,7 +347,7 @@ static void find_non_local_tags(const struct ref *refs,\n \t\t\t\t\t\t       add_already_queued_tags,\n \t\t\t\t\t\t       &existing_refs);\n \n-\tfor (ref = refs; ref; ref = ref->next) {\n+\tfor (const struct ref *ref = refs; ref; ref = ref->next) {\n \t\tif (!starts_with(ref->name, \"refs/tags/\"))\n \t\t\tcontinue;\n \n@@ -434,12 +431,10 @@ static void find_non_local_tags(const struct ref *refs,\n \n static void filter_prefetch_refspec(struct refspec *rs)\n {\n-\tint i;\n-\n \tif (!prefetch)\n \t\treturn;\n \n-\tfor (i = 0; i < rs->nr; i++) {\n+\tfor (int i = 0; i < rs->nr; i++) {\n \t\tstruct strbuf new_dst = STRBUF_INIT;\n \t\tchar *old_dst;\n \t\tconst char *sub = NULL;\n@@ -698,14 +693,13 @@ static int s_update_ref(const char *action,\n \n static int refcol_width(const struct ref *ref_map, int compact_format)\n {\n-\tconst struct ref *ref;\n \tint max, width = 10;\n \n \tmax = term_columns();\n \tif (compact_format)\n \t\tmax = max * 2 / 3;\n \n-\tfor (ref = ref_map; ref; ref = ref->next) {\n+\tfor (const struct ref *ref = ref_map; ref; ref = ref->next) {\n \t\tint rlen, llen = 0, len;\n \n \t\tif (ref->status == REF_STATUS_REJECT_SHALLOW ||\n@@ -1138,7 +1132,6 @@ static int store_updated_refs(struct display_state *display_state,\n \tstruct strbuf note = STRBUF_INIT;\n \tconst char *what, *kind;\n \tstruct ref *rm;\n-\tint want_status;\n \tint summary_width = 0;\n \n \tif (verbosity >= 0)\n@@ -1161,9 +1154,7 @@ static int store_updated_refs(struct display_state *display_state,\n \t * merged entries are written before not-for-merge. That lets readers\n \t * use FETCH_HEAD as a refname to refer to the ref to be merged.\n \t */\n-\tfor (want_status = FETCH_HEAD_MERGE;\n-\t     want_status <= FETCH_HEAD_IGNORE;\n-\t     want_status++) {\n+\tfor (int want_status = FETCH_HEAD_MERGE; want_status <= FETCH_HEAD_IGNORE; want_status++) {\n \t\tfor (rm = ref_map; rm; rm = rm->next) {\n \t\t\tstruct ref *ref = NULL;\n \n@@ -1294,7 +1285,6 @@ static int check_exist_and_connected(struct ref *ref_map)\n {\n \tstruct ref *rm = ref_map;\n \tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n-\tstruct ref *r;\n \n \t/*\n \t * If we are deepening a shallow clone we already have these\n@@ -1318,7 +1308,7 @@ static int check_exist_and_connected(struct ref *ref_map)\n \t * check_connected() allows objects to merely be promised, but\n \t * we need all direct targets to exist.\n \t */\n-\tfor (r = rm; r; r = r->next) {\n+\tfor (struct ref *r = rm; r; r = r->next) {\n \t\tif (!repo_has_object_file_with_flags(the_repository, &r->old_oid,\n \t\t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT))\n \t\t\treturn -1;\n@@ -1462,9 +1452,7 @@ static int add_oid(const char *refname UNUSED,\n static void add_negotiation_tips(struct git_transport_options *smart_options)\n {\n \tstruct oid_array *oids = xcalloc(1, sizeof(*oids));\n-\tint i;\n-\n-\tfor (i = 0; i < negotiation_tip.nr; i++) {\n+\tfor (int i = 0; i < negotiation_tip.nr; i++) {\n \t\tconst char *s = negotiation_tip.items[i].string;\n \t\tint old_nr;\n \t\tif (!has_glob_specials(s)) {\n@@ -1592,8 +1580,6 @@ static int do_fetch(struct transport *transport,\n \t}\n \n \tif (rs->nr) {\n-\t\tint i;\n-\n \t\trefspec_ref_prefixes(rs, &transport_ls_refs_options.ref_prefixes);\n \n \t\t/*\n@@ -1601,7 +1587,7 @@ static int do_fetch(struct transport *transport,\n \t\t * OIDs\n \t\t */\n \t\tmust_list_refs = 0;\n-\t\tfor (i = 0; i < rs->nr; i++) {\n+\t\tfor (int i = 0; i < rs->nr; i++) {\n \t\t\tif (!rs->items[i].exact_sha1) {\n \t\t\t\tmust_list_refs = 1;\n \t\t\t\tbreak;\n@@ -1615,8 +1601,7 @@ static int do_fetch(struct transport *transport,\n \t\t\t\t\t     &transport_ls_refs_options.ref_prefixes);\n \t\tif (branch_has_merge_config(branch) &&\n \t\t    !strcmp(branch->remote_name, transport->remote->name)) {\n-\t\t\tint i;\n-\t\t\tfor (i = 0; i < branch->merge_nr; i++) {\n+\t\t\tfor (int i = 0; i < branch->merge_nr; i++) {\n \t\t\t\tstrvec_push(&transport_ls_refs_options.ref_prefixes,\n \t\t\t\t\t    branch->merge[i]->src);\n \t\t\t}\n@@ -1725,7 +1710,6 @@ static int do_fetch(struct transport *transport,\n \n \tif (set_upstream) {\n \t\tstruct branch *branch = branch_get(\"HEAD\");\n-\t\tstruct ref *rm;\n \t\tstruct ref *source_ref = NULL;\n \n \t\t/*\n@@ -1738,7 +1722,7 @@ static int do_fetch(struct transport *transport,\n \t\t * request ambiguous and err on the safe side by doing\n \t\t * nothing and just emit a warning.\n \t\t */\n-\t\tfor (rm = ref_map; rm; rm = rm->next) {\n+\t\tfor (struct ref *rm = ref_map; rm; rm = rm->next) {\n \t\t\tif (!rm->peer_ref) {\n \t\t\t\tif (source_ref) {\n \t\t\t\t\twarning(_(\"multiple branches detected, incompatible with --set-upstream\"));\n@@ -2049,7 +2033,6 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,\n \t\t     const struct fetch_config *config)\n {\n \tstruct refspec rs = REFSPEC_INIT_FETCH;\n-\tint i;\n \tint exit_code;\n \tint maybe_prune_tags;\n \tint remote_via_config = remote_is_configured(remote, 0);\n@@ -2087,7 +2070,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,\n \tif (maybe_prune_tags && (argc || !remote_via_config))\n \t\trefspec_append(&rs, TAG_REFSPEC);\n \n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tif (!strcmp(argv[i], \"tag\")) {\n \t\t\ti++;\n \t\t\tif (i >= argc)\ndiff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c\nindex 28186b30f5..4fc94e2b2c 100644\n--- a/builtin/for-each-repo.c\n+++ b/builtin/for-each-repo.c\n@@ -14,14 +14,13 @@ static const char * const for_each_repo_usage[] = {\n \n static int run_command_on_repo(const char *path, int argc, const char ** argv)\n {\n-\tint i;\n \tstruct child_process child = CHILD_PROCESS_INIT;\n \tchar *abspath = interpolate_path(path, 0);\n \n \tchild.git_cmd = 1;\n \tstrvec_pushl(&child.args, \"-C\", abspath, NULL);\n \n-\tfor (i = 0; i < argc; i++)\n+\tfor (int i = 0; i < argc; i++)\n \t\tstrvec_push(&child.args, argv[i]);\n \n \tfree(abspath);\n@@ -32,7 +31,7 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv)\n int cmd_for_each_repo(int argc, const char **argv, const char *prefix)\n {\n \tstatic const char *config_key = NULL;\n-\tint i, result = 0;\n+\tint result = 0;\n \tconst struct string_list *values;\n \tint err;\n \n@@ -55,7 +54,7 @@ int cmd_for_each_repo(int argc, const char **argv, const char *prefix)\n \telse if (err)\n \t\treturn 0;\n \n-\tfor (i = 0; !result && i < values->nr; i++)\n+\tfor (int i = 0; !result && i < values->nr; i++)\n \t\tresult = run_command_on_repo(values->items[i].string, argc, argv);\n \n \treturn result;\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex a7cf94f67e..52084409d6 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -366,7 +366,7 @@ static void check_object(struct object *obj)\n \n static void check_connectivity(void)\n {\n-\tint i, max;\n+\tint max;\n \n \t/* Traverse the pending reachable objects */\n \ttraverse_reachable();\n@@ -396,7 +396,7 @@ static void check_connectivity(void)\n \tif (verbose)\n \t\tfprintf_ln(stderr, _(\"Checking connectivity (%d objects)\"), max);\n \n-\tfor (i = 0; i < max; i++) {\n+\tfor (int i = 0; i < max; i++) {\n \t\tstruct object *obj = get_indexed_object(i);\n \n \t\tif (obj)\n@@ -561,14 +561,14 @@ static int fsck_head_link(const char *head_ref_name,\n \n static void get_default_heads(void)\n {\n-\tstruct worktree **worktrees, **p;\n+\tstruct worktree **worktrees;\n \tconst char *head_points_at;\n \tstruct object_id head_oid;\n \n \tfor_each_rawref(fsck_handle_ref, NULL);\n \n \tworktrees = get_worktrees();\n-\tfor (p = worktrees; *p; p++) {\n+\tfor (struct worktree **p = worktrees; *p; p++) {\n \t\tstruct worktree *wt = *p;\n \t\tstruct strbuf ref = STRBUF_INIT;\n \n@@ -742,7 +742,6 @@ static int fsck_head_link(const char *head_ref_name,\n \n static int fsck_cache_tree(struct cache_tree *it, const char *index_path)\n {\n-\tint i;\n \tint err = 0;\n \n \tif (verbose)\n@@ -762,7 +761,7 @@ static int fsck_cache_tree(struct cache_tree *it, const char *index_path)\n \t\tif (obj->type != OBJ_TREE)\n \t\t\terr |= objerror(obj, _(\"non-tree in cache-tree\"));\n \t}\n-\tfor (i = 0; i < it->subtree_nr; i++)\n+\tfor (int i = 0; i < it->subtree_nr; i++)\n \t\terr |= fsck_cache_tree(it->down[i]->cache_tree, index_path);\n \treturn err;\n }\n@@ -809,11 +808,9 @@ static int fsck_resolve_undo(struct index_state *istate,\n static void fsck_index(struct index_state *istate, const char *index_path,\n \t\t       int is_current_worktree)\n {\n-\tunsigned int i;\n-\n \t/* TODO: audit for interaction with sparse-index. */\n \tensure_full_index(istate);\n-\tfor (i = 0; i < istate->cache_nr; i++) {\n+\tfor (unsigned int i = 0; i < istate->cache_nr; i++) {\n \t\tunsigned int mode;\n \t\tstruct blob *blob;\n \t\tstruct object *obj;\n@@ -921,7 +918,6 @@ static struct option fsck_opts[] = {\n \n int cmd_fsck(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tstruct object_directory *odb;\n \n \t/* fsck knows how to handle missing promisor objects */\n@@ -994,7 +990,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \t\t\terrors_found |= ERROR_OBJECT;\n \t}\n \n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \t\tstruct object_id oid;\n \t\tif (!repo_get_oid(the_repository, arg, &oid)) {\n@@ -1030,13 +1026,13 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (keep_cache_objects) {\n-\t\tstruct worktree **worktrees, **p;\n+\t\tstruct worktree **worktrees;\n \n \t\tverify_index_checksum = 1;\n \t\tverify_ce_order = 1;\n \n \t\tworktrees = get_worktrees();\n-\t\tfor (p = worktrees; *p; p++) {\n+\t\tfor (struct worktree **p = worktrees; *p; p++) {\n \t\t\tstruct worktree *wt = *p;\n \t\t\tstruct index_state istate =\n \t\t\t\tINDEX_STATE_INIT(the_repository);\ndiff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c\nindex 1593713f4c..054e79dd03 100644\n--- a/builtin/fsmonitor--daemon.c\n+++ b/builtin/fsmonitor--daemon.c\n@@ -227,12 +227,9 @@ static enum fsmonitor_cookie_item_result with_lock__wait_for_cookie(\n static void with_lock__mark_cookies_seen(struct fsmonitor_daemon_state *state,\n \t\t\t\t\t const struct string_list *cookie_names)\n {\n-\t/* assert current thread holding state->main_lock */\n-\n-\tint k;\n \tint nr_seen = 0;\n \n-\tfor (k = 0; k < cookie_names->nr; k++) {\n+\tfor (int k = 0; k < cookie_names->nr; k++) {\n \t\tstruct fsmonitor_cookie_item key;\n \t\tstruct fsmonitor_cookie_item *cookie;\n \n@@ -468,13 +465,11 @@ void fsmonitor_batch__add_path(struct fsmonitor_batch *batch,\n static void fsmonitor_batch__combine(struct fsmonitor_batch *batch_dest,\n \t\t\t\t     const struct fsmonitor_batch *batch_src)\n {\n-\tsize_t k;\n-\n \tALLOC_GROW(batch_dest->interned_paths,\n \t\t   batch_dest->nr + batch_src->nr + 1,\n \t\t   batch_dest->alloc);\n \n-\tfor (k = 0; k < batch_src->nr; k++)\n+\tfor (size_t k = 0; k < batch_src->nr; k++)\n \t\tbatch_dest->interned_paths[batch_dest->nr++] =\n \t\t\tbatch_src->interned_paths[k];\n }\n@@ -512,9 +507,6 @@ static struct fsmonitor_batch *with_lock__truncate_old_batches(\n \tstruct fsmonitor_daemon_state *state,\n \tconst struct fsmonitor_batch *batch_marker)\n {\n-\t/* assert current thread holding state->main_lock */\n-\n-\tconst struct fsmonitor_batch *batch;\n \tstruct fsmonitor_batch *remainder;\n \n \tif (!batch_marker)\n@@ -524,7 +516,7 @@ static struct fsmonitor_batch *with_lock__truncate_old_batches(\n \t\t\t batch_marker->batch_seq_nr,\n \t\t\t (uint64_t)batch_marker->pinned_time);\n \n-\tfor (batch = batch_marker; batch; batch = batch->next) {\n+\tfor (const struct fsmonitor_batch *batch = batch_marker; batch; batch = batch->next) {\n \t\ttime_t t;\n \n \t\tif (!batch->pinned_time) /* an overflow batch */\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex cb80ced6cb..1151f59d76 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -80,8 +80,7 @@ static struct string_list pack_garbage = STRING_LIST_INIT_DUP;\n \n static void clean_pack_garbage(void)\n {\n-\tint i;\n-\tfor (i = 0; i < pack_garbage.nr; i++)\n+\tfor (int i = 0; i < pack_garbage.nr; i++)\n \t\tunlink_or_warn(pack_garbage.items[i].string);\n \tstring_list_clear(&pack_garbage, 0);\n }\n@@ -226,9 +225,9 @@ static int too_many_loose_objects(void)\n static struct packed_git *find_base_packs(struct string_list *packs,\n \t\t\t\t\t  unsigned long limit)\n {\n-\tstruct packed_git *p, *base = NULL;\n+\tstruct packed_git *base = NULL;\n \n-\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\tfor (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {\n \t\tif (!p->pack_local || p->is_cruft)\n \t\t\tcontinue;\n \t\tif (limit) {\n@@ -1100,7 +1099,6 @@ static int maintenance_task_loose_objects(struct maintenance_run_opts *opts)\n \n static int incremental_repack_auto_condition(void)\n {\n-\tstruct packed_git *p;\n \tint incremental_repack_auto_limit = 10;\n \tint count = 0;\n \n@@ -1116,9 +1114,7 @@ static int incremental_repack_auto_condition(void)\n \tif (incremental_repack_auto_limit < 0)\n \t\treturn 1;\n \n-\tfor (p = get_packed_git(the_repository);\n-\t     count < incremental_repack_auto_limit && p;\n-\t     p = p->next) {\n+\tfor (struct packed_git *p = get_packed_git(the_repository); count < incremental_repack_auto_limit && p; p = p->next) {\n \t\tif (!p->multi_pack_index)\n \t\t\tcount++;\n \t}\n@@ -1177,11 +1173,10 @@ static off_t get_auto_pack_size(void)\n \toff_t max_size = 0;\n \toff_t second_largest_size = 0;\n \toff_t result_size;\n-\tstruct packed_git *p;\n \tstruct repository *r = the_repository;\n \n \treprepare_packed_git(r);\n-\tfor (p = get_all_packs(r); p; p = p->next) {\n+\tfor (struct packed_git *p = get_all_packs(r); p; p = p->next) {\n \t\tif (p->pack_size > max_size) {\n \t\t\tsecond_largest_size = max_size;\n \t\t\tmax_size = p->pack_size;\n@@ -1389,14 +1384,13 @@ static void initialize_maintenance_strategy(void)\n \n static void initialize_task_config(int schedule)\n {\n-\tint i;\n \tstruct strbuf config_name = STRBUF_INIT;\n \tgc_config();\n \n \tif (schedule)\n \t\tinitialize_maintenance_strategy();\n \n-\tfor (i = 0; i < TASK__COUNT; i++) {\n+\tfor (int i = 0; i < TASK__COUNT; i++) {\n \t\tint config_value;\n \t\tchar *config_str;\n \n@@ -1423,12 +1417,12 @@ static void initialize_task_config(int schedule)\n static int task_option_parse(const struct option *opt UNUSED,\n \t\t\t     const char *arg, int unset)\n {\n-\tint i, num_selected = 0;\n+\tint num_selected = 0;\n \tstruct maintenance_task *task = NULL;\n \n \tBUG_ON_OPT_NEG(unset);\n \n-\tfor (i = 0; i < TASK__COUNT; i++) {\n+\tfor (int i = 0; i < TASK__COUNT; i++) {\n \t\tif (tasks[i].selected_order >= 0)\n \t\t\tnum_selected++;\n \t\tif (!strcasecmp(tasks[i].name, arg)) {\n@@ -1453,7 +1447,6 @@ static int task_option_parse(const struct option *opt UNUSED,\n \n static int maintenance_run(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tstruct maintenance_run_opts opts;\n \tstruct option builtin_maintenance_run_options[] = {\n \t\tOPT_BOOL(0, \"auto\", &opts.auto_flag,\n@@ -1472,7 +1465,7 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)\n \n \topts.quiet = !isatty(2);\n \n-\tfor (i = 0; i < TASK__COUNT; i++)\n+\tfor (int i = 0; i < TASK__COUNT; i++)\n \t\ttasks[i].selected_order = -1;\n \n \targc = parse_options(argc, argv, prefix,\n@@ -2691,7 +2684,6 @@ static void validate_scheduler(enum scheduler scheduler)\n static int update_background_schedule(const struct maintenance_start_opts *opts,\n \t\t\t\t      int enable)\n {\n-\tunsigned int i;\n \tint result = 0;\n \tstruct lock_file lk;\n \tchar *lock_path = xstrfmt(\"%s/schedule\", the_repository->objects->odb->path);\n@@ -2701,7 +2693,7 @@ static int update_background_schedule(const struct maintenance_start_opts *opts,\n \t\treturn error(_(\"another process is scheduling background maintenance\"));\n \t}\n \n-\tfor (i = 1; i < ARRAY_SIZE(scheduler_fn); i++) {\n+\tfor (unsigned int i = 1; i < ARRAY_SIZE(scheduler_fn); i++) {\n \t\tif (enable && opts->scheduler == i)\n \t\t\tcontinue;\n \t\tif (!scheduler_fn[i].is_available())\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 982bcfc4b1..ebb61eec1b 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -179,9 +179,7 @@ static void work_done(struct work_item *w)\n \n static void free_repos(void)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < repos_to_free_nr; i++) {\n+\tfor (int i = 0; i < repos_to_free_nr; i++) {\n \t\trepo_clear(repos_to_free[i]);\n \t\tfree(repos_to_free[i]);\n \t}\n@@ -250,7 +248,6 @@ static void start_threads(struct grep_opt *opt)\n static int wait_all(void)\n {\n \tint hit = 0;\n-\tint i;\n \n \tif (!HAVE_THREADS)\n \t\tBUG(\"Never call this function unless you have started threads\");\n@@ -268,7 +265,7 @@ static int wait_all(void)\n \tpthread_cond_broadcast(&cond_add);\n \tgrep_unlock();\n \n-\tfor (i = 0; i < num_threads; i++) {\n+\tfor (int i = 0; i < num_threads; i++) {\n \t\tvoid *h;\n \t\tpthread_join(threads[i], &h);\n \t\thit |= (int) (intptr_t) h;\n@@ -418,9 +415,9 @@ static void run_pager(struct grep_opt *opt, const char *prefix)\n {\n \tstruct string_list *path_list = opt->output_priv;\n \tstruct child_process child = CHILD_PROCESS_INIT;\n-\tint i, status;\n+\tint status;\n \n-\tfor (i = 0; i < path_list->nr; i++)\n+\tfor (int i = 0; i < path_list->nr; i++)\n \t\tstrvec_push(&child.args, path_list->items[i].string);\n \tchild.dir = prefix;\n \tchild.use_shell = 1;\n@@ -544,7 +541,6 @@ static int grep_cache(struct grep_opt *opt,\n {\n \tstruct repository *repo = opt->repo;\n \tint hit = 0;\n-\tint nr;\n \tstruct strbuf name = STRBUF_INIT;\n \tint name_base_len = 0;\n \tif (repo->submodule_prefix) {\n@@ -555,7 +551,7 @@ static int grep_cache(struct grep_opt *opt,\n \tif (repo_read_index(repo) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n-\tfor (nr = 0; nr < repo->index->cache_nr; nr++) {\n+\tfor (int nr = 0; nr < repo->index->cache_nr; nr++) {\n \t\tconst struct cache_entry *ce = repo->index->cache[nr];\n \n \t\tif (!cached && ce_skip_worktree(ce))\n@@ -726,11 +722,10 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tconst struct object_array *list)\n {\n-\tunsigned int i;\n \tint hit = 0;\n \tconst unsigned int nr = list->nr;\n \n-\tfor (i = 0; i < nr; i++) {\n+\tfor (unsigned int i = 0; i < nr; i++) {\n \t\tstruct object *real_obj;\n \n \t\tobj_read_lock();\n@@ -770,7 +765,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\t  int exc_std, int use_index)\n {\n \tstruct dir_struct dir = DIR_INIT;\n-\tint i, hit = 0;\n+\tint hit = 0;\n \n \tif (!use_index)\n \t\tdir.flags |= DIR_NO_GITLINKS;\n@@ -778,7 +773,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\tsetup_standard_excludes(&dir);\n \n \tfill_directory(&dir, opt->repo->index, pathspec);\n-\tfor (i = 0; i < dir.nr; i++) {\n+\tfor (int i = 0; i < dir.nr; i++) {\n \t\thit |= grep_file(opt, dir.entries[i]->name);\n \t\tif (hit && opt->status_only)\n \t\t\tbreak;\n@@ -1148,8 +1143,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t * \"do what I mean\" case, we verify and complain when that isn't true.\n \t */\n \tif (!seen_dashdash) {\n-\t\tint j;\n-\t\tfor (j = i; j < argc; j++)\n+\t\tfor (int j = i; j < argc; j++)\n \t\t\tverify_filename(prefix, argv[j], j == i && allow_revs);\n \t}\n \ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex 82ca6d2bfd..5cefac6ef8 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -112,7 +112,6 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING( 0 , \"path\", &vpath, N_(\"file\"), N_(\"process file as it were from this path\")),\n \t\tOPT_END()\n \t};\n-\tint i;\n \tconst char *errstr = NULL;\n \n \targc = parse_options(argc, argv, prefix, hash_object_options,\n@@ -153,7 +152,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)\n \tif (hashstdin)\n \t\thash_fd(0, type, vpath, flags, literally);\n \n-\tfor (i = 0 ; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \t\tchar *to_free = NULL;\n \ndiff --git a/builtin/help.c b/builtin/help.c\nindex dc1fbe2b98..cea3415a17 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -122,14 +122,11 @@ static void list_config_help(enum show_config_type type)\n \t\t{ \"receive.fsck\", \"<msg-id>\", list_config_fsck_msg_ids },\n \t\t{ NULL, NULL, NULL }\n \t};\n-\tconst char **p;\n \tstruct slot_expansion *e;\n \tstruct string_list keys = STRING_LIST_INIT_DUP;\n \tstruct string_list keys_uniq = STRING_LIST_INIT_DUP;\n \tstruct string_list_item *item;\n-\tint i;\n-\n-\tfor (p = config_name_list; *p; p++) {\n+\tfor (const char **p = config_name_list; *p; p++) {\n \t\tconst char *var = *p;\n \t\tstruct strbuf sb = STRBUF_INIT;\n \n@@ -154,7 +151,7 @@ static void list_config_help(enum show_config_type type)\n \t\t\t    e->prefix, e->placeholder);\n \n \tstring_list_sort(&keys);\n-\tfor (i = 0; i < keys.nr; i++) {\n+\tfor (int i = 0; i < keys.nr; i++) {\n \t\tconst char *var = keys.items[i].string;\n \t\tconst char *wildcard, *tag, *cut;\n \t\tconst char *dot = NULL;\n@@ -216,9 +213,7 @@ static enum help_format parse_help_format(const char *format)\n \n static const char *get_man_viewer_info(const char *name)\n {\n-\tstruct man_viewer_info_list *viewer;\n-\n-\tfor (viewer = man_viewer_info_list; viewer; viewer = viewer->next)\n+\tfor (struct man_viewer_info_list *viewer = man_viewer_info_list; viewer; viewer = viewer->next)\n \t{\n \t\tif (!strcasecmp(name, viewer->name))\n \t\t\treturn viewer->info;\n@@ -489,11 +484,10 @@ static void exec_viewer(const char *name, const char *page)\n \n static void show_man_page(const char *page)\n {\n-\tstruct man_viewer_list *viewer;\n \tconst char *fallback = getenv(\"GIT_MAN_VIEWER\");\n \n \tsetup_man_path();\n-\tfor (viewer = man_viewer_list; viewer; viewer = viewer->next)\n+\tfor (struct man_viewer_list *viewer = man_viewer_list; viewer; viewer = viewer->next)\n \t{\n \t\texec_viewer(viewer->name, page); /* will return when unable */\n \t}\ndiff --git a/builtin/hook.c b/builtin/hook.c\nindex 5234693a94..9015f47532 100644\n--- a/builtin/hook.c\n+++ b/builtin/hook.c\n@@ -20,7 +20,6 @@ static const char * const builtin_hook_run_usage[] = {\n \n static int run(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tstruct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;\n \tint ignore_missing = 0;\n \tconst char *hook_name;\n@@ -49,7 +48,7 @@ static int run(int argc, const char **argv, const char *prefix)\n \t\tgoto usage;\n \n \t/* Add our arguments, start after -- */\n-\tfor (i = 2 ; i < argc; i++)\n+\tfor (int i = 2; i < argc; i++)\n \t\tstrvec_push(&opt.args, argv[i]);\n \n \t/* Need to take into account core.hooksPath */\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex a3a37bd215..f3489b51e7 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -186,7 +186,6 @@ static inline void unlock_mutex(pthread_mutex_t *mutex)\n  */\n static void init_thread(void)\n {\n-\tint i;\n \tinit_recursive_mutex(&read_mutex);\n \tpthread_mutex_init(&counter_mutex, NULL);\n \tpthread_mutex_init(&work_mutex, NULL);\n@@ -194,7 +193,7 @@ static void init_thread(void)\n \t\tpthread_mutex_init(&deepest_delta_mutex, NULL);\n \tpthread_key_create(&key, NULL);\n \tCALLOC_ARRAY(thread_data, nr_threads);\n-\tfor (i = 0; i < nr_threads; i++) {\n+\tfor (int i = 0; i < nr_threads; i++) {\n \t\tthread_data[i].pack_fd = xopen(curr_pack, O_RDONLY);\n \t}\n \n@@ -203,7 +202,6 @@ static void init_thread(void)\n \n static void cleanup_thread(void)\n {\n-\tint i;\n \tif (!threads_active)\n \t\treturn;\n \tthreads_active = 0;\n@@ -212,7 +210,7 @@ static void cleanup_thread(void)\n \tpthread_mutex_destroy(&work_mutex);\n \tif (show_stat)\n \t\tpthread_mutex_destroy(&deepest_delta_mutex);\n-\tfor (i = 0; i < nr_threads; i++)\n+\tfor (int i = 0; i < nr_threads; i++)\n \t\tclose(thread_data[i].pack_fd);\n \tpthread_key_delete(key);\n \tfree(thread_data);\n@@ -261,14 +259,14 @@ static unsigned check_object(struct object *obj)\n \n static unsigned check_objects(void)\n {\n-\tunsigned i, max, foreign_nr = 0;\n+\tunsigned max, foreign_nr = 0;\n \n \tmax = get_max_object_index();\n \n \tif (verbose)\n \t\tprogress = start_delayed_progress(_(\"Checking objects\"), max);\n \n-\tfor (i = 0; i < max; i++) {\n+\tfor (unsigned i = 0; i < max; i++) {\n \t\tforeign_nr += check_object(get_indexed_object(i));\n \t\tdisplay_progress(progress, i + 1);\n \t}\n@@ -1627,7 +1625,6 @@ static void read_v2_anomalous_offsets(struct packed_git *p,\n \t\t\t\t      struct pack_idx_option *opts)\n {\n \tconst uint32_t *idx1, *idx2;\n-\tuint32_t i;\n \n \t/* The address of the 4-byte offset table */\n \tidx1 = (((const uint32_t *)((const uint8_t *)p->index_data + p->crc_offset))\n@@ -1637,7 +1634,7 @@ static void read_v2_anomalous_offsets(struct packed_git *p,\n \t/* The address of the 8-byte offset table */\n \tidx2 = idx1 + p->num_objects;\n \n-\tfor (i = 0; i < p->num_objects; i++) {\n+\tfor (uint32_t i = 0; i < p->num_objects; i++) {\n \t\tuint32_t off = ntohl(idx1[i]);\n \t\tif (!(off & 0x80000000))\n \t\t\tcontinue;\ndiff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c\nindex 033bd1556c..cd6f32bbd5 100644\n--- a/builtin/interpret-trailers.c\n+++ b/builtin/interpret-trailers.c\n@@ -130,8 +130,7 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)\n \t\t\toptions);\n \n \tif (argc) {\n-\t\tint i;\n-\t\tfor (i = 0; i < argc; i++)\n+\t\tfor (int i = 0; i < argc; i++)\n \t\t\tprocess_trailers(argv[i], &opts, &trailers);\n \t} else {\n \t\tif (opts.in_place)\ndiff --git a/builtin/log.c b/builtin/log.c\nindex db1808d7c1..eb3d9f7623 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -190,7 +190,6 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n static void set_default_decoration_filter(struct decoration_filter *decoration_filter)\n {\n-\tint i;\n \tchar *value = NULL;\n \tstruct string_list *include = decoration_filter->include_ref_pattern;\n \tconst struct string_list *config_exclude;\n@@ -224,7 +223,7 @@ static void set_default_decoration_filter(struct decoration_filter *decoration_f\n \t * No command-line or config options were given, so\n \t * populate with sensible defaults.\n \t */\n-\tfor (i = 0; i < ARRAY_SIZE(ref_namespace); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(ref_namespace); i++) {\n \t\tif (!ref_namespace[i].decoration)\n \t\t\tcontinue;\n \n@@ -734,7 +733,6 @@ static void show_setup_revisions_tweak(struct rev_info *rev)\n int cmd_show(int argc, const char **argv, const char *prefix)\n {\n \tstruct rev_info rev;\n-\tunsigned int i;\n \tstruct setup_revision_opt opt;\n \tstruct pathspec match_all;\n \tint ret = 0;\n@@ -765,7 +763,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\treturn cmd_log_deinit(cmd_log_walk(&rev), &rev);\n \n \trev.diffopt.no_free = 1;\n-\tfor (i = 0; i < rev.pending.nr && !ret; i++) {\n+\tfor (unsigned int i = 0; i < rev.pending.nr && !ret; i++) {\n \t\tstruct object *o = rev.pending.objects[i].item;\n \t\tconst char *name = rev.pending.objects[i].name;\n \t\tswitch (o->type) {\n@@ -1211,13 +1209,13 @@ static void print_signature(FILE *file)\n \n static char *find_branch_name(struct rev_info *rev)\n {\n-\tint i, positive = -1;\n+\tint positive = -1;\n \tstruct object_id branch_oid;\n \tconst struct object_id *tip_oid;\n \tconst char *ref, *v;\n \tchar *full_ref, *branch = NULL;\n \n-\tfor (i = 0; i < rev->cmdline.nr; i++) {\n+\tfor (int i = 0; i < rev->cmdline.nr; i++) {\n \t\tif (rev->cmdline.rev[i].flags & UNINTERESTING)\n \t\t\tcontinue;\n \t\tif (positive < 0)\n@@ -1760,7 +1758,6 @@ static void prepare_bases(struct base_tree_info *bases,\n \tstruct rev_info revs;\n \tstruct diff_options diffopt;\n \tstruct commit_base commit_base;\n-\tint i;\n \n \tif (!base)\n \t\treturn;\n@@ -1775,7 +1772,7 @@ static void prepare_bases(struct base_tree_info *bases,\n \trepo_init_revisions(the_repository, &revs, NULL);\n \trevs.max_parents = 1;\n \trevs.topo_order = 1;\n-\tfor (i = 0; i < total; i++) {\n+\tfor (int i = 0; i < total; i++) {\n \t\tlist[i]->object.flags &= ~UNINTERESTING;\n \t\tadd_pending_object(&revs, &list[i]->object, \"rev_list\");\n \t\t*commit_base_at(&commit_base, list[i]) = 1;\n@@ -1806,8 +1803,6 @@ static void prepare_bases(struct base_tree_info *bases,\n \n static void print_bases(struct base_tree_info *bases, FILE *file)\n {\n-\tint i;\n-\n \t/* Only do this once, either for the cover or for the first one */\n \tif (is_null_oid(&bases->base_commit))\n \t\treturn;\n@@ -1816,7 +1811,7 @@ static void print_bases(struct base_tree_info *bases, FILE *file)\n \tfprintf(file, \"\\nbase-commit: %s\\n\", oid_to_hex(&bases->base_commit));\n \n \t/* Show the prerequisite patches */\n-\tfor (i = bases->nr_patch_id - 1; i >= 0; i--)\n+\tfor (int i = bases->nr_patch_id - 1; i >= 0; i--)\n \t\tfprintf(file, \"prerequisite-patch-id: %s\\n\", oid_to_hex(&bases->patch_id[i]));\n \n \tfree(bases->patch_id);\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex 92f94e65bf..e8ceb86599 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -163,9 +163,7 @@ static void show_dir_entry(struct index_state *istate,\n static void show_other_files(struct index_state *istate,\n \t\t\t     const struct dir_struct *dir)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < dir->nr; i++) {\n+\tfor (int i = 0; i < dir->nr; i++) {\n \t\tstruct dir_entry *ent = dir->entries[i];\n \t\tif (!index_name_is_other(istate, ent->name, ent->len))\n \t\t\tcontinue;\n@@ -176,8 +174,7 @@ static void show_other_files(struct index_state *istate,\n static void show_killed_files(struct index_state *istate,\n \t\t\t      const struct dir_struct *dir)\n {\n-\tint i;\n-\tfor (i = 0; i < dir->nr; i++) {\n+\tfor (int i = 0; i < dir->nr; i++) {\n \t\tstruct dir_entry *ent = dir->entries[i];\n \t\tchar *cp, *sp;\n \t\tint pos, len, killed = 0;\n@@ -400,7 +397,6 @@ static void construct_fullname(struct strbuf *out, const struct repository *repo\n \n static void show_files(struct repository *repo, struct dir_struct *dir)\n {\n-\tint i;\n \tstruct strbuf fullname = STRBUF_INIT;\n \n \t/* For cached/deleted files we don't need to even do the readdir */\n@@ -420,7 +416,7 @@ static void show_files(struct repository *repo, struct dir_struct *dir)\n \tif (!show_sparse_dirs)\n \t\tensure_full_index(repo->index);\n \n-\tfor (i = 0; i < repo->index->cache_nr; i++) {\n+\tfor (int i = 0; i < repo->index->cache_nr; i++) {\n \t\tconst struct cache_entry *ce = repo->index->cache[i];\n \t\tstruct stat st;\n \t\tint stat_err;\n@@ -571,7 +567,7 @@ static int option_parse_exclude_standard(const struct option *opt,\n \n int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)\n {\n-\tint require_work_tree = 0, show_tag = 0, i;\n+\tint require_work_tree = 0, show_tag = 0;\n \tchar *max_prefix;\n \tstruct dir_struct dir = DIR_INIT;\n \tstruct pattern_list *pl;\n@@ -663,7 +659,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)\n \targc = parse_options(argc, argv, prefix, builtin_ls_files_options,\n \t\t\tls_files_usage, 0);\n \tpl = add_pattern_list(&dir, EXC_CMDL, \"--exclude option\");\n-\tfor (i = 0; i < exclude_list.nr; i++) {\n+\tfor (int i = 0; i < exclude_list.nr; i++) {\n \t\tadd_pattern(exclude_list.items[i].string, \"\", 0, pl, --exclude_args);\n \t}\n \ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex e4a891337c..24d21dbad6 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -55,15 +55,13 @@ struct ls_tree_options {\n static int show_recursive(struct ls_tree_options *options, const char *base,\n \t\t\t  size_t baselen, const char *pathname)\n {\n-\tint i;\n-\n \tif (options->ls_options & LS_RECURSIVE)\n \t\treturn 1;\n \n \tif (!options->pathspec.nr)\n \t\treturn 0;\n \n-\tfor (i = 0; i < options->pathspec.nr; i++) {\n+\tfor (int i = 0; i < options->pathspec.nr; i++) {\n \t\tconst char *spec = options->pathspec.items[i].match;\n \t\tsize_t len, speclen;\n \n@@ -341,7 +339,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_id oid;\n \tstruct tree *tree;\n-\tint i, full_tree = 0;\n+\tint full_tree = 0;\n \tint full_name = !prefix || !*prefix;\n \tread_tree_fn_t fn = NULL;\n \tenum ls_tree_cmdmode cmdmode = MODE_DEFAULT;\n@@ -419,7 +417,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n \t\t       ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),\n \t\t       PATHSPEC_PREFER_CWD,\n \t\t       prefix, argv + 1);\n-\tfor (i = 0; i < options.pathspec.nr; i++)\n+\tfor (int i = 0; i < options.pathspec.nr; i++)\n \t\toptions.pathspec.items[i].nowildcard_len = options.pathspec.items[i].len;\n \toptions.pathspec.has_wildcard = 0;\n \ttree = parse_tree_indirect(&oid);\ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 3af9ddb8ae..ccb52fbc4b 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -114,10 +114,9 @@ static int populate_maildir_list(struct string_list *list, const char *path)\n \tstruct dirent *dent;\n \tchar *name = NULL;\n \tchar *subs[] = { \"cur\", \"new\", NULL };\n-\tchar **sub;\n \tint ret = -1;\n \n-\tfor (sub = subs; *sub; ++sub) {\n+\tfor (char **sub = subs; *sub; ++sub) {\n \t\tfree(name);\n \t\tname = xstrfmt(\"%s/%s\", path, *sub);\n \t\tif (!(dir = opendir(name))) {\n@@ -172,7 +171,6 @@ static int split_maildir(const char *maildir, const char *dir,\n \tchar *file = NULL;\n \tFILE *f = NULL;\n \tint ret = -1;\n-\tint i;\n \tstruct string_list list = STRING_LIST_INIT_DUP;\n \n \tlist.cmp = maildir_filename_cmp;\n@@ -180,7 +178,7 @@ static int split_maildir(const char *maildir, const char *dir,\n \tif (populate_maildir_list(&list, maildir) < 0)\n \t\tgoto out;\n \n-\tfor (i = 0; i < list.nr; i++) {\n+\tfor (int i = 0; i < list.nr; i++) {\n \t\tchar *name;\n \n \t\tfree(file);\ndiff --git a/builtin/merge-base.c b/builtin/merge-base.c\nindex d26e8fbf6f..2c66380e3b 100644\n--- a/builtin/merge-base.c\n+++ b/builtin/merge-base.c\n@@ -10,7 +10,7 @@\n \n static int show_merge_base(struct commit **rev, int rev_nr, int show_all)\n {\n-\tstruct commit_list *result, *r;\n+\tstruct commit_list *result;\n \n \tresult = repo_get_merge_bases_many_dirty(the_repository, rev[0],\n \t\t\t\t\t\t rev_nr - 1, rev + 1);\n@@ -18,7 +18,7 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)\n \tif (!result)\n \t\treturn 1;\n \n-\tfor (r = result; r; r = r->next) {\n+\tfor (struct commit_list *r = result; r; r = r->next) {\n \t\tprintf(\"%s\\n\", oid_to_hex(&r->item->object.oid));\n \t\tif (!show_all)\n \t\t\tbreak;\n@@ -53,10 +53,8 @@ static struct commit *get_commit_reference(const char *arg)\n \n static int handle_independent(int count, const char **args)\n {\n-\tstruct commit_list *revs = NULL, *rev;\n-\tint i;\n-\n-\tfor (i = count - 1; i >= 0; i--)\n+\tstruct commit_list *revs = NULL;\n+\tfor (int i = count - 1; i >= 0; i--)\n \t\tcommit_list_insert(get_commit_reference(args[i]), &revs);\n \n \treduce_heads_replace(&revs);\n@@ -64,7 +62,7 @@ static int handle_independent(int count, const char **args)\n \tif (!revs)\n \t\treturn 1;\n \n-\tfor (rev = revs; rev; rev = rev->next)\n+\tfor (struct commit_list *rev = revs; rev; rev = rev->next)\n \t\tprintf(\"%s\\n\", oid_to_hex(&rev->item->object.oid));\n \n \tfree_commit_list(revs);\n@@ -74,10 +72,8 @@ static int handle_independent(int count, const char **args)\n static int handle_octopus(int count, const char **args, int show_all)\n {\n \tstruct commit_list *revs = NULL;\n-\tstruct commit_list *result, *rev;\n-\tint i;\n-\n-\tfor (i = count - 1; i >= 0; i--)\n+\tstruct commit_list *result;\n+\tfor (int i = count - 1; i >= 0; i--)\n \t\tcommit_list_insert(get_commit_reference(args[i]), &revs);\n \n \tresult = get_octopus_merge_bases(revs);\n@@ -87,7 +83,7 @@ static int handle_octopus(int count, const char **args, int show_all)\n \tif (!result)\n \t\treturn 1;\n \n-\tfor (rev = result; rev; rev = rev->next) {\n+\tfor (struct commit_list *rev = result; rev; rev = rev->next) {\n \t\tprintf(\"%s\\n\", oid_to_hex(&rev->item->object.oid));\n \t\tif (!show_all)\n \t\t\tbreak;\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex 270d5f644a..39a0535d56 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -63,10 +63,9 @@ static void merge_one_path(const char *path)\n \n static void merge_all(void)\n {\n-\tint i;\n \t/* TODO: audit for interaction with sparse-index. */\n \tensure_full_index(&the_index);\n-\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\tfor (int i = 0; i < the_index.cache_nr; i++) {\n \t\tconst struct cache_entry *ce = the_index.cache[i];\n \t\tif (!ce_stage(ce))\n \t\t\tcontinue;\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex cbd8e15af6..72e0844ad1 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -109,8 +109,7 @@ static void *origin(struct merge_list *entry, unsigned long *size)\n \n static int show_outf(void *priv UNUSED, mmbuffer_t *mb, int nbuf)\n {\n-\tint i;\n-\tfor (i = 0; i < nbuf; i++)\n+\tfor (int i = 0; i < nbuf; i++)\n \t\tprintf(\"%.*s\", (int) mb[i].size, mb[i].ptr);\n \treturn 0;\n }\n@@ -267,10 +266,9 @@ static struct merge_list *link_entry(unsigned stage, const struct traverse_info\n static void unresolved(const struct traverse_info *info, struct name_entry n[3])\n {\n \tstruct merge_list *entry = NULL;\n-\tint i;\n \tunsigned dirmask = 0, mask = 0;\n \n-\tfor (i = 0; i < 3; i++) {\n+\tfor (int i = 0; i < 3; i++) {\n \t\tmask |= (1 << i);\n \t\t/*\n \t\t * Treat missing entries as directories so that we return\n@@ -490,10 +488,9 @@ static int real_merge(struct merge_tree_options *o,\n \tif (!result.clean) {\n \t\tstruct string_list conflicted_files = STRING_LIST_INIT_NODUP;\n \t\tconst char *last = NULL;\n-\t\tint i;\n \n \t\tmerge_get_conflicted_files(&result, &conflicted_files);\n-\t\tfor (i = 0; i < conflicted_files.nr; i++) {\n+\t\tfor (int i = 0; i < conflicted_files.nr; i++) {\n \t\t\tconst char *name = conflicted_files.items[i].string;\n \t\t\tstruct stage_info *c = conflicted_files.items[i].util;\n \t\t\tif (!o->name_only)\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 935c8a57dd..df0650348d 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -393,7 +393,6 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead\n {\n \tstruct rev_info rev;\n \tstruct strbuf out = STRBUF_INIT;\n-\tstruct commit_list *j;\n \tstruct pretty_print_context ctx = {0};\n \n \tprintf(_(\"Squash commit -- not updating HEAD\\n\"));\n@@ -405,7 +404,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead\n \tcommit->object.flags |= UNINTERESTING;\n \tadd_pending_object(&rev, &commit->object, NULL);\n \n-\tfor (j = remoteheads; j; j = j->next)\n+\tfor (struct commit_list *j = remoteheads; j; j = j->next)\n \t\tadd_pending_object(&rev, &j->item->object, NULL);\n \n \tsetup_revisions(0, NULL, &rev, NULL);\n@@ -650,7 +649,7 @@ static int git_merge_config(const char *k, const char *v,\n static int read_tree_trivial(struct object_id *common, struct object_id *head,\n \t\t\t     struct object_id *one)\n {\n-\tint i, nr_trees = 0;\n+\tint nr_trees = 0;\n \tstruct tree *trees[MAX_UNPACK_TREES];\n \tstruct tree_desc t[MAX_UNPACK_TREES];\n \tstruct unpack_trees_options opts;\n@@ -675,7 +674,7 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head,\n \t\treturn -1;\n \topts.fn = threeway_merge;\n \tcache_tree_free(&the_index.cache_tree);\n-\tfor (i = 0; i < nr_trees; i++) {\n+\tfor (int i = 0; i < nr_trees; i++) {\n \t\tparse_tree(trees[i]);\n \t\tinit_tree_desc(t+i, trees[i]->buffer, trees[i]->size);\n \t}\n@@ -704,11 +703,10 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,\n \tif (!strcmp(strategy, \"recursive\") || !strcmp(strategy, \"subtree\") ||\n \t    !strcmp(strategy, \"ort\")) {\n \t\tstruct lock_file lock = LOCK_INIT;\n-\t\tint clean, x;\n+\t\tint clean;\n \t\tstruct commit *result;\n \t\tstruct commit_list *reversed = NULL;\n \t\tstruct merge_options o;\n-\t\tstruct commit_list *j;\n \n \t\tif (remoteheads->next) {\n \t\t\terror(_(\"Not handling anything other than two heads merge.\"));\n@@ -722,14 +720,14 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,\n \t\to.show_rename_progress =\n \t\t\tshow_progress == -1 ? isatty(2) : show_progress;\n \n-\t\tfor (x = 0; x < xopts.nr; x++)\n+\t\tfor (int x = 0; x < xopts.nr; x++)\n \t\t\tif (parse_merge_opt(&o, xopts.v[x]))\n \t\t\t\tdie(_(\"unknown strategy option: -X%s\"), xopts.v[x]);\n \n \t\to.branch1 = head_arg;\n \t\to.branch2 = merge_remote_util(remoteheads->item)->name;\n \n-\t\tfor (j = common; j; j = j->next)\n+\t\tfor (struct commit_list *j = common; j; j = j->next)\n \t\t\tcommit_list_insert(j->item, &reversed);\n \n \t\trepo_hold_locked_index(the_repository, &lock,\n@@ -765,9 +763,9 @@ static void count_diff_files(struct diff_queue_struct *q,\n \n static int count_unmerged_entries(void)\n {\n-\tint i, ret = 0;\n+\tint ret = 0;\n \n-\tfor (i = 0; i < the_index.cache_nr; i++)\n+\tfor (int i = 0; i < the_index.cache_nr; i++)\n \t\tif (ce_stage(the_index.cache[i]))\n \t\t\tret++;\n \n@@ -776,8 +774,6 @@ static int count_unmerged_entries(void)\n \n static void add_strategies(const char *string, unsigned attr)\n {\n-\tint i;\n-\n \tif (string) {\n \t\tstruct string_list list = STRING_LIST_INIT_DUP;\n \t\tstruct string_list_item *item;\n@@ -787,7 +783,7 @@ static void add_strategies(const char *string, unsigned attr)\n \t\tstring_list_clear(&list, 0);\n \t\treturn;\n \t}\n-\tfor (i = 0; i < ARRAY_SIZE(all_strategy); i++)\n+\tfor (int i = 0; i < ARRAY_SIZE(all_strategy); i++)\n \t\tif (all_strategy[i].attr & attr)\n \t\t\tappend_strategy(&all_strategy[i]);\n \n@@ -1022,10 +1018,9 @@ static int setup_with_upstream(const char ***argv)\n \n static void write_merge_heads(struct commit_list *remoteheads)\n {\n-\tstruct commit_list *j;\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tfor (j = remoteheads; j; j = j->next) {\n+\tfor (struct commit_list *j = remoteheads; j; j = j->next) {\n \t\tstruct object_id *oid;\n \t\tstruct commit *c = j->item;\n \t\tstruct merge_remote_desc *desc;\n@@ -1130,7 +1125,7 @@ static void prepare_merge_message(struct strbuf *merge_names, struct strbuf *mer\n static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge_names)\n {\n \tconst char *filename;\n-\tint fd, pos, npos;\n+\tint fd, npos;\n \tstruct strbuf fetch_head_file = STRBUF_INIT;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n@@ -1145,7 +1140,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge\n \tif (close(fd) < 0)\n \t\tdie_errno(_(\"could not close '%s'\"), filename);\n \n-\tfor (pos = 0; pos < merge_names->len; pos = npos) {\n+\tfor (int pos = 0; pos < merge_names->len; pos = npos) {\n \t\tstruct object_id oid;\n \t\tchar *ptr;\n \t\tstruct commit *commit;\n@@ -1209,8 +1204,7 @@ static struct commit_list *collect_parents(struct commit *head_commit,\n \t\t}\n \t\tremoteheads = reduce_parents(head_commit, head_subsumed, remoteheads);\n \t\tif (autogen) {\n-\t\t\tstruct commit_list *p;\n-\t\t\tfor (p = remoteheads; p; p = p->next)\n+\t\t\tfor (struct commit_list *p = remoteheads; p; p = p->next)\n \t\t\t\tmerge_name(merge_remote_util(p->item)->name, autogen);\n \t\t}\n \t}\n@@ -1623,9 +1617,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \t\t * to date.\n \t\t */\n \t\tint up_to_date = 1;\n-\t\tstruct commit_list *j;\n-\n-\t\tfor (j = remoteheads; j; j = j->next) {\n+\t\tfor (struct commit_list *j = remoteheads; j; j = j->next) {\n \t\t\tstruct commit_list *common_one;\n \t\t\tstruct commit *common_item;\n \ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 2dd1807c4e..3689e898f8 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -417,14 +417,12 @@ static int name_ref(const char *path, const struct object_id *oid,\n \n static void name_tips(void)\n {\n-\tint i;\n-\n \t/*\n \t * Try to set better names first, so that worse ones spread\n \t * less.\n \t */\n \tQSORT(tip_table.table, tip_table.nr, cmp_by_tag_and_age);\n-\tfor (i = 0; i < tip_table.nr; i++) {\n+\tfor (int i = 0; i < tip_table.nr; i++) {\n \t\tstruct tip_table_entry *e = &tip_table.table[i];\n \t\tif (e->commit) {\n \t\t\tname_rev(e->commit, e->refname, e->taggerdate,\n@@ -659,10 +657,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tstrbuf_release(&sb);\n \t} else if (all) {\n-\t\tint i, max;\n+\t\tint max;\n \n \t\tmax = get_max_object_index();\n-\t\tfor (i = 0; i < max; i++) {\n+\t\tfor (int i = 0; i < max; i++) {\n \t\t\tstruct object *obj = get_indexed_object(i);\n \t\t\tif (!obj || obj->type != OBJ_COMMIT)\n \t\t\t\tcontinue;\n@@ -670,8 +668,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\t\t  always, allow_undefined, data.name_only);\n \t\t}\n \t} else {\n-\t\tint i;\n-\t\tfor (i = 0; i < revs.nr; i++)\n+\t\tfor (int i = 0; i < revs.nr; i++)\n \t\t\tshow_name(revs.objects[i].item, revs.objects[i].name,\n \t\t\t\t  always, allow_undefined, data.name_only);\n \t}\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex caf20fd5bd..75c57e745c 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -254,9 +254,7 @@ static void append_separator(struct strbuf *message)\n static void concat_messages(struct note_data *d)\n {\n \tstruct strbuf msg = STRBUF_INIT;\n-\tsize_t i;\n-\n-\tfor (i = 0; i < d->msg_nr ; i++) {\n+\tfor (size_t i = 0; i < d->msg_nr; i++) {\n \t\tif (d->buf.len)\n \t\t\tappend_separator(&d->buf);\n \t\tstrbuf_add(&msg, d->messages[i]->buf.buf, d->messages[i]->buf.len);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 329aeac804..3e3150198b 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1549,7 +1549,6 @@ static int want_object_in_pack(const struct object_id *oid,\n {\n \tint want;\n \tstruct list_head *pos;\n-\tstruct multi_pack_index *m;\n \n \tif (!exclude && local && has_loose_object_nonlocal(oid))\n \t\treturn 0;\n@@ -1568,7 +1567,7 @@ static int want_object_in_pack(const struct object_id *oid,\n \t\t*found_offset = 0;\n \t}\n \n-\tfor (m = get_multi_pack_index(the_repository); m; m = m->next) {\n+\tfor (struct multi_pack_index *m = get_multi_pack_index(the_repository); m; m = m->next) {\n \t\tstruct pack_entry e;\n \t\tif (fill_midx_entry(the_repository, oid, &e, m)) {\n \t\t\twant = want_object_in_pack_one(e.p, oid, exclude, found_pack, found_offset);\n@@ -1718,7 +1717,6 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \tvoid *data;\n \tunsigned long size;\n \tenum object_type type;\n-\tint neigh;\n \tint my_ix = pbase_tree_cache_ix(oid);\n \tint available_ix = -1;\n \n@@ -1726,7 +1724,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)\n \t * your object will be found at your index or within a few\n \t * slots after that slot if it is cached.\n \t */\n-\tfor (neigh = 0; neigh < 8; neigh++) {\n+\tfor (int neigh = 0; neigh < 8; neigh++) {\n \t\tent = pbase_tree_cache[my_ix];\n \t\tif (ent && oideq(&ent->oid, oid)) {\n \t\t\tent->ref++;\n@@ -1872,7 +1870,6 @@ static int check_pbase_path(unsigned hash)\n \n static void add_preferred_base_object(const char *name)\n {\n-\tstruct pbase_tree *it;\n \tsize_t cmplen;\n \tunsigned hash = pack_name_hash(name);\n \n@@ -1880,7 +1877,7 @@ static void add_preferred_base_object(const char *name)\n \t\treturn;\n \n \tcmplen = name_cmp_len(name);\n-\tfor (it = pbase_tree; it; it = it->next) {\n+\tfor (struct pbase_tree *it = pbase_tree; it; it = it->next) {\n \t\tif (cmplen == 0) {\n \t\t\tadd_object_entry(&it->pcache.oid, OBJ_TREE, NULL, 1);\n \t\t}\n@@ -1926,7 +1923,6 @@ static void add_preferred_base(struct object_id *oid)\n static void cleanup_preferred_base(void)\n {\n \tstruct pbase_tree *it;\n-\tunsigned i;\n \n \tit = pbase_tree;\n \tpbase_tree = NULL;\n@@ -1937,7 +1933,7 @@ static void cleanup_preferred_base(void)\n \t\tfree(tmp);\n \t}\n \n-\tfor (i = 0; i < ARRAY_SIZE(pbase_tree_cache); i++) {\n+\tfor (unsigned i = 0; i < ARRAY_SIZE(pbase_tree_cache); i++) {\n \t\tif (!pbase_tree_cache[i])\n \t\t\tcontinue;\n \t\tfree(pbase_tree_cache[i]->tree_data);\n@@ -1996,9 +1992,7 @@ static int can_reuse_delta(const struct object_id *base_oid,\n \n static void prefetch_to_pack(uint32_t object_index_start) {\n \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n-\tuint32_t i;\n-\n-\tfor (i = object_index_start; i < to_pack.nr_objects; i++) {\n+\tfor (uint32_t i = object_index_start; i < to_pack.nr_objects; i++) {\n \t\tstruct object_entry *entry = to_pack.objects + i;\n \n \t\tif (!oid_object_info_extended(the_repository,\n@@ -2727,7 +2721,7 @@ static unsigned long free_unpacked(struct unpacked *n)\n static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\t\tint window, int depth, unsigned *processed)\n {\n-\tuint32_t i, idx = 0, count = 0;\n+\tuint32_t idx = 0, count = 0;\n \tstruct unpacked *array;\n \tunsigned long mem_usage = 0;\n \n@@ -2859,7 +2853,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\t\tidx = 0;\n \t}\n \n-\tfor (i = 0; i < window; ++i) {\n+\tfor (uint32_t i = 0; i < window; ++i) {\n \t\tfree_delta_index(array[i].index);\n \t\tfree(array[i].data);\n \t}\n@@ -3130,7 +3124,7 @@ static int add_ref_tag(const char *tag UNUSED, const struct object_id *oid,\n static void prepare_pack(int window, int depth)\n {\n \tstruct object_entry **delta_list;\n-\tuint32_t i, nr_deltas;\n+\tuint32_t nr_deltas;\n \tunsigned n;\n \n \tif (use_delta_islands)\n@@ -3154,7 +3148,7 @@ static void prepare_pack(int window, int depth)\n \tALLOC_ARRAY(delta_list, to_pack.nr_objects);\n \tnr_deltas = n = 0;\n \n-\tfor (i = 0; i < to_pack.nr_objects; i++) {\n+\tfor (uint32_t i = 0; i < to_pack.nr_objects; i++) {\n \t\tstruct object_entry *entry = to_pack.objects + i;\n \n \t\tif (DELTA(entry))\n@@ -3630,7 +3624,6 @@ static void enumerate_cruft_objects(void)\n \n static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs)\n {\n-\tstruct packed_git *p;\n \tstruct rev_info revs;\n \tint ret;\n \n@@ -3658,7 +3651,7 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs\n \t * Re-mark only the fresh packs as kept so that objects in\n \t * unknown packs do not halt the reachability traversal early.\n \t */\n-\tfor (p = get_all_packs(the_repository); p; p = p->next)\n+\tfor (struct packed_git *p = get_all_packs(the_repository); p; p = p->next)\n \t\tp->pack_keep_in_core = 0;\n \tmark_pack_kept_in_core(fresh_packs, 1);\n \n@@ -3677,7 +3670,6 @@ static void read_cruft_objects(void)\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct string_list discard_packs = STRING_LIST_INIT_DUP;\n \tstruct string_list fresh_packs = STRING_LIST_INIT_DUP;\n-\tstruct packed_git *p;\n \n \tignore_packed_keep_in_core = 1;\n \n@@ -3694,7 +3686,7 @@ static void read_cruft_objects(void)\n \tstring_list_sort(&discard_packs);\n \tstring_list_sort(&fresh_packs);\n \n-\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\tfor (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {\n \t\tconst char *pack_name = pack_basename(p);\n \t\tstruct string_list_item *item;\n \n@@ -3781,13 +3773,12 @@ static void show_object(struct object *obj, const char *name,\n \tadd_object_entry(&obj->oid, obj->type, name, 0);\n \n \tif (use_delta_islands) {\n-\t\tconst char *p;\n \t\tunsigned depth;\n \t\tstruct object_entry *ent;\n \n \t\t/* the empty string is a root tree, which is depth 0 */\n \t\tdepth = *name ? 1 : 0;\n-\t\tfor (p = strchr(name, '/'); p; p = strchr(p + 1, '/'))\n+\t\tfor (const char *p = strchr(name, '/'); p; p = strchr(p + 1, '/'))\n \t\t\tdepth++;\n \n \t\tent = packlist_find(&to_pack, &obj->oid);\n@@ -3981,12 +3972,11 @@ static int loosened_object_can_be_discarded(const struct object_id *oid,\n \n static void loosen_unused_packed_objects(void)\n {\n-\tstruct packed_git *p;\n \tuint32_t i;\n \tuint32_t loosened_objects_nr = 0;\n \tstruct object_id oid;\n \n-\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\tfor (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {\n \t\tif (!p->pack_local || p->pack_keep || p->pack_keep_in_core)\n \t\t\tcontinue;\n \n@@ -4183,12 +4173,10 @@ static void get_object_list(struct rev_info *revs, int ac, const char **av)\n \n static void add_extra_kept_packs(const struct string_list *names)\n {\n-\tstruct packed_git *p;\n-\n \tif (!names->nr)\n \t\treturn;\n \n-\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\tfor (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {\n \t\tconst char *name = basename(p->pack_name);\n \t\tint i;\n \n@@ -4545,14 +4533,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\tif (!p) /* no keep-able packs found */\n \t\t\tignore_packed_keep_on_disk = 0;\n \t}\n-\tif (local) {\n-\t\t/*\n-\t\t * unlike ignore_packed_keep_on_disk above, we do not\n-\t\t * want to unset \"local\" based on looking at packs, as\n-\t\t * it also covers non-local objects\n-\t\t */\n-\t\tstruct packed_git *p;\n-\t\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\tif (local) {for (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {\n \t\t\tif (!p->pack_local) {\n \t\t\t\thave_non_local_packs = 1;\n \t\t\t\tbreak;\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 4c735ba069..0891a05692 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -368,7 +368,6 @@ static int cmp_remaining_objects(const void *a, const void *b)\n static void sort_pack_list(struct pack_list **pl)\n {\n \tstruct pack_list **ary, *p;\n-\tint i;\n \tsize_t n = pack_list_size(*pl);\n \n \tif (n < 2)\n@@ -382,7 +381,7 @@ static void sort_pack_list(struct pack_list **pl)\n \tQSORT(ary, n, cmp_remaining_objects);\n \n \t/* link them back again */\n-\tfor (i = 0; i < n - 1; i++)\n+\tfor (int i = 0; i < n - 1; i++)\n \t\tary[i]->next = ary[i + 1];\n \tary[n - 1]->next = NULL;\n \t*pl = ary[0];\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 73a68b75b0..ff5c73ed1f 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -283,10 +283,9 @@ static void argv_push_force(struct strvec *arr)\n  */\n static void set_reflog_message(int argc, const char **argv)\n {\n-\tint i;\n \tstruct strbuf msg = STRBUF_INIT;\n \n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tif (i)\n \t\t\tstrbuf_addch(&msg, ' ');\n \t\tstrbuf_addstr(&msg, argv[i]);\n@@ -937,11 +936,10 @@ static int get_can_ff(struct object_id *orig_head,\n static int already_up_to_date(struct object_id *orig_head,\n \t\t\t      struct oid_array *merge_heads)\n {\n-\tint i;\n \tstruct commit *ours;\n \n \tours = lookup_commit_reference(the_repository, orig_head);\n-\tfor (i = 0; i < merge_heads->nr; i++) {\n+\tfor (int i = 0; i < merge_heads->nr; i++) {\n \t\tstruct commit_list *list = NULL;\n \t\tstruct commit *theirs;\n \t\tint ok;\ndiff --git a/builtin/push.c b/builtin/push.c\nindex 2fbb31c3ad..2d4e7e329c 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -100,9 +100,7 @@ static void set_refspecs(const char **refs, int nr, const char *repo)\n {\n \tstruct remote *remote = NULL;\n \tstruct ref *local_refs = NULL;\n-\tint i;\n-\n-\tfor (i = 0; i < nr; i++) {\n+\tfor (int i = 0; i < nr; i++) {\n \t\tconst char *ref = refs[i];\n \t\tif (!strcmp(\"tag\", ref)) {\n \t\t\tif (nr <= ++i)\ndiff --git a/builtin/range-diff.c b/builtin/range-diff.c\nindex f02cbac087..b75283f2f5 100644\n--- a/builtin/range-diff.c\n+++ b/builtin/range-diff.c\n@@ -39,7 +39,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \tstruct option *options;\n-\tint i, dash_dash = -1, res = 0;\n+\tint dash_dash = -1, res = 0;\n \tstruct strbuf range1 = STRBUF_INIT, range2 = STRBUF_INIT;\n \tstruct object_id oid;\n \tconst char *three_dots = NULL;\n@@ -58,7 +58,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)\n \tif (!simple_color)\n \t\tdiffopt.use_color = 1;\n \n-\tfor (i = 0; i < argc; i++)\n+\tfor (int i = 0; i < argc; i++)\n \t\tif (!strcmp(argv[i], \"--\")) {\n \t\t\tdash_dash = i;\n \t\t\tbreak;\ndiff --git a/builtin/read-tree.c b/builtin/read-tree.c\nindex 20e7db1973..196e87c0cd 100644\n--- a/builtin/read-tree.c\n+++ b/builtin/read-tree.c\n@@ -88,11 +88,9 @@ static void debug_stage(const char *label, const struct cache_entry *ce,\n static int debug_merge(const struct cache_entry * const *stages,\n \t\t       struct unpack_trees_options *o)\n {\n-\tint i;\n-\n \tprintf(\"* %d-way merge\\n\", o->internal.merge_size);\n \tdebug_stage(\"index\", stages[0], o);\n-\tfor (i = 1; i <= o->internal.merge_size; i++) {\n+\tfor (int i = 1; i <= o->internal.merge_size; i++) {\n \t\tchar buf[24];\n \t\txsnprintf(buf, sizeof(buf), \"ent#%d\", i);\n \t\tdebug_stage(buf, stages[i], o);\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex db65607485..da1ee58688 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -413,12 +413,10 @@ static void proc_receive_ref_append(const char *prefix)\n \n static int proc_receive_ref_matches(struct command *cmd)\n {\n-\tstruct proc_receive_ref *p;\n-\n \tif (!proc_receive_ref)\n \t\treturn 0;\n \n-\tfor (p = proc_receive_ref; p; p = p->next) {\n+\tfor (struct proc_receive_ref *p = proc_receive_ref; p; p = p->next) {\n \t\tconst char *match = p->ref_prefix;\n \t\tconst char *remains;\n \n@@ -547,7 +545,6 @@ static void hmac_hash(unsigned char *out,\n \tunsigned char key[GIT_MAX_BLKSZ];\n \tunsigned char k_ipad[GIT_MAX_BLKSZ];\n \tunsigned char k_opad[GIT_MAX_BLKSZ];\n-\tint i;\n \tgit_hash_ctx ctx;\n \n \t/* RFC 2104 2. (1) */\n@@ -561,7 +558,7 @@ static void hmac_hash(unsigned char *out,\n \t}\n \n \t/* RFC 2104 2. (2) & (5) */\n-\tfor (i = 0; i < sizeof(key); i++) {\n+\tfor (int i = 0; i < sizeof(key); i++) {\n \t\tk_ipad[i] = key[i] ^ 0x36;\n \t\tk_opad[i] = key[i] ^ 0x5c;\n \t}\n@@ -600,9 +597,7 @@ static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)\n static int constant_memequal(const char *a, const char *b, size_t n)\n {\n \tint res = 0;\n-\tsize_t i;\n-\n-\tfor (i = 0; i < n; i++)\n+\tfor (size_t i = 0; i < n; i++)\n \t\tres |= a[i] ^ b[i];\n \treturn res;\n }\n@@ -803,8 +798,7 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,\n \tproc.trace2_hook_name = hook_name;\n \n \tif (feed_state->push_options) {\n-\t\tsize_t i;\n-\t\tfor (i = 0; i < feed_state->push_options->nr; i++)\n+\t\tfor (size_t i = 0; i < feed_state->push_options->nr; i++)\n \t\t\tstrvec_pushf(&proc.env,\n \t\t\t\t     \"GIT_PUSH_OPTION_%\"PRIuMAX\"=%s\",\n \t\t\t\t     (uintmax_t)i,\n@@ -958,7 +952,6 @@ static int read_proc_receive_report(struct packet_reader *reader,\n \t\t\t\t    struct command *commands,\n \t\t\t\t    struct strbuf *errmsg)\n {\n-\tstruct command *cmd;\n \tstruct command *hint = NULL;\n \tstruct ref_push_report *report = NULL;\n \tint new_report = 0;\n@@ -1077,7 +1070,7 @@ static int read_proc_receive_report(struct packet_reader *reader,\n \t\tnew_report = 1;\n \t}\n \n-\tfor (cmd = commands; cmd; cmd = cmd->next)\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next)\n \t\tif (cmd->run_proc_receive && !cmd->error_string &&\n \t\t    !(cmd->run_proc_receive & RUN_PROC_RECEIVE_RETURNED)) {\n \t\t    cmd->error_string = \"proc-receive failed to report status\";\n@@ -1608,7 +1601,6 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \n static void run_update_post_hook(struct command *commands)\n {\n-\tstruct command *cmd;\n \tstruct child_process proc = CHILD_PROCESS_INIT;\n \tconst char *hook;\n \n@@ -1616,7 +1608,7 @@ static void run_update_post_hook(struct command *commands)\n \tif (!hook)\n \t\treturn;\n \n-\tfor (cmd = commands; cmd; cmd = cmd->next) {\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next) {\n \t\tif (cmd->error_string || cmd->did_not_exist)\n \t\t\tcontinue;\n \t\tif (!proc.args.nr)\n@@ -1728,9 +1720,7 @@ static const struct object_id *command_singleton_iterator(void *cb_data)\n static void set_connectivity_errors(struct command *commands,\n \t\t\t\t    struct shallow_info *si)\n {\n-\tstruct command *cmd;\n-\n-\tfor (cmd = commands; cmd; cmd = cmd->next) {\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next) {\n \t\tstruct command *singleton = cmd;\n \t\tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n \n@@ -1774,12 +1764,11 @@ static void reject_updates_to_hidden(struct command *commands)\n {\n \tstruct strbuf refname_full = STRBUF_INIT;\n \tsize_t prefix_len;\n-\tstruct command *cmd;\n \n \tstrbuf_addstr(&refname_full, get_git_namespace());\n \tprefix_len = refname_full.len;\n \n-\tfor (cmd = commands; cmd; cmd = cmd->next) {\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next) {\n \t\tif (cmd->error_string)\n \t\t\tcontinue;\n \n@@ -1805,9 +1794,7 @@ static int should_process_cmd(struct command *cmd)\n static void BUG_if_skipped_connectivity_check(struct command *commands,\n \t\t\t\t\t       struct shallow_info *si)\n {\n-\tstruct command *cmd;\n-\n-\tfor (cmd = commands; cmd; cmd = cmd->next) {\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next) {\n \t\tif (should_process_cmd(cmd) && si->shallow_ref[cmd->index])\n \t\t\tbug(\"connectivity check has not been run on ref %s\",\n \t\t\t    cmd->ref_name);\n@@ -1818,10 +1805,9 @@ static void BUG_if_skipped_connectivity_check(struct command *commands,\n static void execute_commands_non_atomic(struct command *commands,\n \t\t\t\t\tstruct shallow_info *si)\n {\n-\tstruct command *cmd;\n \tstruct strbuf err = STRBUF_INIT;\n \n-\tfor (cmd = commands; cmd; cmd = cmd->next) {\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next) {\n \t\tif (!should_process_cmd(cmd) || cmd->run_proc_receive)\n \t\t\tcontinue;\n \n@@ -2392,12 +2378,11 @@ static void update_shallow_info(struct command *commands,\n \n static void report(struct command *commands, const char *unpack_status)\n {\n-\tstruct command *cmd;\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tpacket_buf_write(&buf, \"unpack %s\\n\",\n \t\t\t unpack_status ? unpack_status : \"ok\");\n-\tfor (cmd = commands; cmd; cmd = cmd->next) {\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next) {\n \t\tif (!cmd->error_string)\n \t\t\tpacket_buf_write(&buf, \"ok %s\\n\",\n \t\t\t\t\t cmd->ref_name);\n@@ -2416,13 +2401,12 @@ static void report(struct command *commands, const char *unpack_status)\n \n static void report_v2(struct command *commands, const char *unpack_status)\n {\n-\tstruct command *cmd;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct ref_push_report *report;\n \n \tpacket_buf_write(&buf, \"unpack %s\\n\",\n \t\t\t unpack_status ? unpack_status : \"ok\");\n-\tfor (cmd = commands; cmd; cmd = cmd->next) {\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next) {\n \t\tint count = 0;\n \n \t\tif (cmd->error_string) {\n@@ -2461,8 +2445,7 @@ static void report_v2(struct command *commands, const char *unpack_status)\n \n static int delete_only(struct command *commands)\n {\n-\tstruct command *cmd;\n-\tfor (cmd = commands; cmd; cmd = cmd->next) {\n+\tfor (struct command *cmd = commands; cmd; cmd = cmd->next) {\n \t\tif (!is_null_oid(&cmd->new_oid))\n \t\t\treturn 0;\n \t}\n@@ -2551,8 +2534,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)\n \t\tif (use_push_options)\n \t\t\tread_push_options(&reader, &push_options);\n \t\tif (!check_cert_push_options(&push_options)) {\n-\t\t\tstruct command *cmd;\n-\t\t\tfor (cmd = commands; cmd; cmd = cmd->next)\n+\t\t\tfor (struct command *cmd = commands; cmd; cmd = cmd->next)\n \t\t\t\tcmd->error_string = \"inconsistent push options\";\n \t\t}\n \ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex 2c3369fca5..bee26f2998 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -160,12 +160,10 @@ static int reflog_expire_config(const char *var, const char *value,\n \n static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, const char *ref)\n {\n-\tstruct reflog_expire_cfg *ent;\n-\n \tif (cb->explicit_expiry == (EXPIRE_TOTAL|EXPIRE_UNREACH))\n \t\treturn; /* both given explicitly -- nothing to tweak */\n \n-\tfor (ent = reflog_expire_cfg; ent; ent = ent->next) {\n+\tfor (struct reflog_expire_cfg *ent = reflog_expire_cfg; ent; ent = ent->next) {\n \t\tif (!wildmatch(ent->pattern, ref, 0)) {\n \t\t\tif (!(cb->explicit_expiry & EXPIRE_TOTAL))\n \t\t\t\tcb->expire_total = ent->expire_total;\n@@ -242,7 +240,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n {\n \tstruct cmd_reflog_expire_cb cmd = { 0 };\n \ttimestamp_t now = time(NULL);\n-\tint i, status, do_all, single_worktree = 0;\n+\tint status, do_all, single_worktree = 0;\n \tunsigned int flags = 0;\n \tint verbose = 0;\n \treflog_expiry_should_prune_fn *should_prune_fn = should_expire_reflog_ent;\n@@ -313,10 +311,10 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \t\t\t.reflogs = STRING_LIST_INIT_DUP,\n \t\t};\n \t\tstruct string_list_item *item;\n-\t\tstruct worktree **worktrees, **p;\n+\t\tstruct worktree **worktrees;\n \n \t\tworktrees = get_worktrees();\n-\t\tfor (p = worktrees; *p; p++) {\n+\t\tfor (struct worktree **p = worktrees; *p; p++) {\n \t\t\tif (single_worktree && !(*p)->is_current)\n \t\t\t\tcontinue;\n \t\t\tcollected.worktree = *p;\n@@ -341,7 +339,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \t\tstring_list_clear(&collected.reflogs, 0);\n \t}\n \n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tchar *ref;\n \t\tstruct expire_reflog_policy_cb cb = { .cmd = cmd };\n \n@@ -362,7 +360,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n \n static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)\n {\n-\tint i, status = 0;\n+\tint status = 0;\n \tunsigned int flags = 0;\n \tint verbose = 0;\n \n@@ -384,7 +382,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)\n \tif (argc < 1)\n \t\treturn error(_(\"no reflog specified to delete\"));\n \n-\tfor (i = 0; i < argc; i++)\n+\tfor (int i = 0; i < argc; i++)\n \t\tstatus |= reflog_delete(argv[i], flags, verbose);\n \n \treturn status;\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex d91bbe728d..97a33ea644 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -366,9 +366,7 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat\n {\n \tstruct ref *fetch_map = NULL, **tail = &fetch_map;\n \tstruct ref *ref, *stale_refs;\n-\tint i;\n-\n-\tfor (i = 0; i < states->remote->fetch.nr; i++)\n+\tfor (int i = 0; i < states->remote->fetch.nr; i++)\n \t\tif (get_fetch_map(remote_refs, &states->remote->fetch.items[i], &tail, 1))\n \t\t\tdie(_(\"Could not get fetch map for refspec %s\"),\n \t\t\t\tstates->remote->fetch.raw[i]);\n@@ -415,7 +413,7 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \tstruct ref_states *states)\n {\n \tstruct remote *remote = states->remote;\n-\tstruct ref *ref, *local_refs, *push_map;\n+\tstruct ref *local_refs, *push_map;\n \tif (remote->mirror)\n \t\treturn 0;\n \n@@ -424,7 +422,7 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \n \tmatch_push_refs(local_refs, &push_map, &remote->push, MATCH_REFS_NONE);\n \n-\tfor (ref = push_map; ref; ref = ref->next) {\n+\tfor (struct ref *ref = push_map; ref; ref = ref->next) {\n \t\tstruct string_list_item *item;\n \t\tstruct push_info *info;\n \n@@ -458,7 +456,6 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \n static int get_push_ref_states_noquery(struct ref_states *states)\n {\n-\tint i;\n \tstruct remote *remote = states->remote;\n \tstruct string_list_item *item;\n \tstruct push_info *info;\n@@ -472,7 +469,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)\n \t\tinfo->status = PUSH_STATUS_NOTQUERIED;\n \t\tinfo->dest = xstrdup(item->string);\n \t}\n-\tfor (i = 0; i < remote->push.nr; i++) {\n+\tfor (int i = 0; i < remote->push.nr; i++) {\n \t\tconst struct refspec_item *spec = &remote->push.items[i];\n \t\tif (spec->matching)\n \t\t\titem = string_list_append(&states->push, _(\"(matching)\"));\n@@ -491,7 +488,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)\n \n static int get_head_names(const struct ref *remote_refs, struct ref_states *states)\n {\n-\tstruct ref *ref, *matches;\n+\tstruct ref *matches;\n \tstruct ref *fetch_map = NULL, **fetch_map_tail = &fetch_map;\n \tstruct refspec_item refspec;\n \n@@ -502,7 +499,7 @@ static int get_head_names(const struct ref *remote_refs, struct ref_states *stat\n \tget_fetch_map(remote_refs, &refspec, &fetch_map_tail, 0);\n \tmatches = guess_remote_head(find_ref_by_name(remote_refs, \"HEAD\"),\n \t\t\t\t    fetch_map, 1);\n-\tfor (ref = matches; ref; ref = ref->next)\n+\tfor (struct ref *ref = matches; ref; ref = ref->next)\n \t\tstring_list_append(&states->heads, abbrev_branch(ref->name));\n \n \tfree_refs(fetch_map);\n@@ -548,7 +545,6 @@ static int add_branch_for_removal(const char *refname,\n {\n \tstruct branches_for_remote *branches = cb_data;\n \tstruct refspec_item refspec;\n-\tstruct known_remote *kr;\n \n \tmemset(&refspec, 0, sizeof(refspec));\n \trefspec.dst = (char *)refname;\n@@ -556,7 +552,7 @@ static int add_branch_for_removal(const char *refname,\n \t\treturn 0;\n \n \t/* don't delete a branch if another remote also uses it */\n-\tfor (kr = branches->keep->list; kr; kr = kr->next) {\n+\tfor (struct known_remote *kr = branches->keep->list; kr; kr = kr->next) {\n \t\tmemset(&refspec, 0, sizeof(refspec));\n \t\trefspec.dst = (char *)refname;\n \t\tif (!remote_find_tracking(kr->remote, &refspec))\n@@ -1097,7 +1093,6 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)\n \tstruct branch_info *branch_info = item->util;\n \tstruct string_list *merge = &branch_info->merge;\n \tint width = show_info->width + 4;\n-\tint i;\n \n \tif (branch_info->rebase >= REBASE_TRUE && branch_info->merge.nr > 1) {\n \t\terror(_(\"invalid branch.%s.merge; cannot rebase onto > 1 branch\"),\n@@ -1123,7 +1118,7 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)\n \t} else {\n \t\tprintf_ln(_(\"merges with remote %s\"), merge->items[0].string);\n \t}\n-\tfor (i = 1; i < merge->nr; i++)\n+\tfor (int i = 1; i < merge->nr; i++)\n \t\tprintf(_(\"%-*s    and with remote %s\\n\"), width, \"\",\n \t\t       merge->items[i].string);\n \n@@ -1208,7 +1203,7 @@ static int get_one_entry(struct remote *remote, void *priv)\n \tstruct string_list *list = priv;\n \tstruct strbuf remote_info_buf = STRBUF_INIT;\n \tconst char **url;\n-\tint i, url_nr;\n+\tint url_nr;\n \n \tif (remote->url_nr > 0) {\n \t\tstruct strbuf promisor_config = STRBUF_INIT;\n@@ -1231,7 +1226,7 @@ static int get_one_entry(struct remote *remote, void *priv)\n \t\turl = remote->url;\n \t\turl_nr = remote->url_nr;\n \t}\n-\tfor (i = 0; i < url_nr; i++)\n+\tfor (int i = 0; i < url_nr; i++)\n \t{\n \t\tstrbuf_addf(&remote_info_buf, \"%s (push)\", url[i]);\n \t\tstring_list_append(list, remote->name)->util =\n@@ -1249,10 +1244,8 @@ static int show_all(void)\n \tresult = for_each_remote(get_one_entry, &list);\n \n \tif (!result) {\n-\t\tint i;\n-\n \t\tstring_list_sort(&list);\n-\t\tfor (i = 0; i < list.nr; i++) {\n+\t\tfor (int i = 0; i < list.nr; i++) {\n \t\t\tstruct string_list_item *item = list.items + i;\n \t\t\tif (verbose)\n \t\t\t\tprintf(\"%s\\t%s\\n\", item->string,\n@@ -1510,7 +1503,7 @@ static int get_remote_default(const char *key, const char *value UNUSED,\n \n static int update(int argc, const char **argv, const char *prefix)\n {\n-\tint i, prune = -1;\n+\tint prune = -1;\n \tstruct option options[] = {\n \t\tOPT_BOOL('p', \"prune\", &prune,\n \t\t\t N_(\"prune remotes after fetching\")),\n@@ -1532,7 +1525,7 @@ static int update(int argc, const char **argv, const char *prefix)\n \tstrvec_push(&cmd.args, \"--multiple\");\n \tif (argc < 2)\n \t\tstrvec_push(&cmd.args, \"default\");\n-\tfor (i = 1; i < argc; i++)\n+\tfor (int i = 1; i < argc; i++)\n \t\tstrvec_push(&cmd.args, argv[i]);\n \n \tif (strcmp(cmd.args.v[cmd.args.nr-1], \"default\") == 0) {\n@@ -1665,7 +1658,7 @@ static int get_url(int argc, const char **argv, const char *prefix)\n \n static int set_url(int argc, const char **argv, const char *prefix)\n {\n-\tint i, push_mode = 0, add_mode = 0, delete_mode = 0;\n+\tint push_mode = 0, add_mode = 0, delete_mode = 0;\n \tint matches = 0, negative_matches = 0;\n \tconst char *remotename = NULL;\n \tconst char *newurl = NULL;\n@@ -1732,7 +1725,7 @@ static int set_url(int argc, const char **argv, const char *prefix)\n \tif (regcomp(&old_regex, oldurl, REG_EXTENDED))\n \t\tdie(_(\"Invalid old URL pattern: %s\"), oldurl);\n \n-\tfor (i = 0; i < urlset_nr; i++)\n+\tfor (int i = 0; i < urlset_nr; i++)\n \t\tif (!regexec(&old_regex, urlset[i], 0, NULL, 0))\n \t\t\tmatches++;\n \t\telse\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex ede36328a3..197af23c55 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -235,10 +235,9 @@ static void existing_packs_release(struct existing_packs *existing)\n static void collect_pack_filenames(struct existing_packs *existing,\n \t\t\t\t   const struct string_list *extra_keep)\n {\n-\tstruct packed_git *p;\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\tfor (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {\n \t\tint i;\n \t\tconst char *base;\n \n@@ -340,9 +339,7 @@ static struct generated_pack_data *populate_pack_exts(const char *name)\n \tstruct stat statbuf;\n \tstruct strbuf path = STRBUF_INIT;\n \tstruct generated_pack_data *data = xcalloc(1, sizeof(*data));\n-\tint i;\n-\n-\tfor (i = 0; i < ARRAY_SIZE(exts); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(exts); i++) {\n \t\tstrbuf_reset(&path);\n \t\tstrbuf_addf(&path, \"%s-%s%s\", packtmp, name, exts[i].name);\n \n@@ -359,8 +356,7 @@ static struct generated_pack_data *populate_pack_exts(const char *name)\n static int has_pack_ext(const struct generated_pack_data *data,\n \t\t\tconst char *ext)\n {\n-\tint i;\n-\tfor (i = 0; i < ARRAY_SIZE(exts); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(exts); i++) {\n \t\tif (strcmp(exts[i].name, ext))\n \t\t\tcontinue;\n \t\treturn !!data->tempfiles[i];\n@@ -460,10 +456,9 @@ static void init_pack_geometry(struct pack_geometry *geometry,\n \t\t\t       struct existing_packs *existing,\n \t\t\t       const struct pack_objects_args *args)\n {\n-\tstruct packed_git *p;\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\tfor (struct packed_git *p = get_all_packs(the_repository); p; p = p->next) {\n \t\tif (args->local && !p->pack_local)\n \t\t\t/*\n \t\t\t * When asked to only repack local packfiles we skip\n@@ -592,8 +587,6 @@ static void split_pack_geometry(struct pack_geometry *geometry)\n \n static struct packed_git *get_preferred_pack(struct pack_geometry *geometry)\n {\n-\tuint32_t i;\n-\n \tif (!geometry) {\n \t\t/*\n \t\t * No geometry means either an all-into-one repack (in which\n@@ -614,7 +607,7 @@ static struct packed_git *get_preferred_pack(struct pack_geometry *geometry)\n \t * other words, it is the largest pack that does not get rolled up in\n \t * the geometric repack.\n \t */\n-\tfor (i = geometry->pack_nr; i > geometry->split; i--)\n+\tfor (uint32_t i = geometry->pack_nr; i > geometry->split; i--)\n \t\t/*\n \t\t * A pack that is not local would never be included in a\n \t\t * multi-pack index. We thus skip over any non-local packs.\n@@ -630,9 +623,7 @@ static void geometry_remove_redundant_packs(struct pack_geometry *geometry,\n \t\t\t\t\t    struct existing_packs *existing)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tuint32_t i;\n-\n-\tfor (i = 0; i < geometry->split; i++) {\n+\tfor (uint32_t i = 0; i < geometry->split; i++) {\n \t\tstruct packed_git *p = geometry->pack[i];\n \t\tif (string_list_has_string(names, hash_to_hex(p->hash)))\n \t\t\tcontinue;\n@@ -734,8 +725,7 @@ static void midx_included_packs(struct string_list *include,\n \t\tstring_list_insert(include, xstrfmt(\"pack-%s.idx\", item->string));\n \tif (geometry->split_factor) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tuint32_t i;\n-\t\tfor (i = geometry->split; i < geometry->pack_nr; i++) {\n+\t\tfor (uint32_t i = geometry->split; i < geometry->pack_nr; i++) {\n \t\t\tstruct packed_git *p = geometry->pack[i];\n \n \t\t\t/*\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex da59600ad2..79f2c1c337 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -109,7 +109,7 @@ typedef int (*each_replace_name_fn)(const char *name, const char *ref,\n \n static int for_each_replace_name(const char **argv, each_replace_name_fn fn)\n {\n-\tconst char **p, *full_hex;\n+\tconst char *full_hex;\n \tstruct strbuf ref = STRBUF_INIT;\n \tsize_t base_len;\n \tint had_error = 0;\n@@ -119,7 +119,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)\n \tstrbuf_addstr(&ref, git_replace_ref_base);\n \tbase_len = ref.len;\n \n-\tfor (p = argv; *p; p++) {\n+\tfor (const char **p = argv; *p; p++) {\n \t\tif (repo_get_oid(the_repository, *p, &oid)) {\n \t\t\terror(\"failed to resolve '%s' as a valid ref\", *p);\n \t\t\thad_error = 1;\n@@ -367,7 +367,6 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv)\n {\n \tstruct strbuf new_parents = STRBUF_INIT;\n \tconst char *parent_start, *parent_end;\n-\tint i;\n \tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \t/* find existing parents */\n@@ -379,7 +378,7 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv)\n \t\tparent_end += hexsz + 8; /* \"parent \" + \"hex sha1\" + \"\\n\" */\n \n \t/* prepare new parents */\n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tstruct object_id oid;\n \t\tstruct commit *commit;\n \n@@ -417,7 +416,6 @@ static int check_one_mergetag(struct commit *commit UNUSED,\n \tconst char *ref = mergetag_data->argv[0];\n \tstruct object_id tag_oid;\n \tstruct tag *tag;\n-\tint i;\n \n \thash_object_file(the_hash_algo, extra->value, extra->len,\n \t\t\t OBJ_TAG, &tag_oid);\n@@ -428,7 +426,7 @@ static int check_one_mergetag(struct commit *commit UNUSED,\n \t\treturn error(_(\"malformed mergetag in commit '%s'\"), ref);\n \n \t/* iterate over new parents */\n-\tfor (i = 1; i < mergetag_data->argc; i++) {\n+\tfor (int i = 1; i < mergetag_data->argc; i++) {\n \t\tstruct object_id oid;\n \t\tif (repo_get_oid(the_repository, mergetag_data->argv[i], &oid) < 0)\n \t\t\treturn error(_(\"not a valid object name: '%s'\"),\ndiff --git a/builtin/replay.c b/builtin/replay.c\nindex 6bc4b47f09..624636cc6e 100644\n--- a/builtin/replay.c\n+++ b/builtin/replay.c\n@@ -94,8 +94,6 @@ struct ref_info {\n static void get_ref_information(struct rev_cmdline_info *cmd_info,\n \t\t\t\tstruct ref_info *ref_info)\n {\n-\tint i;\n-\n \tref_info->onto = NULL;\n \tstrset_init(&ref_info->positive_refs);\n \tstrset_init(&ref_info->negative_refs);\n@@ -117,7 +115,7 @@ static void get_ref_information(struct rev_cmdline_info *cmd_info,\n \t * the second because they'd likely just be replaying commits on top\n \t * of the same commit and not making any difference.\n \t */\n-\tfor (i = 0; i < cmd_info->nr; i++) {\n+\tfor (int i = 0; i < cmd_info->nr; i++) {\n \t\tstruct rev_cmdline_entry *e = cmd_info->rev + i;\n \t\tstruct object_id oid;\n \t\tconst char *refexpr = e->name;\ndiff --git a/builtin/rerere.c b/builtin/rerere.c\nindex b2efc6f640..29cf9d17d2 100644\n--- a/builtin/rerere.c\n+++ b/builtin/rerere.c\n@@ -16,8 +16,7 @@ static const char * const rerere_usage[] = {\n \n static int outf(void *dummy UNUSED, mmbuffer_t *ptr, int nbuf)\n {\n-\tint i;\n-\tfor (i = 0; i < nbuf; i++)\n+\tfor (int i = 0; i < nbuf; i++)\n \t\tif (write_in_full(1, ptr[i].ptr, ptr[i].size) < 0)\n \t\t\treturn -1;\n \treturn 0;\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex f0bf29a478..b654c00511 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -58,7 +58,7 @@ static inline int is_merge(void)\n \n static int reset_index(const char *ref, const struct object_id *oid, int reset_type, int quiet)\n {\n-\tint i, nr = 0;\n+\tint nr = 0;\n \tstruct tree_desc desc[2];\n \tstruct tree *tree;\n \tstruct unpack_trees_options opts;\n@@ -122,7 +122,7 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t\n \tret = 0;\n \n out:\n-\tfor (i = 0; i < nr; i++)\n+\tfor (int i = 0; i < nr; i++)\n \t\tfree((void *)desc[i].buffer);\n \treturn ret;\n }\n@@ -145,10 +145,9 @@ static void update_index_from_diff(struct diff_queue_struct *q,\n \t\t\t\t   struct diff_options *opt UNUSED,\n \t\t\t\t   void *data)\n {\n-\tint i;\n \tint intent_to_add = *(int *)data;\n \n-\tfor (i = 0; i < q->nr; i++) {\n+\tfor (int i = 0; i < q->nr; i++) {\n \t\tint pos;\n \t\tstruct diff_filespec *one = q->queue[i]->one;\n \t\tint is_in_reset_tree = one->mode && !is_null_oid(&one->oid);\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex b3f4783858..0aa0320756 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -742,12 +742,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (filter_provided_objects) {\n-\t\tstruct commit_list *c;\n \t\tfor (i = 0; i < revs.pending.nr; i++) {\n \t\t\tstruct object_array_entry *pending = revs.pending.objects + i;\n \t\t\tpending->item->flags |= NOT_USER_GIVEN;\n \t\t}\n-\t\tfor (c = revs.commits; c; c = c->next)\n+\t\tfor (struct commit_list *c = revs.commits; c; c = c->next)\n \t\t\tc->item->object.flags |= NOT_USER_GIVEN;\n \t}\n \ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex fd130cea2d..fe2c0c5b7b 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -55,11 +55,10 @@ static void print_error_files(struct string_list *files_list,\n \t\t\t      int *errs)\n {\n \tif (files_list->nr) {\n-\t\tint i;\n \t\tstruct strbuf err_msg = STRBUF_INIT;\n \n \t\tstrbuf_addstr(&err_msg, main_msg);\n-\t\tfor (i = 0; i < files_list->nr; i++)\n+\t\tfor (int i = 0; i < files_list->nr; i++)\n \t\t\tstrbuf_addf(&err_msg,\n \t\t\t\t    \"\\n    %s\",\n \t\t\t\t    files_list->items[i].string);\n@@ -72,8 +71,7 @@ static void print_error_files(struct string_list *files_list,\n \n static void submodules_absorb_gitdir_if_needed(void)\n {\n-\tint i;\n-\tfor (i = 0; i < list.nr; i++) {\n+\tfor (int i = 0; i < list.nr; i++) {\n \t\tconst char *name = list.entry[i].name;\n \t\tint pos;\n \t\tconst struct cache_entry *ce;\n@@ -105,14 +103,14 @@ static int check_local_mod(struct object_id *head, int index_only)\n \t * lazy, and who cares if removal of files is a tad\n \t * slower than the theoretical maximum speed?\n \t */\n-\tint i, no_head;\n+\tint no_head;\n \tint errs = 0;\n \tstruct string_list files_staged = STRING_LIST_INIT_NODUP;\n \tstruct string_list files_cached = STRING_LIST_INIT_NODUP;\n \tstruct string_list files_local = STRING_LIST_INIT_NODUP;\n \n \tno_head = is_null_oid(head);\n-\tfor (i = 0; i < list.nr; i++) {\n+\tfor (int i = 0; i < list.nr; i++) {\n \t\tstruct stat st;\n \t\tint pos;\n \t\tconst struct cache_entry *ce;\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex 3df9eaad09..30ea49318f 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -327,8 +327,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \t\ttransport_print_push_status(dest, remote_refs, args.verbose, 0, &reject_reasons);\n \n \tif (!args.dry_run && remote) {\n-\t\tstruct ref *ref;\n-\t\tfor (ref = remote_refs; ref; ref = ref->next)\n+\t\tfor (struct ref *ref = remote_refs; ref; ref = ref->next)\n \t\t\ttransport_update_tracking_ref(remote, ref, args.verbose);\n \t}\n \ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 1307ed2b88..cf25851837 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -478,13 +478,13 @@ static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,\n \n void shortlog_output(struct shortlog *log)\n {\n-\tsize_t i, j;\n+\tsize_t j;\n \tstruct strbuf sb = STRBUF_INIT;\n \n \tif (log->sort_by_number)\n \t\tSTABLE_QSORT(log->list.items, log->list.nr,\n \t\t      log->summary ? compare_by_counter : compare_by_list);\n-\tfor (i = 0; i < log->list.nr; i++) {\n+\tfor (size_t i = 0; i < log->list.nr; i++) {\n \t\tconst struct string_list_item *item = &log->list.items[i];\n \t\tif (log->summary) {\n \t\t\tfprintf(log->file, \"%6d\\t%s\\n\",\ndiff --git a/builtin/show-branch.c b/builtin/show-branch.c\nindex b01ec761d2..cd9ba4db63 100644\n--- a/builtin/show-branch.c\n+++ b/builtin/show-branch.c\n@@ -523,9 +523,7 @@ static int show_independent(struct commit **rev,\n \t\t\t    int num_rev,\n \t\t\t    unsigned int *rev_mask)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < num_rev; i++) {\n+\tfor (int i = 0; i < num_rev; i++) {\n \t\tstruct commit *commit = rev[i];\n \t\tunsigned int flag = rev_mask[i];\n \ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex 0f52e25249..15460f153f 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -26,9 +26,7 @@ static char const * const builtin_sparse_checkout_usage[] = {\n \n static void write_patterns_to_file(FILE *fp, struct pattern_list *pl)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < pl->nr; i++) {\n+\tfor (int i = 0; i < pl->nr; i++) {\n \t\tstruct path_pattern *p = pl->patterns[i];\n \n \t\tif (p->flags & PATTERN_FLAG_NEGATIVE)\n@@ -79,7 +77,6 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (pl.use_cone_patterns) {\n-\t\tint i;\n \t\tstruct pattern_entry *pe;\n \t\tstruct hashmap_iter iter;\n \t\tstruct string_list sl = STRING_LIST_INIT_DUP;\n@@ -91,7 +88,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \n \t\tstring_list_sort(&sl);\n \n-\t\tfor (i = 0; i < sl.nr; i++) {\n+\t\tfor (int i = 0; i < sl.nr; i++) {\n \t\t\tquote_c_style(sl.items[i].string, NULL, stdout, 0);\n \t\t\tprintf(\"\\n\");\n \t\t}\n@@ -107,7 +104,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix)\n \n static void clean_tracked_sparse_directories(struct repository *r)\n {\n-\tint i, was_full = 0;\n+\tint was_full = 0;\n \tstruct strbuf path = STRBUF_INIT;\n \tsize_t pathlen;\n \tstruct string_list_item *item;\n@@ -150,7 +147,7 @@ static void clean_tracked_sparse_directories(struct repository *r)\n \t * store the entries in a list before exploring, since that might\n \t * expand the sparse-index again.\n \t */\n-\tfor (i = 0; i < r->index->cache_nr; i++) {\n+\tfor (int i = 0; i < r->index->cache_nr; i++) {\n \t\tstruct cache_entry *ce = r->index->cache[i];\n \n \t\tif (S_ISSPARSEDIR(ce->ce_mode) &&\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 7fb355bff0..0bedbe485d 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -179,10 +179,9 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)\n \tstruct strbuf symbolic = STRBUF_INIT;\n \n \tif (argc > 1) {\n-\t\tint i;\n \t\tstruct strbuf refs_msg = STRBUF_INIT;\n \n-\t\tfor (i = 0; i < argc; i++)\n+\t\tfor (int i = 0; i < argc; i++)\n \t\t\tstrbuf_addf(&refs_msg, \" '%s'\", argv[i]);\n \n \t\tfprintf_ln(stderr, _(\"Too many revisions specified:%s\"),\n@@ -364,9 +363,7 @@ static void add_diff_to_buf(struct diff_queue_struct *q,\n \t\t\t    struct diff_options *options UNUSED,\n \t\t\t    void *data)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < q->nr; i++) {\n+\tfor (int i = 0; i < q->nr; i++) {\n \t\tif (is_path_a_directory(q->queue[i]->one->path))\n \t\t\tcontinue;\n \n@@ -424,7 +421,6 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)\n \tstruct checkout state = CHECKOUT_INIT;\n \tstruct diff_options diff_opts;\n \tstruct lock_file lock = LOCK_INIT;\n-\tint i;\n \n \t/* If any entries have skip_worktree set, we'll have to check 'em out */\n \tstate.force = 1;\n@@ -447,7 +443,7 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)\n \tdiffcore_std(&diff_opts);\n \n \t/* Iterate over the paths that changed due to the merge... */\n-\tfor (i = 0; i < diff_queued_diff.nr; i++) {\n+\tfor (int i = 0; i < diff_queued_diff.nr; i++) {\n \t\tstruct diff_filepair *p;\n \t\tstruct cache_entry *ce;\n \t\tint pos;\n@@ -864,9 +860,7 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op\n \tstruct tree *tree[ARRAY_SIZE(oid)];\n \tstruct tree_desc tree_desc[ARRAY_SIZE(oid)];\n \tstruct unpack_trees_options unpack_tree_opt = { 0 };\n-\tint i;\n-\n-\tfor (i = 0; i < ARRAY_SIZE(oid); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(oid); i++) {\n \t\ttree[i] = parse_tree_indirect(oid[i]);\n \t\tif (parse_tree(tree[i]) < 0)\n \t\t\tdie(_(\"failed to parse tree\"));\n@@ -887,7 +881,6 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op\n \n static int show_stash(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tint ret = -1;\n \tstruct stash_info info = STASH_INFO_INIT;\n \tstruct rev_info rev;\n@@ -918,7 +911,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)\n \t\t\t     PARSE_OPT_KEEP_DASHDASH);\n \n \tstrvec_push(&revision_args, argv[0]);\n-\tfor (i = 1; i < argc; i++) {\n+\tfor (int i = 1; i < argc; i++) {\n \t\tif (argv[i][0] != '-')\n \t\t\tstrvec_push(&stash_args, argv[i]);\n \t\telse\n@@ -1049,9 +1042,7 @@ static int store_stash(int argc, const char **argv, const char *prefix)\n \n static void add_pathspecs(struct strvec *args,\n \t\t\t  const struct pathspec *ps) {\n-\tint i;\n-\n-\tfor (i = 0; i < ps->nr; i++)\n+\tfor (int i = 0; i < ps->nr; i++)\n \t\tstrvec_push(args, ps->items[i].original);\n }\n \n@@ -1065,7 +1056,6 @@ static void add_pathspecs(struct strvec *args,\n static int get_untracked_files(const struct pathspec *ps, int include_untracked,\n \t\t\t       struct strbuf *untracked_files)\n {\n-\tint i;\n \tint found = 0;\n \tstruct dir_struct dir = DIR_INIT;\n \n@@ -1073,7 +1063,7 @@ static int get_untracked_files(const struct pathspec *ps, int include_untracked,\n \t\tsetup_standard_excludes(&dir);\n \n \tfill_directory(&dir, the_repository->index, ps);\n-\tfor (i = 0; i < dir.nr; i++) {\n+\tfor (int i = 0; i < dir.nr; i++) {\n \t\tstruct dir_entry *ent = dir.entries[i];\n \t\tfound++;\n \t\tstrbuf_addstr(untracked_files, ent->name);\n@@ -1535,12 +1525,11 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q\n \n \trepo_read_index_preload(the_repository, NULL, 0);\n \tif (!include_untracked && ps->nr) {\n-\t\tint i;\n \t\tchar *ps_matched = xcalloc(ps->nr, 1);\n \n \t\t/* TODO: audit for interaction with sparse-index. */\n \t\tensure_full_index(&the_index);\n-\t\tfor (i = 0; i < the_index.cache_nr; i++)\n+\t\tfor (int i = 0; i < the_index.cache_nr; i++)\n \t\t\tce_path_match(&the_index, the_index.cache[i], ps,\n \t\t\t\t      ps_matched);\n \ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex fda50f2af1..711a184b62 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -143,7 +143,6 @@ static char *get_submodule_displaypath(const char *path, const char *prefix,\n static char *compute_rev_name(const char *sub_path, const char* object_id)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n-\tconst char ***d;\n \n \tstatic const char *describe_bare[] = { NULL };\n \n@@ -157,7 +156,7 @@ static char *compute_rev_name(const char *sub_path, const char* object_id)\n \t\t\t\t\t\tdescribe_contains,\n \t\t\t\t\t\tdescribe_all_always, NULL };\n \n-\tfor (d = describe_argv; *d; d++) {\n+\tfor (const char ***d = describe_argv; *d; d++) {\n \t\tstruct child_process cp = CHILD_PROCESS_INIT;\n \t\tprepare_submodule_repo_env(&cp.env);\n \t\tcp.dir = sub_path;\n@@ -194,7 +193,7 @@ static int module_list_compute(const char **argv,\n \t\t\t       struct pathspec *pathspec,\n \t\t\t       struct module_list *list)\n {\n-\tint i, result = 0;\n+\tint result = 0;\n \tchar *ps_matched = NULL;\n \n \tparse_pathspec(pathspec, 0,\n@@ -207,7 +206,7 @@ static int module_list_compute(const char **argv,\n \tif (repo_read_index(the_repository) < 0)\n \t\tdie(_(\"index file corrupt\"));\n \n-\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\tfor (int i = 0; i < the_index.cache_nr; i++) {\n \t\tconst struct cache_entry *ce = the_index.cache[i];\n \n \t\tif (!match_pathspec(&the_index, pathspec, ce->name, ce_namelen(ce),\n@@ -236,10 +235,9 @@ static int module_list_compute(const char **argv,\n \n static void module_list_active(struct module_list *list)\n {\n-\tint i;\n \tstruct module_list active_modules = MODULE_LIST_INIT;\n \n-\tfor (i = 0; i < list->nr; i++) {\n+\tfor (int i = 0; i < list->nr; i++) {\n \t\tconst struct cache_entry *ce = list->entries[i];\n \n \t\tif (!is_submodule_active(the_repository, ce->name))\n@@ -257,10 +255,9 @@ static void module_list_active(struct module_list *list)\n \n static char *get_up_path(const char *path)\n {\n-\tint i;\n \tstruct strbuf sb = STRBUF_INIT;\n \n-\tfor (i = count_slashes(path); i; i--)\n+\tfor (int i = count_slashes(path); i; i--)\n \t\tstrbuf_addstr(&sb, \"../\");\n \n \t/*\n@@ -277,9 +274,7 @@ static char *get_up_path(const char *path)\n static void for_each_listed_submodule(const struct module_list *list,\n \t\t\t\t      each_submodule_fn fn, void *cb_data)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < list->nr; i++)\n+\tfor (int i = 0; i < list->nr; i++)\n \t\tfn(list->entries[i], cb_data);\n }\n \n@@ -787,9 +782,7 @@ struct module_cb_list {\n \n static void module_cb_list_release(struct module_cb_list *mcbl)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < mcbl->nr; i++) {\n+\tfor (int i = 0; i < mcbl->nr; i++) {\n \t\tstruct module_cb *mcb = mcbl->entries[i];\n \n \t\tmodule_cb_release(mcb);\n@@ -1021,8 +1014,7 @@ static void generate_submodule_summary(struct summary_cb *info,\n static void prepare_submodule_summary(struct summary_cb *info,\n \t\t\t\t      struct module_cb_list *list)\n {\n-\tint i;\n-\tfor (i = 0; i < list->nr; i++) {\n+\tfor (int i = 0; i < list->nr; i++) {\n \t\tconst struct submodule *sub;\n \t\tstruct module_cb *p = list->entries[i];\n \t\tstruct strbuf sm_gitdir = STRBUF_INIT;\n@@ -1063,9 +1055,8 @@ static void submodule_summary_callback(struct diff_queue_struct *q,\n \t\t\t\t       struct diff_options *options UNUSED,\n \t\t\t\t       void *data)\n {\n-\tint i;\n \tstruct module_cb_list *list = data;\n-\tfor (i = 0; i < q->nr; i++) {\n+\tfor (int i = 0; i < q->nr; i++) {\n \t\tstruct diff_filepair *p = q->queue[i];\n \t\tstruct module_cb *temp;\n \n@@ -2592,7 +2583,7 @@ static int update_submodule(struct update_data *update_data)\n \n static int update_submodules(struct update_data *update_data)\n {\n-\tint i, ret = 0;\n+\tint ret = 0;\n \tstruct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT;\n \tconst struct run_process_parallel_opts opts = {\n \t\t.tr2_category = \"submodule\",\n@@ -2622,7 +2613,7 @@ static int update_submodules(struct update_data *update_data)\n \t\tgoto cleanup;\n \t}\n \n-\tfor (i = 0; i < suc.update_clone_nr; i++) {\n+\tfor (int i = 0; i < suc.update_clone_nr; i++) {\n \t\tstruct update_clone_data ucd = suc.update_clone[i];\n \t\tint code;\n \n@@ -2812,13 +2803,12 @@ static int push_check(int argc, const char **argv, const char *prefix UNUSED)\n \n \t/* Check the refspec */\n \tif (argc > 2) {\n-\t\tint i;\n \t\tstruct ref *local_refs = get_local_heads();\n \t\tstruct refspec refspec = REFSPEC_INIT_PUSH;\n \n \t\trefspec_appendn(&refspec, argv + 2, argc - 2);\n \n-\t\tfor (i = 0; i < refspec.nr; i++) {\n+\t\tfor (int i = 0; i < refspec.nr; i++) {\n \t\t\tconst struct refspec_item *rs = &refspec.items[i];\n \n \t\t\tif (rs->pattern || rs->matching)\n@@ -2855,7 +2845,6 @@ static int push_check(int argc, const char **argv, const char *prefix UNUSED)\n \n static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n {\n-\tint i;\n \tstruct pathspec pathspec = { 0 };\n \tstruct module_list list = MODULE_LIST_INIT;\n \tconst char *super_prefix = NULL;\n@@ -2875,7 +2864,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \tif (module_list_compute(argv, prefix, &pathspec, &list) < 0)\n \t\tgoto cleanup;\n \n-\tfor (i = 0; i < list.nr; i++)\n+\tfor (int i = 0; i < list.nr; i++)\n \t\tabsorb_git_dir_into_superproject(list.entries[i]->name,\n \t\t\t\t\t\t super_prefix);\n \n@@ -3239,7 +3228,6 @@ static void die_on_index_match(const char *path, int force)\n \t\tdie(_(\"index file corrupt\"));\n \n \tif (ps.nr) {\n-\t\tint i;\n \t\tchar *ps_matched = xcalloc(ps.nr, 1);\n \n \t\t/* TODO: audit for interaction with sparse-index. */\n@@ -3249,7 +3237,7 @@ static void die_on_index_match(const char *path, int force)\n \t\t * Since there is only one pathspec, we just need to\n \t\t * check ps_matched[0] to know if a cache entry matched.\n \t\t */\n-\t\tfor (i = 0; i < the_index.cache_nr; i++) {\n+\t\tfor (int i = 0; i < the_index.cache_nr; i++) {\n \t\t\tce_path_match(&the_index, the_index.cache[i], &ps,\n \t\t\t\t      ps_matched);\n \ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 37473ac21f..2e2b315183 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -78,12 +78,11 @@ typedef int (*each_tag_name_fn)(const char *name, const char *ref,\n static int for_each_tag_name(const char **argv, each_tag_name_fn fn,\n \t\t\t     void *cb_data)\n {\n-\tconst char **p;\n \tstruct strbuf ref = STRBUF_INIT;\n \tint had_error = 0;\n \tstruct object_id oid;\n \n-\tfor (p = argv; *p; p++) {\n+\tfor (const char **p = argv; *p; p++) {\n \t\tstrbuf_reset(&ref);\n \t\tstrbuf_addf(&ref, \"refs/tags/%s\", *p);\n \t\tif (read_ref(ref.buf, &oid)) {\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex e0a701f2b3..0801d13b0e 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -248,8 +248,7 @@ static int check_object(struct object *obj, enum object_type type,\n \n static void write_rest(void)\n {\n-\tunsigned i;\n-\tfor (i = 0; i < nr_objects; i++) {\n+\tfor (unsigned i = 0; i < nr_objects; i++) {\n \t\tif (obj_list[i].obj)\n \t\t\tcheck_object(obj_list[i].obj, OBJ_ANY, NULL, NULL);\n \t}\n@@ -574,7 +573,6 @@ static void unpack_one(unsigned nr)\n \n static void unpack_all(void)\n {\n-\tint i;\n \tstruct pack_header *hdr = fill(sizeof(struct pack_header));\n \n \tnr_objects = ntohl(hdr->hdr_entries);\n@@ -590,7 +588,7 @@ static void unpack_all(void)\n \t\tprogress = start_progress(_(\"Unpacking objects\"), nr_objects);\n \tCALLOC_ARRAY(obj_list, nr_objects);\n \tbegin_odb_transaction();\n-\tfor (i = 0; i < nr_objects; i++) {\n+\tfor (int i = 0; i < nr_objects; i++) {\n \t\tunpack_one(i);\n \t\tdisplay_progress(progress, i + 1);\n \t}\n@@ -603,7 +601,6 @@ static void unpack_all(void)\n \n int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)\n {\n-\tint i;\n \tstruct object_id oid;\n \tgit_hash_ctx tmp_ctx;\n \n@@ -613,7 +610,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)\n \n \tquiet = !isatty(2);\n \n-\tfor (i = 1 ; i < argc; i++) {\n+\tfor (int i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n \t\tif (*arg == '-') {\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 7bcaa1476c..60e346960e 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -655,10 +655,9 @@ static int unresolve_one(const char *path)\n static int do_unresolve(int ac, const char **av,\n \t\t\tconst char *prefix, int prefix_length)\n {\n-\tint i;\n \tint err = 0;\n \n-\tfor (i = 1; i < ac; i++) {\n+\tfor (int i = 1; i < ac; i++) {\n \t\tconst char *arg = av[i];\n \t\tchar *p = prefix_path(prefix, prefix_length, arg);\n \t\terr |= unresolve_one(p);\n@@ -670,10 +669,6 @@ static int do_unresolve(int ac, const char **av,\n static int do_reupdate(const char **paths,\n \t\t       const char *prefix)\n {\n-\t/* Read HEAD and run update-index on paths that are\n-\t * merged and already different between index and HEAD.\n-\t */\n-\tint pos;\n \tint has_head = 1;\n \tstruct pathspec pathspec;\n \tstruct object_id head_oid;\n@@ -688,7 +683,7 @@ static int do_reupdate(const char **paths,\n \t\t */\n \t\thas_head = 0;\n  redo:\n-\tfor (pos = 0; pos < the_index.cache_nr; pos++) {\n+\tfor (int pos = 0; pos < the_index.cache_nr; pos++) {\n \t\tconst struct cache_entry *ce = the_index.cache[pos];\n \t\tstruct cache_entry *old = NULL;\n \t\tint save_nr;\ndiff --git a/builtin/var.c b/builtin/var.c\nindex cf5567208a..3aa4e4d45b 100644\n--- a/builtin/var.c\n+++ b/builtin/var.c\n@@ -168,10 +168,9 @@ static struct git_var git_vars[] = {\n \n static void list_vars(void)\n {\n-\tstruct git_var *ptr;\n \tchar *val;\n \n-\tfor (ptr = git_vars; ptr->read; ptr++)\n+\tfor (struct git_var *ptr = git_vars; ptr->read; ptr++)\n \t\tif ((val = ptr->read(0))) {\n \t\t\tif (ptr->multivalued && *val) {\n \t\t\t\tstruct string_list list = STRING_LIST_INIT_DUP;\n@@ -190,8 +189,7 @@ static void list_vars(void)\n \n static const struct git_var *get_git_var(const char *var)\n {\n-\tstruct git_var *ptr;\n-\tfor (ptr = git_vars; ptr->read; ptr++) {\n+\tfor (struct git_var *ptr = git_vars; ptr->read; ptr++) {\n \t\tif (strcmp(var, ptr->name) == 0) {\n \t\t\treturn ptr;\n \t\t}\ndiff --git a/builtin/verify-pack.c b/builtin/verify-pack.c\nindex 011dddd2dc..a342d5adf3 100644\n--- a/builtin/verify-pack.c\n+++ b/builtin/verify-pack.c\n@@ -66,7 +66,6 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix)\n \tint err = 0;\n \tunsigned int flags = 0;\n \tconst char *object_format = NULL;\n-\tint i;\n \tconst struct option verify_pack_options[] = {\n \t\tOPT_BIT('v', \"verbose\", &flags, N_(\"verbose\"),\n \t\t\tVERIFY_PACK_VERBOSE),\n@@ -82,7 +81,7 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix)\n \t\t\t     verify_pack_usage, 0);\n \tif (argc < 1)\n \t\tusage_with_options(verify_pack_usage, verify_pack_options);\n-\tfor (i = 0; i < argc; i++) {\n+\tfor (int i = 0; i < argc; i++) {\n \t\tif (verify_one_pack(argv[i], flags, object_format))\n \t\t\terr = 1;\n \t}\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 9c76b62b02..d4c5b6b7d3 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -191,10 +191,8 @@ static int prune_cmp(const void *a, const void *b)\n \n static void prune_dups(struct string_list *l)\n {\n-\tint i;\n-\n \tQSORT(l->items, l->nr, prune_cmp);\n-\tfor (i = 1; i < l->nr; i++) {\n+\tfor (int i = 1; i < l->nr; i++) {\n \t\tif (!fspathcmp(l->items[i].string, l->items[i - 1].string))\n \t\t\tprune_worktree(l->items[i].util, \"duplicate entry\");\n \t}\n@@ -999,9 +997,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)\n \n static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)\n {\n-\tint i;\n-\n-\tfor (i = 0; wt[i]; i++) {\n+\tfor (int i = 0; wt[i]; i++) {\n \t\tint sha1_len;\n \t\tint path_len = strlen(wt[i]->path);\n \n@@ -1055,7 +1051,7 @@ static int list(int ac, const char **av, const char *prefix)\n \t\tdie(_(\"the option '%s' requires '%s'\"), \"-z\", \"--porcelain\");\n \telse {\n \t\tstruct worktree **worktrees = get_worktrees();\n-\t\tint path_maxlen = 0, abbrev = DEFAULT_ABBREV, i;\n+\t\tint path_maxlen = 0, abbrev = DEFAULT_ABBREV;\n \n \t\t/* sort worktrees by path but keep main worktree at top */\n \t\tpathsort(worktrees + 1);\n@@ -1063,7 +1059,7 @@ static int list(int ac, const char **av, const char *prefix)\n \t\tif (!porcelain)\n \t\t\tmeasure_widths(worktrees, &abbrev, &path_maxlen);\n \n-\t\tfor (i = 0; worktrees[i]; i++) {\n+\t\tfor (int i = 0; worktrees[i]; i++) {\n \t\t\tif (porcelain)\n \t\t\t\tshow_worktree_porcelain(worktrees[i],\n \t\t\t\t\t\t\tline_terminator);\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex eb46b88637..c00c4ad3a7 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -51,7 +51,6 @@ static void flush_bulk_checkin_packfile(struct bulk_checkin_packfile *state)\n {\n \tunsigned char hash[GIT_MAX_RAWSZ];\n \tstruct strbuf packname = STRBUF_INIT;\n-\tint i;\n \n \tif (!state->f)\n \t\treturn;\n@@ -76,7 +75,7 @@ static void flush_bulk_checkin_packfile(struct bulk_checkin_packfile *state)\n \tfinish_tmp_packfile(&packname, state->pack_tmp_name,\n \t\t\t    state->written, state->nr_written,\n \t\t\t    &state->pack_idx_opts, hash);\n-\tfor (i = 0; i < state->nr_written; i++)\n+\tfor (int i = 0; i < state->nr_written; i++)\n \t\tfree(state->written[i]);\n \n clear_exit:\n@@ -124,14 +123,12 @@ static void flush_batch_fsync(void)\n \n static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid)\n {\n-\tint i;\n-\n \t/* The object may already exist in the repository */\n \tif (repo_has_object_file(the_repository, oid))\n \t\treturn 1;\n \n \t/* Might want to keep the list sorted */\n-\tfor (i = 0; i < state->nr_written; i++)\n+\tfor (int i = 0; i < state->nr_written; i++)\n \t\tif (oideq(&state->written[i]->oid, oid))\n \t\t\treturn 1;\n \ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex ca32050a78..45d615a3db 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -114,8 +114,7 @@ void print_bundle_list(FILE *fp, struct bundle_list *list)\n \tfprintf(fp, \"\\tmode = %s\\n\", mode);\n \n \tif (list->heuristic) {\n-\t\tint i;\n-\t\tfor (i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {\n+\t\tfor (int i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {\n \t\t\tif (heuristics[i].heuristic == list->heuristic) {\n \t\t\t\tprintf(\"\\theuristic = %s\\n\",\n \t\t\t\t       heuristics[list->heuristic].name);\n@@ -167,8 +166,7 @@ static int bundle_list_update(const char *key, const char *value,\n \t\t}\n \n \t\tif (!strcmp(subkey, \"heuristic\")) {\n-\t\t\tint i;\n-\t\t\tfor (i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {\n+\t\t\tfor (int i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {\n \t\t\t\tif (heuristics[i].heuristic &&\n \t\t\t\t    heuristics[i].name &&\n \t\t\t\t    !strcmp(value, heuristics[i].name)) {\ndiff --git a/bundle.c b/bundle.c\nindex a9744da255..419ba4cc45 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -60,9 +60,7 @@ static int parse_capability(struct bundle_header *header, const char *capability\n \n static int parse_bundle_signature(struct bundle_header *header, const char *line)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < ARRAY_SIZE(bundle_sigs); i++) {\n+\tfor (int i = 0; i < ARRAY_SIZE(bundle_sigs); i++) {\n \t\tif (!strcmp(line, bundle_sigs[i].signature)) {\n \t\t\theader->version = bundle_sigs[i].version;\n \t\t\treturn 0;\n@@ -167,9 +165,7 @@ int is_bundle(const char *path, int quiet)\n \n static int list_refs(struct string_list *r, int argc, const char **argv)\n {\n-\tint i;\n-\n-\tfor (i = 0; i < r->nr; i++) {\n+\tfor (int i = 0; i < r->nr; i++) {\n \t\tstruct object_id *oid;\n \t\tconst char *name;\n \n@@ -216,7 +212,7 @@ int verify_bundle(struct repository *r,\n \t * to be verbose about the errors\n \t */\n \tstruct string_list *p = &header->prerequisites;\n-\tint i, ret = 0;\n+\tint ret = 0;\n \tconst char *message = _(\"Repository lacks these prerequisite commits:\");\n \tstruct string_list_iterator iter = {\n \t\t.list = p,\n@@ -228,7 +224,7 @@ int verify_bundle(struct repository *r,\n \tif (!r || !r->objects || !r->objects->odb)\n \t\treturn error(_(\"need a repository to verify a bundle\"));\n \n-\tfor (i = 0; i < p->nr; i++) {\n+\tfor (int i = 0; i < p->nr; i++) {\n \t\tstruct string_list_item *e = p->items + i;\n \t\tconst char *name = e->string;\n \t\tstruct object_id *oid = e->util;\n@@ -320,7 +316,6 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)\n {\n \tstruct child_process pack_objects = CHILD_PROCESS_INIT;\n-\tint i;\n \n \tstrvec_pushl(&pack_objects.args,\n \t\t     \"pack-objects\",\n@@ -350,7 +345,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *\n \tif (start_command(&pack_objects))\n \t\treturn error(_(\"Could not spawn pack-objects\"));\n \n-\tfor (i = 0; i < revs->pending.nr; i++) {\n+\tfor (int i = 0; i < revs->pending.nr; i++) {\n \t\tstruct object *object = revs->pending.objects[i].item;\n \t\tif (object->flags & UNINTERESTING)\n \t\t\twrite_or_die(pack_objects.in, \"^\", 1);\n@@ -374,10 +369,9 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *\n  */\n static int write_bundle_refs(int bundle_fd, struct rev_info *revs)\n {\n-\tint i;\n \tint ref_count = 0;\n \n-\tfor (i = 0; i < revs->pending.nr; i++) {\n+\tfor (int i = 0; i < revs->pending.nr; i++) {\n \t\tstruct object_array_entry *e = revs->pending.objects + i;\n \t\tstruct object_id oid;\n \t\tchar *ref;\n@@ -500,7 +494,6 @@ int create_bundle(struct repository *r, const char *path,\n \tstruct rev_info revs, revs_copy;\n \tint min_version = 2;\n \tstruct bundle_prerequisites_info bpi;\n-\tint i;\n \n \t/* init revs to list objects for pack-objects later */\n \tsave_commit_buffer = 0;\n@@ -566,7 +559,7 @@ int create_bundle(struct repository *r, const char *path,\n \trevs_copy.pending.nr = 0;\n \trevs_copy.pending.alloc = 0;\n \trevs_copy.pending.objects = NULL;\n-\tfor (i = 0; i < revs.pending.nr; i++) {\n+\tfor (int i = 0; i < revs.pending.nr; i++) {\n \t\tstruct object_array_entry *e = revs.pending.objects + i;\n \t\tif (e)\n \t\t\tadd_object_array_with_path(e->item, e->name,\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 64678fe199..1aa30bdd80 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -27,12 +27,11 @@ struct cache_tree *cache_tree(void)\n \n void cache_tree_free(struct cache_tree **it_p)\n {\n-\tint i;\n \tstruct cache_tree *it = *it_p;\n \n \tif (!it)\n \t\treturn;\n-\tfor (i = 0; i < it->subtree_nr; i++)\n+\tfor (int i = 0; i < it->subtree_nr; i++)\n \t\tif (it->down[i]) {\n \t\t\tcache_tree_free(&it->down[i]->cache_tree);\n \t\t\tfree(it->down[i]);\n@@ -216,8 +215,8 @@ static void discard_unused_subtrees(struct cache_tree *it)\n {\n \tstruct cache_tree_sub **down = it->down;\n \tint nr = it->subtree_nr;\n-\tint dst, src;\n-\tfor (dst = src = 0; src < nr; src++) {\n+\tint src;\n+\tfor (int dst = src = 0; src < nr; src++) {\n \t\tstruct cache_tree_sub *s = down[src];\n \t\tif (s->used)\n \t\t\tdown[dst++] = s;\n@@ -231,12 +230,11 @@ static void discard_unused_subtrees(struct cache_tree *it)\n \n int cache_tree_fully_valid(struct cache_tree *it)\n {\n-\tint i;\n \tif (!it)\n \t\treturn 0;\n \tif (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid))\n \t\treturn 0;\n-\tfor (i = 0; i < it->subtree_nr; i++) {\n+\tfor (int i = 0; i < it->subtree_nr; i++) {\n \t\tif (!cache_tree_fully_valid(it->down[i]->cache_tree))\n \t\t\treturn 0;\n \t}\n@@ -495,8 +493,6 @@ int cache_tree_update(struct index_state *is"},{"id":"488744","messageId":"xmqqcysxskd9.fsf@gitster.g","threadId":"60925","inReplyTo":"20240215094243.147057-1-gitter.spiros@gmail.com","subject":"Re: [PATCH] use C99 declaration of variable in for() loop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-15T17:33:22Z","receivedAt":"2024-02-15T17:33:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elia Pinto <gitter.spiros@gmail.com> writes:\n\n> With the exception of cbtree.c, which would need initial\n> reworking to remove the usage of goto, it expands the\n> use of variable scope reduction in for loops as\n> permitted by the C99 standard, which was first introduced\n> in the git codebase with commit 44ba10d6.\n\nThanks, but ...\n\nOur test balloon may have proven that nobody will be inconvenienced,\nand it does mean we can be liberal using it when we add new code or\nupdate existing loops \"while at it\", but I personally do not think\nsuch a code churn is very welcome.\n"},{"id":"488746","messageId":"CAP8UFD2hHYeUxtXm1tNDe3tpBAif7amLbkTQpurp3w1n7uO+HQ@mail.gmail.com","threadId":"60925","inReplyTo":"xmqqcysxskd9.fsf@gitster.g","subject":"Re: [PATCH] use C99 declaration of variable in for() loop","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2024-02-15T18:17:13Z","receivedAt":"2024-02-15T18:17:27Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thu, Feb 15, 2024 at 6:33 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Elia Pinto <gitter.spiros@gmail.com> writes:\n>\n> > With the exception of cbtree.c, which would need initial\n> > reworking to remove the usage of goto, it expands the\n> > use of variable scope reduction in for loops as\n> > permitted by the C99 standard, which was first introduced\n> > in the git codebase with commit 44ba10d6.\n>\n> Thanks, but ...\n>\n> Our test balloon may have proven that nobody will be inconvenienced,\n> and it does mean we can be liberal using it when we add new code or\n> update existing loops \"while at it\", but I personally do not think\n> such a code churn is very welcome.\n\nPerhaps such changes could be accepted when they are made in only one\nfile as part of a microproject though?\n"},{"id":"488750","messageId":"xmqqv86ppnqa.fsf@gitster.g","threadId":"60925","inReplyTo":"CAP8UFD2hHYeUxtXm1tNDe3tpBAif7amLbkTQpurp3w1n7uO+HQ@mail.gmail.com","subject":"Re: [PATCH] use C99 declaration of variable in for() loop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-15T18:49:01Z","receivedAt":"2024-02-15T18:49:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <christian.couder@gmail.com> writes:\n\n> Perhaps such changes could be accepted when they are made in only one\n> file as part of a microproject though?\n\nYes, a microproject is not about helping this project, but is about\nus investing our cycles in helping aspiring developers with small\npractice material.  Even though we may not want to see massive code\nchurn, we can view the cost of reviewing and accepting small changes\nas a part of the cost to onboard new folks.\n\n\n"},{"id":"488751","messageId":"CA+EOSBktLGnzi+DjOTVv9_cVNsM_fjEKiF9kWnaYrGtvGJ-Kdg@mail.gmail.com","threadId":"60925","inReplyTo":"xmqqcysxskd9.fsf@gitster.g","subject":"Re: [PATCH] use C99 declaration of variable in for() loop","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2024-02-15T18:56:40Z","receivedAt":"2024-02-15T18:56:53Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"Il giorno gio 15 feb 2024 alle ore 18:33 Junio C Hamano\n<gitster@pobox.com> ha scritto:\n>\n> Elia Pinto <gitter.spiros@gmail.com> writes:\n>\n> > With the exception of cbtree.c, which would need initial\n> > reworking to remove the usage of goto, it expands the\n> > use of variable scope reduction in for loops as\n> > permitted by the C99 standard, which was first introduced\n> > in the git codebase with commit 44ba10d6.\n>\n> Thanks, but ...\n>\n> Our test balloon may have proven that nobody will be inconvenienced,\n> and it does mean we can be liberal using it when we add new code or\n> update existing loops \"while at it\", but I personally do not think\n> such a code churn is very welcome.\n\nThank you for your reply. I can understand that, clearly. However,\nthis means that extensive code\nrefactoring contributions are never welcome. I am not saying this is a\nproblem, but just an observation.\n\nBest\n"},{"id":"488754","messageId":"xmqqmss1pk4a.fsf@gitster.g","threadId":"60925","inReplyTo":"CA+EOSBktLGnzi+DjOTVv9_cVNsM_fjEKiF9kWnaYrGtvGJ-Kdg@mail.gmail.com","subject":"Re: [PATCH] use C99 declaration of variable in for() loop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-15T20:07:01Z","receivedAt":"2024-02-15T20:07:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elia Pinto <gitter.spiros@gmail.com> writes:\n\n> Thank you for your reply. I can understand that, clearly. However,\n> this means that extensive code\n> refactoring contributions are never welcome. I am not saying this is a\n> problem, but just an observation.\n\nSuch changes can happen and have happened when the benefit of such\ncode churn outweighs the cost of reviewing *and* cost of updating or\nadjusting in-flight topics that may already or may not yet be in my\ntree.  Coccinelle-driven patches that can be mechanically reproduced\nand whose validity can be trusted can be one way to reduce the review\nand maintenance cost for such a tree-wide change.\n\n\n"},{"id":"488767","messageId":"Zc6abO6RV9RwpABR@tapette.crustytoothpaste.net","threadId":"60925","inReplyTo":"xmqqcysxskd9.fsf@gitster.g","subject":"Re: [PATCH] use C99 declaration of variable in for() loop","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2024-02-15T23:12:44Z","receivedAt":"2024-02-15T23:12:53Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2024-02-15 at 17:33:22, Junio C Hamano wrote:\n> Elia Pinto <gitter.spiros@gmail.com> writes:\n> \n> > With the exception of cbtree.c, which would need initial\n> > reworking to remove the usage of goto, it expands the\n> > use of variable scope reduction in for loops as\n> > permitted by the C99 standard, which was first introduced\n> > in the git codebase with commit 44ba10d6.\n> \n> Thanks, but ...\n> \n> Our test balloon may have proven that nobody will be inconvenienced,\n> and it does mean we can be liberal using it when we add new code or\n> update existing loops \"while at it\", but I personally do not think\n> such a code churn is very welcome.\n\nI will also say that sending one giant patch for this may be a bit hard\nto review.  While I will defer to Junio's opinion as the maintainer, I\nwould be more inclined to review this kind of series if it came in in\nsmaller patches, a few at a time, in which case I would find it a\nwelcome improvement.\n\nSince my time to work on Git is relatively limited, having, say, a\nfive-patch series where we each update a single file would let me review\nthese changes in a relatively short amount of time, which I would be\nmore likely to be able to find time for.  Looking at the large patch,\nI'd be worried that I wouldn't be able to get through the entire thing\nin one sitting.\n\nOf course, if you bring in a nice Coccinelle patch for it, then that may\nmake a longer (but still one-file-per-commit) series more viable, since\nit will help reviewers have more confidence in your change.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"488771","messageId":"xmqqa5o1mgyo.fsf@gitster.g","threadId":"60925","inReplyTo":"Zc6abO6RV9RwpABR@tapette.crustytoothpaste.net","subject":"Re: [PATCH] use C99 declaration of variable in for() loop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-15T23:43:27Z","receivedAt":"2024-02-15T23:43:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> I will also say that sending one giant patch for this may be a bit hard\n> to review.  While I will defer to Junio's opinion as the maintainer, I\n> would be more inclined to review this kind of series if it came in in\n> smaller patches, a few at a time, in which case I would find it a\n> welcome improvement.\n\nTrue.  As to the specific topic of using \"for (int i = 0; ...)\",\nit is tedious to review for mistakes and 17000+ lines of patch is\nnot a way to do so.  I do not think I would be able to spot a change\nin behaviour caused by a hunk like this\n\n\tint i = 3;\n\t... after some operations ...\n-\tfor (i = 0; i < 5; i++)\n+\tfor (int i = 0; i < 5; i++)\n\t\tif (condition_on_i(i))\n\t\t\tbreak;\n\t... after some operations ...\n\treturn i;\n\nafter scanning similar changes for 1000+ times in a single huge\npatch.\n"}]}