git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: Caleb Cushing <xenoterracide@gmail.com>,
	git@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>
Subject: Re: mergetool feature request - select remote or local
Date: Wed, 14 May 2008 12:19:47 -0700	[thread overview]
Message-ID: <7vtzh0n164.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LNX.1.00.0805141351540.19665@iabervon.org> (Daniel Barkalow's message of "Wed, 14 May 2008 14:40:47 -0400 (EDT)")

Daniel Barkalow <barkalow@iabervon.org> writes:

> On Wed, 14 May 2008, Junio C Hamano wrote:
> ...
>> If this turns out to be a better approach, perhaps we would further want
>> to tweak things to make:
>> 
>> 	$ git checkout --unmerged MERGE_HEAD [--] [<pathspec>...]
>> 
>> to work (if you want "local", you would use "HEAD" instead of
>> "MERGE_HEAD").
>
> This is "for all (or some, by pathspecs) files currently unmerged in the 
> index, resolve them to the version in MERGE_HEAD", right?

Yeah, and possibly limited by pathspec as usual.

>> I would have done so here if "git checkout" were still a scripted version,
>> but now it is in C, it would take significantly more effort than it is
>> worth just to raise a weatherbaloon.
>
> Like this (also untested)? (This is missing defaulting to a pathspec of 
> '.' if --unmerged is used without any pathspecs)

Looks easy enough.  Caleb, does this approach fit the situation you
described better?

> diff --git a/builtin-checkout.c b/builtin-checkout.c
> index 10ec137..0bae1d4 100644
> --- a/builtin-checkout.c
> +++ b/builtin-checkout.c
> @@ -42,6 +42,8 @@ static int post_checkout_hook(struct commit *old, struct commit *new,
>  	return run_command(&proc);
>  }
>  
> +static int unmerged;
> +
>  static int update_some(const unsigned char *sha1, const char *base, int baselen,
>  		       const char *pathname, unsigned mode, int stage)
>  {
> @@ -59,6 +61,13 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
>  	hashcpy(ce->sha1, sha1);
>  	memcpy(ce->name, base, baselen);
>  	memcpy(ce->name + baselen, pathname, len - baselen);
> +	if (unmerged) {
> +		int pos = cache_name_pos(ce->name, len);
> +		if (!(pos && pos < active_nr && ce_same_name(active_cache[pos], active_cache[pos + 1]))) {
> +			free(ce);
> +			return 0;
> +		}
> +	}
>  	ce->ce_flags = create_ce_flags(len, 0);
>  	ce->ce_mode = create_ce_mode(mode);
>  	add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
> @@ -508,6 +517,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
>  			BRANCH_TRACK_EXPLICIT),
>  		OPT_BOOLEAN('f', NULL, &opts.force, "force"),
>  		OPT_BOOLEAN('m', NULL, &opts.merge, "merge"),
> +		OPT_BOOLEAN( 0 , "unmerged", &unmerged, "check out unmerged paths"),
>  		OPT_END(),
>  	};
>  

  reply	other threads:[~2008-05-14 19:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-14 11:21 mergetool feature request - select remote or local Caleb Cushing
2008-05-14 17:47 ` Junio C Hamano
2008-05-14 18:40   ` Daniel Barkalow
2008-05-14 19:19     ` Junio C Hamano [this message]
2008-05-15  1:25   ` Caleb Cushing

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=7vtzh0n164.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=xenoterracide@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).