git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* diff <commit> using 3-dot behavior
@ 2016-08-24 14:28 Robert Dailey
  2016-08-24 16:00 ` Michael J Gruber
  2016-08-24 16:22 ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Robert Dailey @ 2016-08-24 14:28 UTC (permalink / raw)
  To: Git

I want to view the complete diff of my branch (topic) relative to its
parent branch (master). This should include cached/staged files and
unstaged working tree changes.

If I do this:

$ git diff master

This will include changes on master *since* my last merge, which I do
not want (I don't want to see changes on master, only on topic). I
tried this:

$ git diff master --not master

This didn't give me any output. If I do this:

$ git diff master...topic

This shows me only committed changes on topic, but excludes staged &
unstaged changes.

How can I get the results I want?

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

* Re: diff <commit> using 3-dot behavior
  2016-08-24 14:28 diff <commit> using 3-dot behavior Robert Dailey
@ 2016-08-24 16:00 ` Michael J Gruber
  2016-08-24 16:10   ` Robert Dailey
  2016-08-24 16:22 ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Michael J Gruber @ 2016-08-24 16:00 UTC (permalink / raw)
  To: Robert Dailey, Git

Robert Dailey venit, vidit, dixit 24.08.2016 16:28:
> I want to view the complete diff of my branch (topic) relative to its
> parent branch (master). This should include cached/staged files and
> unstaged working tree changes.
> 
> If I do this:
> 
> $ git diff master
> 
> This will include changes on master *since* my last merge, which I do
> not want (I don't want to see changes on master, only on topic). I
> tried this:
> 
> $ git diff master --not master
> 
> This didn't give me any output. If I do this:
> 
> $ git diff master...topic
> 
> This shows me only committed changes on topic, but excludes staged &
> unstaged changes.
> 
> How can I get the results I want?

The 3-dot notation means:

Show the difference between the merge-base of master and topic, and topic.

I'm not completely sure, but I guess what you want is:

Show the difference between the merge-base of master and topic, and the
worktree.

You can accomplish this with:

git diff $(git merge-base master topic)

I guess a shorter notation for that could come in handy. OTOH, I usually
diff against HEAD in a situation like that.

Cheers,
Michael

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

* Re: diff <commit> using 3-dot behavior
  2016-08-24 16:00 ` Michael J Gruber
@ 2016-08-24 16:10   ` Robert Dailey
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Dailey @ 2016-08-24 16:10 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: Git

On Wed, Aug 24, 2016 at 11:00 AM, Michael J Gruber
<git@drmicha.warpmail.net> wrote:
> The 3-dot notation means:
>
> Show the difference between the merge-base of master and topic, and topic.
>
> I'm not completely sure, but I guess what you want is:
>
> Show the difference between the merge-base of master and topic, and the
> worktree.
>
> You can accomplish this with:
>
> git diff $(git merge-base master topic)
>
> I guess a shorter notation for that could come in handy. OTOH, I usually
> diff against HEAD in a situation like that.

Great solution. I feel silly now, the answer ended up being rather
obvious. I can create an alias for that. But I can't diff against HEAD
because then I am not seeing a diff of changes already committed.
Thanks for your help.

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

* Re: diff <commit> using 3-dot behavior
  2016-08-24 14:28 diff <commit> using 3-dot behavior Robert Dailey
  2016-08-24 16:00 ` Michael J Gruber
@ 2016-08-24 16:22 ` Junio C Hamano
  2016-08-24 20:48   ` Jacob Keller
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2016-08-24 16:22 UTC (permalink / raw)
  To: Robert Dailey; +Cc: Git

Robert Dailey <rcdailey.lists@gmail.com> writes:

> $ git diff master...topic

... which is defined roughly as

	git diff $(git merge-base master topic) topic

The merge-base is to compute the point you forked your topic from
the mainline.  So if you want to compare your current state in the
index with the fork point, you'd do

	git diff --cached $(git merge-base master topic)

and comparing your working tree state would be

	git diff --cached $(git merge-base master topic)


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

* Re: diff <commit> using 3-dot behavior
  2016-08-24 16:22 ` Junio C Hamano
@ 2016-08-24 20:48   ` Jacob Keller
  2016-08-24 21:39     ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Jacob Keller @ 2016-08-24 20:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Robert Dailey, Git

On Wed, Aug 24, 2016 at 9:22 AM, Junio C Hamano <gitster@pobox.com> wrote:
> The merge-base is to compute the point you forked your topic from
> the mainline.  So if you want to compare your current state in the
> index with the fork point, you'd do
>
>         git diff --cached $(git merge-base master topic)
>
> and comparing your working tree state would be
>
>         git diff --cached $(git merge-base master topic)
>

Those are both identical?

Thanks,
Jake

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

* Re: diff <commit> using 3-dot behavior
  2016-08-24 20:48   ` Jacob Keller
@ 2016-08-24 21:39     ` Jeff King
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2016-08-24 21:39 UTC (permalink / raw)
  To: Jacob Keller; +Cc: Junio C Hamano, Robert Dailey, Git

On Wed, Aug 24, 2016 at 01:48:30PM -0700, Jacob Keller wrote:

> On Wed, Aug 24, 2016 at 9:22 AM, Junio C Hamano <gitster@pobox.com> wrote:
> > The merge-base is to compute the point you forked your topic from
> > the mainline.  So if you want to compare your current state in the
> > index with the fork point, you'd do
> >
> >         git diff --cached $(git merge-base master topic)
> >
> > and comparing your working tree state would be
> >
> >         git diff --cached $(git merge-base master topic)
> >
> 
> Those are both identical?

I imagine the second one just meant to drop "--cached".

-Peff

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

end of thread, other threads:[~2016-08-24 21:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24 14:28 diff <commit> using 3-dot behavior Robert Dailey
2016-08-24 16:00 ` Michael J Gruber
2016-08-24 16:10   ` Robert Dailey
2016-08-24 16:22 ` Junio C Hamano
2016-08-24 20:48   ` Jacob Keller
2016-08-24 21:39     ` Jeff King

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