Merge branch 'fixes'
This commit is contained in:
commit
d6179f56f8
@ -44,14 +44,16 @@ man: man1 man7
|
|||||||
man1: $(DOC_MAN1)
|
man1: $(DOC_MAN1)
|
||||||
man7: $(DOC_MAN7)
|
man7: $(DOC_MAN7)
|
||||||
|
|
||||||
install:
|
install: man
|
||||||
$(INSTALL) -d -m755 $(DESTDIR)/$(man1) $(DESTDIR)/$(man7)
|
$(INSTALL) -d -m755 $(DESTDIR)/$(man1) $(DESTDIR)/$(man7)
|
||||||
$(INSTALL) $(DOC_MAN1) $(DESTDIR)/$(man1)
|
$(INSTALL) $(DOC_MAN1) $(DESTDIR)/$(man1)
|
||||||
$(INSTALL) $(DOC_MAN7) $(DESTDIR)/$(man7)
|
$(INSTALL) $(DOC_MAN7) $(DESTDIR)/$(man7)
|
||||||
|
|
||||||
# 'include' dependencies
|
# 'include' dependencies
|
||||||
git-diff-%.txt: diff-format.txt diff-options.txt
|
$(patsubst %.txt,%.1,$(wildcard git-diff-*.txt)): \
|
||||||
touch $@
|
diff-format.txt diff-options.txt
|
||||||
|
$(patsubst %,%.1,git-fetch git-pull git-push): pull-fetch-param.txt
|
||||||
|
git.7: ../README
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html
|
rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html
|
||||||
|
47
fetch.c
47
fetch.c
@ -33,7 +33,7 @@ static void report_missing(const char *what, const unsigned char *missing)
|
|||||||
what, missing_hex, sha1_to_hex(current_commit_sha1));
|
what, missing_hex, sha1_to_hex(current_commit_sha1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process(unsigned char *sha1, const char *type);
|
static int process(struct object *obj);
|
||||||
|
|
||||||
static int process_tree(struct tree *tree)
|
static int process_tree(struct tree *tree)
|
||||||
{
|
{
|
||||||
@ -46,8 +46,7 @@ static int process_tree(struct tree *tree)
|
|||||||
tree->entries = NULL;
|
tree->entries = NULL;
|
||||||
while (entry) {
|
while (entry) {
|
||||||
struct tree_entry_list *next = entry->next;
|
struct tree_entry_list *next = entry->next;
|
||||||
if (process(entry->item.any->sha1,
|
if (process(entry->item.any))
|
||||||
entry->directory ? tree_type : blob_type))
|
|
||||||
return -1;
|
return -1;
|
||||||
free(entry);
|
free(entry);
|
||||||
entry = next;
|
entry = next;
|
||||||
@ -55,10 +54,9 @@ static int process_tree(struct tree *tree)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COMPLETE 1U
|
#define COMPLETE (1U << 0)
|
||||||
#define TO_FETCH 2U
|
#define SEEN (1U << 1)
|
||||||
#define TO_SCAN 4U
|
#define TO_SCAN (1U << 2)
|
||||||
#define SCANNED 8U
|
|
||||||
|
|
||||||
static struct commit_list *complete = NULL;
|
static struct commit_list *complete = NULL;
|
||||||
|
|
||||||
@ -79,7 +77,7 @@ static int process_commit(struct commit *commit)
|
|||||||
pull_say("walk %s\n", sha1_to_hex(commit->object.sha1));
|
pull_say("walk %s\n", sha1_to_hex(commit->object.sha1));
|
||||||
|
|
||||||
if (get_tree) {
|
if (get_tree) {
|
||||||
if (process(commit->tree->object.sha1, tree_type))
|
if (process(&commit->tree->object))
|
||||||
return -1;
|
return -1;
|
||||||
if (!get_all)
|
if (!get_all)
|
||||||
get_tree = 0;
|
get_tree = 0;
|
||||||
@ -87,7 +85,7 @@ static int process_commit(struct commit *commit)
|
|||||||
if (get_history) {
|
if (get_history) {
|
||||||
struct commit_list *parents = commit->parents;
|
struct commit_list *parents = commit->parents;
|
||||||
for (; parents; parents = parents->next) {
|
for (; parents; parents = parents->next) {
|
||||||
if (process(parents->item->object.sha1, commit_type))
|
if (process(&parents->item->object))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,7 +96,7 @@ static int process_tag(struct tag *tag)
|
|||||||
{
|
{
|
||||||
if (parse_tag(tag))
|
if (parse_tag(tag))
|
||||||
return -1;
|
return -1;
|
||||||
return process(tag->tagged->sha1, NULL);
|
return process(tag->tagged);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct object_list *process_queue = NULL;
|
static struct object_list *process_queue = NULL;
|
||||||
@ -106,10 +104,6 @@ static struct object_list **process_queue_end = &process_queue;
|
|||||||
|
|
||||||
static int process_object(struct object *obj)
|
static int process_object(struct object *obj)
|
||||||
{
|
{
|
||||||
if (obj->flags & SCANNED)
|
|
||||||
return 0;
|
|
||||||
obj->flags |= SCANNED;
|
|
||||||
|
|
||||||
if (obj->type == commit_type) {
|
if (obj->type == commit_type) {
|
||||||
if (process_commit((struct commit *)obj))
|
if (process_commit((struct commit *)obj))
|
||||||
return -1;
|
return -1;
|
||||||
@ -133,28 +127,23 @@ static int process_object(struct object *obj)
|
|||||||
obj->type, sha1_to_hex(obj->sha1));
|
obj->type, sha1_to_hex(obj->sha1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process(unsigned char *sha1, const char *type)
|
static int process(struct object *obj)
|
||||||
{
|
{
|
||||||
struct object *obj = lookup_object_type(sha1, type);
|
if (obj->flags & SEEN)
|
||||||
|
return 0;
|
||||||
|
obj->flags |= SEEN;
|
||||||
|
|
||||||
if (has_sha1_file(sha1)) {
|
if (has_sha1_file(obj->sha1)) {
|
||||||
parse_object(sha1);
|
|
||||||
/* We already have it, so we should scan it now. */
|
/* We already have it, so we should scan it now. */
|
||||||
if (obj->flags & (SCANNED | TO_SCAN))
|
|
||||||
return 0;
|
|
||||||
object_list_insert(obj, process_queue_end);
|
|
||||||
process_queue_end = &(*process_queue_end)->next;
|
|
||||||
obj->flags |= TO_SCAN;
|
obj->flags |= TO_SCAN;
|
||||||
|
} else {
|
||||||
|
if (obj->flags & COMPLETE)
|
||||||
return 0;
|
return 0;
|
||||||
|
prefetch(obj->sha1);
|
||||||
}
|
}
|
||||||
if (obj->flags & (COMPLETE | TO_FETCH))
|
|
||||||
return 0;
|
|
||||||
object_list_insert(obj, process_queue_end);
|
object_list_insert(obj, process_queue_end);
|
||||||
process_queue_end = &(*process_queue_end)->next;
|
process_queue_end = &(*process_queue_end)->next;
|
||||||
obj->flags |= TO_FETCH;
|
|
||||||
|
|
||||||
prefetch(sha1);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +217,7 @@ int pull(char *target)
|
|||||||
if (interpret_target(target, sha1))
|
if (interpret_target(target, sha1))
|
||||||
return error("Could not interpret %s as something to pull",
|
return error("Could not interpret %s as something to pull",
|
||||||
target);
|
target);
|
||||||
if (process(sha1, NULL))
|
if (process(lookup_unknown_object(sha1)))
|
||||||
return -1;
|
return -1;
|
||||||
if (loop())
|
if (loop())
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -152,7 +152,8 @@ yes,yes)
|
|||||||
# Look at objects/info/alternates for rsync -- http will
|
# Look at objects/info/alternates for rsync -- http will
|
||||||
# support it natively and git native ones will do it on the
|
# support it natively and git native ones will do it on the
|
||||||
# remote end. Not having that file is not a crime.
|
# remote end. Not having that file is not a crime.
|
||||||
rsync -q "$repo/objects/info/alternates" "$D/.git/TMP_ALT" ||
|
rsync -q "$repo/objects/info/alternates" \
|
||||||
|
"$D/.git/TMP_ALT" 2>/dev/null ||
|
||||||
rm -f "$D/.git/TMP_ALT"
|
rm -f "$D/.git/TMP_ALT"
|
||||||
if test -f "$D/.git/TMP_ALT"
|
if test -f "$D/.git/TMP_ALT"
|
||||||
then
|
then
|
||||||
|
@ -193,7 +193,8 @@ do
|
|||||||
# Look at objects/info/alternates for rsync -- http will
|
# Look at objects/info/alternates for rsync -- http will
|
||||||
# support it natively and git native ones will do it on the remote
|
# support it natively and git native ones will do it on the remote
|
||||||
# end. Not having that file is not a crime.
|
# end. Not having that file is not a crime.
|
||||||
rsync -q "$remote/objects/info/alternates" "$GIT_DIR/TMP_ALT" ||
|
rsync -q "$remote/objects/info/alternates" \
|
||||||
|
"$GIT_DIR/TMP_ALT" 2>/dev/null ||
|
||||||
rm -f "$GIT_DIR/TMP_ALT"
|
rm -f "$GIT_DIR/TMP_ALT"
|
||||||
if test -f "$GIT_DIR/TMP_ALT"
|
if test -f "$GIT_DIR/TMP_ALT"
|
||||||
then
|
then
|
||||||
|
29
http-fetch.c
29
http-fetch.c
@ -350,13 +350,18 @@ int fetch_object(struct alt_base *repo, unsigned char *sha1)
|
|||||||
char *hex = sha1_to_hex(sha1);
|
char *hex = sha1_to_hex(sha1);
|
||||||
char *filename = sha1_file_name(sha1);
|
char *filename = sha1_file_name(sha1);
|
||||||
unsigned char real_sha1[20];
|
unsigned char real_sha1[20];
|
||||||
|
char tmpfile[PATH_MAX];
|
||||||
|
int ret;
|
||||||
char *url;
|
char *url;
|
||||||
char *posn;
|
char *posn;
|
||||||
|
|
||||||
local = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
|
snprintf(tmpfile, sizeof(tmpfile), "%s/obj_XXXXXX",
|
||||||
|
get_object_directory());
|
||||||
|
|
||||||
|
local = mkstemp(tmpfile);
|
||||||
if (local < 0)
|
if (local < 0)
|
||||||
return error("Couldn't open local object %s\n", filename);
|
return error("Couldn't create temporary file %s for %s: %s\n",
|
||||||
|
tmpfile, filename, strerror(errno));
|
||||||
|
|
||||||
memset(&stream, 0, sizeof(stream));
|
memset(&stream, 0, sizeof(stream));
|
||||||
|
|
||||||
@ -386,18 +391,32 @@ int fetch_object(struct alt_base *repo, unsigned char *sha1)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fchmod(local, 0444);
|
||||||
close(local);
|
close(local);
|
||||||
inflateEnd(&stream);
|
inflateEnd(&stream);
|
||||||
SHA1_Final(real_sha1, &c);
|
SHA1_Final(real_sha1, &c);
|
||||||
if (zret != Z_STREAM_END) {
|
if (zret != Z_STREAM_END) {
|
||||||
unlink(filename);
|
unlink(tmpfile);
|
||||||
return error("File %s (%s) corrupt\n", hex, url);
|
return error("File %s (%s) corrupt\n", hex, url);
|
||||||
}
|
}
|
||||||
if (memcmp(sha1, real_sha1, 20)) {
|
if (memcmp(sha1, real_sha1, 20)) {
|
||||||
unlink(filename);
|
unlink(tmpfile);
|
||||||
return error("File %s has bad hash\n", hex);
|
return error("File %s has bad hash\n", hex);
|
||||||
}
|
}
|
||||||
|
ret = link(tmpfile, filename);
|
||||||
|
if (ret < 0) {
|
||||||
|
/* Same Coda hack as in write_sha1_file(sha1_file.c) */
|
||||||
|
ret = errno;
|
||||||
|
if (ret == EXDEV && !rename(tmpfile, filename))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
unlink(tmpfile);
|
||||||
|
if (ret) {
|
||||||
|
if (ret != EEXIST)
|
||||||
|
return error("unable to write sha1 filename %s: %s",
|
||||||
|
filename, strerror(ret));
|
||||||
|
}
|
||||||
|
out:
|
||||||
pull_say("got %s\n", hex);
|
pull_say("got %s\n", hex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user