aboutsummaryrefslogtreecommitdiff
path: root/bundle.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-07-19 19:22:25 -0700
committerJunio C Hamano <gitster@pobox.com>2008-07-19 23:08:58 -0700
commitc972ec04204b6edf4fe7ec0d59a3ce3564378303 (patch)
tree6aec6ba838e79473149275d3e5c0623f298b1b15 /bundle.c
parent09651dd86eb07d1d6f1a2e88fe7b4860891808c1 (diff)
downloadgit-c972ec04204b6edf4fe7ec0d59a3ce3564378303.tar.gz
git-c972ec04204b6edf4fe7ec0d59a3ce3564378303.tar.xz
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 'bundle.c')
0 files changed, 0 insertions, 0 deletions