git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git diff
       [not found] <AANLkTi=ASvicFGaaDfqxjOxJELWPLKsQwvk7rEeT36Fh@mail.gmail.com>
@ 2011-01-13 22:46 ` Carter Lamb
  2011-01-17 22:30   ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Carter Lamb @ 2011-01-13 22:46 UTC (permalink / raw)
  To: git

I use git diff --summary --numstat <commit> to report the files
modified, created, and deleted between the current commit and some
prior commit. The --stat and --numstat options count the lines added
and deleted for each file. Is there a way to report the lines modified
for each file. For example:

Given content below for commit 1:
aaaaa
ccccc

Given content below for commit 2:
aaaaa
bbbbb
ccccc

Given content below for commit 3:
Aaaaa
Bbbbb
ccccc
ddddd

git diff --numstat between commits 1 and 2 will report one line added.
git diff --numstat between commits 2 and 3 will report three lines
added and two lines deleted.
I'd like to see the diff between commits 2 and 3 report two lines
modified and one line added.
Can this be done?

Best,
Carter

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

* Re: git diff
  2011-01-13 22:46 ` Carter Lamb
@ 2011-01-17 22:30   ` Jeff King
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2011-01-17 22:30 UTC (permalink / raw)
  To: Carter Lamb; +Cc: git

On Thu, Jan 13, 2011 at 04:46:16PM -0600, Carter Lamb wrote:

> I use git diff --summary --numstat <commit> to report the files
> modified, created, and deleted between the current commit and some
> prior commit. The --stat and --numstat options count the lines added
> and deleted for each file. Is there a way to report the lines modified
> for each file. For example:

Not really, because it's not well defined. Consider your example:

> Given content below for commit 1:
> aaaaa
> ccccc
> 
> Given content below for commit 2:
> aaaaa
> bbbbb
> ccccc
> 
> Given content below for commit 3:
> Aaaaa
> Bbbbb
> ccccc
> ddddd

How do we know that "Aaaaa" is a modification of line "aaaaa", and not
simply the deletion of the old line and the addition of a new one? It's
easy to come up with a case where that is more obvious:

  -aaaaa
  +ddddd

but there are many shades of gray in between. Is:

  -aaaaa
  +Aaada

the deletion of an old line and the introduction of a new one, or the
modification of an existing line?  So fundamentally the diff format just
deals with added and removed lines, and modifications are represented as
a delete followed by an add.

Which isn't to say you couldn't think of many clever algorithms for
heuristically determining a modification, but git doesn't do that itself
in numstat.

-Peff

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

* git diff
@ 2016-10-12 10:50 webmaster
  2016-10-12 11:06 ` Mike Rappazzo
  0 siblings, 1 reply; 5+ messages in thread
From: webmaster @ 2016-10-12 10:50 UTC (permalink / raw)
  To: git

Hi.

I created a new branch named hotfix from master.
I switched to the branch, changed 1 file.

Now I want to see the diff from the both using

git diff hotfix master

I do not see any output (difference).
When I do a git status I see my file with status mofified, not staged for
commit.
Also, I can see that I am working with the correct branch, hotfix

What am I doing wrong?

-fuz

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

* Re: git diff
  2016-10-12 10:50 git diff webmaster
@ 2016-10-12 11:06 ` Mike Rappazzo
  2016-10-12 13:51   ` webmaster
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Rappazzo @ 2016-10-12 11:06 UTC (permalink / raw)
  To: webmaster; +Cc: git

On Wed, Oct 12, 2016 at 6:50 AM,  <webmaster@peter-speer.de> wrote:
> Hi.
>
> I created a new branch named hotfix from master.
> I switched to the branch, changed 1 file.
>
> Now I want to see the diff from the both using
>
> git diff hotfix master
>
> I do not see any output (difference).
> When I do a git status I see my file with status mofified, not staged for
> commit.

Since you just created the branch, and did not add any content, there
is no difference to see.  A branch is just a pointer to a commit.  You
now have two pointers pointing at the same commit.

If you want to see the difference between your changes and the master
branch, you can omit the first reference:

    git diff master

