git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git diff-tree against the root commit
@ 2010-10-29  6:13 Joshua Jensen
  2010-11-07 10:58 ` Christoph Mallon
  0 siblings, 1 reply; 3+ messages in thread
From: Joshua Jensen @ 2010-10-29  6:13 UTC (permalink / raw)
  To: git@vger.kernel.org

I am mirroring a Git repository into another SCM.  I am using 'git 
diff-tree' to tell me what changes I need to make to the other SCM.

Today, I attempted to mirror a new submodule.  'git diff-tree' reported 
two SHAs... 0000000000000000000000000000000000000000 and the revision 
the submodule currently resides at.  I attempted to run a 'git 
diff-tree' within the submodule for the all zero SHA and the revision 
specified, but apparently, 0000000000000000000000000000000000000000 does 
not really represent the root commit and does not work.  I then 
discovered the --root option, but that doesn't seem to give me the 
complete file list either.

'git diff-tree' has been working great for everything else, but I really 
need a root commit diff-tree listing for proper automation.

What are my options?

Thanks!

Josh

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

* Re: git diff-tree against the root commit
  2010-10-29  6:13 git diff-tree against the root commit Joshua Jensen
@ 2010-11-07 10:58 ` Christoph Mallon
  2010-11-07 17:23   ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Mallon @ 2010-11-07 10:58 UTC (permalink / raw)
  To: Joshua Jensen; +Cc: git@vger.kernel.org

On 29.10.2010 08:13, Joshua Jensen wrote:
> I am mirroring a Git repository into another SCM.  I am using 'git diff-tree' to tell me what changes I need to make to the other SCM.
> 
> Today, I attempted to mirror a new submodule.  'git diff-tree' reported two SHAs... 0000000000000000000000000000000000000000 and the revision the submodule currently resides at.  I attempted to run a 'git diff-tree' within the submodule for the all zero SHA and the revision specified, but apparently, 0000000000000000000000000000000000000000 does not really represent the root commit and does not work.  I then discovered the --root option, but that doesn't seem to give me the complete file list either.
> 
> 'git diff-tree' has been working great for everything else, but I really need a root commit diff-tree listing for proper automation.
> 
> What are my options?

Diff against the empty tree. This gives you the treeish of the empty tree:
	git mktree < /dev/null
The result is 4b825dc642cb6eb9a060e54bf8d69288fbee4904. This magic number is used in git in several places. git's behaviour with parentless commits is somewhat annoying and/or broken.

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

* Re: git diff-tree against the root commit
  2010-11-07 10:58 ` Christoph Mallon
@ 2010-11-07 17:23   ` Linus Torvalds
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 2010-11-07 17:23 UTC (permalink / raw)
  To: Christoph Mallon; +Cc: Joshua Jensen, git@vger.kernel.org

On Sun, Nov 7, 2010 at 2:58 AM, Christoph Mallon
<christoph.mallon@gmx.de> wrote:
> On 29.10.2010 08:13, Joshua Jensen wrote:
>> I am mirroring a Git repository into another SCM.  I am using 'git diff-tree' to tell me what changes I need to make to the other SCM.
>>
>> Today, I attempted to mirror a new submodule.  'git diff-tree' reported two SHAs... 0000000000000000000000000000000000000000 and the revision the submodule currently resides at.  I attempted to run a 'git diff-tree' within the submodule for the all zero SHA and the revision specified, but apparently, 0000000000000000000000000000000000000000 does not really represent the root commit and does not work.  I then discovered the --root option, but that doesn't seem to give me the complete file list either.
>>
>> 'git diff-tree' has been working great for everything else, but I really need a root commit diff-tree listing for proper automation.
>>
>> What are my options?
>
> Diff against the empty tree.

That works, but it's a bit too technical.

The traditional way to do it is to just

   git diff-tree --root <commit>

where the magic "--root" option is just the flag to say "I want to see
the root as a diff too". The reason it isn't the default is
historical: since git started out for the kernel, and since the root
is an import from another tree, showing the root as a patch was
annoying.

You have to realize that back in the original coding days (when git
read-tree was introduced), it was meant for very basic scripting. What
is now "git log -p" used to be basically

  git-rev-list $(cat .git/HEAD) | git-diff-tree --stdin

and with the target being the kernel, the default of not showing that
first commit was a sane one (and going back even further,
git-diff-tree really only worked on trees, so you had to give explicit
beginning and end points).

Of course, by the time we actually had a "git log" command, I think
that default had already changed. But it still explains why there is a
separate option to show the root commit with a patch.

                                 Linus

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

end of thread, other threads:[~2010-11-07 17:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-29  6:13 git diff-tree against the root commit Joshua Jensen
2010-11-07 10:58 ` Christoph Mallon
2010-11-07 17:23   ` Linus Torvalds

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