git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: demerphq <demerphq@gmail.com>
To: "Santi Béjar" <santi@agolina.net>
Cc: Git <git@vger.kernel.org>
Subject: Re: Adding files to a git-archive when it is generated, and whats the  best way to find out what branch a commit is on?
Date: Wed, 29 Jul 2009 11:51:42 +0200	[thread overview]
Message-ID: <9b18b3110907290251t4d8c83d3rf12d0ea9268c19bd@mail.gmail.com> (raw)
In-Reply-To: <adf1fd3d0907290233y78514f98h89a2fca7bf68b4f2@mail.gmail.com>

2009/7/29 Santi Béjar <santi@agolina.net>:
> 2009/7/29 demerphq <demerphq@gmail.com>:
>> 2009/7/29 Santi Béjar <santi@agolina.net>:
>>> 2009/7/29 demerphq <demerphq@gmail.com>:
>>>> Another question is whether anyone has any advice on the best way to
>>>> find out the "best" branch an arbitrary commit is on. Where best can
>>>> be flexibly definied to handle commits that are reachable from
>>>> multiple branches.  I have hacked a solution involving git-log and
>>>> grep, but it performs quite poorly. I was wondering if there is a
>>>> better solution.
>>>
>>> The "best" tag is easy: git describe commit. For branches I think you
>>> could use "git name-ref --refs=refs/heads/* commit", because git
>>> describe does not have a --branches flag.
>>
>> Dang, I guess this is from a newer release than mine. So now i have an
>> excuse to upgrade.
>
> No, it is quite old (the --refs flag since the v1.5.1). If the problem
> is that you don't find the "git name-ref" command is because it is
> "git name-rev", oops.

Dang, guess i need a different excuse. :-)

But it doesn't seem to do what i need:

$ git name-rev --refs=refs/heads/* faa7dc9f4d3a618b0ad8b3c95edd54e24c6976e7
faa7dc9f4d3a618b0ad8b3c95edd54e24c6976e7 undefined

But i think that just because in this case I need remote refs:

git name-rev --refs=refs/remotes/* faa7dc9f4d3a618b0ad8b3c95edd54e24c6976e7
faa7dc9f4d3a618b0ad8b3c95edd54e24c6976e7 remotes/origin/maint-5.005~25

Which is definitely better. Can I safely strip the ~25 off the end to
get the real branch name?

BTW, this is the shell version of what I'm currently using:

$ for b in $(git branch -r); do git log --pretty='format:%H' $b | grep
faa7dc9f4d3a618b0ad8b3c95edd54e24c6976e7 && echo $b; done
faa7dc9f4d3a618b0ad8b3c95edd54e24c6976e7
origin/maint-5.005

The main difference with the real code I use (in perl) is that I can
specify the order of the branches to be searched, so that I can ensure
that if its on two it is reported to be "from" the most likely
candidate. And of course the perl version I use stops searching as
soon as it finds a match.

Anyway, if I can reliably strip off the ~25 then this is a big step
forward for me.

Thanks Santi, and of course thanks Johannes (author of name-rev).

cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

  reply	other threads:[~2009-07-29  9:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-29  8:15 Adding files to a git-archive when it is generated, and whats the best way to find out what branch a commit is on? demerphq
2009-07-29  8:40 ` Avery Pennarun
2009-07-29  8:41 ` Santi Béjar
2009-07-29  9:21   ` demerphq
2009-07-29  9:33     ` Santi Béjar
2009-07-29  9:51       ` demerphq [this message]
2009-07-29 11:13         ` Santi Béjar
2009-07-30 20:33     ` René Scharfe
2009-07-31 10:04       ` demerphq
     [not found]         ` <m3hbwtrpip.fsf@localhost.localdomain>
2009-07-31 13:48           ` demerphq
2009-08-02 13:52         ` René Scharfe
2009-08-02 14:19           ` demerphq
2009-08-04 17:50             ` René Scharfe
2009-07-29 16:12 ` 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=9b18b3110907290251t4d8c83d3rf12d0ea9268c19bd@mail.gmail.com \
    --to=demerphq@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=santi@agolina.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).