Re: [git-users] Re: Doing a diff of different versions of a file

2017-11-02 Thread Konstantin Khomoutov
On Tue, Oct 31, 2017 at 08:07:53PM -0700, Michael wrote:

[...]
> keybounceMBP:extractor michael$ git diff head^1 head^2 adobepass.py
[...]

…and while we're on it, can I heartily recommend you to unlearn this
habit of lowercasing the name of the ref "HEAD"?

The problem with it is that the fact it works for you is just a Git's
implementation detail combined with the semantics of the filesystems
native to Windows.  In a stock Git implementation, most of the refs
(those which are not "packed" due to age) are represented as plain files
under the ".git" subdirectory. Windows-native filesystems (at least with
default settings which no one ever touches anyway) are
case-insensitive¹.

This means when you tell Git you want it to access the "head" ref it
actually tries to find a file ".git/refs/tags/head" then
".git/refs/heads/head" then ".git/head", which succeeds because there's
a file named ".git/HEAD".

As soon as you'll happen to work with Git on a non-Windows OS with a
case-sensitive filesystem, your habit will promptly bite you in the
rear.


¹ NTFS is case-insensitive but case-preserving, so if you'll create a
file named "kAbOoM" on it, it will be stored as "kAbOoM" but you will be
able to access it by the name "kaboom" or "KABOOM" or via any other
combination of the cases of those letters.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Re: Doing a diff of different versions of a file

2017-11-01 Thread Philip Oakley

From: "Konstantin Khomoutov" 
You understand the man page correcly but are you sure HEAD^1 and HEAD^2
is really what you want? To cite the manual page:

| A suffix ^ to a revision parameter means the first parent of that
| commit object.  ^ means the th parent.

=
As an aside: I commonly get confused by the "Parent" notation. I tend to 
think of the parentage numbers as being ancestry counts, so that it would 
be:- parent, grand parent, great grandparent.


However that's not what it (^) means, rather it's more father, mother, step 
father, stepmother, etc. So for me seeing ^3 always felt like it should be 
great grand parent. Such was my confusion.


The ancestry / generation  count use the '~' (tilde) as its symbol.

Good counting everyone.
--
Philip

--
You received this message because you are subscribed to the Google Groups "Git for 
human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Re: Doing a diff of different versions of a file

2017-11-01 Thread Michael

> So supposedly you'd need
> 
>  $ git diff :2:adobepass.py :3:adobepass.py

Thank you!

Would you believe I tried abodepass.py:1, and 1: adobepass.py, but did not 
realize that I needed :x: prefix?

(I also thought that "0" was the common, and "1" and "2" were the two sides.)

===

Next question, on that merge_head diff. Attempting to ask for the difference 
before doing a merge (I'm trying to rebuild a fork of youtube-dl with several 
pull requests and patches) would show an insanely large number of diffs 
(everything that has changed from a patch based on a months-old master), while 
the patch itself would only conflict in one file. My problem is that most of 
the hunks for that file apply without problem; in order to know how to resolve 
the changes, I need to know what's actually changing in that file.

How do I ask for a diff of "This is what would be applied if you tried to 
merge", rather than "this is everything that differs over the course of months"?

Basically, a given change would be adding unconflicted stuff here and there, 
and then adding something to a commonly edited area. Fixing that common area 
requires knowing what's what. I have three-way diffmarks enabled (not sure what 
it's official name is), so I see a very old common, and two large sets of 
changes.

At least one of the patches that I was trying to add in seems to be completely 
obsoleted by a later change.

(Aka: What I have runs, but I don't know if it will work correctly in all 
cases, or if I messed something up in the combination.)

---
Entertaining minecraft videos
http://YouTube.com/keybounce

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Re: Doing a diff of different versions of a file

2017-11-01 Thread Michael

> So supposedly you'd need
> 
>  $ git diff :2:adobepass.py :3:adobepass.py

Thank you!

Would you believe I tried abodepass.py:1, and 1: adobepass.py, but did not 
realize that I needed :x: prefix?

(I also thought that "0" was the common, and "1" and "2" were the two sides.)

===

Next question, on that merge_head diff. Attempting to ask for the difference 
before doing a merge (I'm trying to rebuild a fork of youtube-dl with several 
pull requests and patches) would show an insanely large number of diffs 
(everything that has changed from a patch based on a months-old master), while 
the patch itself would only conflict in one file. My problem is that most of 
the hunks for that file apply without problem; in order to know how to resolve 
the changes, I need to know what's actually changing in that file.

How do I ask for a diff of "This is what would be applied if you tried to 
merge", rather than "this is everything that differs over the course of months"?

Basically, a given change would be adding unconflicted stuff here and there, 
and then adding something to a commonly edited area. Fixing that common area 
requires knowing what's what. I have three-way diffmarks enabled (not sure what 
it's official name is), so I see a very old common, and two large sets of 
changes.

At least one of the patches that I was trying to add in seems to be completely 
obsoleted by a later change.

(Aka: What I have runs, but I don't know if it will work correctly in all 
cases, or if I messed something up in the combination.)

---
Entertaining minecraft videos
http://YouTube.com/keybounce

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Re: Doing a diff of different versions of a file

2017-11-01 Thread Michael

> So supposedly you'd need
> 
>  $ git diff :2:adobepass.py :3:adobepass.py

Thank you!

Would you believe I tried abodepass.py:1, and 1: adobepass.py, but did not 
realize that I needed :x: prefix?

(I also thought that "0" was the common, and "1" and "2" were the two sides.)

