git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Petr Baudis <pasky@suse.cz>, Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 1/2] Use symbolic constants for diff-raw status indicators.
Date: Mon, 25 Jul 2005 17:20:48 -0700	[thread overview]
Message-ID: <7vd5p6fme7.fsf_-_@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vpst6fmif.fsf_-_@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Mon, 25 Jul 2005 17:18:16 -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>
---

 diff-helper.c |    3 ++-
 diff.c        |   58 ++++++++++++++++++++++++++++++++-------------------------
 diff.h        |   16 ++++++++++++++++
 3 files changed, 51 insertions(+), 26 deletions(-)

e7baa4f45f4420a6d2da6a13e8959f8405c3ea19
diff --git a/diff-helper.c b/diff-helper.c
--- a/diff-helper.c
+++ b/diff-helper.c
@@ -94,7 +94,8 @@ int main(int ac, const char **av) {
 			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 */
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -617,7 +617,7 @@ static void run_diff(struct diff_filepai
 	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"
@@ -626,7 +626,7 @@ static void run_diff(struct diff_filepai
 			name, other);
 		xfrm_msg = msg_;
 		break;
-	case 'R':
+	case DIFF_STATUS_RENAMED:
 		sprintf(msg_,
 			"similarity index %d%%\n"
 			"rename from %s\n"
@@ -635,7 +635,7 @@ static void run_diff(struct diff_filepai
 			name, other);
 		xfrm_msg = msg_;
 		break;
-	case 'M':
+	case DIFF_STATUS_MODIFIED:
 		if (p->score) {
 			sprintf(msg_,
 				"dissimilarity index %d%%",
@@ -796,10 +796,12 @@ static void diff_flush_raw(struct diff_f
 		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:
@@ -928,13 +930,13 @@ static void diff_resolve_rename_copy(voi
 		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.
@@ -942,7 +944,7 @@ static void diff_resolve_rename_copy(voi
 		 */
 		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
@@ -956,22 +958,22 @@ static void diff_resolve_rename_copy(voi
 				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);
@@ -989,7 +991,7 @@ void diff_flush(int diff_output_style, i
 	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");
@@ -1024,15 +1026,17 @@ static void diffcore_apply_filter(const 
 	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)
@@ -1050,10 +1054,14 @@ static void diffcore_apply_filter(const 
 		/* 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);
diff --git a/diff.h b/diff.h
--- a/diff.h
+++ b/diff.h
@@ -82,4 +82,20 @@ extern int diff_queue_is_empty(void);
 
 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 */

  reply	other threads:[~2005-07-26  0:22 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-21 20:23 [PATCH 1/1] Tell vim the textwidth is 75 Bryan larsen
2005-07-22  2:50 ` Junio C Hamano
2005-07-22 10:37   ` Catalin Marinas
2005-07-22 19:24     ` Sam Ravnborg
2005-07-22 20:39       ` Junio C Hamano
2005-07-22 20:59         ` Petr Baudis
2005-07-24 22:49           ` [RFC] extending git-ls-files --exclude Junio C Hamano
2005-07-24 22:50             ` [PATCH] git-ls-files: --exclude mechanism updates Junio C Hamano
2005-07-24 22:51             ` [PATCH] Documentation: describe git-ls-files --exclude patterns Junio C Hamano
2005-07-25  9:19             ` [RFC] extending git-ls-files --exclude Catalin Marinas
2005-07-25 19:58               ` Junio C Hamano
2005-07-25 20:09                 ` Linus Torvalds
2005-07-25 20:27                   ` Junio C Hamano
2005-07-25 20:51                     ` Catalin Marinas
2005-07-28 15:57                     ` Petr Baudis
2005-07-25 20:59                 ` Catalin Marinas
2005-07-28 15:52             ` Petr Baudis
2005-07-28 16:04               ` A Large Angry SCM
2005-07-28 19:25                 ` Matthias Urlichs
2005-07-29  7:21                   ` Petr Baudis
2005-07-29  7:37                     ` Matthias Urlichs
2005-07-29 13:49                     ` A Large Angry SCM
2005-07-29  5:04               ` Junio C Hamano
2005-07-29  7:36                 ` Petr Baudis
2005-07-29  8:24                   ` Junio C Hamano
2005-07-29  8:41                     ` Petr Baudis
2005-08-01 16:14                     ` Wayne Scott
2005-07-29  7:50                 ` [PATCH] ls-files: rework exclude patterns Junio C Hamano
2005-07-29  7:51                 ` [PATCH] Documentation and tests: ls-files exclude pattern Junio C Hamano
2005-07-22 21:43         ` [PATCH 1/1] Tell vim the textwidth is 75 Catalin Marinas
2005-07-22 23:07           ` Junio C Hamano
2005-07-23  8:41             ` Catalin Marinas
2005-07-23  9:30               ` Petr Baudis
2005-07-23 10:27                 ` Catalin Marinas
2005-07-23 16:33                   ` Bryan Larsen
2005-07-23 20:52                     ` Catalin Marinas
2005-07-28 19:47                   ` Petr Baudis
2005-07-29  2:24                     ` Junio C Hamano
2005-07-29  2:59                       ` Linus Torvalds
2005-07-29  9:55                     ` Catalin Marinas
2005-07-29 11:10                       ` Petr Baudis
2005-07-29 12:34                         ` Catalin Marinas
2005-07-30  2:11                         ` Junio C Hamano
2005-07-23  9:04             ` Petr Baudis
2005-07-24  1:13               ` Junio C Hamano
2005-07-22 21:00       ` Catalin Marinas
2005-07-22 20:41     ` Petr Baudis
2005-07-22 21:16       ` Junio C Hamano
2005-07-22 21:27         ` Petr Baudis
2005-07-22 23:24           ` Junio C Hamano
2005-07-22 23:50             ` Petr Baudis
2005-07-23 10:32             ` Catalin Marinas
2005-07-26  0:18             ` Updating diff-raw status letter to 'A' for added files Junio C Hamano
2005-07-26  0:20               ` Junio C Hamano [this message]
2005-07-26  0:21               ` [PATCH 2/2] diff-raw: Use 'A' instead of 'N' " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vd5p6fme7.fsf_-_@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pasky@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).