git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Parag Kalra <paragkalra@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Listing files in order they are changed
Date: Thu, 23 Sep 2010 16:38:15 -0400	[thread overview]
Message-ID: <20100923203814.GA10951@sigill.intra.peff.net> (raw)
In-Reply-To: <AANLkTimHrCujEggj9KbAWWivY+WxnL0YqsXs+idhymBA@mail.gmail.com>

On Thu, Sep 23, 2010 at 11:51:56AM -0700, Parag Kalra wrote:

> Is there a way I can make Git list all the tracked files in the
> working directory in order they are changed (modified, added or
> deleted)

It's a somewhat expensive operation, since you have to walk history
backwards looking at changes. But try:

git log --pretty=format: --name-only |
  grep . |
  perl -ne 'print unless $seen{$_}++'

which will walk history backwards, printing out each filename the most
recent time it is encountered. Which should give you a list of all files
in the repo (including ones which no longer exist!), in order of most
recent to oldest.

If you want to restrict only to existing files, you would have to do
some clever path-limiting, or parse the results with a slightly smarter
perl script.

You can also tweak the definition of "most recent" by using --topo-order
or --date-order with git log.

-Peff

  reply	other threads:[~2010-09-23 20:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-23 18:51 Listing files in order they are changed Parag Kalra
2010-09-23 20:38 ` Jeff King [this message]
2010-09-24  7:59   ` Peter Krefting
2010-09-23 20:48 ` Jakub Narebski
2010-09-23 20:53   ` Sverre Rabbelier
2010-09-23 21:02     ` Jakub Narebski
2010-09-23 21:20       ` Sverre Rabbelier

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=20100923203814.GA10951@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=paragkalra@gmail.com \
    /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).