* Re: Git-1.6.0.2-preview20080921 on Windows
From: Steffen Prohaska @ 2008-09-22 5:51 UTC (permalink / raw)
To: Jakub Narebski; +Cc: msysGit, Git Mailing List
In-Reply-To: <m3od2hl3lv.fsf@localhost.localdomain>
On Sep 21, 2008, at 9:07 PM, Jakub Narebski wrote:
> Steffen Prohaska <prohaska@zib.de> writes:
>
>> Git-1.6.0.2-preview20080921 for Windows is available at
>>
>> http://code.google.com/p/msysgit/downloads
>
> Wouldn't it be better if this email had [ANNOUNCE] in the subject, to
> be catched by mail2rss thingy that feeds Ohloh page for Git?
Your are right.
Steffen
^ permalink raw reply
* Re: [PATCH 7/7] Windows: Revert to default paths and convert them by RUNTIME_PREFIX
From: Steffen Prohaska @ 2008-09-22 5:57 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Junio C Hamano, Johannes Schindelin
In-Reply-To: <200809212358.48125.johannes.sixt@telecom.at>
On Sep 21, 2008, at 11:58 PM, Johannes Sixt wrote:
> On Sonntag, 21. September 2008, Steffen Prohaska wrote:
>> The RUNTIME_PREFIX mechanism allows us to use the default
>> (absolute) paths
>> on Windows too. Defining RUNTIME_PREFIX explicitly requests for
>> translation of paths during runtime, depending on the path to the
>> executable.
>>
>> Signed-off-by: Steffen Prohaska <prohaska@zib.de>
>> ---
>> Makefile | 4 +---
>> 1 files changed, 1 insertions(+), 3 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 8181f74..98278f0 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -767,6 +767,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
>> SNPRINTF_RETURNS_BOGUS = YesPlease
>> NO_SVN_TESTS = YesPlease
>> NO_PERL_MAKEMAKER = YesPlease
>> + RUNTIME_PREFIX = YesPlease
>> NO_POSIX_ONLY_PROGRAMS = YesPlease
>> NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
>> COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/
>> regex
>> -Icompat/fnmatch @@ -775,9 +776,6 @@ ifneq (,$(findstring
>> MINGW,$(uname_S)))
>> COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o
>> compat/regex/regex.o compat/winansi.o EXTLIBS += -lws2_32
>> X = .exe
>> - gitexecdir = ../libexec/git-core
>> - template_dir = ../share/git-core/templates/
>> - ETC_GITCONFIG = ../etc/gitconfig
>> endif
>> ifneq (,$(findstring arm,$(uname_M)))
>> ARM_SHA1 = YesPlease
>
> This cannot be the complete patch. The part that sets $(prefix) to
> the empty
> string is missing, otherwise the runtime prefix discovery would never
> trigger, right? (But see also my comment on [PATCH 1/7].)
Right. There are still some differences between msysgit's Makefile and
the official one, so I forgot to include all necessary changes.
I'll modify the implementation as you propose in your comment
on [PATCH 1/7].
Steffen
^ permalink raw reply
* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Johannes Sixt @ 2008-09-22 7:25 UTC (permalink / raw)
To: Alexander Gavrilov; +Cc: git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <200809212252.35769.angavrilov@gmail.com>
Alexander Gavrilov schrieb:
> Subject: [PATCH] gitk: Implement batch lookup and caching of encoding attrs.
>
> When the diff contains thousands of files, calling git-check-attr
> once per file is very slow. With this patch gitk does attribute
> lookup in batches of 30 files while reading the diff file list,
> which leads to a very noticeable speedup.
This one does not work for me: The correct is not picked up anymore,
neither in Patch mode nor Tree mode. (It works as expected without this
patch.)
> +proc cache_gitattr {attr pathlist} {
> + global path_attr_cache
> + set newlist {}
> + foreach path $pathlist {
> + if {[info exists path_attr_cache($attr,$path)]} continue
> + lappend newlist $path
> + }
> + while {$newlist ne {}} {
> + set head [lrange $newlist 0 29]
> + set newlist [lrange $newlist 30 end]
> + if {![catch {set rlist [eval exec git check-attr $attr -- $head]}]} {
> + foreach row [split $rlist "\n"] {
> + set cols [split $row :]
This colon made me nervous (because of the drive-colon combination on
Windows), but as long as you feed relative paths into 'git check-attr',
this should not matter (in my case).
> + set path [lindex $cols 0]
> + set value [join [lrange $cols 2 end] :]
> + if {[string index $path 0] eq "\""} {
> + set path [encoding convertfrom [lindex $path 0]]
> + }
> + set path_attr_cache($attr,$path) $value
> + }
> + }
> + update
> + }
> +}
^ permalink raw reply
* Re: [PATCH (GIT-GUI)] git-gui: Reenable staging unmerged files by clicking the icon.
From: Johannes Sixt @ 2008-09-22 7:31 UTC (permalink / raw)
To: Alexander Gavrilov; +Cc: git, Shawn O. Pearce
In-Reply-To: <200809201219.18630.angavrilov@gmail.com>
Alexander Gavrilov schrieb:
> This restores functionality of the file icon for unmerged files.
> Safety is enforced by loading the diff and checking for lines
> that look like conflict markers. If such lines are found, or
> the conflict involves deletion and/or symlinks, a confirmation
> dialog is presented. Otherwise, the icon immediately stages the
> working copy version of the file.
>
> Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca
> (Restore ability to Stage Working Copy for conflicts)
Thanks, works fine after a brief test:
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
-- Hannes
^ permalink raw reply
* Re: out of memory problem
From: Andreas Ericsson @ 2008-09-22 7:32 UTC (permalink / raw)
To: Guo Tang; +Cc: Git mailing list
In-Reply-To: <alpine.LFD.2.00.0809211556030.19373@homelinux>
Guo Tang wrote:
> Gentlemen,
>
> I try to run "git gc" on linux kernel tree. The virtual memory keeps
> going up until over 3GB, then crash.
> Tried twice with the v1.6.0.2, same result.
> Then I used the git coming with FC9 (v1.5.5.1), the peak virutal memory
> usage is about 1.5GB. "git gc" finished without any trouble.
>
> Could there be a memory leak in v1.6.0.2?
>
There could be, but most likely it's commit
38bd64979a2a3ffa178af801c6a62e6fcd658274 (Enable threaded delta
search on BSD and Linux). Do you have multiple cpu's in the
computer where 'git gc' was running? If so, and if you've set
pack.threads = 0, or --threads=0 it will autodetect the number
of CPU's you have and then saturate all of them with work. Each
thread will however consume memory close to that of a single
process running the repack, so for large repositories you might
want to set pack.threads = 1 in such large repositories.
It's a shame you didn't save the unpacked repository, or this could
have been properly debugged. While it's possible there is a memory
leak, it's a dismal project trying to locate it by staring at the
code, and the time it takes to repack huge repositories with memory
intensive parameters is sort of prohibitive for finding the possible
leak by bisection.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply
* Re: ignoring files/directories in git
From: Boaz Harrosh @ 2008-09-22 7:37 UTC (permalink / raw)
To: mwolfe38; +Cc: git
In-Reply-To: <19599905.post@talk.nabble.com>
mwolfe38 wrote:
> I just thought that I would add that the reason is a bug in the 1.5.4.3
> version that I am using which is the ubuntu 8.04 repository version.
> According to some developers, the current version should fix this issue.
>
>
[Please don't top-post]
I have 1.6.0.1 I compiled here, and it has the same problem. So it is
a very recent fix
> mwolfe38 wrote:
>> I'm working on a project by myself and using git mostly just to learn
>> about it.
>> In my project I have several directories I want to have git ignore. One of
>> them being
>> cache/ and the other log/
>> I've added them to the .gitignore file which I have in the initial
>> directory of the repository
>> The contents of my gitignore are:
>>
>> .settings
>> .cache
>> cache/
>> log/
>> .project
>>
>> However, if I do
>> git add .
>> It will add the files from cache and log anyways.
>> I know git add . will add anything that hasn't been added but shouldn't it
>> ignore files in .gitignore?
>> If not, what is the point, I would just ignore them manually anyways.
>> The main reason i like doing git add .
>> is because i'm using symfony php framework which makes good use of scripts
>> which generates lots if initial files for you and thus adding one at a
>> time would be a pain.
>>
>> Any idea what might be going on here? I thought maybe I had added those
>> directories before putting them in .gitignore so i used git rm -r to
>> remove them but they still show back up with doing git add .
>>
>> Thanks in advance
>>
>
Boaz
^ permalink raw reply
* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Johannes Sixt @ 2008-09-22 7:46 UTC (permalink / raw)
To: Alexander Gavrilov; +Cc: git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <48D74877.9050607@viscovery.net>
Johannes Sixt schrieb:
> Alexander Gavrilov schrieb:
>> Subject: [PATCH] gitk: Implement batch lookup and caching of encoding attrs.
>>
>> When the diff contains thousands of files, calling git-check-attr
>> once per file is very slow. With this patch gitk does attribute
>> lookup in batches of 30 files while reading the diff file list,
>> which leads to a very noticeable speedup.
>
> This one does not work for me: The correct is not picked up anymore,
The correct _encoding_ is not picked up anymore...
> neither in Patch mode nor Tree mode. (It works as expected without this
> patch.)
>
>> +proc cache_gitattr {attr pathlist} {
>> + global path_attr_cache
>> + set newlist {}
>> + foreach path $pathlist {
>> + if {[info exists path_attr_cache($attr,$path)]} continue
>> + lappend newlist $path
>> + }
>> + while {$newlist ne {}} {
>> + set head [lrange $newlist 0 29]
>> + set newlist [lrange $newlist 30 end]
>> + if {![catch {set rlist [eval exec git check-attr $attr -- $head]}]} {
>> + foreach row [split $rlist "\n"] {
>> + set cols [split $row :]
>
> This colon made me nervous (because of the drive-colon combination on
> Windows), but as long as you feed relative paths into 'git check-attr',
> this should not matter (in my case).
This comment does not imply that I debugged this code. I just noticed the
colon while reading the patch.
>> + set path [lindex $cols 0]
>> + set value [join [lrange $cols 2 end] :]
>> + if {[string index $path 0] eq "\""} {
>> + set path [encoding convertfrom [lindex $path 0]]
>> + }
>> + set path_attr_cache($attr,$path) $value
>> + }
>> + }
>> + update
>> + }
>> +}
^ permalink raw reply
* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Alexander Gavrilov @ 2008-09-22 8:01 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <48D74877.9050607@viscovery.net>
On Monday 22 September 2008 11:25:43 Johannes Sixt wrote:
> Alexander Gavrilov schrieb:
> > Subject: [PATCH] gitk: Implement batch lookup and caching of encoding attrs.
> >
> > When the diff contains thousands of files, calling git-check-attr
> > once per file is very slow. With this patch gitk does attribute
> > lookup in batches of 30 files while reading the diff file list,
> > which leads to a very noticeable speedup.
>
> This one does not work for me: The correct is not picked up anymore,
> neither in Patch mode nor Tree mode. (It works as expected without this
> patch.)
>
OOPS, I forgot to copy the line that removes leading whitespace:
@@ -9876,6 +9876,7 @@ proc cache_gitattr {attr pathlist} {
if {[string index $path 0] eq "\""} {
set path [encoding convertfrom [lindex $path 0]]
}
+ regsub {^ } $value {} value
set path_attr_cache($attr,$path) $value
}
}
> > + set cols [split $row :]
> > + set path [lindex $cols 0]
>
> This colon made me nervous (because of the drive-colon combination on
> Windows), but as long as you feed relative paths into 'git check-attr',
> this should not matter (in my case).
I'm afraid there is nothing to be done about it without changing git-check-attr.
For example, it could quote ':' in the path in octal -- current interface allows it.
But since the path is relative, it is not a big deal.
--- >8 ---
From: Alexander Gavrilov <angavrilov@gmail.com>
Subject: [PATCH v2] gitk: Implement batch lookup and caching of encoding attrs.
When the diff contains thousands of files, calling git-check-attr
once per file is very slow. With this patch gitk does attribute
lookup in batches of 30 files while reading the diff file list,
which leads to a very noticeable speedup.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
gitk | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/gitk b/gitk
index 1355aa2..cf557c3 100755
--- a/gitk
+++ b/gitk
@@ -6530,6 +6530,7 @@ proc gettreediffline {gdtf ids} {
global cmitmode vfilelimit curview limitdiffs
set nr 0
+ set sublist {}
while {[incr nr] <= 1000 && [gets $gdtf line] >= 0} {
set i [string first "\t" $line]
if {$i >= 0} {
@@ -6539,8 +6540,10 @@ proc gettreediffline {gdtf ids} {
}
set file [encoding convertfrom $file]
lappend treediff $file
+ lappend sublist $file
}
}
+ cache_gitattr encoding $sublist
if {![eof $gdtf]} {
return [expr {$nr >= 1000? 2: 1}]
}
@@ -9839,18 +9842,48 @@ proc tcl_encoding {enc} {
}
proc gitattr {path attr default} {
- if {[catch {set r [exec git check-attr $attr -- $path]}]} {
+ global path_attr_cache
+ if {[info exists path_attr_cache($attr,$path)]} {
+ set r $path_attr_cache($attr,$path)
+ } elseif {[catch {set r [exec git check-attr $attr -- $path]}]} {
set r unspecified
} else {
set r [join [lrange [split $r :] 2 end] :]
regsub {^ } $r {} r
}
+ set path_attr_cache($attr,$path) $r
if {$r eq {unspecified}} {
return $default
}
return $r
}
+proc cache_gitattr {attr pathlist} {
+ global path_attr_cache
+ set newlist {}
+ foreach path $pathlist {
+ if {[info exists path_attr_cache($attr,$path)]} continue
+ lappend newlist $path
+ }
+ while {$newlist ne {}} {
+ set head [lrange $newlist 0 29]
+ set newlist [lrange $newlist 30 end]
+ if {![catch {set rlist [eval exec git check-attr $attr -- $head]}]} {
+ foreach row [split $rlist "\n"] {
+ set cols [split $row :]
+ set path [lindex $cols 0]
+ set value [join [lrange $cols 2 end] :]
+ if {[string index $path 0] eq "\""} {
+ set path [encoding convertfrom [lindex $path 0]]
+ }
+ regsub {^ } $value {} value
+ set path_attr_cache($attr,$path) $value
+ }
+ }
+ update
+ }
+}
+
proc get_path_encoding {path} {
global gui_encoding
set tcl_enc [tcl_encoding $gui_encoding]
--
1.6.0.20.g6148bc
^ permalink raw reply related
* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Johannes Sixt @ 2008-09-22 8:20 UTC (permalink / raw)
To: Alexander Gavrilov; +Cc: git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <200809221201.35507.angavrilov@gmail.com>
Alexander Gavrilov schrieb:
> On Monday 22 September 2008 11:25:43 Johannes Sixt wrote:
>> Alexander Gavrilov schrieb:
>>> Subject: [PATCH] gitk: Implement batch lookup and caching of encoding attrs.
>>>
>>> When the diff contains thousands of files, calling git-check-attr
>>> once per file is very slow. With this patch gitk does attribute
>>> lookup in batches of 30 files while reading the diff file list,
>>> which leads to a very noticeable speedup.
>> This one does not work for me: The correct is not picked up anymore,
>> neither in Patch mode nor Tree mode. (It works as expected without this
>> patch.)
>>
>
> OOPS, I forgot to copy the line that removes leading whitespace:
Thanks, with this it works now. The delay for a 1000 file patch is
bearable (on Windows, but y'know, Windows types are masochists :-).
Feel free to add:
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
to the patches in the series when you resend it - and I hope you do resend
it after addressing Paul's concerns.
-- Hannes
^ permalink raw reply
* Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax
From: Gustaf Hendeby @ 2008-09-22 8:29 UTC (permalink / raw)
To: Brandon Casey
Cc: Junio C Hamano, Arjen Laarhoven, Mike Ralphson, Johannes Sixt,
Jeff King, Boyd Lynn Gerber, Git Mailing List, Avery Pennarun,
Johan Herland, Andreas Ericsson, Kirill Smelkov, Giuseppe Bilotta,
Jonathan del Strother
In-Reply-To: <4i0Mu795rKpv37JoHytmE6kODBjwgwITn0-DuKdZiFs3ZnUlyJC-Fw@cipher.nrlssc.navy.mil>
On 09/19/2008 12:47 AM, Brandon Casey wrote:
> The 'non-GNU' part of this basic RE to extended RE conversion means '\\s' was
> converted to ' '.
I've tested the converted BibTeX pattern and it seems to work as expected.
/Gustaf
^ permalink raw reply
* Re: [CORRECTION] Git-1.6.0.2-preview20080921 on Windows
From: Peter Krefting @ 2008-09-22 8:41 UTC (permalink / raw)
To: Steffen Prohaska; +Cc: msysGit, Git Mailing List
In-Reply-To: <691F01A6-CA78-46DA-8388-C8339A3F0F04@zib.de>
Steffen Prohaska:
> Git-1.6.0.2-preview20080921 for Windows is available at
> http://code.google.com/p/msysgit/downloads
Thank you!
After installing and running some simple tests (some command line
commands, git gui, gitk), everything seems to be working just fine.
One minor detail that would be nice to get fixed is in the installer --
it forgets the some of choices I made last time I installed Git. The
install path and icon creation is saved, but I need to select "Run from
Windows command line" and "Use PLink" manually even though I selected
them last time.
--
\\// Peter - http://www.softwolves.pp.se/
^ permalink raw reply
* Re: ignoring files/directories in git
From: Dmitry Potapov @ 2008-09-22 8:52 UTC (permalink / raw)
To: Boaz Harrosh; +Cc: mwolfe38, git
In-Reply-To: <48D74B1C.6020408@panasas.com>
On Mon, Sep 22, 2008 at 10:37:00AM +0300, Boaz Harrosh wrote:
>
> I have 1.6.0.1 I compiled here, and it has the same problem. So it is
> a very recent fix
I certainly tested 1.6.0.1 and does not have this problem, and it was
fixed a long time ago:
===
commit d6b8fc303b389b026f2bf9918f6f83041488989b
Author: Junio C Hamano <gitster@pobox.com>
Date: Thu Jan 31 01:17:48 2008 -0800
gitignore(5): Allow "foo/" in ignore list to match directory "foo"
A pattern "foo/" in the exclude list did not match directory
"foo", but a pattern "foo" did. This attempts to extend the
exclude mechanism so that it would while not matching a regular
file or a symbolic link "foo". In order to differentiate a
directory and non directory, this passes down the type of path
being checked to excluded() function.
A downside is that the recursive directory walk may need to run
lstat(2) more often on systems whose "struct dirent" do not give
the type of the entry; earlier it did not have to do so for an
excluded path, but we now need to figure out if a path is a
directory before deciding to exclude it. This is especially bad
because an idea similar to the earlier CE_UPTODATE optimization
to reduce number of lstat(2) calls would by definition not apply
to the codepaths involved, as (1) directories will not be
registered in the index, and (2) excluded paths will not be in
the index anyway.
===
The patch is included in 1.5.5.
Dmitry
^ permalink raw reply
* [PATCH v2] make "git remote" report multiple URLs
From: Michael J Gruber @ 2008-09-22 8:57 UTC (permalink / raw)
To: git; +Cc: Michael J Gruber
In-Reply-To: <7vej3fswwe.fsf@gitster.siamese.dyndns.org>
This patch makes "git remote -v" and "git remote show" report multiple URLs
rather than warn about them. Multiple URLs are OK for pushing into
multiple repos simultaneously. Without "-v" each repo is shown once only.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
builtin-remote.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
Change in v2: report each repo once only if "-v" is not used (i.e. URL is not shown),
as requested by JC.
JC wrote:
> MJG wrote:
>> This passes all tests, so I think the new output does not break anything.
> Or just there is no existing tests that verify the output from this command.
JC, sounds as if you're a mathematician, as well ;)
diff --git a/builtin-remote.c b/builtin-remote.c
index 01945a8..1e2edc2 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -652,10 +652,13 @@ static int get_one_entry(struct remote *remote, void *priv)
{
struct string_list *list = priv;
- string_list_append(remote->name, list)->util = remote->url_nr ?
- (void *)remote->url[0] : NULL;
- if (remote->url_nr > 1)
- warning("Remote %s has more than one URL", remote->name);
+ if (remote->url_nr > 0) {
+ int i;
+
+ for (i = 0; i < remote->url_nr; i++)
+ string_list_append(remote->name, list)->util = (void *)remote->url[i];
+ } else
+ string_list_append(remote->name, list)->util = NULL;
return 0;
}
@@ -671,10 +674,14 @@ static int show_all(void)
sort_string_list(&list);
for (i = 0; i < list.nr; i++) {
struct string_list_item *item = list.items + i;
- printf("%s%s%s\n", item->string,
- verbose ? "\t" : "",
- verbose && item->util ?
- (const char *)item->util : "");
+ if (verbose)
+ printf("%s\t%s\n", item->string,
+ item->util ? (const char *)item->util : "");
+ else {
+ if (i && !strcmp((item - 1)->string, item->string))
+ continue;
+ printf("%s\n", item->string);
+ }
}
}
return result;
--
1.6.0.2.287.g3791f
^ permalink raw reply related
* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Dmitry Potapov @ 2008-09-22 9:01 UTC (permalink / raw)
To: Alexander Gavrilov; +Cc: Johannes Sixt, git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <200809212252.35769.angavrilov@gmail.com>
On Sun, Sep 21, 2008 at 10:52:35PM +0400, Alexander Gavrilov wrote:
>
> I made a patch to optimize attribute lookup. I'm afraid that further optimization
> is impossible without interface changes in git-check-attr, or reimplementing
> the attribute parser in Tcl.
I wonder would not make sense to add --stdin-paths option to git
check-attr in the same way as we have for git hash-object?
Dmitry
^ permalink raw reply
* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Alexander Gavrilov @ 2008-09-22 9:02 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <48D7554C.4020601@viscovery.net>
On Monday 22 September 2008 12:20:28 Johannes Sixt wrote:
> Alexander Gavrilov schrieb:
> > On Monday 22 September 2008 11:25:43 Johannes Sixt wrote:
> >> Alexander Gavrilov schrieb:
> >>> Subject: [PATCH] gitk: Implement batch lookup and caching of encoding attrs.
> >>>
> >>> When the diff contains thousands of files, calling git-check-attr
> >>> once per file is very slow. With this patch gitk does attribute
> >>> lookup in batches of 30 files while reading the diff file list,
> >>> which leads to a very noticeable speedup.
> >> This one does not work for me: The correct is not picked up anymore,
> >> neither in Patch mode nor Tree mode. (It works as expected without this
> >> patch.)
> >>
> >
> > OOPS, I forgot to copy the line that removes leading whitespace:
>
> Thanks, with this it works now. The delay for a 1000 file patch is
> bearable (on Windows, but y'know, Windows types are masochists :-).
You can also try applying this patch (originally made for git-gui). It may save
additional 0.3 sec, especially for obscure legacy encodings.
P.S. I do believe there is a place for a library shared between gitk & git-gui.
This code duplication is ugly and annoying; moreover, they have different
indentation conventions, which get messed up...
--- >8 ---
From: Alexander Gavrilov <angavrilov@gmail.com>
Subject: [PATCH] git-gui: Optimize encoding name resolution using a lookup table.
Encoding menu construction does almost a hundred of encoding
resolutions, which with the old implementation led to a
small but noticeable delay.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
gitk | 84 ++++++++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 54 insertions(+), 30 deletions(-)
diff --git a/gitk b/gitk
index 254faa1..1355aa2 100755
--- a/gitk
+++ b/gitk
@@ -9779,39 +9779,63 @@ set encoding_aliases {
{ Big5 csBig5 }
}
-proc tcl_encoding {enc} {
- global encoding_aliases
- set names [encoding names]
- set lcnames [string tolower $names]
- set enc [string tolower $enc]
- set i [lsearch -exact $lcnames $enc]
- if {$i < 0} {
- # look for "isonnn" instead of "iso-nnn" or "iso_nnn"
- if {[regsub {^(iso|cp|ibm|jis)[-_]} $enc {\1} encx]} {
- set i [lsearch -exact $lcnames $encx]
+proc build_encoding_table {} {
+ global encoding_aliases encoding_lookup_table
+
+ # Prepare the lookup list; cannot use lsort -nocase because
+ # of compatibility issues with older Tcl (e.g. in msysgit)
+ set names [list]
+ foreach item [encoding names] {
+ lappend names [list [string tolower $item] $item]
+ }
+ set names [lsort -ascii -index 0 $names]
+ # neither can we use lsearch -index
+ set lnames [list]
+ foreach item $names {
+ lappend lnames [lindex $item 0]
+ }
+
+ foreach grp $encoding_aliases {
+ set target {}
+ foreach item $grp {
+ set i [lsearch -sorted -ascii $lnames \
+ [string tolower $item]]
+ if {$i >= 0} {
+ set target [lindex $names $i 1]
+ break
+ }
+ }
+ if {$target eq {}} continue
+ foreach item $grp {
+ set encoding_lookup_table([string tolower $item]) $target
+ }
}
- }
- if {$i < 0} {
- foreach l $encoding_aliases {
- set ll [string tolower $l]
- if {[lsearch -exact $ll $enc] < 0} continue
- # look through the aliases for one that tcl knows about
- foreach e $ll {
- set i [lsearch -exact $lcnames $e]
- if {$i < 0} {
- if {[regsub {^(iso|cp|ibm|jis)[-_]} $e {\1} ex]} {
- set i [lsearch -exact $lcnames $ex]
- }
+
+ foreach item $names {
+ set encoding_lookup_table([lindex $item 0]) [lindex $item 1]
+ }
+}
+
+proc tcl_encoding {enc} {
+ global encoding_lookup_table
+ if {$enc eq {}} {
+ return {}
+ }
+ if {![info exists encoding_lookup_table]} {
+ build_encoding_table
+ }
+ set enc [string tolower $enc]
+ if {![info exists encoding_lookup_table($enc)]} {
+ # look for "isonnn" instead of "iso-nnn" or "iso_nnn"
+ if {[regsub {^(iso|cp|ibm|jis)[-_]} $enc {\1} encx]} {
+ set enc $encx
}
- if {$i >= 0} break
- }
- break
}
- }
- if {$i >= 0} {
- return [lindex $names $i]
- }
- return {}
+ if {[info exists encoding_lookup_table($enc)]} {
+ return $encoding_lookup_table($enc)
+ } else {
+ return {}
+ }
}
proc gitattr {path attr default} {
--
1.6.0.20.g6148bc
^ permalink raw reply related
* [PATCH 1/3] for-each-ref: utilize core.warnambiguousrefs for strict refname:short format
From: Bert Wesarg @ 2008-09-22 9:09 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, szeder, Shawn O. Pearce
core.warnambiguousrefs is used to enable strict mode for the
abbreviation.
In strict mode, the abbreviated ref will never trigger the
'warn_ambiguous_refs' warning. I.e. for these refs:
refs/heads/xyzzy
refs/tags/xyzzy
the abbreviated forms are:
heads/xyzzy
tags/xyzzy
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
On Tue, Sep 9, 2008 at 10:05, Junio C Hamano <gitster@pobox.com> wrote:
> "Bert Wesarg" <bert.wesarg@googlemail.com> writes:
>
>> Any opinions, whether we want the 'strict' mode? i.e.:
>>
>> for refs/heads/xyzzy and refs/tags/xyzzy:
>>
>> loose mode (current implementation):
>>
>> refs/heads/xyzzy => heads/xyzzy
>> refs/tags/xyzzy => xyzzy
>>
>> there would be a ambiguous warning (if enabled) if you use xyzzy as a
>> tag, but it resolves correctly to the tag.
>>
>> strict mode:
>>
>> refs/heads/xyzzy => heads/xyzzy
>> refs/tags/xyzzy => tags/xyzzy
>>
>> will always produce a non-ambiguous short forms.
>
> I have no strong opinions either way, but if we want to pick only one, I
> suspect that the loose mode would be more appropriate for bash completion
> purposes exactly because:
>
> (1) the shorter form would match the users' expectations, and;
>
> (2) if it triggers ambiguity warning to use that result that matches
> users' expectations, it is a *good thing* --- it reminds the user
> that s/he is playing with fire _if_ the user is of careful type who
> enables the ambiguity warning.
>
> Thinking about it from a different angle, it would make more sense to use
> loose mode if the user does not have ambiguity warning configured, and use
> strict mode if the warning is enabled. Then people who will get warnings
> from ambiguity will not get an ambiguous completion, and people who won't
> will get shorter but still unambiguous completion.
Cc: git@vger.kernel.org
Cc: szeder@ira.uka.de
Cc: "Shawn O. Pearce" <spearce@spearce.org>
Documentation/git-for-each-ref.txt | 2 +
builtin-for-each-ref.c | 43 ++++++++++++++++++++++-------------
2 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt
index 5061d3e..265bbf3 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -75,6 +75,8 @@ For all objects, the following names can be used:
refname::
The name of the ref (the part after $GIT_DIR/).
For a non-ambiguous short name of the ref append `:short`.
+ The option core.warnambiguousrefs is used to enable the strict mode
+ for the abbretiation.
objecttype::
The type of the object (`blob`, `tree`, `commit`, `tag`).
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 9b44092..e7b7712 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -571,7 +571,7 @@ static void gen_scanf_fmt(char *scanf_fmt, const char *rule)
/*
* Shorten the refname to an non-ambiguous form
*/
-static char *get_short_ref(struct refinfo *ref)
+static void get_short_ref(struct refinfo *ref, int strict, char **short_ref)
{
int i;
static char **scanf_fmts;
@@ -598,16 +598,16 @@ static char *get_short_ref(struct refinfo *ref)
}
}
- /* bail out if there are no rules */
- if (!nr_rules)
- return ref->refname;
-
/* buffer for scanf result, at most ref->refname must fit */
short_name = xstrdup(ref->refname);
+ *short_ref = short_name;
- /* skip first rule, it will always match */
- for (i = nr_rules - 1; i > 0 ; --i) {
- int j;
+ /* bail out if there are no rules */
+ if (!nr_rules)
+ return;
+
+ for (i = nr_rules - 1; i >= 0 ; --i) {
+ int j, rules_to_fail = i;
int short_name_len;
if (1 != sscanf(ref->refname, scanf_fmts[i], short_name))
@@ -616,13 +616,23 @@ static char *get_short_ref(struct refinfo *ref)
short_name_len = strlen(short_name);
/*
+ * in strict mode, all (except the matched one) rules
+ * must fail to resolve to a valid ref
+ */
+ if (strict)
+ rules_to_fail = nr_rules;
+ /*
* check if the short name resolves to a valid ref,
* but use only rules prior to the matched one
*/
- for (j = 0; j < i; j++) {
+ for (j = 0; j < rules_to_fail; j++) {
const char *rule = ref_rev_parse_rules[j];
unsigned char short_objectname[20];
+ /* skip matched rule */
+ if (i == j)
+ continue;
+
/*
* the short name is ambiguous, if it resolves
* (with this previous rule) to a valid ref
@@ -635,14 +645,14 @@ static char *get_short_ref(struct refinfo *ref)
/*
* short name is non-ambiguous if all previous rules
- * haven't resolved to a valid ref
+ * doesn't resolved to a valid ref
*/
- if (j == i)
- return short_name;
+ if (j == rules_to_fail)
+ return;
}
- free(short_name);
- return ref->refname;
+ /* can't abbreviate refname, return full name */
+ strcpy(short_name, ref->refname);
}
@@ -678,13 +688,14 @@ static void populate_value(struct refinfo *ref)
}
if (!prefixcmp(name, "refname")) {
const char *formatp = strchr(name, ':');
- const char *refname = ref->refname;
+ char *refname = ref->refname;
/* look for "short" refname format */
if (formatp) {
formatp++;
if (!strcmp(formatp, "short"))
- refname = get_short_ref(ref);
+ get_short_ref(ref, warn_ambiguous_refs,
+ &refname);
else
die("unknown refname format %s",
formatp);
--
1.6.0.1
^ permalink raw reply related
* [PATCH 2/3] for-each-ref: factor out get_short_ref() into refs.c:abbreviate_refname()
From: Bert Wesarg @ 2008-09-22 9:09 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, szeder, Shawn O. Pearce
In-Reply-To: <1222074591-26548-1-git-send-email-bert.wesarg@googlemail.com>
Moves the function get_short_ref() from builtin-for-each-ref.c into refs.c
as function abbreviate_refname().
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
Cc: git@vger.kernel.org
Cc: szeder@ira.uka.de
Cc: "Shawn O. Pearce" <spearce@spearce.org>
builtin-for-each-ref.c | 116 +----------------------------------------------
cache.h | 1 +
refs.c | 110 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+), 113 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index e7b7712..06fd6a2 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -546,117 +546,6 @@ static void grab_values(struct atom_value *val, int deref, struct object *obj, v
}
/*
- * generate a format suitable for scanf from a ref_rev_parse_rules
- * rule, that is replace the "%.*s" spec with a "%s" spec
- */
-static void gen_scanf_fmt(char *scanf_fmt, const char *rule)
-{
- char *spec;
-
- spec = strstr(rule, "%.*s");
- if (!spec || strstr(spec + 4, "%.*s"))
- die("invalid rule in ref_rev_parse_rules: %s", rule);
-
- /* copy all until spec */
- strncpy(scanf_fmt, rule, spec - rule);
- scanf_fmt[spec - rule] = '\0';
- /* copy new spec */
- strcat(scanf_fmt, "%s");
- /* copy remaining rule */
- strcat(scanf_fmt, spec + 4);
-
- return;
-}
-
-/*
- * Shorten the refname to an non-ambiguous form
- */
-static void get_short_ref(struct refinfo *ref, int strict, char **short_ref)
-{
- int i;
- static char **scanf_fmts;
- static int nr_rules;
- char *short_name;
-
- /* pre generate scanf formats from ref_rev_parse_rules[] */
- if (!nr_rules) {
- size_t total_len = 0;
-
- /* the rule list is NULL terminated, count them first */
- for (; ref_rev_parse_rules[nr_rules]; nr_rules++)
- /* no +1 because strlen("%s") < strlen("%.*s") */
- total_len += strlen(ref_rev_parse_rules[nr_rules]);
-
- scanf_fmts = xmalloc(nr_rules * sizeof(char *) + total_len);
-
- total_len = 0;
- for (i = 0; i < nr_rules; i++) {
- scanf_fmts[i] = (char *)&scanf_fmts[nr_rules]
- + total_len;
- gen_scanf_fmt(scanf_fmts[i], ref_rev_parse_rules[i]);
- total_len += strlen(ref_rev_parse_rules[i]);
- }
- }
-
- /* buffer for scanf result, at most ref->refname must fit */
- short_name = xstrdup(ref->refname);
- *short_ref = short_name;
-
- /* bail out if there are no rules */
- if (!nr_rules)
- return;
-
- for (i = nr_rules - 1; i >= 0 ; --i) {
- int j, rules_to_fail = i;
- int short_name_len;
-
- if (1 != sscanf(ref->refname, scanf_fmts[i], short_name))
- continue;
-
- short_name_len = strlen(short_name);
-
- /*
- * in strict mode, all (except the matched one) rules
- * must fail to resolve to a valid ref
- */
- if (strict)
- rules_to_fail = nr_rules;
- /*
- * check if the short name resolves to a valid ref,
- * but use only rules prior to the matched one
- */
- for (j = 0; j < rules_to_fail; j++) {
- const char *rule = ref_rev_parse_rules[j];
- unsigned char short_objectname[20];
-
- /* skip matched rule */
- if (i == j)
- continue;
-
- /*
- * the short name is ambiguous, if it resolves
- * (with this previous rule) to a valid ref
- * read_ref() returns 0 on success
- */
- if (!read_ref(mkpath(rule, short_name_len, short_name),
- short_objectname))
- break;
- }
-
- /*
- * short name is non-ambiguous if all previous rules
- * doesn't resolved to a valid ref
- */
- if (j == rules_to_fail)
- return;
- }
-
- /* can't abbreviate refname, return full name */
- strcpy(short_name, ref->refname);
-}
-
-
-/*
* Parse the object referred by ref, and grab needed value.
*/
static void populate_value(struct refinfo *ref)
@@ -694,8 +583,9 @@ static void populate_value(struct refinfo *ref)
if (formatp) {
formatp++;
if (!strcmp(formatp, "short"))
- get_short_ref(ref, warn_ambiguous_refs,
- &refname);
+ abbreviate_refname(ref->refname,
+ warn_ambiguous_refs,
+ &refname);
else
die("unknown refname format %s",
formatp);
diff --git a/cache.h b/cache.h
index de8c2b6..8a128a5 100644
--- a/cache.h
+++ b/cache.h
@@ -582,6 +582,7 @@ extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
extern int refname_match(const char *abbrev_name, const char *full_name, const char **rules);
extern const char *ref_rev_parse_rules[];
extern const char *ref_fetch_rules[];
+extern void abbreviate_refname(const char *refname, int strict, char **abbrev_name);
extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg);
extern int validate_headref(const char *ref);
diff --git a/refs.c b/refs.c
index b680750..f370081 100644
--- a/refs.c
+++ b/refs.c
@@ -730,6 +730,116 @@ int refname_match(const char *abbrev_name, const char *full_name, const char **r
return 0;
}
+/*
+ * generate a format suitable for scanf from a ref_rev_parse_rules rule
+ * that is replace the "%.*s" spec with a "%s" spec
+ */
+static void gen_scanf_fmt(char *scanf_fmt, const char *rule)
+{
+ char *spec;
+
+ spec = strstr(rule, "%.*s");
+ if (!spec || strstr(spec + 4, "%.*s"))
+ die("invalid rule in ref_rev_parse_rules: %s", rule);
+
+ /* copy all until spec */
+ strncpy(scanf_fmt, rule, spec - rule);
+ scanf_fmt[spec - rule] = '\0';
+ /* copy new spec */
+ strcat(scanf_fmt, "%s");
+ /* copy remaining rule */
+ strcat(scanf_fmt, spec + 4);
+}
+
+/*
+ * Abbreviate refname to an non-ambiguous form, undefined if refname is not
+ * a fully quallified refname
+ */
+void abbreviate_refname(const char *refname, int strict, char **abbrev_name)
+{
+ int i;
+ static char **scanf_fmts;
+ static int nr_rules;
+ char *abbrev;
+
+ /* pre generate scanf formats from ref_rev_parse_rules[] */
+ if (!nr_rules) {
+ size_t total_len = 0;
+
+ /* the rule list is NULL terminated, count them first */
+ for (; ref_rev_parse_rules[nr_rules]; nr_rules++)
+ /* no +1 because strlen("%s") < strlen("%.*s") */
+ total_len += strlen(ref_rev_parse_rules[nr_rules]);
+
+ scanf_fmts = xmalloc(nr_rules * sizeof(char *) + total_len);
+
+ total_len = 0;
+ for (i = 0; i < nr_rules; i++) {
+ scanf_fmts[i] = (char *)&scanf_fmts[nr_rules]
+ + total_len;
+ gen_scanf_fmt(scanf_fmts[i], ref_rev_parse_rules[i]);
+ total_len += strlen(ref_rev_parse_rules[i]);
+ }
+ }
+
+ /* buffer for scanf result, at most refname must fit */
+ abbrev = xstrdup(refname);
+ *abbrev_name = abbrev;
+
+ /* bail out if there are no rules */
+ if (!nr_rules)
+ return;
+
+ for (i = nr_rules - 1; i >= 0 ; --i) {
+ int j, rules_to_fail = i;
+ int abbrev_len;
+
+ if (1 != sscanf(refname, scanf_fmts[i], abbrev))
+ continue;
+
+ abbrev_len = strlen(abbrev);
+
+ /*
+ * in strict mode, all (except the matched one) rules
+ * must fail to resolve to a valid ref
+ */
+ if (strict)
+ rules_to_fail = nr_rules;
+
+ /*
+ * check if the short name resolves to a valid ref,
+ */
+ for (j = 0; j < rules_to_fail; j++) {
+ const char *rule = ref_rev_parse_rules[j];
+ unsigned char abbrev_objectname[20];
+
+ /* skip matched rule */
+ if (i == j)
+ continue;
+
+ /*
+ * the abbreviated name is ambiguous,
+ * if it resolves to a valid ref
+ *
+ * read_ref() returns 0 on success
+ */
+ if (!read_ref(mkpath(rule, abbrev_len, abbrev),
+ abbrev_objectname))
+ break;
+ }
+
+ /*
+ * abbrev is non-ambiguous if all rules
+ * doesn't resolved to a valid ref
+ */
+ if (j == rules_to_fail)
+ return;
+ }
+
+ /* can't abbreviate refname, return full name */
+ strcpy(abbrev, refname);
+}
+
static struct ref_lock *verify_lock(struct ref_lock *lock,
const unsigned char *old_sha1, int mustexist)
{
--
1.6.0.1
^ permalink raw reply related
* [PATCH 3/3] git abbref-ref: new porcelain for abbreviate_ref()
From: Bert Wesarg @ 2008-09-22 9:09 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, szeder, Shawn O. Pearce
In-Reply-To: <1222074591-26548-2-git-send-email-bert.wesarg@googlemail.com>
This gives direct access to the abbreviate_ref() function. The operation
mode defaults to the core.warnambiguousrefs value, like the refname:short
format, but can be explicitly changed with the --{,no}-strict option.
The bash completion script utilizes this new command.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
Junio, if this is not a porcelain, tell me.
Cc: git@vger.kernel.org
Cc: szeder@ira.uka.de
Cc: "Shawn O. Pearce" <spearce@spearce.org>
.gitignore | 1 +
Documentation/git-abbrev-ref.txt | 34 +++++++++++++++++++++++++++
Makefile | 1 +
builtin-abbrev-ref.c | 40 ++++++++++++++++++++++++++++++++
builtin.h | 1 +
contrib/completion/git-completion.bash | 16 ++++++------
git.c | 1 +
7 files changed, 86 insertions(+), 8 deletions(-)
create mode 100644 Documentation/git-abbrev-ref.txt
create mode 100644 builtin-abbrev-ref.c
diff --git a/.gitignore b/.gitignore
index bbaf9de..c2d0ce4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@ GIT-CFLAGS
GIT-GUI-VARS
GIT-VERSION-FILE
git
+git-abbrev-ref
git-add
git-add--interactive
git-am
diff --git a/Documentation/git-abbrev-ref.txt b/Documentation/git-abbrev-ref.txt
new file mode 100644
index 0000000..67f6733
--- /dev/null
+++ b/Documentation/git-abbrev-ref.txt
@@ -0,0 +1,34 @@
+git-abbrev-ref(1)
+=================
+
+NAME
+----
+git-abbrev-ref - Abbreviate a named ref
+
+SYNOPSIS
+--------
+'git abbrev-ref' [--strict] <ref>...
+
+DESCRIPTION
+-----------
+
+
+OPTIONS
+-------
+<ref>...::
+ Refnames to be abbreviated.
+
+--strict::
+ Operates in strict mode. Defaults to core.warnambiguousrefs.
+
+Author
+------
+Written by Bert Wesarg <bert.wesarg@googlemail.com>
+
+Documentation
+--------------
+Documentation by Bert Wesarg and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Makefile b/Makefile
index 3c0664a..f78e75f 100644
--- a/Makefile
+++ b/Makefile
@@ -493,6 +493,7 @@ LIB_OBJS += ws.o
LIB_OBJS += wt-status.o
LIB_OBJS += xdiff-interface.o
+BUILTIN_OBJS += builtin-abbrev-ref.o
BUILTIN_OBJS += builtin-add.o
BUILTIN_OBJS += builtin-annotate.o
BUILTIN_OBJS += builtin-apply.o
diff --git a/builtin-abbrev-ref.c b/builtin-abbrev-ref.c
new file mode 100644
index 0000000..4c4d42c
--- /dev/null
+++ b/builtin-abbrev-ref.c
@@ -0,0 +1,40 @@
+#include "builtin.h"
+#include "cache.h"
+#include "refs.h"
+#include "parse-options.h"
+
+static const char * const git_abbrev_ref_usage[] = {
+ "git abbrev-ref [options] ref...",
+ NULL
+};
+
+int cmd_abbrev_ref(int argc, const char **argv, const char *prefix)
+{
+ int i;
+ int strict = 0;
+ struct option options[] = {
+ OPT_BOOLEAN( 0 , "strict", &strict, "use strict mode"),
+ OPT_END(),
+ };
+
+ git_config(git_default_config, NULL);
+ strict = warn_ambiguous_refs;
+ argc = parse_options(argc, argv, options, git_abbrev_ref_usage, 0);
+
+ for (i = 0; i < argc; i++) {
+ unsigned char sha1[20];
+ char *ref;
+ char *abbrev_ref;
+
+ if (!dwim_ref(argv[i], strlen(argv[i]), sha1, &ref))
+ die("No such ref %s", argv[i]);
+
+ abbreviate_refname(ref, strict, &abbrev_ref);
+ puts(abbrev_ref);
+
+ free(ref);
+ free(abbrev_ref);
+ }
+
+ return 0;
+}
diff --git a/builtin.h b/builtin.h
index e67cb20..8271a4e 100644
--- a/builtin.h
+++ b/builtin.h
@@ -20,6 +20,7 @@ extern int commit_tree(const char *msg, unsigned char *tree,
struct commit_list *parents, unsigned char *ret);
extern int check_pager_config(const char *cmd);
+extern int cmd_abbrev_ref(int argc, const char **argv, const char *prefix);
extern int cmd_add(int argc, const char **argv, const char *prefix);
extern int cmd_annotate(int argc, const char **argv, const char *prefix);
extern int cmd_apply(int argc, const char **argv, const char *prefix);
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 93f0881..7f002c0 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -112,9 +112,9 @@ __git_ps1 ()
fi
if [ -n "$1" ]; then
- printf "$1" "${b##refs/heads/}$r"
+ printf "$1" "$(git abbrev-ref $b)$r"
else
- printf " (%s)" "${b##refs/heads/}$r"
+ printf " (%s)" "$(git abbrev-ref $b)$r"
fi
fi
}
@@ -162,7 +162,7 @@ __git_heads ()
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
- n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
+ n,refs/heads/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
n,*) is_hash=y; echo "$i" ;;
esac
done
@@ -180,7 +180,7 @@ __git_tags ()
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
- n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
+ n,refs/tags/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
n,*) is_hash=y; echo "$i" ;;
esac
done
@@ -199,9 +199,9 @@ __git_refs ()
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
- n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
- n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
- n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
+ n,refs/tags/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
+ n,refs/heads/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
+ n,refs/remotes/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
n,*) is_hash=y; echo "$i" ;;
esac
done
@@ -222,7 +222,7 @@ __git_refs_remotes ()
case "$is_hash,$i" in
n,refs/heads/*)
is_hash=y
- echo "$i:refs/remotes/$1/${i#refs/heads/}"
+ echo "$i:refs/remotes/$1/$(git abbrev-ref $i)"
;;
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
diff --git a/git.c b/git.c
index 905acc2..052ebb5 100644
--- a/git.c
+++ b/git.c
@@ -263,6 +263,7 @@ static void handle_internal_command(int argc, const char **argv)
{
const char *cmd = argv[0];
static struct cmd_struct commands[] = {
+ { "abbrev-ref", cmd_abbrev_ref, RUN_SETUP },
{ "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
{ "annotate", cmd_annotate, RUN_SETUP },
{ "apply", cmd_apply },
--
1.6.0.1
^ permalink raw reply related
* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Johannes Sixt @ 2008-09-22 9:18 UTC (permalink / raw)
To: Alexander Gavrilov; +Cc: git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <200809221302.52424.angavrilov@gmail.com>
Alexander Gavrilov schrieb:
> You can also try applying this patch (originally made for git-gui). It may save
> additional 0.3 sec, especially for obscure legacy encodings.
Is this about startup time? Personally, I don't care about 0.3 sec startup
time. I close my primary gitk and git-gui Windows only once a week. ;-)
-- Hannes
^ permalink raw reply
* Re: [ANNOUNCE] TopGit v0.3
From: Jan Nieuwenhuizen @ 2008-09-22 9:13 UTC (permalink / raw)
To: Petr Baudis; +Cc: martin f krafft, git
In-Reply-To: <20080921142445.GJ10360@machine.or.cz>
On zo, 2008-09-21 at 16:24 +0200, Petr Baudis wrote:
> The problem is that you can undo the merge content, but not the history
> information. So this revert can e.g. propagate even into branches which
> still *should* depend on the other branch, you get into trouble when you
> want to make your branch depend on the other one anyway, etc.
Ah, yes. I see. Does this mean that functionality for easy adding and
removing dependencies/patches from a branch can only be provided through
some sort of [unpublishable] patch based mechanism like stgit?
Possibly we'd need a kind of setup where stgit-like patch branches
can be "finalized" into topgit branches. Hmm.
Jan.
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org
^ permalink raw reply
* Re: [PATCH (GIT-GUI,GITK) 0/8] Encoding support in GUI
From: Alexander Gavrilov @ 2008-09-22 10:12 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git, Shawn O. Pearce
In-Reply-To: <18646.53492.20994.908025@cargo.ozlabs.ibm.com>
On Mon, Sep 22, 2008 at 2:55 AM, Paul Mackerras <paulus@samba.org> wrote:
> I'm happy with providing a way to say what the default encoding of
> files in the repository is, but I wonder why it is seen as a property
> of the GUI. Is it just that there is an existing "gui" section that
> is convenient to use, or does git-gui already use gui.encoding (before
> this patch series), or is there some other reason?
No particular reason, it can be easily renamed to i18n.encoding, or
something else. I only recall seeing the name 'gui.encoding' in a
discussion on this topic several months ago.
> I haven't used .gitattributes before, but I would expect that the
> .gitattributes files would be stored in the repository along with
> everything else. If that's the case, then for gitk at least there is
> the question of which version of a given .gitattributes file one
> should use when viewing the tree for a commit which isn't the
> currently checked-out commit - do you use the version from that tree,
> or the version in the working directory? We seem to be using the
> latter at present, and caching the results. Is there a philosophical
> reason to do that, other than speed? (Also it seems that we won't
> notice if the user changes .gitattributes after we've looked at it, or
> if they create one after we've looked for one and not found it.)
Core git does not provide any interface for reading attributes from
older commits, so they are loaded from the working copy. And caching
is necessary for performance when lookup involves calling an external
application at least once per 30 files. This may change if
git-check-attr is modified to support --stdin-paths.
>> There are also some bugs in handling of commit encodings in gitk,
>> but they are out of the scope of this series.
>
> I'm interested to hear what they are.
When I tested it, I noticed that:
1. It works correctly only if all commits use the encoding specified
in i18n.commitencoding
2. Even when they do, sometimes commits are loaded through cat-file,
and in this case they are processed using the locale encoding.
Alexander
^ permalink raw reply
* Re: [PATCH (GIT-GUI,GITK) 6/8] gitk: Port new encoding logic from git-gui.
From: Alexander Gavrilov @ 2008-09-22 10:18 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Shawn O. Pearce, Paul Mackerras
In-Reply-To: <48D762EC.2030009@viscovery.net>
On Mon, Sep 22, 2008 at 1:18 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Alexander Gavrilov schrieb:
>> You can also try applying this patch (originally made for git-gui). It may save
>> additional 0.3 sec, especially for obscure legacy encodings.
>
> Is this about startup time? Personally, I don't care about 0.3 sec startup
> time. I close my primary gitk and git-gui Windows only once a week. ;-)
As encoding lookups are currently cached, all this discussion is about
the first viewing.
This patch addresses the time necessary to convert an arbitrary
encoding name to a name that is known to Tcl, or determine that it is
not supported. Without the patch it is done using a linear search
through a large table of aliases. In git-gui it caused a noticeable
delay before the Encoding submenu, which lists all available
encodings, was displayed.
Alexander
^ permalink raw reply
* Re: ignoring files/directories in git
From: Boaz Harrosh @ 2008-09-22 10:41 UTC (permalink / raw)
To: Dmitry Potapov; +Cc: mwolfe38, git
In-Reply-To: <20080922085200.GI21650@dpotapov.dyndns.org>
Dmitry Potapov wrote:
> On Mon, Sep 22, 2008 at 10:37:00AM +0300, Boaz Harrosh wrote:
>> I have 1.6.0.1 I compiled here, and it has the same problem. So it is
>> a very recent fix
>
> I certainly tested 1.6.0.1 and does not have this problem, and it was
> fixed a long time ago:
>
> ===
> commit d6b8fc303b389b026f2bf9918f6f83041488989b
> Author: Junio C Hamano <gitster@pobox.com>
> Date: Thu Jan 31 01:17:48 2008 -0800
>
> gitignore(5): Allow "foo/" in ignore list to match directory "foo"
>
> A pattern "foo/" in the exclude list did not match directory
> "foo", but a pattern "foo" did. This attempts to extend the
> exclude mechanism so that it would while not matching a regular
> file or a symbolic link "foo". In order to differentiate a
> directory and non directory, this passes down the type of path
> being checked to excluded() function.
>
> A downside is that the recursive directory walk may need to run
> lstat(2) more often on systems whose "struct dirent" do not give
> the type of the entry; earlier it did not have to do so for an
> excluded path, but we now need to figure out if a path is a
> directory before deciding to exclude it. This is especially bad
> because an idea similar to the earlier CE_UPTODATE optimization
> to reduce number of lstat(2) calls would by definition not apply
> to the codepaths involved, as (1) directories will not be
> registered in the index, and (2) excluded paths will not be in
> the index anyway.
> ===
>
> The patch is included in 1.5.5.
>
> Dmitry
> --
Ok I found it. Regular subdirectories it works as you said,
but soft-link to a folder does not. Sorry for the noise i didn't
realize that in my test it was a simlink and not a full directory.
Please don't fix it if it will hurt performance, I'm happy with
current solution as it is. Just maybe a small addition to the
.gitignore documentation perhaps.
Boaz
^ permalink raw reply
* [PATCH] git-remote: do not use user input in a printf format string
From: Johannes Sixt @ 2008-09-22 11:03 UTC (permalink / raw)
To: Junio C Hamano, Johannes Schindelin; +Cc: git, Johannes Sixt
'git remote show' substituted the remote name into a string that was later
used as a printf format string. If a remote name contains a printf format
specifier like this:
$ git remote add foo%sbar .
then the command
$ git remote show foo%sbar
would print garbage (if you are lucky) or crash. This fixes it.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
builtin-remote.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/builtin-remote.c b/builtin-remote.c
index 01945a8..890a680 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -407,14 +407,15 @@ static int rm(int argc, const char **argv)
return i;
}
-static void show_list(const char *title, struct string_list *list)
+static void show_list(const char *title, struct string_list *list,
+ const char *extra_arg)
{
int i;
if (!list->nr)
return;
- printf(title, list->nr > 1 ? "es" : "");
+ printf(title, list->nr > 1 ? "es" : "", extra_arg);
printf("\n ");
for (i = 0; i < list->nr; i++)
printf("%s%s", i ? " " : "", list->items[i].string);
@@ -503,18 +504,16 @@ static int show(int argc, const char **argv)
}
if (!no_query) {
- strbuf_init(&buf, 0);
- strbuf_addf(&buf, " New remote branch%%s (next fetch "
- "will store in remotes/%s)", states.remote->name);
- show_list(buf.buf, &states.new);
- strbuf_release(&buf);
+ show_list(" New remote branch%s (next fetch "
+ "will store in remotes/%s)",
+ &states.new, states.remote->name);
show_list(" Stale tracking branch%s (use 'git remote "
- "prune')", &states.stale);
+ "prune')", &states.stale, "");
}
if (no_query)
for_each_ref(append_ref_to_tracked_list, &states);
- show_list(" Tracked remote branch%s", &states.tracked);
+ show_list(" Tracked remote branch%s", &states.tracked, "");
if (states.remote->push_refspec_nr) {
printf(" Local branch%s pushed with 'git push'\n ",
--
1.6.0.1.281.g8a3c6
^ permalink raw reply related
* Re: [PATCH] Use dashless git commands in setgitperms.perl
From: Todd Zullinger @ 2008-09-22 11:30 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jakub Narebski, git
In-Reply-To: <7v4p4b7gjr.fsf@gitster.siamese.dyndns.org>
Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
contrib/hooks/setgitperms.perl | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Junio C Hamano wrote:
> The patch is wrong on one point, and should be unnecessary.
>
> First of all, you do not understand what "." does in shell ;-)
> That is the "wrong" part.
Ugh, that was embarrassing to miss (bad enough to miss it on my own,
but worse to not notice it after Jakub questioned it).
> About the "unnecessary" part, a hook should run under an environment
> where exec-path is already added to the $PATH, so it should be able
> to find git-sh-setup just fine without your change.
>
> But I think the politically correct way would be:
>
> #!/bin/sh
> PATH=$(git --exec-path):$PATH
> SUBDIRECTORY_OK=1 . git-sh-setup
> $GIT_DIR/hooks/setgitperms.perl -r
>
> especially if we envision that somebody may run the script by
> itself, not from the hook.
Since that chunk is only in a comment explaining what to add to the
hook the user wants to run this script from, it seems like that really
is unnecessary.
I was in fact running .git/hooks/setgitperms.perl directly (to create
an initial .gitmeta file) which is why I noticed it used git-*
commands and was failing. Using "git " makes that work for me.
> The change to the perl script should not be strictly necessary
> (because this is expected to be run from a hook), but to set a
> better example, I think it is a good idea to do these s/git-/git /
> substitutions.
Sounds good. Here is a patch with just those changes.
diff --git a/contrib/hooks/setgitperms.perl b/contrib/hooks/setgitperms.perl
index dab7c8e..a577ad0 100644
--- a/contrib/hooks/setgitperms.perl
+++ b/contrib/hooks/setgitperms.perl
@@ -50,7 +50,7 @@ if ((@ARGV < 0) || !GetOptions(
)) { die $usage; }
die $usage unless ($read_mode xor $write_mode);
-my $topdir = `git-rev-parse --show-cdup` or die "\n"; chomp $topdir;
+my $topdir = `git rev-parse --show-cdup` or die "\n"; chomp $topdir;
my $gitdir = $topdir . '.git';
my $gitmeta = $topdir . '.gitmeta';
@@ -155,7 +155,7 @@ elsif ($read_mode) {
open (OUT, ">$gitmeta.tmp") or die "Could not open $gitmeta.tmp for writing: $!\n";
}
- my @files = `git-ls-files`;
+ my @files = `git ls-files`;
my %dirs;
foreach my $path (@files) {
--
1.6.0.2
--
Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Careful. We don't want to learn from this.
-- Calvin
^ 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