git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Miles Bader <miles@gnu.org>
Cc: git@vger.kernel.org
Subject: Re: git-diff new files (without using index)
Date: Sat, 4 Aug 2007 23:52:45 -0400	[thread overview]
Message-ID: <20070805035245.GE9527@spearce.org> (raw)
In-Reply-To: <87wswalkad.fsf@catnip.gol.com>

Miles Bader <miles@gnu.org> wrote:
> One thing I often want to do is generate a complete diff of all changes,
> including new/removed files.
> 
> If I add things to the index, I can use "git-diff --cached" to do it;
> however I'd actually like to be able to do this _without_ updating the
> index; in other words, any un-added new file as a change.  As it is, the
> "non-indexed" state seems kind of a second-class citizen, as you can
> never have new files there (or rather, git will never really see them).
 
Use a temporary index:

  (export GIT_INDEX_FILE=.git/tempindex;
   cp .git/index $GIT_INDEX_FILE;
   git add new-file;
   git add other-new-file;
   git diff --cached)

We pull this trick sometimes in internal tools, when we want to
produce some result but aren't sure we want to keep the resulting
index, or really know we don't want to keep the resulting index.

Another option is to just add everything, then reset the index:

  git add new-file
  git add other-new-file
  git diff --cached
  git reset

Granted if you had other files staged they just became unstaged
and will need to be restaged...  the temporary index trick above
avoids that.

-- 
Shawn.

  reply	other threads:[~2007-08-05  3:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-05  3:42 git-diff new files (without using index) Miles Bader
2007-08-05  3:52 ` Shawn O. Pearce [this message]
2007-08-05  4:00   ` Miles Bader
2007-08-05  4:08     ` Shawn O. Pearce
2007-08-05  4:20       ` Junio C Hamano
2007-08-05  4:37         ` Miles Bader

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=20070805035245.GE9527@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=miles@gnu.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;
as well as URLs for NNTP newsgroup(s).