summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b42a63)
raw | patch | inline | side by side (parent: 3b42a63)
author | Junio C Hamano <junkio@cox.net> | |
Thu, 2 Jun 2005 22:19:00 +0000 (15:19 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Thu, 2 Jun 2005 22:48:33 +0000 (15:48 -0700) |
When a remote repository is deltified, we need to get the
objects that a deltified object we want to obtain is based upon.
The initial parts of each retrieved SHA1 file is inflated and
inspected to see if it is deltified, and its base object is
asked from the remote side when it is. Since this partial
inflation and inspection has a small performance hit, it can
optionally be skipped by giving -d flag to git-*-pull commands.
This flag should be used only when the remote repository is
known to have no deltified objects.
Rsync transport does not have this problem since it fetches
everything the remote side has.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
objects that a deltified object we want to obtain is based upon.
The initial parts of each retrieved SHA1 file is inflated and
inspected to see if it is deltified, and its base object is
asked from the remote side when it is. Since this partial
inflation and inspection has a small performance hit, it can
optionally be skipped by giving -d flag to git-*-pull commands.
This flag should be used only when the remote repository is
known to have no deltified objects.
Rsync transport does not have this problem since it fetches
everything the remote side has.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Documentation/git-http-pull.txt | patch | blob | history | |
Documentation/git-local-pull.txt | patch | blob | history | |
Documentation/git-rpull.txt | patch | blob | history | |
cache.h | patch | blob | history | |
http-pull.c | patch | blob | history | |
local-pull.c | patch | blob | history | |
pull.c | patch | blob | history | |
pull.h | patch | blob | history | |
rpull.c | patch | blob | history | |
sha1_file.c | patch | blob | history |
index 59cd090a78cddeb4f820312892cc88f9c78ea542..8b54f09c223f0829ebf85cc4c5708e678fb4542a 100644 (file)
SYNOPSIS
--------
-'git-http-pull' [-c] [-t] [-a] [-v] commit-id url
+'git-http-pull' [-c] [-t] [-a] [-v] [-d] commit-id url
DESCRIPTION
-----------
Get trees associated with the commit objects.
-a::
Get all the objects.
+-d::
+ Do not check for delta base objects (use this option
+ only when you know the remote repository is not
+ deltified).
-v::
Report what is downloaded.
index 53f5d3968216044d35151c5f6e56285274e3a574..79d0f5c28f68f2634bc41de80b0c22a296aa6590 100644 (file)
SYNOPSIS
--------
-'git-local-pull' [-c] [-t] [-a] [-l] [-s] [-n] [-v] commit-id path
+'git-local-pull' [-c] [-t] [-a] [-l] [-s] [-n] [-v] [-d] commit-id path
DESCRIPTION
-----------
Get trees associated with the commit objects.
-a::
Get all the objects.
+-d::
+ Do not check for delta base objects (use this option
+ only when you know the remote repository is not
+ deltified).
-v::
Report what is downloaded.
index 1807fc571af5db105debd1f7d2e37a5095ea9e5c..3a8386629b7d05a2d6493815e232a8552a962585 100644 (file)
SYNOPSIS
--------
-'git-rpull' [-c] [-t] [-a] [-v] commit-id url
+'git-rpull' [-c] [-t] [-a] [-d] [-v] commit-id url
DESCRIPTION
-----------
Get trees associated with the commit objects.
-a::
Get all the objects.
+-d::
+ Do not check for delta base objects (use this option
+ only when you know the remote repository is not
+ deltified).
-v::
Report what is downloaded.
index aa74bcc0179fc20c4ddc490d6da4bf0730a2fb9e..e54176b4b572e7681ecbed1832b1b4ef4951d8bc 100644 (file)
--- a/cache.h
+++ b/cache.h
extern void * map_sha1_file(const unsigned char *sha1, unsigned long *size);
extern int unpack_sha1_header(z_stream *stream, void *map, unsigned long mapsize, void *buffer, unsigned long size);
extern int parse_sha1_header(char *hdr, char *type, unsigned long *sizep);
+extern int sha1_delta_base(const unsigned char *, unsigned char *);
extern void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, unsigned long *size);
extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
diff --git a/http-pull.c b/http-pull.c
index ba8585cfd4fcbe05b62a7ed2f0aa4ddbb625326e..551663e49234dc9b719ee4abb9f8dc8609d759aa 100644 (file)
--- a/http-pull.c
+++ b/http-pull.c
get_tree = 1;
} else if (argv[arg][1] == 'c') {
get_history = 1;
+ } else if (argv[arg][1] == 'd') {
+ get_delta = 0;
} else if (argv[arg][1] == 'a') {
get_all = 1;
get_tree = 1;
arg++;
}
if (argc < arg + 2) {
- usage("git-http-pull [-c] [-t] [-a] [-v] commit-id url");
+ usage("git-http-pull [-c] [-t] [-a] [-d] [-v] commit-id url");
return 1;
}
commit_id = argv[arg];
diff --git a/local-pull.c b/local-pull.c
index 10d4ca890502d03a72d82a4eb2556d76cdf6d2c7..e5d834ff2f7d6949ca2c7dd2424c65f6431a839b 100644 (file)
--- a/local-pull.c
+++ b/local-pull.c
}
static const char *local_pull_usage =
-"git-local-pull [-c] [-t] [-a] [-l] [-s] [-n] [-v] commit-id path";
+"git-local-pull [-c] [-t] [-a] [-l] [-s] [-n] [-v] [-d] commit-id path";
/*
* By default we only use file copy.
get_tree = 1;
else if (argv[arg][1] == 'c')
get_history = 1;
+ else if (argv[arg][1] == 'd')
+ get_delta = 0;
else if (argv[arg][1] == 'a') {
get_all = 1;
get_tree = 1;
index 0bed44f4cbf6716cfc3152f35626123992766408..cd77738ac62be17e7382bc3b368e686f11f7098d 100644 (file)
--- a/pull.c
+++ b/pull.c
int get_tree = 0;
int get_history = 0;
+int get_delta = 1;
int get_all = 0;
int get_verbosely = 0;
static unsigned char current_commit_sha1[20];
status = fetch(sha1);
if (status && what)
report_missing(what, sha1);
+ if (get_delta) {
+ char delta_sha1[20];
+ status = sha1_delta_base(sha1, delta_sha1);
+ if (0 < status)
+ status = make_sure_we_have_it(what, delta_sha1);
+ }
return status;
}
index d2dca02de7c23426e84e9f63762df9428933e8d8..3cd14cfb811a755a8770a0d01e8e2f96ba604058 100644 (file)
--- a/pull.h
+++ b/pull.h
/** Set to fetch the trees in the commit history. **/
extern int get_all;
+/* Set to zero to skip the check for delta object base. */
+extern int get_delta;
+
/* Set to be verbose */
extern int get_verbosely;
index 36e49f799a6ac300a00f8d09d9dc9e6636b3d8e0..8b3322fe0798d8d74c54817d020ff1478d4a25d4 100644 (file)
--- a/rpull.c
+++ b/rpull.c
get_tree = 1;
} else if (argv[arg][1] == 'c') {
get_history = 1;
+ } else if (argv[arg][1] == 'd') {
+ get_delta = 0;
} else if (argv[arg][1] == 'a') {
get_all = 1;
get_tree = 1;
arg++;
}
if (argc < arg + 2) {
- usage("git-rpull [-c] [-t] [-a] [-v] commit-id url");
+ usage("git-rpull [-c] [-t] [-a] [-v] [-d] commit-id url");
return 1;
}
commit_id = argv[arg];
diff --git a/sha1_file.c b/sha1_file.c
index af39e8860ec55d420c724a079be02379288e3f61..ccfcca07c76297ea9295f7bcf174a35edf814b2e 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -401,6 +401,37 @@ void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, unsigned l
return unpack_sha1_rest(&stream, hdr, *size);
}
+int sha1_delta_base(const unsigned char *sha1, unsigned char *base_sha1)
+{
+ int ret;
+ unsigned long mapsize, size;
+ void *map;
+ z_stream stream;
+ char hdr[64], type[20];
+ void *delta_data_head;
+
+ map = map_sha1_file(sha1, &mapsize);
+ if (!map)
+ return -1;
+ ret = unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr));
+ if (ret < Z_OK || parse_sha1_header(hdr, type, &size) < 0) {
+ ret = -1;
+ goto out;
+ }
+ if (strcmp(type, "delta")) {
+ ret = 0;
+ goto out;
+ }
+
+ delta_data_head = hdr + strlen(hdr) + 1;
+ ret = 1;
+ memcpy(base_sha1, delta_data_head, 20);
+ out:
+ inflateEnd(&stream);
+ munmap(map, mapsize);
+ return ret;
+}
+
void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size)
{
unsigned long mapsize;