* Determining commit reachability
@ 2010-09-05 20:34 Artur Skawina
2010-09-06 3:17 ` Jeff King
2010-09-06 6:47 ` Junio C Hamano
0 siblings, 2 replies; 13+ messages in thread
From: Artur Skawina @ 2010-09-05 20:34 UTC (permalink / raw)
To: Git List
Given commit C, refs (branches) R, S and T what would be the best way
to test whether 'C' is reachable from any of the heads?
Checking if `git rev-list -n1 O ^R ^S ^T` produces any output is what
i came up with; is there a better (ie faster) solution?
artur
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-05 20:34 Determining commit reachability Artur Skawina
@ 2010-09-06 3:17 ` Jeff King
2010-09-06 5:04 ` Artur Skawina
2010-09-06 6:47 ` Junio C Hamano
1 sibling, 1 reply; 13+ messages in thread
From: Jeff King @ 2010-09-06 3:17 UTC (permalink / raw)
To: Artur Skawina; +Cc: Git List
On Sun, Sep 05, 2010 at 10:34:11PM +0200, Artur Skawina wrote:
> Given commit C, refs (branches) R, S and T what would be the best way
> to test whether 'C' is reachable from any of the heads?
>
> Checking if `git rev-list -n1 O ^R ^S ^T` produces any output is what
> i came up with; is there a better (ie faster) solution?
I think that is about as fast as you will get. You could try something
with git-merge-base, but it should be about the same speed.
Note that neither will tell you _which_ head the target was reachable
from. For that, given the current interface you have to test each head
individually. If you write some C code, you can do it all in a single
traversal. See this thread for some discussion of how "git tag
--contains" can be sped up:
http://article.gmane.org/gmane.comp.version-control.git/150039
-Peff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-06 3:17 ` Jeff King
@ 2010-09-06 5:04 ` Artur Skawina
0 siblings, 0 replies; 13+ messages in thread
From: Artur Skawina @ 2010-09-06 5:04 UTC (permalink / raw)
To: Jeff King; +Cc: Git List
On 09/06/10 05:17, Jeff King wrote:
> On Sun, Sep 05, 2010 at 10:34:11PM +0200, Artur Skawina wrote:
>
>> Given commit C, refs (branches) R, S and T what would be the best way
>> to test whether 'C' is reachable from any of the heads?
>>
>> Checking if `git rev-list -n1 O ^R ^S ^T` produces any output is what
>> i came up with; is there a better (ie faster) solution?
>
> I think that is about as fast as you will get. You could try something
> with git-merge-base, but it should be about the same speed.
>
> Note that neither will tell you _which_ head the target was reachable
> from. For that, given the current interface you have to test each head
As i think i'll only need this to prevent leaking (private) commits that
wouldn't be reachable from the (public) heads, just catching the
unreachable ones should be enough.
$ time git rev-list -n1 v2.6.12 ^v33 ^v35
0m2.333s user 0m0.040s system 0m2.379s elapsed 99.77% CPU
$ time git rev-list -n1 v2.6.36-rc2 ^v33 ^v35
76be97c1fc945db08aae1f1b746012662d643e97
0m0.500s user 0m0.010s system 0m0.514s elapsed 99.13% CPU
A bit expensive, but I guess should it become a problem I could cache
the result and/or blacklist the client.
Thanks,
artur
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-05 20:34 Determining commit reachability Artur Skawina
2010-09-06 3:17 ` Jeff King
@ 2010-09-06 6:47 ` Junio C Hamano
2010-09-06 20:45 ` Sverre Rabbelier
1 sibling, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2010-09-06 6:47 UTC (permalink / raw)
To: Artur Skawina; +Cc: Git List
Artur Skawina <art.08.09@gmail.com> writes:
> Given commit C, refs (branches) R, S and T what would be the best way
> to test whether 'C' is reachable from any of the heads?
Depends on the definition of "best", but I often find myself typing
git branch --with C
where C often is somewhere between 'master' and 'ko/master' (the 'master'
branch everybody else has already seen on k.org). When I have second
thoughts sometime after applying a patch directly on top of 'master', I
need to see if I have built a new topic branch forking from the faulty
commit before rewinding it, as such a topic branch also needs to be
rewound.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-06 6:47 ` Junio C Hamano
@ 2010-09-06 20:45 ` Sverre Rabbelier
2010-09-06 20:53 ` Ævar Arnfjörð Bjarmason
0 siblings, 1 reply; 13+ messages in thread
From: Sverre Rabbelier @ 2010-09-06 20:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Artur Skawina, Git List
Heya,
On Mon, Sep 6, 2010 at 01:47, Junio C Hamano <gitster@pobox.com> wrote:
> Depends on the definition of "best", but I often find myself typing
>
> git branch --with C
In case anyone else is wondering, '--with' is a hidden alias for '--contains'.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-06 20:45 ` Sverre Rabbelier
@ 2010-09-06 20:53 ` Ævar Arnfjörð Bjarmason
2010-09-06 21:05 ` Sverre Rabbelier
0 siblings, 1 reply; 13+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-09-06 20:53 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: Junio C Hamano, Artur Skawina, Git List
On Mon, Sep 6, 2010 at 20:45, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> Heya,
>
> On Mon, Sep 6, 2010 at 01:47, Junio C Hamano <gitster@pobox.com> wrote:
>> Depends on the definition of "best", but I often find myself typing
>>
>> git branch --with C
>
> In case anyone else is wondering, '--with' is a hidden alias for '--contains'.
Maybe it should be documented?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-06 20:53 ` Ævar Arnfjörð Bjarmason
@ 2010-09-06 21:05 ` Sverre Rabbelier
2010-09-06 23:38 ` Junio C Hamano
0 siblings, 1 reply; 13+ messages in thread
From: Sverre Rabbelier @ 2010-09-06 21:05 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason, Junio C Hamano
Cc: Artur Skawina, Git List
Heya,
On Mon, Sep 6, 2010 at 15:53, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> On Mon, Sep 6, 2010 at 20:45, Sverre Rabbelier <srabbelier@gmail.com> wrote:
>> In case anyone else is wondering, '--with' is a hidden alias for '--contains'.
>
> Maybe it should be documented?
Junio added it that way back in "git-branch --contains=commit"
v1.5.3.6-879-g694a577 (Nov 7 2007) when the feature was added. Junio,
do you remember why you added "--with" as a hidden alias?
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-06 21:05 ` Sverre Rabbelier
@ 2010-09-06 23:38 ` Junio C Hamano
2010-09-07 5:52 ` [PATCH] Documentation: explain "git branch --with" Jonathan Nieder
2010-09-07 13:04 ` Determining commit reachability Nguyen Thai Ngoc Duy
0 siblings, 2 replies; 13+ messages in thread
From: Junio C Hamano @ 2010-09-06 23:38 UTC (permalink / raw)
To: Sverre Rabbelier
Cc: Ævar Arnfjörð Bjarmason, Artur Skawina, Git List
Sverre Rabbelier <srabbelier@gmail.com> writes:
> On Mon, Sep 6, 2010 at 15:53, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>> On Mon, Sep 6, 2010 at 20:45, Sverre Rabbelier <srabbelier@gmail.com> wrote:
>>> In case anyone else is wondering, '--with' is a hidden alias for '--contains'.
>>
>> Maybe it should be documented?
>
> Junio added it that way back in "git-branch --contains=commit"
> v1.5.3.6-879-g694a577 (Nov 7 2007) when the feature was added. Junio,
> do you remember why you added "--with" as a hidden alias?
It was originally called --with. I wrote it to help me in the exact use
case in this thread, and the option was naturally named --with, as the
request I wanted to make was "Give me branches _with_ this commit, so that
I know which ones I need to rewind before reintegrating and publishing".
Somehow people wanted to see an option with a longer name, but by that
time my fingers were well trained, so I kept "--with" but didn't bother
advertising duplicated options.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] Documentation: explain "git branch --with"
2010-09-06 23:38 ` Junio C Hamano
@ 2010-09-07 5:52 ` Jonathan Nieder
2010-09-07 10:51 ` Ævar Arnfjörð Bjarmason
2010-09-09 22:45 ` Junio C Hamano
2010-09-07 13:04 ` Determining commit reachability Nguyen Thai Ngoc Duy
1 sibling, 2 replies; 13+ messages in thread
From: Jonathan Nieder @ 2010-09-07 5:52 UTC (permalink / raw)
To: Junio C Hamano
Cc: Sverre Rabbelier, Ævar Arnfjörð Bjarmason,
Artur Skawina, Git List
Junio C Hamano wrote:
> It was originally called --with. I wrote it to help me in the exact use
> case in this thread, and the option was naturally named --with, as the
> request I wanted to make was "Give me branches _with_ this commit, so that
> I know which ones I need to rewind before reintegrating and publishing".
>
> Somehow people wanted to see an option with a longer name, but by that
> time my fingers were well trained, so I kept "--with" but didn't bother
> advertising duplicated options.
More precisely, it is advertised by "git branch --help-all" but not
the manual or "git branch -h".
How about adding it to the man page so people can look up this option
after encountering it in the wild?
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Documentation/git-branch.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 1940256..f479e2f 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -142,6 +142,7 @@ start-point is either a local or remote branch.
branch points to is not changed.
--contains <commit>::
+--with <commit>::
Only list branches which contain the specified commit.
--merged [<commit>]::
--
1.7.2.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] Documentation: explain "git branch --with"
2010-09-07 5:52 ` [PATCH] Documentation: explain "git branch --with" Jonathan Nieder
@ 2010-09-07 10:51 ` Ævar Arnfjörð Bjarmason
2010-09-09 22:45 ` Junio C Hamano
1 sibling, 0 replies; 13+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-09-07 10:51 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Junio C Hamano, Sverre Rabbelier, Artur Skawina, Git List
On Tue, Sep 7, 2010 at 05:52, Jonathan Nieder <jrnieder@gmail.com> wrote:
> How about adding it to the man page so people can look up this option
> after encountering it in the wild?
Much better, thanks.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-06 23:38 ` Junio C Hamano
2010-09-07 5:52 ` [PATCH] Documentation: explain "git branch --with" Jonathan Nieder
@ 2010-09-07 13:04 ` Nguyen Thai Ngoc Duy
2010-09-07 13:07 ` Nguyen Thai Ngoc Duy
1 sibling, 1 reply; 13+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-09-07 13:04 UTC (permalink / raw)
To: Junio C Hamano
Cc: Sverre Rabbelier, Ævar Arnfjörð, Artur Skawina,
Git List
On Tue, Sep 7, 2010 at 9:38 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Somehow people wanted to see an option with a longer name, but by that
> time my fingers were well trained, so I kept "--with" but didn't bother
> advertising duplicated options.
But do you object a document patch for that option? I ask because I
found another undocumented option, --clear-resolve-undo in
update-index and was wondering if it's worth a patch.
--
Duy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Determining commit reachability
2010-09-07 13:04 ` Determining commit reachability Nguyen Thai Ngoc Duy
@ 2010-09-07 13:07 ` Nguyen Thai Ngoc Duy
0 siblings, 0 replies; 13+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-09-07 13:07 UTC (permalink / raw)
To: Junio C Hamano
Cc: Sverre Rabbelier, Ævar Arnfjörð, Artur Skawina,
Git List
On Tue, Sep 7, 2010 at 11:04 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> On Tue, Sep 7, 2010 at 9:38 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> Somehow people wanted to see an option with a longer name, but by that
>> time my fingers were well trained, so I kept "--with" but didn't bother
>> advertising duplicated options.
>
> But do you object a document patch for that option? I ask because I
> found another undocumented option, --clear-resolve-undo in
> update-index and was wondering if it's worth a patch.
Hmm.. just saw Jonathan's patch. I guess I just go ahead and make a patch then.
--
Duy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Documentation: explain "git branch --with"
2010-09-07 5:52 ` [PATCH] Documentation: explain "git branch --with" Jonathan Nieder
2010-09-07 10:51 ` Ævar Arnfjörð Bjarmason
@ 2010-09-09 22:45 ` Junio C Hamano
1 sibling, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2010-09-09 22:45 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Sverre Rabbelier, Ævar Arnfjörð Bjarmason,
Artur Skawina, Git List
Jonathan Nieder <jrnieder@gmail.com> writes:
> More precisely, it is advertised by "git branch --help-all" but not
> the manual or "git branch -h".
Sorry, but I don't understand what you are trying to say here. Isn't it
the whole point of distinction between --help-all vs -h (aka
PARSE_OPT_HIDDEN)?
Some interesting findings after a quick "grep" to see which ones are
hidden (potential bugs below might be good for janitors).
* apply --allow-binary-replacement, --binary
These are always on, and are no-op (even --no-binary is a no-op);
documented.
* archive -[2-8]
git-archive manual page mentions -0 thru -9 can be used as "zip backend
option", while explicitly describing -0 and -9. "git archive -h" gives
special description for -1 as well. Perhaps we should be consistent and
document -1 in the manual page.
* checkout --[no-]guess
Controls the "dwim 'git checkout x' to 'git checkout -b x remote/x' when
'x' cannot possibly name anything other than a branch that we copied
from a remote repository uniquely"; since the dwimming is on by default,
the only use case is to say --no-guess; not documented.
* clone --naked
An old name used during the development for the current --bare option;
not documented.
* commit --allow-empty --allow-empty-message
Documented; hidden primarily to discourage their uses and also to keep
output from 'commit -h' short.
* fmt-merge-msg --summary
An old name used during the development for the current --log option;
documented.
* grep --help-all, show-ref --help-all
I do not know why an entry for this needs to be in the struct option []
for the command. It is not (and should not be) documented in the manual
page of the individual commands.
* show-ref -h
"-h" was meant to be a historical synonym for "--head" (i.e. tells the
command include HEAD in the output not just under refs/ hierarchy), but
it seems that we broke it somewhere between v1.6.5 and v1.7.0; it now
shows the help text.
* write-tree --ignore-cache-tree
A debugging aid; not documented.
It seems that our use of OPT_HIDDEN or if a hidden option is documented
are not entirely consistent. The "--with" under discussion is similar to
"clone --naked" and "fmt-merge-msg --summary".
I am Ok with a policy to document historical synonyms that are hidden, but
if we were to document them, I suspect that we would need to explicitly
state they are synonyms. Otherwise, somebody who saw this...
> --contains <commit>::
> +--with <commit>::
> Only list branches which contain the specified commit.
... for the first time is bound to ask what the differences are between
the two.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2010-09-09 22:50 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-05 20:34 Determining commit reachability Artur Skawina
2010-09-06 3:17 ` Jeff King
2010-09-06 5:04 ` Artur Skawina
2010-09-06 6:47 ` Junio C Hamano
2010-09-06 20:45 ` Sverre Rabbelier
2010-09-06 20:53 ` Ævar Arnfjörð Bjarmason
2010-09-06 21:05 ` Sverre Rabbelier
2010-09-06 23:38 ` Junio C Hamano
2010-09-07 5:52 ` [PATCH] Documentation: explain "git branch --with" Jonathan Nieder
2010-09-07 10:51 ` Ævar Arnfjörð Bjarmason
2010-09-09 22:45 ` Junio C Hamano
2010-09-07 13:04 ` Determining commit reachability Nguyen Thai Ngoc Duy
2010-09-07 13:07 ` Nguyen Thai Ngoc Duy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.