update-index: use enum for untracked cache options
Helped-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jan 24, 2016 at 16:28 UTC
113e6413187c65a9fbf2b845a1fb31c7d17c0755
1 file changed
+13
-5
builtin/update-index.c
+13
-5
@@ -35,6 +35,14 @@ static int mark_skip_worktree_only;
35
#define UNMARK_FLAG 2
36
static struct strbuf mtime_dir = STRBUF_INIT;
37
38
+/* Untracked cache mode */
39
+enum uc_mode {
40
+ UC_UNSPECIFIED = -1,
41
+ UC_DISABLE = 0,
42
+ UC_ENABLE,
43
+ UC_FORCE
44
+};
45
+
46
__attribute__((format (printf, 1, 2)))
47
static void report(const char *fmt, ...)
48
{
@@ -902,7 +910,7 @@ static int reupdate_callback(struct parse_opt_ctx_t *ctx,
910
int cmd_update_index(int argc, const char **argv, const char *prefix)
911
{
912
int newfd, entries, has_errors = 0, line_termination = '\n';
905
- int untracked_cache = -1;
913
+ enum uc_mode untracked_cache = UC_UNSPECIFIED;
914
int read_from_stdin = 0;
915
int prefix_length = prefix ? strlen(prefix) : 0;
916
int preferred_index_format = 0;
@@ -997,7 +1005,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1005
OPT_BOOL(0, "untracked-cache", &untracked_cache,
1006
N_("enable/disable untracked cache")),
1007
OPT_SET_INT(0, "force-untracked-cache", &untracked_cache,
1000
- N_("enable untracked cache without testing the filesystem"), 2),
1008
+ N_("enable untracked cache without testing the filesystem"), UC_FORCE),
1009
OPT_END()
1010
};
1011
@@ -1104,10 +1112,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1112
the_index.split_index = NULL;
1113
the_index.cache_changed |= SOMETHING_CHANGED;
1114
}
1107
- if (untracked_cache > 0) {
1115
+ if (untracked_cache > UC_DISABLE) {
1116
struct untracked_cache *uc;
1117
1110
- if (untracked_cache < 2) {
1118
+ if (untracked_cache < UC_FORCE) {
1119
setup_work_tree();
1120
if (!test_if_untracked_cache_is_supported())
1121
return 1;
@@ -1122,7 +1130,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1130
}
1131
add_untracked_ident(the_index.untracked);
1132
the_index.cache_changed |= UNTRACKED_CHANGED;
1125
- } else if (!untracked_cache && the_index.untracked) {
1133
+ } else if (untracked_cache == UC_DISABLE && the_index.untracked) {
1134
free_untracked_cache(the_index.untracked);
1135
the_index.untracked = NULL;
1136
the_index.cache_changed |= UNTRACKED_CHANGED;