* [PATCH 4/6] pack-objects.c: fix some global variable abuse and memory leaks
From: Nicolas Pitre @ 2007-10-17 1:55 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1192586150-13743-4-git-send-email-nico@cam.org>
To keep things well layered, sha1close() now returns the file descriptor
when it doesn't close the file.
An ugly cast was added to the return of write_idx_file() to avoid a
warning. A proper fix will come separately.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
builtin-pack-objects.c | 29 +++++++++++++++--------------
csum-file.c | 23 ++++++++++++++---------
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index d729cb7..933c252 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -65,8 +65,6 @@ static int no_reuse_delta, no_reuse_object, keep_unreachable;
static int local;
static int incremental;
static int allow_ofs_delta;
-static const char *pack_tmp_name, *idx_tmp_name;
-static char tmpname[PATH_MAX];
static const char *base_name;
static int progress = 1;
static int window = 10;
@@ -587,12 +585,6 @@ static off_t write_one(struct sha1file *f,
return offset + size;
}
-static int open_object_dir_tmp(const char *path)
-{
- snprintf(tmpname, sizeof(tmpname), "%s/%s", get_object_directory(), path);
- return xmkstemp(tmpname);
-}
-
/* forward declaration for write_pack_file */
static int adjust_perm(const char *path, mode_t mode);
@@ -611,11 +603,16 @@ static void write_pack_file(void)
do {
unsigned char sha1[20];
+ char *pack_tmp_name = NULL;
if (pack_to_stdout) {
f = sha1fd(1, "<stdout>");
} else {
- int fd = open_object_dir_tmp("tmp_pack_XXXXXX");
+ char tmpname[PATH_MAX];
+ int fd;
+ snprintf(tmpname, sizeof(tmpname),
+ "%s/tmp_pack_XXXXXX", get_object_directory());
+ fd = xmkstemp(tmpname);
pack_tmp_name = xstrdup(tmpname);
f = sha1fd(fd, pack_tmp_name);
}
@@ -643,19 +640,21 @@ static void write_pack_file(void)
if (pack_to_stdout || nr_written == nr_remaining) {
sha1close(f, sha1, 1);
} else {
- sha1close(f, sha1, 0);
- fixup_pack_header_footer(f->fd, sha1, pack_tmp_name, nr_written);
- close(f->fd);
+ int fd = sha1close(f, NULL, 0);
+ fixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written);
+ close(fd);
}
if (!pack_to_stdout) {
mode_t mode = umask(0);
+ char *idx_tmp_name, tmpname[PATH_MAX];
umask(mode);
mode = 0444 & ~mode;
- idx_tmp_name = write_idx_file(NULL,
- (struct pack_idx_entry **) written_list, nr_written, sha1);
+ idx_tmp_name = (char *) write_idx_file(NULL,
+ (struct pack_idx_entry **) written_list,
+ nr_written, sha1);
snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
base_name, sha1_to_hex(sha1));
if (adjust_perm(pack_tmp_name, mode))
@@ -672,6 +671,8 @@ static void write_pack_file(void)
if (rename(idx_tmp_name, tmpname))
die("unable to rename temporary index file: %s",
strerror(errno));
+ free(idx_tmp_name);
+ free(pack_tmp_name);
puts(sha1_to_hex(sha1));
}
diff --git a/csum-file.c b/csum-file.c
index 9ab9971..9929991 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -31,22 +31,27 @@ static void sha1flush(struct sha1file *f, unsigned int count)
int sha1close(struct sha1file *f, unsigned char *result, int final)
{
+ int fd;
unsigned offset = f->offset;
if (offset) {
SHA1_Update(&f->ctx, f->buffer, offset);
sha1flush(f, offset);
f->offset = 0;
}
- if (!final)
- return 0; /* only want to flush (no checksum write, no close) */
- SHA1_Final(f->buffer, &f->ctx);
- if (result)
- hashcpy(result, f->buffer);
- sha1flush(f, 20);
- if (close(f->fd))
- die("%s: sha1 file error on close (%s)", f->name, strerror(errno));
+ if (final) {
+ /* write checksum and close fd */
+ SHA1_Final(f->buffer, &f->ctx);
+ if (result)
+ hashcpy(result, f->buffer);
+ sha1flush(f, 20);
+ if (close(f->fd))
+ die("%s: sha1 file error on close (%s)",
+ f->name, strerror(errno));
+ fd = 0;
+ } else
+ fd = f->fd;
free(f);
- return 0;
+ return fd;
}
int sha1write(struct sha1file *f, void *buf, unsigned int count)
--
1.5.3.4.1212.gdb015
^ permalink raw reply related
* [PATCH 3/6] pack-objects: no delta possible with only one object in the list
From: Nicolas Pitre @ 2007-10-17 1:55 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1192586150-13743-3-git-send-email-nico@cam.org>
... so don't even try in that case, and save another useless line of
progress display.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
builtin-pack-objects.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index df69abd..d729cb7 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1714,7 +1714,7 @@ static void prepare_pack(int window, int depth)
delta_list[n++] = entry;
}
- if (nr_deltas) {
+ if (nr_deltas && n > 1) {
unsigned nr_done = 0;
if (progress)
start_progress(&progress_state, "Deltifying objects",
--
1.5.3.4.1212.gdb015
^ permalink raw reply related
* [PATCH 5/6] fix const issues with some functions
From: Nicolas Pitre @ 2007-10-17 1:55 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1192586150-13743-5-git-send-email-nico@cam.org>
Two functions, namely write_idx_file() and open_pack_file(), currently
return a const pointer. However that pointer is either a copy of the
first argument, or set to a malloc'd buffer when that first argument
is null. In the later case it is wrong to qualify that pointer as const
since ownership of the buffer is transferred to the caller to dispose of,
and obviously the free() function is not meant to be passed const
pointers.
Making the return pointer not const causes a warning when the first
argument is returned since that argument is also marked const.
The correct thing to do is therefore to remove the const qualifiers,
avoiding the need for ugly casts only to silence some warnings.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
builtin-pack-objects.c | 2 +-
index-pack.c | 8 ++++----
pack-write.c | 3 ++-
pack.h | 2 +-
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 933c252..15d3750 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -652,7 +652,7 @@ static void write_pack_file(void)
umask(mode);
mode = 0444 & ~mode;
- idx_tmp_name = (char *) write_idx_file(NULL,
+ idx_tmp_name = write_idx_file(NULL,
(struct pack_idx_entry **) written_list,
nr_written, sha1);
snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
diff --git a/index-pack.c b/index-pack.c
index c784dec..60173d5 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -106,7 +106,7 @@ static void use(int bytes)
consumed_bytes += bytes;
}
-static const char *open_pack_file(const char *pack_name)
+static char *open_pack_file(char *pack_name)
{
if (from_stdin) {
input_fd = 0;
@@ -686,15 +686,15 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
int main(int argc, char **argv)
{
int i, fix_thin_pack = 0;
- const char *curr_pack, *pack_name = NULL;
- const char *curr_index, *index_name = NULL;
+ char *curr_pack, *pack_name = NULL;
+ char *curr_index, *index_name = NULL;
const char *keep_name = NULL, *keep_msg = NULL;
char *index_name_buf = NULL, *keep_name_buf = NULL;
struct pack_idx_entry **idx_objects;
unsigned char sha1[20];
for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
+ char *arg = argv[i];
if (*arg == '-') {
if (!strcmp(arg, "--stdin")) {
diff --git a/pack-write.c b/pack-write.c
index 979bdff..665e2b2 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -17,7 +17,8 @@ static int sha1_compare(const void *_a, const void *_b)
* the SHA1 hash of sorted object names. The objects array passed in
* will be sorted by SHA1 on exit.
*/
-const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1)
+char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
+ int nr_objects, unsigned char *sha1)
{
struct sha1file *f;
struct pack_idx_entry **sorted_by_sha, **list, **last;
diff --git a/pack.h b/pack.h
index b57ba2d..b31b376 100644
--- a/pack.h
+++ b/pack.h
@@ -55,7 +55,7 @@ struct pack_idx_entry {
off_t offset;
};
-extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
+extern char *write_idx_file(char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
extern int verify_pack(struct packed_git *, int);
extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t);
--
1.5.3.4.1212.gdb015
^ permalink raw reply related
* [PATCH 6/6] fix for more minor memory leaks
From: Nicolas Pitre @ 2007-10-17 1:55 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1192586150-13743-6-git-send-email-nico@cam.org>
Now that some pointers have lost their const attribute, we can free their
associated memory when done with them. This is more a correctness issue
about the rule for freeing those pointers which isn't completely trivial
more than the leak itself which didn't matter as the program is
exiting anyway.
Signed-off-by: Nicolas Pitre <nico@cam.org>
---
index-pack.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index 60173d5..2f149a4 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -815,6 +815,10 @@ int main(int argc, char **argv)
free(objects);
free(index_name_buf);
free(keep_name_buf);
+ if (pack_name == NULL)
+ free(curr_pack);
+ if (index_name == NULL)
+ free(curr_index);
return 0;
}
--
1.5.3.4.1212.gdb015
^ permalink raw reply related
* Re: [PATCH 1/6] more compact progress display
From: Shawn O. Pearce @ 2007-10-17 2:11 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: git
In-Reply-To: <1192586150-13743-2-git-send-email-nico@cam.org>
Nicolas Pitre <nico@cam.org> wrote:
> Each progress can be on a single line instead of two.
Nice. Of course that screws with git-gui and now I have to
match two regexs and not one. But whatever.
> +++ b/progress.c
> @@ -35,10 +35,11 @@ static void clear_progress_signal(void)
> progress_update = 0;
> }
>
> -int display_progress(struct progress *progress, unsigned n)
> +static int display(struct progress *progress, unsigned n, int done)
> {
> + char *eol;
> +
> if (progress->delay) {
> - char buf[80];
> if (!progress_update || --progress->delay)
> return 0;
> if (progress->total) {
> @@ -51,60 +52,56 @@ int display_progress(struct progress *progress, unsigned n)
> return 0;
> }
> }
> - if (snprintf(buf, sizeof(buf),
> - progress->delayed_title, progress->total))
> - fprintf(stderr, "%s\n", buf);
> }
> +
> + progress->last_value = n;
Hmm. n is unsigned and last_value is signed. Uh? I know you are
using the special value -1 to mean we've never output anything for
this progress meter but mixing signed and unsigned always gives me
the willies.
--
Shawn.
^ permalink raw reply
* Deltifying? (was [PATCH 3/6] pack-objects: no delta possible...)
From: Shawn O. Pearce @ 2007-10-17 2:15 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: git
In-Reply-To: <1192586150-13743-4-git-send-email-nico@cam.org>
Nicolas Pitre <nico@cam.org> wrote:
> start_progress(&progress_state, "Deltifying objects",
Totally unrelated to this patch but yesterday a coworker called the
Grammar Police on me because Git said "Deltifying objects" in their
console window during a fetch or push operation. I told them it was
perfectly valid, they disagreed. I got free coffee out of the deal.
But still, it bothers some users that we use perhaps less than
commonly accepted English in an important tool's output. Seeing it
in your context just reminded me of that discussion yesterday.
--
Shawn.
^ permalink raw reply
* [PATCH 1/2] fix filter-branch documentation
From: Johannes Schindelin @ 2007-10-17 2:22 UTC (permalink / raw)
To: Bill Lear; +Cc: git, spearce, gitster
In-Reply-To: <18197.24051.863751.436705@lisa.zopyra.com>
The man page for filter-branch still talked about writing the result
to the branch "newbranch". This is hopefully the last place where the
old behaviour was described.
Noticed by Bill Lear.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Documentation/git-filter-branch.txt | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index c878ed3..ba9b4fb 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -180,8 +180,7 @@ A significantly faster version:
git filter-branch --index-filter 'git update-index --remove filename' HEAD
--------------------------------------------------------------------------
-Now, you will get the rewritten history saved in the branch 'newbranch'
-(your current branch is left untouched).
+Now, you will get the rewritten history saved in HEAD.
To set a commit (which typically is at the tip of another
history) to be the parent of the current initial commit, in
--
1.5.3.4.1223.ga973c
^ permalink raw reply related
* [PATCH 2/2] filter-branch: update current branch when rewritten
From: Johannes Schindelin @ 2007-10-17 2:23 UTC (permalink / raw)
To: Bill Lear; +Cc: git, spearce, gitster
In-Reply-To: <Pine.LNX.4.64.0710170322000.25221@racer.site>
Earlier, "git filter-branch --<options> HEAD" would not update the
working tree after rewriting the branch. This commit fixes it.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Bill, I hope this clarifies some things for you, too...
git-filter-branch.sh | 15 +++++++++++++++
t/t7003-filter-branch.sh | 4 +++-
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index a12f6c2..ffcc408 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -94,6 +94,10 @@ USAGE="[--env-filter <command>] [--tree-filter <command>] \
. git-sh-setup
+git diff-files --quiet &&
+ git diff-index --cached --quiet HEAD ||
+ die "Cannot rewrite branch(es) with a dirty working directory."
+
tempdir=.git-rewrite
filter_env=
filter_tree=
@@ -196,6 +200,9 @@ do
esac
done < "$tempdir"/backup-refs
+ORIG_GIT_DIR="$GIT_DIR"
+ORIG_GIT_WORK_TREE="$GIT_WORK_TREE"
+ORIG_GIT_INDEX_FILE="$GIT_INDEX_FILE"
export GIT_DIR GIT_WORK_TREE=.
# These refs should be updated if their heads were rewritten
@@ -413,4 +420,12 @@ echo
test $count -gt 0 && echo "These refs were rewritten:"
git show-ref | grep ^"$orig_namespace"
+unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
+test -z "$ORIG_GIT_DIR" || GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
+test -z "$ORIG_GIT_WORK_TREE" || GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
+ export GIT_WORK_TREE
+test -z "$ORIG_GIT_INDEX_FILE" || GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
+ export GIT_INDEX_FILE
+git read-tree -u -m HEAD
+
exit $ret
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index e935b20..2089351 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -41,7 +41,9 @@ test_expect_success 'rewrite, renaming a specific file' '
'
test_expect_success 'test that the file was renamed' '
- test d = $(git show HEAD:doh)
+ test d = $(git show HEAD:doh) &&
+ test -f doh &&
+ test d = $(cat doh)
'
git tag oldD HEAD~4
--
1.5.3.4.1223.ga973c
^ permalink raw reply related
* Re: [PATCH 1/6] more compact progress display
From: Nicolas Pitre @ 2007-10-17 2:24 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20071017021137.GO13801@spearce.org>
On Tue, 16 Oct 2007, Shawn O. Pearce wrote:
> Hmm. n is unsigned and last_value is signed. Uh? I know you are
> using the special value -1 to mean we've never output anything for
> this progress meter but mixing signed and unsigned always gives me
> the willies.
Really? ;-)
Nicolas
^ permalink raw reply
* Re: [PATCH 2/3] git-cvsexportcommit.perl tmpdir removed
From: Shawn O. Pearce @ 2007-10-17 2:25 UTC (permalink / raw)
To: Michael Witten; +Cc: git
In-Reply-To: <1192522094-4988-2-git-send-email-mfwitten@mit.edu>
Michael Witten <mfwitten@mit.edu> wrote:
> Signed-off-by: Michael Witten <mfwitten@mit.edu>
> ---
> This is perhaps a duplicate of another patch sent in,
> but it applies to the tabified version.
Yea, I don't know if you know this but I do already have this in my
master branch. Same change but it came from Johannes Schindelin.
I just happened to come across his patch first in my inbox last
night when I was processing through what I could.
--
Shawn.
^ permalink raw reply
* Re: Deltifying? (was [PATCH 3/6] pack-objects: no delta possible...)
From: Nicolas Pitre @ 2007-10-17 2:28 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20071017021555.GP13801@spearce.org>
On Tue, 16 Oct 2007, Shawn O. Pearce wrote:
> Nicolas Pitre <nico@cam.org> wrote:
> > start_progress(&progress_state, "Deltifying objects",
>
> Totally unrelated to this patch but yesterday a coworker called the
> Grammar Police on me because Git said "Deltifying objects" in their
> console window during a fetch or push operation. I told them it was
> perfectly valid, they disagreed. I got free coffee out of the deal.
Whatever is proper English I don't mind, as long as it is short, like a
single word to describe the action + "objects".
> But still, it bothers some users that we use perhaps less than
> commonly accepted English in an important tool's output. Seeing it
> in your context just reminded me of that discussion yesterday.
With Git's growing user base, this is becoming more and more common
though. ;-)
Nicolas
^ permalink raw reply
* Re: [PATCH] gitweb: speed up project listing by limiting find depth
From: Shawn O. Pearce @ 2007-10-17 2:40 UTC (permalink / raw)
To: Luke Lu; +Cc: git, pasky
In-Reply-To: <1192583606-14893-1-git-send-email-git@vicaya.com>
Luke Lu <git@vicaya.com> wrote:
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 3064298..d62357f 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1509,16 +1513,23 @@ sub git_get_projects_list {
...
> + # don't traverse too deep (Find is super slow on os x)
> + if (tr!/!! - $pfxdepth > $project_maxdepth) {
> + $File::Find::prune = 1;
> + return;
> + }
>
> my $subdir = substr($File::Find::name, $pfxlen + 1);
Your patch appears to be causing some errors in the test suite
in t/t9500-gitweb-standalone-no-errors.sh. Perl is whining about
$subdir not getting initialized above due to the substr being off
the string. I've got too many other topics tonight to figure out
why yours is failing, can you please run the test and resubmit when
you've resolved the error?
--
Shawn.
^ permalink raw reply
* RE: Is there any plan to support partial checkout or submouduleimprovement?
From: franky @ 2007-10-17 2:54 UTC (permalink / raw)
To: 'Jan Hudec'; +Cc: git
In-Reply-To: <20071016213359.GJ26127@efreet.light.src>
franky
> -----Original Message-----
> From: Jan Hudec [mailto:bulb@ucw.cz]
> Sent: Wednesday, October 17, 2007 5:34 AM
> To: franky
> Cc: 'Johannes Schindelin'; 'Lars Hjemli'; git@vger.kernel.org
> Subject: Re: Is there any plan to support partial checkout or
> submouduleimprovement?
>
> On Tue, Oct 16, 2007 at 19:53:08 +0800, franky wrote:
> > > You are talking as if your partial checkout was a project in its own
> > > right. Then make it so. Do not use a partial checkout, but make that
a
> > > submodule.
> >
> > As I said in the first email, the submodule way suffers from the
multiple
> > commit problem: src and bin as two submodules of project, three commits
(for
> > the 3 dirs separately) are needed when src directory changes and
compiled
> > binaries being put in bin directory. It's annoying to have to give 3
commit
> > logs.
>
> Thinking about it, it's only two commits -- src can be a submodule, but
bin
> a normal directory (you can choose not to check out subprojects during
> repository checkout).
> Now I would actually say that commiting bin independently is better.
> It allows you to commit sources more often (eg. if you are doing series of
> small fixes) and more flexibility for branching (you don't want to merge
> binaries).
>
Thanks for the advice. It's a good idea.
> --
> Jan 'Bulb' Hudec
<bulb@ucw.cz>
^ permalink raw reply
* Re: On Tabs and Spaces
From: Michael Witten @ 2007-10-17 3:08 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds
In-Reply-To: <alpine.LFD.0.999.0710161722320.26902@woody.linux-foundation.org>
On 16 Oct 2007, at 8:45:51 PM, Linus Torvalds wrote:
> And is it really so unreasonable to just say "8-character tabs are the
> gold standard"?
It's unreasonable not to list that anywhere.
mfwitten
^ permalink raw reply
* Re: What's cooking in git/spearce.git (topics)
From: Shawn O. Pearce @ 2007-10-17 3:20 UTC (permalink / raw)
To: Theodore Tso; +Cc: Johannes Schindelin, git
In-Reply-To: <20071016195744.GB32132@closure.lan>
Theodore Tso <tytso@mit.edu> wrote:
> I've recently started trying to use some of the scripts in "todo" to
> send similar "What's cooking" messages, and started wondering if they
> were what Junio actually used in production to send his notes. For
> example, the scripts don't work particularly well if the refs have
> been packed. So I had to make changes such as these so they would
> work for me.
I think Junio just makes sure he doesn't pack his refs. :-)
> diff --git a/PU b/PU
> index 4b4be2b..4643a42 100755
> --- a/PU
> +++ b/PU
> @@ -26,8 +26,8 @@ case "$#" in
> 0)
> # interactive ;-)
> shift
> - HH=`cd .git/refs/heads && find -type f |
> - sed -e 's/^\.\///' \
> + HH=`git-show-ref --heads | awk '{print $2}' |\
Perhaps `git for-each-ref --format='%(refname)' refs/heads` is the
better change here as then you can avoid the pipe into awk. We still
need the sed to strip the refs/heads/ off the results though.
> + sed -e 's;refs/heads/;;' \
> -e '/^naster$/d' -e '/^master$/d' -e '/^maint$/d' -e '/^pu$/d'`
> while test "$HH"
> do
I'm actually applying it with the show-ref variant and will wind up
pushing it into my tree later tonight. Because I do pack my refs.
--
Shawn.
^ permalink raw reply
* Re: On Tabs and Spaces
From: Linus Torvalds @ 2007-10-17 3:29 UTC (permalink / raw)
To: Michael Witten; +Cc: git
In-Reply-To: <B01BBB60-6231-4AF6-9A64-10374464E442@mit.edu>
On Tue, 16 Oct 2007, Michael Witten wrote:
>
> On 16 Oct 2007, at 8:45:51 PM, Linus Torvalds wrote:
>
> > And is it really so unreasonable to just say "8-character tabs are the
> > gold standard"?
>
> It's unreasonable not to list that anywhere.
Heh.
I was sure we had a "CodingStyle", but it turns out that no, we don't, and
yes, the 8-tab assumption is implicit in (a) the kernel rules (which git
started out following for obvious reasons, and which *does* have
documentation making this very explicit indeed) and (b) those few places
where you can actually see it in the result.
So maybe it should be made explicit. You can see the effect right now by
doing
git grep -1 ' ' *.c
(again, that regex is a "tab+space", although it's not obvious) and then
looking for places where we line up things in ways that simply wouldn't
have worked if it wasn't a 8-wide tab, ie things like
...
check_all_attr = xrealloc(check_all_attr,
sizeof(*check_all_attr) * attr_nr);
..
read_tree_recursive(args->tree, args->base, plen, 0,
args->pathspec, write_zip_entry);
..
where the arguments wouldn't line up for anything but 8-char-wide tabs.
(But the code is certainly *readable* with other tab sizes, so it's not
like this makes it impossible to work if somebody has a 4-space tab, it
just means that such people can get odd effects - but they may not even
realize that others see things line up!)
Linus
^ permalink raw reply
* Re: On Tabs and Spaces
From: David @ 2007-10-17 3:41 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20071016230952.GA18099@machine.or.cz>
On 10/16/07, Petr Baudis <pasky@suse.cz> wrote:
> On Tue, Oct 16, 2007 at 07:40:26PM +0200, Sam Ravnborg wrote:
> > Tabs should be used for indent and not general alignment.
> >
> > Consider:
> > <tab>if (some long condition that
> > <tab>....&& spans two lines) {
> > <tab><tab>my_private_printf("bla bla bla"
> > <tab><tab>.................."more bla bla\n");
> > <tab><tab>}
> >
> > This will look good and align "more bla bla\n" as
> > intended no matter your tab setting.
> > But replacing the 8 spaces with a tab will
> > cause it to look bad.
>
> I'd so much love to have this and sometimes do this even manually, but
> does anyone have an idea how to make vim do this for me? I never got
> around to investigate this in depth or possibly make a patch...
>
> --
> Petr "Pasky" Baudis
> Early to rise and early to bed makes a male healthy and wealthy and dead.
> -- James Thurber
Hello
I use both vim and emacs so I must be weird.
Anyways, here's some useful vim settings that I've come across:
set tabstop=8
set softtabstop=8
set shiftwidth=8
set noexpandtab
set list
set listchars=<tab>:.\
The last two are extremely useful, especially if you're hacking on
python. That's
listchars=(less-than)tab(greater-than)(colon)(dot)(backslash)(space)
(don't forget the space!).
That makes vim display tabs with a "." indicator, so you have a very
clear view of when tabs are in use. This has helped me countless
times.
You can use any character in there instead of dot. I actually use an
extended ascii character since it looks nicer but I didn't want to
risk email mangling it.
--
David
^ permalink raw reply
* [PATCH] gitweb: speed up project listing on large work trees by limiting find depth
From: Luke Lu @ 2007-10-17 3:45 UTC (permalink / raw)
To: git; +Cc: pasky, spearce, Luke Lu
Resubmitting patch after passing gitweb regression tests.
Signed-off-by: Luke Lu <git@vicaya.com>
---
Makefile | 2 ++
gitweb/gitweb.perl | 10 ++++++++++
t/t9500-gitweb-standalone-no-errors.sh | 1 +
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index 8db4dbe..3e9938e 100644
--- a/Makefile
+++ b/Makefile
@@ -165,6 +165,7 @@ GITWEB_CONFIG = gitweb_config.perl
GITWEB_HOME_LINK_STR = projects
GITWEB_SITENAME =
GITWEB_PROJECTROOT = /pub/git
+GITWEB_PROJECT_MAXDEPTH = 2007
GITWEB_EXPORT_OK =
GITWEB_STRICT_EXPORT =
GITWEB_BASE_URL =
@@ -831,6 +832,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
-e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
-e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
+ -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
-e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
-e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
-e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3064298..48e21da 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -35,6 +35,10 @@ our $GIT = "++GIT_BINDIR++/git";
#our $projectroot = "/pub/scm";
our $projectroot = "++GITWEB_PROJECTROOT++";
+# fs traversing limit for getting project list
+# the number is relative to the projectroot
+our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
+
# target of the home link on top of all pages
our $home_link = $my_uri || "/";
@@ -1509,6 +1513,7 @@ sub git_get_projects_list {
# remove the trailing "/"
$dir =~ s!/+$!!;
my $pfxlen = length("$dir");
+ my $pfxdepth = ($dir =~ tr!/!!);
File::Find::find({
follow_fast => 1, # follow symbolic links
@@ -1519,6 +1524,11 @@ sub git_get_projects_list {
return if (m!^[/.]$!);
# only directories can be git repositories
return unless (-d $_);
+ # don't traverse too deep (Find is super slow on os x)
+ if (($File::Find::name =~ tr!/!!) - $pfxdepth > $project_maxdepth) {
+ $File::Find::prune = 1;
+ return;
+ }
my $subdir = substr($File::Find::name, $pfxlen + 1);
# we check related file in $projectroot
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 642b836..f7bad5b 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -18,6 +18,7 @@ gitweb_init () {
our \$version = "current";
our \$GIT = "git";
our \$projectroot = "$(pwd)";
+our \$project_maxdepth = 8;
our \$home_link_str = "projects";
our \$site_name = "[localhost]";
our \$site_header = "";
--
1.5.3.4
^ permalink raw reply related
* Re: [PATCH] gitweb: speed up project listing on large work trees by limiting find depth
From: Shawn O. Pearce @ 2007-10-17 4:00 UTC (permalink / raw)
To: Luke Lu; +Cc: git, pasky
In-Reply-To: <1192592725-28143-1-git-send-email-git@vicaya.com>
Luke Lu <git@vicaya.com> wrote:
> Resubmitting patch after passing gitweb regression tests.
...
> @@ -1519,6 +1524,11 @@ sub git_get_projects_list {
> return if (m!^[/.]$!);
> # only directories can be git repositories
> return unless (-d $_);
> + # don't traverse too deep (Find is super slow on os x)
> + if (($File::Find::name =~ tr!/!!) - $pfxdepth > $project_maxdepth) {
> + $File::Find::prune = 1;
> + return;
> + }
Thanks. I'm squashing this into your patch. I'm not sure what
the impact is of altering $File::Find::name in the middle of the
find algorithm and I'm not sure we want to figure that out later.
We found out the hard way today that altering a non-local'd $_
in the function is what was causing the breakage.
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 48e21da..9f47c3f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1525,7 +1525,8 @@ sub git_get_projects_list {
# only directories can be git repositories
return unless (-d $_);
# don't traverse too deep (Find is super slow on os x)
- if (($File::Find::name =~ tr!/!!) - $pfxdepth > $project_maxdepth) {
+ local $_ = $File::Find::name;
+ if (tr!/!! - $pfxdepth > $project_maxdepth) {
$File::Find::prune = 1;
return;
}
--
Shawn.
^ permalink raw reply related
* Re: [PATCH] gitweb: speed up project listing on large work trees by limiting find depth
From: Luke Lu @ 2007-10-17 4:19 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, pasky
In-Reply-To: <20071017040028.GT13801@spearce.org>
On Oct 16, 2007, at 9:00 PM, Shawn O. Pearce wrote:
> Luke Lu <git@vicaya.com> wrote:
>> Resubmitting patch after passing gitweb regression tests.
> ...
>> @@ -1519,6 +1524,11 @@ sub git_get_projects_list {
>> return if (m!^[/.]$!);
>> # only directories can be git repositories
>> return unless (-d $_);
>> + # don't traverse too deep (Find is super slow on os x)
>> + if (($File::Find::name =~ tr!/!!) - $pfxdepth >
>> $project_maxdepth) {
>> + $File::Find::prune = 1;
>> + return;
>> + }
>
> Thanks. I'm squashing this into your patch. I'm not sure what
> the impact is of altering $File::Find::name in the middle of the
> find algorithm and I'm not sure we want to figure that out later.
> We found out the hard way today that altering a non-local'd $_
> in the function is what was causing the breakage.
This is generally a good advice. But tr!/!! doesn't alter the string
at all (OK, replicates it), unless you use the /d option. tr/stuff//
is an idiom to count stuff. Check perldoc perlop for details. I don't
think it's necessary.
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 48e21da..9f47c3f 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1525,7 +1525,8 @@ sub git_get_projects_list {
> # only directories can be git repositories
> return unless (-d $_);
> # don't traverse too deep (Find is super slow on os x)
> - if (($File::Find::name =~ tr!/!!) - $pfxdepth >
> $project_maxdepth) {
> + local $_ = $File::Find::name;
> + if (tr!/!! - $pfxdepth > $project_maxdepth) {
> $File::Find::prune = 1;
> return;
> }
> --
> Shawn.
^ permalink raw reply
* Re: [PATCH] gitweb: speed up project listing on large work trees by limiting find depth
From: Shawn O. Pearce @ 2007-10-17 4:27 UTC (permalink / raw)
To: Luke Lu; +Cc: git, pasky
In-Reply-To: <6B74E96C-37ED-4D6A-8A98-C90B61EFA181@vicaya.com>
Luke Lu <git@vicaya.com> wrote:
> On Oct 16, 2007, at 9:00 PM, Shawn O. Pearce wrote:
> >
> >Thanks. I'm squashing this into your patch. I'm not sure what
> >the impact is of altering $File::Find::name in the middle of the
> >find algorithm and I'm not sure we want to figure that out later.
> >We found out the hard way today that altering a non-local'd $_
> >in the function is what was causing the breakage.
>
> This is generally a good advice. But tr!/!! doesn't alter the string
> at all (OK, replicates it), unless you use the /d option. tr/stuff//
> is an idiom to count stuff. Check perldoc perlop for details. I don't
> think it's necessary.
Oh. Yea, I see what you mean now. So the bug was really that you
were matching on $_ not $File::Find::name. But according to perldoc
File::Find $_ and $File::Find::name are the same when no_chdir =>
1 which your patch also sets. So I'm really not seeing how the
updated version fixes the bug.
> >diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> >index 48e21da..9f47c3f 100755
> >--- a/gitweb/gitweb.perl
> >+++ b/gitweb/gitweb.perl
> >@@ -1525,7 +1525,8 @@ sub git_get_projects_list {
> > # only directories can be git repositories
> > return unless (-d $_);
> > # don't traverse too deep (Find is super
> > slow on os x)
> >- if (($File::Find::name =~ tr!/!!) -
> >$pfxdepth > $project_maxdepth) {
> >+ local $_ = $File::Find::name;
> >+ if (tr!/!! - $pfxdepth > $project_maxdepth) {
> > $File::Find::prune = 1;
> > return;
> > }
--
Shawn.
^ permalink raw reply
* Re: [PATCH 07/25] parse-options: make some arguments optional, add callbacks.
From: Shawn O. Pearce @ 2007-10-17 4:44 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: René Scharfe, git, Nicolas Pitre
In-Reply-To: <20071016165045.GB13946@artemis.corp>
Pierre Habouzit <madcoder@debian.org> wrote:
> On Tue, Oct 16, 2007 at 04:38:36PM +0000, René Scharfe wrote:
> > Pierre Habouzit schrieb:
> > > This bit is to allow to aggregate options with arguments together when
> > > the argument is numeric.
> > >
> > > +#if 0
> > > + /* can be used to understand -A1B1 like -A1 -B1 */
> > > + if (flag & OPT_SHORT && opt->opt && isdigit(*opt->opt)) {
> > > + *(int *)opt->value = strtol(opt->opt, (char **)&opt->opt, 10);
> > > + return 0;
> > > + }
> > > +#endif
> >
> > I don't like it, it complicates number options with unit suffixes (e.g.
> > --windows-memory of git-pack-objects).
...
> This is a very strong argument _against_ this chunk IMO.
Since everyone (including myself) is apparently strongly against this
hunk I removed it when I cherry-picked this series from Pierre into
my tree. The series will be in my pu tonight, but minus this hunk.
--
Shawn.
^ permalink raw reply
* Re: How to Import a bitkeeper repo into git - Had a few questions on Qgit; I like the GUI.
From: Pete/Piet Delaney @ 2007-10-17 5:02 UTC (permalink / raw)
To: Marco Costalba
Cc: Linus Torvalds, VMiklos, free cycle, git, piet.delaney,
Piet Delaney
In-Reply-To: <e5bfff550710152156t33ba10dam6171e3210c18d3ac@mail.gmail.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Marco Costalba wrote:
Hi Marco:
I've gone back and tried my old Qgit 1.5.3 and it was
much closer in functionality to Bitkeeper.
> On 10/16/07, Pete/Piet Delaney <pete@bluelane.com> wrote:
>> I just download 'meld', looks interesting, I didn't know about it or
>> 'kompare'. Linking either one into gitk would be a pleasant graphical
>> 'bling'.
>>
>
> In case you are interested a git GUI viewer called qgit can spawn
> 'Kompare' , 'Meld' or any other diff tool that support 'two files'
> command line interface:
>
> $my_preferred_diff_tool file1.txt file2.txt
>
> And they will show what you are looking for. The input files are
> prepared by qgit that also handles the housekeeping at the end.
While I'm looking at the diffs for a file if I pull down External Diff
it launches 'kcompare' but for a file with a large change it seems
to be running extremely slow. We have a file with 13,000 files in it
and I have two changes in the file, each is an addition and deletion
of about 100 lines in one contiguous block. If I click between them
it's fine but since the 100 lines is more than one page I try to
scroll thru the diff. At this point of time 'kompare' seems to be
using 95% of the CPU time and it takes about 10 seconds for it to
scroll. It scrolls fine in the qgit diff window. It;s not a problem
for small files. Know of what can me done so that 'kcompare' works
fast on large files; something like pointing it's tmp files to a
not NFS partition.
Another problem I've noticed is that sometime while running git
it seems to spend a large amount of time switching from one
change-set to the next; seems to be due to all of the tagged
files.
> Another feature you asked, i.e. CTRL + right click to select a
> revision (different from the parent) to diff against the current one
> is also already implemented.
It seems that while I'm in "Rev List" mode I can select the the
two versions to compare a selected file with View->External diff...
Now, if I pull down "View File" or go to the file context were
you see the change-set for a file then I can't get the CTRL + right
click to allow me to diff two revisions of the file.
While messing around in this area of trying to diff two revision
of the file from the file context I got:
- ------------------------------------------------------------------
/nethome/piet/src/blux$ qgit
Saving cache. Please wait...
Compressing data...
Done.
Saving cache. Please wait...
Compressing data...
Done.
ASSERT in getAncestor: empty file from
e86306878efb575be80d070ac3dec49f8d358cd1
ASSERT in lookupAnnotation: no annotation for cli/quagga-0.96/lib/bluelane.c
ASSERT in remove: 8 is not the first in list
Thrown exception 'Canceling annotation'
Exception 'Canceling annotation' not handled in init...re-throw
terminate called after throwing an instance of 'i'
Aborted
/nethome/piet/src/blux$
- ------------------------------------------------------------------
MY guess is that I should install a newer version of qgit,
I'm using 1.5.3.
How difficult is it to upgrade to the Qt4. Can I just
install it to /usr/local and not interfere with Qt3?
Last I recall messing with installing ethereal from src
I needed a graphics lib and as I recall installing it in
/usr/local/ confused some build crap. It would be interesting
to try out your new qgit-2.0.
>
> And of course the two above features can be integrated: you select two
> random revisions and then call the external diff viewer to check at
> the differences in the way you prefer.
Right, but how do I do this from the file context?
>
> It is possible to download qgit from
>
> http://sourceforge.net/project/showfiles.php?group_id=139897
>
>
> Two versions:
>
> qgit-1.5.7 is Qt3 based
>
> qgit-2.0 is Qt4 based (works also under Windows)
Picked up both, I'll start with qgit-1.5.7.
Installing qt4 might not be so easy; looking at:
http://packages.qa.debian.org/q/qt4-x11.html
it seems to be pretty big. The date on 1.5.7 was very
close to 2.0 so I thought they might be very close in
functionality and you maintaining the same code for
both the common Qt3 and the new Qt4 to make it easy
for users to install.
Regards,
Piet
>
>
>
> regards
> Marco
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHFZd4JICwm/rv3hoRAgMVAJ0d49Sbbuppt8o5F1U7tbkaQjSQzwCfV0nn
mnFXyUWIKGhoxz7pqulJeVk=
=Jq+Y
-----END PGP SIGNATURE-----
^ permalink raw reply
* Re: How to Import a bitkeeper repo into git
From: Pete/Piet Delaney @ 2007-10-17 5:22 UTC (permalink / raw)
To: Marco Costalba; +Cc: Linus Torvalds, VMiklos, free cycle, git
In-Reply-To: <e5bfff550710160211g5dbfa7fai95386b173edc45c3@mail.gmail.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Marco Costalba wrote:
> On 10/16/07, Pete/Piet Delaney <pete@bluelane.com> wrote:
>> It's not quite a intuitive/familiar as with bitkeeper. I suspect I just
>> need some practice. I selected a huge list if files that we use to
>> filter the release with and double clicked on the file I thought showing
>> to focus on that file. The I pulled down External Diff and it took for
>> ever; like it's confused.
>>
>
> You shoudl select only _one_ additional revision.
>
> The currenlty selected revision is the base + select another one
> (only) with CTRL + *RIGHT* click (the file list change background
> color) , then call external diff tool.
>
>> Often we/I want to see the rev history for a particular file.
>> How would you do that with Qgit?
>>
>
> Select the file from the file list (right bottom pane) or from the
> tree view (use key 't' to toggle treev view) double click on it or use
> context menu (right click on the file name) and that's all.
't' worked fine but still can see how to diff do of the list of
changes for a file. Viewing diffs of files based on change sets
worked fine but I think with BitKeeper I found it helpful to be
able to do a full 'kompare' type diff the file only; often I'm
not interested in which change set it went into.
Something for a future version or am I lucky and you have
it covered already?
>
>> Can I see just the revs for a particular file?
>>
>
> See above.
>
>
> I know I'm going to tell you a very _unpopular_ thing, but, in case
> you have 5 minutes of spare time (yes, it doesn't take longer), open
> qgit then please press a nice key called 'F1', a nice handbook will
> appear...
Good Idea, thought it's brought up a few questions:
1. When I do the <control-minis> to Decrease the font size
I can't undo it with the <control-plus>. Also <control-plus>
doesn't seem to do anything.
2. When displaying the "Lane info" why can't I see the
branch names?
>
> I really suggest to look at it. To keep UI 'clean' a lot of features
> are not immediatly visible, so reading the handbook (at least the
> chapter's titiles) would give you a better idea of what qgit could do
> for you.
I'll read it a few more times. I seem to sometimes get into a state
where I'm locked onto the current change set and can't get back to
the other change sets without starting another qgit.
>
>> I'll get the latest and greatest. Thinks. Often the problem is
>> having the current version of Qt3. My workstation is Mandrake
>> 1005 Limited Edition (X11 Xinerama works on this release).
>> Looks like I have Qt3 on my workstation. Would it be worthwhile
>> to install Qt4 from src and try to use qgit-2.0?
>>
>
> Yes it is. There are a lot of new featrures, is almost as stable as
> the previous and if you are interested in file history (annotations)
> in qgit-2.0 this feature has been greatly speeded up.
Do you know if it's a lot of work to install Qt4?
- -piet
>
>
> Have fun
> Marco
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHFZv5JICwm/rv3hoRAky6AJ47DFL/pWa8CCHv0ezw0wdkLLmbIQCeJqZN
cNHuMINv2/7fmnwczWcowhs=
=VSZN
-----END PGP SIGNATURE-----
^ permalink raw reply
* Re: [PATCH] gitweb: speed up project listing on large work trees by limiting find depth
From: Shawn O. Pearce @ 2007-10-17 5:25 UTC (permalink / raw)
To: Luke Lu; +Cc: git, pasky
In-Reply-To: <562B5254-2BE7-43DF-AB62-499458E360CC@vicaya.com>
Luke Lu <git@vicaya.com> wrote:
> OK, let me try again :) I was using no_chdir => 1 to shorten the tr,
> as well as saving a syscall. However the code is expecting $_ to be
> relative elsewhere (line 1524) to check for the toplevel, so the
> check failed for the toplevel because of no_chdir, which caused
> substr to work on the toplevel, which is $pfxlen long. Note $pfxlen +
> 1 passes the end of the toplevel path, hence the errors, though the
> program still worked correctly, as $subdir is undefined in this case,
> which would by pass the rest of the code, which is logically correct.
> It'll probably crash, if it's written in C :)
>
> So, I got rid of no_chdir => 1 in the new patch and uses
> $File::Find::name directly, as otherwise I'd have to come up with a
> messier regex for checking toplevel at line 1524.
*light dawns*. Thank you for the explanation.
--
Shawn.
^ permalink raw reply
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