When you start adding commits to your hotfix branch, you will be able
to see the diff between that and master with the command that you
gave.  However, your arguments may be in the reverse order than what
you expect.  You want to specify master first because that is the
mainline branch (I presume).

When you have several commits on your hotfix branch, you can refer to
older commits to diff against.  There are several ways to refer back,
but the simplest is to use a tilde '~' followed by a number to count
back.  For example 'hotfix~1' refers to the parent commit on the
hotfix branch.  There is a lot in the documentation[1], so take a look
there for more info.

Good luck.
_Mike

[1] https://git-scm.com/doc


> Also, I can see that I am working with the correct branch, hotfix
>
> What am I doing wrong?
>
> -fuz

On Wed, Oct 12, 2016 at 6:50 AM,  <webmaster@peter-speer.de> wrote:
> Hi.
>
> I created a new branch named hotfix from master.
> I switched to the branch, changed 1 file.
>
> Now I want to see the diff from the both using
>
> git diff hotfix master
>
> I do not see any output (difference).
> When I do a git status I see my file with status mofified, not staged for
> commit.
> Also, I can see that I am working with the correct branch, hotfix
>
> What am I doing wrong?
>
> -fuz

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

* Re: git diff
  2016-10-12 11:06 ` Mike Rappazzo
@ 2016-10-12 13:51   ` webmaster
  0 siblings, 0 replies; 5+ messages in thread
From: webmaster @ 2016-10-12 13:51 UTC (permalink / raw)
  To: Mike Rappazzo; +Cc: git

Thanks, Mike. Now I understood.

-fuz

> Mike Rappazzo <rappazzo@gmail.com> hat am 12. Oktober 2016 um 13:06
> geschrieben:
> 
> On Wed, Oct 12, 2016 at 6:50 AM, <webmaster@peter-speer.de> wrote:
> > Hi.
> >
> > I created a new branch named hotfix from master.
> > I switched to the branch, changed 1 file.
> >
> > Now I want to see the diff from the both using
> >
> > git diff hotfix master
> >
> > I do not see any output (difference).
> > When I do a git status I see my file with status mofified, not staged for
> > commit.
> 
> Since you just created the branch, and did not add any content, there
> is no difference to see. A branch is just a pointer to a commit. You
> now have two pointers pointing at the same commit.
> 
> If you want to see the difference between your changes and the master
> branch, you can omit the first reference:
> 
>  git diff master
> 
> When you start adding commits to your hotfix branch, you will be able
> to see the diff between that and master with the command that you
> gave. However, your arguments may be in the reverse order than what
> you expect. You want to specify master first because that is the
> mainline branch (I presume).
> 
> When you have several commits on your hotfix branch, you can refer to
> older commits to diff against. There are several ways to refer back,
> but the simplest is to use a tilde '~' followed by a number to count
> back. For example 'hotfix~1' refers to the parent commit on the
> hotfix branch. There is a lot in the documentation[1], so take a look
> there for more info.
> 
> Good luck.
> _Mike
> 
> [1] https://git-scm.com/doc
> 
> > Also, I can see that I am working with the correct branch, hotfix
> >
> > What am I doing wrong?
> >
> > -fuz
> 
> On Wed, Oct 12, 2016 at 6:50 AM, <webmaster@peter-speer.de> wrote:
> > Hi.
> >
> > I created a new branch named hotfix from master.
> > I switched to the branch, changed 1 file.
> >
> > Now I want to see the diff from the both using
> >
> > git diff hotfix master
> >
> > I do not see any output (difference).
> > When I do a git status I see my file with status mofified, not staged for
> > commit.
> > Also, I can see that I am working with the correct branch, hotfix
> >
> > What am I doing wrong?
> >
> > -fuz

>

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

end of thread, other threads:[~2016-10-12 13:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12 10:50 git diff webmaster
2016-10-12 11:06 ` Mike Rappazzo
2016-10-12 13:51   ` webmaster
     [not found] <AANLkTi=ASvicFGaaDfqxjOxJELWPLKsQwvk7rEeT36Fh@mail.gmail.com>
2011-01-13 22:46 ` Carter Lamb
2011-01-17 22:30   ` 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).