Commit e1bcc191 by Russell Belfer

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.
parent c19bc93c
...@@ -75,6 +75,20 @@ enum { ...@@ -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. * Description of one side of a diff.
*/ */
typedef struct { typedef struct {
...@@ -101,7 +115,7 @@ typedef struct { ...@@ -101,7 +115,7 @@ typedef struct {
typedef struct { typedef struct {
git_diff_file old; git_diff_file old;
git_diff_file new; 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 */ unsigned int similarity; /**< for RENAMED and COPIED, value from 0 to 100 */
int binary; int binary;
} git_diff_delta; } git_diff_delta;
......
...@@ -31,7 +31,7 @@ GIT_BEGIN_DECL ...@@ -31,7 +31,7 @@ GIT_BEGIN_DECL
#define GIT_STATUS_WT_MODIFIED (1 << 4) #define GIT_STATUS_WT_MODIFIED (1 << 4)
#define GIT_STATUS_WT_DELETED (1 << 5) #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. * Gather file statuses and run a callback for each one.
......
...@@ -314,15 +314,9 @@ enum git_treewalk_mode { ...@@ -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); GIT_EXTERN(int) git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload);
typedef enum { typedef enum {
GIT_STATUS_UNMODIFIED = 0,
GIT_STATUS_ADDED = 1, GIT_STATUS_ADDED = 1,
GIT_STATUS_DELETED = 2, GIT_STATUS_DELETED = 2,
GIT_STATUS_MODIFIED = 3, 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; } git_status_t;
typedef struct { typedef struct {
......
...@@ -29,7 +29,7 @@ static void diff_delta__free(git_diff_delta *delta) ...@@ -29,7 +29,7 @@ static void diff_delta__free(git_diff_delta *delta)
static git_diff_delta *diff_delta__alloc( static git_diff_delta *diff_delta__alloc(
git_diff_list *diff, git_diff_list *diff,
git_status_t status, git_delta_t status,
const char *path) const char *path)
{ {
git_diff_delta *delta = git__calloc(1, sizeof(git_diff_delta)); git_diff_delta *delta = git__calloc(1, sizeof(git_diff_delta));
...@@ -46,8 +46,8 @@ static git_diff_delta *diff_delta__alloc( ...@@ -46,8 +46,8 @@ static git_diff_delta *diff_delta__alloc(
if (diff->opts.flags & GIT_DIFF_REVERSE) { if (diff->opts.flags & GIT_DIFF_REVERSE) {
switch (status) { switch (status) {
case GIT_STATUS_ADDED: status = GIT_STATUS_DELETED; break; case GIT_DELTA_ADDED: status = GIT_DELTA_DELETED; break;
case GIT_STATUS_DELETED: status = GIT_STATUS_ADDED; break; case GIT_DELTA_DELETED: status = GIT_DELTA_ADDED; break;
default: break; /* leave other status values alone */ default: break; /* leave other status values alone */
} }
} }
...@@ -112,16 +112,16 @@ static git_diff_delta *diff_delta__merge_like_cgit( ...@@ -112,16 +112,16 @@ static git_diff_delta *diff_delta__merge_like_cgit(
* those choices so we can emulate the type of diff. * those choices so we can emulate the type of diff.
*/ */
if (git_oid_cmp(&dup->old.oid, &dup->new.oid) == 0) { 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 */; /* preserve pending delete info */;
else if (b->status == GIT_STATUS_UNTRACKED || else if (b->status == GIT_DELTA_UNTRACKED ||
b->status == GIT_STATUS_IGNORED) b->status == GIT_DELTA_IGNORED)
dup->status = b->status; dup->status = b->status;
else else
dup->status = GIT_STATUS_UNMODIFIED; dup->status = GIT_DELTA_UNMODIFIED;
} }
else if (dup->status == GIT_STATUS_UNMODIFIED || else if (dup->status == GIT_DELTA_UNMODIFIED ||
b->status == GIT_STATUS_DELETED) b->status == GIT_DELTA_DELETED)
dup->status = b->status; dup->status = b->status;
return dup; return dup;
...@@ -129,7 +129,7 @@ static git_diff_delta *diff_delta__merge_like_cgit( ...@@ -129,7 +129,7 @@ static git_diff_delta *diff_delta__merge_like_cgit(
static int diff_delta__from_one( static int diff_delta__from_one(
git_diff_list *diff, git_diff_list *diff,
git_status_t status, git_delta_t status,
const git_index_entry *entry) const git_index_entry *entry)
{ {
int error; int error;
...@@ -138,9 +138,9 @@ static int diff_delta__from_one( ...@@ -138,9 +138,9 @@ static int diff_delta__from_one(
return git__rethrow(GIT_ENOMEM, "Could not allocate diff record"); return git__rethrow(GIT_ENOMEM, "Could not allocate diff record");
/* This fn is just for single-sided diffs */ /* 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.mode = entry->mode;
delta->old.size = entry->file_size; delta->old.size = entry->file_size;
git_oid_cpy(&delta->old.oid, &entry->oid); git_oid_cpy(&delta->old.oid, &entry->oid);
...@@ -161,7 +161,7 @@ static int diff_delta__from_one( ...@@ -161,7 +161,7 @@ static int diff_delta__from_one(
static int diff_delta__from_two( static int diff_delta__from_two(
git_diff_list *diff, git_diff_list *diff,
git_status_t status, git_delta_t status,
const git_index_entry *old, const git_index_entry *old,
const git_index_entry *new, const git_index_entry *new,
git_oid *new_oid) git_oid *new_oid)
...@@ -333,9 +333,9 @@ static int maybe_modified( ...@@ -333,9 +333,9 @@ static int maybe_modified(
return GIT_SUCCESS; return GIT_SUCCESS;
if (GIT_MODE_TYPE(oitem->mode) != GIT_MODE_TYPE(nitem->mode)) { 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) 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; return error;
} }
...@@ -370,7 +370,7 @@ static int maybe_modified( ...@@ -370,7 +370,7 @@ static int maybe_modified(
} }
return diff_delta__from_two( 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( static int diff_from_iterators(
...@@ -401,7 +401,7 @@ static int diff_from_iterators( ...@@ -401,7 +401,7 @@ static int diff_from_iterators(
/* create DELETED records for old items not matched in new */ /* create DELETED records for old items not matched in new */
if (oitem && (!nitem || strcmp(oitem->path, nitem->path) < 0)) { 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) if (error == GIT_SUCCESS)
error = git_iterator_advance(old, &oitem); error = git_iterator_advance(old, &oitem);
continue; continue;
...@@ -412,7 +412,7 @@ static int diff_from_iterators( ...@@ -412,7 +412,7 @@ static int diff_from_iterators(
*/ */
if (nitem && (!oitem || strcmp(oitem->path, nitem->path) > 0)) { if (nitem && (!oitem || strcmp(oitem->path, nitem->path) > 0)) {
int is_ignored; 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. */ /* contained in ignored parent directory, so this can be skipped. */
if (ignore_prefix != NULL && if (ignore_prefix != NULL &&
...@@ -431,14 +431,14 @@ static int diff_from_iterators( ...@@ -431,14 +431,14 @@ static int diff_from_iterators(
error = git_iterator_advance_into_directory(new, &nitem); error = git_iterator_advance_into_directory(new, &nitem);
continue; continue;
} }
use_status = GIT_STATUS_UNTRACKED; delta_type = GIT_DELTA_UNTRACKED;
} }
else if (is_ignored) else if (is_ignored)
use_status = GIT_STATUS_IGNORED; delta_type = GIT_DELTA_IGNORED;
else if (new->type == GIT_ITERATOR_WORKDIR) 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) if (error == GIT_SUCCESS)
error = git_iterator_advance(new, &nitem); error = git_iterator_advance(new, &nitem);
continue; continue;
......
...@@ -309,14 +309,14 @@ int git_diff_foreach( ...@@ -309,14 +309,14 @@ int git_diff_foreach(
git_blob *old_blob = NULL, *new_blob = NULL; git_blob *old_blob = NULL, *new_blob = NULL;
git_map old_data, new_data; git_map old_data, new_data;
if (delta->status == GIT_STATUS_UNMODIFIED) if (delta->status == GIT_DELTA_UNMODIFIED)
continue; continue;
if (delta->status == GIT_STATUS_IGNORED && if (delta->status == GIT_DELTA_IGNORED &&
(diff->opts.flags & GIT_DIFF_INCLUDE_IGNORED) == 0) (diff->opts.flags & GIT_DIFF_INCLUDE_IGNORED) == 0)
continue; continue;
if (delta->status == GIT_STATUS_UNTRACKED && if (delta->status == GIT_DELTA_UNTRACKED &&
(diff->opts.flags & GIT_DIFF_INCLUDE_UNTRACKED) == 0) (diff->opts.flags & GIT_DIFF_INCLUDE_UNTRACKED) == 0)
continue; continue;
...@@ -337,8 +337,8 @@ int git_diff_foreach( ...@@ -337,8 +337,8 @@ int git_diff_foreach(
/* map files */ /* map files */
if (delta->binary != 1 && if (delta->binary != 1 &&
(hunk_cb || line_cb) && (hunk_cb || line_cb) &&
(delta->status == GIT_STATUS_DELETED || (delta->status == GIT_DELTA_DELETED ||
delta->status == GIT_STATUS_MODIFIED)) delta->status == GIT_DELTA_MODIFIED))
{ {
if (diff->old_src == GIT_ITERATOR_WORKDIR) if (diff->old_src == GIT_ITERATOR_WORKDIR)
error = get_workdir_content(diff->repo, &delta->old, &old_data); error = get_workdir_content(diff->repo, &delta->old, &old_data);
...@@ -351,8 +351,8 @@ int git_diff_foreach( ...@@ -351,8 +351,8 @@ int git_diff_foreach(
if (delta->binary != 1 && if (delta->binary != 1 &&
(hunk_cb || line_cb || git_oid_iszero(&delta->new.oid)) && (hunk_cb || line_cb || git_oid_iszero(&delta->new.oid)) &&
(delta->status == GIT_STATUS_ADDED || (delta->status == GIT_DELTA_ADDED ||
delta->status == GIT_STATUS_MODIFIED)) delta->status == GIT_DELTA_MODIFIED))
{ {
if (diff->new_src == GIT_ITERATOR_WORKDIR) if (diff->new_src == GIT_ITERATOR_WORKDIR)
error = get_workdir_content(diff->repo, &delta->new, &new_data); error = get_workdir_content(diff->repo, &delta->new, &new_data);
...@@ -372,7 +372,7 @@ int git_diff_foreach( ...@@ -372,7 +372,7 @@ int git_diff_foreach(
* incorrect status and need to skip this item. * incorrect status and need to skip this item.
*/ */
if (git_oid_cmp(&delta->old.oid, &delta->new.oid) == 0) { if (git_oid_cmp(&delta->old.oid, &delta->new.oid) == 0) {
delta->status = GIT_STATUS_UNMODIFIED; delta->status = GIT_DELTA_UNMODIFIED;
goto cleanup; goto cleanup;
} }
} }
...@@ -451,13 +451,13 @@ static int print_compact(void *data, git_diff_delta *delta, float progress) ...@@ -451,13 +451,13 @@ static int print_compact(void *data, git_diff_delta *delta, float progress)
GIT_UNUSED(progress); GIT_UNUSED(progress);
switch (delta->status) { switch (delta->status) {
case GIT_STATUS_ADDED: code = 'A'; break; case GIT_DELTA_ADDED: code = 'A'; break;
case GIT_STATUS_DELETED: code = 'D'; break; case GIT_DELTA_DELETED: code = 'D'; break;
case GIT_STATUS_MODIFIED: code = 'M'; break; case GIT_DELTA_MODIFIED: code = 'M'; break;
case GIT_STATUS_RENAMED: code = 'R'; break; case GIT_DELTA_RENAMED: code = 'R'; break;
case GIT_STATUS_COPIED: code = 'C'; break; case GIT_DELTA_COPIED: code = 'C'; break;
case GIT_STATUS_IGNORED: code = 'I'; break; case GIT_DELTA_IGNORED: code = 'I'; break;
case GIT_STATUS_UNTRACKED: code = '?'; break; case GIT_DELTA_UNTRACKED: code = '?'; break;
default: code = 0; default: code = 0;
} }
...@@ -695,8 +695,8 @@ int git_diff_blobs( ...@@ -695,8 +695,8 @@ int git_diff_blobs(
/* populate a "fake" delta record */ /* populate a "fake" delta record */
delta.status = old.ptr ? delta.status = old.ptr ?
(new.ptr ? GIT_STATUS_MODIFIED : GIT_STATUS_DELETED) : (new.ptr ? GIT_DELTA_MODIFIED : GIT_DELTA_DELETED) :
(new.ptr ? GIT_STATUS_ADDED : GIT_STATUS_UNTRACKED); (new.ptr ? GIT_DELTA_ADDED : GIT_DELTA_UNTRACKED);
delta.old.mode = 0100644; /* can't know the truth from a blob alone */ delta.old.mode = 0100644; /* can't know the truth from a blob alone */
delta.new.mode = 0100644; delta.new.mode = 0100644;
git_oid_cpy(&delta.old.oid, git_object_id((const git_object *)old_blob)); git_oid_cpy(&delta.old.oid, git_object_id((const git_object *)old_blob));
......
...@@ -131,7 +131,7 @@ static int status_entry_update_ignore(struct status_entry *e, git_ignores *ignor ...@@ -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 && if ((error = git_ignore__lookup(ignores, path, &ignored)) == GIT_SUCCESS &&
ignored) ignored)
e->status_flags = 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; return error;
} }
......
...@@ -30,11 +30,11 @@ int diff_file_fn( ...@@ -30,11 +30,11 @@ int diff_file_fn(
(void)progress; (void)progress;
e->files++; e->files++;
switch (delta->status) { switch (delta->status) {
case GIT_STATUS_ADDED: e->file_adds++; break; case GIT_DELTA_ADDED: e->file_adds++; break;
case GIT_STATUS_DELETED: e->file_dels++; break; case GIT_DELTA_DELETED: e->file_dels++; break;
case GIT_STATUS_MODIFIED: e->file_mods++; break; case GIT_DELTA_MODIFIED: e->file_mods++; break;
case GIT_STATUS_IGNORED: e->file_ignored++; break; case GIT_DELTA_IGNORED: e->file_ignored++; break;
case GIT_STATUS_UNTRACKED: e->file_untracked++; break; case GIT_DELTA_UNTRACKED: e->file_untracked++; break;
default: break; default: break;
} }
return 0; return 0;
......
...@@ -29,7 +29,7 @@ static const char *entry_paths0[] = { ...@@ -29,7 +29,7 @@ static const char *entry_paths0[] = {
static const unsigned int entry_statuses0[] = { static const unsigned int entry_statuses0[] = {
GIT_STATUS_WT_DELETED, GIT_STATUS_WT_DELETED,
GIT_STATUS_WT_IGNORED, GIT_STATUS_IGNORED,
GIT_STATUS_WT_MODIFIED, GIT_STATUS_WT_MODIFIED,
GIT_STATUS_WT_NEW, GIT_STATUS_WT_NEW,
GIT_STATUS_INDEX_MODIFIED, GIT_STATUS_INDEX_MODIFIED,
......
...@@ -120,7 +120,7 @@ void test_status_worktree__ignores(void) ...@@ -120,7 +120,7 @@ void test_status_worktree__ignores(void)
cl_git_pass( cl_git_pass(
git_status_should_ignore(repo, entry_paths0[i], &ignored) 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( cl_git_pass(
......
...@@ -83,7 +83,7 @@ static const char *entry_paths0[] = { ...@@ -83,7 +83,7 @@ static const char *entry_paths0[] = {
static const unsigned int entry_statuses0[] = { static const unsigned int entry_statuses0[] = {
GIT_STATUS_WT_DELETED, GIT_STATUS_WT_DELETED,
GIT_STATUS_WT_IGNORED, GIT_STATUS_IGNORED,
GIT_STATUS_WT_MODIFIED, GIT_STATUS_WT_MODIFIED,
GIT_STATUS_WT_NEW, GIT_STATUS_WT_NEW,
GIT_STATUS_INDEX_MODIFIED, GIT_STATUS_INDEX_MODIFIED,
...@@ -205,7 +205,7 @@ static const char *entry_paths2[] = { ...@@ -205,7 +205,7 @@ static const char *entry_paths2[] = {
static const unsigned int entry_statuses2[] = { static const unsigned int entry_statuses2[] = {
GIT_STATUS_WT_DELETED, GIT_STATUS_WT_DELETED,
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_WT_DELETED | GIT_STATUS_INDEX_MODIFIED, GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
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[] = { ...@@ -291,7 +291,7 @@ static const unsigned int entry_statuses3[] = {
GIT_STATUS_WT_NEW, GIT_STATUS_WT_NEW,
GIT_STATUS_WT_NEW, GIT_STATUS_WT_NEW,
GIT_STATUS_WT_DELETED, GIT_STATUS_WT_DELETED,
GIT_STATUS_WT_IGNORED, GIT_STATUS_IGNORED,
GIT_STATUS_WT_MODIFIED, GIT_STATUS_WT_MODIFIED,
GIT_STATUS_WT_NEW, GIT_STATUS_WT_NEW,
GIT_STATUS_INDEX_MODIFIED, GIT_STATUS_INDEX_MODIFIED,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment