Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: pasky@ucw.cz, torvalds@osdl.org
Cc: git@vger.kernel.org
Subject: [PATCH 1/3] Update mode-change strings in diff output.
Date: Fri, 13 May 2005 18:40:14 -0700	[thread overview]
Message-ID: <7vhdh660w1.fsf@assigned-by-dhcp.cox.net> (raw)

This updates the mode change strings to be a bit more machine
friendly.  Although this might go against the spirit of
readability for human consumption, these mode bits strings are
shown only when unusual things (mode change, file creation and
deletion) happens, output normalized for machine consumption
would be permissible.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

diff.c |   22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)

--- a/diff.c
+++ b/diff.c
@@ -83,6 +83,7 @@
 			 struct diff_tempfile *temp)
 {
 	int i, next_at;
+	const char *git_prefix = "# mode: ";
 	const char *diff_cmd = "diff -L'%s%s' -L'%s%s'";
 	const char *diff_arg  = "'%s' '%s'||:"; /* "||:" is to return 0 */
 	const char *input_name_sq[2];
@@ -123,17 +124,18 @@
 			    diff_arg, input_name_sq[0], input_name_sq[1]);
 
 	if (!path1[0][0])
-		printf("Created: %s (mode:%s)\n", name, temp[1].mode);
+		printf("%s. %s %s\n", git_prefix, temp[1].mode, name);
 	else if (!path1[1][0])
-		printf("Deleted: %s\n", name);
-	else if (strcmp(temp[0].mode, temp[1].mode)) {
-		printf("Mode changed: %s (%s->%s)\n", name,
-		       temp[0].mode, temp[1].mode);
-		/* Be careful.  We do not want to diff between
-		 * symlink and a file.
-		 */
-		if (strncmp(temp[0].mode, "120", 3) !=
-		    strncmp(temp[1].mode, "120", 3))
+		printf("%s%s . %s\n", git_prefix, temp[0].mode, name);
+	else {
+		if (strcmp(temp[0].mode, temp[1].mode))
+			printf("%s%s %s %s\n", git_prefix,
+			       temp[0].mode, temp[1].mode, name);
+
+		if (strncmp(temp[0].mode, temp[1].mode, 3))
+			/* we do not run diff between different kind
+			 * of objects.
+			 */
 			exit(0);
 	}
 	fflush(NULL);


                 reply	other threads:[~2005-05-14  1:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=7vhdh660w1.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=pasky@ucw.cz \
    --cc=torvalds@osdl.org \
    /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