Revert clock-skew based attempt to optimize tag --contains traversal
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 14, 2011 at 11:02 UTC
c6d72c49720aa333e9c646f447147e8e546df174
6 files changed
+3
-87
.gitignore
-1
@@ -132,7 +132,6 @@
132
/git-show-branch
133
/git-show-index
134
/git-show-ref
135
-/git-skew
135
/git-stage
136
/git-stash
137
/git-status
Makefile
-1
@@ -725,7 +725,6 @@ BUILTIN_OBJS += builtin/send-pack.o
725
BUILTIN_OBJS += builtin/shortlog.o
726
BUILTIN_OBJS += builtin/show-branch.o
727
BUILTIN_OBJS += builtin/show-ref.o
728
-BUILTIN_OBJS += builtin/skew.o
728
BUILTIN_OBJS += builtin/stripspace.o
729
BUILTIN_OBJS += builtin/symbolic-ref.o
730
BUILTIN_OBJS += builtin/tag.o
builtin.h
-1
@@ -141,6 +141,5 @@ extern int cmd_verify_pack(int argc, const char **argv, const char *prefix);
141
extern int cmd_show_ref(int argc, const char **argv, const char *prefix);
142
extern int cmd_pack_refs(int argc, const char **argv, const char *prefix);
143
extern int cmd_replace(int argc, const char **argv, const char *prefix);
144
-extern int cmd_skew(int argc, const char **argv, const char *prefix);
144
145
#endif
builtin/skew.c
deleted
-50
@@ -1,50 +0,0 @@
1
-#include "cache.h"
2
-#include "commit.h"
3
-#include "diff.h"
4
-#include "revision.h"
5
-
6
-unsigned long worst_skew = 0;
7
-
8
-static void check_skew_recurse(struct commit *c, unsigned long when)
9
-{
10
- struct commit_list *p;
11
-
12
- if (c->object.flags & SEEN)
13
- return;
14
- c->object.flags |= SEEN;
15
-
16
- if (parse_commit(c) < 0)
17
- return;
18
-
19
- if (c->date > when) {
20
- unsigned long skew = c->date - when;
21
- if (skew > worst_skew)
22
- worst_skew = skew;
23
- }
24
-
25
- for (p = c->parents; p; p = p->next)
26
- check_skew_recurse(p->item, c->date < when ? c->date : when);
27
-}
28
-
29
-static void check_skew(struct commit *c)
30
-{
31
- check_skew_recurse(c, time(NULL));
32
-}
33
-
34
-int cmd_skew(int argc, const char **argv, const char *prefix) {
35
- struct rev_info revs;
36
- int i;
37
-
38
- git_config(git_default_config, NULL);
39
- init_revisions(&revs, prefix);
40
- argc = setup_revisions(argc, argv, &revs, NULL);
41
-
42
- for (i = 0; i < revs.pending.nr; i++) {
43
- struct object *o = revs.pending.objects[i].item;
44
- if (o->type == OBJ_COMMIT)
45
- check_skew((struct commit *)o);
46
- }
47
-
48
- printf("%lu\n", worst_skew);
49
- return 0;
50
-}
builtin/tag.c
+3
-33
@@ -25,8 +25,6 @@ static const char * const git_tag_usage[] = {
25
26
static char signingkey[1000];
27
28
-static int core_clock_skew = 86400;
29
-
28
struct tag_filter {
29
const char *pattern;
30
int lines;
@@ -44,8 +42,7 @@ static int in_commit_list(const struct commit_list *want, struct commit *c)
42
}
43
44
static int contains_recurse(struct commit *candidate,
47
- const struct commit_list *want,
48
- unsigned long cutoff)
45
+ const struct commit_list *want)
46
{
47
struct commit_list *p;
48
@@ -62,13 +59,9 @@ static int contains_recurse(struct commit *candidate,
59
if (parse_commit(candidate) < 0)
60
return 0;
61
65
- /* stop searching if we go too far back in time */
66
- if (candidate->date < cutoff)
67
- return 0;
68
-
62
/* Otherwise recurse and mark ourselves for future traversals. */
63
for (p = candidate->parents; p; p = p->next) {
71
- if (contains_recurse(p->item, want, cutoff)) {
64
+ if (contains_recurse(p->item, want)) {
65
candidate->object.flags |= TMP_MARK;
66
return 1;
67
}
@@ -79,22 +72,7 @@ static int contains_recurse(struct commit *candidate,
72
73
static int contains(struct commit *candidate, const struct commit_list *want)
74
{
82
- unsigned long cutoff = 0;
83
-
84
- if (core_clock_skew >= 0) {
85
- const struct commit_list *c;
86
- unsigned long min_date = ULONG_MAX;
87
- for (c = want; c; c = c->next) {
88
- if (parse_commit(c->item) < 0)
89
- continue;
90
- if (c->item->date < min_date)
91
- min_date = c->item->date;
92
- }
93
- if (min_date > core_clock_skew)
94
- cutoff = min_date - core_clock_skew;
95
- }
96
-
97
- return contains_recurse(candidate, want, cutoff);
75
+ return contains_recurse(candidate, want);
76
}
77
78
static int show_reference(const char *refname, const unsigned char *sha1,
@@ -301,14 +279,6 @@ static int git_tag_config(const char *var, const char *value, void *cb)
279
return 0;
280
}
281
304
- if (!strcmp(var, "core.clockskew")) {
305
- if (!value || !strcmp(value, "none"))
306
- core_clock_skew = -1;
307
- else
308
- core_clock_skew = git_config_int(var, value);
309
- return 0;
310
- }
311
-
282
return git_default_config(var, value, cb);
283
}
284
git.c
-1
@@ -399,7 +399,6 @@ static void handle_internal_command(int argc, const char **argv)
399
{ "verify-pack", cmd_verify_pack },
400
{ "show-ref", cmd_show_ref, RUN_SETUP },
401
{ "pack-refs", cmd_pack_refs, RUN_SETUP },
402
- { "skew", cmd_skew, RUN_SETUP },
402
};
403
int i;
404
static const char ext[] = STRIP_EXTENSION;