diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-07-20 04:22:25 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-20 08:08:58 +0200 |
commit | c972ec04204b6edf4fe7ec0d59a3ce3564378303 (patch) | |
tree | 6aec6ba838e79473149275d3e5c0623f298b1b15 /show-index.c | |
parent | Getting closer to 1.6.0-rc0 (diff) | |
download | git-c972ec04204b6edf4fe7ec0d59a3ce3564378303.tar.xz git-c972ec04204b6edf4fe7ec0d59a3ce3564378303.zip |
builtin-add.c: restructure the code for maintainability
The implementation of "git add" has four major codepaths that are mutually
exclusive:
- if "--interactive" or "--patch" is given, spawn "git add--interactive"
and exit without doing anything else. Otherwise things are handled
internally in this C code;
- if "--update" is given, update the modified files and exit without
doing anything else;
- if "--refresh" is given, do refresh and exit without doing anything
else;
- otherwise, find the paths that match pathspecs and stage their
contents.
It led to an unholy mess in the code structure; each of the latter three
codepaths has a separate call to read_cache(), even though they are all
about "read the current index, update it and write it back", and logically
they should read the index once _anyway_.
This cleans up the latter three cases by introducing a pair of helper
variables:
- "add_new_files" is set if we need to scan the working tree for paths
that match the pathspec. This variable is false for "--update" and
"--refresh", because they only work on already tracked files.
- "require_pathspec" is set if the user must give at least one pathspec.
"--update" does not need it but all the other cases do.
This is in preparation for introducing a new option "--all", that does the
equivalent of "git add -u && git add ." (aka "addremove").
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'show-index.c')
0 files changed, 0 insertions, 0 deletions