Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import foreign commit prefixed instead of transplanting the tree #10

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/git-subrepo
Expand Up @@ -115,11 +115,21 @@ command:clone() {
# Create a tree object from the index:
local tree_commit="$(git write-tree)"

local parent2_orig_tree="$(git log --max-count=1 --format=%T $upstream_head)"

# Make a tree object with one dir "subdir" which points to parent2_orig_tree
# WARNING: Arbitrary code execution risk here.
local parent2_tree="$(
(
echo -n "040000 ${subdir}";
perl -e "print chr(0) . pack q[H*], q[$parent2_orig_tree];";
) | git hash-object -w -t tree --stdin
)";

# Create a commit object from the tree:
update_commit="$(
action-message |
git commit-tree \
"$(git log --max-count=1 --format=%T "$upstream_head")"
git commit-tree "$parent2_tree"
)"

# Create a merge commit:
Expand Down