git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander GQ Gerasiov <gq@cs.msu.su>
To: git@vger.kernel.org
Subject: How to put tree into index
Date: Wed, 20 Nov 2013 15:47:14 +0400	[thread overview]
Message-ID: <20131120154714.39fc5202@snail> (raw)

Hello there.

I need to realize the following scenario with git.

1. I have repository with tree like this:

dir1/
	file1
	file2
	file3

dir2/
	subdir1/
		some files


2. Current branch is B.

3. I want to get dir1 from branch A, and save it's content on current
branch (B) as dir2/subdir1



>From my point I should do the following

1. Get tree-object sha1 of dir1 from A with git ls-tree
2. Put into index new tree-object with the same sha1/content, but under
the name dir2/subdir1
3. Commit index.


But it doesn't work for me. It works with blob object, but not with
tree object.

I tried the following commands:

git ls-tree A dir1 | 
sed 's#dir1#dir2/subdir1#' | 
git update-index --index-info

But after this I see in the index not tree-object with mode 040000, but
commit-object with mode 160000.



So my question is
How to put into index tree-object with known sha1 and given name?


PS I was able to do what I need when copied files, not tree-itself.
Just add -r to git ls-tree, and put into index blobs/files, not tree.
But I'm interested: is it possible to put tree-object into index?

             reply	other threads:[~2013-11-20 11:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-20 11:47 Alexander GQ Gerasiov [this message]
2013-11-20 12:25 ` How to put tree into index Matthew Cengia
2013-11-20 12:41 ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131120154714.39fc5202@snail \
    --to=gq@cs.msu.su \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).