Skip to content

Kill the_index part 1, expose it

Nguyễn Thái Ngọc Duy git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 16 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15contrib: add cocci script to replace index compat macroscontrib/coccinelle/index-compat.cocci+184 -05 replies
2/15apply.c: stop using index compat macrosapply.c+19 -154 replies
3/15blame.c: stop using index compat macrosblame.c+10 -90 replies
4/15check-racy.c: stop using index compat macroscheck-racy.c+5 -50 replies
5/15diff-lib.c: stop using index compat macrosdiff-lib.c+4 -40 replies
6/15diff.c: stop using index compat macrosdiff.c+6 -60 replies
7/15entry.c: stop using index compat macrosentry.c+2 -10 replies
8/15merge-recursive.c: stop using index compat macrosmerge-recursive.c+33 -320 replies
9/15merge.c: stop using index compat macrosmerge.c+7 -70 replies
10/15rerere.c: stop using index compat macrosrerere.c+18 -180 replies
11/15revision.c: stop using index compat macrosrevision.c+7 -70 replies
12/15sequencer.c: stop using index compat macrossequencer.c+16 -160 replies
13/15sha1-name.c: stop using index compat macrossha1-name.c+11 -110 replies
14/15wt-status.c: stop using index compat macroswt-status.c+12 -120 replies
15/15cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switchattr.c builtin/add.c builtin/am.c +35 more+29 -111 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/15] Kill the_index part 1, expose it

This is the beginning of the end of the_index. The problem with the_index is it lets library code anywhere access it freely. This is not good because from high level you may not realize that the_index is being used while you don't want to touch index at all, or you want to use a different index instead.

This is a long series, 86 patches [1], so I'm going to split and submit it in 15-20 patches at a time. The first two parts are trivial though and could be safely fast tracked if needed.

This is the first part, which kills the use of index compat macros outside builtin/ and expose the_index in all library code. Later on we will ban the_index from one file each time until it's gone for good.

"struct index_state *" will be passed from builtin/ through the call chain to the function that needs it. In some cases, "struct repository *" will be passed instead when the whole operation spans more than just the index. By the end, the_index becomes part of "index compat macros" and cannot be used outside builtin/

Part one is mechanical conversion with the help of coccinelle. The only real patches are the first and the last one.

[1] https://gitlab.com/pclouds/git/commits/really-kill-the-index

Nguyễn Thái Ngọc Duy (15):
contrib: add cocci script to replace index compat macros apply.c: stop using index compat macros blame.c: stop using index compat macros check-racy.c: stop using index compat macros diff-lib.c: stop using index compat macros diff.c: stop using index compat macros
entry.c: stop using index compat macros merge-recursive.c: stop using index compat macros merge.c: stop using index compat macros rerere.c: stop using index compat macros revision.c: stop using index compat macros sequencer.c: stop using index compat macros sha1-name.c: stop using index compat macros wt-status.c: stop using index compat macros cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch

 apply.c                               |  34 ++---
 attr.c                                |   1 -
 blame.c                               |  19 +--
 builtin/add.c                         |   1 +
 builtin/am.c                          |   1 +
 builtin/check-attr.c                  |   1 +
 builtin/check-ignore.c                |   1 +
 builtin/checkout-index.c              |   1 +
 builtin/checkout.c                    |   1 +
 builtin/clean.c                       |   1 +
 builtin/commit.c                      |   1 +
 builtin/describe.c                    |   1 +
 builtin/diff-files.c                  |   1 +
 builtin/diff-index.c                  |   1 +
 builtin/diff-tree.c                   |   1 +
 builtin/diff.c                        |   1 +
 builtin/fsck.c                        |   1 +
 builtin/ls-files.c                    |   1 -
 builtin/merge-index.c                 |   1 +
 builtin/merge-ours.c                  |   1 +
 builtin/merge.c                       |   1 +
 builtin/mv.c                          |   1 +
 builtin/pull.c                        |   1 +
 builtin/read-tree.c                   |   1 +
 builtin/reset.c                       |   1 +
 builtin/rev-parse.c                   |   1 +
 builtin/rm.c                          |   1 +
 builtin/submodule--helper.c           |   1 +
 builtin/update-index.c                |   1 +
 cache.h                               |   2 +-
 check-racy.c                          |  10 +-
 contrib/coccinelle/index-compat.cocci | 184 ++++++++++++++++++++++++++
 convert.c                             |   1 -
 diff-lib.c                            |   8 +-
 diff.c                                |  12 +-
 dir.c                                 |   1 -
 entry.c                               |   3 +-
 merge-recursive.c                     |  65 ++++-----
 merge.c                               |  14 +-
 name-hash.c                           |   1 -
 pathspec.c                            |   1 -
 read-cache.c                          |   1 -
 rerere.c                              |  36 ++---
 revision.c                            |  14 +-
 sequencer.c                           |  32 ++---
 sha1-name.c                           |  22 +--
 submodule.c                           |   1 -
 t/helper/test-dump-untracked-cache.c  |   1 +
 t/helper/test-tool.h                  |   2 +
 tree.c                                |   1 -
 unpack-trees.c                        |   1 -
 wt-status.c                           |  24 ++--
 52 files changed, 363 insertions(+), 154 deletions(-)
 create mode 100644 contrib/coccinelle/index-compat.cocci
Signature · 1 line
2.18.0.rc0.333.g22e6ee6cdf