* Re: [PATCH] remove inline iteration variable
From: Alex Riesen @ 2006-08-17 9:11 UTC (permalink / raw)
To: David Rientjes; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0608161441070.29566@chino.corp.google.com>
On 8/16/06, David Rientjes <rientjes@google.com> wrote:
> > > > > Remove unnecessary iteration variable in inline.
> > > > > - for (i = 0; i < in; i++) putchar(' ');
> > > > > + for (; in > 0; in--)
> > > >
> > > > while(in--) putchar(' ');
> > > >
> > >
> > > That goes into an infinite loop if the argument is negative because
> > > it emits a cmpl $0, x(%ebp). Should never happen, but there's no
> > > reason not to prevent it with a for loop.
> >
> > while (in-- > 0) putchar(' ');
> >
> > still shorter :)
> >
>
> It emits a slightly rearranged assembly with the same number of instructions.
>
oops. I should've looked at the output. But the point moot anyway, Junio says :)
^ permalink raw reply
* Re: RFC: git pull <remote> making an octopus?
From: Junio C Hamano @ 2006-08-17 9:08 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: git
In-Reply-To: <20060814075305.GH21963@mellanox.co.il>
"Michael S. Tsirkin" <mst@mellanox.co.il> writes:
> Quoting r. Junio C Hamano <junkio@cox.net>:
>> Are you by any chance running a version of git that has some
>> unofficial patches that affect the generation of not-for-merge
>> markers?
>
> No, I just reproduced this on plain 1.4.2.
Doesn't reproduce for me and I am getting worried.
Has anybody else seen this?
^ permalink raw reply
* Re: git log - filter missing changesets
From: Michael S. Tsirkin @ 2006-08-17 8:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v7j17u4zw.fsf@assigned-by-dhcp.cox.net>
Quoting r. Junio C Hamano <junkio@cox.net>:
> Subject: Re: git log - filter missing changesets
>
> "Michael S. Tsirkin" <mst@mellanox.co.il> writes:
>
> > Hi!
> > git log with -- parameter seems to sometimes miss changesets that
> > affect a specific directory:
> > ...
> > what gives?
>
> Most likely history simplification threw away the entire side
> branch.
>
> This is getting to be a FAQ I suspect.
>
> http://thread.gmane.org/gmane.comp.version-control.git/21633
>
>
Yes, --full-history helps. Thanks!
I'm still not sure *when* does this simplification happen -
the changes that got hidden do not add/remove any files - but oh well.
BTW, --full-history does not seem to be documented on git-rev-list(1)
man page.
--
MST
^ permalink raw reply
* Re: git log - filter missing changesets
From: Junio C Hamano @ 2006-08-17 8:43 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: git
In-Reply-To: <20060817082558.GB2630@mellanox.co.il>
"Michael S. Tsirkin" <mst@mellanox.co.il> writes:
> Hi!
> git log with -- parameter seems to sometimes miss changesets that
> affect a specific directory:
> ...
> what gives?
Most likely history simplification threw away the entire side
branch.
This is getting to be a FAQ I suspect.
http://thread.gmane.org/gmane.comp.version-control.git/21633
^ permalink raw reply
* git log - filter missing changesets
From: Michael S. Tsirkin @ 2006-08-17 8:25 UTC (permalink / raw)
To: git
Hi!
git log with -- parameter seems to sometimes miss changesets that
affect a specific directory:
>git log -p vofed-1.1-rc1.. -- drivers/infiniband/ulp/sdp/ | \
grep drivers/infiniband/ulp/sdp
diff --git a/drivers/infiniband/ulp/sdp/sdp.h b/drivers/infiniband/ulp/sdp/sdp.h
--- a/drivers/infiniband/ulp/sdp/sdp.h
+++ b/drivers/infiniband/ulp/sdp/sdp.h
diff --git a/drivers/infiniband/ulp/sdp/sdp_bcopy.c
b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
--- a/drivers/infiniband/ulp/sdp/sdp_bcopy.c
+++ b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c
b/drivers/infiniband/ulp/sdp/sdp_main.c
--- a/drivers/infiniband/ulp/sdp/sdp_main.c
+++ b/drivers/infiniband/ulp/sdp/sdp_main.c
but without a filter:
>git log -p vofed-1.1-rc1.. | \
grep drivers/infiniband/ulp/sdp drivers/infiniband/ulp/sdp/sdp_main.c
diff --git a/drivers/infiniband/ulp/sdp/sdp.h b/drivers/infiniband/ulp/sdp/sdp.h
--- a/drivers/infiniband/ulp/sdp/sdp.h
+++ b/drivers/infiniband/ulp/sdp/sdp.h
diff --git a/drivers/infiniband/ulp/sdp/sdp_bcopy.c b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
--- a/drivers/infiniband/ulp/sdp/sdp_bcopy.c
+++ b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c
--- a/drivers/infiniband/ulp/sdp/sdp_main.c
+++ b/drivers/infiniband/ulp/sdp/sdp_main.c
diff --git a/drivers/infiniband/ulp/sdp/sdp.h b/drivers/infiniband/ulp/sdp/sdp.h
--- a/drivers/infiniband/ulp/sdp/sdp.h
+++ b/drivers/infiniband/ulp/sdp/sdp.h
diff --git a/drivers/infiniband/ulp/sdp/sdp_bcopy.c b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
--- a/drivers/infiniband/ulp/sdp/sdp_bcopy.c
+++ b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c
--- a/drivers/infiniband/ulp/sdp/sdp_main.c
+++ b/drivers/infiniband/ulp/sdp/sdp_main.c
what gives?
--
MST
^ permalink raw reply
* Re: Huge win, compressing a window of delta runs as a unit
From: Johannes Schindelin @ 2006-08-17 8:07 UTC (permalink / raw)
To: Shawn Pearce; +Cc: Jon Smirl, git
In-Reply-To: <Pine.LNX.4.63.0608170943470.28360@wbgn013.biozentrum.uni-wuerzburg.de>
Hi,
On Thu, 17 Aug 2006, Johannes Schindelin wrote:
> However, I see some real problems when a public repository has a pack like
> this: if the client is older, the server has to do some real work,
> especially in the case of a fresh clone. It gets even worse with a public
> HTTP repo.
>
> The obvious short-time solution would be to make this opt-in, and use it
> only on private repositories.
>
> Then, one could think about how to handle the delta-chains in the pack
> protocol (it should be easy, since you just have to store one object
> instead of a few), and make this a "supports" option.
Oh, and I completely forgot: IIUC you have to unpack the (possibly big)
delta-chain until you have the delta you really want, right? So, you might
want to have a clever mechanism to keep the delta-chains short for recent
objects (i.e. objects you are likely to need more often).
At least, the delta-chains should be limited by size (_not_ by number of
deltas: you can have huge deltas, and if you have to unpack 5 huge deltas
before getting to the huge delta you really need, it takes really long).
Ciao,
Dscho
^ permalink raw reply
* Re: Huge win, compressing a window of delta runs as a unit
From: Johannes Schindelin @ 2006-08-17 7:56 UTC (permalink / raw)
To: Shawn Pearce; +Cc: Jon Smirl, git
In-Reply-To: <20060817040719.GC18500@spearce.org>
Hi,
On Thu, 17 Aug 2006, Shawn Pearce wrote:
> Jon Smirl <jonsmirl@gmail.com> wrote:
> >
> > One entry per delta - 845,42,0150
> > Packed deltas - 295,018,474
> > 65% smaller
Impressed.
> Unfortunately I can't think of a way to make this type of pack
> readable by older software. So this could be creating a pretty
> big change in the pack format, relatively speaking. :)
Not necessarily: the format could stay the same, where multiple object
names point to the same entry.
It should not be a problem, as long as this change is kept local: the same
git tools which created this kind of pack have to read it.
However, I see some real problems when a public repository has a pack like
this: if the client is older, the server has to do some real work,
especially in the case of a fresh clone. It gets even worse with a public
HTTP repo.
The obvious short-time solution would be to make this opt-in, and use it
only on private repositories.
Then, one could think about how to handle the delta-chains in the pack
protocol (it should be easy, since you just have to store one object
instead of a few), and make this a "supports" option.
Ciao,
Dscho
^ permalink raw reply
* Re: gitweb: Support for snapshots in gitweb
From: Aneesh Kumar @ 2006-08-17 7:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vhd0bu873.fsf@assigned-by-dhcp.cox.net>
On 8/17/06, Junio C Hamano <junkio@cox.net> wrote:
> "Aneesh Kumar K.V" <aneesh.kumar@gmail.com> writes:
>
> > @@ -2097,6 +2102,23 @@ sub git_tree {
> > git_footer_html();
> > }
> >
> > +sub git_snapshot {
> > + if (!defined $hash) {
> > + $hash = git_get_head_hash($project);
> > + }
> > + print $cgi->header(-type=>'application/x-tar', -Content-Encoding=>'x-gzip',
> > + '-content-disposition' => "inline; filename=\"$project.tar.gz\"",
> > + -status=> '200 OK');
>
> These -Mixed-Case, '-sometimes-quoted', spaces sometimes around
> double-arrow sometimes missing, parameters bother me. Perhaps:
>
> print $cgi->header(-type => 'application/x-tar',
> -content-encoding => 'x-gzip',
> -content-disposition =>
> "inline; filename=\"$project.tar.gz\"",
> -status => '200 OK');
>
> RFC 2616 says that "gzip" content-coding is registered with
> IANA, so I do not think you need to say "x-gzip".
>
Please feel free to change the code. Or if you want me to send another
patch with the changes suggested i can do the same. Let me know.
> > + open my $fd, "-|", "$GIT tar-tree $hash \'$project\' | gzip -c6" or die_error(undef, "Execute git-tar-tree failed.");
>
> I think this "6" is because somebody suggested to use the
> default "6" instead of "9" in your original and the suggestion
> was because "9" tends to be too expensive.
>
> But if we do not have a good, specific, reason to use "6" (as
> opposed to, say, "5" or "7") and have "6" here only because we
> happen to know "6" is the current gzip default, then probably we
> are better off just letting gzip decide what compression level
> to use without specifying it ourselves?
yes that is correct. I changed it because it was suggested.
-aneesh
^ permalink raw reply
* Re: gitweb: Support for snapshots in gitweb
From: Junio C Hamano @ 2006-08-17 7:34 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: git
In-Reply-To: <44E40CB1.7040805@gmail.com>
"Aneesh Kumar K.V" <aneesh.kumar@gmail.com> writes:
> @@ -2097,6 +2102,23 @@ sub git_tree {
> git_footer_html();
> }
>
> +sub git_snapshot {
> + if (!defined $hash) {
> + $hash = git_get_head_hash($project);
> + }
> + print $cgi->header(-type=>'application/x-tar', -Content-Encoding=>'x-gzip',
> + '-content-disposition' => "inline; filename=\"$project.tar.gz\"",
> + -status=> '200 OK');
These -Mixed-Case, '-sometimes-quoted', spaces sometimes around
double-arrow sometimes missing, parameters bother me. Perhaps:
print $cgi->header(-type => 'application/x-tar',
-content-encoding => 'x-gzip',
-content-disposition =>
"inline; filename=\"$project.tar.gz\"",
-status => '200 OK');
RFC 2616 says that "gzip" content-coding is registered with
IANA, so I do not think you need to say "x-gzip".
> + open my $fd, "-|", "$GIT tar-tree $hash \'$project\' | gzip -c6" or die_error(undef, "Execute git-tar-tree failed.");
I think this "6" is because somebody suggested to use the
default "6" instead of "9" in your original and the suggestion
was because "9" tends to be too expensive.
But if we do not have a good, specific, reason to use "6" (as
opposed to, say, "5" or "7") and have "6" here only because we
happen to know "6" is the current gzip default, then probably we
are better off just letting gzip decide what compression level
to use without specifying it ourselves?
^ permalink raw reply
* What's in git.git
From: Junio C Hamano @ 2006-08-17 6:45 UTC (permalink / raw)
To: git
* The 'maint' branch has these fixes since the last announcement.
I am planning to cut a 1.4.2.1 with them soon.
Dennis Stosberg:
Solaris does not support C99 format strings before version 10
Johannes Schindelin:
git-mv: succeed even if source is a prefix of destination
git-mv: add more path normalization
Junio C Hamano:
finish_connect(): thinkofix
* The 'master' branch has these since the last announcement.
- Many many clean-ups by David Rientjes.
- Portability fixes by Dennis Stosberg for Solaris.
- Franck Bui-Huu's "format-patch --signoff" updates.
- Gitweb clean-up continues, headed by Jakub Narebski with
help from Martin Waitz and Yasushi Shoji.
- There was a code to sleep before writing out the index, in
order to avoid paying runtime costs in the racy-git
avoidance code later. After some experimenting and a bit of
thinking, removed this sleep. While at it, documented what
the racy-git problem is and how the avoidance works.
- Ville Skyttä updated Emacs VC support.
* The 'next' branch, in addition, has these.
- Git.pm/Git.xs series as before (no change)
- git-merge-recur as before (no change)
- upload-pack tweaks for the case where downloader has more
root than the server (no change -- need testing)
- git-apply --reverse --binary (new)
Earlier "git apply --reverse" rejected binary patch because
our binary patch format was irreversible. So I made it
reversible, and wrote some tests. This affects both diff
and apply.
* The 'pu' branch, in addition, has these.
- git-status WIP
I am hoping I can drop this; the implementation Peff
outlined sounded far simpler and cleaner.
- git-apply --reject (WIP)
I started working on an option to let 'git apply' apply a
patch whose some hunks do and some hunks do not apply, while
leaving rejects in a separate file (or files). Haven't
started testing this yet, though.
^ permalink raw reply
* gitweb: Support for snapshots in gitweb
From: Aneesh Kumar K.V @ 2006-08-17 6:29 UTC (permalink / raw)
To: git; +Cc: git
In-Reply-To: <7v4pwc4l0y.fsf@assigned-by-dhcp.cox.net>
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 0001-gitweb-Support-for-snapshots-in-gitweb.txt --]
[-- Type: text/plain, Size: 3167 bytes --]
This add snapshot support to gitweb. This need to be enabled
per project using config gitweb.snapshot = true
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
gitweb/gitweb.perl | 34 ++++++++++++++++++++++++++++++----
1 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 37a6284..4c78e80 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -175,6 +175,7 @@ my %actions = (
"tag" => \&git_tag,
"tags" => \&git_tags,
"tree" => \&git_tree,
+ "snapshot" => \&git_snapshot,
);
$action = 'summary' if (!defined($action));
@@ -1309,6 +1310,7 @@ sub git_difftree_body {
sub git_shortlog_body {
# uses global variable $project
my ($revlist, $from, $to, $refs, $extra) = @_;
+ my $have_snapshot = git_get_project_config_bool ('snapshot');
$from = 0 unless defined $from;
$to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);
@@ -1333,8 +1335,11 @@ sub git_shortlog_body {
print "</td>\n" .
"<td class=\"link\">" .
$cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
- $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
- "</td>\n" .
+ $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff");
+ if ($have_snapshot) {
+ print " | " . $cgi->a({-href => href(action=>"snapshot", hash=>$commit)}, "snapshot");
+ }
+ print "</td>\n" .
"</tr>\n";
}
if (defined $extra) {
@@ -2097,6 +2102,23 @@ sub git_tree {
git_footer_html();
}
+sub git_snapshot {
+ if (!defined $hash) {
+ $hash = git_get_head_hash($project);
+ }
+ print $cgi->header(-type=>'application/x-tar', -Content-Encoding=>'x-gzip',
+ '-content-disposition' => "inline; filename=\"$project.tar.gz\"",
+ -status=> '200 OK');
+
+ open my $fd, "-|", "$GIT tar-tree $hash \'$project\' | gzip -c6" or die_error(undef, "Execute git-tar-tree failed.");
+ binmode STDOUT, ':raw';
+ print <$fd>;
+ binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
+ close $fd;
+
+
+}
+
sub git_log {
my $head = git_get_head_hash($project);
if (!defined $hash) {
@@ -2191,6 +2213,7 @@ sub git_commit {
}
my $refs = git_get_references();
my $ref = format_ref_marker($refs, $co{'id'});
+ my $have_snapshot = git_get_project_config_bool ('snapshot');
my $formats_nav = '';
if (defined $file_name && defined $co{'parent'}) {
my $parent = $co{'parent'};
@@ -2226,8 +2249,11 @@ sub git_commit {
"<td class=\"sha1\">" .
$cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash), class => "list"}, $co{'tree'}) .
"</td>" .
- "<td class=\"link\">" . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash)}, "tree") .
- "</td>" .
+ "<td class=\"link\">" . $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash)}, "tree");
+ if ($have_snapshot) {
+ print " | " . $cgi->a({-href => href(action=>"snapshot", hash=>$hash)}, "snapshot");
+ }
+ print "</td>" .
"</tr>\n";
my $parents = $co{'parents'};
foreach my $par (@$parents) {
--
1.4.2.rc1.g83e1-dirty
^ permalink raw reply related
* Re: [PATCH] introduce inline is_same_sha1
From: Junio C Hamano @ 2006-08-17 6:26 UTC (permalink / raw)
To: David Rientjes; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0608162029540.14684@chino.corp.google.com>
David Rientjes <rientjes@google.com> writes:
> On Wed, 16 Aug 2006, Junio C Hamano wrote:
>
> The reason it is not
> int cmp_object_name(const void *, const void *)
>
> ties into the ultimate goal. As you said, 20 is hardcoded everywhere in
> the code as the length sha1's name. Since my own development tree uses
> two different hashes configurable at runtime, I decided to create a single
> static inline that would deal with name comparisons. I submitted a
> similar change to your tree because, like you, I envisioned that someday
> you may have several different hashes that require different comparison
> lengths.
Good, we are on the same wavelength. But that does not explain
why you do not use (void *) which would let you avoid casts at
the calling sites.
>> I would have liked if the function were to give the comparison
>> results similar to standard comparison functions such as memcmp
>> and strcmp. I do not know off-hand if we order by the object
>> names, and we might only be interested in equality tests, but
>> still...
>
> Remember, this is an inline function. The only reason for writing it
> would be to isolate the number 20 to this particular function (those that
> require comparisons were untouched, as I previously stated, so it still
> exists there as well), otherwise it's useless.
I may be slower than I usually am, but I fail to see the logic.
If we are isolating the comparison length and nothing else,
which I agree is a good thing, I would expect the function to
return 0 when same, just like memcmp(), which means "is_same" is
not the interface we would want. "is_same" is justified only
when all the callers want to know equality and not comparison.
> ... If you're going to allow a
> configurable hash function, then you'll need to isolate the n-bytes
> somewhere if you don't want to pass HASH_NAME_LENGTH around everywhere.
Exactly. So if some other call sites do want comparison, they
would either need to do memcmp() with 20 or needs cmp_object_name()
like interface, wouldn't they?
> git does sort on sha1 name, specifically with qsort in pack-objects using
> sha1_sort (which isn't an inline, but should be).
Correct, pack idx is sorted by object name.
> (It would be helpful if you were to specifically request changes to a
> patch or explicitly state whether or not you queued to apply it, I can
> never tell).
I am interested in this clean-up, but please convince me that
having two interfaces (is_same and compare) is better way to
abstract out 20 than one interface (compare), or if you agree
with me that one interface is better, please redo the patch and
the change the call sites you deliberately left as memcmp() in
the patch as well.
I sometimes say "I'd apply this as is, but you need to fix such
and such", when the contributor has a good track record of
responding. Please don't get this wrong, but you are still
unknown quantity to me. This is a learning process for both of
us.
By the way, Wednesdays and Saturdays (my time) are my git days,
so I try to summarize the current status of "master" and "next"
branches on these days. On other days I hack on git only during
lunch and evenings so the turnaround and response tend be slower
and sketchier.
^ permalink raw reply
* Re: [RFC/PATCH] Trace into a file if GIT_TRACE can interpreted as a filename.
From: Christian Couder @ 2006-08-17 6:14 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vhd0c2xbz.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano writes:
>
> I wonder if we can pass an already opened file descriptor to
> GIT_TRACE. E.g.
>
> GIT_TRACE=9 make test 9>/var/tmp/trace.log
>
> and make the trace code to emit the message with one write(2) to
> make sure messages from processes do not get mixed up in the
> middle.
I will see if I can come up with something.
Thanks again,
Christian.
^ permalink raw reply
* Logos, letterheads, business cards, envelops (ID128951477)
From: Emery Hurt @ 2006-08-17 5:47 UTC (permalink / raw)
To: georas
vnf
Our art team creates a custom logo for you, based on your needs. Years of experience have taught us how to create a logo that makes a statement that is unique to you.
In a professional manner we learn about your image and how you would like the world to perceive you and your company. With this information we then create a logo that is not only unique but reflects the purpose of you and your company.
For value and a logo that reflects your image, take a few minutes and visit Logo Maker!
http://cauliflower.biz.marklogo-ax.biz
Sincerely,
Logo Design Team
bullfrog digest bedtime
^ permalink raw reply
* Re: Huge win, compressing a window of delta runs as a unit
From: Shawn Pearce @ 2006-08-17 4:07 UTC (permalink / raw)
To: Jon Smirl; +Cc: git
In-Reply-To: <9e4733910608161020s6855140bs68aaab6e1bbd3bad@mail.gmail.com>
Jon Smirl <jonsmirl@gmail.com> wrote:
> Shawn put together a new version of his import utility that packs all
> of the deltas from a run into a single blob instead of one blob per
> delta. The idea is to put 10 or more deltas into each delta entry
> instead of one. The index format would map the 10 sha1's to a single
> packed delta entry which would be expanded when needed. Note that you
> probably needed multiple entries out of the delta pack to generate the
> revision you were looking for so this is no real loss on extraction.
>
> I ran it overnight on mozcvs. If his delta pack code is correct this
> is a huge win.
>
> One entry per delta - 845,42,0150
> Packed deltas - 295,018,474
> 65% smaller
>
> The effect of packing the deltas is to totally eliminate many of the
> redundant zlib dictionaries.
I'm going to try to integrate this into core GIT this weekend.
My current idea is to make use of the OBJ_EXT type flag to add
an extended header field behind the length which describes the
"chunk" as being a delta chain compressed in one zlib stream.
I'm not overly concerned about saving lots of space in the header
here as it looks like we're winning a huge amount of pack space,
so the extended header will probably itself be a couple of bytes.
This keeps the shorter reserved types free for other great ideas. :)
My primary goal of integrating it into core GIT is to take
advantage of verify-pack to check the file fast-import is producing.
Plus having support for it in sha1_file.c will make it easier to
performance test the common access routines that need to be fast,
like commit and tree walking.
My secondary goal is to get a patchset which other folks can try
on their own workloads to see if its as effective as what Jon is
seeing on the Mozilla archive.
Unfortunately I can't think of a way to make this type of pack
readable by older software. So this could be creating a pretty
big change in the pack format, relatively speaking. :)
--
Shawn.
^ permalink raw reply
* Re: [PATCH] introduce inline is_same_sha1
From: David Rientjes @ 2006-08-17 3:51 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vveos17ym.fsf@assigned-by-dhcp.cox.net>
On Wed, 16 Aug 2006, Junio C Hamano wrote:
> I would have expected the inline function to be:
>
> int cmp_object_name(const void *, const void *)
>
> No need for "unsigned char *" that way [*1*].
>
> I do not know what your ultimate goal with this patch is, but I
> like the fact that we do not have to hardcode "20" everywhere.
> With a yet-to-be-written companion patch to make the "20" into a
> symbolic constant OBJECT_NAME_LENGTH, we could someday have a
> flag day to use a hash different from SHA-1 with an updated
> 'git-convert-objects' ;-).
>
The reason it is not
int cmp_object_name(const void *, const void *)
ties into the ultimate goal. As you said, 20 is hardcoded everywhere in
the code as the length sha1's name. Since my own development tree uses
two different hashes configurable at runtime, I decided to create a single
static inline that would deal with name comparisons. I submitted a
similar change to your tree because, like you, I envisioned that someday
you may have several different hashes that require different comparison
lengths. The easy solution is using strcmp in the inline but then you're
required to cast based on signness and sometimes you want to truncate the
comparison to n bytes anyway depending on your hash of choice. If you
want to open your project to the possibility of implementing other
hashes, my patch is a step in that direction.
> I would have liked if the function were to give the comparison
> results similar to standard comparison functions such as memcmp
> and strcmp. I do not know off-hand if we order by the object
> names, and we might only be interested in equality tests, but
> still...
>
Remember, this is an inline function. The only reason for writing it
would be to isolate the number 20 to this particular function (those that
require comparisons were untouched, as I previously stated, so it still
exists there as well), otherwise it's useless. If you're going to allow a
configurable hash function, then you'll need to isolate the n-bytes
somewhere if you don't want to pass HASH_NAME_LENGTH around everywhere.
git does sort on sha1 name, specifically with qsort in pack-objects using
sha1_sort (which isn't an inline, but should be).
(It would be helpful if you were to specifically request changes to a
patch or explicitly state whether or not you queued to apply it, I can
never tell).
David
^ permalink raw reply
* Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.
From: Junio C Hamano @ 2006-08-17 2:06 UTC (permalink / raw)
To: Martin Waitz; +Cc: git
In-Reply-To: <11557673281583-git-send-email-tali@admingilde.org>
Martin Waitz <tali@admingilde.org> writes:
> Allow to use the global action dispatcher for all actions by introducing
> "/actions". If no project directory is given then a / is prepended to the
> action and the normal dispatcher is called.
> Project list and OPML generation are now hooked into the list as "/summary"
> and "/opml".
>
> As "/" is not an allowed character in actions accepted through the CGI
> parameters, it is still ensured that no normal action can be called without
> giving a valid project directory.
>
> Signed-off-by: Martin Waitz <tali@admingilde.org>
> ---
> gitweb/gitweb.perl | 17 ++++++++---------
> 1 files changed, 8 insertions(+), 9 deletions(-)
You completely lost me. What are you trying to achieve here?
I suspect this kind of funkies (and PATH_INFO) might be easier
to do in mod_rewrite() outside gitweb, but that is probably just
me.
^ permalink raw reply
* Re: [PATCH] gitweb: continue consolidation of URL generation.
From: Junio C Hamano @ 2006-08-17 1:59 UTC (permalink / raw)
To: Martin Waitz; +Cc: git
In-Reply-To: <11557673213372-git-send-email-tali@admingilde.org>
Martin Waitz <tali@admingilde.org> writes:
> Further use href() instead of URL generation by string concatenation.
> Almost all functions are converted now.
>
> Signed-off-by: Martin Waitz <tali@admingilde.org>
> ---
> gitweb/gitweb.perl | 68 +++++++++++++++++++++++++++-------------------------
> 1 files changed, 35 insertions(+), 33 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 37a6284..72e687e 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -204,7 +204,9 @@ sub href(%) {
>
> my $href = "$my_uri?";
> $href .= esc_param( join(";",
> - map { "$mapping{$_}=$params{$_}" } keys %params
> + map {
> + "$mapping{$_}=$params{$_}" if $params{$_}
> + } keys %params
> ) );
>
> return $href;
This is not about "further use href()".
I think "if $params{$_}" is unsafe here. Can you guarantee that
we will never want to pass 0 or an empty string as an parameter
value both in the current and the future code?
I think it needs to be "if defined $params{$_}", at least.
> @@ -1252,7 +1254,7 @@ sub git_difftree_body {
> "<td class=\"link\">" .
> $cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, "blob");
> if ($to_id ne $from_id) { # modified
> - print $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
> + print " | " . $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
> }
> print " | " . $cgi->a({-href => href(action=>"history", hash_base=>$hash, file_name=>$file)}, "history") . "\n";
> print "</td>\n";
Well spotted.
^ permalink raw reply
* Re: [PATCH] introduce inline is_same_sha1
From: Junio C Hamano @ 2006-08-17 1:12 UTC (permalink / raw)
To: David Rientjes; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0608161721020.11465@chino.corp.google.com>
David Rientjes <rientjes@google.com> writes:
> Introduces global inline:
> is_same_sha1(const unsigned char *sha1,
> const unsigned char *sha2);
>
> Uses memcmp for comparison and returns the result. All tests
> for comparisons for sha1 have been changed to use the new
> global inline, but existing uses of memcmp have been preserved
> where the return value other than 0 is needed, i.e.:
>
> int cmp = !memcmp(old_sha1, new_sha1, 20);
>
> Conversions from char* to unsigned char* casts have been made
> where appropriate.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
I would have expected the inline function to be:
int cmp_object_name(const void *, const void *)
No need for "unsigned char *" that way [*1*].
I do not know what your ultimate goal with this patch is, but I
like the fact that we do not have to hardcode "20" everywhere.
With a yet-to-be-written companion patch to make the "20" into a
symbolic constant OBJECT_NAME_LENGTH, we could someday have a
flag day to use a hash different from SHA-1 with an updated
'git-convert-objects' ;-).
I would have liked if the function were to give the comparison
results similar to standard comparison functions such as memcmp
and strcmp. I do not know off-hand if we order by the object
names, and we might only be interested in equality tests, but
still...
Line-wrap the message for comfortable viewing on 80-column
terminals, please.
[Footnote]
*1* On the other hand if stricter type checking is wanted,
"const unsigned char *" is too weak. We would need either
sparse annotation or a new type (maybe a struct that has a
single member that has 20-byte uchar array). I personally
think that is an overkill, though.
^ permalink raw reply
* [PATCH] introduce inline is_same_sha1
From: David Rientjes @ 2006-08-17 0:25 UTC (permalink / raw)
To: git
Introduces global inline:
is_same_sha1(const unsigned char *sha1,
const unsigned char *sha2);
Uses memcmp for comparison and returns the result. All tests for comparisons
for sha1 have been changed to use the new global inline, but existing uses of
memcmp have been preserved where the return value other than 0 is needed, i.e.:
int cmp = !memcmp(old_sha1, new_sha1, 20);
Conversions from char* to unsigned char* casts have been made where appropriate.
Signed-off-by: David Rientjes <rientjes@google.com>
---
builtin-commit-tree.c | 2 +-
builtin-diff-stages.c | 2 +-
builtin-diff.c | 2 +-
builtin-pack-objects.c | 6 +++---
builtin-show-branch.c | 4 ++--
builtin-unpack-objects.c | 4 ++--
builtin-update-index.c | 4 ++--
cache.h | 4 ++++
combine-diff.c | 4 ++--
diff-lib.c | 2 +-
diff.c | 8 ++++----
diffcore-break.c | 2 +-
diffcore-rename.c | 2 +-
dump-cache-tree.c | 2 +-
http-fetch.c | 6 +++---
http-push.c | 4 ++--
index-pack.c | 10 ++++++----
merge-tree.c | 2 +-
object.c | 2 +-
pack-check.c | 6 +++---
read-cache.c | 2 +-
refs.c | 8 ++++----
send-pack.c | 2 +-
sha1_file.c | 16 ++++++++--------
sha1_name.c | 4 ++--
ssh-fetch.c | 2 +-
tree-diff.c | 2 +-
unpack-trees.c | 2 +-
28 files changed, 61 insertions(+), 55 deletions(-)
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index 9c98796..99fab3b 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -69,7 +69,7 @@ static int new_parent(int idx)
int i;
unsigned char *sha1 = parent_sha1[idx];
for (i = 0; i < idx; i++) {
- if (!memcmp(parent_sha1[i], sha1, 20)) {
+ if (is_same_sha1(parent_sha1[i], sha1)) {
error("duplicate parent %s ignored", sha1_to_hex(sha1));
return 0;
}
diff --git a/builtin-diff-stages.c b/builtin-diff-stages.c
index 5960e08..4593fd2 100644
--- a/builtin-diff-stages.c
+++ b/builtin-diff-stages.c
@@ -46,7 +46,7 @@ static void diff_stages(int stage1, int
else if (!two)
diff_addremove(&diff_options, '-', ntohl(one->ce_mode),
one->sha1, name, NULL);
- else if (memcmp(one->sha1, two->sha1, 20) ||
+ else if (!is_same_sha1(one->sha1, two->sha1) ||
(one->ce_mode != two->ce_mode) ||
diff_options.find_copies_harder)
diff_change(&diff_options,
diff --git a/builtin-diff.c b/builtin-diff.c
index 40e5c96..12ae9b1 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -69,7 +69,7 @@ static void stuff_change(struct diff_opt
struct diff_filespec *one, *two;
if (!is_null_sha1(old_sha1) && !is_null_sha1(new_sha1) &&
- !memcmp(old_sha1, new_sha1, 20))
+ is_same_sha1(old_sha1, new_sha1))
return;
if (opt->reverse_diff) {
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 448461b..3c1d3c1 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -441,7 +441,7 @@ static int locate_object_entry_hash(cons
memcpy(&ui, sha1, sizeof(unsigned int));
i = ui % object_ix_hashsz;
while (0 < object_ix[i]) {
- if (!memcmp(sha1, objects[object_ix[i]-1].sha1, 20))
+ if (is_same_sha1(sha1, objects[object_ix[i] - 1].sha1))
return i;
if (++i == object_ix_hashsz)
i = 0;
@@ -607,7 +607,7 @@ static struct pbase_tree_cache *pbase_tr
*/
for (neigh = 0; neigh < 8; neigh++) {
ent = pbase_tree_cache[my_ix];
- if (ent && !memcmp(ent->sha1, sha1, 20)) {
+ if (ent && is_same_sha1(ent->sha1, sha1)) {
ent->ref++;
return ent;
}
@@ -789,7 +789,7 @@ static void add_preferred_base(unsigned
return;
for (it = pbase_tree; it; it = it->next) {
- if (!memcmp(it->pcache.sha1, tree_sha1, 20)) {
+ if (is_same_sha1(it->pcache.sha1, tree_sha1)) {
free(data);
return;
}
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 95fbf77..88c7c1c 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -378,7 +378,7 @@ static int append_head_ref(const char *r
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
- if (get_sha1(refname + ofs, tmp) || memcmp(tmp, sha1, 20))
+ if (get_sha1(refname + ofs, tmp) || !is_same_sha1(tmp, sha1))
ofs = 5;
return append_ref(refname + ofs, sha1);
}
@@ -442,7 +442,7 @@ static int rev_is_head(char *head_path,
{
int namelen;
if ((!head_path[0]) ||
- (head_sha1 && sha1 && memcmp(head_sha1, sha1, 20)))
+ (head_sha1 && sha1 && !is_same_sha1(head_sha1, sha1)))
return 0;
namelen = strlen(name);
if ((headlen < namelen) ||
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index 63f4b8e..4f42d21 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -136,7 +136,7 @@ static void added_object(unsigned char *
struct delta_info *info;
while ((info = *p) != NULL) {
- if (!memcmp(info->base_sha1, sha1, 20)) {
+ if (is_same_sha1(info->base_sha1, sha1)) {
*p = info->next;
p = &delta_list;
resolve_delta(type, data, size, info->delta, info->size);
@@ -292,7 +292,7 @@ int cmd_unpack_objects(int argc, const c
unpack_all();
SHA1_Update(&ctx, buffer, offset);
SHA1_Final(sha1, &ctx);
- if (memcmp(fill(20), sha1, 20))
+ if (!is_same_sha1(fill(20), sha1))
die("final sha1 did not match");
use(20);
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 9f0cf28..1f74edd 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -378,7 +378,7 @@ static int unresolve_one(const char *pat
ret = -1;
goto free_return;
}
- if (!memcmp(ce_2->sha1, ce_3->sha1, 20) &&
+ if (is_same_sha1(ce_2->sha1, ce_3->sha1) &&
ce_2->ce_mode == ce_3->ce_mode) {
fprintf(stderr, "%s: identical in both, skipping.\n",
path);
@@ -460,7 +460,7 @@ static int do_reupdate(int ac, const cha
old = read_one_ent(NULL, head_sha1,
ce->name, ce_namelen(ce), 0);
if (old && ce->ce_mode == old->ce_mode &&
- !memcmp(ce->sha1, old->sha1, 20)) {
+ is_same_sha1(ce->sha1, old->sha1)) {
free(old);
continue; /* unchanged */
}
diff --git a/cache.h b/cache.h
index c738299..5a78b03 100644
--- a/cache.h
+++ b/cache.h
@@ -214,6 +214,10 @@ static inline int is_null_sha1(const uns
{
return !memcmp(sha1, null_sha1, 20);
}
+static inline int is_same_sha1(const unsigned char *sha1, const unsigned char *sha2)
+{
+ return !memcmp(sha1, sha2, 20);
+}
int git_mkstemp(char *path, size_t n, const char *template);
diff --git a/combine-diff.c b/combine-diff.c
index ce063b4..c78a157 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -688,8 +688,8 @@ static void show_patch_diff(struct combi
for (i = 0; i < num_parent; i++) {
int j;
for (j = 0; j < i; j++) {
- if (!memcmp(elem->parent[i].sha1,
- elem->parent[j].sha1, 20)) {
+ if (is_same_sha1(elem->parent[i].sha1,
+ elem->parent[j].sha1)) {
reuse_combine_diff(sline, cnt, i, j);
break;
}
diff --git a/diff-lib.c b/diff-lib.c
index 116b5a9..4bcb350 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -215,7 +215,7 @@ static int show_modified(struct rev_info
}
oldmode = old->ce_mode;
- if (mode == oldmode && !memcmp(sha1, old->sha1, 20) &&
+ if (mode == oldmode && is_same_sha1(sha1, old->sha1) &&
!revs->diffopt.find_copies_harder)
return 0;
diff --git a/diff.c b/diff.c
index 7a238d0..b1e07a1 100644
--- a/diff.c
+++ b/diff.c
@@ -1140,7 +1140,7 @@ static int work_tree_matches(const char
if ((lstat(name, &st) < 0) ||
!S_ISREG(st.st_mode) || /* careful! */
ce_match_stat(ce, &st, 0) ||
- memcmp(sha1, ce->sha1, 20))
+ !is_same_sha1(sha1, ce->sha1))
return 0;
/* we return 1 only when we can stat, it is a regular file,
* stat information matches, and sha1 recorded in the cache
@@ -1579,7 +1579,7 @@ static void run_diff(struct diff_filepai
;
}
- if (memcmp(one->sha1, two->sha1, 20)) {
+ if (!is_same_sha1(one->sha1, two->sha1)) {
int abbrev = o->full_index ? 40 : DEFAULT_ABBREV;
len += snprintf(msg + len, sizeof(msg) - len,
@@ -2098,7 +2098,7 @@ int diff_unmodified_pair(struct diff_fil
* dealing with a change.
*/
if (one->sha1_valid && two->sha1_valid &&
- !memcmp(one->sha1, two->sha1, sizeof(one->sha1)))
+ is_same_sha1(one->sha1, two->sha1))
return 1; /* no change */
if (!one->sha1_valid && !two->sha1_valid)
return 1; /* both look at the same file on the filesystem. */
@@ -2237,7 +2237,7 @@ static void diff_resolve_rename_copy(voi
if (!p->status)
p->status = DIFF_STATUS_RENAMED;
}
- else if (memcmp(p->one->sha1, p->two->sha1, 20) ||
+ else if (!is_same_sha1(p->one->sha1, p->two->sha1) ||
p->one->mode != p->two->mode)
p->status = DIFF_STATUS_MODIFIED;
else {
diff --git a/diffcore-break.c b/diffcore-break.c
index ed0e14c..821ec57 100644
--- a/diffcore-break.c
+++ b/diffcore-break.c
@@ -56,7 +56,7 @@ static int should_break(struct diff_file
return 0; /* leave symlink rename alone */
if (src->sha1_valid && dst->sha1_valid &&
- !memcmp(src->sha1, dst->sha1, 20))
+ is_same_sha1(src->sha1, dst->sha1))
return 0; /* they are the same */
if (diff_populate_filespec(src, 0) || diff_populate_filespec(dst, 0))
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 0ec488a..32afcc3 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -101,7 +101,7 @@ static int is_exact_match(struct diff_fi
int contents_too)
{
if (src->sha1_valid && dst->sha1_valid &&
- !memcmp(src->sha1, dst->sha1, 20))
+ is_same_sha1(src->sha1, dst->sha1))
return 1;
if (!contents_too)
return 0;
diff --git a/dump-cache-tree.c b/dump-cache-tree.c
index 1ccaf51..51aadcc 100644
--- a/dump-cache-tree.c
+++ b/dump-cache-tree.c
@@ -33,7 +33,7 @@ static int dump_cache_tree(struct cache_
}
else {
dump_one(it, pfx, "");
- if (memcmp(it->sha1, ref->sha1, 20) ||
+ if (!is_same_sha1(it->sha1, ref->sha1) ||
ref->entry_count != it->entry_count ||
ref->subtree_nr != it->subtree_nr) {
dump_one(ref, pfx, "#(ref) ");
diff --git a/http-fetch.c b/http-fetch.c
index 7f07d2a..dc4e30e 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -301,7 +301,7 @@ static void finish_object_request(struct
unlink(obj_req->tmpfile);
return;
}
- if (memcmp(obj_req->sha1, obj_req->real_sha1, 20)) {
+ if (!is_same_sha1(obj_req->sha1, obj_req->real_sha1)) {
unlink(obj_req->tmpfile);
return;
}
@@ -1070,7 +1070,7 @@ static int fetch_object(struct alt_base
int ret = 0;
struct object_request *obj_req = object_queue_head;
- while (obj_req != NULL && memcmp(obj_req->sha1, sha1, 20))
+ while (obj_req != NULL && !is_same_sha1(obj_req->sha1, sha1))
obj_req = obj_req->next;
if (obj_req == NULL)
return error("Couldn't find request for %s in the queue", hex);
@@ -1109,7 +1109,7 @@ #endif
} else if (obj_req->zret != Z_STREAM_END) {
corrupt_object_found++;
ret = error("File %s (%s) corrupt", hex, obj_req->url);
- } else if (memcmp(obj_req->sha1, obj_req->real_sha1, 20)) {
+ } else if (!is_same_sha1(obj_req->sha1, obj_req->real_sha1)) {
ret = error("File %s has bad hash", hex);
} else if (obj_req->rename < 0) {
ret = error("unable to write sha1 filename %s",
diff --git a/http-push.c b/http-push.c
index 2bd9845..6a13c3e 100644
--- a/http-push.c
+++ b/http-push.c
@@ -745,7 +745,7 @@ static void finish_request(struct transf
SHA1_Final(request->real_sha1, &request->c);
if (request->zret != Z_STREAM_END) {
unlink(request->tmpfile);
- } else if (memcmp(request->obj->sha1, request->real_sha1, 20)) {
+ } else if (!is_same_sha1(request->obj->sha1, request->real_sha1)) {
unlink(request->tmpfile);
} else {
request->rename =
@@ -2416,7 +2416,7 @@ int main(int argc, char **argv)
if (!ref->peer_ref)
continue;
- if (!memcmp(ref->old_sha1, ref->peer_ref->new_sha1, 20)) {
+ if (is_same_sha1(ref->old_sha1, ref->peer_ref->new_sha1)) {
if (push_verbosely || 1)
fprintf(stderr, "'%s': up-to-date\n", ref->name);
continue;
diff --git a/index-pack.c b/index-pack.c
index b20659c..be4c36b 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -82,7 +82,7 @@ static void parse_pack_header(void)
SHA1_Init(&ctx);
SHA1_Update(&ctx, pack_base, pack_size - 20);
SHA1_Final(sha1, &ctx);
- if (memcmp(sha1, pack_base + pack_size - 20, 20))
+ if (!is_same_sha1(sha1, pack_base + pack_size - 20))
die("packfile '%s' SHA1 mismatch", pack_name);
}
@@ -210,9 +210,11 @@ static int find_deltas_based_on_sha1(con
if (first < 0)
return -1;
- while (first > 0 && !memcmp(deltas[first-1].base_sha1, base_sha1, 20))
+ while (first > 0 && is_same_sha1(deltas[first - 1].base_sha1,
+ base_sha1))
--first;
- while (last < end && !memcmp(deltas[last+1].base_sha1, base_sha1, 20))
+ while (last < end && is_same_sha1(deltas[last + 1].base_sha1,
+ base_sha1))
++last;
*first_index = first;
*last_index = last;
diff --git a/merge-tree.c b/merge-tree.c
index 7cf00be..7f68cb9 100644
--- a/merge-tree.c
+++ b/merge-tree.c
@@ -152,7 +152,7 @@ static int same_entry(struct name_entry
{
return a->sha1 &&
b->sha1 &&
- !memcmp(a->sha1, b->sha1, 20) &&
+ is_same_sha1(a->sha1, b->sha1) &&
a->mode == b->mode;
}
diff --git a/object.c b/object.c
index b5d8ed4..bcf3564 100644
--- a/object.c
+++ b/object.c
@@ -58,7 +58,7 @@ struct object *lookup_object(const unsig
i = hashtable_index(sha1);
while ((obj = obj_hash[i]) != NULL) {
- if (!memcmp(sha1, obj->sha1, 20))
+ if (is_same_sha1(sha1, obj->sha1))
break;
i++;
if (i == obj_hash_size)
diff --git a/pack-check.c b/pack-check.c
index 3a62e1b..8434a8d 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -29,10 +29,10 @@ static int verify_packfile(struct packed
pack_base = p->pack_base;
SHA1_Update(&ctx, pack_base, pack_size - 20);
SHA1_Final(sha1, &ctx);
- if (memcmp(sha1, (char *) pack_base + pack_size - 20, 20))
+ if (!is_same_sha1(sha1, (unsigned char *)pack_base + pack_size - 20))
return error("Packfile %s SHA1 mismatch with itself",
p->pack_name);
- if (memcmp(sha1, (char *) index_base + index_size - 40, 20))
+ if (!is_same_sha1(sha1, (unsigned char *)index_base + index_size - 40))
return error("Packfile %s SHA1 mismatch with idx",
p->pack_name);
@@ -135,7 +135,7 @@ int verify_pack(struct packed_git *p, in
SHA1_Init(&ctx);
SHA1_Update(&ctx, index_base, index_size - 20);
SHA1_Final(sha1, &ctx);
- if (memcmp(sha1, (char *) index_base + index_size - 20, 20))
+ if (!is_same_sha1(sha1, (unsigned char *)index_base + index_size - 20))
ret = error("Packfile index for %s SHA1 mismatch",
p->pack_name);
diff --git a/read-cache.c b/read-cache.c
index 3228ffb..ae0156f 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -739,7 +739,7 @@ static int verify_hdr(struct cache_heade
SHA1_Init(&c);
SHA1_Update(&c, hdr, size - 20);
SHA1_Final(sha1, &c);
- if (memcmp(sha1, (char *) hdr + size - 20, 20))
+ if (!is_same_sha1(sha1, (unsigned char *)hdr + size - 20))
return error("bad index file sha1 signature");
return 0;
}
diff --git a/refs.c b/refs.c
index 86ef916..5f3f5d2 100644
--- a/refs.c
+++ b/refs.c
@@ -281,7 +281,7 @@ static struct ref_lock *verify_lock(stru
unlock_ref(lock);
return NULL;
}
- if (memcmp(lock->old_sha1, old_sha1, 20)) {
+ if (!is_same_sha1(lock->old_sha1, old_sha1)) {
error("Ref %s is at %s but expected %s", lock->ref_file,
sha1_to_hex(lock->old_sha1), sha1_to_hex(old_sha1));
unlock_ref(lock);
@@ -411,7 +411,7 @@ int write_ref_sha1(struct ref_lock *lock
if (!lock)
return -1;
- if (!lock->force_write && !memcmp(lock->old_sha1, sha1, 20)) {
+ if (!lock->force_write && is_same_sha1(lock->old_sha1, sha1)) {
unlock_ref(lock);
return 0;
}
@@ -475,7 +475,7 @@ int read_ref_at(const char *ref, unsigne
die("Log %s is corrupt.", logfile);
if (get_sha1_hex(rec + 41, sha1))
die("Log %s is corrupt.", logfile);
- if (memcmp(logged_sha1, sha1, 20)) {
+ if (!is_same_sha1(logged_sha1, sha1)) {
tz = strtoul(tz_c, NULL, 10);
fprintf(stderr,
"warning: Log %s has gap after %s.\n",
@@ -489,7 +489,7 @@ int read_ref_at(const char *ref, unsigne
else {
if (get_sha1_hex(rec + 41, logged_sha1))
die("Log %s is corrupt.", logfile);
- if (memcmp(logged_sha1, sha1, 20)) {
+ if (!is_same_sha1(logged_sha1, sha1)) {
tz = strtoul(tz_c, NULL, 10);
fprintf(stderr,
"warning: Log %s unexpectedly ended on %s.\n",
diff --git a/send-pack.c b/send-pack.c
index 43e10b0..d7f58cd 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -265,7 +265,7 @@ static int send_pack(int in, int out, in
char old_hex[60], *new_hex;
if (!ref->peer_ref)
continue;
- if (!memcmp(ref->old_sha1, ref->peer_ref->new_sha1, 20)) {
+ if (is_same_sha1(ref->old_sha1, ref->peer_ref->new_sha1)) {
if (verbose)
fprintf(stderr, "'%s': up-to-date\n", ref->name);
continue;
diff --git a/sha1_file.c b/sha1_file.c
index 18dece4..04d54ef 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -485,10 +485,10 @@ int use_packed_git(struct packed_git *p)
/* Check if the pack file matches with the index file.
* this is cheap.
*/
- if (memcmp((char*)(p->index_base) + p->index_size - 40,
- (char *) p->pack_base + p->pack_size - 20,
- 20)) {
-
+ if (!is_same_sha1((unsigned char *)(p->index_base) +
+ p->index_size - 40,
+ (unsigned char *)p->pack_base +
+ p->pack_size - 20)) {
die("packfile %s does not match index.", p->pack_name);
}
}
@@ -643,7 +643,7 @@ int check_sha1_signature(const unsigned
SHA1_Update(&c, header, 1+sprintf(header, "%s %lu", type, size));
SHA1_Update(&c, map, size);
SHA1_Final(real_sha1, &c);
- return memcmp(sha1, real_sha1, 20) ? -1 : 0;
+ return !is_same_sha1(sha1, real_sha1) ? -1 : 0;
}
void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
@@ -941,7 +941,7 @@ int check_reuse_pack_delta(struct packed
ptr = unpack_object_header(p, ptr, kindp, sizep);
if (*kindp != OBJ_DELTA)
goto done;
- memcpy(base, (char *) p->pack_base + ptr, 20);
+ memcpy(base, (unsigned char *) p->pack_base + ptr, 20);
status = 0;
done:
unuse_packed_git(p);
@@ -1715,7 +1715,7 @@ int write_sha1_from_fd(const unsigned ch
unlink(tmpfile);
return error("File %s corrupted", sha1_to_hex(sha1));
}
- if (memcmp(sha1, real_sha1, 20)) {
+ if (!is_same_sha1(sha1, real_sha1)) {
unlink(tmpfile);
return error("File %s has bad hash", sha1_to_hex(sha1));
}
diff --git a/sha1_name.c b/sha1_name.c
index f567454..2d4d26a 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -106,7 +106,7 @@ static int find_short_packed_object(int
memcpy(found_sha1, now, 20);
found++;
}
- else if (memcmp(found_sha1, now, 20)) {
+ else if (!is_same_sha1(found_sha1, now)) {
found = 2;
break;
}
@@ -144,7 +144,7 @@ static int find_unique_short_object(int
return 0;
}
/* Both have unique ones -- do they match? */
- if (memcmp(packed_sha1, unpacked_sha1, 20))
+ if (!is_same_sha1(packed_sha1, unpacked_sha1))
return SHORT_NAME_AMBIGUOUS;
memcpy(sha1, packed_sha1, 20);
return 0;
diff --git a/ssh-fetch.c b/ssh-fetch.c
index 0b89df6..603e244 100644
--- a/ssh-fetch.c
+++ b/ssh-fetch.c
@@ -67,7 +67,7 @@ int fetch(unsigned char *sha1)
signed char remote;
struct object_list *temp;
- if (memcmp(sha1, in_transit->item->sha1, 20)) {
+ if (!is_same_sha1(sha1, in_transit->item->sha1)) {
/* we must have already fetched it to clean the queue */
return has_sha1_file(sha1) ? 0 : -1;
}
diff --git a/tree-diff.c b/tree-diff.c
index 916f489..51df262 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -40,7 +40,7 @@ static int compare_tree_entry(struct tre
return 1;
}
if (!opt->find_copies_harder &&
- !memcmp(sha1, sha2, 20) && mode1 == mode2)
+ is_same_sha1(sha1, sha2) && mode1 == mode2)
return 0;
/*
diff --git a/unpack-trees.c b/unpack-trees.c
index 43ed124..153b321 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -417,7 +417,7 @@ static int same(struct cache_entry *a, s
if (!a && !b)
return 1;
return a->ce_mode == b->ce_mode &&
- !memcmp(a->sha1, b->sha1, 20);
+ is_same_sha1(a->sha1, b->sha1);
}
--
1.4.2.g1c2a-dirty
^ permalink raw reply related
* Re: gitweb / cg-export
From: Kay Sievers @ 2006-08-16 22:50 UTC (permalink / raw)
To: Martin Waitz; +Cc: Aneesh Kumar K.V, git
In-Reply-To: <20060816224000.GE14459@admingilde.org>
On Thu, 2006-08-17 at 00:40 +0200, Martin Waitz wrote:
> hoi :)
>
> On Wed, Aug 16, 2006 at 04:23:05PM +0530, Aneesh Kumar K.V wrote:
> > @@ -1334,6 +1335,7 @@ sub git_shortlog_body {
> > "<td class=\"link\">" .
> > $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
> > $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
> > + " | " .$cgi->a({-href => "$my_uri/$project.tar.gz?" . esc_param("p=$project;a=snapshot;h=$commit")}, "snapshot") .
> > "</td>\n" .
> > "</tr>\n";
> > }
>
> Isn't there some other way to tell the webbroser how to name the file?
> I thought there is some HTML header to explicitly give one file name.
Something like in line 1923?
$cgi->header(-type => "$type", '-content-disposition' => "inline; filename=\"$save_as\"");
Kay
^ permalink raw reply
* Re: gitweb / cg-export
From: Martin Waitz @ 2006-08-16 22:40 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: git
In-Reply-To: <44E2F911.6060002@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
hoi :)
On Wed, Aug 16, 2006 at 04:23:05PM +0530, Aneesh Kumar K.V wrote:
> @@ -1334,6 +1335,7 @@ sub git_shortlog_body {
> "<td class=\"link\">" .
> $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
> $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
> + " | " .$cgi->a({-href => "$my_uri/$project.tar.gz?" . esc_param("p=$project;a=snapshot;h=$commit")}, "snapshot") .
> "</td>\n" .
> "</tr>\n";
> }
Isn't there some other way to tell the webbroser how to name the file?
I thought there is some HTML header to explicitly give one file name.
--
Martin Waitz
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* [PATCH] gitweb: support for "fp" parameter.
From: Martin Waitz @ 2006-08-16 22:28 UTC (permalink / raw)
To: git; +Cc: Martin Waitz
In-Reply-To: <11557673212235-git-send-email-tali@admingilde.org>
The "fp" (file name parent) parameter was previously generated for
blob diffs of renamed files. However, it was not used in any code.
Now href() can generate "fp" parameters and they are used by the
blobdiff code to show the correct file name.
Signed-off-by: Martin Waitz <tali@admingilde.org>
---
gitweb/gitweb.perl | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ed6bd0e..a022569 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -124,6 +124,13 @@ if (defined $file_name) {
}
}
+our $file_parent = $cgi->param('fp');
+if (defined $file_parent) {
+ if (!validate_input($file_parent)) {
+ die_error(undef, "Invalid file parent parameter");
+ }
+}
+
our $hash = $cgi->param('h');
if (defined $hash) {
if (!validate_input($hash)) {
@@ -197,6 +204,7 @@ sub href(%) {
action => "a",
project => "p",
file_name => "f",
+ file_parent => "fp",
hash => "h",
hash_parent => "hp",
hash_base => "hb",
@@ -1282,8 +1290,7 @@ sub git_difftree_body {
$cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$to_file)}, "blob");
if ($to_id ne $from_id) {
print " | " .
- $cgi->a({-href => "$my_uri?" .
- esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file;fp=$from_file")}, "diff");
+ $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$to_file, file_parent=>$from_file)}, "diff");
}
print "</td>\n";
@@ -1304,8 +1311,7 @@ sub git_difftree_body {
$cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$to_file)}, "blob");
if ($to_id ne $from_id) {
print " | " .
- $cgi->a({-href => "$my_uri?" .
- esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file;fp=$from_file")}, "diff");
+ $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$to_file, file_parent=>$from_file)}, "diff");
}
print "</td>\n";
} # we should not encounter Unmerged (U) or Unknown (X) status
@@ -2290,7 +2296,7 @@ sub git_blobdiff {
git_print_page_path($file_name, "blob");
print "<div class=\"page_body\">\n" .
"<div class=\"diff_info\">blob:" .
- $cgi->a({-href => href(action=>"blob", hash=>$hash_parent, hash_base=>$hash_base, file_name=>$file_name)}, $hash_parent) .
+ $cgi->a({-href => href(action=>"blob", hash=>$hash_parent, hash_base=>$hash_base, file_name=>($file_parent || $file_name))}, $hash_parent) .
" -> blob:" .
$cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, $hash) .
"</div>\n";
--
1.4.2.rc2.gf055
^ permalink raw reply related
* [PATCH] gitweb: support for / as home_link.
From: Martin Waitz @ 2006-08-16 22:28 UTC (permalink / raw)
To: git; +Cc: Martin Waitz
In-Reply-To: <1155767325181-git-send-email-tali@admingilde.org>
If the webserver is configured to use gitweb even for the root directory
of the site, then my_uri is empty which leads to a non-functional home
link. Fix that by defaulting to "/" in this case.
Signed-off-by: Martin Waitz <tali@admingilde.org>
---
gitweb/gitweb.perl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a022569..0a0b37f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -34,7 +34,7 @@ # location for temporary files needed fo
our $git_temp = "/tmp/gitweb";
# target of the home link on top of all pages
-our $home_link = $my_uri;
+our $home_link = $my_uri || "/";
# string of the home link on top of all pages
our $home_link_str = "++GITWEB_HOME_LINK_STR++";
--
1.4.2.rc2.gf055
^ permalink raw reply related
* [PATCH] gitweb: fix project list if PATH_INFO=="/".
From: Martin Waitz @ 2006-08-16 22:28 UTC (permalink / raw)
To: git; +Cc: Martin Waitz
In-Reply-To: <11557673263081-git-send-email-tali@admingilde.org>
The project list now uses several common header / footer generation functions.
These functions only check for "defined $project", but when PATH_INFO just
contains a "/" (which is often generated by web servers), then this test
fails.
Now explicitly undef $project if there is none so that the tests in other
gitweb parts work again.
Signed-off-by: Martin Waitz <tali@admingilde.org>
---
gitweb/gitweb.perl | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0a0b37f..3b6333c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -100,8 +100,9 @@ our $project = ($cgi->param('p') || $ENV
if (defined $project) {
$project =~ s|^/||;
$project =~ s|/$||;
+ $project = undef unless $project;
}
-if (defined $project && $project) {
+if (defined $project) {
if (!validate_input($project)) {
die_error(undef, "Invalid project parameter");
}
--
1.4.2.rc2.gf055
^ 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