From: Jeff King <peff@peff.net>
To: Christian Couder <chriscool@tuxfamily.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [RFC/PATCH] replace: add --graft option
Date: Mon, 19 May 2014 07:21:51 -0400 [thread overview]
Message-ID: <20140519112151.GC17492@sigill.intra.peff.net> (raw)
In-Reply-To: <20140518182939.5260.91202.chriscool@tuxfamily.org>
On Sun, May 18, 2014 at 08:29:38PM +0200, Christian Couder wrote:
> +static int create_graft(int argc, const char **argv, int force)
> +{
> + unsigned char old[20], new[20];
> + const char *old_ref = argv[0];
> + struct strbuf buf = STRBUF_INIT;
> + struct strbuf new_parents = STRBUF_INIT;
> + const char *parent_start, *parent_end;
> + int i;
> +
> + if (get_sha1(old_ref, old) < 0)
> + die(_("Not a valid object name: '%s'"), old_ref);
> + lookup_commit_or_die(old, old_ref);
> + if (read_sha1_commit(old, &buf))
> + die(_("Invalid commit: '%s'"), old_ref);
Do we want to peel to commits here? That is, should:
git replace --graft v1.5.0 v1.4.0
work? On the one hand, I see it as friendly. On the other, it may be a
bit surprising when working with something as potentially dangerous a
replace refs. If we don't do it automatically, the user can still say
"v1.5.0^{commit}" to be explicit. I dunno; maybe I am being overly
paranoid.
> + /* prepare new parents */
> + for (i = 1; i < argc; i++) {
> + unsigned char sha1[20];
> + if (get_sha1(argv[i], sha1) < 0)
> + die(_("Not a valid object name: '%s'"), argv[i]);
> + lookup_commit_or_die(sha1, argv[i]);
> + strbuf_addf(&new_parents, "parent %s\n", sha1_to_hex(sha1));
> + }
Either way, I think _this_ peeling is a sane thing to do.
-Peff
prev parent reply other threads:[~2014-05-19 11:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-18 18:29 [RFC/PATCH] replace: add --graft option Christian Couder
2014-05-19 9:42 ` Michael Haggerty
2014-05-19 11:19 ` Jeff King
2014-05-19 17:25 ` Junio C Hamano
2014-05-19 17:35 ` Jeff King
2014-05-19 18:34 ` Junio C Hamano
2014-05-23 6:39 ` Christian Couder
2014-05-19 11:21 ` Jeff King [this message]
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=20140519112151.GC17492@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).