===

Next question, on that merge_head diff. Attempting to ask for the difference 
before doing a merge (I'm trying to rebuild a fork of youtube-dl with several 
pull requests and patches) would show an insanely large number of diffs 
(everything that has changed from a patch based on a months-old master), while 
the patch itself would only conflict in one file. My problem is that most of 
the hunks for that file apply without problem; in order to know how to resolve 
the changes, I need to know what's actually changing in that file.

How do I ask for a diff of "This is what would be applied if you tried to 
merge", rather than "this is everything that differs over the course of months"?

Basically, a given change would be adding unconflicted stuff here and there, 
and then adding something to a commonly edited area. Fixing that common area 
requires knowing what's what. I have three-way diffmarks enabled (not sure what 
it's official name is), so I see a very old common, and two large sets of 
changes.

At least one of the patches that I was trying to add in seems to be completely 
obsoleted by a later change.

(Aka: What I have runs, but I don't know if it will work correctly in all 
cases, or if I messed something up in the combination.)

---
Entertaining minecraft videos
http://YouTube.com/keybounce

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Re: Doing a diff of different versions of a file

2017-11-01 Thread Konstantin Khomoutov
On Tue, Oct 31, 2017 at 08:07:53PM -0700, Michael wrote:

> > How do I get git diff to show me the difference between two
> > different versions of one file?
> > 
> > I can say git diff tree-1 tree-2
> > 
> > I can say git diff file1
> > 
> > How do I ask for file1 in tree-1 versus file1 in tree-2?
> 
> Ok, perhaps a better question: Why isn't this doing what I expect?
> 
> keybounceMBP:extractor michael$ git status
> On branch new
> You have unmerged paths.
>   (fix conflicts and run "git commit")
>   (use "git merge --abort" to abort the merge)
> 
> Changes to be committed:
> 
> modified:   ../../.github/ISSUE_TEMPLATE.md
> modified:   ../../.travis.yml
> modified:   ../../ChangeLog
> ...
> Unmerged paths:
>   (use "git add ..." to mark resolution)
> 
> both modified:   adobepass.py
> 
> keybounceMBP:extractor michael$ git diff head^1 head^2 adobepass.py
> 
> If I understood the man page correctly, git diff tree-1 tree-2 path should 
> work.
> But that's not what I'm getting from that.

You understand the man page correcly but are you sure HEAD^1 and HEAD^2
is really what you want? To cite the manual page:

| A suffix ^ to a revision parameter means the first parent of that
| commit object.  ^ means the th parent.

That is, the encantation you presented assumes the HEAD is a merge
commit and is asking Git to compare the states of "adobepass.py"
between the two parents of the merge commit at HEAD.

We seem to discuss a *failed attempt* to merge something, and whet this
happend, there's no merge commit yet. If that was your line of
reasoning, this could explain your attempt at using ^.
Was that the case?

If yes, Git has another approach to this task.
As I've said, when you're dealing with a failed merge attempt, there's
no merge commit yet; instead, the repo is in a special state, in which
it has a special ref called MERGE_HEAD which contains one or more (for
a so-called "octopus merge") "their" heads -- those which are being
merged.

When a merge conflict occurs, for each file with one or more conflicts,
Git does the following:
- Modifies the contents of that file in the work tree by placing there
  those conflict markers delimiting conflicting chunks.
- Modifies the index entry for that file -- by placing there references
  to the *three* versions of that file's contents: "base", "ours" and
  "theirs" -- with "base" being the version at the nearest preceding
  commits both branches had before they diverged.

So it's those index entries you'd want to inspect when dealing with a
merge conflict.

The syntax you want to use is explained in the gitrevisions(7) man page:

| ::, e.g. :0:README, :README
|   A colon, optionally followed by a stage number (0 to 3) and a colon,
|   followed by a path, names a blob object in the index at the given path.
|   A missing stage number (and the colon that follows it) names a stage 0
|   entry. During a merge, stage 1 is the common ancestor, stage 2 is the
|   target branch’s version (typically the current branch), and stage 3
|   is the version from the branch which is being merged.

So supposedly you'd need

  $ git diff :2:adobepass.py :3:adobepass.py

to ask the question «what are the differences in "adobepass.py" between
the HEAD of the branch I'm merging into and the branch I'm mering?»

Still, it may turn out that

  $ git diff HEAD MERGE_HEAD adobepass.py

would be a simpler approach.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[git-users] Re: Doing a diff of different versions of a file

2017-10-31 Thread Michael

On 2017-10-31, at 7:53 PM, Michael  wrote:

> How do I get git diff to show me the difference between two different 
> versions of one file?
> 
> I can say git diff tree-1 tree-2
> 
> I can say git diff file1
> 
> How do I ask for file1 in tree-1 versus file1 in tree-2?

Ok, perhaps a better question: Why isn't this doing what I expect?

keybounceMBP:extractor michael$ git status
On branch new
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:

modified:   ../../.github/ISSUE_TEMPLATE.md
modified:   ../../.travis.yml
modified:   ../../ChangeLog
...
Unmerged paths:
  (use "git add ..." to mark resolution)

both modified:   adobepass.py

keybounceMBP:extractor michael$ git diff head^1 head^2 adobepass.py

If I understood the man page correctly, git diff tree-1 tree-2 path should work.
But that's not what I'm getting from that.

> ---
> Entertaining minecraft videos
> http://YouTube.com/keybounce
> 

---
Entertaining minecraft videos
http://YouTube.com/keybounce

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.