* Re: [PATCH] Let .git/config specify the url for submodules
From: Josef Weidendorfer @ 2007-06-01 8:08 UTC (permalink / raw)
To: Lars Hjemli; +Cc: Junio C Hamano, git
In-Reply-To: <8c5c35580705301717h4e9b127fr21ee19764f8ec288@mail.gmail.com>
On Thursday 31 May 2007, Lars Hjemli wrote:
> On 5/28/07, Lars Hjemli <hjemli@gmail.com> wrote:
> > This changes git-submodule in a few ways:
>
> Please don't apply the "Let .git/config specify the url for
> submodules" patch, I'm having second thoughts ;-)
>
> Your design outline in
> http://article.gmane.org/gmane.comp.version-control.git/48287 is
> obviously superior, and I'd like to take a stab at it with something
> like this:
>
> 1. 'git-submodule init' saves submodule name and suggested url from
> .gitmodules into .git/config (submodule.$name.url)
>
> 2. 'git-submodule update' keeps the work tree updated for submodules
> with five separate (and optional) operations:
> a) git-clone --bare $url .git/submodules/$name.git
> b) git-clone -l -s .git/submodules/$name.git $path
> c) cd .git/submodules/$name.git && git-fetch
> d) cd $path && git-fetch
> e) cd $path && git-checkout $sha1
>
> 3) 'git-submodule push' runs something like 'cd $path && git push
> origin $branch', where $branch is found in .gitmodules
> (path.$path.branch).
So if you need superproject related corrections in the submodule,
you always have to do it on branch "path.$path.branch" in the
submodule to get it saved?
I would assume that pushing the current branch should be enough.
If you want to play with multiple different "corrections" on
different branches in the submodule, you do not want to force
the branch name to a unique one given in .gitmodules.
Josef
^ permalink raw reply
* Re: [PATCH] catch asciidoc failures
From: Jonas Fonseca @ 2007-06-01 8:55 UTC (permalink / raw)
To: Martin Waitz; +Cc: Scott Lamb, Junio C Hamano, git
In-Reply-To: <20070601083621.GB3521@admingilde.org>
On 6/1/07, Martin Waitz <tali@admingilde.org> wrote:
> On Thu, May 31, 2007 at 11:23:57PM -0700, Scott Lamb wrote:
> > If pipefail is available (GNU bash >= 3.00), fail when asciidoc returns
> > error rather than possibly later during XSLT.
>
> perhaps we should simply change the pipe ordering to get asciidoc
> to the end of the pipeline so that all shells respect its exit code?
For tig I also adopted the nice man page headers git has. However, I have
used asciidoc attributes provided on the command line avoid having to
use sed. I can make a patch later if nobody beats me. The required changes
are outlined below.
> > --- a/Documentation/Makefile
> > +++ b/Documentation/Makefile
> > @@ -111,6 +111,7 @@ clean:
> >
> > %.html : %.txt
> > rm -f $@+ $@
> > + set -o pipefail 2>/dev/null; \
> > $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
> > $(ASCIIDOC_EXTRA) -o - $< | \
> > sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+
>
> something like (untested):
> sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' $< |
> $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
> $(ASCIIDOC_EXTRA) -o $@+ -
More untested stuff. Use -a to define git_version attribute:
$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
$(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@ $<
Then change the @@GIT_VERSION@@ symbol in asciidoc.conf to {git_version}.
--
Jonas Fonseca
^ permalink raw reply
* Re: [PATCH] Let .git/config specify the url for submodules
From: Sven Verdoolaege @ 2007-06-01 8:57 UTC (permalink / raw)
To: Lars Hjemli; +Cc: Junio C Hamano, git
In-Reply-To: <8c5c35580705301717h4e9b127fr21ee19764f8ec288@mail.gmail.com>
On Thu, May 31, 2007 at 02:17:30AM +0200, Lars Hjemli wrote:
> 1. 'git-submodule init' saves submodule name and suggested url from
> .gitmodules into .git/config (submodule.$name.url)
Could you please document the proposed .gitmodules first?
Since it looks like I'm going to be forced to my submodule URLs there,
I need to know how to do it before I can start using submodules properly.
skimo
^ permalink raw reply
* Re: [PATCH] catch asciidoc failures
From: Jeff King @ 2007-06-01 9:10 UTC (permalink / raw)
To: Martin Waitz; +Cc: Scott Lamb, Junio C Hamano, git, jonas.fonseca
In-Reply-To: <20070601083621.GB3521@admingilde.org>
On Fri, Jun 01, 2007 at 10:36:21AM +0200, Martin Waitz wrote:
> perhaps we should simply change the pipe ordering to get asciidoc
> to the end of the pipeline so that all shells respect its exit code?
> [...]
> something like (untested):
> sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' $< |
> $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
> $(ASCIIDOC_EXTRA) -o $@+ -
That won't work. The text @@GIT_VERSION@@ is pulled in from the
asciidoc.conf file, so it's not even in the source file; it's only in
the built product.
As Jonas suggested, making it an asciidoc attribute is much more
elegant (patch even tested!):
-- >8 --
Documentation: robustify asciidoc GIT_VERSION replacement
Instead of using sed on the resulting file, we now have a
git_version asciidoc attribute. This means that we don't
pipe the output of asciidoc, which means we can detect build
failures.
Problem reported by Scott Lamb, solution suggested by Jonas Fonseca.
Signed-off-by: Jeff King <peff@peff.net>
---
Documentation/Makefile | 6 ++----
Documentation/asciidoc.conf | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 3f92783..4064b38 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -112,8 +112,7 @@ clean:
%.html : %.txt
rm -f $@+ $@
$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
- $(ASCIIDOC_EXTRA) -o - $< | \
- sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+
+ $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<
mv $@+ $@
%.1 %.5 %.7 : %.xml
@@ -122,8 +121,7 @@ clean:
%.xml : %.txt
rm -f $@+ $@
$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
- $(ASCIIDOC_EXTRA) -o - $< | \
- sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+
+ $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<
mv $@+ $@
user-manual.xml: user-manual.txt user-manual.conf
diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf
index fa7dc94..60e15ba 100644
--- a/Documentation/asciidoc.conf
+++ b/Documentation/asciidoc.conf
@@ -40,7 +40,7 @@ template::[header-declarations]
<refentrytitle>{mantitle}</refentrytitle>
<manvolnum>{manvolnum}</manvolnum>
<refmiscinfo class="source">Git</refmiscinfo>
-<refmiscinfo class="version">@@GIT_VERSION@@</refmiscinfo>
+<refmiscinfo class="version">{git_version}</refmiscinfo>
<refmiscinfo class="manual">Git Manual</refmiscinfo>
</refmeta>
<refnamediv>
--
1.5.2.871.g0ff23
^ permalink raw reply related
* Re: [PATCH] Let .git/config specify the url for submodules
From: Lars Hjemli @ 2007-06-01 9:17 UTC (permalink / raw)
To: Josef Weidendorfer; +Cc: Junio C Hamano, git
In-Reply-To: <200706011008.38063.Josef.Weidendorfer@gmx.de>
On 6/1/07, Josef Weidendorfer <Josef.Weidendorfer@gmx.de> wrote:
> > On 5/28/07, Lars Hjemli <hjemli@gmail.com> wrote:
> > 3) 'git-submodule push' runs something like 'cd $path && git push
> > origin $branch', where $branch is found in .gitmodules
> > (path.$path.branch).
>
> So if you need superproject related corrections in the submodule,
> you always have to do it on branch "path.$path.branch" in the
> submodule to get it saved?
>
> I would assume that pushing the current branch should be enough.
> If you want to play with multiple different "corrections" on
> different branches in the submodule, you do not want to force
> the branch name to a unique one given in .gitmodules.
>
The current (and planned) implementation of git-submodule detaches
HEAD in the submodules, so there will not be a current branch unless
the user has done 'cd $path && git-checkout somebranch'.
We might take advantage of that fact:
* try to exec 'git-symbolic-ref HEAD'
* if it fails, push to path.$path.branch
* otherwise, push to the ref pointed to by HEAD
But this will still loose any changes on _other_ branches (that has
not been pushed to origin manually). I'm not sure if/how we can avoid
this, except by making $path be a symlink to .git/submodules/$name.git
(which has other issues...)
--
larsh
^ permalink raw reply
* Re: [PATCH 1/4] Add 2 new contrib scripts.
From: David Kågedal @ 2007-06-01 9:22 UTC (permalink / raw)
To: git
In-Reply-To: <20070531223423.6005.59088.stgit@gandelf.nowhere.earth>
Yann Dirson <ydirson@altern.org> writes:
> diff --git a/contrib/stg-unnew b/contrib/stg-unnew
> new file mode 100755
> index 0000000..5ac8781
> --- /dev/null
> +++ b/contrib/stg-unnew
> @@ -0,0 +1,15 @@
> +#!/bin/sh
> +set -e
> +
> +# stg-unnew - sort of "reverse an 'stg new'"
> +
> +# Remove the current patch from the stack, keeping its contents as
> +# uncommitted changes.
> +
> +# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
> +# Subject to the GNU GPL, version 2.
> +
> +patch=$(stg top)
> +stg pop
> +stg pick --fold $patch
> +stg delete $patch
>
This is something I've been missing. But I'd call it "stg merge" or
something, since what it does is that it merges the top patch into the
patch below it. But since "merge" means something else to git, it
might not be the best choice.
--
David Kågedal
^ permalink raw reply
* Re: [PATCH] Let .git/config specify the url for submodules
From: Lars Hjemli @ 2007-06-01 9:25 UTC (permalink / raw)
To: skimo; +Cc: Junio C Hamano, git
In-Reply-To: <20070601085705.GT955MdfPADPa@greensroom.kotnet.org>
On 6/1/07, Sven Verdoolaege <skimo@kotnet.org> wrote:
> On Thu, May 31, 2007 at 02:17:30AM +0200, Lars Hjemli wrote:
> > 1. 'git-submodule init' saves submodule name and suggested url from
> > .gitmodules into .git/config (submodule.$name.url)
>
> Could you please document the proposed .gitmodules first?
The man-page for git-submodule found in 'next' mentions how it uses
.gitmodules, but there isn't (yet) a separate man-page for
.gitmodules(5).
But: when I implement the proposed plan, it will change the current
layout of .gitmodules from
[module '$path']
url=/some/url
to
[path '$path']
submodule=modulename
url=/some/url
Is it ok if gitmodules(5) appears as part of the planned patch-series?
--
larsh
^ permalink raw reply
* Re: [PATCH] Let .git/config specify the url for submodules
From: Sven Verdoolaege @ 2007-06-01 9:35 UTC (permalink / raw)
To: Lars Hjemli; +Cc: Junio C Hamano, git
In-Reply-To: <8c5c35580706010225p7c34c3ceu8bbfb9996388d673@mail.gmail.com>
On Fri, Jun 01, 2007 at 11:25:42AM +0200, Lars Hjemli wrote:
> On 6/1/07, Sven Verdoolaege <skimo@kotnet.org> wrote:
> >Could you please document the proposed .gitmodules first?
>
> The man-page for git-submodule found in 'next' mentions how it uses
> .gitmodules, but there isn't (yet) a separate man-page for
> .gitmodules(5).
That's what I'd like to see first.
.gitmodules(5) will hopefully not change in an incompatible
way after it is accepted, while there is no such constraint
for git-submodule.
> [path '$path']
> submodule=modulename
> url=/some/url
Wouldn't it make more sense to have
[path '$path']
submodule=modulename
and
[submodule '$modulename']
url=/some/url
in case the same module appears in more than one path?
> Is it ok if gitmodules(5) appears as part of the planned patch-series?
For me it is.
skimo
^ permalink raw reply
* Re: [PATCH] catch asciidoc failures
From: Martin Waitz @ 2007-06-01 9:39 UTC (permalink / raw)
To: Jeff King; +Cc: Scott Lamb, Junio C Hamano, git, jonas.fonseca
In-Reply-To: <20070601091030.GA2215@coredump.intra.peff.net>
[-- Attachment #1: Type: text/plain, Size: 252 bytes --]
hoi :)
On Fri, Jun 01, 2007 at 05:10:30AM -0400, Jeff King wrote:
> As Jonas suggested, making it an asciidoc attribute is much more
> elegant (patch even tested!):
very nice!
Does that need any special asciidoc version?
--
Martin Waitz
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* Re: [PATCH] catch asciidoc failures
From: Jeff King @ 2007-06-01 9:43 UTC (permalink / raw)
To: Martin Waitz; +Cc: Scott Lamb, Junio C Hamano, git, jonas.fonseca
In-Reply-To: <20070601093929.GC3521@admingilde.org>
On Fri, Jun 01, 2007 at 11:39:29AM +0200, Martin Waitz wrote:
> very nice!
> Does that need any special asciidoc version?
I don't think so, but I'm not an asciidoc expert. Flipping through the
changelog, it looks like '-a' has existed since before 7.0.
-Peff
^ permalink raw reply
* Re: [PATCH] catch asciidoc failures
From: Scott Lamb @ 2007-06-01 9:46 UTC (permalink / raw)
To: Jeff King; +Cc: Martin Waitz, Junio C Hamano, git, jonas.fonseca
In-Reply-To: <20070601091030.GA2215@coredump.intra.peff.net>
On Jun 1, 2007, at 2:10 AM, Jeff King wrote:
> %.html : %.txt
> rm -f $@+ $@
> $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
> - $(ASCIIDOC_EXTRA) -o - $< | \
> - sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+
> + $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $<
> mv $@+ $@
Hmm, now the $@+ intermediary shouldn't be necessary anymore - with "-
o" it's asciidoc's responsibility to handle the output file correctly.
I think there's a lightbulb joke here somewhere. ;)
--
Scott Lamb <http://www.slamb.org/>
^ permalink raw reply
* Re: Breaking up repositories
From: Jakub Narebski @ 2007-06-01 10:25 UTC (permalink / raw)
To: git
In-Reply-To: <465EEF96.6050307@freedesktop.org>
Josh Triplett wrote:
> Jason Sewall wrote:
>> I recently imported my subversion repo with git-svn and I'm curious
>> what the best way to break up the monolithic repo (my many disparate
>> projects from my single svn repo) into individual git repos of their
>> own.
>
> In the specific case of git-svn, you can probably give git-svn the
> appropriate paths to import each project separately; that may do what you
> want, depending on your repository layout.
>
> In the general case, if you want to split a subtree of a git repo into a git
> repo, you want git-split, by Jamey Sharp and I:
> <http://people.freedesktop.org/~jamey/git-split>
> From a copy of the git repo you want to split, just run "git-split subdir",
> optionally with a newest and oldest commit, and it will output the sha1 of
> the new top commit for use as the new branch ref. Remove all other
> branches, reflogs, and other references to the old commits, and use prune
> or gc to get rid of old objects. Repeat as desired for other subdirs.
I have added info about git-split to Git Wiki
http://git.or.cz/gitwiki/InterfacesFrontendsAndTools
Please improve this information, and correct if it is wrong.
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply
* Re: [PATCH] gitweb: use decode_utf8 directly
From: Alexandre Julliard @ 2007-06-01 13:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ismail Dönmez, git, Jakub Narebski
In-Reply-To: <7vsladzp29.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
> I would say that the patch is an improvement from the current
> code so it should hit 'master'; I was a bit busy lately and then
> am sick, and also we are post -rc1 freeze now and I was being
> cautious, just in case some nacks from more informed parties
> arrive late.
Sorry for the late nack, but it turns out that this patch breaks diff
output on the Wine server for files that are not utf-8.
The cause is apparently that decode_utf8() returns undef for invalid
sequences instead of substituting a replacement char like
decode("utf8") does.
That may be considered an Encode bug since we are running a fairly old
version (1.99, coming with Debian 3.1), but I'd rather not upgrade
perl on the server. Could the patch be reverted, or done differently?
--
Alexandre Julliard
julliard@winehq.org
^ permalink raw reply
* Re: [PATCH] gitweb: use decode_utf8 directly
From: Ismail Dönmez @ 2007-06-01 13:50 UTC (permalink / raw)
To: Alexandre Julliard; +Cc: Junio C Hamano, git, Jakub Narebski
In-Reply-To: <87zm3ju6tg.fsf@wine.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]
On Friday 01 June 2007 16:45:31 Alexandre Julliard wrote:
> Junio C Hamano <junkio@cox.net> writes:
> > I would say that the patch is an improvement from the current
> > code so it should hit 'master'; I was a bit busy lately and then
> > am sick, and also we are post -rc1 freeze now and I was being
> > cautious, just in case some nacks from more informed parties
> > arrive late.
>
> Sorry for the late nack, but it turns out that this patch breaks diff
> output on the Wine server for files that are not utf-8.
Isn't UTF-8 default even for Linux kernel now?
> The cause is apparently that decode_utf8() returns undef for invalid
> sequences instead of substituting a replacement char like
> decode("utf8") does.
>
> That may be considered an Encode bug since we are running a fairly old
> version (1.99, coming with Debian 3.1), but I'd rather not upgrade
> perl on the server. Could the patch be reverted, or done differently?
Sorry but thats too old. Of course I am not the maintainer of GIT so its not
for me to decide but well as David Woodhouse puts it, please join us in 21st
century and start using UTF-8.
/ismail
--
Perfect is the enemy of good
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply
* Re: [PATCH] Let .git/config specify the url for submodules
From: Lars Hjemli @ 2007-06-01 14:45 UTC (permalink / raw)
To: skimo; +Cc: Junio C Hamano, git
In-Reply-To: <20070601093554.GV955MdfPADPa@greensroom.kotnet.org>
On 6/1/07, Sven Verdoolaege <skimo@kotnet.org> wrote:
> On Fri, Jun 01, 2007 at 11:25:42AM +0200, Lars Hjemli wrote:
> > On 6/1/07, Sven Verdoolaege <skimo@kotnet.org> wrote:
> > >Could you please document the proposed .gitmodules first?
> >
> > The man-page for git-submodule found in 'next' mentions how it uses
> > .gitmodules, but there isn't (yet) a separate man-page for
> > .gitmodules(5).
>
> That's what I'd like to see first.
> .gitmodules(5) will hopefully not change in an incompatible
> way after it is accepted, while there is no such constraint
> for git-submodule.
True
>
> > [path '$path']
> > submodule=modulename
> > url=/some/url
>
> Wouldn't it make more sense to have
>
> [path '$path']
> submodule=modulename
>
> and
>
> [submodule '$modulename']
> url=/some/url
>
> in case the same module appears in more than one path?
Yes, that would be a properly normalized model.
Hmm.... Maybe we could allow both variations, with your suggestion
overriding mine if both are present? (I think there would be many
cases where the extra level of [submodule...] wouldn't be needed.
Also, the url in .gitmodules will only function as the initially
suggested url stored in the 'superprojects' .git/config)
--
larsh
^ permalink raw reply
* Re: [PATCH] Let .git/config specify the url for submodules
From: Sven Verdoolaege @ 2007-06-01 14:51 UTC (permalink / raw)
To: Lars Hjemli; +Cc: Junio C Hamano, git
In-Reply-To: <8c5c35580706010745l76fc5410l21f2e3f385693ad9@mail.gmail.com>
On Fri, Jun 01, 2007 at 04:45:06PM +0200, Lars Hjemli wrote:
> On 6/1/07, Sven Verdoolaege <skimo@kotnet.org> wrote:
> >On Fri, Jun 01, 2007 at 11:25:42AM +0200, Lars Hjemli wrote:
> >> [path '$path']
> >> submodule=modulename
> >> url=/some/url
> >
> >Wouldn't it make more sense to have
> >
> >[path '$path']
> > submodule=modulename
> >
> >and
> >
> >[submodule '$modulename']
> > url=/some/url
> >
> >in case the same module appears in more than one path?
>
> Yes, that would be a properly normalized model.
>
> Hmm.... Maybe we could allow both variations, with your suggestion
> overriding mine if both are present? (I think there would be many
> cases where the extra level of [submodule...] wouldn't be needed.
Hmm.... I was thinking that the extra "path" level could be optional,
i.e., if there is no path.$path.submodule, then the name of the
submodule would simply be $path.
skimo
^ permalink raw reply
* Re: [PATCH] Let .git/config specify the url for submodules
From: Lars Hjemli @ 2007-06-01 15:56 UTC (permalink / raw)
To: skimo; +Cc: Junio C Hamano, git
In-Reply-To: <20070601145104.GY955MdfPADPa@greensroom.kotnet.org>
On 6/1/07, Sven Verdoolaege <skimo@kotnet.org> wrote:
> On Fri, Jun 01, 2007 at 04:45:06PM +0200, Lars Hjemli wrote:
> > On 6/1/07, Sven Verdoolaege <skimo@kotnet.org> wrote:
> > >On Fri, Jun 01, 2007 at 11:25:42AM +0200, Lars Hjemli wrote:
> > >> [path '$path']
> > >> submodule=modulename
> > >> url=/some/url
> > >
> > >Wouldn't it make more sense to have
> > >
> > >[path '$path']
> > > submodule=modulename
> > >
> > >and
> > >
> > >[submodule '$modulename']
> > > url=/some/url
> > >
> > >in case the same module appears in more than one path?
> >
> > Yes, that would be a properly normalized model.
> >
> > Hmm.... Maybe we could allow both variations, with your suggestion
> > overriding mine if both are present? (I think there would be many
> > cases where the extra level of [submodule...] wouldn't be needed.
>
> Hmm.... I was thinking that the extra "path" level could be optional,
> i.e., if there is no path.$path.submodule, then the name of the
> submodule would simply be $path.
Yeah, that should also work out. Time for a quick poll?
--
larsh
^ permalink raw reply
* Re: [PATCH] gitweb: use decode_utf8 directly
From: Martin Koegler @ 2007-06-01 16:13 UTC (permalink / raw)
To: julliard; +Cc: git
Alexandre Julliard wrote:
>Junio C Hamano <junkio@cox.net> writes:
> > I would say that the patch is an improvement from the current
> > code so it should hit 'master'; I was a bit busy lately and then
> > am sick, and also we are post -rc1 freeze now and I was being
> > cautious, just in case some nacks from more informed parties
> > arrive late.
>
> Sorry for the late nack, but it turns out that this patch breaks diff
> output on the Wine server for files that are not utf-8.
>
> The cause is apparently that decode_utf8() returns undef for invalid
> sequences instead of substituting a replacement char like
> decode("utf8") does.
>
> That may be considered an Encode bug since we are running a fairly old
> version (1.99, coming with Debian 3.1), but I'd rather not upgrade
> perl on the server. Could the patch be reverted, or done differently?
I hit the same problem:
http://marc.info/?l=git&m=117978122420441&w=2
On my system, I use this patch as workaround:
http://marc.info/?l=git&m=118038526531694&w=2
mfg Martin Kögler
^ permalink raw reply
* Re: [PATCH] Let .git/config specify the url for submodules
From: Linus Torvalds @ 2007-06-01 16:29 UTC (permalink / raw)
To: Lars Hjemli; +Cc: skimo, Junio C Hamano, git
In-Reply-To: <8c5c35580706010856s390b1157p3ea0d28cb2074cae@mail.gmail.com>
On Fri, 1 Jun 2007, Lars Hjemli wrote:
> On 6/1/07, Sven Verdoolaege <skimo@kotnet.org> wrote:
> >
> > Hmm.... I was thinking that the extra "path" level could be optional,
> > i.e., if there is no path.$path.submodule, then the name of the
> > submodule would simply be $path.
>
> Yeah, that should also work out. Time for a quick poll?
Ack. I think the natural thing for a lot of cases is the trivial "module
name == path" case, so having to have
[path "kernel"]
module = kernel
for that case just sounds unnecessary.
That said, I wonder if it wouldn't be more natural to do things the other
way around, because quite often a "module" (under CVS conventions) is a
*set* of directories, so with that in mind, it might be better to have the
mapping be something like this:
[module "infrastructure"]
submodule = lib
submodule = build
[submodule "lib"]
url = git://xyzzy/lib-1.2.3
[submodule "build"]
url = git://xyzzy/build-0.61
and make the rule be:
- submodules are named by their paths (ie "path == submodule")
- a module is a set of such submodules/paths
- if no "module" is defined, the default is to just use the
path/submodule name
IOW, in the above case, we have *three* modules:
- module "infrastructure", that is the union of submodules/paths "lib"
and "build"
- module "lib" (== submodule/path "lib")
- module "build" (== submodule/path "build")
and when you do a
git submodule checkout infrastructure
it would be basically equivalent to
git submodule checkout lib
git submodule checkout build
Hmm? That's how CVS users use modules (ie the "src" module may be much
more than a single subdirectory)
Linus
^ permalink raw reply
* Re: [PATCH] gitweb: use decode_utf8 directly
From: Alexandre Julliard @ 2007-06-01 16:51 UTC (permalink / raw)
To: Ismail Dönmez; +Cc: Junio C Hamano, git, Jakub Narebski
In-Reply-To: <200706011650.10650.ismail@pardus.org.tr>
Ismail Dönmez <ismail@pardus.org.tr> writes:
> Sorry but thats too old. Of course I am not the maintainer of GIT so its not
> for me to decide but well as David Woodhouse puts it, please join us in 21st
> century and start using UTF-8.
That's not very helpful. There can be many valid reasons for not using
utf-8, in our case compatibility with Windows tools is the main
reason. And even if we were to convert all our files today, it
wouldn't help when browsing older versions.
I'm not asking gitweb to magically guess the encoding of the files,
I'm happy with it replacing invalid sequences with some substitution
char, like it did before 1.5.2. But now it is deleting whole lines
from the diff, without any indication that something went wrong.
That's not an improvement IMNSHO.
--
Alexandre Julliard
julliard@winehq.org
^ permalink raw reply
* Re: [MinGW port] Unable to repack on Clearcase dynamic views
From: Jan Hudec @ 2007-06-01 18:11 UTC (permalink / raw)
To: Robin Rosenberg
Cc: Nguyen Thai Ngoc Duy, Paolo Teti, Git Mailing List,
Matthias Lederhofer, Junio C Hamano
In-Reply-To: <200705302028.15549.robin.rosenberg.lists@dewire.com>
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
On Wed, May 30, 2007 at 20:28:15 +0200, Robin Rosenberg wrote:
> Wasn't because it's better to make .git a link to a repository somewhere
> else? Just a guess.
>
> ln -s /somewhere/repo/.git .git
>
> Works fine for me (yes, in a clearcase dynamic view).
It works for me too. It requires cygwin version of git though, since windows
don't have native symlinks.
> BTW, Does anyone have something like git-cvsexportcommit for clearcase?
No, but it should not be too hard to create.
If you want to quickly import something, you can try starting with something
like:
diff clearcase-view git-checkout > p
lsdiff p | xargs -d '\n' cleartool checkout
patch -p $n < p
You'll have to sort out which directories to run which command in and how
many components to strip with -p in the patch. It also does not handle adding
and removing.
--
Jan 'Bulb' Hudec <bulb@ucw.cz>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* [mingw port] git plumbing piping with CR/NL
From: Nguyen Thai Ngoc Duy @ 2007-06-01 18:23 UTC (permalink / raw)
To: Git Mailing List, Johannes Sixt
Hi,
I haven't had time looking at the code yet. I report here so that I
can free my memory for other things. I made a command like this:
$ git ls-tree -r HEAD|grep blah.cc|git update-index --index-info
and the output of git-status was:
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: path/to/blah.cc\r
#
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
#
# deleted: path/to/blah.cc\r
...
$ git version
git version 1.5.2.651.g80e39-dirty (if the commit isn't in the master
branch, it is based on master branch)
Apparently git should ignore \r at the end of the path. Will look at it later.
--
Duy
^ permalink raw reply
* Re: [PATCH] gitweb: use decode_utf8 directly
From: Junio C Hamano @ 2007-06-01 19:44 UTC (permalink / raw)
To: Alexandre Julliard; +Cc: Ismail Dönmez, git, Jakub Narebski
In-Reply-To: <87zm3ju6tg.fsf@wine.dyndns.org>
Alexandre Julliard <julliard@winehq.org> writes:
> Sorry for the late nack, but it turns out that this patch breaks diff
> output on the Wine server for files that are not utf-8.
>
> The cause is apparently that decode_utf8() returns undef for invalid
> sequences instead of substituting a replacement char like
> decode("utf8") does.
Thanks for noticing. Will revert.
^ permalink raw reply
* Re: [PATCH] gitweb: use decode_utf8 directly
From: Ismail Dönmez @ 2007-06-01 19:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Alexandre Julliard, git, Jakub Narebski
In-Reply-To: <7vr6ovzcgr.fsf@assigned-by-dhcp.cox.net>
[-- Attachment #1: Type: text/plain, Size: 589 bytes --]
On Friday 01 June 2007 22:44:36 Junio C Hamano wrote:
> Alexandre Julliard <julliard@winehq.org> writes:
> > Sorry for the late nack, but it turns out that this patch breaks diff
> > output on the Wine server for files that are not utf-8.
> >
> > The cause is apparently that decode_utf8() returns undef for invalid
> > sequences instead of substituting a replacement char like
> > decode("utf8") does.
>
> Thanks for noticing. Will revert.
Why are reverting a correct bugfix? :( He's at most using outdated software.
*sigh*
/ismail
--
Perfect is the enemy of good
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply
* [PATCH] Unify write_index_file functions
From: Geert Bosch @ 2007-06-01 19:18 UTC (permalink / raw)
To: git Mailing List
This patch creates a new pack-idx.c file containing a unified version of
the write_index_file functions in builtin-pack-objects.c and index-pack.c.
As the name "index" is overloaded in git, move in the direction
of using "idx" and "pack idx" when refering to the pack index.
There should be no change in functionality.
Signed-off-by: Geert Bosch <bosch@gnat.com>
---
Makefile | 3 +-
builtin-pack-objects.c | 143 ++++--------------------------------------
index-pack.c | 161 +++++-------------------------------------------
pack-idx.c | 144 +++++++++++++++++++++++++++++++++++++++++++
pack.h | 15 +++++
5 files changed, 190 insertions(+), 276 deletions(-)
create mode 100644 pack-idx.c
diff --git a/Makefile b/Makefile
index 7527734..8e89cda 100644
--- a/Makefile
+++ b/Makefile
@@ -310,7 +310,8 @@ LIB_OBJS = \
interpolate.o \
lockfile.o \
patch-ids.o \
- object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.o \
+ object.o pack-check.o pack-idx.o pack-write.o \
+ patch-delta.o path.o pkt-line.o \
sideband.o reachable.o reflog-walk.o \
quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index e52332d..d4c5d2b 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -24,9 +24,10 @@ git-pack-objects [{ -q | --progress | --all-progress }] [--max-pack-size=N] \n\
struct object_entry {
unsigned char sha1[20];
- uint32_t crc32; /* crc of raw pack data for this object */
off_t offset; /* offset into the final pack file */
unsigned long size; /* uncompressed size */
+ uint32_t crc32; /* crc of raw pack data for this object */
+
unsigned int hash; /* name hint hash */
unsigned int depth; /* delta depth */
struct packed_git *in_pack; /* already in pack */
@@ -584,8 +585,7 @@ static int open_object_dir_tmp(const char *path)
return mkstemp(tmpname);
}
-/* forward declarations for write_pack_file */
-static void write_index_file(off_t last_obj_offset, unsigned char *sha1);
+/* forward declaration for write_pack_file */
static int adjust_perm(const char *path, mode_t mode);
static void write_pack_file(void)
@@ -641,15 +641,17 @@ static void write_pack_file(void)
}
if (!pack_to_stdout) {
- unsigned char object_list_sha1[20];
+ unsigned char sha1[20];
mode_t mode = umask(0);
umask(mode);
mode = 0444 & ~mode;
- write_index_file(last_obj_offset, object_list_sha1);
+ hashcpy(sha1, pack_file_sha1);
+ idx_tmp_name = write_idx_file(NULL,
+ (struct idx_object_entry **) written_list, nr_written, sha1);
snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
- base_name, sha1_to_hex(object_list_sha1));
+ base_name, sha1_to_hex(sha1));
if (adjust_perm(pack_tmp_name, mode))
die("unable to make temporary pack file readable: %s",
strerror(errno));
@@ -657,14 +659,14 @@ static void write_pack_file(void)
die("unable to rename temporary pack file: %s",
strerror(errno));
snprintf(tmpname, sizeof(tmpname), "%s-%s.idx",
- base_name, sha1_to_hex(object_list_sha1));
+ base_name, sha1_to_hex(sha1));
if (adjust_perm(idx_tmp_name, mode))
die("unable to make temporary index file readable: %s",
strerror(errno));
if (rename(idx_tmp_name, tmpname))
die("unable to rename temporary index file: %s",
strerror(errno));
- puts(sha1_to_hex(object_list_sha1));
+ puts(sha1_to_hex(sha1));
}
/* mark written objects as written to previous pack */
@@ -693,123 +695,6 @@ static void write_pack_file(void)
die("wrote %u objects as expected but %u unwritten", written, j);
}
-static int sha1_sort(const void *_a, const void *_b)
-{
- const struct object_entry *a = *(struct object_entry **)_a;
- const struct object_entry *b = *(struct object_entry **)_b;
- return hashcmp(a->sha1, b->sha1);
-}
-
-static uint32_t index_default_version = 1;
-static uint32_t index_off32_limit = 0x7fffffff;
-
-static void write_index_file(off_t last_obj_offset, unsigned char *sha1)
-{
- struct sha1file *f;
- struct object_entry **sorted_by_sha, **list, **last;
- uint32_t array[256];
- uint32_t i, index_version;
- SHA_CTX ctx;
-
- int fd = open_object_dir_tmp("tmp_idx_XXXXXX");
- if (fd < 0)
- die("unable to create %s: %s\n", tmpname, strerror(errno));
- idx_tmp_name = xstrdup(tmpname);
- f = sha1fd(fd, idx_tmp_name);
-
- if (nr_written) {
- sorted_by_sha = written_list;
- qsort(sorted_by_sha, nr_written, sizeof(*sorted_by_sha), sha1_sort);
- list = sorted_by_sha;
- last = sorted_by_sha + nr_written;
- } else
- sorted_by_sha = list = last = NULL;
-
- /* if last object's offset is >= 2^31 we should use index V2 */
- index_version = (last_obj_offset >> 31) ? 2 : index_default_version;
-
- /* index versions 2 and above need a header */
- if (index_version >= 2) {
- struct pack_idx_header hdr;
- hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
- hdr.idx_version = htonl(index_version);
- sha1write(f, &hdr, sizeof(hdr));
- }
-
- /*
- * Write the first-level table (the list is sorted,
- * but we use a 256-entry lookup to be able to avoid
- * having to do eight extra binary search iterations).
- */
- for (i = 0; i < 256; i++) {
- struct object_entry **next = list;
- while (next < last) {
- struct object_entry *entry = *next;
- if (entry->sha1[0] != i)
- break;
- next++;
- }
- array[i] = htonl(next - sorted_by_sha);
- list = next;
- }
- sha1write(f, array, 256 * 4);
-
- /* Compute the SHA1 hash of sorted object names. */
- SHA1_Init(&ctx);
-
- /* Write the actual SHA1 entries. */
- list = sorted_by_sha;
- for (i = 0; i < nr_written; i++) {
- struct object_entry *entry = *list++;
- if (index_version < 2) {
- uint32_t offset = htonl(entry->offset);
- sha1write(f, &offset, 4);
- }
- sha1write(f, entry->sha1, 20);
- SHA1_Update(&ctx, entry->sha1, 20);
- }
-
- if (index_version >= 2) {
- unsigned int nr_large_offset = 0;
-
- /* write the crc32 table */
- list = sorted_by_sha;
- for (i = 0; i < nr_written; i++) {
- struct object_entry *entry = *list++;
- uint32_t crc32_val = htonl(entry->crc32);
- sha1write(f, &crc32_val, 4);
- }
-
- /* write the 32-bit offset table */
- list = sorted_by_sha;
- for (i = 0; i < nr_written; i++) {
- struct object_entry *entry = *list++;
- uint32_t offset = (entry->offset <= index_off32_limit) ?
- entry->offset : (0x80000000 | nr_large_offset++);
- offset = htonl(offset);
- sha1write(f, &offset, 4);
- }
-
- /* write the large offset table */
- list = sorted_by_sha;
- while (nr_large_offset) {
- struct object_entry *entry = *list++;
- uint64_t offset = entry->offset;
- if (offset > index_off32_limit) {
- uint32_t split[2];
- split[0] = htonl(offset >> 32);
- split[1] = htonl(offset & 0xffffffff);
- sha1write(f, split, 8);
- nr_large_offset--;
- }
- }
- }
-
- sha1write(f, pack_file_sha1, 20);
- sha1close(f, NULL, 1);
- SHA1_Final(sha1, &ctx);
-}
-
static int locate_object_entry_hash(const unsigned char *sha1)
{
int i;
@@ -1825,12 +1710,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
}
if (!prefixcmp(arg, "--index-version=")) {
char *c;
- index_default_version = strtoul(arg + 16, &c, 10);
- if (index_default_version > 2)
+ pack_idx_default_version = strtoul(arg + 16, &c, 10);
+ if (pack_idx_default_version > 2)
die("bad %s", arg);
if (*c == ',')
- index_off32_limit = strtoul(c+1, &c, 0);
- if (*c || index_off32_limit & 0x80000000)
+ pack_idx_off32_limit = strtoul(c+1, &c, 0);
+ if (*c || pack_idx_off32_limit & 0x80000000)
die("bad %s", arg);
continue;
}
diff --git a/index-pack.c b/index-pack.c
index 58c4a9c..ed6ff9c 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -13,13 +13,14 @@ static const char index_pack_usage[] =
struct object_entry
{
+ unsigned char sha1[20];
off_t offset;
unsigned long size;
- unsigned int hdr_size;
uint32_t crc32;
+
+ unsigned int hdr_size;
enum object_type type;
enum object_type real_type;
- unsigned char sha1[20];
};
union delta_base {
@@ -602,145 +603,6 @@ static void fix_unresolved_deltas(int nr_unresolved)
free(sorted_by_pos);
}
-static uint32_t index_default_version = 1;
-static uint32_t index_off32_limit = 0x7fffffff;
-
-static int sha1_compare(const void *_a, const void *_b)
-{
- struct object_entry *a = *(struct object_entry **)_a;
- struct object_entry *b = *(struct object_entry **)_b;
- return hashcmp(a->sha1, b->sha1);
-}
-
-/*
- * On entry *sha1 contains the pack content SHA1 hash, on exit it is
- * the SHA1 hash of sorted object names.
- */
-static const char *write_index_file(const char *index_name, unsigned char *sha1)
-{
- struct sha1file *f;
- struct object_entry **sorted_by_sha, **list, **last;
- uint32_t array[256];
- int i, fd;
- SHA_CTX ctx;
- uint32_t index_version;
-
- if (nr_objects) {
- sorted_by_sha =
- xcalloc(nr_objects, sizeof(struct object_entry *));
- list = sorted_by_sha;
- last = sorted_by_sha + nr_objects;
- for (i = 0; i < nr_objects; ++i)
- sorted_by_sha[i] = &objects[i];
- qsort(sorted_by_sha, nr_objects, sizeof(sorted_by_sha[0]),
- sha1_compare);
- }
- else
- sorted_by_sha = list = last = NULL;
-
- if (!index_name) {
- static char tmpfile[PATH_MAX];
- snprintf(tmpfile, sizeof(tmpfile),
- "%s/tmp_idx_XXXXXX", get_object_directory());
- fd = mkstemp(tmpfile);
- index_name = xstrdup(tmpfile);
- } else {
- unlink(index_name);
- fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
- }
- if (fd < 0)
- die("unable to create %s: %s", index_name, strerror(errno));
- f = sha1fd(fd, index_name);
-
- /* if last object's offset is >= 2^31 we should use index V2 */
- index_version = (objects[nr_objects-1].offset >> 31) ? 2 : index_default_version;
-
- /* index versions 2 and above need a header */
- if (index_version >= 2) {
- struct pack_idx_header hdr;
- hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
- hdr.idx_version = htonl(index_version);
- sha1write(f, &hdr, sizeof(hdr));
- }
-
- /*
- * Write the first-level table (the list is sorted,
- * but we use a 256-entry lookup to be able to avoid
- * having to do eight extra binary search iterations).
- */
- for (i = 0; i < 256; i++) {
- struct object_entry **next = list;
- while (next < last) {
- struct object_entry *obj = *next;
- if (obj->sha1[0] != i)
- break;
- next++;
- }
- array[i] = htonl(next - sorted_by_sha);
- list = next;
- }
- sha1write(f, array, 256 * 4);
-
- /* compute the SHA1 hash of sorted object names. */
- SHA1_Init(&ctx);
-
- /*
- * Write the actual SHA1 entries..
- */
- list = sorted_by_sha;
- for (i = 0; i < nr_objects; i++) {
- struct object_entry *obj = *list++;
- if (index_version < 2) {
- uint32_t offset = htonl(obj->offset);
- sha1write(f, &offset, 4);
- }
- sha1write(f, obj->sha1, 20);
- SHA1_Update(&ctx, obj->sha1, 20);
- }
-
- if (index_version >= 2) {
- unsigned int nr_large_offset = 0;
-
- /* write the crc32 table */
- list = sorted_by_sha;
- for (i = 0; i < nr_objects; i++) {
- struct object_entry *obj = *list++;
- uint32_t crc32_val = htonl(obj->crc32);
- sha1write(f, &crc32_val, 4);
- }
-
- /* write the 32-bit offset table */
- list = sorted_by_sha;
- for (i = 0; i < nr_objects; i++) {
- struct object_entry *obj = *list++;
- uint32_t offset = (obj->offset <= index_off32_limit) ?
- obj->offset : (0x80000000 | nr_large_offset++);
- offset = htonl(offset);
- sha1write(f, &offset, 4);
- }
-
- /* write the large offset table */
- list = sorted_by_sha;
- while (nr_large_offset) {
- struct object_entry *obj = *list++;
- uint64_t offset = obj->offset;
- if (offset > index_off32_limit) {
- uint32_t split[2];
- split[0] = htonl(offset >> 32);
- split[1] = htonl(offset & 0xffffffff);
- sha1write(f, split, 8);
- nr_large_offset--;
- }
- }
- }
-
- sha1write(f, sha1, 20);
- sha1close(f, NULL, 1);
- free(sorted_by_sha);
- SHA1_Final(sha1, &ctx);
- return index_name;
-}
-
static void final(const char *final_pack_name, const char *curr_pack_name,
const char *final_index_name, const char *curr_index_name,
const char *keep_name, const char *keep_msg,
@@ -830,6 +692,7 @@ int main(int argc, char **argv)
const char *curr_index, *index_name = NULL;
const char *keep_name = NULL, *keep_msg = NULL;
char *index_name_buf = NULL, *keep_name_buf = NULL;
+ struct idx_object_entry **idx_objects;
unsigned char sha1[20];
for (i = 1; i < argc; i++) {
@@ -865,12 +728,12 @@ int main(int argc, char **argv)
index_name = argv[++i];
} else if (!prefixcmp(arg, "--index-version=")) {
char *c;
- index_default_version = strtoul(arg + 16, &c, 10);
- if (index_default_version > 2)
+ pack_idx_default_version = strtoul(arg + 16, &c, 10);
+ if (pack_idx_default_version > 2)
die("bad %s", arg);
if (*c == ',')
- index_off32_limit = strtoul(c+1, &c, 0);
- if (*c || index_off32_limit & 0x80000000)
+ pack_idx_off32_limit = strtoul(c+1, &c, 0);
+ if (*c || pack_idx_off32_limit & 0x80000000)
die("bad %s", arg);
} else
usage(index_pack_usage);
@@ -940,7 +803,13 @@ int main(int argc, char **argv)
nr_deltas - nr_resolved_deltas);
}
free(deltas);
- curr_index = write_index_file(index_name, sha1);
+
+ idx_objects = xmalloc((nr_objects) * sizeof(struct idx_object_entry *));
+ for (i = 0; i < nr_objects; i++)
+ idx_objects[i] = (struct idx_object_entry *) &objects[i];
+ curr_index = write_idx_file(index_name, idx_objects, nr_objects, sha1);
+ free(idx_objects);
+
final(pack_name, curr_pack,
index_name, curr_index,
keep_name, keep_msg,
diff --git a/pack-idx.c b/pack-idx.c
new file mode 100644
index 0000000..ccf232e
--- /dev/null
+++ b/pack-idx.c
@@ -0,0 +1,144 @@
+#include "cache.h"
+#include "pack.h"
+#include "csum-file.h"
+
+uint32_t pack_idx_default_version = 1;
+uint32_t pack_idx_off32_limit = 0x7fffffff;
+
+static int sha1_compare(const void *_a, const void *_b)
+{
+ struct idx_object_entry *a = *(struct idx_object_entry **)_a;
+ struct idx_object_entry *b = *(struct idx_object_entry **)_b;
+ return hashcmp(a->sha1, b->sha1);
+}
+
+/*
+ * On entry *sha1 contains the pack content SHA1 hash, on exit it is
+ * 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 idx_object_entry **objects, int nr_objects, unsigned char *sha1)
+{
+ struct sha1file *f;
+ struct idx_object_entry **sorted_by_sha, **list, **last;
+ off_t last_obj_offset = 0;
+ uint32_t array[256];
+ int i, fd;
+ SHA_CTX ctx;
+ uint32_t index_version;
+
+ if (nr_objects) {
+ sorted_by_sha = objects;
+ list = sorted_by_sha;
+ last = sorted_by_sha + nr_objects;
+ for (i = 0; i < nr_objects; ++i) {
+ if (objects[i]->offset > last_obj_offset)
+ last_obj_offset = objects[i]->offset;
+ }
+ qsort(sorted_by_sha, nr_objects, sizeof(sorted_by_sha[0]),
+ sha1_compare);
+ }
+ else
+ sorted_by_sha = list = last = NULL;
+
+ if (!index_name) {
+ static char tmpfile[PATH_MAX];
+ snprintf(tmpfile, sizeof(tmpfile),
+ "%s/tmp_idx_XXXXXX", get_object_directory());
+ fd = mkstemp(tmpfile);
+ index_name = xstrdup(tmpfile);
+ } else {
+ unlink(index_name);
+ fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
+ }
+ if (fd < 0)
+ die("unable to create %s: %s", index_name, strerror(errno));
+ f = sha1fd(fd, index_name);
+
+ /* if last object's offset is >= 2^31 we should use index V2 */
+ index_version = (last_obj_offset >> 31) ? 2 : pack_idx_default_version;
+
+ /* index versions 2 and above need a header */
+ if (index_version >= 2) {
+ struct pack_idx_header hdr;
+ hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
+ hdr.idx_version = htonl(index_version);
+ sha1write(f, &hdr, sizeof(hdr));
+ }
+
+ /*
+ * Write the first-level table (the list is sorted,
+ * but we use a 256-entry lookup to be able to avoid
+ * having to do eight extra binary search iterations).
+ */
+ for (i = 0; i < 256; i++) {
+ struct idx_object_entry **next = list;
+ while (next < last) {
+ struct idx_object_entry *obj = *next;
+ if (obj->sha1[0] != i)
+ break;
+ next++;
+ }
+ array[i] = htonl(next - sorted_by_sha);
+ list = next;
+ }
+ sha1write(f, array, 256 * 4);
+
+ /* compute the SHA1 hash of sorted object names. */
+ SHA1_Init(&ctx);
+
+ /*
+ * Write the actual SHA1 entries..
+ */
+ list = sorted_by_sha;
+ for (i = 0; i < nr_objects; i++) {
+ struct idx_object_entry *obj = *list++;
+ if (index_version < 2) {
+ uint32_t offset = htonl(obj->offset);
+ sha1write(f, &offset, 4);
+ }
+ sha1write(f, obj->sha1, 20);
+ SHA1_Update(&ctx, obj->sha1, 20);
+ }
+
+ if (index_version >= 2) {
+ unsigned int nr_large_offset = 0;
+
+ /* write the crc32 table */
+ list = sorted_by_sha;
+ for (i = 0; i < nr_objects; i++) {
+ struct idx_object_entry *obj = *list++;
+ uint32_t crc32_val = htonl(obj->crc32);
+ sha1write(f, &crc32_val, 4);
+ }
+
+ /* write the 32-bit offset table */
+ list = sorted_by_sha;
+ for (i = 0; i < nr_objects; i++) {
+ struct idx_object_entry *obj = *list++;
+ uint32_t offset = (obj->offset <= pack_idx_off32_limit) ?
+ obj->offset : (0x80000000 | nr_large_offset++);
+ offset = htonl(offset);
+ sha1write(f, &offset, 4);
+ }
+
+ /* write the large offset table */
+ list = sorted_by_sha;
+ while (nr_large_offset) {
+ struct idx_object_entry *obj = *list++;
+ uint64_t offset = obj->offset;
+ if (offset > pack_idx_off32_limit) {
+ uint32_t split[2];
+ split[0] = htonl(offset >> 32);
+ split[1] = htonl(offset & 0xffffffff);
+ sha1write(f, split, 8);
+ nr_large_offset--;
+ }
+ }
+ }
+
+ sha1write(f, sha1, 20);
+ sha1close(f, NULL, 1);
+ SHA1_Final(sha1, &ctx);
+ return index_name;
+}
diff --git a/pack.h b/pack.h
index d667fb8..f6c5f2c 100644
--- a/pack.h
+++ b/pack.h
@@ -34,6 +34,10 @@ struct pack_header {
*/
#define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */
+/* These may be overridden by command-line parameters */
+extern uint32_t pack_idx_default_version;
+extern uint32_t pack_idx_off32_limit;
+
/*
* Packed object index header
*/
@@ -42,6 +46,17 @@ struct pack_idx_header {
uint32_t idx_version;
};
+/*
+ * Common part of object structure used for write_idx_file
+ */
+struct idx_object_entry {
+ unsigned char sha1[20];
+ off_t offset;
+ unsigned long size;
+ uint32_t crc32;
+};
+
+extern const char *write_idx_file(const char *index_name, struct idx_object_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.1
^ 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