Re: [PATCH] git-diff: Add --staged as a synonym for --cached.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, 12 Nov 2008, Jeff King wrote:

> On Mon, Nov 10, 2008 at 11:04:42PM -0500, Avery Pennarun wrote:
> 
> > Speaking just for myself, I would find this all a lot less confusing 
> > if "staged" were a refspec of some sort, not an option at all.
> > 
> >    git diff HEAD..STAGED
> >    git diff STAGED..WORKTREE
> >    git grep pattern STAGED HEAD sillybranch WORKTREE ^ignorebranch --
> > path/to/files
> 
> I agree that such a thing is reasonably intuitive. I have thought about 
> "magic" refspecs before; my local git has an "EMPTY" refspec which 
> points to the empty tree for diffing. However, that was trivial to 
> implement (since it turns into a sha1), and yours is very hard (since 
> you will have to pass these "pretend" objects around).
> 
> So I think it is a neat idea, but I am not volunteering to work on it.
> :)

Just in case anybody thought about creating tree objects on the fly and 
use their SHA-1s: that won't fly, as you can have unmerged entries in the 
index.  So STAGED.. is a _fundamentally_ different thing from HEAD^..

Maybe we could play tricks with a special staged_commit (pretending to be 
a commit with SHA-1 000000... so that git log STAGED.. would do the same 
as plain git log, the rationale being that STAGED is no commit, so ^STAGED 
should be a nop).

"git diff" would then have some special handling for the case that there 
are exactly two revs, exactly one of them negative, and exactly one of 
them being the staged_commit, passing off to the respective diff backends.

Ciao,
Dscho

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux