git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
To: Junio C Hamano <junkio@cox.net>, Linus Torvalds <torvalds@osdl.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: More gitweb queries..
Date: Mon, 30 May 2005 01:56:31 +0200	[thread overview]
Message-ID: <20050529235630.GG12290@cip.informatik.uni-erlangen.de> (raw)
In-Reply-To: <20050529234606.GF12290@cip.informatik.uni-erlangen.de>

Hello,
here is the actual version of my merge function. However I have a
question left over: When I do an automatic merge or a threeway merge
should I set the head for the next round to the remote one or just let
it be the current one (this is the current behaviour) or maybe make it
configurable? Note: At the moment the *local* head for the merge-base is only
modified during the set of the first head *or* on a head forward condition. I
have no clue. I am going to write the 'more on merging chapter' after I have
figured this out. ;-)

sub
merge
{

	my $message      = undef;
	my $head         = undef;
	my $last_tree    = undef;
	my $fh;
	my @heads        = ();

	foreach my $r (@_) {
		my $current_head = @{$r}[0];
		my $current_url  = @{$r}[1];

		print "current_head => $current_head\ncurrent_url => $current_url\n";

		push(@heads, '-p', ${current_head});

		if (! defined($last_tree)) {
			$message    = "=> ${current_url}\n";
			$head       = $current_head;
			$last_tree  = $current_head;
			
			if (@_ == 1) {
				head($head);
				return;
			}

			next;
		}

		my $merge_base = gitcmdout('git-merge-base', $head, $current_head)
				 || die ("no merge-base");
		chomp($merge_base);

		print "head => $head\nremote => $current_head\nbase => $merge_base\n";
	
		if ($merge_base eq $current_head) {
			$message .= "<= ${current_url} (nothing to merge)\n";

			$#heads -= 2;

			next;
		}

		if ($merge_base eq $head) {
			$message   .= "<= ${current_url} (bringing head ahead)\n";
			$head       = ${current_head};
			$last_tree  = ${current_head};

			$#heads -= 4;
			push(@heads, '-p', $current_head);

			next;
		}

		gitcmd('git-read-tree', '-m', $merge_base, $last_tree, $current_head);
		if (! defined($last_tree = write_tree())) {
			system('git-merge-cache', '-o', 'git-merge-one-file-script', '-a');
			if (! defined($last_tree = write_tree())) {
				# FIXME: Make manual intervention possible
				# --tg 23:11 05-05-29
				die("Couldn't merge automatically: Call 'git resolve'");
			}
			$message .= "<= ${current_url} (threeway merge)\n";

		} else {
			$message .= "<= ${current_url} (automatic merge)\n";
		}
	}

	if (@heads == 1) {
		head(@head[0]);
		return;
	}

	open($fh, "+>", undef);
	print $fh $message;
	seek($fh, 0, 0);
	$head = gitcmdinout($fh, 'git-commit-tree', $last_tree, @heads);
	chomp($head);
	close $fh;

	head($head);
	return;
}

	Thomas

  reply	other threads:[~2005-05-29 23:54 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-27 19:24 More gitweb queries Linus Torvalds
2005-05-27 19:29 ` Thomas Glanzmann
2005-05-27 19:52   ` Junio C Hamano
2005-05-27 19:55     ` Thomas Glanzmann
2005-05-27 20:13       ` Junio C Hamano
2005-05-27 20:32         ` Thomas Glanzmann
2005-05-27 20:40           ` Junio C Hamano
2005-05-27 22:00             ` Linus Torvalds
2005-05-27 22:04               ` Thomas Glanzmann
2005-05-28  2:26               ` Junio C Hamano
2005-05-29 23:02           ` Thomas Glanzmann
2005-05-29 23:10             ` Thomas Glanzmann
2005-05-29 23:16               ` Thomas Glanzmann
2005-05-29 23:46                 ` Thomas Glanzmann
2005-05-29 23:56                   ` Thomas Glanzmann [this message]
2005-05-30  0:50                     ` Junio C Hamano
2005-05-30  0:57                       ` Junio C Hamano
2005-05-30  1:33                         ` Thomas Glanzmann
2005-05-30  1:30                       ` Thomas Glanzmann
2005-05-30  7:57                         ` Junio C Hamano
2005-05-30  8:36                           ` Thomas Glanzmann
2005-05-30  9:21                             ` Thomas Glanzmann
2005-05-30 10:20                               ` Junio C Hamano
2005-05-30 12:11                                 ` Thomas Glanzmann
2005-05-30 17:54                                   ` Junio C Hamano
2005-05-27 20:17       ` Linus Torvalds
2005-05-27 19:54   ` Junio C Hamano
2005-05-27 19:58     ` Thomas Glanzmann
2005-05-27 20:03   ` Linus Torvalds
2005-05-27 20:24     ` Junio C Hamano
2005-05-27 19:31 ` Thomas Glanzmann
2005-05-27 19:32 ` Junio C Hamano
2005-05-27 19:48   ` Linus Torvalds
2005-05-27 23:12 ` Benjamin Herrenschmidt
2005-05-27 23:59 ` Kay Sievers
2005-05-28  1:03   ` Daniel Serpell
2005-05-28  2:51     ` David Lang
2005-05-28 10:56       ` Kay Sievers
2005-05-28  8:42     ` Kay Sievers
2005-05-28 22:43       ` Benjamin Herrenschmidt
2005-05-30 23:03 ` Paul Mackerras
2005-05-31  2:27   ` Jeff Epler

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=20050529235630.GG12290@cip.informatik.uni-erlangen.de \
    --to=sithglan@stud.uni-erlangen.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=torvalds@osdl.org \
    /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).