threads / discuss / 3821

Can't export whole repo as patches

Subject: Can't export whole repo as patches

## tl;dr

10 messages between Apr 7, 2006 and Apr 9, 2006.

replies: 9people: 5as markdown or json

Peter Baumann· Apr 7, 2006, 18:47 UTC · lore

I'd like to export the whole history of a project of mine via patches but I can't get the inital commit.

How can I get the inital commit as a patch?
That's what I tried:
  git --version
  git version 1.2.4				# debian sarge
  mkdir /tmp/testrepo && cd /tmp/testrepo
  git-init-db
  echo a > a_file.txt
  git-add a_file.txt
  git-commit -a -m "a_file added"
  echo b >> a_file.txt
  git-commit -a -m "a_file modifed"
  xp:/tmp/testrepo git-format-patch master~1
  0001-a_file-modified.txt
  cat 0001-a_file-modified.txt
  From nobody Mon Sep 17 00:00:00 2001
  From: Peter Baumann <peter.baumann@gmail.com>
  Date: Fri Apr 7 12:20:54 2006 +0200
  Subject: [PATCH] a_file modified
  ---
   a_file.txt |    1 +
   1 files changed, 1 insertions(+), 0 deletions(-)
  d8ceeed82a29004c066a98e0d390818e65fa9da7
  diff --git a/a_file.txt b/a_file.txt
  index 7898192..422c2b7 100644
  --- a/a_file.txt
  +++ b/a_file.txt
  @@ -1 +1,2 @@
   a
  +b
  --
  1.2.4

As you can see, there is only a patch of the second commit. But it seems that this behaviour is correct, because I asked for the diff between master^..master

Obviously, I wanted a way to get the diff of master~2..master.
Trying harder:
  git-format-patch master~2
  Not a valid rev master~2 (master~2..HEAD)
Any hint to the correct way is appreciated.

</me thinking loudly> The best would be if git would have an implicit tag or branch called "init" (name doesn't really matter) which is the root of an empty repository. In that case one can do git-format-patch root..master and it would the right thing.

Greetings,
  Peter Baumann
Junio C Hamano· Apr 7, 2006, 19:18 UTC · re: Peter Baumann · lore

Re: Can't export whole repo as patches

Peter Baumann <peter.baumann@gmail.com> writes:
> How can I get the inital commit as a patch?

format-patch is designed to get a patch to send to upstream, and does not handle the root commit. In your two revisions repository, you could do something like this:

	$ git diff-tree -p --root master~1
Or more in general:
	$ git rev-list master |
          git diff-tree --stdin --root --pretty=fuller -p

BTW, I've been meaning to add --pretty=patch to give format-patch compatible output to diff-tree, but haven't got around to actually do it. Another thing I've been meaning to do is "git log --diff" which is more or less "git whatchanged".

Peter Baumann· Apr 8, 2006, 18:02 UTC · re: Junio C Hamano · lore

How to create independent branches

On Fri, Apr 07, 2006 at 12:18:27PM -0700, Junio C Hamano wrote:
Show 20 quoted lines
> Peter Baumann <peter.baumann@gmail.com> writes:
> 
> > How can I get the inital commit as a patch?
> 
> format-patch is designed to get a patch to send to upstream, and
> does not handle the root commit.  In your two revisions
> repository, you could do something like this:
> 
> 	$ git diff-tree -p --root master~1
> 
> Or more in general:
> 
> 	$ git rev-list master |
>           git diff-tree --stdin --root --pretty=fuller -p
> 
> BTW, I've been meaning to add --pretty=patch to give
> format-patch compatible output to diff-tree, but haven't got
> around to actually do it.  Another thing I've been meaning to do
> is "git log --diff" which is more or less "git whatchanged".
> 
Ok. That did it.

Another question. I'd like to create a totaly independent branch (like the "todo" branch in git). Is there a more user friendly way than doing

git-checkout -b todo rm .git/refs/heads/todo rm .git/index rm <all_files_in_your_workdir>

... hack hack hack ... git-commit -a

I looked all over the docs, but can't find anything obvious.
-Peter
Jakub Narebski· Apr 8, 2006, 18:28 UTC · re: Peter Baumann · lore

Re: How to create independent branches

Peter Baumann wrote:
Show 10 quoted lines
> Another question. I'd like to create a totaly independent branch (like
> the "todo" branch in git). Is there a more user friendly way than doing
> 
> git-checkout -b todo
> rm .git/refs/heads/todo
> rm .git/index
> rm <all_files_in_your_workdir>
> 
> ... hack hack hack ...
> git-commit -a

