git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Haberman <stephen@exigencecorp.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, Michael J Gruber <git@drmicha.warpmail.net>,
	Stephan Beyer <s-beyer@gmx.net>,
	Sitaram Chamarty <sitaramc@gmail.com>
Subject: Re: [PATCH] rebase -p: seed first commit in case it's before the merge bases.
Date: Sat, 17 Jan 2009 21:57:51 -0600	[thread overview]
Message-ID: <20090117215751.60ade90a.stephen@exigencecorp.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0901180108480.3586@pacific.mpi-cbg.de>


> > However, I have a strong feeling that just piling onto the current
> > code will not fix the underlying issues.
> 
> BTW just to clarify what I mean by "underlying issues": if you say
> "git rebase -i" in Sitaram's test case, you will see the two commits
> -- as expected.
> 
> However, if you add "-p", all of a sudden you will only see "noop".
> IMO there is no excuse that the code can hide them at all.  If the
> commits are reachable from HEAD but not from $UPSTREAM, they have to
> be in the list.  As simple as that.

Agreed--the rewritten-parent probing being rooted at the merge bases
was not good enough.

> Another thing that I find horribly wrong: there is a "touch
> $REWRITTEN/sha1".  There was a simple design in the beginning: the
> files in $REWRITTEN are actually a mapping from old SHA-1 (file name)
> to new SHA-1 (content).  This was broken, without any good
> explanation.

Perhaps it is not "good", but the explanation a blank REWRITTEN/sha1 is
used a marker during the probe phase that this commit will be rewritten.
So when looking at any of its children commits, they should be rewritten
if a REWRITTEN/parentSha1 exists. Then as the rewriting actually happens,
they get filled in with the new sha1. I cribbed this approach from
Stephan's sequencer rewrite of rebase-i-p.

If you want a different data structure, be it file based, or bash/list
based, or whatever, to track "this commit will eventually be rewritten
but we haven't gotten there yet" during the probe, then we could go back
to leaving REWRITTEN/sha1 alone until after the sha1 commit has been
rebased.

I'm open to suggestions.

Also, as you seem to realize, the current bug stems from not knowing how
to initialize the rewritten data structure. For Sitaram's case, the
first commit is behind any of the merge bases, so marking its parents
(if they exist) as rewritten to ONTO seems reasonable.

If there are no parents, as you point out, I added a "-o sha1 = FIRST"
that should also get the ball rolling. It's another hack, but does this
address your concern until a large refactoring happens?

-------------------------- git-rebase--interactive.sh --------------------------
index c8b0861..8740d9f 100755
@@ -604,11 +604,18 @@ first and then run 'git rebase --continue' again."
 				echo $ONTO > "$REWRITTEN"/$c ||
 					die "Could not init rewritten commits"
 			done
+			# Along with the merge bases, look at the first commit's
+			# parent (which may be before the merge base) and mark it
+			# as rewritten to ONTO
+			FIRST="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
+			for p in $(git rev-list --parents -1 $FIRST | cut -d' ' -f2)
+			do
+				echo $ONTO > "$REWRITTEN/$p"
+			done
 			# No cherry-pick because our first pass is to determine
 			# parents to rewrite and skipping dropped commits would
 			# prematurely end our probe
 			MERGES_OPTION=
-			first_after_upstream="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
 		else
 			MERGES_OPTION="--no-merges --cherry-pick"
 		fi
@@ -629,12 +636,12 @@ first and then run 'git rebase --continue' again."
 				preserve=t
 				for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
 				do
-					if test -f "$REWRITTEN"/$p -a \( $p != $UPSTREAM -o $sha1 = $first_after_upstream \)
+					if test -f "$REWRITTEN"/$p -a $p != $UPSTREAM
 					then
 						preserve=f
 					fi
 				done
-				if test f = "$preserve"
+				if test f = "$preserve" -o $sha1 = $FIRST
 				then
 					touch "$REWRITTEN"/$sha1
 					echo "pick $shortsha1 $rest" >> "$TODO"

(I'm adding the other 3 cc's back after my failed patch attempt
stripped them out--sorry, guys.)

- Stephen

  reply	other threads:[~2009-01-18  3:59 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-15 10:39 rebase -p confusion in 1.6.1 Sitaram Chamarty
2009-01-15 13:34 ` Johannes Schindelin
2009-01-15 14:51   ` Sitaram Chamarty
2009-01-15 15:09     ` Stephan Beyer
2009-01-15 15:21       ` Sitaram Chamarty
2009-01-15 13:38 ` Stephan Beyer
2009-01-15 13:58   ` Johannes Schindelin
2009-01-15 15:03     ` Sitaram Chamarty
2009-01-15 13:39 ` Michael J Gruber
2009-01-15 13:55   ` Stephan Beyer
2009-01-15 14:14     ` Michael J Gruber
2009-01-15 14:25       ` Johannes Schindelin
2009-01-15 14:45         ` Michael J Gruber
2009-01-15 16:04           ` Johannes Schindelin
2009-01-15 16:24             ` Sitaram Chamarty
2009-01-15 16:53               ` Johannes Schindelin
2009-01-15 18:22                 ` Sitaram Chamarty
2009-01-15 16:56             ` Michael J Gruber
2009-01-15 18:18               ` Johannes Schindelin
     [not found]               ` <cover.1232233454.git.stephen@exigencecorp.com>
2009-01-17 23:41                 ` [PATCH] do not drop commits before the merge base Johannes Schindelin
     [not found]                 ` <ac1a4533de095f916dd68029793c8ee6eb02d200.1232233454.git.stephen@exigencecorp.com>
     [not found]                   ` <a524993b13ee586cf0e8fbd3b6459ccd6767c6d8.1232233454.git.stephen@exigencecorp.com>
2009-01-17 23:51                     ` [PATCH] rebase -p: seed first commit in case it's before the merge bases Johannes Schindelin
2009-01-18  0:11                       ` Stephen Haberman
2009-01-18  0:19                       ` Johannes Schindelin
2009-01-18  3:57                         ` Stephen Haberman [this message]
2009-01-18  4:02                           ` Stephen Haberman
2009-01-15 14:40       ` rebase -p confusion in 1.6.1 Stephan Beyer
2009-01-15 16:43         ` Johannes Schindelin
2009-01-15 15:14   ` Sitaram Chamarty

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=20090117215751.60ade90a.stephen@exigencecorp.com \
    --to=stephen@exigencecorp.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=s-beyer@gmx.net \
    --cc=sitaramc@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).