Revert GIT_STATUS constants to avoid issues This reverts the changes to the GIT_STATUS constants and adds a new enumeration to describe the type of change in a git_diff_delta. I don't love this solution, but it should prevent strange errors from occurring for now. Eventually, I would like to unify the various status constants, but it needs a larger plan and I just wanted to eliminate this breakage quickly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 413de8d..0e7c02f 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -75,6 +75,20 @@ enum {
};
/**
+ * What type of change is described by a git_diff_delta?
+ */
+typedef enum {
+ GIT_DELTA_UNMODIFIED = 0,
+ GIT_DELTA_ADDED = 1,
+ GIT_DELTA_DELETED = 2,
+ GIT_DELTA_MODIFIED = 3,
+ GIT_DELTA_RENAMED = 4,
+ GIT_DELTA_COPIED = 5,
+ GIT_DELTA_IGNORED = 6,
+ GIT_DELTA_UNTRACKED = 7
+} git_delta_t;
+
+/**
* Description of one side of a diff.
*/
typedef struct {
@@ -101,7 +115,7 @@ typedef struct {
typedef struct {
git_diff_file old;
git_diff_file new;
- git_status_t status; /**< value from tree.h */
+ git_delta_t status;
unsigned int similarity; /**< for RENAMED and COPIED, value from 0 to 100 */
int binary;
} git_diff_delta;
diff --git a/include/git2/status.h b/include/git2/status.h
index 31823c6..5c45dae 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -31,7 +31,7 @@ GIT_BEGIN_DECL
#define GIT_STATUS_WT_MODIFIED (1 << 4)
#define GIT_STATUS_WT_DELETED (1 << 5)
-#define GIT_STATUS_WT_IGNORED (1 << 6)
+#define GIT_STATUS_IGNORED (1 << 6)
/**
* Gather file statuses and run a callback for each one.
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 95be1d3..972c379 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -314,15 +314,9 @@ enum git_treewalk_mode {
GIT_EXTERN(int) git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload);
typedef enum {
- GIT_STATUS_UNMODIFIED = 0,
GIT_STATUS_ADDED = 1,
GIT_STATUS_DELETED = 2,
GIT_STATUS_MODIFIED = 3,
- /* the following will only be generated by git_diff functions */
- GIT_STATUS_RENAMED = 4,
- GIT_STATUS_COPIED = 5,
- GIT_STATUS_IGNORED = 6,
- GIT_STATUS_UNTRACKED = 7
} git_status_t;
typedef struct {
diff --git a/src/diff.c b/src/diff.c
index dcc0aef..a0fd5fd 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -29,7 +29,7 @@ static void diff_delta__free(git_diff_delta *delta)
static git_diff_delta *diff_delta__alloc(
git_diff_list *diff,
- git_status_t status,
+ git_delta_t status,
const char *path)
{
git_diff_delta *delta = git__calloc(1, sizeof(git_diff_delta));
@@ -46,8 +46,8 @@ static git_diff_delta *diff_delta__alloc(
if (diff->opts.flags & GIT_DIFF_REVERSE) {
switch (status) {
- case GIT_STATUS_ADDED: status = GIT_STATUS_DELETED; break;
- case GIT_STATUS_DELETED: status = GIT_STATUS_ADDED; break;
+ case GIT_DELTA_ADDED: status = GIT_DELTA_DELETED; break;
+ case GIT_DELTA_DELETED: status = GIT_DELTA_ADDED; break;
default: break; /* leave other status values alone */
}
}
@@ -112,16 +112,16 @@ static git_diff_delta *diff_delta__merge_like_cgit(
* those choices so we can emulate the type of diff.
*/
if (git_oid_cmp(&dup->old.oid, &dup->new.oid) == 0) {
- if (dup->status == GIT_STATUS_DELETED)
+ if (dup->status == GIT_DELTA_DELETED)
/* preserve pending delete info */;
- else if (b->status == GIT_STATUS_UNTRACKED ||
- b->status == GIT_STATUS_IGNORED)
+ else if (b->status == GIT_DELTA_UNTRACKED ||
+ b->status == GIT_DELTA_IGNORED)
dup->status = b->status;
else
- dup->status = GIT_STATUS_UNMODIFIED;
+ dup->status = GIT_DELTA_UNMODIFIED;
}
- else if (dup->status == GIT_STATUS_UNMODIFIED ||
- b->status == GIT_STATUS_DELETED)
+ else if (dup->status == GIT_DELTA_UNMODIFIED ||
+ b->status == GIT_DELTA_DELETED)
dup->status = b->status;
return dup;
@@ -129,7 +129,7 @@ static git_diff_delta *diff_delta__merge_like_cgit(
static int diff_delta__from_one(
git_diff_list *diff,
- git_status_t status,
+ git_delta_t status,
const git_index_entry *entry)
{
int error;
@@ -138,9 +138,9 @@ static int diff_delta__from_one(
return git__rethrow(GIT_ENOMEM, "Could not allocate diff record");
/* This fn is just for single-sided diffs */
- assert(status != GIT_STATUS_MODIFIED);
+ assert(status != GIT_DELTA_MODIFIED);
- if (delta->status == GIT_STATUS_DELETED) {
+ if (delta->status == GIT_DELTA_DELETED) {
delta->old.mode = entry->mode;
delta->old.size = entry->file_size;
git_oid_cpy(&delta->old.oid, &entry->oid);
@@ -161,7 +161,7 @@ static int diff_delta__from_one(
static int diff_delta__from_two(
git_diff_list *diff,
- git_status_t status,
+ git_delta_t status,
const git_index_entry *old,
const git_index_entry *new,
git_oid *new_oid)
@@ -333,9 +333,9 @@ static int maybe_modified(
return GIT_SUCCESS;
if (GIT_MODE_TYPE(oitem->mode) != GIT_MODE_TYPE(nitem->mode)) {
- error = diff_delta__from_one(diff, GIT_STATUS_DELETED, oitem);
+ error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem);
if (error == GIT_SUCCESS)
- error = diff_delta__from_one(diff, GIT_STATUS_ADDED, nitem);
+ error = diff_delta__from_one(diff, GIT_DELTA_ADDED, nitem);
return error;
}
@@ -370,7 +370,7 @@ static int maybe_modified(
}
return diff_delta__from_two(
- diff, GIT_STATUS_MODIFIED, oitem, nitem, use_noid);
+ diff, GIT_DELTA_MODIFIED, oitem, nitem, use_noid);
}
static int diff_from_iterators(
@@ -401,7 +401,7 @@ static int diff_from_iterators(
/* create DELETED records for old items not matched in new */
if (oitem && (!nitem || strcmp(oitem->path, nitem->path) < 0)) {
- error = diff_delta__from_one(diff, GIT_STATUS_DELETED, oitem);
+ error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem);
if (error == GIT_SUCCESS)
error = git_iterator_advance(old, &oitem);
continue;
@@ -412,7 +412,7 @@ static int diff_from_iterators(
*/
if (nitem && (!oitem || strcmp(oitem->path, nitem->path) > 0)) {
int is_ignored;
- git_status_t use_status = GIT_STATUS_ADDED;
+ git_delta_t delta_type = GIT_DELTA_ADDED;
/* contained in ignored parent directory, so this can be skipped. */
if (ignore_prefix != NULL &&
@@ -431,14 +431,14 @@ static int diff_from_iterators(
error = git_iterator_advance_into_directory(new, &nitem);
continue;
}
- use_status = GIT_STATUS_UNTRACKED;
+ delta_type = GIT_DELTA_UNTRACKED;
}
else if (is_ignored)
- use_status = GIT_STATUS_IGNORED;
+ delta_type = GIT_DELTA_IGNORED;
else if (new->type == GIT_ITERATOR_WORKDIR)
- use_status = GIT_STATUS_UNTRACKED;
+ delta_type = GIT_DELTA_UNTRACKED;
- error = diff_delta__from_one(diff, use_status, nitem);
+ error = diff_delta__from_one(diff, delta_type, nitem);
if (error == GIT_SUCCESS)
error = git_iterator_advance(new, &nitem);
continue;
diff --git a/src/diff_output.c b/src/diff_output.c
index b800be9..8493518 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -309,14 +309,14 @@ int git_diff_foreach(
git_blob *old_blob = NULL, *new_blob = NULL;
git_map old_data, new_data;
- if (delta->status == GIT_STATUS_UNMODIFIED)
+ if (delta->status == GIT_DELTA_UNMODIFIED)
continue;
- if (delta->status == GIT_STATUS_IGNORED &&
+ if (delta->status == GIT_DELTA_IGNORED &&
(diff->opts.flags & GIT_DIFF_INCLUDE_IGNORED) == 0)
continue;
- if (delta->status == GIT_STATUS_UNTRACKED &&
+ if (delta->status == GIT_DELTA_UNTRACKED &&
(diff->opts.flags & GIT_DIFF_INCLUDE_UNTRACKED) == 0)
continue;
@@ -337,8 +337,8 @@ int git_diff_foreach(
/* map files */
if (delta->binary != 1 &&
(hunk_cb || line_cb) &&
- (delta->status == GIT_STATUS_DELETED ||
- delta->status == GIT_STATUS_MODIFIED))
+ (delta->status == GIT_DELTA_DELETED ||
+ delta->status == GIT_DELTA_MODIFIED))
{
if (diff->old_src == GIT_ITERATOR_WORKDIR)
error = get_workdir_content(diff->repo, &delta->old, &old_data);
@@ -351,8 +351,8 @@ int git_diff_foreach(
if (delta->binary != 1 &&
(hunk_cb || line_cb || git_oid_iszero(&delta->new.oid)) &&
- (delta->status == GIT_STATUS_ADDED ||
- delta->status == GIT_STATUS_MODIFIED))
+ (delta->status == GIT_DELTA_ADDED ||
+ delta->status == GIT_DELTA_MODIFIED))
{
if (diff->new_src == GIT_ITERATOR_WORKDIR)
error = get_workdir_content(diff->repo, &delta->new, &new_data);
@@ -372,7 +372,7 @@ int git_diff_foreach(
* incorrect status and need to skip this item.
*/
if (git_oid_cmp(&delta->old.oid, &delta->new.oid) == 0) {
- delta->status = GIT_STATUS_UNMODIFIED;
+ delta->status = GIT_DELTA_UNMODIFIED;
goto cleanup;
}
}
@@ -451,13 +451,13 @@ static int print_compact(void *data, git_diff_delta *delta, float progress)
GIT_UNUSED(progress);
switch (delta->status) {
- case GIT_STATUS_ADDED: code = 'A'; break;
- case GIT_STATUS_DELETED: code = 'D'; break;
- case GIT_STATUS_MODIFIED: code = 'M'; break;
- case GIT_STATUS_RENAMED: code = 'R'; break;
- case GIT_STATUS_COPIED: code = 'C'; break;
- case GIT_STATUS_IGNORED: code = 'I'; break;
- case GIT_STATUS_UNTRACKED: code = '?'; break;
+ case GIT_DELTA_ADDED: code = 'A'; break;
+ case GIT_DELTA_DELETED: code = 'D'; break;
+ case GIT_DELTA_MODIFIED: code = 'M'; break;
+ case GIT_DELTA_RENAMED: code = 'R'; break;
+ case GIT_DELTA_COPIED: code = 'C'; break;
+ case GIT_DELTA_IGNORED: code = 'I'; break;
+ case GIT_DELTA_UNTRACKED: code = '?'; break;
default: code = 0;
}
@@ -695,8 +695,8 @@ int git_diff_blobs(
/* populate a "fake" delta record */
delta.status = old.ptr ?
- (new.ptr ? GIT_STATUS_MODIFIED : GIT_STATUS_DELETED) :
- (new.ptr ? GIT_STATUS_ADDED : GIT_STATUS_UNTRACKED);
+ (new.ptr ? GIT_DELTA_MODIFIED : GIT_DELTA_DELETED) :
+ (new.ptr ? GIT_DELTA_ADDED : GIT_DELTA_UNTRACKED);
delta.old.mode = 0100644; /* can't know the truth from a blob alone */
delta.new.mode = 0100644;
git_oid_cpy(&delta.old.oid, git_object_id((const git_object *)old_blob));
diff --git a/src/status.c b/src/status.c
index 76ae831..106e500 100644
--- a/src/status.c
+++ b/src/status.c
@@ -131,7 +131,7 @@ static int status_entry_update_ignore(struct status_entry *e, git_ignores *ignor
if ((error = git_ignore__lookup(ignores, path, &ignored)) == GIT_SUCCESS &&
ignored)
e->status_flags =
- (e->status_flags & ~GIT_STATUS_WT_NEW) | GIT_STATUS_WT_IGNORED;
+ (e->status_flags & ~GIT_STATUS_WT_NEW) | GIT_STATUS_IGNORED;
return error;
}
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index 67a4f1c..d8eca7d 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -30,11 +30,11 @@ int diff_file_fn(
(void)progress;
e->files++;
switch (delta->status) {
- case GIT_STATUS_ADDED: e->file_adds++; break;
- case GIT_STATUS_DELETED: e->file_dels++; break;
- case GIT_STATUS_MODIFIED: e->file_mods++; break;
- case GIT_STATUS_IGNORED: e->file_ignored++; break;
- case GIT_STATUS_UNTRACKED: e->file_untracked++; break;
+ case GIT_DELTA_ADDED: e->file_adds++; break;
+ case GIT_DELTA_DELETED: e->file_dels++; break;
+ case GIT_DELTA_MODIFIED: e->file_mods++; break;
+ case GIT_DELTA_IGNORED: e->file_ignored++; break;
+ case GIT_DELTA_UNTRACKED: e->file_untracked++; break;
default: break;
}
return 0;
diff --git a/tests-clar/status/status_data.h b/tests-clar/status/status_data.h
index 719d841..1a68648 100644
--- a/tests-clar/status/status_data.h
+++ b/tests-clar/status/status_data.h
@@ -29,7 +29,7 @@ static const char *entry_paths0[] = {
static const unsigned int entry_statuses0[] = {
GIT_STATUS_WT_DELETED,
- GIT_STATUS_WT_IGNORED,
+ GIT_STATUS_IGNORED,
GIT_STATUS_WT_MODIFIED,
GIT_STATUS_WT_NEW,
GIT_STATUS_INDEX_MODIFIED,
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index f654b8a..132ec1f 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -120,7 +120,7 @@ void test_status_worktree__ignores(void)
cl_git_pass(
git_status_should_ignore(repo, entry_paths0[i], &ignored)
);
- cl_assert(ignored == (entry_statuses0[i] == GIT_STATUS_WT_IGNORED));
+ cl_assert(ignored == (entry_statuses0[i] == GIT_STATUS_IGNORED));
}
cl_git_pass(
diff --git a/tests/t18-status.c b/tests/t18-status.c
index aeadd5e..2b90ac6 100644
--- a/tests/t18-status.c
+++ b/tests/t18-status.c
@@ -83,7 +83,7 @@ static const char *entry_paths0[] = {
static const unsigned int entry_statuses0[] = {
GIT_STATUS_WT_DELETED,
- GIT_STATUS_WT_IGNORED,
+ GIT_STATUS_IGNORED,
GIT_STATUS_WT_MODIFIED,
GIT_STATUS_WT_NEW,
GIT_STATUS_INDEX_MODIFIED,
@@ -205,7 +205,7 @@ static const char *entry_paths2[] = {
static const unsigned int entry_statuses2[] = {
GIT_STATUS_WT_DELETED,
GIT_STATUS_WT_DELETED,
- GIT_STATUS_WT_IGNORED,
+ GIT_STATUS_IGNORED,
GIT_STATUS_WT_DELETED,
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
@@ -291,7 +291,7 @@ static const unsigned int entry_statuses3[] = {
GIT_STATUS_WT_NEW,
GIT_STATUS_WT_NEW,
GIT_STATUS_WT_DELETED,
- GIT_STATUS_WT_IGNORED,
+ GIT_STATUS_IGNORED,
GIT_STATUS_WT_MODIFIED,
GIT_STATUS_WT_NEW,
GIT_STATUS_INDEX_MODIFIED,