Wouldn't it be better and more natural to go back to first commit, or even empty repository state at the beginning, and branch there? Or make separate repository?

-- 
Jakub Narebski
Warsaw, Poland
Peter Baumann· Apr 9, 2006, 08:11 UTC · re: Jakub Narebski · lore

Re: How to create independent branches

On Sat, Apr 08, 2006 at 08:28:58PM +0200, Jakub Narebski wrote:
Show 14 quoted lines
> Peter Baumann wrote:
> 
> > Another question. I'd like to create a totaly independent branch (like
> > the "todo" branch in git). Is there a more user friendly way than doing
> > 
> > git-checkout -b todo
> > rm .git/refs/heads/todo
> > rm .git/index
> > rm <all_files_in_your_workdir>
> > 
> > ... hack hack hack ...
> > git-commit -a
> 
> Wouldn't it be better and more natural to go back to first commit? > 
If I go back to the first commit, I'll get the following:
	first
	 / \
	/   \
   master    todo

That's not what I want, because in the near future I want to merge master and todo, but in my case, todo consists of only of one file (lets call it file_a), and the master branch has severeal files (file_{a..z}). If I go back to first, I have to delete all files file_{b..z}. Further file_a from todo and file_a from master are not equal, the share just the same name. But in the near future, they will be merged together, so they are equal.

If I go with the above branching, I'll _think_ (I may be wrong, please correct me if I am) I get a merge conflict or worse, all my other files file_a{b..z} are merged as "deleted", wich is wrong.

> Or even empty repository state at the beginning, and branch there?

This isn't possible because the repository already exists and I don't know how to go back to the empty repository state. Even

	git-init-db
	git branch todo master
didn't work.
> Or make separate repository?

Ok. You got it. In fact, the todo branch alread exists as a seperate repository and I'd like to integrate this in my master repository for easier handling (diff etc.)

To import todo as a subproject doesn't seem right, because it's not something really independent in the view of the master repo and I'am going to merge todo _into_ master in the near future.

Any further suggestions?
-Peter
Peter Baumann· Apr 9, 2006, 08:22 UTC · re: Peter Baumann · lore

Re: How to create independent branches

On Sun, Apr 09, 2006 at 10:11:05AM +0200, Peter Baumann wrote:
Show 57 quoted lines
> On Sat, Apr 08, 2006 at 08:28:58PM +0200, Jakub Narebski wrote:
> > Peter Baumann wrote:
> > 
> > > Another question. I'd like to create a totaly independent branch (like
> > > the "todo" branch in git). Is there a more user friendly way than doing
> > > 
> > > git-checkout -b todo
> > > rm .git/refs/heads/todo
> > > rm .git/index
> > > rm <all_files_in_your_workdir>
> > > 
> > > ... hack hack hack ...
> > > git-commit -a
> > 
> > Wouldn't it be better and more natural to go back to first commit? > 
> 
> If I go back to the first commit, I'll get the following:
> 
> 	first
> 	 / \
> 	/   \
>    master    todo
> 
> That's not what I want, because in the near future I want to merge
> master and todo, but in my case, todo consists of only of one file (lets
> call it file_a), and the master branch has severeal files (file_{a..z}).
> If I go back to first, I have to delete all files file_{b..z}.
> Further file_a from todo and file_a from master are not equal, the share
> just the same name. But in the near future, they will be merged
> together, so they are equal.
> 
> If I go with the above branching, I'll _think_ (I may be wrong, please
> correct me if I am) I get a merge conflict or worse, all my other files
> file_a{b..z} are merged as "deleted", wich is wrong.
> 
> > Or even empty repository state at the beginning, and branch there?
> 
> This isn't possible because the repository already exists and I don't
> know how to go back to the empty repository state. Even 
> 
> 	git-init-db
> 	git branch todo master
> 
> didn't work.
> 
> > Or make separate repository?
> 
> Ok. You got it. In fact, the todo branch alread exists as a seperate
> repository and I'd like to integrate this in my master repository for
> easier handling (diff etc.)
> 
> To import todo as a subproject doesn't seem right, because it's not
> something really independent in the view of the master repo and I'am
> going to merge todo _into_ master in the near future.
> 
> Any further suggestions?
> 

