git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [bug?] checkout -m doesn't work without a base version

From
MSMichael Schubert <mschub@elegosoft.com>
Date
Dec 14, 2011, 10:19 UTC
Message-ID
<4EE8782A.9040507@elegosoft.com>
In-Reply-To
<7vbormn8vk.fsf@alter.siamese.dyndns.org>
On 12/05/2011 07:58 PM, Junio C Hamano wrote:
Show 50 quoted lines
> @@ -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

Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 15 in “[bug?] checkout -m doesn't work without a base version”
  1. Pete HarlanDec 4, 2011
  2. Junio C HamanoDec 5, 2011
  3. Pete HarlanDec 7, 2011
  4. Junio C HamanoDec 8, 2011
  5. Pete HarlanDec 12, 2011
  6. Junio C HamanoDec 12, 2011
  7. t/t2023-checkout-m.sh: fix use of test_must_failÆvar Arnfjörð Bjarmason, Dec 20, 2011
  8. Junio C HamanoDec 20, 2011
  9. Michael SchubertDec 14, 2011
  10. Junio C HamanoDec 14, 2011
  11. Miles BaderDec 15, 2011
  12. Michael SchubertDec 15, 2011
  13. Andreas SchwabDec 15, 2011
  14. Junio C HamanoDec 15, 2011
  15. Ramsay JonesDec 16, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.