git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Can't diff against the 00000000 revision

From
SMStefan Monnier <monnier@iro.umontreal.ca>
Date
Jan 12, 2016, 15:17 UTC
Message-ID
<jwv4meiygrc.fsf-monnier+gmane.comp.version-control.git@gnu.org>
If I look at the initial commit on a branch, I see something like:
    % git show d59cfff346c3e210adc26501f8cebf8da5ab2e7d
    commit d59cfff346c3e210adc26501f8cebf8da5ab2e7d
    Author: Stefan Monnier <monnier@iro.umontreal.ca>
    Date:   Wed Dec 2 20:46:51 2015 -0500
    
        Initial release
    
    diff --git a/bugit b/bugit
    new file mode 100755
    index 0000000..681bd38
    --- /dev/null
    +++ b/bugit
    @@ -0,0 +1,512 @@
    ...
which is great.  But I can't get the same result with
    git diff 0000000..681bd38
because it complains:
    % git diff 0000000..681bd38
    fatal: ambiguous argument '0000000..681bd38': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'
    %

I bumped into this problem in a post-receive hook where I need to pay attention to all newly added files, and where this problem means that I can't use the same code for a newly added branch as for a push on a pre-existing branch.

I currently work around the problem by adding a dummy empty branch, but being able to use the revision 00000000 as a known reference to an empty tree would come in really handy, and since it's already used at various places in Git (post-receive hook and "git show" output, at least), it would seem like a natural extension.

        Stefan
Next: Jeff King
Message 1 of 8 in “Can't diff against the 00000000 revision”
  1. Stefan MonnierJan 12, 2016
  2. Jeff KingJan 12, 2016
  3. Jeff KingJan 12, 2016
  4. Stefan MonnierJan 12, 2016
  5. Jeff KingJan 12, 2016
  6. Junio C HamanoJan 12, 2016
  7. Andreas SchwabJan 12, 2016
  8. Jeff KingJan 12, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.