Skip to contentSkip to conversation

GIT 1.0.4 and what is in master and proposed updates.

PATCH New Junio C Hamano 1 participant 2 messages Dec 24, 2005 – Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

GIT 1.0.4 contains the following updates since GIT 1.0.3:

* check_packed_git_idx(): check integrity of the idx file itself.

Earlier we did not use SHA1 checksum at the end of the index file that records the checksum of the index file itself.

* show-branch: usability updates.

Fixes the bug that made 'git show-branch --heads' show the same heads twice, among other things.

* merge --no-commit: tweak message.

Instead of saying "failed/prevented", say which one.

* ls-files --full-name: usage string and documentation.

The option was not documented.

* mailinfo: iconv does not like "latin-1" -- should spell it "latin1"

Noted by Marco; when a message does not identify its own charset, we tried to assume latin1 but misspelled it as latin-1, and iconv barfed.

The master branch has all of the above, and in addition contains the following:

* git-clone: do not special case dumb http.

This is to remove the remnant from the days http-fetch did not handle packed repositories natively.

* rev-parse: --show-cdup

This is a low-impact shorthand for:

        git rev-parse --show-prefix | sed -e 's|[^/][^/]*|..|g'

and will be used by "git checkout works from a subdirectory" patch.

The proposed updates branch has the following updates.

* git-daemon --base-path

Lack of the command line verification bugs me somewhat with this patch. Also we might want to apply the base-path to the whitelist as well, which the patch currently does not do. Almost there, but not quite ready.

* help with group permission in a shared repository.

This series consists of these commits:

Introduce core.sharedrepository
git-init-db: initialize shared repositories with --shared
Tutorial: mention shared repository management.

I think this one is ready. I just am taking things slowly.

* make git-checkout work from a subdirectory.

This series consists of these commits:

checkout: sometimes work from a subdirectory.
ls-tree: chomp leading directories when run from a subdirectory Adjust to ls-tree --full-name when run from a subdirectory.

This seems to work pretty well. I just am taking things slowly.

* require packfiles to follow the naming convention more strictly.

This rejects a packfile whose name does not begin with "pack-" followed by 40-byte hexadecimal digits. The core never had such limitation (the only thing it required was that the pack and the idx are named with the same basename with .pack and .idx extention), but the way http-fetch handles packs requires this.

An alternative strategy to handle the current mess would be to fix http-fetch so that it does not assume that pack names are always in the format "pack-[0-9a-f]{40}.pack", getting rid of sha1[] column from struct packed_git. This is probably more work, but would be cleaner. On the other hand, the cleanliness probably would not buy us much. We do not need to insist on "pack-" prefix, but there is no strong reason to hate it, and we need to ensure packnames do not collide with each other anyway, so having SHA1 hash in the name makes sense. However, we currently allow arbitrary 40 hexadecimal digits there and the user is free to say 0{40}. Continuing to allow this defeats the initial purpose of why 40 hexadecimal digits are there: collision avoidance.

This series starts warning if the 40-byte hex that follows "pack-" is not the correct hash for contained object names that was given by pack-objects when the pack was created, and has a provision to later start rejecting such packs.

This is probably controversial because it would eventually require users to rename their packs created using pre v0.99.9 tools. There is a small utility program that helps the conversion process, so it may not be that painful.

* Disable USE_SYMLINK_HEAD by default.

This uses symref for .git/HEAD everywhere. Some Porcelain may not be ready to deal with it, so it is kept in the proposed updates branch for now.

If your Porcelain "cat .git/HEAD", or "readlink .git/HEAD", it is already broken in repositories that use symref for HEAD, but it will be broken everywhere by this. Use git-symbolic-ref if you want to find out the name of the branch HEAD points at, or git-rev-parse if you want to find out the commit object name HEAD points at.

Most notably, git_read_hash(".../HEAD") in gitweb is probably affected (meaning, it is already broken).

#1 lore raw

PATCH 1/1 Require packfiles to follow the naming convention.

Quoted 13 lines · Junio C Hamano

* require packfiles to follow the naming convention more strictly.

