Re: [BUG] Cannot push some grafted branches
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 21, 2012, 16:58 UTC
- Message-ID
- <7vzk171gvh.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <50D45A78.3020104@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 44 quoted lines
> While replace refs are much more general than grafts, it seems the two
> main uses are:
>
> - grafts (change the recorded parents for a commit)
> - svn cleanup (convert tagging commits into tag objects)
>
> The latter one being quite a special case already.
>
> The script below has helped me move from grafts to replace objects.
> While not being super clean, something like it may be fit for contrib.
>
> I think we ought to help John Doe get along with parents, while we can
> safely leave most more advanced operations to people who know how to
> edit a raw object file. Putting that facility into "git-commit" seems to
> be too encouraging, though - people would use replace when they should
> use amend or rebase-i. I'd prefer a special git-replace mode (be it
> "--graft" or "--graft-commit") which does just what my script does. We
> could add things like "--commit-tag" later, a full blown
> "object-factory" seems like overkill.
>
> Michael
>
> --->%---
>
> #!/bin/sh
>
> die () {
> echo "$@"
> rm -f "$commitfile"
> exit 1
> }
>
> warn () {
> echo "$@"
> }
>
> test $# -gt 0 || die "Usage: $0 <commit> [<parent>]*"
>
> for commit
> do
> git rev-parse --verify -q "$commit" >/dev/null || die "Cannot parse
> $commit."
> test x$(git cat-file -t $commit) == "xcommit" || die "$commit is no
> commit."s/==/=/ or you have to say #!/bin/bash on the first line, I think. Appears multiple times throughout this script.
Show 12 quoted lines
> done > > commit="$1" > shift > > commitfile=$(mktemp) > > git cat-file commit "$commit" | while read a b > do > if test "$a" != "parent" > then > echo $a $b
You are losing information on non-header lines by reading without "-r" in the above, and also multi-line headers (e.g. mergetag), aren't you?
Show 13 quoted lines
> fi > if test "$a" == "tree" > then > for parent > do > echo "parent $(git rev-parse $parent)" > done > fi > done >$commitfile > hash=$(git hash-object -t commit -w "$commitfile") || die "Cannot create > commit object." > git replace "$commit" $hash > rm -f $commitfile