summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 30b0535)
raw | patch | inline | side by side (parent: 30b0535)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 25 Jul 2005 20:05:44 +0000 (13:05 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 26 Jul 2005 00:15:34 +0000 (17:15 -0700) |
Both Cogito and StGIT prefer to see 'A' for new files. The
current 'N' is visually harder to distinguish from 'M', which is
used for modified files. Prepare the internals to use symbolic
constants to make the change easier.
Signed-off-by: Junio C Hamano <junkio@cox.net>
current 'N' is visually harder to distinguish from 'M', which is
used for modified files. Prepare the internals to use symbolic
constants to make the change easier.
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff-helper.c | patch | blob | history | |
diff.c | patch | blob | history | |
diff.h | patch | blob | history |
diff --git a/diff-helper.c b/diff-helper.c
index 6649fb548f798c84342168b8ef9fe9211093fbfc..07ccd7cc38d02843d339a9feb21088912f63dcba 100644 (file)
--- a/diff-helper.c
+++ b/diff-helper.c
if (!strchr("MCRNDU", status))
break;
two_paths = score = 0;
- if (status == 'R' || status == 'C')
+ if (status == DIFF_STATUS_RENAMED ||
+ status == DIFF_STATUS_COPIED)
two_paths = 1;
/* pick up score if exists */
index 3cb41c533313fdd70b3f13858c68032aeb08062a..4a4b62191284a2289631c01b3a2885387f59a8c0 100644 (file)
--- a/diff.c
+++ b/diff.c
other = (strcmp(name, p->two->path) ? p->two->path : NULL);
one = p->one; two = p->two;
switch (p->status) {
- case 'C':
+ case DIFF_STATUS_COPIED:
sprintf(msg_,
"similarity index %d%%\n"
"copy from %s\n"
name, other);
xfrm_msg = msg_;
break;
- case 'R':
+ case DIFF_STATUS_RENAMED:
sprintf(msg_,
"similarity index %d%%\n"
"rename from %s\n"
name, other);
xfrm_msg = msg_;
break;
- case 'M':
+ case DIFF_STATUS_MODIFIED:
if (p->score) {
sprintf(msg_,
"dissimilarity index %d%%",
status[1] = 0;
}
switch (p->status) {
- case 'C': case 'R':
+ case DIFF_STATUS_COPIED:
+ case DIFF_STATUS_RENAMED:
two_paths = 1;
break;
- case 'N': case 'D':
+ case DIFF_STATUS_ADDED:
+ case DIFF_STATUS_DELETED:
two_paths = 0;
break;
default:
p = q->queue[i];
p->status = 0; /* undecided */
if (DIFF_PAIR_UNMERGED(p))
- p->status = 'U';
+ p->status = DIFF_STATUS_UNMERGED;
else if (!DIFF_FILE_VALID(p->one))
- p->status = 'N';
+ p->status = DIFF_STATUS_ADDED;
else if (!DIFF_FILE_VALID(p->two))
- p->status = 'D';
+ p->status = DIFF_STATUS_DELETED;
else if (DIFF_PAIR_TYPE_CHANGED(p))
- p->status = 'T';
+ p->status = DIFF_STATUS_TYPE_CHANGED;
/* from this point on, we are dealing with a pair
* whose both sides are valid and of the same type, i.e.
*/
else if (DIFF_PAIR_RENAME(p)) {
if (p->source_stays) {
- p->status = 'C';
+ p->status = DIFF_STATUS_COPIED;
continue;
}
/* See if there is some other filepair that
if (!DIFF_PAIR_RENAME(pp))
continue; /* not a rename/copy */
/* pp is a rename/copy from the same source */
- p->status = 'C';
+ p->status = DIFF_STATUS_COPIED;
break;
}
if (!p->status)
- p->status = 'R';
+ p->status = DIFF_STATUS_RENAMED;
}
else if (memcmp(p->one->sha1, p->two->sha1, 20) ||
p->one->mode != p->two->mode)
- p->status = 'M';
+ p->status = DIFF_STATUS_MODIFIED;
else {
/* This is a "no-change" entry and should not
* happen anymore, but prepare for broken callers.
*/
error("feeding unmodified %s to diffcore",
p->one->path);
- p->status = 'X';
+ p->status = DIFF_STATUS_UNKNOWN;
}
}
diff_debug_queue("resolve-rename-copy done", q);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
if ((diff_output_style == DIFF_FORMAT_NO_OUTPUT) ||
- (p->status == 'X'))
+ (p->status == DIFF_STATUS_UNKNOWN))
continue;
if (p->status == 0)
die("internal error in diff-resolve-rename-copy");
if (!filter)
return;
- if (strchr(filter, 'A')) {
- /* All-or-none */
+ if (strchr(filter, DIFF_STATUS_FILTER_AON)) {
int found;
for (i = found = 0; !found && i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
- if (((p->status == 'M') &&
- ((p->score && strchr(filter, 'B')) ||
- (!p->score && strchr(filter, 'M')))) ||
- ((p->status != 'M') && strchr(filter, p->status)))
+ if (((p->status == DIFF_STATUS_MODIFIED) &&
+ ((p->score &&
+ strchr(filter, DIFF_STATUS_FILTER_BROKEN)) ||
+ (!p->score &&
+ strchr(filter, DIFF_STATUS_MODIFIED)))) ||
+ ((p->status != DIFF_STATUS_MODIFIED) &&
+ strchr(filter, p->status)))
found++;
}
if (found)
/* Only the matching ones */
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
- if (((p->status == 'M') &&
- ((p->score && strchr(filter, 'B')) ||
- (!p->score && strchr(filter, 'M')))) ||
- ((p->status != 'M') && strchr(filter, p->status)))
+
+ if (((p->status == DIFF_STATUS_MODIFIED) &&
+ ((p->score &&
+ strchr(filter, DIFF_STATUS_FILTER_BROKEN)) ||
+ (!p->score &&
+ strchr(filter, DIFF_STATUS_MODIFIED)))) ||
+ ((p->status != DIFF_STATUS_MODIFIED) &&
+ strchr(filter, p->status)))
diff_q(&outq, p);
else
diff_free_filepair(p);
index e0a3207a62eab9c72d74e3b15cfae660fbcdaa66..aebf3f1ab52c75e09e3a7da0a663cf12f68d197e 100644 (file)
--- a/diff.h
+++ b/diff.h
extern void diff_flush(int output_style, int line_terminator);
+/* diff-raw status letters */
+#define DIFF_STATUS_ADDED 'N'
+#define DIFF_STATUS_COPIED 'C'
+#define DIFF_STATUS_DELETED 'D'
+#define DIFF_STATUS_MODIFIED 'M'
+#define DIFF_STATUS_RENAMED 'R'
+#define DIFF_STATUS_TYPE_CHANGED 'T'
+#define DIFF_STATUS_UNKNOWN 'X'
+#define DIFF_STATUS_UNMERGED 'U'
+
+/* these are not diff-raw status letters proper, but used by
+ * diffcore-filter insn to specify additional restrictions.
+ */
+#define DIFF_STATUS_FILTER_AON 'A'
+#define DIFF_STATUS_FILTER_BROKEN 'B'
+
#endif /* DIFF_H */