Skip to content

Commit d44c782

Browse files
committed
Merge branch 'sv/objfixes'
* sv/objfixes: Don't assume tree entries that are not dirs are blobs git-cvsimport: Make sure to use $git_dir always instead of .git sometimes fix documentation of unpack-objects -n Accept dates before 2000/01/01 when specified as seconds since the epoch
2 parents f07dfba + e2ac7cb commit d44c782

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

Documentation/git-unpack-objects.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ new packs and replace existing ones.
2727
OPTIONS
2828
-------
2929
-n::
30-
Only list the objects that would be unpacked, don't actually unpack
31-
them.
30+
Dry run. Check the pack file without actually unpacking
31+
the objects.
3232

3333
-q::
3434
The command usually shows percentage progress. This

date.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,11 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
414414
num = strtoul(date, &end, 10);
415415

416416
/*
417-
* Seconds since 1970? We trigger on that for anything after Jan 1, 2000
417+
* Seconds since 1970? We trigger on that for any numbers with
418+
* more than 8 digits. This is because we don't want to rule out
419+
* numbers like 20070606 as a YYYYMMDD date.
418420
*/
419-
if (num > 946684800) {
421+
if (num >= 100000000) {
420422
time_t time = num;
421423
if (gmtime_r(&time, tm)) {
422424
*tm_gmt = 1;

git-cvsimport.perl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ sub commit {
692692
if ($branch eq $opt_o && !$index{branch} && !get_headref($branch, $git_dir)) {
693693
# looks like an initial commit
694694
# use the index primed by git-init
695-
$ENV{GIT_INDEX_FILE} = '.git/index';
696-
$index{$branch} = '.git/index';
695+
$ENV{GIT_INDEX_FILE} = "$git_dir/index";
696+
$index{$branch} = "$git_dir/index";
697697
} else {
698698
# use an index per branch to speed up
699699
# imports of projects with many branches
@@ -984,7 +984,7 @@ sub commit {
984984
}
985985
986986
foreach my $git_index (values %index) {
987-
if ($git_index ne '.git/index') {
987+
if ($git_index ne "$git_dir/index") {
988988
unlink($git_index);
989989
}
990990
}

object.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
160160
parse_tag_buffer(tag, buffer, size);
161161
obj = &tag->object;
162162
} else {
163+
warning("object %s has unknown type id %d\n", sha1_to_hex(sha1), type);
163164
obj = NULL;
164165
}
166+
if (obj && obj->type == OBJ_NONE)
167+
obj->type = type;
165168
*eaten_p = eaten;
166169
return obj;
167170
}

tree.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,13 @@ static void track_tree_refs(struct tree *item)
173173
continue;
174174
if (S_ISDIR(entry.mode))
175175
obj = &lookup_tree(entry.sha1)->object;
176-
else
176+
else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode))
177177
obj = &lookup_blob(entry.sha1)->object;
178+
else {
179+
warning("in tree %s: entry %s has bad mode %.6o\n",
180+
sha1_to_hex(item->object.sha1), entry.path, entry.mode);
181+
obj = lookup_unknown_object(entry.sha1);
182+
}
178183
refs->ref[i++] = obj;
179184
}
180185
set_object_refs(&item->object, refs);

0 commit comments

Comments
 (0)