Just in case nobody noticed, that's why I asked for exporting the whole repo with git-format-patch in the first place, because I'd like to import the patches with git-am in the totally independent branch.

Peter
Junio C Hamano· Apr 8, 2006, 20:49 UTC · re: Peter Baumann · lore

Re: How to create independent branches

Peter Baumann <peter.baumann@gmail.com> writes:
Show 12 quoted lines
> Another question. I'd like to create a totaly independent branch (like
> the "todo" branch in git). Is there a more user friendly way than doing
>
> git-checkout -b todo
> rm .git/refs/heads/todo
> rm .git/index
> rm <all_files_in_your_workdir>
>
> ... hack hack hack ...
> git-commit -a
>
> I looked all over the docs, but can't find anything obvious.

My "todo" branch is not even part of my main git repository. I just have two independent repositories (git and todo) locally, and push into the same public repository.

        
Petr Baudis· Apr 8, 2006, 20:57 UTC · re: Junio C Hamano · lore

Re: How to create independent branches

Dear diary, on Sat, Apr 08, 2006 at 10:49:04PM CEST, I got a letter where Junio C Hamano <junkio@cox.net> said that...

Show 18 quoted lines
> Peter Baumann <peter.baumann@gmail.com> writes:
> 
> > Another question. I'd like to create a totaly independent branch (like
> > the "todo" branch in git). Is there a more user friendly way than doing
> >
> > git-checkout -b todo
> > rm .git/refs/heads/todo
> > rm .git/index
> > rm <all_files_in_your_workdir>
> >
> > ... hack hack hack ...
> > git-commit -a
> >
> > I looked all over the docs, but can't find anything obvious.
> 
> My "todo" branch is not even part of my main git repository.  I
> just have two independent repositories (git and todo) locally,
> and push into the same public repository.

Wouldn't it be better to separate it to two distinct public repositories as well? It's confusing people and encouraging a practice that really isn't very feasible and practical in Git.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time.  I think
I have forgotten this before.
Junio C Hamano· Apr 8, 2006, 21:00 UTC · re: Petr Baudis · lore

Re: How to create independent branches

Petr Baudis <pasky@suse.cz> writes:
> Wouldn't it be better to separate it to two distinct public repositories
> as well? It's confusing people and encouraging a practice that really
> isn't very feasible and practical in Git.

That's mainly historical. I haven't bothered to check it recently, but /pub/scm/git was not writable by me on kernel.org machine, only /pub/scm/git/git.git/ was.

Johannes Schindelin· Apr 8, 2006, 22:09 UTC · re: Petr Baudis · lore

Re: How to create independent branches

Hi,
On Sat, 8 Apr 2006, Petr Baudis wrote:
Show 10 quoted lines
> Dear diary, on Sat, Apr 08, 2006 at 10:49:04PM CEST, I got a letter
> where Junio C Hamano <junkio@cox.net> said that...
> > 
> > My "todo" branch is not even part of my main git repository.  I
> > just have two independent repositories (git and todo) locally,
> > and push into the same public repository.
> 
> Wouldn't it be better to separate it to two distinct public repositories
> as well? It's confusing people and encouraging a practice that really
> isn't very feasible and practical in Git.

How so? I find it highly practical, and do it myself. For example, I track a project which is not version-controlled at all. So I have a "branch" in git where I keep the tools to fake that version-controlling. And git makes it easy to just fetch the changes of both the project and my tools.

Ciao, Dscho

← back to recent threads