[flashrom] [PATCH 2/2] Improve getrevision.sh.
Stefan Tauner
stefan.tauner at student.tuwien.ac.at
Wed Aug 7 23:57:28 CEST 2013
On Tue, 6 Aug 2013 20:09:19 -0700
David Hendricks <dhendrix at google.com> wrote:
> > git_url() {
> > - # Only the first line of `git remote' is considered.
> > - echo $(LC_ALL=C git remote show origin 2>/dev/null |
> > - grep 'Fetch URL:' |
> > - sed 's/.*URL:[[:blank:]]*//' |
> > - grep ^.
> > - )
> > + # get all remote branches containing the last commit
> > + branches=$(git branch -r --contains HEAD | cut -c 3-)
> > + if [ -z "$branches" ] ; then
> > + echo "No remote branch contains current HEAD">&2
> > + return
> > + fi
> > +
> > + # find "nearest" branch
> > + local diff=9000
> > + local target=
> > + for branch in $branches ; do
> > + curdiff=$(git rev-list --count HEAD..$branch)
> > + if [ $curdiff -ge $diff ] ; then
> > + continue
> > + fi
> > + diff=$curdiff
> > + target=$branch
> > + done
> > +
> > + echo "$(git ls-remote --exit-code --get-url ${target%/*})
> > ${target#*/}"
> > }
> >
>
> I am seeing a lot of errors when trying this. The version in the previous
> patch worked, though it kept the http:// prefix which is kind of
> superfluous.
>
> Try cloning http://git.chromium.org/chromiumos/third_party/flashrom.git .
That's the only thing (out of vanilla svn, git-svn, cloned github
git-svn, chromium tree) I did not test at all yet. Thanks for trying so
fast!
>
> $ sh getrevision.sh -U
> fatal: ambiguous argument 'HEAD..->': unknown revision or path not in the
> working tree.
> Use '--' to separate paths from revisions, like this:
> 'git <command> [<revision>...] -- [<file>...]'
> getrevision.sh: line 115: [: -ge: unary operator expected
> getrevision.sh: line 115: [: 0: unary operator expected
> http://git.chromium.org/chromiumos/third_party/flashrom.git master
>
> What about something like:
> git ls-remote --exit-code --get-url | sed 's/.*\/\///'
>
> That looks simpler and works better, at least in my testing...
The problem is the output of git branch -r --contains HEAD:
origin/HEAD -> origin/master
origin/master
Namely the origin/HEAD pointing to another branch which specifies the
branch one checks out automatically when cloning the repository. I do
not have this in my working repository where I was testing because i did
add the chromium tree as a plain remote only...
I have attached another approach, now with:
branches=$(git branch -r --contains HEAD | sed 's/[\t ]*//;/.*->.*/d')
--
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Improve-getrevision.sh.patch
Type: text/x-patch
Size: 8381 bytes
Desc: not available
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20130807/f248c510/attachment.patch>
More information about the flashrom
mailing list