git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Rast <tr@thomasrast.ch>
To: Fabian Ruch <bafain@gmail.com>
Cc: git@vger.kernel.org, Michael Haggerty <mhagger@alum.mit.edu>,
	Jeff King <peff@peff.net>, Chris Webb <chris@arachsys.com>
Subject: Re: [PATCH v1] rebase --root: sentinel commit cloaks empty commits
Date: Fri, 18 Jul 2014 14:10:43 +0200	[thread overview]
Message-ID: <871tti50l8.fsf@thomasrast.ch> (raw)
In-Reply-To: <8d5cf2e1ff45e2e60072bf6c6e05371e4b265709.1405539123.git.bafain@gmail.com> (Fabian Ruch's message of "Wed, 16 Jul 2014 21:32:45 +0200")

Hi Fabian

Impressive analysis!

> Concerning the bugfix: Obviously, the patch misuses the `squash_onto`
> flag because it assumes that the new base is empty except for the
> sentinel commit. The variable name does not imply anything close to
> that. An additional flag to disable the use of the git-rev-list
> option `--cherry-pick` would work and make sense again (for instance,
> `keep_redundant`).

Seeing as there are only two existing uses of the variable, you could
also rename it to make it more obvious what is going on.  I think either
way is fine.

[...]
> Please take a closer look at the last two test cases that specify the
> expected behaviour of rebasing a branch that tracks the empty tree.
> At this point they expect the "Nothing to do" error (aborts with
> untouched history). This is consistent with rebasing only empty
> commits without `--root`, which also doesn't just delete them from
> the history. Furthermore, I think the two alternatives adding a note
> that all commits in the range were empty, and removing the empty
> commits (thus making the branch empty) are better discussed in a
> separate bug report.

Makes sense to me, though I have never thought much about rebasing empty
commits.  Maybe Chris has a more informed opinion?

>  is_empty_commit() {
> -	tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null ||
> -		die "$1: not a commit that can be picked")
> -	ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null ||
> -		ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904)
> +	tree=$(git rev-parse -q --verify "$1"^{tree} 2>/dev/null) ||
> +		die "$1: not a commit that can be picked"
> +	ptree=$(git rev-parse -q --verify "$1"^^{tree} 2>/dev/null) ||
> +		ptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
>  	test "$tree" = "$ptree"
>  }

Nice catch!

> @@ -958,7 +958,17 @@ then
>  	revisions=$upstream...$orig_head
>  	shortrevisions=$shortupstream..$shorthead
>  else
> -	revisions=$onto...$orig_head
> +	if test -n "$squash_onto"
> +	then
> +		# $onto points to an empty commit (the sentinel
> +		# commit) which was not created by the user.
> +		# Exclude it from the rev list to avoid skipping
> +		# empty user commits prematurely, i. e. before
> +		# --keep-empty can take effect.
> +		revisions=$orig_head
> +	else
> +		revisions=$onto...$orig_head
> +	fi
>  	shortrevisions=$shorthead

Nit: I think this would be clearer if you phrased it using an 'elif',
instead of nesting (but keep the comment!).

-- 
Thomas Rast
tr@thomasrast.ch

  reply	other threads:[~2014-07-18 12:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 12:10 [RFC] rebase --root: Empty root commit is replaced with sentinel Fabian Ruch
2014-06-19 11:35 ` Michael Haggerty
2014-06-19 12:39   ` Fabian Ruch
2014-06-19 13:08     ` Michael Haggerty
2014-07-16 19:32 ` [PATCH v1] rebase --root: sentinel commit cloaks empty commits Fabian Ruch
2014-07-18 12:10   ` Thomas Rast [this message]
2014-07-20 20:52     ` Chris Webb

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=871tti50l8.fsf@thomasrast.ch \
    --to=tr@thomasrast.ch \
    --cc=bafain@gmail.com \
    --cc=chris@arachsys.com \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=peff@peff.net \
    /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).