diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2013-09-17 03:06:14 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-09-17 10:07:13 -0700 |
commit | db5360f3f4966c4586d072bd1440880773185b81 (patch) | |
tree | 2df90653f56aecf73f7c644e543888e872eb5da8 /unix-socket.h | |
parent | Sync with maint for l10n updates (diff) | |
download | tgif-db5360f3f4966c4586d072bd1440880773185b81.tar.xz |
name-hash: refactor polymorphic index_name_exists()
Depending upon the absence or presence of a trailing '/' on the incoming
pathname, index_name_exists() checks either if a file is present in the
index or if a directory is represented within the index. Each caller
explicitly chooses the mode of operation by adding or removing a
trailing '/' before invoking index_name_exists().
Since these two modes of operations are disjoint and have no code in
common (one searches index_state.name_hash; the other dir_hash), they
can be represented more naturally as distinct functions: one to search
for a file, and one for a directory.
Splitting index searching into two functions relieves callers of the
artificial burden of having to add or remove a slash to select the mode
of operation; instead they just call the desired function. A subsequent
patch will take advantage of this benefit in order to eliminate the
requirement that the incoming pathname for a directory search must have
a trailing slash.
(In order to avoid disturbing in-flight topics, index_name_exists() is
retained as a thin wrapper dispatching either to index_dir_exists() or
index_file_exists().)
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unix-socket.h')
0 files changed, 0 insertions, 0 deletions