git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Brian Gerst <bgerst@didntduck.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] Show modified files in git-ls-files
Date: Thu, 01 Sep 2005 20:35:37 -0400	[thread overview]
Message-ID: <43179E59.80106@didntduck.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]

Add -m/--modified to show files that have been modified wrt. the index.

M was already taken so the tag for modifified files is C (changed).

$ git-ls-files -m -t
C Documentation/git-ls-files.txt
C ls-files.c

Signed-off-by: Brian Gerst <bgerst@didntduck.org>

---

  Documentation/git-ls-files.txt |    4 ++++
  ls-files.c                     |   20 +++++++++++++++-----
  2 files changed, 19 insertions(+), 5 deletions(-)


[-- Attachment #2: 0001-Show-modified-files-in-git-ls-files.txt --]
[-- Type: text/plain, Size: 3046 bytes --]

Subject: [PATCH] Show modified files in git-ls-files

Add -m/--modified to show files that have been modified wrt. the index.

M was already taken so the tag for modifified files is C (changed).

$ git-ls-files -m -t
C Documentation/git-ls-files.txt
C ls-files.c

Signed-off-by: Brian Gerst <bgerst@didntduck.org>

---

 Documentation/git-ls-files.txt |    4 ++++
 ls-files.c                     |   20 +++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

9de83ef7cce7ed5c1aa129cf2a81f8bce3aedb4f
diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -33,6 +33,9 @@ OPTIONS
 -d|--deleted::
 	Show deleted files in the output
 
+-m|--modified::
+	Show modified files in the output
+
 -o|--others::
 	Show other files in the output
 
@@ -71,6 +74,7 @@ OPTIONS
 	H	cached
 	M	unmerged
 	R	removed/deleted
+	C	modifed (changed)
 	K	to be killed
 	?	other
 
diff --git a/ls-files.c b/ls-files.c
--- a/ls-files.c
+++ b/ls-files.c
@@ -17,6 +17,7 @@ static int show_ignored = 0;
 static int show_stage = 0;
 static int show_unmerged = 0;
 static int show_killed = 0;
+static int show_modified = 0;
 static int line_terminator = '\n';
 
 static int prefix_len = 0, prefix_offset = 0;
@@ -26,6 +27,7 @@ static const char **pathspec = NULL;
 static const char *tag_cached = "";
 static const char *tag_unmerged = "";
 static const char *tag_removed = "";
+static const char *tag_modified = "";
 static const char *tag_other = "";
 static const char *tag_killed = "";
 
@@ -443,15 +445,18 @@ static void show_files(void)
 			show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
 		}
 	}
-	if (show_deleted) {
+	if (show_deleted | show_modified) {
 		for (i = 0; i < active_nr; i++) {
 			struct cache_entry *ce = active_cache[i];
 			struct stat st;
+			int err;
 			if (excluded(ce->name) != show_ignored)
 				continue;
-			if (!lstat(ce->name, &st))
-				continue;
-			show_ce_entry(tag_removed, ce);
+			err = lstat(ce->name, &st);
+			if (show_deleted && err)
+				show_ce_entry(tag_removed, ce);
+			if (show_modified && ce_match_stat(ce, &st))
+				show_ce_entry(tag_modified, ce);
 		}
 	}
 }
@@ -547,6 +552,7 @@ int main(int argc, char **argv)
 			tag_cached = "H ";
 			tag_unmerged = "M ";
 			tag_removed = "R ";
+			tag_modified = "C ";
 			tag_other = "? ";
 			tag_killed = "K ";
 			continue;
@@ -559,6 +565,10 @@ int main(int argc, char **argv)
 			show_deleted = 1;
 			continue;
 		}
+		if (!strcmp(arg, "-m") || !strcmp(arg, "--modified")) {
+			show_modified = 1;
+			continue;
+		}
 		if (!strcmp(arg, "-o") || !strcmp(arg, "--others")) {
 			show_others = 1;
 			continue;
@@ -630,7 +640,7 @@ int main(int argc, char **argv)
 	}
 
 	/* With no flags, we default to showing the cached files */
-	if (!(show_stage | show_deleted | show_others | show_unmerged | show_killed))
+	if (!(show_stage | show_deleted | show_others | show_unmerged | show_killed | show_modified))
 		show_cached = 1;
 
 	read_cache();

             reply	other threads:[~2005-09-02  0:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-02  0:35 Brian Gerst [this message]
2005-09-02  9:04 ` [PATCH] Show modified files in git-ls-files Catalin Marinas
2005-09-02  9:28   ` Junio C Hamano
2005-09-02 12:17     ` Brian Gerst

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=43179E59.80106@didntduck.org \
    --to=bgerst@didntduck.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).