git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Show modified files in git-ls-files
@ 2005-09-02  0:35 Brian Gerst
  2005-09-02  9:04 ` Catalin Marinas
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Gerst @ 2005-09-02  0:35 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

[-- 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();

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Show modified files in git-ls-files
  2005-09-02  0:35 [PATCH] Show modified files in git-ls-files Brian Gerst
@ 2005-09-02  9:04 ` Catalin Marinas
  2005-09-02  9:28   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2005-09-02  9:04 UTC (permalink / raw)
  To: Brian Gerst; +Cc: Junio C Hamano, git

Brian Gerst <bgerst@didntduck.org> wrote:
> 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).

I think git-ls-files should be consistent with git-diff-cache where M
means modified and U unmerged (but for the former, M is unmerged).

StGIT currently uses C to report a merge conflict but I will probably
change this since it means copied in git-diff-cache.

-- 
Catalin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Show modified files in git-ls-files
  2005-09-02  9:04 ` Catalin Marinas
@ 2005-09-02  9:28   ` Junio C Hamano
  2005-09-02 12:17     ` Brian Gerst
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2005-09-02  9:28 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Brian Gerst, git

Catalin Marinas <catalin.marinas@gmail.com> writes:

> Brian Gerst <bgerst@didntduck.org> wrote:
>> 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).
>
> I think git-ls-files should be consistent with git-diff-cache where M
> means modified and U unmerged (but for the former, M is unmerged).
>
> StGIT currently uses C to report a merge conflict but I will probably
> change this since it means copied in git-diff-cache.

I think that is an excellent suggestion.  It looks to me that
the tag feature in ls-files needs serious renaming.

 * an option is called --deleted and the variable to control the
   output is show_deleted; the tag variable and string is
   removed and "R".  Probably the tag should be renamed to "D".

 * before "modified", tag_cached was OK, but probably "known to
   git" would have been a better name.  I'd vote for just a
   single space " " as the tag letter; if we want to use printing
   character, then a single dot ".".  Most of the things are
   "known to git" anyway so these are visually less
   distracting.

 * unmerged should be "U" as you say.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Show modified files in git-ls-files
  2005-09-02  9:28   ` Junio C Hamano
@ 2005-09-02 12:17     ` Brian Gerst
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Gerst @ 2005-09-02 12:17 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Catalin Marinas, git

Junio C Hamano wrote:
> Catalin Marinas <catalin.marinas@gmail.com> writes:
> 
> 
>>Brian Gerst <bgerst@didntduck.org> wrote:
>>
>>>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).
>>
>>I think git-ls-files should be consistent with git-diff-cache where M
>>means modified and U unmerged (but for the former, M is unmerged).
>>
>>StGIT currently uses C to report a merge conflict but I will probably
>>change this since it means copied in git-diff-cache.
> 
> 
> I think that is an excellent suggestion.  It looks to me that
> the tag feature in ls-files needs serious renaming.
> 
>  * an option is called --deleted and the variable to control the
>    output is show_deleted; the tag variable and string is
>    removed and "R".  Probably the tag should be renamed to "D".
> 
>  * before "modified", tag_cached was OK, but probably "known to
>    git" would have been a better name.  I'd vote for just a
>    single space " " as the tag letter; if we want to use printing
>    character, then a single dot ".".  Most of the things are
>    "known to git" anyway so these are visually less
>    distracting.

It should have some character, so the output is parseable by other scripts.

>  * unmerged should be "U" as you say.

I agree that the tags should be renamed.  I just didn't want to break 
other scripts which depend on those tags.

--
					Brian Gerst

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-09-02 12:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-02  0:35 [PATCH] Show modified files in git-ls-files Brian Gerst
2005-09-02  9:04 ` Catalin Marinas
2005-09-02  9:28   ` Junio C Hamano
2005-09-02 12:17     ` Brian Gerst

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).