git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-am with an initial checkin doesn't work
@ 2009-07-14 14:55 Dirk Süsserott
  2009-07-14 18:24 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Dirk Süsserott @ 2009-07-14 14:55 UTC (permalink / raw)
  To: Git Mailing List

Hi,

I've a question concerning 'git am' and 'git format-patch'. It seems
impossible to apply the "initial checkin" (as generated by git
format-patch -N --root) to an empty repository. The following workflow
might clarify that:

# Create a new repository with an initial checkin:
mkdir foo && cd foo && git init
echo "initial checkin" > initial.checkin
git add initial.checkin && git commit -m "initial checkin"

# Kinda "export" the repo:
git format-patch -1 --root; # generates 0001-initial-checkin.patch

# Re-create the repository:
rm -rf .git initial.checkin && git init

# Try to "import" the patch:
git am 0001-initial-checkin.patch

The latter yields to
fatal: HEAD: not a valid SHA1
fatal: bad revision 'HEAD'

It works, when I
git apply 0001-initial-checkin.patch
instead of am'ing it, but then the thing isn't committed and I've to
manually git-commit it.

Is this a bug, intentional behavior, or am I missing some magic option
to git-am?

Background:
I faced that problem when I tried to import some old data into Git
(namely .tar.gz files) and wanted to start with 2 or 3 commits of my own
(the import scripts) and then the other files on top of it. Because my
import scripts didn't work well at first, I had to re-, re-, and
re-import and start over all again. To always start with a clean repo, I
thought adding my scripts and then saving them as 000N-*.patch would be
a good idea, but the initial git-am didn't work. I know, there are other
ways (git-rebase is a big friend here), but I thought git-format-patch
and git-am worked symmetrically. Wrong?

Cheers,
    Dirk

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

* Re: git-am with an initial checkin doesn't work
  2009-07-14 14:55 git-am with an initial checkin doesn't work Dirk Süsserott
@ 2009-07-14 18:24 ` Junio C Hamano
  2009-07-15 14:46   ` Dirk Süsserott
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-07-14 18:24 UTC (permalink / raw)
  To: Dirk Süsserott; +Cc: Git Mailing List

Dirk Süsserott <newsletter@dirk.my1.cc> writes:

> # Try to "import" the patch:
> git am 0001-initial-checkin.patch
>
> The latter yields to
> fatal: HEAD: not a valid SHA1
> fatal: bad revision 'HEAD'
>
> It works, when I
> git apply 0001-initial-checkin.patch
> instead of am'ing it, but then the thing isn't committed and I've to
> manually git-commit it.
>
> Is this a bug, intentional behavior, or am I missing some magic option
> to git-am?

The original mode of operation of the e-mail patchflow commands was to
support project members who contribute changes to _existing_ projects, and
maintainers to accept such changes.  The reason behind the behaviour you
are observing is merely a historical accident that nobody bothered about
use cases outside of that original purpose.  For exactly the same reason,
the original implementation of format-patch did not bother with the root
commit.

IOW, this was not an intentional behaviour, neither it was a bug.  It was
simply use outside of spec, and nobody bothered until f79d4c8 (git-am:
teach git-am to apply a patch to an unborn branch, 2009-04-10), which is
v1.6.3-rc1~11^2, added a support for it.

What version of git are you running?

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

* Re: git-am with an initial checkin doesn't work
  2009-07-14 18:24 ` Junio C Hamano
@ 2009-07-15 14:46   ` Dirk Süsserott
  0 siblings, 0 replies; 3+ messages in thread
From: Dirk Süsserott @ 2009-07-15 14:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Dirk Süsserott, Git Mailing List

Am 14.07.2009 20:24 schrieb Junio C Hamano:
> Dirk Süsserott <newsletter@dirk.my1.cc> writes:
> 
>> # Try to "import" the patch:
>> git am 0001-initial-checkin.patch
>>
>> The latter yields to
>> fatal: HEAD: not a valid SHA1
>> fatal: bad revision 'HEAD'
>>
>> It works, when I
>> git apply 0001-initial-checkin.patch
>> instead of am'ing it, but then the thing isn't committed and I've to
>> manually git-commit it.
>>
>> Is this a bug, intentional behavior, or am I missing some magic option
>> to git-am?
> 
> The original mode of operation of the e-mail patchflow commands was to
> support project members who contribute changes to _existing_ projects, and
> maintainers to accept such changes.  The reason behind the behaviour you
> are observing is merely a historical accident that nobody bothered about
> use cases outside of that original purpose.  For exactly the same reason,
> the original implementation of format-patch did not bother with the root
> commit.
> 
> IOW, this was not an intentional behaviour, neither it was a bug.  It was
> simply use outside of spec, and nobody bothered until f79d4c8 (git-am:
> teach git-am to apply a patch to an unborn branch, 2009-04-10), which is
> v1.6.3-rc1~11^2, added a support for it.
> 
> What version of git are you running?
> 
> 

Hi Junio,

I used "1.6.1.9.g97c34" which is an msysGit release and not exactly the 
latest. I now updated to "1.6.3.2.1299.gee46c" and the problem 
dissapeared. Thanks for the hint and sorry for the noise.

     -- Dirk

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

end of thread, other threads:[~2009-07-15 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-14 14:55 git-am with an initial checkin doesn't work Dirk Süsserott
2009-07-14 18:24 ` Junio C Hamano
2009-07-15 14:46   ` Dirk Süsserott

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