This rejects a packfile whose name does not begin with "pack-" followed by 40-byte hexadecimal digits. The core never had such limitation (the only thing it required was that the pack and the idx are named with the same basename with .pack and .idx extention), but the way http-fetch handles packs requires this.
...
This is probably controversial because it would eventually require users to rename their packs created using pre v0.99.9 tools. There is a small utility program that helps the conversion process, so it may not be that painful.

And this is the patch in question. When your packs are the ones produced by pre v0.99.9 tools, you can ask git-convert-packs to suggest you the "right name" to use.

$ git-convert-packs
warning: index name '.git/objects/pack/pack-a3b60db8bb6dad970f6dcdc03b0addf3988e8556.idx' does not match contents of the pack '83b60db8bb6dad970f6dcdc03b0addf3988e8556'
# Packname does not match contents.
mv '.git/objects/pack/pack-a3b60db8bb6dad970f6dcdc03b0addf3988e8556.pack' '.git/objects/pack/pack-83b60db8bb6dad970f6dcdc03b0addf3988e8556.pack'
mv '.git/objects/pack/pack-a3b60db8bb6dad970f6dcdc03b0addf3988e8556.idx' '.git/objects/pack/pack-83b60db8bb6dad970f6dcdc03b0addf3988e8556.idx'
$ git-convert-packs | sh 
warning: index name '.git/objects/pack/pack-a3b60db8bb6dad970f6dcdc03b0addf3988e8556.idx' does not match contents of the pack '83b60db8bb6dad970f6dcdc03b0addf3988e8556'
$ git-convert-packs
$ exit

Comments?

-- >8 --
Pack files names are required to be "pack-[0-9a-f]{40}.pack", with corresponding .idx file. This is not strictly needed at the core level, but the packed file transfer over HTTP relies on this format. With this commit, the core would ignore otherwise a valid packfile in .git/objects/packs that "git-unpack-objects" would expand properly, if it does not follow the naming convention.

The hexadecimal part should be what git-pack-objects computed when the pack was created originally, and it is the SHA1 sum over sorted object names (i.e. 20-byte binary SHA1 checksum each). However, this condition is checked but not enforced currently, because git-pack-objects before v0.99.9 computed a checksum over object names without sorting (i.e. the order git-rev-list fed the object names), just to make pack names unlikely to collide. This made less than ideal use of SHA1 sum to name packs, which we would want to rectify in the future.

Many packfiles in the wild were created with git before v0.99.9, so the check would trigger and will give a warning message like this:

warning: index name '.git/objects/pack/pack-3b60db8....idx' does not match contents of the pack '83b60db...'

You can rename the existing pack that has this old name (3b60db8...) to new name (83b60db...) to squelch this warning message. For that, a new command git-convert-packs is provided to produce suitable "mv" command you can paste into your shell.

---

 .gitignore             |    1 +
 Makefile               |    2 +
 convert-packs.c        |   49 ++++++++++++++++++++++++++++++
 sha1_file.c            |   41 ++++++++++++++++++++++++-
 t/t5300-pack-object.sh |   79 ++++++++++++++++++++++++++----------------------
 5 files changed, 133 insertions(+), 39 deletions(-)
 create mode 100644 convert-packs.c

9c9f23b012e4030f433c7d4260a3fae93c302a0e

.gitignore +1 -0
index 6bd508e..d713f62 100644
@@ -18,6 +18,7 @@ git-clone-pack
 git-commit
 git-commit-tree
 git-convert-objects
+git-convert-packs
 git-count-objects
 git-cvsexportcommit
 git-cvsimport
Makefile +1 -1
index 3395a9e..2209f97 100644
@@ -121,7 +121,7 @@ SIMPLE_PROGRAMS = \
 PROGRAMS = \
 	git-apply$X git-cat-file$X \
 	git-checkout-index$X git-clone-pack$X git-commit-tree$X \
-	git-convert-objects$X git-diff-files$X \
+	git-convert-objects$X git-convert-packs$X git-diff-files$X \
 	git-diff-index$X git-diff-stages$X \
 	git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
 	git-hash-object$X git-index-pack$X git-init-db$X \
convert-packs.c new file +49 -0

49 lines not on this page · raw message

sha1_file.c +40 -1

65 lines not on this page · raw message

t/t5300-pack-object.sh +42 -37

153 lines not on this page · raw message

Signature · 1 line
1.0.GIT