From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Klas Lindberg <klas.lindberg@gmail.com>, git@vger.kernel.org
Subject: Re: Create a new commit from patches without using any worktree?
Date: Wed, 27 Oct 2010 12:28:58 +0200 [thread overview]
Message-ID: <AANLkTimykD+2Y9WKs2gXE+1Q2SS=5DaN+Kf4sW2dhegB@mail.gmail.com> (raw)
In-Reply-To: <4CC7EBEA.9070804@viscovery.net>
On Wed, Oct 27, 2010 at 11:07, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Am 10/27/2010 3:49, schrieb Klas Lindberg:
>> Is there any way to record a new commit based on contents in a patch
>> without going through a worktree?
>
> This script may be a starter. It takes a commit on the command line
> instead of a patch, but it processes that commit as a patch ("diff-tree -p"),
> so the script should be easy to adapt.
>
> -- Hannes
>
> -- 8< --
> #!/bin/sh
>
> OPTIONS_SPEC="\
> git post to-ref [from-rev]
> --
> "
> . git-sh-setup
>
> while test $# != 0
> do
> case "$1" in
> --) shift; break;;
> -*) usage;;
> *) break;;
> esac
> shift
> done
>
> FROM=$(git rev-parse --verify --symbolic-full-name "$1") || exit
> shift
> if test $# = 0; then
> set -- HEAD
> fi
> test $# = 1 || usage
>
> # populate a temporary index
> tmpidx=$GIT_DIR/index-post-$$
I think you should honor GIT_INDEX_FILE here, so that you can
guarantee that tmpidx is on the same device as the index file used by
git read-tree.
Bert
> git read-tree --index-output="$tmpidx" "$FROM" || exit
> GIT_INDEX_FILE=$tmpidx
> export GIT_INDEX_FILE
> trap 'rm -f "$tmpidx"' 0 1 2 15
>
> git diff-tree -p -M -C "$@" | git apply --cached || exit
>
> newtree=$(git write-tree) &&
> newrev=$(
> eval "$(get_author_ident_from_commit "$1")"
> git-cat-file commit "$1" | sed -e '1,/^$/d' |
> git commit-tree $newtree -p "$FROM"
> ) || exit
>
> if git check-ref-format "$FROM"
> then
> set_reflog_action post
> subject=$(git log --no-walk --pretty=%s "$newrev") &&
> git update-ref -m "$GIT_REFLOG_ACTION: $subject" "$FROM" $newrev || exit
> fi
> if test -z "$GIT_QUIET"
> then
> git rev-list -1 --oneline $newrev
> fi
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2010-10-27 10:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-27 1:49 Create a new commit from patches without using any worktree? Klas Lindberg
2010-10-27 2:58 ` Jonathan Nieder
2010-10-27 9:07 ` Johannes Sixt
2010-10-27 10:28 ` Bert Wesarg [this message]
2010-10-27 15:20 ` Klas Lindberg
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='AANLkTimykD+2Y9WKs2gXE+1Q2SS=5DaN+Kf4sW2dhegB@mail.gmail.com' \
--to=bert.wesarg@googlemail.com \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--cc=klas.lindberg@gmail.com \
/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).