From: Michael Schubert <mschub@elegosoft.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Pete Harlan <pgit@pcharlan.com>, git@vger.kernel.org
Subject: Re: [bug?] checkout -m doesn't work without a base version
Date: Wed, 14 Dec 2011 11:19:22 +0100 [thread overview]
Message-ID: <4EE8782A.9040507@elegosoft.com> (raw)
In-Reply-To: <7vbormn8vk.fsf@alter.siamese.dyndns.org>
On 12/05/2011 07:58 PM, Junio C Hamano wrote:
> @@ -150,18 +155,27 @@ static int checkout_merged(int pos, struct checkout *state)
> int status;
> unsigned char sha1[20];
> mmbuffer_t result_buf;
> + unsigned char threeway[3][20];
> + unsigned mode;
> +
> + memset(threeway, 0, sizeof(threeway));
> + while (pos < active_nr) {
> + int stage;
> + stage = ce_stage(ce);
> + if (!stage || strcmp(path, ce->name))
> + break;
> + hashcpy(threeway[stage - 1], ce->sha1);
> + if (stage == 2)
> + mode = create_ce_mode(ce->ce_mode);
> + pos++;
> + ce = active_cache[pos];
> + }
> + if (is_null_sha1(threeway[1]) || is_null_sha1(threeway[2]))
> + return error(_("path '%s' does not have necessary versions"), path);
>
> - if (ce_stage(ce) != 1 ||
> - active_nr <= pos + 2 ||
> - strcmp(active_cache[pos+1]->name, path) ||
> - ce_stage(active_cache[pos+1]) != 2 ||
> - strcmp(active_cache[pos+2]->name, path) ||
> - ce_stage(active_cache[pos+2]) != 3)
> - return error(_("path '%s' does not have all 3 versions"), path);
> -
> - read_mmblob(&ancestor, active_cache[pos]->sha1);
> - read_mmblob(&ours, active_cache[pos+1]->sha1);
> - read_mmblob(&theirs, active_cache[pos+2]->sha1);
> + read_mmblob(&ancestor, threeway[0]);
> + read_mmblob(&ours, threeway[1]);
> + read_mmblob(&theirs, threeway[2]);
>
> /*
> * NEEDSWORK: re-create conflicts from merges with
> @@ -192,9 +206,7 @@ static int checkout_merged(int pos, struct checkout *state)
> if (write_sha1_file(result_buf.ptr, result_buf.size,
> blob_type, sha1))
> die(_("Unable to add merge result for '%s'"), path);
> - ce = make_cache_entry(create_ce_mode(active_cache[pos+1]->ce_mode),
> - sha1,
> - path, 2, 0);
> + ce = make_cache_entry(mode, sha1, path, 2, 0);
> if (!ce)
> die(_("make_cache_entry failed for path '%s'"), path);
> status = checkout_entry(ce, state, NULL);
gcc 4.6.2:
builtin/checkout.c: In function ‘cmd_checkout’:
builtin/checkout.c:210:5: warning: ‘mode’ may be used uninitialized in this function [-Wuninitialized]
builtin/checkout.c:160:11: note: ‘mode’ was declared here
next prev parent reply other threads:[~2011-12-14 10:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-04 22:31 [bug?] checkout -m doesn't work without a base version Pete Harlan
2011-12-05 18:58 ` Junio C Hamano
2011-12-07 7:30 ` Pete Harlan
2011-12-08 18:27 ` Junio C Hamano
2011-12-12 1:48 ` Pete Harlan
2011-12-12 5:29 ` Junio C Hamano
2011-12-20 20:37 ` [PATCH] t/t2023-checkout-m.sh: fix use of test_must_fail Ævar Arnfjörð Bjarmason
2011-12-20 21:23 ` Junio C Hamano
2011-12-14 10:19 ` Michael Schubert [this message]
2011-12-14 17:54 ` [bug?] checkout -m doesn't work without a base version Junio C Hamano
2011-12-15 4:20 ` Miles Bader
2011-12-15 10:11 ` Michael Schubert
2011-12-15 10:42 ` Andreas Schwab
2011-12-15 17:36 ` Junio C Hamano
2011-12-16 22:38 ` Ramsay Jones
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=4EE8782A.9040507@elegosoft.com \
--to=mschub@elegosoft.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pgit@pcharlan.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).