diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/diff.c | 20 | ||||
-rw-r--r-- | src/diff.h | 5 | ||||
-rw-r--r-- | src/iterator.c | 5 | ||||
-rw-r--r-- | src/iterator.h | 4 | ||||
-rw-r--r-- | src/status.c | 29 | ||||
-rw-r--r-- | src/util.h | 8 |
6 files changed, 36 insertions, 35 deletions
diff --git a/src/diff.c b/src/diff.c index caed8bf40..8b7433c62 100644 --- a/src/diff.c +++ b/src/diff.c @@ -14,6 +14,7 @@ #include "index.h" #include "odb.h" #include "submodule.h" +#include "trace.h" #define DIFF_FLAG_IS_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) != 0) #define DIFF_FLAG_ISNT_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) == 0) @@ -554,8 +555,7 @@ int git_diff__oid_for_entry( if (!entry.mode) { struct stat st; - GIT_PERF_INC(diff->stat_calls); - + git_trace(GIT_TRACE_TRACE, "stat=1"); if (p_stat(full_path.ptr, &st) < 0) { error = git_path_set_error(errno, entry.path, "stat"); git_buf_free(&full_path); @@ -570,8 +570,7 @@ int git_diff__oid_for_entry( if (S_ISGITLINK(entry.mode)) { git_submodule *sm; - GIT_PERF_INC(diff->submodule_lookups); - + git_trace(GIT_TRACE_TRACE, "submodule_lookup=1"); if (!git_submodule_lookup(&sm, diff->repo, entry.path)) { const git_oid *sm_oid = git_submodule_wd_id(sm); if (sm_oid) @@ -584,7 +583,7 @@ int git_diff__oid_for_entry( giterr_clear(); } } else if (S_ISLNK(entry.mode)) { - GIT_PERF_INC(diff->oid_calculations); + git_trace(GIT_TRACE_TRACE, "oid_calculation=1"); error = git_odb__hashlink(out, full_path.ptr); } else if (!git__is_sizet(entry.file_size)) { giterr_set(GITERR_OS, "File size overflow (for 32-bits) on '%s'", @@ -597,7 +596,7 @@ int git_diff__oid_for_entry( if (fd < 0) error = fd; else { - GIT_PERF_INC(diff->oid_calculations); + git_trace(GIT_TRACE_TRACE, "oid_calculation=1"); error = git_odb__hashfd_filtered( out, fd, (size_t)entry.file_size, GIT_OBJ_BLOB, fl); p_close(fd); @@ -656,7 +655,7 @@ static int maybe_modified_submodule( ign == GIT_SUBMODULE_IGNORE_ALL) return 0; - GIT_PERF_INC(diff->submodule_lookups); + git_trace(GIT_TRACE_TRACE, "submodule_lookup=1"); if ((error = git_submodule_lookup( &sub, diff->repo, info->nitem->path)) < 0) { @@ -966,7 +965,7 @@ static int handle_unmatched_new_item( delta_type = GIT_DELTA_ADDED; else if (nitem->mode == GIT_FILEMODE_COMMIT) { - GIT_PERF_INC(diff->submodule_lookups); + git_trace(GIT_TRACE_TRACE, "submodule_lookup=1"); /* ignore things that are not actual submodules */ if (git_submodule_lookup(NULL, info->repo, nitem->path) != 0) { @@ -1120,11 +1119,6 @@ int git_diff__from_iterators( error = 0; } - GIT_PERF_ADD(diff->stat_calls, old_iter->stat_calls); - GIT_PERF_ADD(diff->stat_calls, new_iter->stat_calls); - GIT_PERF_ADD(diff->submodule_lookups, old_iter->submodule_lookups); - GIT_PERF_ADD(diff->submodule_lookups, new_iter->submodule_lookups); - cleanup: if (!error) *diff_ptr = diff; diff --git a/src/diff.h b/src/diff.h index b2b7dba70..2e7ce0b7d 100644 --- a/src/diff.h +++ b/src/diff.h @@ -62,11 +62,6 @@ struct git_diff { git_iterator_type_t old_src; git_iterator_type_t new_src; uint32_t diffcaps; -#ifdef GIT_PERF - size_t stat_calls; - size_t oid_calculations; - size_t submodule_lookups; -#endif int (*strcomp)(const char *, const char *); int (*strncomp)(const char *, const char *, size_t); diff --git a/src/iterator.c b/src/iterator.c index 03058b956..bebdeba84 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -11,6 +11,7 @@ #include "ignore.h" #include "buffer.h" #include "submodule.h" +#include "trace.h" #include <ctype.h> #define ITERATOR_SET_CB(P,NAME_LC) do { \ @@ -1017,7 +1018,7 @@ static int fs_iterator__expand_dir(fs_iterator *fi) return GIT_ENOTFOUND; } - GIT_PERF_ADD(fi->base.stat_calls, ff->entries.length); + git_trace(GIT_TRACE_TRACE, "stat=%ld", (long)ff->entries.length); fs_iterator__seek_frame_start(fi, ff); @@ -1309,7 +1310,7 @@ static int workdir_iterator__enter_dir(fs_iterator *fi) if (!S_ISDIR(entry->st.st_mode) || !strcmp(GIT_DIR, entry->path)) continue; - GIT_PERF_INC(fi->base.submodule_lookups); + git_trace(GIT_TRACE_TRACE, "submodule_lookup=1"); if (git_submodule__is_submodule(fi->base.repo, entry->path)) { entry->st.st_mode = GIT_FILEMODE_COMMIT; entry->path_len--; diff --git a/src/iterator.h b/src/iterator.h index 2968b8c0c..ba9c1e486 100644 --- a/src/iterator.h +++ b/src/iterator.h @@ -53,10 +53,6 @@ struct git_iterator { char *end; int (*prefixcomp)(const char *str, const char *prefix); unsigned int flags; -#ifdef GIT_PERF - size_t stat_calls; - size_t submodule_lookups; -#endif }; extern int git_iterator_for_nothing( diff --git a/src/status.c b/src/status.c index e1f8e06ae..e418cf7b6 100644 --- a/src/status.c +++ b/src/status.c @@ -225,6 +225,28 @@ static git_status_list *git_status_list_alloc(git_index *index) return status; } +static int status_validate_options(const git_status_options *opts) +{ + if (!opts) + return 0; + + GITERR_CHECK_VERSION(opts, GIT_STATUS_OPTIONS_VERSION, "git_status_options"); + + if (opts->show > GIT_STATUS_SHOW_WORKDIR_ONLY) { + giterr_set(GITERR_INVALID, "Unknown status 'show' option"); + return -1; + } + + if ((opts->flags & GIT_STATUS_OPT_NO_REFRESH) != 0 && + (opts->flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0) { + giterr_set(GITERR_INVALID, "Updating index from status " + "is not allowed when index refresh is disabled"); + return -1; + } + + return 0; +} + int git_status_list_new( git_status_list **out, git_repository *repo, @@ -240,11 +262,10 @@ int git_status_list_new( int error = 0; unsigned int flags = opts ? opts->flags : GIT_STATUS_OPT_DEFAULTS; - assert(show <= GIT_STATUS_SHOW_WORKDIR_ONLY); - *out = NULL; - GITERR_CHECK_VERSION(opts, GIT_STATUS_OPTIONS_VERSION, "git_status_options"); + if (status_validate_options(opts) < 0) + return -1; if ((error = git_repository__ensure_not_bare(repo, "status")) < 0 || (error = git_repository_index(&index, repo)) < 0) @@ -287,6 +308,8 @@ int git_status_list_new( diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_IGNORED_DIRS; if ((flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES) != 0) diffopt.flags = diffopt.flags | GIT_DIFF_IGNORE_SUBMODULES; + if ((flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0) + diffopt.flags = diffopt.flags | GIT_DIFF_UPDATE_INDEX; if ((flags & GIT_STATUS_OPT_RENAMES_FROM_REWRITES) != 0) findopt.flags = findopt.flags | diff --git a/src/util.h b/src/util.h index be7a16ef8..6fb2dc0f4 100644 --- a/src/util.h +++ b/src/util.h @@ -436,12 +436,4 @@ GIT_INLINE(double) git__timer(void) #endif -#ifdef GIT_PERF -# define GIT_PERF_INC(counter) (counter)++ -# define GIT_PERF_ADD(counter,val) (counter) += (val) -#else -# define GIT_PERF_INC(counter) 0 -# define GIT_PERF_ADD(counter,val) 0 -#endif - #endif /* INCLUDE_util_h__ */ |