* Re: What's cooking in git.git (Dec 2010, #01; Sat, 4)
From: Miles Bader @ 2010-12-06 8:39 UTC (permalink / raw)
To: Yann Dirson; +Cc: gitster, git list
In-Reply-To: <20101206092122.21c19011@chalon.bertin.fr>
On Mon, Dec 6, 2010 at 5:21 PM, Yann Dirson <dirson@bertin.fr> wrote:
> Seen that argument before.
> 1. does anyone care ? (I personally don't)
If nobody cared, you wouldn't get an argument.
-Miles
--
Cat is power. Cat is peace.
^ permalink raw reply
* Re: Can't seem to commit
From: Chris Packham @ 2010-12-06 8:54 UTC (permalink / raw)
To: weloki; +Cc: git@vger.kernel.org
In-Reply-To: <4CFCA445.2020205@gmail.com>
Sorry for the dupe, I forgot to CC the list.
On 05/12/10 05:33, weloki wrote:
>
> There is probably an easy solution to this but I'm seeing something really
> weird...
> I can't seem to commit anything to my new branch. When I try to commit it
> just says "no changes added to commit (use "git add" and/or "git commit
> -a")"
> When I try to do git add it doesn't seem to do anything.
> When I try to push it says "Everything up-to-date", but when I look at the
> branch on github my files aren't there.
> Strangely I was able to do everything fine with a different branch I created
> afterwards.
One thing to check is where you're pushing to ("git remote show origin"
should tell you). You may also want to check the value of "git config
branch.master.merge", "git config remote.origin.url" and "git config
push.default".
For me these are
refs/heads/master
<my github project>
tracking
Also on a very fresh repository you need to use "git push origin
master:refs/heads/master" to create the master branch on the remote end.
^ permalink raw reply
* Re: What's cooking in git.git (Dec 2010, #01; Sat, 4)
From: Michael J Gruber @ 2010-12-06 8:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v4oasvvao.fsf@alter.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 05.12.2010 21:06:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
>
>> Junio C Hamano venit, vidit, dixit 05.12.2010 07:30:
>> ...
>>>
>>> * mg/cvsimport (2010-11-28) 3 commits
>>> - cvsimport.txt: document the mapping between config and options
>>> - cvsimport: fix the parsing of uppercase config options
>>> - cvsimport: partial whitespace cleanup
>>>
>>> I was being lazy and said "Ok" to "cvsimport.capital-r" but luckily other
>>> people injected sanity to the discussion. Weatherbaloon patch sent, but
>>
>> I assume I should try and not read too much into this...
>
> No, you shouldn't. I wasn't questioning _your_ sanity, and if you took it
> that way, I apologize.
No need to. I was pointing out a potentially misunderstandable
formulation without misunderstanding it ;)
> I as the maintainer have different priority from contributors. The
> contributed patches want to "get the job done" first, and their solution
> only need to be "correct and not too ugly".
>
> I however in addition need to make sure that the changes make sense in the
> longer term,
Exactly, and you're doing a good job of it. It can lead to the
impression (on the contributors' side) that even simple patches are
difficult to "get in", and can lead to frustration, of course. But it
also ensures that we don't have even more work later on, trying to work
around a half-thought-through earlier change.
[In this particular case, I reckoned cvsimport basically hasn't got much
"later" left, but who knows when cvs2git is ready for incremental sync.]
Michael
^ permalink raw reply
* Re: What's cooking in git.git (Dec 2010, #01; Sat, 4)
From: Yann Dirson @ 2010-12-06 8:48 UTC (permalink / raw)
To: Miles Bader; +Cc: gitster, git list
In-Reply-To: <AANLkTimPC3-x1XFJ+t9uiFFXV6fg812ugF5vz9p=4GWB@mail.gmail.com>
On Mon, 06 Dec 2010 17:39:54 +0900
Miles Bader <miles@gnu.org> wrote:
> On Mon, Dec 6, 2010 at 5:21 PM, Yann Dirson <dirson@bertin.fr> wrote:
> > Seen that argument before.
> > 1. does anyone care ? (I personally don't)
>
> If nobody cared, you wouldn't get an argument.
OK, I can hear that - but well, noone complained till now that
--find-copies-harder would sound like "an action to be performed
_instead_ of some normal processing".
But most importantly, I don't get much feedback on the direct
implication of that choice: are we going to have 2 exact synonyms
(--find-copies-harder and --detect-copies-harder) forever, and to what
extent (see prev. mail about completion) ?
In the end, I still think the implications for the usability are what
matters, more than arguing about a subtle nuance of vocabulary.
--
Yann Dirson - Bertin Technologies
^ permalink raw reply
* Re: What's cooking in git.git (Dec 2010, #01; Sat, 4)
From: Miles Bader @ 2010-12-06 9:13 UTC (permalink / raw)
To: Yann Dirson; +Cc: gitster, git list
In-Reply-To: <20101206094806.10ae1ff2@chalon.bertin.fr>
On Mon, Dec 6, 2010 at 5:48 PM, Yann Dirson <dirson@bertin.fr> wrote:
> In the end, I still think the implications for the usability are what
> matters, more than arguing about a subtle nuance of vocabulary.
There is no "usability" problem.
it's is normal and good that option names are sometimes revisited and
improved -- nothing is perfect on the first try. By keeping the old
option around as a deprecated alias, we avoid compatibility issues.
That doesn't mean there aren't _any_ issues, but they tend to be
pretty minor (such as the "space used by the deprecation option" that
you complain about).
Maybe if you renamed every option simultaneously, there would be
confusion, but seriously, it's only one option. It's not going to be
a problem.
-Miles
--
Cat is power. Cat is peace.
^ permalink raw reply
* [PATCHv3] parse-remote: handle detached HEAD
From: Santi Béjar @ 2010-12-06 10:20 UTC (permalink / raw)
To: git; +Cc: Sverre Rabbelier, Junio C Hamano
In-Reply-To: <7vfwubtw1g.fsf@alter.siamese.dyndns.org>
get_remote_merge_branch with zero or one arguments returns the
upstream branch. But a detached HEAD does no have an upstream branch,
as it is not tracking anything. Handle this case testing the exit code
of "git symbolic-ref -q HEAD".
Reported-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Santi Béjar <santi@agolina.net>
---
> If that is the case, shouldn't we be not calling "echo" at all to begin
> with? IOW, shouldn't the code read more like this?
>
> curr_branch=$(git symbolic-ref -q HEAD) &&
> test "$origin" = "$default" &&
> echo ...
Or course, you are right. I didn't know/think about the exit
code... Thanks.
Santi
git-parse-remote.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 5f47b18..4da72ae 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -66,7 +66,7 @@ get_remote_merge_branch () {
origin="$1"
default=$(get_default_remote)
test -z "$origin" && origin=$default
- curr_branch=$(git symbolic-ref -q HEAD)
+ curr_branch=$(git symbolic-ref -q HEAD) &&
[ "$origin" = "$default" ] &&
echo $(git for-each-ref --format='%(upstream)' $curr_branch)
;;
--
1.7.3.3.399.g0d2be.dirty
^ permalink raw reply related
* Re: [PATCH] rebase: pass --signoff option to git am
From: Giuseppe Bilotta @ 2010-12-06 10:41 UTC (permalink / raw)
To: Kevin Ballard; +Cc: git list, Junio C Hamano
In-Reply-To: <AANLkTindvz=7OmYaL6AL_oAj50U9PLnRrbSpjgR92z7C@mail.gmail.com>
On Tue, Nov 30, 2010 at 9:09 AM, Giuseppe Bilotta
<giuseppe.bilotta@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 11:57 PM, Kevin Ballard <kevin@sb.org> wrote:
>> On Nov 27, 2010, at 3:15 AM, Giuseppe Bilotta wrote:
>>
>>> This allows people (like me) that forget to sign off their commits to do
>>> a single rebase pass e.g. while preparing the patchset for submission.
>>
>> You're probably already aware, but git format-patch supports the -s/--signoff
>> flags to sign off commits as they're prepared. There's even a config var
>> you can set to make this the default (format.signoff = true).
>
> That works if you're sharing your patches with format-patch, but not
> for example when asking for a pull. Maybe I should extend the commit
> message to include this case.
For what it's worth, somebody on #git just asked how to signoff a
bunch of patches. The answer was to rebase -i and sign off each one of
them. This is exactly the kind of usage that my patch would simplify.
Any chance of it getting merged?
--
Giuseppe "Oblomov" Bilotta
^ permalink raw reply
* Re: [PATCH] describe: Don’t look up commits with --exact-match
From: Thomas Rast @ 2010-12-06 10:53 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Anders Kaseorg, Junio C Hamano, git, SZEDER Gábor,
Kirill Smelkov
In-Reply-To: <20101206073214.GA3745@burratino>
Jonathan Nieder wrote:
> Anders Kaseorg wrote:
> > On Fri, 3 Dec 2010, Jonathan Nieder wrote:
>
> >> Instead of looking up the commit to be matched exactly in the commits
> >> hash table, this makes a linear search.
> [...]
> > I don’t think it’s ever a problem: in my repository with 1800 tags on a
> > warm cache, that loop accounts for about 0.1% of even the fastest
> > non-exact-match query (a commit right after a tag).
>
> Thanks for checking. Makes sense.
Apart from measuring: for_each_ref *loads* the tags in a linear scan,
so another linear scan doesn't add to the runtime w.r.t. number of
tags. It only hurts if you also describe many refs in one go.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: What's cooking in git.git (Dec 2010, #01; Sat, 4)
From: Matthieu Moy @ 2010-12-06 11:37 UTC (permalink / raw)
To: Miles Bader; +Cc: Yann Dirson, gitster, git list
In-Reply-To: <AANLkTinJu0KzXZ2Rjbs2+XH7T=Gq5MOajxo51DHtqoGZ@mail.gmail.com>
Miles Bader <miles@gnu.org> writes:
> it's is normal and good that option names are sometimes revisited and
> improved -- nothing is perfect on the first try. By keeping the old
> option around as a deprecated alias, we avoid compatibility issues.
The problem is that the old name isn't kept as a _deprecated_ alias,
but just as an alias:
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -251,6 +251,7 @@ endif::git-log[]
If `n` is specified, it has the same meaning as for `-M<n>`.
--find-copies-harder::
+--detect-copies-harder::
For performance reasons, by default, `-C` option finds copies only
if the original file of the copy was modified in the same
changeset. This flag makes the command
I'd rather have stg like
---find-copies-harder::
+--detect-copies-harder::
...
+--find-copies-harder::
+ Deprecated alias for --detect-copies-harder.
+
even if the old alias is kept forever. It's good to let old-timers use
the old name, but we shouldn't confuse new users with two names
without a hint on which one they're supposed to use. Otherwise, the
addition of an alias doesn't really have any benefit for anyone.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply
* Re: What's cooking in git.git (Dec 2010, #01; Sat, 4)
From: Yann Dirson @ 2010-12-06 11:31 UTC (permalink / raw)
To: Miles Bader; +Cc: gitster, git list
In-Reply-To: <AANLkTinJu0KzXZ2Rjbs2+XH7T=Gq5MOajxo51DHtqoGZ@mail.gmail.com>
On Mon, 06 Dec 2010 18:13:06 +0900
Miles Bader <miles@gnu.org> wrote:
> On Mon, Dec 6, 2010 at 5:48 PM, Yann Dirson <dirson@bertin.fr> wrote:
> it's is normal and good that option names are sometimes revisited and
> improved -- nothing is perfect on the first try. By keeping the old
> option around as a deprecated alias, we avoid compatibility issues.
... except Junio advocates *not* deprecating this one, since it is here
since ages.
> That doesn't mean there aren't _any_ issues, but they tend to be
> pretty minor (such as the "space used by the deprecation option" that
> you complain about).
>
> Maybe if you renamed every option simultaneously, there would be
> confusion, but seriously, it's only one option. It's not going to be
> a problem.
I'm not sure we want to use "it's only one option" as an excuse. It
can easily become a bad habit.
> There is no "usability" problem.
Completion of "git diff --<TAB>" in stable branch gives 44 choices here.
One of the most frequent criticisms about git I hear among coworkers is
that there are so many commands and options. Will be funny to explain
them that "we just added another one, for no technical reason".
--
Yann Dirson - Bertin Technologies
^ permalink raw reply
* Re: [PATCHv3] parse-remote: handle detached HEAD
From: Santi Béjar @ 2010-12-06 14:32 UTC (permalink / raw)
To: git; +Cc: Sverre Rabbelier, Junio C Hamano
In-Reply-To: <1291630811-16584-1-git-send-email-santi@agolina.net>
On Mon, Dec 6, 2010 at 11:20 AM, Santi Béjar <santi@agolina.net> wrote:
> get_remote_merge_branch with zero or one arguments returns the
> upstream branch. But a detached HEAD does no have an upstream branch,
> as it is not tracking anything. Handle this case testing the exit code
> of "git symbolic-ref -q HEAD".
>
> Reported-by: Sverre Rabbelier <srabbelier@gmail.com>
> Signed-off-by: Santi Béjar <santi@agolina.net>
> ---
>
>> If that is the case, shouldn't we be not calling "echo" at all to begin
>> with? IOW, shouldn't the code read more like this?
>>
>> curr_branch=$(git symbolic-ref -q HEAD) &&
>> test "$origin" = "$default" &&
>> echo ...
>
> Or course, you are right. I didn't know/think about the exit
> code... Thanks.
Now that I think of... the final form of the patch is yours (Junio).
Feel free to add something like this to the commit message:
Final patch form by Junio C Hamano
Or alternatively, take ownership of the patch and add something like
"Patch handled by Santi Béjar but final patch form by Junio C Hamano"
and:
Acked-by: Santi Béjar <santi@agolina.net>
Santi
^ permalink raw reply
* [ANNOUNCE] Git 1.7.3.3
From: Junio C Hamano @ 2010-12-06 15:28 UTC (permalink / raw)
To: git
In-Reply-To: <7vk4jrppeu.fsf@alter.siamese.dyndns.org>
The latest maintenance release Git 1.7.3.3 is available at the
usual places:
http://www.kernel.org/pub/software/scm/git/
git-1.7.3.3.tar.{gz,bz2} (source tarball)
git-htmldocs-1.7.3.3.tar.{gz,bz2} (preformatted docs)
git-manpages-1.7.3.3.tar.{gz,bz2} (preformatted docs)
The RPM binary packages for a few architectures are found in:
RPMS/$arch/git-*-1.7.3.3-1.fc11.$arch.rpm (RPM)
Git v1.7.3.3 Release Notes
==========================
In addition to the usual fixes, this release also includes support for
the new "add.ignoreErrors" name given to the existing "add.ignore-errors"
configuration variable.
The next version, Git 1.7.4, and future versions, will support both
old and incorrect name and the new corrected name, but without this
backport, users who want to use the new name "add.ignoreErrors" in
their repositories cannot use older versions of Git.
Fixes since v1.7.3.2
--------------------
* "git apply" segfaulted when a bogus input is fed to it.
* Running "git cherry-pick --ff" on a root commit segfaulted.
* "diff", "blame" and friends incorrectly applied textconv filters to
symlinks.
* Highlighting of whitespace breakage in "diff" output was showing
incorrect amount of whitespaces when blank-at-eol is set and the line
consisted only of whitespaces and a TAB.
* "diff" was overly inefficient when trying to find the line to use for
the function header (i.e. equivalent to --show-c-function of GNU diff).
* "git imap-send" depends on libcrypto but our build rule relied on the
linker to implicitly link it via libssl, which was wrong.
* "git merge-file" can be called from within a subdirectory now.
* "git repack -f" expanded and recompressed non-delta objects in the
existing pack, which was wasteful. Use new "-F" option if you really
want to (e.g. when changing the pack.compression level).
* "git rev-list --format="...%x00..." incorrectly chopped its output
at NUL.
* "git send-email" did not correctly remove duplicate mail addresses from
the Cc: header that appear on the To: header.
* The completion script (in contrib/completion) ignored lightweight tags
in __git_ps1().
* "git-blame" mode (in contrib/emacs) didn't say (require 'format-spec)
even though it depends on it; it didn't work with Emacs 22 or older
unless Gnus is used.
* "git-p4" (in contrib/) did not correctly handle deleted files.
Other minor fixes and documentation updates are also included.
^ permalink raw reply
* Re: What's cooking in git.git (Dec 2010, #01; Sat, 4)
From: Thiago Farina @ 2010-12-06 15:39 UTC (permalink / raw)
To: Michael J Gruber; +Cc: Junio C Hamano, git
In-Reply-To: <4CFCA4E6.30209@drmicha.warpmail.net>
On Mon, Dec 6, 2010 at 6:55 AM, Michael J Gruber
<git@drmicha.warpmail.net> wrote:
> Exactly, and you're doing a good job of it.
Yeah, he does a good a job. :)
> It can lead to the impression (on the contributors' side) that even simple patches are
> difficult to "get in", and can lead to frustration, of course.
This resumes some of my frustrations here, and maybe the other
contributors here too. So is not just me that has this impression.
Hope the experience can be improved in future.
> But it also ensures that we don't have even more work later on, trying to work
> around a half-thought-through earlier change.
>
And this is also true.
^ permalink raw reply
* Re: [PATCHv3] parse-remote: handle detached HEAD
From: Junio C Hamano @ 2010-12-06 16:03 UTC (permalink / raw)
To: Santi Béjar; +Cc: git, Sverre Rabbelier
In-Reply-To: <1291630811-16584-1-git-send-email-santi@agolina.net>
Santi Béjar <santi@agolina.net> writes:
> get_remote_merge_branch with zero or one arguments returns the
> upstream branch. But a detached HEAD does no have an upstream branch,
> as it is not tracking anything. Handle this case testing the exit code
> of "git symbolic-ref -q HEAD".
>
> Reported-by: Sverre Rabbelier <srabbelier@gmail.com>
> Signed-off-by: Santi Béjar <santi@agolina.net>
> ---
>
>> If that is the case, shouldn't we be not calling "echo" at all to begin
>> with? IOW, shouldn't the code read more like this?
>>
>> curr_branch=$(git symbolic-ref -q HEAD) &&
>> test "$origin" = "$default" &&
>> echo ...
>
> Or course, you are right. I didn't know/think about the exit
> code... Thanks.
The calling codepath in git-pull that wants to determine remoteref and
oldremoteref seems to expect get-remote-merge-branch to succeed in order
to find its $oldremoteref variable, and returning false in detached HEAD
case here will change what happens there---it won't run "rev-list -g"
anymore and quits the codepath early, leaving the variable empty.
But we do want to set the variable to an empty string in this case anyway,
so there is no harm done (it probably is what we actually want to happen).
So this should be Ok. Sverre, do you want to do another round of testing
just to be sure before I apply this?
> Santi
>
> git-parse-remote.sh | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-parse-remote.sh b/git-parse-remote.sh
> index 5f47b18..4da72ae 100644
> --- a/git-parse-remote.sh
> +++ b/git-parse-remote.sh
> @@ -66,7 +66,7 @@ get_remote_merge_branch () {
> origin="$1"
> default=$(get_default_remote)
> test -z "$origin" && origin=$default
> - curr_branch=$(git symbolic-ref -q HEAD)
> + curr_branch=$(git symbolic-ref -q HEAD) &&
> [ "$origin" = "$default" ] &&
> echo $(git for-each-ref --format='%(upstream)' $curr_branch)
> ;;
> --
> 1.7.3.3.399.g0d2be.dirty
^ permalink raw reply
* Re: [ANNOUNCE] Git 1.7.3.3
From: Ævar Arnfjörð Bjarmason @ 2010-12-06 16:51 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vy682syya.fsf@alter.siamese.dyndns.org>
On Mon, Dec 6, 2010 at 16:28, Junio C Hamano <gitster@pobox.com> wrote:
> The latest maintenance release Git 1.7.3.3 is available at the
> usual places:
\o/
> * "git-blame" mode (in contrib/emacs) didn't say (require 'format-spec)
> even though it depends on it; it didn't work with Emacs 22 or older
> unless Gnus is used.
Was it Gnus in particular for some reason. Or just anything that
incidentally loaded format-spec.el ?
emacs.git $ git --no-pager grep "(require 'format-spec)"
lisp/erc/erc-compat.el:(require 'format-spec)
lisp/gnus/gnus-sieve.el:(require 'format-spec)
lisp/gnus/mail-source.el:(require 'format-spec)
lisp/image-dired.el:(require 'format-spec)
lisp/net/tramp-compat.el: (require 'format-spec)
lisp/org/org-docbook.el:(require 'format-spec)
^ permalink raw reply
* Re: [PATCHv3] parse-remote: handle detached HEAD
From: Sverre Rabbelier @ 2010-12-06 17:14 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Santi Béjar, git
In-Reply-To: <7vr5dusxb1.fsf@alter.siamese.dyndns.org>
Heya,
On Mon, Dec 6, 2010 at 17:03, Junio C Hamano <gitster@pobox.com> wrote:
> So this should be Ok. Sverre, do you want to do another round of testing
> just to be sure before I apply this?
Yup:
Tested-by: Sverre Rabbelier <srabbelier@gmail.com
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH] rebase: pass --signoff option to git am
From: Jonathan Nieder @ 2010-12-06 17:28 UTC (permalink / raw)
To: Giuseppe Bilotta; +Cc: Kevin Ballard, git list, Junio C Hamano
In-Reply-To: <AANLkTinnn_QnBJ8AZT9ZB+ZHVRDZV0tDret=YQeyfa01@mail.gmail.com>
Giuseppe Bilotta wrote:
> For what it's worth, somebody on #git just asked how to signoff a
> bunch of patches. The answer was to rebase -i and sign off each one of
> them.
How I would do it in existing git:
git branch oldhead
git reset --keep base
git log --oneline --graph HEAD..oldhead; # the right patches?
git cherry-pick -s HEAD..oldhead
git diff oldhead
Or without multiple-cherry-pick, maybe:
git branch oldhead
git reset --keep base
git format-patch -k --stdout HEAD..oldhead >series
git am -s -3 -i series; # the right patches?
git diff oldhead
No opinion on the automatic-signoff-in-rebase here.
^ permalink raw reply
* Re: [PATCH] describe: Don’t look up commits with --exact-match
From: Anders Kaseorg @ 2010-12-06 17:28 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Junio C Hamano, git, SZEDER Gábor, Kirill Smelkov,
Thomas Rast
In-Reply-To: <20101206073214.GA3745@burratino>
On Mon, 6 Dec 2010, Jonathan Nieder wrote:
> Depends on what "Don't lookup commits" means, I suppose. I
> think the difference between _ref and _rawref is
> […]
> so if I understand correctly, for_each_ref would still allow one to
> get away without unpacking the objects. Is that correct?
Yeah. Okay, I see that “lookup” implies unpacking, as opposed to “find”,
which doesn’t. The important part is to avoid the find, of course,
because the I/O is expensive.
Anyway, here’s a series with that change split out.
Anders
-- 8< --
From 2ad1e58b8f6e9c117c77748b6e8b85227d9d5412 Mon Sep 17 00:00:00 2001
From: Anders Kaseorg <andersk@ksplice.com>
Subject: [PATCH 1/2] describe: Use for_each_rawref
Don’t waste time checking for dangling refs; they wouldn’t affect the
output of ‘git describe’ anyway. Although this doesn’t gain much
performance by itself, it does in conjunction with the next commit.
Signed-off-by: Anders Kaseorg <andersk@ksplice.com>
---
builtin/describe.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index 43caff2..700f740 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -418,7 +418,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
return cmd_name_rev(i + argc, args, prefix);
}
- for_each_ref(get_name, NULL);
+ for_each_rawref(get_name, NULL);
if (!found_names && !always)
die("No names found, cannot describe anything.");
--
1.7.3.3
From ce8a2ab9cf80247c2834d21f36f63cedb794e62f Mon Sep 17 00:00:00 2001
From: Anders Kaseorg <andersk@ksplice.com>
Subject: describe: Don’t look up commits with --exact-match
This makes ‘git describe --exact-match HEAD’ about 15 times faster on
a cold cache (2.3s instead of 35s) in a linux-2.6 repository with many
packed tags. That’s a huge win for the interactivity of the __git_ps1
shell prompt helper.
Signed-off-by: Anders Kaseorg <andersk@ksplice.com>
---
builtin/describe.c | 62 ++++++++++++++++++++++++++-------------------------
1 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index 700f740..0cddef1 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -22,7 +22,7 @@ static int tags; /* Allow lightweight tags */
static int longformat;
static int abbrev = DEFAULT_ABBREV;
static int max_candidates = 10;
-static int found_names;
+static struct commit_name *names;
static const char *pattern;
static int always;
static const char *dirty;
@@ -34,6 +34,8 @@ static const char *diff_index_args[] = {
struct commit_name {
+ struct commit_name *next;
+ unsigned char peeled[20];
struct tag *tag;
unsigned prio:2; /* annotated tag = 2, tag = 1, head = 0 */
unsigned name_checked:1;
@@ -78,31 +80,26 @@ static int replace_name(struct commit_name *e,
}
static void add_to_known_names(const char *path,
- struct commit *commit,
+ const unsigned char *peeled,
int prio,
const unsigned char *sha1)
{
- struct commit_name *e = commit->util;
struct tag *tag = NULL;
- if (replace_name(e, prio, sha1, &tag)) {
- size_t len = strlen(path)+1;
- free(e);
- e = xmalloc(sizeof(struct commit_name) + len);
- e->tag = tag;
- e->prio = prio;
- e->name_checked = 0;
- hashcpy(e->sha1, sha1);
- memcpy(e->path, path, len);
- commit->util = e;
- }
- found_names = 1;
+ size_t len = strlen(path)+1;
+ struct commit_name *e = xmalloc(sizeof(struct commit_name) + len);
+ hashcpy(e->peeled, peeled);
+ e->tag = tag;
+ e->prio = prio;
+ e->name_checked = 0;
+ hashcpy(e->sha1, sha1);
+ memcpy(e->path, path, len);
+ e->next = names;
+ names = e;
}
static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
int might_be_tag = !prefixcmp(path, "refs/tags/");
- struct commit *commit;
- struct object *object;
unsigned char peeled[20];
int is_tag, prio;
@@ -110,16 +107,10 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
return 0;
if (!peel_ref(path, peeled) && !is_null_sha1(peeled)) {
- commit = lookup_commit_reference_gently(peeled, 1);
- if (!commit)
- return 0;
- is_tag = !!hashcmp(sha1, commit->object.sha1);
+ is_tag = !!hashcmp(sha1, peeled);
} else {
- commit = lookup_commit_reference_gently(sha1, 1);
- object = parse_object(sha1);
- if (!commit || !object)
- return 0;
- is_tag = object->type == OBJ_TAG;
+ hashcpy(peeled, sha1);
+ is_tag = 0;
}
/* If --all, then any refs are used.
@@ -142,7 +133,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
if (!prio)
return 0;
}
- add_to_known_names(all ? path + 5 : path + 10, commit, prio, sha1);
+ add_to_known_names(all ? path + 5 : path + 10, peeled, prio, sha1);
return 0;
}
@@ -228,7 +219,7 @@ static void describe(const char *arg, int last_one)
unsigned char sha1[20];
struct commit *cmit, *gave_up_on = NULL;
struct commit_list *list;
- struct commit_name *n;
+ struct commit_name *n, *e;
struct possible_tag all_matches[MAX_TAGS];
unsigned int match_cnt = 0, annotated_cnt = 0, cur_match;
unsigned long seen_commits = 0;
@@ -240,7 +231,12 @@ static void describe(const char *arg, int last_one)
if (!cmit)
die("%s is not a valid '%s' object", arg, commit_type);
- n = cmit->util;
+ n = NULL;
+ for (e = names; e; e = e->next) {
+ if (!hashcmp(e->peeled, cmit->object.sha1) &&
+ replace_name(n, e->prio, e->sha1, &e->tag))
+ n = e;
+ }
if (n && (tags || all || n->prio == 2)) {
/*
* Exact match to an existing ref.
@@ -259,6 +255,12 @@ static void describe(const char *arg, int last_one)
if (debug)
fprintf(stderr, "searching to describe %s\n", arg);
+ for (e = names; e; e = e->next) {
+ struct commit *c = lookup_commit_reference_gently(e->peeled, 1);
+ if (c && replace_name(c->util, e->prio, e->sha1, &e->tag))
+ c->util = e;
+ }
+
list = NULL;
cmit->object.flags = SEEN;
commit_list_insert(cmit, &list);
@@ -419,7 +421,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
}
for_each_rawref(get_name, NULL);
- if (!found_names && !always)
+ if (!names && !always)
die("No names found, cannot describe anything.");
if (argc == 0) {
--
1.7.3.3
^ permalink raw reply related
* Re: git reset and ctime
From: Drew Northup @ 2010-12-06 17:37 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: ghazel, git, Junio C Hamano
In-Reply-To: <20101204005131.GB15906@burratino>
On Fri, 2010-12-03 at 18:51 -0600, Jonathan Nieder wrote:
> Hi Greg,
>
> ghazel@gmail.com wrote:
>
> > I've encountered a strange issue where "git reset --hard" insists on
> > "Checking out files ..." when all that is changed is the ctime
>
> There is a performance trade-off. Refreshing the index requires
> reading+hashing the existing file if the stat information changed;
> this could be faster or slower than blindly overwriting depending on
> the situation.
> > My deploy process (capistrano) maintains a cached copy of
> > a git repo, which it fetches, resets, and then hardlinks files from
> > when a deploy occurs ( https://github.com/37signals/fast_remote_cache
> > ). The hardlinking step is meant to save the time of copying the file.
> > but hardlinking changes the ctime of the source files.
>
> Interesting. Setting "[core] trustctime = false" in the repository
> configuration could be a good solution (no performance downside I can
> think of).
It is worth noting that many file-based backup systems which do "online"
backups (such as in use where I work) restore the atime by default at
the expense of the ctime (logic being that the atime may have had value
and the ctime changes either way--which may or may not be true) on unix
style filesystems. While many of the git command-line things I have run
seem to figure this out ok, it drives gitk nuts. As far as I am
concerned this is a small price to pay for a solid daily-updated backup
of my machine(s) to be available. I haven't yet put "git reset" of any
sort to use (obviously I just haven't been breaking enough things yet),
but I suspect that it would react in a similar way.
--
-Drew Northup N1XIM
AKA RvnPhnx on OPN
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59
^ permalink raw reply
* Re: [PATCH] describe: Don’t look up commits with --exact-match
From: Jonathan Nieder @ 2010-12-06 17:47 UTC (permalink / raw)
To: Anders Kaseorg
Cc: Junio C Hamano, git, SZEDER Gábor, Kirill Smelkov,
Thomas Rast
In-Reply-To: <alpine.DEB.2.02.1012061159500.23348@dr-wily.mit.edu>
Anders Kaseorg wrote:
> Yeah. Okay, I see that “lookup” implies unpacking, as opposed to “find”,
> which doesn’t. The important part is to avoid the find, of course,
> because the I/O is expensive.
>
> Anyway, here’s a series with that change split out.
Thanks.
In theory finding an object would only require looking at the pack
index (and directory listings), but find_pack_entry does
/*
* We are about to tell the caller where they can
* locate the requested object. We better make
* sure the packfile is still here and can be
* accessed before supplying that answer, as
* it may have been deleted since the index
* was loaded!
*/
which spoils that plan.
Your original use of the word "lookup" seemed sane, too; I was just
fishing for a more detailed explanation.
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
> -- 8< --
> From 2ad1e58b8f6e9c117c77748b6e8b85227d9d5412 Mon Sep 17 00:00:00 2001
[...]
For the future: this does not follow the preferred patch format (one
patch per message, each of the form "description/---/diff"). In this
case I am guessing it won't be much trouble to massage on the
receiving end, so no terrible loss.
^ permalink raw reply
* [PATCHv3 1/6] web--browse: coding style
From: Giuseppe Bilotta @ 2010-12-06 17:49 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Christian Couder, Jonathan Nieder,
Giuseppe Bilotta
In-Reply-To: <1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com>
Retab and deindent choices in case statements.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
git-web--browse.sh | 166 ++++++++++++++++++++++++++--------------------------
1 files changed, 83 insertions(+), 83 deletions(-)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 3fc4166..7c4568f 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -31,11 +31,11 @@ valid_custom_tool()
valid_tool() {
case "$1" in
- firefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)
- ;; # happy
- *)
- valid_custom_tool "$1" || return 1
- ;;
+ firefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)
+ ;; # happy
+ *)
+ valid_custom_tool "$1" || return 1
+ ;;
esac
}
@@ -46,139 +46,139 @@ init_browser_path() {
while test $# != 0
do
- case "$1" in
+ case "$1" in
-b|--browser*|-t|--tool*)
- case "$#,$1" in
+ case "$#,$1" in
*,*=*)
- browser=`expr "z$1" : 'z-[^=]*=\(.*\)'`
- ;;
+ browser=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+ ;;
1,*)
- usage ;;
+ usage ;;
*)
- browser="$2"
- shift ;;
- esac
- ;;
+ browser="$2"
+ shift ;;
+ esac
+ ;;
-c|--config*)
- case "$#,$1" in
+ case "$#,$1" in
*,*=*)
- conf=`expr "z$1" : 'z-[^=]*=\(.*\)'`
- ;;
+ conf=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+ ;;
1,*)
- usage ;;
+ usage ;;
*)
- conf="$2"
- shift ;;
- esac
- ;;
+ conf="$2"
+ shift ;;
+ esac
+ ;;
--)
- break
- ;;
+ break
+ ;;
-*)
- usage
- ;;
+ usage
+ ;;
*)
- break
- ;;
- esac
- shift
+ break
+ ;;
+ esac
+ shift
done
test $# = 0 && usage
if test -z "$browser"
then
- for opt in "$conf" "web.browser"
- do
- test -z "$opt" && continue
- browser="`git config $opt`"
- test -z "$browser" || break
- done
- if test -n "$browser" && ! valid_tool "$browser"; then
- echo >&2 "git config option $opt set to unknown browser: $browser"
- echo >&2 "Resetting to default..."
- unset browser
- fi
+ for opt in "$conf" "web.browser"
+ do
+ test -z "$opt" && continue
+ browser="`git config $opt`"
+ test -z "$browser" || break
+ done
+ if test -n "$browser" && ! valid_tool "$browser"; then
+ echo >&2 "git config option $opt set to unknown browser: $browser"
+ echo >&2 "Resetting to default..."
+ unset browser
+ fi
fi
if test -z "$browser" ; then
- if test -n "$DISPLAY"; then
- browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo"
- if test "$KDE_FULL_SESSION" = "true"; then
- browser_candidates="konqueror $browser_candidates"
+ if test -n "$DISPLAY"; then
+ browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo"
+ if test "$KDE_FULL_SESSION" = "true"; then
+ browser_candidates="konqueror $browser_candidates"
+ fi
+ else
+ browser_candidates="w3m links lynx"
fi
- else
- browser_candidates="w3m links lynx"
- fi
- # SECURITYSESSIONID indicates an OS X GUI login session
- if test -n "$SECURITYSESSIONID" \
- -o "$TERM_PROGRAM" = "Apple_Terminal" ; then
- browser_candidates="open $browser_candidates"
- fi
- # /bin/start indicates MinGW
- if test -x /bin/start; then
- browser_candidates="start $browser_candidates"
- fi
-
- for i in $browser_candidates; do
- init_browser_path $i
- if type "$browser_path" > /dev/null 2>&1; then
- browser=$i
- break
+ # SECURITYSESSIONID indicates an OS X GUI login session
+ if test -n "$SECURITYSESSIONID" \
+ -o "$TERM_PROGRAM" = "Apple_Terminal" ; then
+ browser_candidates="open $browser_candidates"
fi
- done
- test -z "$browser" && die "No known browser available."
+ # /bin/start indicates MinGW
+ if test -x /bin/start; then
+ browser_candidates="start $browser_candidates"
+ fi
+
+ for i in $browser_candidates; do
+ init_browser_path $i
+ if type "$browser_path" > /dev/null 2>&1; then
+ browser=$i
+ break
+ fi
+ done
+ test -z "$browser" && die "No known browser available."
else
- valid_tool "$browser" || die "Unknown browser '$browser'."
+ valid_tool "$browser" || die "Unknown browser '$browser'."
- init_browser_path "$browser"
+ init_browser_path "$browser"
- if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then
- die "The browser $browser is not available as '$browser_path'."
- fi
+ if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then
+ die "The browser $browser is not available as '$browser_path'."
+ fi
fi
case "$browser" in
- firefox|iceweasel)
+firefox|iceweasel)
# Check version because firefox < 2.0 does not support "-new-tab".
vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
NEWTAB='-new-tab'
test "$vers" -lt 2 && NEWTAB=''
"$browser_path" $NEWTAB "$@" &
;;
- google-chrome|chrome|chromium)
+google-chrome|chrome|chromium)
# Actual command for chromium is chromium-browser.
# No need to specify newTab. It's default in chromium
eval "$browser_path" "$@" &
;;
- konqueror)
+konqueror)
case "$(basename "$browser_path")" in
- konqueror)
+ konqueror)
# It's simpler to use kfmclient to open a new tab in konqueror.
browser_path="$(echo "$browser_path" | sed -e 's/konqueror$/kfmclient/')"
type "$browser_path" > /dev/null 2>&1 || die "No '$browser_path' found."
eval "$browser_path" newTab "$@"
;;
- kfmclient)
+ kfmclient)
eval "$browser_path" newTab "$@"
;;
- *)
+ *)
"$browser_path" "$@" &
;;
esac
;;
- w3m|links|lynx|open)
+w3m|links|lynx|open)
eval "$browser_path" "$@"
;;
- start)
- exec "$browser_path" '"web-browse"' "$@"
- ;;
- dillo)
+start)
+ exec "$browser_path" '"web-browse"' "$@"
+ ;;
+dillo)
"$browser_path" "$@" &
;;
- *)
+*)
if test -n "$browser_cmd"; then
- ( eval $browser_cmd "$@" )
+ ( eval $browser_cmd "$@" )
fi
;;
esac
--
1.7.3.2.664.g294b8.dirty
^ permalink raw reply related
* [PATCHv3 2/6] web--browse: split valid_tool list
From: Giuseppe Bilotta @ 2010-12-06 17:49 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Christian Couder, Jonathan Nieder,
Giuseppe Bilotta
In-Reply-To: <1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com>
It was getting too long, and we want to add some more.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
git-web--browse.sh | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 7c4568f..e48e30d 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -31,7 +31,8 @@ valid_custom_tool()
valid_tool() {
case "$1" in
- firefox | iceweasel | chrome | google-chrome | chromium | konqueror | w3m | links | lynx | dillo | open | start)
+ firefox | iceweasel | chrome | google-chrome | chromium |\
+ konqueror | w3m | links | lynx | dillo | open | start)
;; # happy
*)
valid_custom_tool "$1" || return 1
--
1.7.3.2.664.g294b8.dirty
^ permalink raw reply related
* [PATCHv3 3/6] web--browse: support opera, seamonkey and elinks
From: Giuseppe Bilotta @ 2010-12-06 17:49 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Christian Couder, Jonathan Nieder,
Giuseppe Bilotta
In-Reply-To: <1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com>
The list of supported browsers is also updated in the documentation.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
Documentation/git-web--browse.txt | 6 ++++++
git-web--browse.sh | 14 +++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index 51e8e0a..5d3ae07 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -20,8 +20,14 @@ The following browsers (or commands) are currently supported:
* firefox (this is the default under X Window when not using KDE)
* iceweasel
+* seamonkey
+* iceape
+* chromium
+* google-chrome
* konqueror (this is the default under KDE, see 'Note about konqueror' below)
+* opera
* w3m (this is the default outside graphical environments)
+* elinks
* links
* lynx
* dillo
diff --git a/git-web--browse.sh b/git-web--browse.sh
index e48e30d..48e5a28 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -31,8 +31,8 @@ valid_custom_tool()
valid_tool() {
case "$1" in
- firefox | iceweasel | chrome | google-chrome | chromium |\
- konqueror | w3m | links | lynx | dillo | open | start)
+ firefox | iceweasel | seamonkey | iceape | chrome | google-chrome | chromium |\
+ konqueror | opera | w3m | elinks | links | lynx | dillo | open | start)
;; # happy
*)
valid_custom_tool "$1" || return 1
@@ -104,12 +104,12 @@ fi
if test -z "$browser" ; then
if test -n "$DISPLAY"; then
- browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror w3m links lynx dillo"
+ browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror opera seamonkey iceape w3m elinks links lynx dillo"
if test "$KDE_FULL_SESSION" = "true"; then
browser_candidates="konqueror $browser_candidates"
fi
else
- browser_candidates="w3m links lynx"
+ browser_candidates="w3m elinks links lynx"
fi
# SECURITYSESSIONID indicates an OS X GUI login session
if test -n "$SECURITYSESSIONID" \
@@ -140,7 +140,7 @@ else
fi
case "$browser" in
-firefox|iceweasel)
+firefox|iceweasel|seamonkey|iceape)
# Check version because firefox < 2.0 does not support "-new-tab".
vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
NEWTAB='-new-tab'
@@ -168,13 +168,13 @@ konqueror)
;;
esac
;;
-w3m|links|lynx|open)
+w3m|elinks|links|lynx|open)
eval "$browser_path" "$@"
;;
start)
exec "$browser_path" '"web-browse"' "$@"
;;
-dillo)
+opera|dillo)
"$browser_path" "$@" &
;;
*)
--
1.7.3.2.664.g294b8.dirty
^ permalink raw reply related
* [PATCHv3 4/6] web--browse: better support for chromium
From: Giuseppe Bilotta @ 2010-12-06 17:49 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Christian Couder, Jonathan Nieder,
Giuseppe Bilotta
In-Reply-To: <1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com>
On Debian-based distributions, Chromium the browser is available under
the name chromium-browser rather than chromium, to prevent conflicts
with the Chromium B.S.U. game.
Look for chromium-browser first when setting the path for chromium, and
also add chromium-browser as a supported browser name. Document the
dual-name support, and mention the dual-name support for
(google-)chrome too.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
Documentation/git-web--browse.txt | 4 ++--
git-web--browse.sh | 12 ++++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index 5d3ae07..c0416e5 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -22,8 +22,8 @@ The following browsers (or commands) are currently supported:
* iceweasel
* seamonkey
* iceape
-* chromium
-* google-chrome
+* chromium (also supported as chromium-browser)
+* google-chrome (also supported as chrome)
* konqueror (this is the default under KDE, see 'Note about konqueror' below)
* opera
* w3m (this is the default outside graphical environments)
diff --git a/git-web--browse.sh b/git-web--browse.sh
index 48e5a28..b2fc3b4 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -31,7 +31,8 @@ valid_custom_tool()
valid_tool() {
case "$1" in
- firefox | iceweasel | seamonkey | iceape | chrome | google-chrome | chromium |\
+ firefox | iceweasel | seamonkey | iceape |\
+ chrome | google-chrome | chromium | chromium-browser |\
konqueror | opera | w3m | elinks | links | lynx | dillo | open | start)
;; # happy
*)
@@ -42,6 +43,10 @@ valid_tool() {
init_browser_path() {
browser_path=$(git config "browser.$1.path")
+ if test -z "$browser_path" -a "$1" = chromium &&
+ type chromium-browser > /dev/null 2>&1 ; then
+ browser_path=chromium-browser
+ fi
test -z "$browser_path" && browser_path="$1"
}
@@ -104,7 +109,7 @@ fi
if test -z "$browser" ; then
if test -n "$DISPLAY"; then
- browser_candidates="firefox iceweasel google-chrome chrome chromium konqueror opera seamonkey iceape w3m elinks links lynx dillo"
+ browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo"
if test "$KDE_FULL_SESSION" = "true"; then
browser_candidates="konqueror $browser_candidates"
fi
@@ -147,8 +152,7 @@ firefox|iceweasel|seamonkey|iceape)
test "$vers" -lt 2 && NEWTAB=''
"$browser_path" $NEWTAB "$@" &
;;
-google-chrome|chrome|chromium)
- # Actual command for chromium is chromium-browser.
+google-chrome|chrome|chromium|chromium-browser)
# No need to specify newTab. It's default in chromium
eval "$browser_path" "$@" &
;;
--
1.7.3.2.664.g294b8.dirty
^ permalink raw reply related
* [PATCHv3 5/6] web--browse: use *www-browser if available
From: Giuseppe Bilotta @ 2010-12-06 17:49 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Christian Couder, Jonathan Nieder,
Giuseppe Bilotta
In-Reply-To: <1291657790-3719-1-git-send-email-giuseppe.bilotta@gmail.com>
Debian and derivatives have an alternatives-based default browser
configuration that uses the /usr/bin/gnome-www-browser,
/usr/bin/x-www-browser and /usr/bin/www-browser symlinks.
When no browser is selected by the user and the Debian alternatives are
available, try to see if they are one of our recognized selection and
in the affermative case use it. Otherwise, warn the user about them
being unsupported and move on with the previous detection logic.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
Documentation/git-web--browse.txt | 4 ++
git-web--browse.sh | 84 +++++++++++++++++++++++++++++++++++-
2 files changed, 85 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
index c0416e5..157738a 100644
--- a/Documentation/git-web--browse.txt
+++ b/Documentation/git-web--browse.txt
@@ -36,6 +36,10 @@ The following browsers (or commands) are currently supported:
Custom commands may also be specified.
+If no default browser is specified, and /usr/bin/gnome-www-browser
+(under GNOME), /usr/bin/x-www-browser (under X) or /usr/bin/www-browser
+is present, they are used to determine the browser to use.
+
OPTIONS
-------
-b <browser>::
diff --git a/git-web--browse.sh b/git-web--browse.sh
index b2fc3b4..b496b6c 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -50,6 +50,63 @@ init_browser_path() {
test -z "$browser_path" && browser_path="$1"
}
+# check if a given executable is a browser we like
+valid_browser_executable() {
+ testexe="$1"
+
+ # check the executable name first, trying to follow symlinks if possible
+ if type readlink > /dev/null 2>&1 ; then
+ basename="$(basename $(readlink -f "$testexe"))"
+ else
+ basename="$(basename "$testexe")"
+ fi
+ if valid_tool "$basename" ; then
+ browser="$basename"
+ browser_path="$testexe"
+ return 0
+ fi
+
+ # if the linked executable doesn't match a browser name we know about,
+ # look at the version string
+
+ # even though most browsers (and applications, in fact) will show their
+ # name and version on the first line of the --version output, this is
+ # not true in particular for the KDE apps (e.g. konqueror and kfmclient),
+ # which display their name and version on the LAST line. So we cannot
+ # clip the version string at the first line when retrieving it. Rather,
+ # we keep it whole and then limit it when we know what we're dealing with.
+
+ verstring="$("$testexe" --version 2> /dev/null)"
+ browser="$(echo "$verstring" | head -n 1 | cut -f1 -d' ' | tr A-Z a-z)"
+ case "$browser" in
+ mozilla)
+ verstring="$(echo "$verstring" | head -n 1)"
+ browser="$(echo "$verstring" | cut -f2 -d' ' | tr A-Z a-z)"
+ ;;
+ google)
+ verstring="$(echo "$verstring" | head -n 1)"
+ browser="google-chrome"
+ ;;
+ qt:)
+ # konqueror, kfmclient or other KDE app
+ verstring="$(echo "$verstring" | tail -n 1)"
+ browser="$(echo "$verstring" | cut -f1 -d:)"
+ ;;
+ *)
+ verstring="$(echo "$verstring" | head -n 1)"
+ ;;
+
+ esac
+ if valid_tool "$browser" ; then
+ browser_path="$i"
+ return 0
+ fi
+
+ echo >&2 "$testexe (detected as $browser) is not a supported browser, skipping"
+ browser=""
+ return 1
+}
+
while test $# != 0
do
case "$1" in
@@ -107,6 +164,26 @@ then
fi
fi
+# Debian and derivatives use gnome-www-browser, x-www-browser or www-browser to
+# set the default browser for the system. If the user did not specify a tool and
+# we detect that one of the *www-browser links to a supported one, we pick it.
+# Otherwise, we warn the user about them being unsupported and proceed to look
+# for a supported browser.
+if test -z "$browser" ; then
+ wwwbrowser="/usr/bin/www-browser"
+ if test -n "$DISPLAY"; then
+ wwwbrowser="/usr/bin/x-www-browser $wwwbrowser"
+ if test -n "$GNOME_DESKTOP_SESSION_ID"; then
+ wwwbrowser="/usr/bin/gnome-www-browser $wwwbrowser"
+ fi
+ fi
+ for i in $wwwbrowser; do
+ if test -x $i && valid_browser_executable $i ; then
+ break
+ fi
+ done
+fi
+
if test -z "$browser" ; then
if test -n "$DISPLAY"; then
browser_candidates="firefox iceweasel google-chrome chrome chromium chromium-browser konqueror opera seamonkey iceape w3m elinks links lynx dillo"
@@ -134,7 +211,7 @@ if test -z "$browser" ; then
fi
done
test -z "$browser" && die "No known browser available."
-else
+else if test -z "$browser_path"; then
valid_tool "$browser" || die "Unknown browser '$browser'."
init_browser_path "$browser"
@@ -142,12 +219,13 @@ else
if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then
die "The browser $browser is not available as '$browser_path'."
fi
-fi
+fi fi
case "$browser" in
firefox|iceweasel|seamonkey|iceape)
# Check version because firefox < 2.0 does not support "-new-tab".
- vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
+ test -z "$verstring" && verstring="$($browser_path -version)"
+ vers=$(expr "$verstring" : '.* \([0-9][0-9]*\)\..*')
NEWTAB='-new-tab'
test "$vers" -lt 2 && NEWTAB=''
"$browser_path" $NEWTAB "$@" &
--
1.7.3.2.664.g294b8.dirty
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox