git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Lars Hjemli <hjemli@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3] git-branch: add support for --merged and --no-merged
Date: Thu, 17 Apr 2008 14:07:19 -0700	[thread overview]
Message-ID: <7vzlrsmbqw.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1208463890-2870-1-git-send-email-hjemli@gmail.com> (Lars Hjemli's message of "Thu, 17 Apr 2008 22:24:50 +0200")

Lars Hjemli <hjemli@gmail.com> writes:

> Junio C Hamano wrote:
>> If the existing --contains implemenation can be extended to allow negative
>> selection, we do not have to introduce yet another mechanism that is very
>> similar.
>
> Very true, so here's an updated version which reuses has_commit(). Thanks
> for the feedback.

> +	if (mergefilter > -1) {
> +		branch.item = lookup_commit_reference_gently(sha1, 1);
> +		if (!branch.item)
> +			die("Unable to lookup HEAD of branch %s", refname);
> +		if (mergefilter == 0 && has_commit(head_sha1, &branch))
> +			return 0;
> +		if (mergefilter == 1 && !has_commit(head_sha1, &branch))
> +			return 0;
> +	}

You did not answer my question as to how --contains and --merged relate to
each other.  I'll answer it myself (please add a documentation updates, as
this would be confusing).  The output from the former is "branches I need
to be careful about, if I were to rewind and rebuild this branch" (that is
what I invented the option for).  The output from the latter is "branches
I can remove with 'git branch -d'".

 * --contains (aka with_commit) gets a single commit; only the branches
   that are descendant of that named commit will be shown (iow, these
   branches contain the commit), with the expression:

	/* Filter with with_commit if specified */
	if (!has_commit(sha1, ref_list->with_commit))
		return 0;

   where "sha1" is the commit at the tip of the branch in question in this
   round of the loop.

 * --merged is the opposite way.  Only the branches whose tips are
   ancestors of the HEAD will be shown (iow, the HEAD contains these
   branches), with the expression:

   	if (has_commit(head_sha1, &branch))

   where "head_sha1" is the HEAD, and "branch" is the branch in question
   in this round of the loop.  i.e. it asks the same question as
   --contains but in the opposite way.

  reply	other threads:[~2008-04-17 21:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-17  9:37 [PATCH] git-branch: add support for --merged and --unmerged Lars Hjemli
2008-04-17 11:34 ` [PATCH] bash: support branch's new '--merged' and '--unmerged' options SZEDER Gábor
2008-04-17 18:07   ` [PATCH] git-branch: add support for --merged and --no-merged Lars Hjemli
2008-04-17 19:13 ` [PATCH] git-branch: add support for --merged and --unmerged Junio C Hamano
2008-04-17 20:24   ` [PATCH v3] git-branch: add support for --merged and --no-merged Lars Hjemli
2008-04-17 21:07     ` Junio C Hamano [this message]
2008-04-17 22:27       ` [PATCH] git-branch.txt: compare --contains, " Lars Hjemli
2008-04-17 22:59     ` [PATCH v3] git-branch: add support for " Lars Hjemli

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=7vzlrsmbqw.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hjemli@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).