* How to list versioned files with modification status
@ 2008-10-04 12:12 Mark Burton
2008-10-04 21:40 ` Alex Riesen
2008-10-04 23:09 ` Dmitry Potapov
0 siblings, 2 replies; 9+ messages in thread
From: Mark Burton @ 2008-10-04 12:12 UTC (permalink / raw)
To: git
Hi,
I would like to be able to easily find those files in a git tree that
don't have pending modifications. Although ls-files can list the
files that are modified, it can't list those that aren't or list all
files with their modification status.
Thanks,
Mark
--
Smart Avionics Ltd. -- producer of innovative avionics for homebuilt
aircraft.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to list versioned files with modification status
2008-10-04 12:12 How to list versioned files with modification status Mark Burton
@ 2008-10-04 21:40 ` Alex Riesen
2008-10-04 22:09 ` Mark Burton
2008-10-04 23:09 ` Dmitry Potapov
1 sibling, 1 reply; 9+ messages in thread
From: Alex Riesen @ 2008-10-04 21:40 UTC (permalink / raw)
To: Mark Burton; +Cc: git
2008/10/4 Mark Burton <markb@smartavionics.com>:
> I would like to be able to easily find those files in a git tree that
> don't have pending modifications. Although ls-files can list the
> files that are modified, it can't list those that aren't or list all
> files with their modification status.
Maybe if you look at git diff and diff-index, you will find something
what suits you better? Because "modification" is just a difference
between a known (recorded in a commit or index) state and your
working tree.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to list versioned files with modification status
2008-10-04 21:40 ` Alex Riesen
@ 2008-10-04 22:09 ` Mark Burton
2008-10-04 22:34 ` Alex Riesen
2008-10-04 23:10 ` Linus Torvalds
0 siblings, 2 replies; 9+ messages in thread
From: Mark Burton @ 2008-10-04 22:09 UTC (permalink / raw)
To: git
Alex Riesen <raa.lkml <at> gmail.com> writes:
>
> 2008/10/4 Mark Burton <markb <at> smartavionics.com>:
> > I would like to be able to easily find those files in a git tree that
> > don't have pending modifications. Although ls-files can list the
> > files that are modified, it can't list those that aren't or list all
> > files with their modification status.
>
> Maybe if you look at git diff and diff-index, you will find something
> what suits you better? Because "modification" is just a difference
> between a known (recorded in a commit or index) state and your
> working tree.
>
'git diff --name-status' looks useful but it only shows the files that have
changed - I would like to see the names of the files that haven't changed. Even
svn could do that (svn status).
Thanks,
Mark
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to list versioned files with modification status
2008-10-04 22:09 ` Mark Burton
@ 2008-10-04 22:34 ` Alex Riesen
2008-10-04 22:52 ` deskinm
2008-10-04 23:02 ` Mark Burton
2008-10-04 23:10 ` Linus Torvalds
1 sibling, 2 replies; 9+ messages in thread
From: Alex Riesen @ 2008-10-04 22:34 UTC (permalink / raw)
To: Mark Burton; +Cc: git
2008/10/5 Mark Burton <markb@ordern.com>:
> Alex Riesen <raa.lkml <at> gmail.com> writes:
>> 2008/10/4 Mark Burton <markb <at> smartavionics.com>:
>> > I would like to be able to easily find those files in a git tree that
>> > don't have pending modifications. Although ls-files can list the
>> > files that are modified, it can't list those that aren't or list all
>> > files with their modification status.
>>
>> Maybe if you look at git diff and diff-index, you will find something
>> what suits you better? Because "modification" is just a difference
>> between a known (recorded in a commit or index) state and your
>> working tree.
>
> 'git diff --name-status' looks useful but it only shows the files that have
> changed - I would like to see the names of the files that haven't changed.
There is nothing to do something like that, but...
> Even svn could do that (svn status).
what exactly are trying to achieve? It is just strange that no one
asked for something like this before...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to list versioned files with modification status
2008-10-04 22:34 ` Alex Riesen
@ 2008-10-04 22:52 ` deskinm
2008-10-04 23:02 ` Mark Burton
1 sibling, 0 replies; 9+ messages in thread
From: deskinm @ 2008-10-04 22:52 UTC (permalink / raw)
To: Alex Riesen; +Cc: Mark Burton, git
On Sun, Oct 05, 2008 at 12:34:31AM +0200, Alex Riesen wrote:
> 2008/10/5 Mark Burton <markb@ordern.com>:
> > Alex Riesen <raa.lkml <at> gmail.com> writes:
> >> 2008/10/4 Mark Burton <markb <at> smartavionics.com>:
> >> > I would like to be able to easily find those files in a git tree that
> >> > don't have pending modifications. Although ls-files can list the
> >> > files that are modified, it can't list those that aren't or list all
> >> > files with their modification status.
> >>
> >> Maybe if you look at git diff and diff-index, you will find something
> >> what suits you better? Because "modification" is just a difference
> >> between a known (recorded in a commit or index) state and your
> >> working tree.
> >
> > 'git diff --name-status' looks useful but it only shows the files that have
> > changed - I would like to see the names of the files that haven't changed.
>
> There is nothing to do something like that, but...
>
> > Even svn could do that (svn status).
>
> what exactly are trying to achieve? It is just strange that no one
> asked for something like this before...
Apologies for the duplicate message; fighting between gmail and
vger.kernel.org.
Here's a terrible way to do this:
$ GIT_EDITOR=: git commit -a -m 'throwaway' >/dev/null
$ (git ls-tree -r HEAD; git ls-tree -r HEAD~1) \
| sort | uniq -d | sed -e 's/^[^ ]* [^ ]* [^\t]*\t//'
$ git reset HEAD~1 >/dev/null
Deskin Miller
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to list versioned files with modification status
2008-10-04 22:34 ` Alex Riesen
2008-10-04 22:52 ` deskinm
@ 2008-10-04 23:02 ` Mark Burton
1 sibling, 0 replies; 9+ messages in thread
From: Mark Burton @ 2008-10-04 23:02 UTC (permalink / raw)
To: git
> > 'git diff --name-status' looks useful but it only shows the files that have
> > changed - I would like to see the names of the files that haven't changed.
>
> There is nothing to do something like that, but...
>
> > Even svn could do that (svn status).
>
> what exactly are trying to achieve? It is just strange that no one
> asked for something like this before...
What I am trying to achieve is to list the versioned files that have no
pending modifications (didn't I say that in the original posting?)
Strange, perhaps, but not completely useless in that it does tell you
something about the state of the current working set of files.
BTW - and sorry for posting the same question in two different emails, I
thought the first one had not made it onto the list - I shall be more
patient in the future.
Mark
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to list versioned files with modification status
2008-10-04 12:12 How to list versioned files with modification status Mark Burton
2008-10-04 21:40 ` Alex Riesen
@ 2008-10-04 23:09 ` Dmitry Potapov
1 sibling, 0 replies; 9+ messages in thread
From: Dmitry Potapov @ 2008-10-04 23:09 UTC (permalink / raw)
To: Mark Burton; +Cc: git
On Sat, Oct 04, 2008 at 01:12:56PM +0100, Mark Burton wrote:
>
> I would like to be able to easily find those files in a git tree that
> don't have pending modifications. Although ls-files can list the
> files that are modified, it can't list those that aren't
Well, it is a rather unusual task to have a special option devoted
to it, and you always combine a few commands together like that:
comm -3 <(git ls-files|sort) <(git ls-files -m|sort)
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to list versioned files with modification status
2008-10-04 22:09 ` Mark Burton
2008-10-04 22:34 ` Alex Riesen
@ 2008-10-04 23:10 ` Linus Torvalds
2008-10-05 9:04 ` Mark Burton
1 sibling, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2008-10-04 23:10 UTC (permalink / raw)
To: Mark Burton; +Cc: git
On Sat, 4 Oct 2008, Mark Burton wrote:
>
> 'git diff --name-status' looks useful but it only shows the files that have
> changed - I would like to see the names of the files that haven't changed. Even
> svn could do that (svn status).
Nobody has ever asked for such a crazy thing, but here's a test-patch to
teach 'git ls-files' the '--unmodified' flag.
It's strictly bigger than need be, partly because ls-files is a horror,
partly because it needed that 'name_status()' helper function to make it
not turn into something even worse.
I also fixed a git ls-files buglet: a deleted file implies modification,
so if you ask for --deleted _and_ --modified at the same time, you'll see
a deleted file listed twice. Use '-v' to see the type. This makes it
only show it once - as deleted if you asked for that information,
otherwise as modified.
So with something like this, you can do
git ls-files -v --modified --deleted --unmodified
and you'll see all files with a tag in front (the tag for unmodified is
empty).
Not very well tested (aka "Hey, it's a patch from Linus, caveat emptor!")
Linus
---
builtin-ls-files.c | 48 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 068f424..27a318a 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -18,6 +18,7 @@ static int show_others;
static int show_stage;
static int show_unmerged;
static int show_modified;
+static int show_unmodified;
static int show_killed;
static int show_valid_bit;
static int line_terminator = '\n';
@@ -35,6 +36,7 @@ static const char *tag_removed = "";
static const char *tag_other = "";
static const char *tag_killed = "";
static const char *tag_modified = "";
+static const char *tag_unmodified = "";
/*
@@ -218,6 +220,20 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
write_name_quoted(ce->name + offset, stdout, line_terminator);
}
+enum show_state {
+ unmodified, deleted, modified
+};
+
+static enum show_state name_status(struct cache_entry *ce)
+{
+ struct stat st;
+ int err = lstat(ce->name, &st);
+
+ if (err)
+ return deleted;
+ return ce_modified(ce, &st, 0) ? modified : unmodified;
+}
+
static void show_files(struct dir_struct *dir, const char *prefix)
{
int i;
@@ -248,19 +264,27 @@ static void show_files(struct dir_struct *dir, const char *prefix)
show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
}
}
- if (show_deleted | show_modified) {
+ if (show_deleted | show_modified | show_unmodified) {
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
- struct stat st;
- int err;
int dtype = ce_to_dtype(ce);
if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
continue;
- err = lstat(ce->name, &st);
- if (show_deleted && err)
- show_ce_entry(tag_removed, ce);
- if (show_modified && ce_modified(ce, &st, 0))
- show_ce_entry(tag_modified, ce);
+ switch (name_status(ce)) {
+ default:
+ if (show_unmodified)
+ show_ce_entry(tag_unmodified, ce);
+ break;
+ case deleted:
+ if (show_deleted) {
+ show_ce_entry(tag_removed, ce);
+ break;
+ }
+ /* Fall through */
+ case modified:
+ if (show_modified)
+ show_ce_entry(tag_modified, ce);
+ }
}
}
}
@@ -457,6 +481,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
tag_modified = "C ";
tag_other = "? ";
tag_killed = "K ";
+ tag_unmodified = " ";
if (arg[1] == 'v')
show_valid_bit = 1;
continue;
@@ -474,6 +499,11 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
require_work_tree = 1;
continue;
}
+ if (!strcmp(arg, "--unmodified")) {
+ show_unmodified = 1;
+ require_work_tree = 1;
+ continue;
+ }
if (!strcmp(arg, "-o") || !strcmp(arg, "--others")) {
show_others = 1;
require_work_tree = 1;
@@ -593,7 +623,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
/* With no flags, we default to showing the cached files */
if (!(show_stage | show_deleted | show_others | show_unmerged |
- show_killed | show_modified))
+ show_killed | show_modified | show_unmodified))
show_cached = 1;
read_cache();
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: How to list versioned files with modification status
2008-10-04 23:10 ` Linus Torvalds
@ 2008-10-05 9:04 ` Mark Burton
0 siblings, 0 replies; 9+ messages in thread
From: Mark Burton @ 2008-10-05 9:04 UTC (permalink / raw)
To: git
Linus Torvalds <torvalds <at> linux-foundation.org> writes:
> Nobody has ever asked for such a crazy thing, but here's a test-patch to
> teach 'git ls-files' the '--unmodified' flag.
>
> ...
Many thanks for the patch, it does exactly what I wanted. Thanks also to the
other people who contributed suggestions.
Mark
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-10-05 9:06 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-04 12:12 How to list versioned files with modification status Mark Burton
2008-10-04 21:40 ` Alex Riesen
2008-10-04 22:09 ` Mark Burton
2008-10-04 22:34 ` Alex Riesen
2008-10-04 22:52 ` deskinm
2008-10-04 23:02 ` Mark Burton
2008-10-04 23:10 ` Linus Torvalds
2008-10-05 9:04 ` Mark Burton
2008-10-04 23:09 ` Dmitry Potapov
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).