From 7054b6089d413f3d466491f1e6e8f565f4aff031 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 21 Mar 2007 22:11:35 -0700 Subject: [PATCH 01/45] t6002: minor spelling fix. The test expects --bisect option can be configured with by setting $_bisect_option. So let's allow that uniformly. Signed-off-by: Junio C Hamano --- t/t6002-rev-list-bisect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh index 7831e3461c..fcb3302764 100755 --- a/t/t6002-rev-list-bisect.sh +++ b/t/t6002-rev-list-bisect.sh @@ -163,7 +163,7 @@ test_sequence() # the bisection point is the head - this is the bad point. # -test_output_expect_success "--bisect l5 ^root" 'git-rev-list $_bisect_option l5 ^root' < Date: Wed, 21 Mar 2007 22:15:54 -0700 Subject: [PATCH 02/45] git-rev-list: add --bisect-vars option. This adds --bisect-vars option to rev-list. The output is suitable for `eval` in shell and defines five variables: - bisect_rev is the next revision to test. - bisect_nr is the expected number of commits to test after bisect_rev is tested. - bisect_good is the expected number of commits to test if bisect_rev turns out to be good. - bisect_bad is the expected number of commits to test if bisect_rev turns out to be bad. - bisect_all is the number of commits we are bisecting right now. The documentation text was partly stolen from Johannes Schindelin's patch. Signed-off-by: Junio C Hamano --- Documentation/git-rev-list.txt | 13 ++++++++ builtin-rev-list.c | 54 ++++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 4f145eaba4..3fa45b81cc 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -26,6 +26,7 @@ SYNOPSIS [ [\--objects | \--objects-edge] [ \--unpacked ] ] [ \--pretty | \--header ] [ \--bisect ] + [ \--bisect-vars ] [ \--merge ] [ \--reverse ] [ \--walk-reflogs ] @@ -249,6 +250,18 @@ introduces a regression is thus reduced to a binary search: repeatedly generate and test new 'midpoint's until the commit chain is of length one. +--bisect-vars:: + +This calculates the same as `--bisect`, but outputs text ready +to be eval'ed by the shell. These lines will assign the name of +the midpoint revision to the variable `bisect_rev`, and the +expected number of commits to be tested after `bisect_rev` is +tested to `bisect_nr`, the expected number of commits to be +tested if `bisect_rev` turns out to be good to `bisect_good`, +the expected number of commits to be tested if `bisect_rev` +turns out to be bad to `bisect_bad`, and the number of commits +we are bisecting right now to `bisect_all`. + -- Commit Ordering diff --git a/builtin-rev-list.c b/builtin-rev-list.c index c2db5a5b03..723e4d419c 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -36,7 +36,8 @@ static const char rev_list_usage[] = " --abbrev=nr | --no-abbrev\n" " --abbrev-commit\n" " special purpose:\n" -" --bisect" +" --bisect\n" +" --bisect-vars" ; static struct rev_info revs; @@ -168,7 +169,8 @@ static void clear_distance(struct commit_list *list) } } -static struct commit_list *find_bisection(struct commit_list *list) +static struct commit_list *find_bisection(struct commit_list *list, + int *reaches, int *all) { int nr, closest; struct commit_list *p, *best; @@ -180,21 +182,23 @@ static struct commit_list *find_bisection(struct commit_list *list) nr++; p = p->next; } + *all = nr; closest = 0; best = list; for (p = list; p; p = p->next) { - int distance; + int distance, reach; if (revs.prune_fn && !(p->item->object.flags & TREECHANGE)) continue; - distance = count_distance(p); + distance = reach = count_distance(p); clear_distance(list); if (nr - distance < distance) distance = nr - distance; if (distance > closest) { best = p; + *reaches = reach; closest = distance; } } @@ -225,6 +229,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) struct commit_list *list; int i; int read_from_stdin = 0; + int bisect_show_vars = 0; git_config(git_default_config); init_revisions(&revs, prefix); @@ -247,6 +252,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) bisect_list = 1; continue; } + if (!strcmp(arg, "--bisect-vars")) { + bisect_list = 1; + bisect_show_vars = 1; + continue; + } if (!strcmp(arg, "--stdin")) { if (read_from_stdin++) die("--stdin given twice?"); @@ -285,8 +295,40 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) if (revs.tree_objects) mark_edges_uninteresting(revs.commits, &revs, show_edge); - if (bisect_list) - revs.commits = find_bisection(revs.commits); + if (bisect_list) { + int reaches = reaches, all = all; + + revs.commits = find_bisection(revs.commits, + &reaches, &all); + if (bisect_show_vars) { + int cnt; + if (!revs.commits) + return 1; + /* + * revs.commits can reach "reaches" commits among + * "all" commits. If it is good, then there are + * (all-reaches) commits left to be bisected. + * On the other hand, if it is bad, then the set + * to bisect is "reaches". + * A bisect set of size N has (N-1) commits further + * to test, as we already know one bad one. + */ + cnt = all-reaches; + if (cnt < reaches) + cnt = reaches; + printf("bisect_rev=%s\n" + "bisect_nr=%d\n" + "bisect_good=%d\n" + "bisect_bad=%d\n" + "bisect_all=%d\n", + sha1_to_hex(revs.commits->item->object.sha1), + cnt - 1, + all - reaches - 1, + reaches - 1, + all); + return 0; + } + } traverse_commit_list(&revs, show_commit, show_object); From 1c4fea3a40e836dcee2f16091bf7bfba96c924d0 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 21 Mar 2007 22:16:24 -0700 Subject: [PATCH 03/45] git-rev-list --bisect: optimization This improves the performance of revision bisection. The idea is to avoid rather expensive count_distance() function, which counts the number of commits that are reachable from any given commit (including itself) in the set. When a commit has only one relevant parent commit, the number of commits the commit can reach is exactly the number of commits that the parent can reach plus one; instead of running count_distance() on commits that are on straight single strand of pearls, we can just add one to the parents' count. On the other hand, for a merge commit, because the commits reachable from one parent can be reachable from another parent, you cannot just add the parents' counts up plus one for the commit itself; that would overcount ancestors that are reachable from more than one parents. The algorithm used in the patch runs count_distance() on merge commits, and uses the util field of commit objects to remember them. After that, the number of commits reachable from each of the remaining commits is counted by finding a commit whose count is not yet known but the count for its (sole) parent is known, and adding one to the parent's count, until we assign numbers to everybody. Another small optimization is whenever we find a half-way commit (that is, a commit that can reach exactly half of the commits), we stop giving counts to remaining commits, as we will not find any better commit than we just found. The performance to bisect between v1.0.0 and v1.5.0 in git.git repository was improved by saying good and bad in turns from 3.68 seconds down to 1.26 seconds. Bisecting the kernel between v2.6.18 and v2.6.20 was sped up from 21.84 seconds down to 4.22 seconds. Signed-off-by: Junio C Hamano --- builtin-rev-list.c | 162 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 160 insertions(+), 2 deletions(-) diff --git a/builtin-rev-list.c b/builtin-rev-list.c index 723e4d419c..b395ffeb03 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -207,6 +207,160 @@ static struct commit_list *find_bisection(struct commit_list *list, return best; } +static inline int commit_interesting(struct commit_list *elem) +{ + unsigned flags = elem->item->object.flags; + if (flags & UNINTERESTING) + return 0; + return (!revs.prune_fn || (flags & TREECHANGE)); +} + +static inline int weight(struct commit_list *elem) +{ + return *((int*)(elem->item->util)); +} + +static inline void weight_set(struct commit_list *elem, int weight) +{ + *((int*)(elem->item->util)) = weight; +} + +static int count_interesting_parents(struct commit_list *elem) +{ + int cnt = 0; + if (!elem->item->parents) + return cnt; + for (elem = elem->item->parents; elem; elem = elem->next) { + if (commit_interesting(elem)) + cnt++; + } + return cnt; +} + +static struct commit_list *find_bisection_2(struct commit_list *list, + int *reaches, int *all) +{ + int n, nr, counted, distance; + struct commit_list *p, *best; + int *weights; + + for (nr = 0, p = list; p; p = p->next) { + if (commit_interesting(p)) + nr++; + } + *all = nr; + weights = xcalloc(nr, sizeof(int*)); + counted = 0; + + for (n = 0, p = list; p; p = p->next) { + if (!commit_interesting(p)) + continue; + if (commit_interesting(p)) { + /* + * positive weight is the number of interesting + * commits it can reach, including itself. + * weight = 0 means it has one parent and + * its distance is unknown. + * weight < 0 means it has more than one + * parent and its distance is unknown. + */ + p->item->util = &weights[n++]; + switch (count_interesting_parents(p)) { + case 0: + weight_set(p, 1); + counted++; + break; + case 1: + weight_set(p, 0); + break; + default: + weight_set(p, -1); + break; + } + } + } + + /* + * If you have only one parent in the resulting set + * then you can reach one commit more than that parent + * can reach. So we do not have to run the expensive + * count_distance() for single strand of pearls. + * + * However, if you have more than one parents, you cannot + * just add their distance and one for yourself, since + * they usually reach the same ancestor and you would + * end up counting them twice that way. + * + * So we will first count distance of merges the usual + * way, and then fill the blanks using cheaper algorithm. + */ + for (p = list; p; p = p->next) { + if (!commit_interesting(p)) + continue; + n = weight(p); + if (0 <= n) + continue; + distance = count_distance(p); + clear_distance(p); + weight_set(p, distance); + + /* Does it happen to be at exactly half-way? */ + distance *= 2; + if (nr == distance || (nr+1) == distance) { + p->next = NULL; + *reaches = weight(p); + free(weights); + return p; + } + counted++; + } + + while (counted < nr) { + for (p = list; p; p = p->next) { + struct commit_list *q; + + if (!commit_interesting(p) || 0 < weight(p)) + continue; + for (q = p->item->parents; q; q = q->next) + if (commit_interesting(q) && 0 < weight(q)) + break; + if (!q) + continue; + weight_set(p, weight(q)+1); + counted++; + + /* Does it happen to be at exactly half-way? */ + distance = weight(p) * 2; + if (nr == distance || (nr+1) == distance) { + p->next = NULL; + *reaches = weight(p); + free(weights); + return p; + } + } + } + + /* Then find the best one */ + counted = 0; + best = list; + for (p = list; p; p = p->next) { + if (!commit_interesting(p)) + continue; + distance = weight(p); + if (nr - distance < distance) + distance = nr - distance; + if (distance > counted) { + best = p; + counted = distance; + *reaches = weight(p); + } + } + if (best) + best->next = NULL; + free(weights); + return best; +} + static void read_revisions_from_stdin(struct rev_info *revs) { char line[1000]; @@ -298,8 +452,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) if (bisect_list) { int reaches = reaches, all = all; - revs.commits = find_bisection(revs.commits, - &reaches, &all); + if (!revs.prune_fn) + revs.commits = find_bisection_2(revs.commits, + &reaches, &all); + else + revs.commits = find_bisection(revs.commits, + &reaches, &all); if (bisect_show_vars) { int cnt; if (!revs.commits) From bab36bf57d7a565e0077e1f5d2e3a10afa319ecc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 22 Mar 2007 23:22:07 -0700 Subject: [PATCH 04/45] t6004: add a bit more path optimization test. Signed-off-by: Junio C Hamano --- t/t6004-rev-list-path-optim.sh | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/t/t6004-rev-list-path-optim.sh b/t/t6004-rev-list-path-optim.sh index 5182dbb158..761f09b1e5 100755 --- a/t/t6004-rev-list-path-optim.sh +++ b/t/t6004-rev-list-path-optim.sh @@ -7,7 +7,8 @@ test_description='git-rev-list trivial path optimization test' test_expect_success setup ' echo Hello > a && git add a && -git commit -m "Initial commit" a +git commit -m "Initial commit" a && +initial=$(git rev-parse --verify HEAD) ' test_expect_success path-optimization ' @@ -16,4 +17,35 @@ test_expect_success path-optimization ' test $(git-rev-list $commit -- . | wc -l) = 1 ' +test_expect_success 'further setup' ' + git checkout -b side && + echo Irrelevant >c && + git add c && + git commit -m "Side makes an irrelevant commit" && + echo "More Irrelevancy" >c && + git add c && + git commit -m "Side makes another irrelevant commit" && + echo Bye >a && + git add a && + git commit -m "Side touches a" && + side=$(git rev-parse --verify HEAD) && + echo "Yet more Irrelevancy" >c && + git add c && + git commit -m "Side makes yet another irrelevant commit" && + git checkout master && + echo Another >b && + git add b && + git commit -m "Master touches b" && + git merge side && + echo Touched >b && + git add b && + git commit -m "Master touches b again" +' + +test_expect_success 'path optimization 2' ' + ( echo "$side"; echo "$initial" ) >expected && + git rev-list HEAD -- a >actual && + diff -u expected actual +' + test_done From 2a4646904a3766abeca7741f15a481d79e97e9e7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 Mar 2007 00:40:54 -0700 Subject: [PATCH 05/45] rev-list --bisect: Fix "halfway" optimization. If you have 5 commits in the set, commits that reach 2 or 3 commits are at halfway. If you have 6 commits, only commits that reach exactly 3 commits are at halfway. The earlier one is completely botched the math. Signed-off-by: Junio C Hamano --- builtin-rev-list.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/builtin-rev-list.c b/builtin-rev-list.c index 09e3a60bf6..7075548e6b 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -237,6 +237,27 @@ static int count_interesting_parents(struct commit_list *elem) return cnt; } +static inline int halfway(struct commit_list *p, int distance, int nr) +{ + /* + * Don't short-cut something we are not going to return! + */ + if (revs.prune_fn && !(p->item->object.flags & TREECHANGE)) + return 0; + + /* + * 2 and 3 are halfway of 5. + * 3 is halfway of 6 but 2 and 4 are not. + */ + distance *= 2; + switch (distance - nr) { + case -1: case 0: case 1: + return 1; + default: + return 0; + } +} + static struct commit_list *find_bisection_2(struct commit_list *list, int *reaches, int *all) { @@ -305,10 +326,9 @@ static struct commit_list *find_bisection_2(struct commit_list *list, weight_set(p, distance); /* Does it happen to be at exactly half-way? */ - distance *= 2; - if (nr == distance || (nr+1) == distance) { + if (halfway(p, distance, nr)) { p->next = NULL; - *reaches = weight(p); + *reaches = distance; free(weights); return p; } @@ -330,10 +350,10 @@ static struct commit_list *find_bisection_2(struct commit_list *list, counted++; /* Does it happen to be at exactly half-way? */ - distance = weight(p) * 2; - if (nr == distance || (nr+1) == distance) { + distance = weight(p); + if (halfway(p, distance, nr)) { p->next = NULL; - *reaches = weight(p); + *reaches = distance; free(weights); return p; } From 1daa09d9a833d3969b64e763865a58df56bc3871 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 Mar 2007 17:54:03 -0700 Subject: [PATCH 06/45] make the previous optimization work also on path-limited rev-list --bisect The trick is to give a child commit that is not tree-changing the same depth as its parent, so that the depth is propagated properly along strand of pearls. Signed-off-by: Junio C Hamano --- builtin-rev-list.c | 249 +++++++++++++++++++++++++++------------------ 1 file changed, 151 insertions(+), 98 deletions(-) diff --git a/builtin-rev-list.c b/builtin-rev-list.c index 7075548e6b..f91685a406 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -169,51 +169,7 @@ static void clear_distance(struct commit_list *list) } } -static struct commit_list *find_bisection(struct commit_list *list, - int *reaches, int *all) -{ - int nr, closest; - struct commit_list *p, *best; - - nr = 0; - p = list; - while (p) { - if (!revs.prune_fn || (p->item->object.flags & TREECHANGE)) - nr++; - p = p->next; - } - closest = -1; - best = list; - *all = nr; - - for (p = list; p; p = p->next) { - int distance, reach; - - if (revs.prune_fn && !(p->item->object.flags & TREECHANGE)) - continue; - - distance = reach = count_distance(p); - clear_distance(list); - if (nr - distance < distance) - distance = nr - distance; - if (distance > closest) { - best = p; - *reaches = reach; - closest = distance; - } - } - if (best) - best->next = NULL; - return best; -} - -static inline int commit_interesting(struct commit_list *elem) -{ - unsigned flags = elem->item->object.flags; - if (flags & UNINTERESTING) - return 0; - return (!revs.prune_fn || (flags & TREECHANGE)); -} +#define DEBUG_BISECT 0 static inline int weight(struct commit_list *elem) { @@ -225,16 +181,17 @@ static inline void weight_set(struct commit_list *elem, int weight) *((int*)(elem->item->util)) = weight; } -static int count_interesting_parents(struct commit_list *elem) +static int count_interesting_parents(struct commit *commit) { - int cnt = 0; - if (!elem->item->parents) - return cnt; - for (elem = elem->item->parents; elem; elem = elem->next) { - if (commit_interesting(elem)) - cnt++; + struct commit_list *p; + int count; + + for (count = 0, p = commit->parents; p; p = p->next) { + if (p->item->object.flags & UNINTERESTING) + continue; + count++; } - return cnt; + return count; } static inline int halfway(struct commit_list *p, int distance, int nr) @@ -244,7 +201,8 @@ static inline int halfway(struct commit_list *p, int distance, int nr) */ if (revs.prune_fn && !(p->item->object.flags & TREECHANGE)) return 0; - + if (DEBUG_BISECT) + return 0; /* * 2 and 3 are halfway of 5. * 3 is halfway of 6 but 2 and 4 are not. @@ -258,49 +216,127 @@ static inline int halfway(struct commit_list *p, int distance, int nr) } } -static struct commit_list *find_bisection_2(struct commit_list *list, - int *reaches, int *all) +#if !DEBUG_BISECT +#define show_list(a,b,c,d) do { ; } while (0) +#else +static void show_list(const char *debug, int counted, int nr, + struct commit_list *list) { - int n, nr, counted, distance; - struct commit_list *p, *best; + struct commit_list *p; + + fprintf(stderr, "%s (%d/%d)\n", debug, counted, nr); + + for (p = list; p; p = p->next) { + struct commit_list *pp; + struct commit *commit = p->item; + unsigned flags = commit->object.flags; + enum object_type type; + unsigned long size; + char *buf = read_sha1_file(commit->object.sha1, &type, &size); + char *ep, *sp; + + fprintf(stderr, "%c%c%c ", + (flags & TREECHANGE) ? 'T' : ' ', + (flags & UNINTERESTING) ? 'U' : ' ', + (flags & COUNTED) ? 'C' : ' '); + if (commit->util) + fprintf(stderr, "%3d", weight(p)); + else + fprintf(stderr, "---"); + fprintf(stderr, " %.*s", 8, sha1_to_hex(commit->object.sha1)); + for (pp = commit->parents; pp; pp = pp->next) + fprintf(stderr, " %.*s", 8, + sha1_to_hex(pp->item->object.sha1)); + + sp = strstr(buf, "\n\n"); + if (sp) { + sp += 2; + for (ep = sp; *ep && *ep != '\n'; ep++) + ; + fprintf(stderr, " %.*s", (int)(ep - sp), sp); + } + fprintf(stderr, "\n"); + } +} +#endif /* DEBUG_BISECT */ + +/* + * zero or positive weight is the number of interesting commits it can + * reach, including itself. Especially, weight = 0 means it does not + * reach any tree-changing commits (e.g. just above uninteresting one + * but traversal is with pathspec). + * + * weight = -1 means it has one parent and its distance is yet to + * be computed. + * + * weight = -2 means it has more than one parent and its distance is + * unknown. After running count_distance() first, they will get zero + * or positive distance. + */ + +static struct commit_list *find_bisection(struct commit_list *list, + int *reaches, int *all) +{ + int n, nr, on_list, counted, distance; + struct commit_list *p, *best, *next, *last; int *weights; - for (nr = 0, p = list; p; p = p->next) { - if (commit_interesting(p)) + show_list("bisection 2 entry", 0, 0, list); + + /* + * Count the number of total and tree-changing items on the + * list, while reversing the list. + */ + for (nr = on_list = 0, last = NULL, p = list; + p; + p = next) { + unsigned flags = p->item->object.flags; + + next = p->next; + if (flags & UNINTERESTING) + continue; + p->next = last; + last = p; + if (!revs.prune_fn || (flags & TREECHANGE)) nr++; + on_list++; } + list = last; + show_list("bisection 2 sorted", 0, nr, list); + *all = nr; - weights = xcalloc(nr, sizeof(int*)); + weights = xcalloc(on_list, sizeof(int*)); counted = 0; for (n = 0, p = list; p; p = p->next) { - if (!commit_interesting(p)) - continue; - if (commit_interesting(p)) { - /* - * positive weight is the number of interesting - * commits it can reach, including itself. - * weight = 0 means it has one parent and - * its distance is unknown. - * weight < 0 means it has more than one - * parent and its distance is unknown. - */ - p->item->util = &weights[n++]; - switch (count_interesting_parents(p)) { - case 0: + struct commit *commit = p->item; + unsigned flags = commit->object.flags; + + p->item->util = &weights[n++]; + switch (count_interesting_parents(commit)) { + case 0: + if (!revs.prune_fn || (flags & TREECHANGE)) { weight_set(p, 1); counted++; - break; - case 1: - weight_set(p, 0); - break; - default: - weight_set(p, -1); - break; + show_list("bisection 2 count one", + counted, nr, list); } + /* + * otherwise, it is known not to reach any + * tree-changing commit and gets weight 0. + */ + break; + case 1: + weight_set(p, -1); + break; + default: + weight_set(p, -2); + break; } } + show_list("bisection 2 initialize", counted, nr, list); + /* * If you have only one parent in the resulting set * then you can reach one commit more than that parent @@ -316,13 +352,13 @@ static struct commit_list *find_bisection_2(struct commit_list *list, * way, and then fill the blanks using cheaper algorithm. */ for (p = list; p; p = p->next) { - if (!commit_interesting(p)) + if (p->item->object.flags & UNINTERESTING) continue; n = weight(p); - if (0 <= n) + if (n != -2) continue; distance = count_distance(p); - clear_distance(p); + clear_distance(list); weight_set(p, distance); /* Does it happen to be at exactly half-way? */ @@ -335,19 +371,37 @@ static struct commit_list *find_bisection_2(struct commit_list *list, counted++; } + show_list("bisection 2 count_distance", counted, nr, list); + while (counted < nr) { for (p = list; p; p = p->next) { struct commit_list *q; + unsigned flags = p->item->object.flags; - if (!commit_interesting(p) || 0 < weight(p)) + if (0 <= weight(p)) continue; - for (q = p->item->parents; q; q = q->next) - if (commit_interesting(q) && 0 < weight(q)) + for (q = p->item->parents; q; q = q->next) { + if (q->item->object.flags & UNINTERESTING) + continue; + if (0 <= weight(q)) break; + } if (!q) continue; - weight_set(p, weight(q)+1); - counted++; + + /* + * weight for p is unknown but q is known. + * add one for p itself if p is to be counted, + * otherwise inherit it from q directly. + */ + if (!revs.prune_fn || (flags & TREECHANGE)) { + weight_set(p, weight(q)+1); + counted++; + show_list("bisection 2 count one", + counted, nr, list); + } + else + weight_set(p, weight(q)); /* Does it happen to be at exactly half-way? */ distance = weight(p); @@ -360,11 +414,15 @@ static struct commit_list *find_bisection_2(struct commit_list *list, } } + show_list("bisection 2 counted all", counted, nr, list); + /* Then find the best one */ - counted = 0; + counted = -1; best = list; for (p = list; p; p = p->next) { - if (!commit_interesting(p)) + unsigned flags = p->item->object.flags; + + if (revs.prune_fn && !(flags & TREECHANGE)) continue; distance = weight(p); if (nr - distance < distance) @@ -472,12 +530,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) if (bisect_list) { int reaches = reaches, all = all; - if (!revs.prune_fn) - revs.commits = find_bisection_2(revs.commits, - &reaches, &all); - else - revs.commits = find_bisection(revs.commits, - &reaches, &all); + revs.commits = find_bisection(revs.commits, &reaches, &all); if (bisect_show_vars) { int cnt; if (!revs.commits) From 7b8a74f39cbd58b514dce963e7a571904508661b Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 25 Mar 2007 13:56:49 +0200 Subject: [PATCH 07/45] Documentation: Replace @@GIT_VERSION@@ in documentation Include GIT-VERSION-FILE and replace @@GIT_VERSION@@ in the HTML and XML asciidoc output. The documentation doesn't depend on GIT-VERSION-FILE so it will not be automatically rebuild if nothing else changed. [jc: fixing the case for interrupted build] Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- Documentation/Makefile | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 7db3fb992f..e82596dcdf 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -65,6 +65,11 @@ install: man $(INSTALL) -m644 $(DOC_MAN7) $(DESTDIR)$(man7dir) +../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE + $(MAKE) -C ../ GIT-VERSION-FILE + +-include ../GIT-VERSION-FILE + # # Determine "include::" file references in asciidoc files. # @@ -91,17 +96,25 @@ $(cmds_txt): cmd-list.perl $(MAN1_TXT) git.7 git.html: git.txt core-intro.txt clean: - rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep + rm -f *.xml *.xml+ *.html *.html+ *.1 *.7 howto-index.txt howto/*.html doc.dep rm -f $(cmds_txt) %.html : %.txt - $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf $(ASCIIDOC_EXTRA) $< + rm -f $@+ $@ + $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ + $(ASCIIDOC_EXTRA) -o - $< | \ + sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+ + mv $@+ $@ %.1 %.7 : %.xml xmlto -m callouts.xsl man $< %.xml : %.txt - $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf $< + rm -f $@+ $@ + $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \ + $(ASCIIDOC_EXTRA) -o - $< | \ + sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+ + mv $@+ $@ user-manual.xml: user-manual.txt user-manual.conf $(ASCIIDOC) -b docbook -d book $< @@ -132,3 +145,5 @@ install-webdoc : html quick-install: sh ./install-doc-quick.sh $(DOC_REF) $(mandir) + +.PHONY: .FORCE-GIT-VERSION-FILE From 7ef195ba3efe0ffa815e12afc4cb1e39a21ddfb4 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 25 Mar 2007 13:56:50 +0200 Subject: [PATCH 08/45] Documentation: Add version information to man pages Override the [header] macro of asciidoc's docbook backend to add version information to the generated man pages. Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- Documentation/asciidoc.conf | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf index 44b1ce4c6b..a86c31d00a 100644 --- a/Documentation/asciidoc.conf +++ b/Documentation/asciidoc.conf @@ -31,6 +31,23 @@ ifdef::backend-docbook[] {title#} endif::backend-docbook[] +ifdef::backend-docbook[] +[header] +template::[header-declarations] + + +{mantitle} +{manvolnum} +Git +@@GIT_VERSION@@ +Git Manual + + + {manname} + {manpurpose} + +endif::backend-docbook[] + ifdef::backend-xhtml11[] [gitlink-inlinemacro] {target}{0?({0})} From d3d4fa86319a0bf97752e285907a8d34a2824951 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 26 Mar 2007 23:45:23 -0700 Subject: [PATCH 09/45] Documentation: unbreak user-manual. The previous one broke generated xml files for anything but manpages, as it took the header for manpage unconditionally. This fixes it. Signed-off-by: Junio C Hamano --- Documentation/asciidoc.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf index a86c31d00a..fa7dc94845 100644 --- a/Documentation/asciidoc.conf +++ b/Documentation/asciidoc.conf @@ -31,6 +31,7 @@ ifdef::backend-docbook[] {title#} endif::backend-docbook[] +ifdef::doctype-manpage[] ifdef::backend-docbook[] [header] template::[header-declarations] @@ -47,6 +48,7 @@ template::[header-declarations] {manpurpose} endif::backend-docbook[] +endif::doctype-manpage[] ifdef::backend-xhtml11[] [gitlink-inlinemacro] From 9fc42d609197ef331f1c5b2ce5ef6fc9f2ee634f Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 30 Mar 2007 20:39:30 -0700 Subject: [PATCH 10/45] Optimize directory listing with pathspec limiter. The way things are set up, you can now pass a "pathspec" to the "read_directory()" function. If you pass NULL, it acts exactly like it used to do (read everything). If you pass a non-NULL pointer, it will simplify it into a "these are the prefixes without any special characters", and stop any readdir() early if the path in question doesn't match any of the prefixes. NOTE! This does *not* obviate the need for the caller to do the *exact* pathspec match later. It's a first-level filter on "read_directory()", but it does not do the full pathspec thing. Maybe it should. But in the meantime, builtin-add.c really does need to do first read_directory(dir, .., pathspec); if (pathspec) prune_directory(dir, pathspec, baselen); ie the "prune_directory()" part will do the *exact* pathspec pruning, while the "read_directory()" will use the pathspec just to do some quick high-level pruning of the directories it will recurse into. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- builtin-add.c | 2 +- builtin-ls-files.c | 2 +- dir.c | 96 +++++++++++++++++++++++++++++++++++++++++++--- dir.h | 2 +- wt-status.c | 2 +- 5 files changed, 95 insertions(+), 9 deletions(-) diff --git a/builtin-add.c b/builtin-add.c index 9fcf514dbc..871e23f0f6 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -87,7 +87,7 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec) } /* Read the directory and prune it */ - read_directory(dir, path, base, baselen); + read_directory(dir, path, base, baselen, pathspec); if (pathspec) prune_directory(dir, pathspec, baselen); } diff --git a/builtin-ls-files.c b/builtin-ls-files.c index 4e1d5af634..74a6acacc1 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -216,7 +216,7 @@ static void show_files(struct dir_struct *dir, const char *prefix) if (baselen) path = base = prefix; - read_directory(dir, path, base, baselen); + read_directory(dir, path, base, baselen, pathspec); if (show_others) show_other_files(dir); if (show_killed) diff --git a/dir.c b/dir.c index b48e19dc09..7426fde330 100644 --- a/dir.c +++ b/dir.c @@ -8,6 +8,11 @@ #include "cache.h" #include "dir.h" +struct path_simplify { + int len; + const char *path; +}; + int common_prefix(const char **pathspec) { const char *path, *slash, *next; @@ -292,6 +297,31 @@ static int dir_exists(const char *dirname, int len) return !strncmp(active_cache[pos]->name, dirname, len); } +/* + * This is an inexact early pruning of any recursive directory + * reading - if the path cannot possibly be in the pathspec, + * return true, and we'll skip it early. + */ +static int simplify_away(const char *path, int pathlen, const struct path_simplify *simplify) +{ + if (simplify) { + for (;;) { + const char *match = simplify->path; + int len = simplify->len; + + if (!match) + break; + if (len > pathlen) + len = pathlen; + if (!memcmp(path, match, len)) + return 0; + simplify++; + } + return 1; + } + return 0; +} + /* * Read a directory tree. We currently ignore anything but * directories, regular files and symlinks. That's because git @@ -301,7 +331,7 @@ static int dir_exists(const char *dirname, int len) * Also, we ignore the name ".git" (even if it is not a directory). * That likely will not change. */ -static int read_directory_recursive(struct dir_struct *dir, const char *path, const char *base, int baselen, int check_only) +static int read_directory_recursive(struct dir_struct *dir, const char *path, const char *base, int baselen, int check_only, const struct path_simplify *simplify) { DIR *fdir = opendir(path); int contents = 0; @@ -324,6 +354,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co continue; len = strlen(de->d_name); memcpy(fullname + baselen, de->d_name, len+1); + if (simplify_away(fullname, baselen + len, simplify)) + continue; if (excluded(dir, fullname) != dir->show_ignored) { if (!dir->show_ignored || DTYPE(de) != DT_DIR) { continue; @@ -350,13 +382,13 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co if (dir->hide_empty_directories && !read_directory_recursive(dir, fullname, fullname, - baselen + len, 1)) + baselen + len, 1, simplify)) continue; break; } contents += read_directory_recursive(dir, - fullname, fullname, baselen + len, 0); + fullname, fullname, baselen + len, 0, simplify); continue; case DT_REG: case DT_LNK: @@ -386,8 +418,61 @@ static int cmp_name(const void *p1, const void *p2) e2->name, e2->len); } -int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen) +/* + * Return the length of the "simple" part of a path match limiter. + */ +static int simple_length(const char *match) { + const char special[256] = { + [0] = 1, ['?'] = 1, + ['\\'] = 1, ['*'] = 1, + ['['] = 1 + }; + int len = -1; + + for (;;) { + unsigned char c = *match++; + len++; + if (special[c]) + return len; + } +} + +static struct path_simplify *create_simplify(const char **pathspec) +{ + int nr, alloc = 0; + struct path_simplify *simplify = NULL; + + if (!pathspec) + return NULL; + + for (nr = 0 ; ; nr++) { + const char *match; + if (nr >= alloc) { + alloc = alloc_nr(alloc); + simplify = xrealloc(simplify, alloc * sizeof(*simplify)); + } + match = *pathspec++; + if (!match) + break; + simplify[nr].path = match; + simplify[nr].len = simple_length(match); + } + simplify[nr].path = NULL; + simplify[nr].len = 0; + return simplify; +} + +static void free_simplify(struct path_simplify *simplify) +{ + if (simplify) + free(simplify); +} + +int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen, const char **pathspec) +{ + struct path_simplify *simplify = create_simplify(pathspec); + /* * Make sure to do the per-directory exclude for all the * directories leading up to our base. @@ -414,7 +499,8 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i } } - read_directory_recursive(dir, path, base, baselen, 0); + read_directory_recursive(dir, path, base, baselen, 0, simplify); + free_simplify(simplify); qsort(dir->entries, dir->nr, sizeof(struct dir_entry *), cmp_name); return dir->nr; } diff --git a/dir.h b/dir.h index 7233d65bbd..33c31f25fb 100644 --- a/dir.h +++ b/dir.h @@ -48,7 +48,7 @@ extern int common_prefix(const char **pathspec); #define MATCHED_EXACTLY 3 extern int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen); -extern int read_directory(struct dir_struct *, const char *path, const char *base, int baselen); +extern int read_directory(struct dir_struct *, const char *path, const char *base, int baselen, const char **pathspec); extern int push_exclude_per_directory(struct dir_struct *, const char *, int); extern void pop_exclude_per_directory(struct dir_struct *, int); diff --git a/wt-status.c b/wt-status.c index a25632bc87..a0559905a0 100644 --- a/wt-status.c +++ b/wt-status.c @@ -260,7 +260,7 @@ static void wt_status_print_untracked(struct wt_status *s) if (file_exists(x)) add_excludes_from_file(&dir, x); - read_directory(&dir, ".", "", 0); + read_directory(&dir, ".", "", 0, NULL); for(i = 0; i < dir.nr; i++) { /* check for matching entry, which is unmerged; lifted from * builtin-ls-files:show_other_files */ From 02f0559ebafffac3af362ea1b1b0ee009090efa1 Mon Sep 17 00:00:00 2001 From: Xavier Maillard Date: Mon, 26 Mar 2007 23:00:54 +0200 Subject: [PATCH 11/45] git-blame.el: separate git-blame-mode to ease maintenance git-blame-mode has been splitted into git-blame-mode-on and git-blame-mode-off; it now conditionnaly calls one of them depending of how we call it. Code is now easier to maintain and to understand. Fixed `git-reblame' function: interactive form was at the wrong place. String displayed on the mode line is now configurable through `git-blame-mode-line-string` (default to " blame"). Signed-off-by: Xavier Maillard Signed-off-by: Junio C Hamano --- contrib/emacs/git-blame.el | 55 +++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el index 64ad50b327..c03ea3e4a7 100644 --- a/contrib/emacs/git-blame.el +++ b/contrib/emacs/git-blame.el @@ -127,39 +127,58 @@ (defvar git-blame-mode nil) (make-variable-buffer-local 'git-blame-mode) -(unless (assq 'git-blame-mode minor-mode-alist) - (setq minor-mode-alist - (cons (list 'git-blame-mode " blame") - minor-mode-alist))) + +(defvar git-blame-mode-line-string " blame" + "String to display on the mode line when git-blame is active.") + +(or (assq 'git-blame-mode minor-mode-alist) + (setq minor-mode-alist + (cons '(git-blame-mode git-blame-mode-line-string) minor-mode-alist))) ;;;###autoload (defun git-blame-mode (&optional arg) - "Minor mode for displaying Git blame" + "Toggle minor mode for displaying Git blame + +With prefix ARG, turn the mode on if ARG is positive." (interactive "P") - (if arg - (setq git-blame-mode (eq arg 1)) - (setq git-blame-mode (not git-blame-mode))) + (cond + ((null arg) + (if git-blame-mode (git-blame-mode-off) (git-blame-mode-on))) + ((> (prefix-numeric-value arg) 0) (git-blame-mode-on)) + (t (git-blame-mode-off)))) + +(defun git-blame-mode-on () + "Turn on git-blame mode. + +See also function `git-blame-mode'." (make-local-variable 'git-blame-colors) (if git-blame-autoupdate (add-hook 'after-change-functions 'git-blame-after-change nil t) (remove-hook 'after-change-functions 'git-blame-after-change t)) (git-blame-cleanup) - (if git-blame-mode - (progn - (let ((bgmode (cdr (assoc 'background-mode (frame-parameters))))) - (if (eq bgmode 'dark) - (setq git-blame-colors git-blame-dark-colors) - (setq git-blame-colors git-blame-light-colors))) - (setq git-blame-cache (make-hash-table :test 'equal)) - (git-blame-run)) - (cancel-timer git-blame-idle-timer))) + (let ((bgmode (cdr (assoc 'background-mode (frame-parameters))))) + (if (eq bgmode 'dark) + (setq git-blame-colors git-blame-dark-colors) + (setq git-blame-colors git-blame-light-colors))) + (setq git-blame-cache (make-hash-table :test 'equal)) + (setq git-blame-mode t) + (git-blame-run)) + +(defun git-blame-mode-off () + "Turn off git-blame mode. + +See also function `git-blame-mode'." + (git-blame-cleanup) + (if git-blame-idle-timer (cancel-timer git-blame-idle-timer)) + (setq git-blame-mode nil)) ;;;###autoload (defun git-reblame () "Recalculate all blame information in the current buffer" + (interactive) (unless git-blame-mode (error "git-blame is not active")) - (interactive) + (git-blame-cleanup) (git-blame-run)) From 3cc5ca3923c4db78d638fb94a3dfb70f103267bf Mon Sep 17 00:00:00 2001 From: Xavier Maillard Date: Wed, 28 Mar 2007 18:44:34 +0200 Subject: [PATCH 12/45] git-blame.el: pick a set of random colors for each git-blame turn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I thought it would be cool to have different set of colors for each git-blame-mode. Function `git-blame-new-commit' does this for us picking when possible, a random colors based on the set we build on startup. When it fails, `git-blame-ancient-color' will be used. We also take care not to use the same color more than once (thank you David Kågedal, really). * Prevent (future possible) namespace clash by renaming `color-scale' into `git-blame-color-scale'. Definition has been changed to be more in the "lisp" way (thanks for help to #emacs). Also added a small description of what it does. * Added docstrings at some point and instructed defvar when a variable was candidate to customisation by users. * Added missing defvar to silent byte-compilers (git-blame-file, git-blame-current) * Do not require 'cl at startup * Added more informations on compatibility Signed-off-by: Xavier Maillard Acked-by: David Kågedal Signed-off-by: Junio C Hamano --- contrib/emacs/git-blame.el | 81 +++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 27 deletions(-) diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el index c03ea3e4a7..bb671d561e 100644 --- a/contrib/emacs/git-blame.el +++ b/contrib/emacs/git-blame.el @@ -8,8 +8,8 @@ ;; License: GPL ;; Keywords: git, version control, release management ;; -;; Compatibility: Emacs21 - +;; Compatibility: Emacs21, Emacs22 and EmacsCVS +;; Git 1.5 and up ;; This file is *NOT* part of GNU Emacs. ;; This file is distributed under the same terms as GNU Emacs. @@ -61,8 +61,9 @@ ;;; Compatibility: ;; -;; It requires GNU Emacs 21. If you'are using Emacs 20, try -;; changing this: +;; It requires GNU Emacs 21 or later and Git 1.5.0 and up +;; +;; If you'are using Emacs 20, try changing this: ;; ;; (overlay-put ovl 'face (list :background ;; (cdr (assq 'color (cddddr info))))) @@ -77,30 +78,51 @@ ;; ;;; Code: -(require 'cl) ; to use `push', `pop' +(eval-when-compile (require 'cl)) ; to use `push', `pop' -(defun color-scale (l) - (let* ((colors ()) - r g b) - (setq r l) - (while r - (setq g l) - (while g - (setq b l) - (while b - (push (concat "#" (car r) (car g) (car b)) colors) - (pop b)) - (pop g)) - (pop r)) - colors)) + +(defun git-blame-color-scale (&rest elements) + "Given a list, returns a list of triples formed with each +elements of the list. + +a b => bbb bba bab baa abb aba aaa aab" + (let (result) + (dolist (a elements) + (dolist (b elements) + (dolist (c elements) + (setq result (cons (format "#%s%s%s" a b c) result))))) + result)) + +;; (git-blame-color-scale "0c" "04" "24" "1c" "2c" "34" "14" "3c") => +;; ("#3c3c3c" "#3c3c14" "#3c3c34" "#3c3c2c" "#3c3c1c" "#3c3c24" +;; "#3c3c04" "#3c3c0c" "#3c143c" "#3c1414" "#3c1434" "#3c142c" ...) + +(defmacro git-blame-random-pop (l) + "Select a random element from L and returns it. Also remove +selected element from l." + ;; only works on lists with unique elements + `(let ((e (elt ,l (random (length ,l))))) + (setq ,l (remove e ,l)) + e)) (defvar git-blame-dark-colors - (color-scale '("0c" "04" "24" "1c" "2c" "34" "14" "3c"))) + (git-blame-color-scale "0c" "04" "24" "1c" "2c" "34" "14" "3c") + "*List of colors (format #RGB) to use in a dark environment. + +To check out the list, evaluate (list-colors-display git-blame-dark-colors).") (defvar git-blame-light-colors - (color-scale '("c4" "d4" "cc" "dc" "f4" "e4" "fc" "ec"))) + (git-blame-color-scale "c4" "d4" "cc" "dc" "f4" "e4" "fc" "ec") + "*List of colors (format #RGB) to use in a light environment. -(defvar git-blame-ancient-color "dark green") +To check out the list, evaluate (list-colors-display git-blame-light-colors).") + +(defvar git-blame-colors '() + "Colors used by git-blame. The list is built once when activating git-blame +minor mode.") + +(defvar git-blame-ancient-color "dark green" + "*Color to be used for ancient commit.") (defvar git-blame-autoupdate t "*Automatically update the blame display while editing") @@ -125,6 +147,10 @@ "A queue of update requests") (make-variable-buffer-local 'git-blame-update-queue) +;; FIXME: docstrings +(defvar git-blame-file nil) +(defvar git-blame-current nil) + (defvar git-blame-mode nil) (make-variable-buffer-local 'git-blame-mode) @@ -177,7 +203,7 @@ See also function `git-blame-mode'." "Recalculate all blame information in the current buffer" (interactive) (unless git-blame-mode - (error "git-blame is not active")) + (error "Git-blame is not active")) (git-blame-cleanup) (git-blame-run)) @@ -294,7 +320,6 @@ See also function `git-blame-mode'." (t nil))) - (defun git-blame-new-commit (hash src-line res-line num-lines) (save-excursion (set-buffer git-blame-file) @@ -302,9 +327,11 @@ See also function `git-blame-mode'." (inhibit-point-motion-hooks t) (inhibit-modification-hooks t)) (when (not info) - (let ((color (pop git-blame-colors))) - (unless color - (setq color git-blame-ancient-color)) + ;; Assign a random color to each new commit info + ;; Take care not to select the same color multiple times + (let ((color (if git-blame-colors + (git-blame-random-pop git-blame-colors) + git-blame-ancient-color))) (setq info (list hash src-line res-line num-lines (git-describe-commit hash) (cons 'color color)))) From 7878b383d6c87824d7c33fa5bfcd0c38aa3f51f5 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Tue, 27 Mar 2007 14:26:01 +0400 Subject: [PATCH 13/45] Add the WITH_P4IMPORT knob to the Makefile. WITH_P4IMPORT: enables the installation of the Perforce import script. Signed-off-by: Eygene Ryabinkin Signed-off-by: Junio C Hamano --- Makefile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Makefile b/Makefile index b159ffd0ae..bc8b70bf1c 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,8 @@ all:: # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's # MakeMaker (e.g. using ActiveState under Cygwin). # +# Define WITH_P4IMPORT to build and install Python git-p4import script. +# GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE @$(SHELL_PATH) ./GIT-VERSION-GEN @@ -196,9 +198,20 @@ SCRIPT_PERL = \ git-svnimport.perl git-cvsexportcommit.perl \ git-send-email.perl git-svn.perl +SCRIPT_PYTHON = \ + git-p4import.py + +ifdef WITH_P4IMPORT +SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ + $(patsubst %.perl,%,$(SCRIPT_PERL)) \ + $(patsubst %.py,%,$(SCRIPT_PYTHON)) \ + git-status git-instaweb +else SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ git-status git-instaweb +endif + # ... and all the rest that could be moved out of bindir to gitexecdir PROGRAMS = \ @@ -241,6 +254,9 @@ endif ifndef PERL_PATH PERL_PATH = /usr/bin/perl endif +ifndef PYTHON_PATH + PYTHON_PATH = /usr/local/bin/python +endif export PERL_PATH @@ -646,6 +662,7 @@ prefix_SQ = $(subst ','\'',$(prefix)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH)) LIBS = $(GITLIBS) $(EXTLIBS) @@ -699,6 +716,15 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak +$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py + rm -f $@ $@+ + sed -e '1s|#!.*/python|#!$(PYTHON_PATH_SQ)|' \ + -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ + -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ + $@.py >$@+ + chmod +x $@+ + mv $@+ $@ + perl/perl.mak: GIT-CFLAGS $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F) From 7a585c0e6ad872af9a7b88c7c4760a2c606be1ec Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Tue, 27 Mar 2007 15:25:15 +0400 Subject: [PATCH 14/45] Added git-p4 package to the list of git RPMs. Signed-off-by: Eygene Ryabinkin Signed-off-by: Junio C Hamano --- git.spec.in | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/git.spec.in b/git.spec.in index 46aee88fd1..e469f213d8 100644 --- a/git.spec.in +++ b/git.spec.in @@ -50,6 +50,13 @@ Requires: git-core = %{version}-%{release}, tla %description arch Git tools for importing Arch repositories. +%package p4 +Summary: Git tools for importing Perforce repositories +Group: Development/Tools +Requires: git-core = %{version}-%{release}, python +%description p4 +Git tools for importing Perforce repositories. + %package email Summary: Git tools for sending email Group: Development/Tools @@ -86,22 +93,22 @@ Perl interface to Git %build make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" WITH_OWN_SUBPROCESS_PY=YesPlease \ - prefix=%{_prefix} all %{!?_without_docs: doc} + WITH_P4IMPORT=YesPlease prefix=%{_prefix} all %{!?_without_docs: doc} %install rm -rf $RPM_BUILD_ROOT make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" DESTDIR=$RPM_BUILD_ROOT \ - WITH_OWN_SUBPROCESS_PY=YesPlease \ + WITH_OWN_SUBPROCESS_PY=YesPlease WITH_P4IMPORT=YesPlease \ prefix=%{_prefix} mandir=%{_mandir} INSTALLDIRS=vendor \ install %{!?_without_docs: install-doc} find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ';' find $RPM_BUILD_ROOT -type f -name '*.bs' -empty -exec rm -f {} ';' find $RPM_BUILD_ROOT -type f -name perllocal.pod -exec rm -f {} ';' -(find $RPM_BUILD_ROOT%{_bindir} -type f | grep -vE "archimport|svn|cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@) > bin-man-doc-files +(find $RPM_BUILD_ROOT%{_bindir} -type f | grep -vE "p4import|archimport|svn|cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@) > bin-man-doc-files (find $RPM_BUILD_ROOT%{perl_vendorlib} -type f | sed -e s@^$RPM_BUILD_ROOT@@) >> perl-files %if %{!?_without_docs:1}0 -(find $RPM_BUILD_ROOT%{_mandir} $RPM_BUILD_ROOT/Documentation -type f | grep -vE "archimport|svn|git-cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@ -e 's/$/*/' ) >> bin-man-doc-files +(find $RPM_BUILD_ROOT%{_mandir} $RPM_BUILD_ROOT/Documentation -type f | grep -vE "p4import|archimport|svn|git-cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@ -e 's/$/*/' ) >> bin-man-doc-files %else rm -rf $RPM_BUILD_ROOT%{_mandir} %endif @@ -133,6 +140,13 @@ rm -rf $RPM_BUILD_ROOT %{!?_without_docs: %{_mandir}/man1/git-archimport.1*} %{!?_without_docs: %doc Documentation/git-archimport.html } +%files p4 +%defattr(-,root,root) +%doc Documentation/git-p4import.txt +%{_bindir}/git-p4import +%{!?_without_docs: %{_mandir}/man1/git-p4import.1*} +%{!?_without_docs: %doc Documentation/git-p4import.html } + %files email %defattr(-,root,root) %doc Documentation/*email*.txt @@ -167,6 +181,9 @@ rm -rf $RPM_BUILD_ROOT %{!?_without_docs: %doc Documentation/*.html } %changelog +* Tue Mar 27 2007 Eygene Ryabinkin +- Added the git-p4 package: Perforce import stuff. + * Mon Feb 13 2007 Nicolas Pitre - Update core package description (Git isn't as stupid as it used to be) From 5250929d6010083779d334634dcd6766de045b1f Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Tue, 27 Mar 2007 12:03:43 -0400 Subject: [PATCH 15/45] Remove unused WITH_OWN_SUBPROCESS_PY from RPM spec We don't have a copy of subprocess.py anymore, so we removed that option from the Makefile. Let's not leave that cruft around the RPM spec file either. Signed-off-by: Junio C Hamano --- git.spec.in | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/git.spec.in b/git.spec.in index e469f213d8..4bf7a8f618 100644 --- a/git.spec.in +++ b/git.spec.in @@ -92,15 +92,14 @@ Perl interface to Git %setup -q %build -make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" WITH_OWN_SUBPROCESS_PY=YesPlease \ - WITH_P4IMPORT=YesPlease prefix=%{_prefix} all %{!?_without_docs: doc} +make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" WITH_P4IMPORT=YesPlease \ + prefix=%{_prefix} all %{!?_without_docs: doc} %install rm -rf $RPM_BUILD_ROOT make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" DESTDIR=$RPM_BUILD_ROOT \ - WITH_OWN_SUBPROCESS_PY=YesPlease WITH_P4IMPORT=YesPlease \ - prefix=%{_prefix} mandir=%{_mandir} INSTALLDIRS=vendor \ - install %{!?_without_docs: install-doc} + WITH_P4IMPORT=YesPlease prefix=%{_prefix} mandir=%{_mandir} \ + INSTALLDIRS=vendor install %{!?_without_docs: install-doc} find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ';' find $RPM_BUILD_ROOT -type f -name '*.bs' -empty -exec rm -f {} ';' find $RPM_BUILD_ROOT -type f -name perllocal.pod -exec rm -f {} ';' From faced1af7112353bcb67e033cd2a4fb47e21b201 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Thu, 29 Mar 2007 14:07:47 +0400 Subject: [PATCH 16/45] Added correct Python path to the RPM specfile. Signed-off-by: Eygene Ryabinkin Signed-off-by: Junio C Hamano --- git.spec.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git.spec.in b/git.spec.in index 4bf7a8f618..1d3934bba5 100644 --- a/git.spec.in +++ b/git.spec.in @@ -1,4 +1,7 @@ # Pass --without docs to rpmbuild if you don't want the documentation + +%define python_path /usr/bin/python + Name: git Version: @@VERSION@@ Release: 1%{?dist} @@ -93,12 +96,13 @@ Perl interface to Git %build make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" WITH_P4IMPORT=YesPlease \ - prefix=%{_prefix} all %{!?_without_docs: doc} + prefix=%{_prefix} PYTHON_PATH=%{python_path} all %{!?_without_docs: doc} %install rm -rf $RPM_BUILD_ROOT make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" DESTDIR=$RPM_BUILD_ROOT \ WITH_P4IMPORT=YesPlease prefix=%{_prefix} mandir=%{_mandir} \ + PYTHON_PATH=%{python_path} \ INSTALLDIRS=vendor install %{!?_without_docs: install-doc} find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ';' find $RPM_BUILD_ROOT -type f -name '*.bs' -empty -exec rm -f {} ';' From 3cfaf11b1dc742dcbbf48dd3d6a5ce376e23a2b8 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Wed, 28 Mar 2007 04:00:23 -0700 Subject: [PATCH 17/45] NO_TCLTK Makefile knob named NO_TCLTK was introduced. It prevents the build and installation of the Tcl/Tk dependent parts. Signed-off-by: Eygene Ryabinkin --- Makefile | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b159ffd0ae..0797ad4a99 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,8 @@ all:: # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's # MakeMaker (e.g. using ActiveState under Cygwin). # +# Define NO_TCLTK if you do not want Tcl/Tk GUI. +# GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE @$(SHELL_PATH) ./GIT-VERSION-GEN @@ -231,6 +233,12 @@ BUILT_INS = \ # what 'all' will build and 'install' will install, in gitexecdir ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) +# what 'all' will build but not install in gitexecdir +OTHER_PROGRAMS = git$X gitweb/gitweb.cgi +ifndef NO_TCLTK +OTHER_PROGRAMS += gitk +endif + # Backward compatibility -- to be removed after 1.0 PROGRAMS += git-ssh-pull$X git-ssh-push$X @@ -661,13 +669,15 @@ export prefix gitexecdir TAR INSTALL DESTDIR SHELL_PATH template_dir ### Build rules -all:: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi +all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) ifneq (,$X) $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), rm -f '$p';) endif all:: +ifndef NO_TCLTK $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all +endif $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) @@ -892,10 +902,13 @@ install: all $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)' $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)' - $(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)' + $(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)' $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install $(MAKE) -C perl prefix='$(prefix_SQ)' install +ifndef NO_TCLTK + $(INSTALL) gitk '$(DESTDIR_SQ)$(bindir_SQ)' $(MAKE) -C git-gui install +endif if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \ then \ ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \ @@ -974,9 +987,11 @@ clean: rm -f gitweb/gitweb.cgi $(MAKE) -C Documentation/ clean $(MAKE) -C perl clean - $(MAKE) -C git-gui clean $(MAKE) -C templates/ clean $(MAKE) -C t/ clean +ifndef NO_TCLTK + $(MAKE) -C git-gui clean +endif rm -f GIT-VERSION-FILE GIT-CFLAGS .PHONY: all install clean strip From 81b63c707ed5962d45bd575c946a7127c19a3e35 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Wed, 28 Mar 2007 04:12:07 -0700 Subject: [PATCH 18/45] Add --with-tcltk and --without-tcltk to configure. --with-tcltk enables the search of the Tcl/Tk interpreter. If no interpreter is found then Tcl/Tk dependend parts are disabled. --without-tcltk unconditionally disables Tcl/Tk dependent parts. The original behaviour is not changed: bare './configure' just installs the Tcl/Tk part doing no checks for the interpreter. Signed-off-by: Eygene Ryabinkin --- Makefile | 12 +++++++++++- config.mak.in | 1 + configure.ac | 26 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0797ad4a99..da086a7fed 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,10 @@ all:: # # Define NO_TCLTK if you do not want Tcl/Tk GUI. # +# The TCLTK_PATH variable governs the location of the Tck/Tk interpreter. +# If not set it defaults to the bare 'wish'. If it is set to the empty +# string then NO_TCLTK will be forced (this is used by configure script). +# GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE @$(SHELL_PATH) ./GIT-VERSION-GEN @@ -161,6 +165,7 @@ AR = ar TAR = tar INSTALL = install RPMBUILD = rpmbuild +TCLTK_PATH = wish # sparse is architecture-neutral, which means that we need to tell it # explicitly what architecture to check for. Fix this up for yours.. @@ -616,6 +621,10 @@ ifdef NO_PERL_MAKEMAKER export NO_PERL_MAKEMAKER endif +ifeq ($(TCLTK_PATH),) +NO_TCLTK=NoThanks +endif + QUIET_SUBDIR0 = $(MAKE) -C # space to separate -C and subdir QUIET_SUBDIR1 = @@ -654,6 +663,7 @@ prefix_SQ = $(subst ','\'',$(prefix)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) LIBS = $(GITLIBS) $(EXTLIBS) @@ -676,7 +686,7 @@ endif all:: ifndef NO_TCLTK - $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all + $(QUIET_SUBDIR0)git-gui TCLTK_PATH='$(TCLTK_PATH_SQ)' $(QUIET_SUBDIR1) all endif $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) diff --git a/config.mak.in b/config.mak.in index 9a578405d8..eb9d7a5549 100644 --- a/config.mak.in +++ b/config.mak.in @@ -6,6 +6,7 @@ CFLAGS = @CFLAGS@ AR = @AR@ TAR = @TAR@ #INSTALL = @INSTALL@ # needs install-sh or install.sh in sources +TCLTK_PATH = @TCLTK_PATH@ prefix = @prefix@ exec_prefix = @exec_prefix@ diff --git a/configure.ac b/configure.ac index 3a8e778def..01fa0f0bda 100644 --- a/configure.ac +++ b/configure.ac @@ -75,6 +75,14 @@ GIT_ARG_SET_PATH(shell) # Define PERL_PATH to provide path to Perl. GIT_ARG_SET_PATH(perl) # +# Declare the with-tcltk/without-tcltk options. +AC_ARG_WITH(tcltk, +AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)]) +AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.]) +AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if]) +AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),\ +GIT_PARSE_WITH(tcltk)) +# ## Checks for programs. @@ -84,6 +92,24 @@ AC_PROG_CC([cc gcc]) #AC_PROG_INSTALL # needs install-sh or install.sh in sources AC_CHECK_TOOL(AR, ar, :) AC_CHECK_PROGS(TAR, [gtar tar]) +# TCLTK_PATH will be set to some value if we want Tcl/Tk +# or will be empty otherwise. +if test -z "$NO_TCLTK"; then + if test "$with_tcltk" = ""; then + # No Tcl/Tk switches given. Do not check for Tcl/Tk, use bare 'wish'. + TCLTK_PATH=wish + AC_SUBST(TCLTK_PATH) + elif test "$with_tcltk" = "yes"; then + # Tcl/Tk check requested. + AC_CHECK_PROGS(TCLTK_PATH, [wish], ) + elif test -x "$with_tcltk"; then + AC_MSG_RESULT([Using Tcl/Tk interpreter $with_tcltk]) + TCLTK_PATH="$with_tcltk" + AC_SUBST(TCLTK_PATH) + else + AC_MSG_ERROR([Tcl/Tk interpreter was not found in $with_tcltk]) + fi +fi ## Checks for libraries. AC_MSG_NOTICE([CHECKS for libraries]) From 6bdb18a9cef9124937941c6e5bd2b645c9da6537 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Wed, 28 Mar 2007 04:22:02 -0700 Subject: [PATCH 19/45] Rewrite Tcl/Tk interpreter path for the GUI tools. --with-tcltk=/path/to/wish sets the TCLTK_PATH variable that is used to substitute the location of the wish interpreter in the Tcl/Tk programs. New tracking file, GIT-GUI-VARS, was introduced: it tracks the location of the Tcl/Tk interpreter and activates the GUI tools rebuild if the interpreter path was changed. The separate tracker is better than the GIT-CFLAGS: there is no need to rebuild the whole git if the interpreter path was changed. Signed-off-by: Eygene Ryabinkin --- Makefile | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index da086a7fed..88f9025e4c 100644 --- a/Makefile +++ b/Makefile @@ -241,7 +241,7 @@ ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) # what 'all' will build but not install in gitexecdir OTHER_PROGRAMS = git$X gitweb/gitweb.cgi ifndef NO_TCLTK -OTHER_PROGRAMS += gitk +OTHER_PROGRAMS += gitk-wish endif # Backward compatibility -- to be removed after 1.0 @@ -694,6 +694,12 @@ endif strip: $(PROGRAMS) git$X $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X +gitk-wish: gitk GIT-GUI-VARS + $(QUIET_GEN)rm -f $@ $@+ && \ + sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' $@+ && \ + chmod +x $@+ && \ + mv -f $@+ $@ + git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS $(QUIET_LINK)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \ $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \ @@ -872,6 +878,20 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS echo "$$FLAGS" >GIT-CFLAGS; \ fi +### Detect Tck/Tk interpreter path changes +ifndef NO_TCLTK +TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)') + +GIT-GUI-VARS: .FORCE-GIT-GUI-VARS + @VARS='$(TRACK_VARS)'; \ + if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \ + echo 1>&2 " * new Tcl/Tk interpreter location"; \ + echo "$$VARS" >$@; \ + fi + +.PHONY: .FORCE-GIT-GUI-VARS +endif + ### Testing rules # GNU make supports exporting all variables by "export" without parameters. @@ -916,7 +936,7 @@ install: all $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install $(MAKE) -C perl prefix='$(prefix_SQ)' install ifndef NO_TCLTK - $(INSTALL) gitk '$(DESTDIR_SQ)$(bindir_SQ)' + $(INSTALL) gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk $(MAKE) -C git-gui install endif if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \ @@ -1000,9 +1020,10 @@ clean: $(MAKE) -C templates/ clean $(MAKE) -C t/ clean ifndef NO_TCLTK + rm -f gitk-wish $(MAKE) -C git-gui clean endif - rm -f GIT-VERSION-FILE GIT-CFLAGS + rm -f GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS .PHONY: all install clean strip .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags .FORCE-GIT-CFLAGS From 68daee085cef975c76d9eeba91a3836cf88bcc3f Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Thu, 29 Mar 2007 14:06:48 +0400 Subject: [PATCH 20/45] Eliminate checks of user-specified Tcl/Tk interpreter. Do not make the checks on the Tcl/Tk interpreter passed by '--with-tcltk=/path/to/wish' configure option: user is free to pass anything. Signed-off-by: Eygene Ryabinkin Signed-off-by: Junio C Hamano --- configure.ac | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 01fa0f0bda..50d2b85ace 100644 --- a/configure.ac +++ b/configure.ac @@ -102,12 +102,10 @@ if test -z "$NO_TCLTK"; then elif test "$with_tcltk" = "yes"; then # Tcl/Tk check requested. AC_CHECK_PROGS(TCLTK_PATH, [wish], ) - elif test -x "$with_tcltk"; then + else AC_MSG_RESULT([Using Tcl/Tk interpreter $with_tcltk]) TCLTK_PATH="$with_tcltk" AC_SUBST(TCLTK_PATH) - else - AC_MSG_ERROR([Tcl/Tk interpreter was not found in $with_tcltk]) fi fi From 30551781938ec98811b8903b653c58ee95368fe4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 30 Mar 2007 00:59:43 -0700 Subject: [PATCH 21/45] Optional Tck/Tk: ignore generated files. Signed-off-by: Junio C Hamano --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e8d2731ee5..b39f78fcdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ GIT-CFLAGS +GIT-GUI-VARS GIT-VERSION-FILE git git-add @@ -141,6 +142,7 @@ git-verify-tag git-whatchanged git-write-tree git-core-*/?* +gitk-wish gitweb/gitweb.cgi test-chmtime test-date From a23f0a73d10542297249b3c57cad0b7cd63b87be Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sun, 1 Apr 2007 22:21:38 +0200 Subject: [PATCH 22/45] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (3) Code should be look the same way, regardless of tab size. Use tabs for indent, but spaces for align. Indent continued part of command spanning multiple lines, but only once. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 3786955fca..8c3123ed06 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1800,7 +1800,7 @@ EOF $cgi->hidden(-name => "a") . "\n" . $cgi->hidden(-name => "h") . "\n" . $cgi->popup_menu(-name => 'st', -default => 'commit', - -values => ['commit', 'author', 'committer', 'pickaxe']) . + -values => ['commit', 'author', 'committer', 'pickaxe']) . $cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) . " search:\n", $cgi->textfield(-name => "s", -value => $searchtext) . "\n" . @@ -3095,7 +3095,7 @@ sub git_summary { git_project_list_body(\@forklist, undef, 0, 15, $#forklist <= 15 ? undef : $cgi->a({-href => href(action=>"forks")}, "..."), - 'noheader'); + 'noheader'); } git_footer_html(); @@ -3202,7 +3202,7 @@ HTML my $rev = substr($full_rev, 0, 8); my $author = $meta->{'author'}; my %date = parse_date($meta->{'author-time'}, - $meta->{'author-tz'}); + $meta->{'author-tz'}); my $date = $date{'iso-tz'}; if ($group_size) { $current_color = ++$current_color % $num_colors; @@ -3214,9 +3214,9 @@ HTML print " rowspan=\"$group_size\"" if ($group_size > 1); print ">"; print $cgi->a({-href => href(action=>"commit", - hash=>$full_rev, - file_name=>$file_name)}, - esc_html($rev)); + hash=>$full_rev, + file_name=>$file_name)}, + esc_html($rev)); print "\n"; } open (my $dd, "-|", git_cmd(), "rev-parse", "$full_rev^") @@ -3225,13 +3225,13 @@ HTML close $dd; chomp($parent_commit); my $blamed = href(action => 'blame', - file_name => $meta->{'filename'}, - hash_base => $parent_commit); + file_name => $meta->{'filename'}, + hash_base => $parent_commit); print ""; print $cgi->a({ -href => "$blamed#l$orig_lineno", - -id => "l$lineno", - -class => "linenr" }, - esc_html($lineno)); + -id => "l$lineno", + -class => "linenr" }, + esc_html($lineno)); print ""; print "" . esc_html($data) . "\n"; print "\n"; @@ -3621,7 +3621,7 @@ sub git_snapshot { my $name = $project; $name =~ s/\047/\047\\\047\047/g; open my $fd, "-|", - "$git archive --format=tar --prefix=\'$name\'/ $hash | $command" + "$git archive --format=tar --prefix=\'$name\'/ $hash | $command" or die_error(undef, "Execute git-tar-tree failed"); binmode STDOUT, ':raw'; print <$fd>; @@ -3734,7 +3734,7 @@ sub git_commit { # difftree output is not printed for merges open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id", @diff_opts, $parent, $hash, "--" - or die_error(undef, "Open git-diff-tree failed"); + or die_error(undef, "Open git-diff-tree failed"); @difftree = map { chomp; $_ } <$fd>; close $fd or die_error(undef, "Reading git-diff-tree failed"); } @@ -4304,13 +4304,13 @@ sub git_search { if ($page > 0) { $paging_nav .= $cgi->a({-href => href(action=>"search", hash=>$hash, - searchtext=>$searchtext, searchtype=>$searchtype)}, - "first"); + searchtext=>$searchtext, searchtype=>$searchtype)}, + "first"); $paging_nav .= " ⋅ " . $cgi->a({-href => href(action=>"search", hash=>$hash, - searchtext=>$searchtext, searchtype=>$searchtype, - page=>$page-1), - -accesskey => "p", -title => "Alt-p"}, "prev"); + searchtext=>$searchtext, searchtype=>$searchtype, + page=>$page-1), + -accesskey => "p", -title => "Alt-p"}, "prev"); } else { $paging_nav .= "first"; $paging_nav .= " ⋅ prev"; @@ -4318,9 +4318,9 @@ sub git_search { if ($#commitlist >= 100) { $paging_nav .= " ⋅ " . $cgi->a({-href => href(action=>"search", hash=>$hash, - searchtext=>$searchtext, searchtype=>$searchtype, - page=>$page+1), - -accesskey => "n", -title => "Alt-n"}, "next"); + searchtext=>$searchtext, searchtype=>$searchtype, + page=>$page+1), + -accesskey => "n", -title => "Alt-n"}, "next"); } else { $paging_nav .= " ⋅ next"; } @@ -4328,9 +4328,9 @@ sub git_search { if ($#commitlist >= 100) { $next_link = $cgi->a({-href => href(action=>"search", hash=>$hash, - searchtext=>$searchtext, searchtype=>$searchtype, - page=>$page+1), - -accesskey => "n", -title => "Alt-n"}, "next"); + searchtext=>$searchtext, searchtype=>$searchtype, + page=>$page+1), + -accesskey => "n", -title => "Alt-n"}, "next"); } git_print_page_nav('','', $hash,$co{'tree'},$hash, $paging_nav); From 3be8e720d95f8d040dbfdd8a579616a9423280df Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sun, 1 Apr 2007 22:22:21 +0200 Subject: [PATCH 23/45] gitweb: Quote hash keys, and do not use barewords keys Ensure that in all references to an element of a hash, the key is singlequoted, instead of using bareword: use $hash{'key'} instead of $hash{key} Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 8c3123ed06..ea491562c8 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -19,7 +19,7 @@ use File::Basename qw(basename); binmode STDOUT, ':utf8'; BEGIN { - CGI->compile() if $ENV{MOD_PERL}; + CGI->compile() if $ENV{'MOD_PERL'}; } our $cgi = new CGI; @@ -1870,16 +1870,16 @@ sub git_print_page_nav { my %arg = map { $_ => {action=>$_} } @navs; if (defined $head) { for (qw(commit commitdiff)) { - $arg{$_}{hash} = $head; + $arg{$_}{'hash'} = $head; } if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) { for (qw(shortlog log)) { - $arg{$_}{hash} = $head; + $arg{$_}{'hash'} = $head; } } } - $arg{tree}{hash} = $treehead if defined $treehead; - $arg{tree}{hash_base} = $treebase if defined $treebase; + $arg{'tree'}{'hash'} = $treehead if defined $treehead; + $arg{'tree'}{'hash_base'} = $treebase if defined $treebase; print "
\n" . (join " | ", @@ -1927,9 +1927,9 @@ sub git_print_header_div { my ($action, $title, $hash, $hash_base) = @_; my %args = (); - $args{action} = $action; - $args{hash} = $hash if $hash; - $args{hash_base} = $hash_base if $hash_base; + $args{'action'} = $action; + $args{'hash'} = $hash if $hash; + $args{'hash_base'} = $hash_base if $hash_base; print "
\n" . $cgi->a({-href => href(%args), -class => "title"}, From e421fc0797d0a6c8a40bce96c4383223c8ae2da7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 3 Apr 2007 01:57:08 -0700 Subject: [PATCH 24/45] git-svn: bail out on incorrect command-line options "git svn log" is the only command that needs the pass-through option in Getopt::Long; otherwise we will bail out and let the user know something is wrong. Also, avoid printing out unaccepted mixed-case options (that are reserved for the command-line) such as --useSvmProps in the usage() function. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-svn.perl b/git-svn.perl index d307d430f3..6216cade0f 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -33,7 +33,7 @@ use Carp qw/croak/; use IO::File qw//; use File::Basename qw/dirname basename/; use File::Path qw/mkpath/; -use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev pass_through/; +use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/; use IPC::Open3; use Git; @@ -168,6 +168,7 @@ for (my $i = 0; $i < @ARGV; $i++) { my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd); read_repo_config(\%opts); +Getopt::Long::Configure('pass_through') if $cmd eq 'log'; my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version, 'minimize-connections' => \$Git::SVN::Migration::_minimize, 'id|i=s' => \$Git::SVN::default_ref_id, @@ -229,6 +230,8 @@ Usage: $0 [options] [arguments]\n next if /^multi-/; # don't show deprecated commands print $fd ' ',pack('A17',$_),$cmd{$_}->[1],"\n"; foreach (keys %{$cmd{$_}->[2]}) { + # mixed-case options are for .git/config only + next if /[A-Z]/ && /^[a-z]+$/i; # prints out arguments as they should be passed: my $x = s#[:=]s$## ? '' : s#[:=]i$## ? '' : ''; print $fd ' ' x 21, join(', ', map { length $_ > 1 ? From 364b8523529163ffeeb71521239a18ac1f550512 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Wed, 4 Apr 2007 15:39:05 -0400 Subject: [PATCH 25/45] Fix t4200-rerere for white-space from "wc -l" On OS X, wc outputs 6 spaces before the number of lines, so the test expecting the string "10" failed. Do not quote $cmd to strip away the problematic whitespace as other tests do. Also fix the grammar of the test name while making changes to it. There's only one preimage, so it's "has", not "have". Signed-off-by: Junio C Hamano --- t/t4200-rerere.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 8b611bbea2..bc878d750d 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -50,10 +50,10 @@ test_expect_success 'recorded preimage' "grep ======= $rr/preimage" test_expect_success 'no postimage or thisimage yet' \ "test ! -f $rr/postimage -a ! -f $rr/thisimage" -test_expect_success 'preimage have right number of lines' ' +test_expect_success 'preimage has right number of lines' ' cnt=$(sed -ne "/^<<<<<<>>>>>>/p" $rr/preimage | wc -l) && - test "$cnt" = 10 + test $cnt = 10 ' From 2b93edbf32700d91c500806e4502077829d66d21 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 4 Apr 2007 14:12:03 -0700 Subject: [PATCH 26/45] rerere: make sorting really stable. The earlier code does not swap hunks when the beginning of the first side is identical to the whole of the second side. In such a case, the first one should sort later. Signed-off-by: Junio C Hamano --- builtin-rerere.c | 7 +++++-- t/t4200-rerere.sh | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/builtin-rerere.c b/builtin-rerere.c index b463c07f04..8c2c8bdc18 100644 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@ -117,10 +117,13 @@ static int handle_file(const char *path, else if (!prefixcmp(buf, "=======")) hunk = 2; else if (!prefixcmp(buf, ">>>>>>> ")) { + int one_is_longer = (one->nr > two->nr); + int common_len = one_is_longer ? two->nr : one->nr; + int cmp = memcmp(one->ptr, two->ptr, common_len); + hunk_no++; hunk = 0; - if (memcmp(one->ptr, two->ptr, one->nr < two->nr ? - one->nr : two->nr) > 0) { + if ((cmp > 0) || ((cmp == 0) && one_is_longer)) { struct buffer *swap = one; one = two; two = swap; diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index bc878d750d..6ba63d7173 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -35,7 +35,8 @@ git commit -q -a -m first git checkout -b second master git show first:a1 | -sed -e 's/To die, t/To die! T/' -e 's/life;$/life./' > a1 +sed -e 's/To die, t/To die! T/' > a1 +echo "* END *" >>a1 git commit -q -a -m second # activate rerere @@ -53,7 +54,7 @@ test_expect_success 'no postimage or thisimage yet' \ test_expect_success 'preimage has right number of lines' ' cnt=$(sed -ne "/^<<<<<<>>>>>>/p" $rr/preimage | wc -l) && - test $cnt = 10 + test $cnt = 9 ' @@ -75,10 +76,10 @@ cat > expect << EOF For in that sleep of death what dreams may come When we have shuffled off this mortal coil, Must give us pause: there's the respect --<<<<<<< --That makes calamity of so long life. --======= That makes calamity of so long life; +-<<<<<<< +-======= +-* END * ->>>>>>> EOF git rerere diff > out From d5ad36fe3584551a09160edce3e76d559d412ae5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 4 Apr 2007 11:32:33 -0700 Subject: [PATCH 27/45] RPM spec: include git-p4 in the list of all packages. Signed-off-by: Junio C Hamano --- git.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.spec.in b/git.spec.in index 1d3934bba5..f0746ed78c 100644 --- a/git.spec.in +++ b/git.spec.in @@ -12,7 +12,7 @@ URL: http://kernel.org/pub/software/scm/git/ Source: http://kernel.org/pub/software/scm/git/%{name}-%{version}.tar.gz BuildRequires: zlib-devel >= 1.2, openssl-devel, curl-devel, expat-devel %{!?_without_docs:, xmlto, asciidoc > 6.0.3} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Requires: git-core, git-svn, git-cvs, git-arch, git-email, gitk, git-gui, perl-Git +Requires: git-core, git-svn, git-cvs, git-arch, git-email, gitk, git-gui, git-p4, perl-Git %description Git is a fast, scalable, distributed revision control system with an From 5850cb645d3ca44c3bc014f92672dae6394c0315 Mon Sep 17 00:00:00 2001 From: Gerrit Pape Date: Wed, 4 Apr 2007 11:52:12 +0000 Subject: [PATCH 28/45] rename contrib/hooks/post-receieve-email to contrib/hooks/post-receive-email. $ git grep post-receieve-email $ git grep post-receive-email templates/hooks--post-receive:#. /usr/share/doc/git-core/contrib/hooks/post-receive-email $ Signed-off-by: Gerrit Pape Signed-off-by: Junio C Hamano --- contrib/hooks/{post-receieve-email => post-receive-email} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/hooks/{post-receieve-email => post-receive-email} (100%) diff --git a/contrib/hooks/post-receieve-email b/contrib/hooks/post-receive-email similarity index 100% rename from contrib/hooks/post-receieve-email rename to contrib/hooks/post-receive-email From 265d528032e55c48798266c538d3e6338cb1e2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Thu, 5 Apr 2007 22:55:43 +0200 Subject: [PATCH 29/45] Revert "builtin-archive: use RUN_SETUP" Commit 64edf4b2 cleaned up the initialization of git-archive, at the cost of 'git-archive --list' now requiring a git repo. This patch reverts the cleanup and documents the requirement for this particular dirtyness in a test. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- builtin-archive.c | 2 ++ git.c | 2 +- t/t5000-tar-tree.sh | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/builtin-archive.c b/builtin-archive.c index 2fae885f5c..8ea6cb1efc 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -252,6 +252,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix) memset(&ar, 0, sizeof(ar)); tree_idx = parse_archive_args(argc, argv, &ar); + if (prefix == NULL) + prefix = setup_git_directory(); argv += tree_idx; parse_treeish_arg(argv, &ar.args, prefix); diff --git a/git.c b/git.c index 5b1bc2a895..33dd4d39d9 100644 --- a/git.c +++ b/git.c @@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "add", cmd_add, RUN_SETUP | NOT_BARE }, { "annotate", cmd_annotate, USE_PAGER }, { "apply", cmd_apply }, - { "archive", cmd_archive, RUN_SETUP }, + { "archive", cmd_archive }, { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP }, { "bundle", cmd_bundle }, diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index ac835fe431..b4359df795 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -130,4 +130,8 @@ test_expect_success \ 'validate file contents with prefix' \ 'diff -r a e/prefix/a' +test_expect_success \ + 'git-archive --list outside of a git repo' \ + 'GIT_DIR=some/non-existing/directory git-archive --list' + test_done From b24bace5ca9420033be83ef6c14fb092c9371fe1 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Thu, 5 Apr 2007 10:53:07 -0400 Subject: [PATCH 30/45] Document --left-right option to rev-list. Explanation is paraphrased from "577ed5c... rev-list --left-right" Signed-off-by: Junio C Hamano --- Documentation/git-rev-list.txt | 31 +++++++++++++++++++++++++++++++ builtin-rev-list.c | 1 + 2 files changed, 32 insertions(+) diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 4f145eaba4..11ce395c98 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -21,6 +21,7 @@ SYNOPSIS [ \--stdin ] [ \--topo-order ] [ \--parents ] + [ \--left-right ] [ \--encoding[=] ] [ \--(author|committer|grep)= ] [ [\--objects | \--objects-edge] [ \--unpacked ] ] @@ -100,6 +101,36 @@ include::pretty-formats.txt[] Print the parents of the commit. +--left-right:: + + Mark which side of a symmetric diff a commit is reachable from. + Commits from the left side are prefixed with `<` and those from + the right with `>`. If combined with `--boundary`, those + commits are prefixed with `-`. ++ +For example, if you have this topology: ++ +----------------------------------------------------------------------- + y---b---b branch B + / \ / + / . + / / \ + o---x---a---a branch A +----------------------------------------------------------------------- ++ +you would get an output line this: ++ +----------------------------------------------------------------------- + $ git rev-list --left-right --boundary --pretty=oneline A...B + + >bbbbbbb... 3rd on b + >bbbbbbb... 2nd on b + Date: Thu, 5 Apr 2007 13:45:41 +0200 Subject: [PATCH 31/45] gitweb: Fix bug in "blobdiff" view for split (e.g. file to symlink) patches git_patchset_body needs patch generated with --full-index option to detect split patches, meaning two patches which corresponds to single difftree (raw diff) entry. An example of such situation is changing type (mode) of a file, e.g. from plain file to symbolic link. Add, in git_blobdiff, --full-index option to patch generating git diff invocation, for the 'html' format output ("blobdiff" view). "blobdiff_plain" still uses shortened sha1 in the extended git diff header "index ..[ ]" line. Noticed-by: Martin Koegler Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 3786955fca..45ac9d7121 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -3934,7 +3934,8 @@ sub git_blobdiff { # open patch output open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts, - '-p', $hash_parent_base, $hash_base, + '-p', ($format eq 'html' ? "--full-index" : ()), + $hash_parent_base, $hash_base, "--", (defined $file_parent ? $file_parent : ()), $file_name or die_error(undef, "Open git-diff-tree failed"); } @@ -3969,7 +3970,8 @@ sub git_blobdiff { } # open patch output - open $fd, "-|", git_cmd(), "diff", '-p', @diff_opts, + open $fd, "-|", git_cmd(), "diff", @diff_opts, + '-p', ($format eq 'html' ? "--full-index" : ()), $hash_parent, $hash, "--" or die_error(undef, "Open git-diff failed"); } else { From 1e31fbe24fac983b0057af39824f73d65dba6502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 5 Apr 2007 21:09:31 +0300 Subject: [PATCH 32/45] DESTDIR support for git/contrib/emacs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make install DESTDIR=... support for git/contrib/emacs Signed-off-by: Ville Skyttä Signed-off-by: Junio C Hamano --- contrib/emacs/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/emacs/Makefile b/contrib/emacs/Makefile index 8554e3967c..98aa0aae9b 100644 --- a/contrib/emacs/Makefile +++ b/contrib/emacs/Makefile @@ -11,8 +11,8 @@ emacsdir = $(prefix)/share/emacs/site-lisp all: $(ELC) install: all - $(INSTALL) -d $(emacsdir) - $(INSTALL_ELC) $(ELC) $(emacsdir) + $(INSTALL) -d $(DESTDIR)$(emacsdir) + $(INSTALL_ELC) $(ELC) $(DESTDIR)$(emacsdir) %.elc: %.el $(EMACS) -batch -f batch-byte-compile $< From 01ebb9dc8846af729c13d5d8c9d939a6d1159240 Mon Sep 17 00:00:00 2001 From: Geert Bosch Date: Thu, 5 Apr 2007 10:20:55 -0400 Subject: [PATCH 33/45] Fix renaming branch without config file Make git_config_rename_section return success if no config file exists. Otherwise, renaming a branch would abort, leaving the repository in an inconsistent state. [jc: test] Signed-off-by: Geert Bosch Signed-off-by: Junio C Hamano --- config.c | 5 +++-- t/t3200-branch.sh | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config.c b/config.c index 6479855723..70d1055679 100644 --- a/config.c +++ b/config.c @@ -916,8 +916,8 @@ int git_config_rename_section(const char *old_name, const char *new_name) } if (!(config_file = fopen(config_filename, "rb"))) { - ret = error("Could not open config file!"); - goto out; + /* no config file means nothing to rename, no error */ + goto unlock_and_out; } while (fgets(buf, sizeof(buf), config_file)) { @@ -951,6 +951,7 @@ int git_config_rename_section(const char *old_name, const char *new_name) } } fclose(config_file); + unlock_and_out: if (close(out_fd) || commit_lock_file(lock) < 0) ret = error("Cannot commit config file!"); out: diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 9558bdb631..ce2c5f41fd 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -83,6 +83,15 @@ test_expect_failure \ git-branch r && git-branch -m q r/q' +mv .git/config .git/config-saved + +test_expect_success 'git branch -m q Q without config should succeed' ' + git-branch -m q Q && + git-branch -m Q q +' + +mv .git/config-saved .git/config + git-config branch.s/s.dummy Hello test_expect_success \ From d72308e01c5977177cda0aed06cfeee9192e1247 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Wed, 4 Apr 2007 16:49:04 -0400 Subject: [PATCH 34/45] clean up and optimize nth_packed_object_sha1() usage Let's avoid the open coded pack index reference in pack-object and use nth_packed_object_sha1() instead. This will help encapsulating index format differences in one place. And while at it there is no reason to copy SHA1's over and over while a direct pointer to it in the index will do just fine. Signed-off-by: Nicolas Pitre Acked-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- builtin-fsck.c | 9 +++------ builtin-pack-objects.c | 2 +- cache.h | 2 +- pack-check.c | 11 +++++++---- sha1_file.c | 9 ++++----- sha1_name.c | 16 ++++++++-------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/builtin-fsck.c b/builtin-fsck.c index 21f1f9e91d..4e5aa33dfb 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -348,7 +348,7 @@ static int fsck_tag(struct tag *tag) return 0; } -static int fsck_sha1(unsigned char *sha1) +static int fsck_sha1(const unsigned char *sha1) { struct object *obj = parse_object(sha1); if (!obj) { @@ -648,11 +648,8 @@ int cmd_fsck(int argc, char **argv, const char *prefix) for (p = packed_git; p; p = p->next) { uint32_t i, num = num_packed_objects(p); - for (i = 0; i < num; i++) { - unsigned char sha1[20]; - nth_packed_object_sha1(p, i, sha1); - fsck_sha1(sha1); - } + for (i = 0; i < num; i++) + fsck_sha1(nth_packed_object_sha1(p, i)); } } diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index b5f9648e80..45ac3e482a 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -222,7 +222,7 @@ static const unsigned char *find_packed_object_name(struct packed_git *p, off_t ofs) { struct revindex_entry *entry = find_packed_object(p, ofs); - return ((unsigned char *)p->index_data) + 4 * 256 + 24 * entry->nr + 4; + return nth_packed_object_sha1(p, entry->nr); } static void *delta_against(void *buf, unsigned long size, struct object_entry *entry) diff --git a/cache.h b/cache.h index 384b260227..1f128d55d2 100644 --- a/cache.h +++ b/cache.h @@ -428,7 +428,7 @@ extern unsigned char* use_pack(struct packed_git *, struct pack_window **, off_t extern void unuse_pack(struct pack_window **); extern struct packed_git *add_packed_git(const char *, int, int); extern uint32_t num_packed_objects(const struct packed_git *p); -extern int nth_packed_object_sha1(const struct packed_git *, uint32_t, unsigned char*); +extern const unsigned char *nth_packed_object_sha1(const struct packed_git *, uint32_t); extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *); extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *); extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep); diff --git a/pack-check.c b/pack-check.c index d9883225ea..f58083d11e 100644 --- a/pack-check.c +++ b/pack-check.c @@ -42,13 +42,14 @@ static int verify_packfile(struct packed_git *p, */ nr_objects = num_packed_objects(p); for (i = 0, err = 0; i < nr_objects; i++) { - unsigned char sha1[20]; + const unsigned char *sha1; void *data; enum object_type type; unsigned long size; off_t offset; - if (nth_packed_object_sha1(p, i, sha1)) + sha1 = nth_packed_object_sha1(p, i); + if (!sha1) die("internal error pack-check nth-packed-object"); offset = find_pack_entry_one(sha1, p); if (!offset) @@ -82,14 +83,16 @@ static void show_pack_info(struct packed_git *p) memset(chain_histogram, 0, sizeof(chain_histogram)); for (i = 0; i < nr_objects; i++) { - unsigned char sha1[20], base_sha1[20]; + const unsigned char *sha1; + unsigned char base_sha1[20]; const char *type; unsigned long size; unsigned long store_size; off_t offset; unsigned int delta_chain_length; - if (nth_packed_object_sha1(p, i, sha1)) + sha1 = nth_packed_object_sha1(p, i); + if (!sha1) die("internal error pack-check nth-packed-object"); offset = find_pack_entry_one(sha1, p); if (!offset) diff --git a/sha1_file.c b/sha1_file.c index 9c26038420..4304fe9bbc 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1532,15 +1532,14 @@ uint32_t num_packed_objects(const struct packed_git *p) return (uint32_t)((p->index_size - 20 - 20 - 4*256) / 24); } -int nth_packed_object_sha1(const struct packed_git *p, uint32_t n, - unsigned char* sha1) +const unsigned char *nth_packed_object_sha1(const struct packed_git *p, + uint32_t n) { const unsigned char *index = p->index_data; index += 4 * 256; if (num_packed_objects(p) <= n) - return -1; - hashcpy(sha1, index + 24 * n + 4); - return 0; + return NULL; + return index + 24 * n + 4; } off_t find_pack_entry_one(const unsigned char *sha1, diff --git a/sha1_name.c b/sha1_name.c index bede0e5b06..267ea3f3ed 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -71,7 +71,7 @@ static int match_sha(unsigned len, const unsigned char *a, const unsigned char * static int find_short_packed_object(int len, const unsigned char *match, unsigned char *sha1) { struct packed_git *p; - unsigned char found_sha1[20]; + const unsigned char *found_sha1 = NULL; int found = 0; prepare_packed_git(); @@ -80,10 +80,10 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne uint32_t first = 0, last = num; while (first < last) { uint32_t mid = (first + last) / 2; - unsigned char now[20]; + const unsigned char *now; int cmp; - nth_packed_object_sha1(p, mid, now); + now = nth_packed_object_sha1(p, mid); cmp = hashcmp(match, now); if (!cmp) { first = mid; @@ -96,14 +96,14 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne last = mid; } if (first < num) { - unsigned char now[20], next[20]; - nth_packed_object_sha1(p, first, now); + const unsigned char *now, *next; + now = nth_packed_object_sha1(p, first); if (match_sha(len, match, now)) { - if (nth_packed_object_sha1(p, first+1, next) || - !match_sha(len, match, next)) { + next = nth_packed_object_sha1(p, first+1); + if (!next|| !match_sha(len, match, next)) { /* unique within this pack */ if (!found) { - hashcpy(found_sha1, now); + found_sha1 = now; found++; } else if (hashcmp(found_sha1, now)) { From 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 4 Apr 2007 10:46:14 -0400 Subject: [PATCH 35/45] Fix lost-found to show commits only referenced by reflogs Prior to 1.5.0 the git-lost-found utility was useful to locate commits that were not referenced by any ref. These were often amends, or resets, or tips of branches that had been deleted. Being able to locate a 'lost' commit and recover it by creating a new branch was a useful feature in those days. Unfortunately 1.5.0 added the reflogs to the reachability analysis performed by git-fsck, which means that most commits users would consider to be lost are still reachable through a reflog. So most (or all!) commits are reachable, and nothing gets output from git-lost-found. Now git-fsck can be told to ignore reflogs during its reachability analysis, making git-lost-found useful again to locate commits that are no longer referenced by a ref itself, but may still be referenced by a reflog. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- Documentation/git-fsck.txt | 8 +++++++- builtin-fsck.c | 8 +++++++- git-lost-found.sh | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt index 058009d2fa..8c68cf0372 100644 --- a/Documentation/git-fsck.txt +++ b/Documentation/git-fsck.txt @@ -9,7 +9,7 @@ git-fsck - Verifies the connectivity and validity of the objects in the database SYNOPSIS -------- [verse] -'git-fsck' [--tags] [--root] [--unreachable] [--cache] +'git-fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs] [--full] [--strict] [*] DESCRIPTION @@ -38,6 +38,12 @@ index file and all SHA1 references in .git/refs/* as heads. Consider any object recorded in the index also as a head node for an unreachability trace. +--no-reflogs:: + Do not consider commits that are referenced only by an + entry in a reflog to be reachable. This option is meant + only to search for commits that used to be in a ref, but + now aren't, but are still in that corresponding reflog. + --full:: Check not just objects in GIT_OBJECT_DIRECTORY ($GIT_DIR/objects), but also the ones found in alternate diff --git a/builtin-fsck.c b/builtin-fsck.c index 4e5aa33dfb..4d8b66c344 100644 --- a/builtin-fsck.c +++ b/builtin-fsck.c @@ -14,6 +14,7 @@ static int show_root; static int show_tags; static int show_unreachable; +static int include_reflogs = 1; static int check_full; static int check_strict; static int keep_cache_objects; @@ -517,7 +518,8 @@ static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int f static void get_default_heads(void) { for_each_ref(fsck_handle_ref, NULL); - for_each_reflog(fsck_handle_reflog, NULL); + if (include_reflogs) + for_each_reflog(fsck_handle_reflog, NULL); /* * Not having any default heads isn't really fatal, but @@ -616,6 +618,10 @@ int cmd_fsck(int argc, char **argv, const char *prefix) keep_cache_objects = 1; continue; } + if (!strcmp(arg, "--no-reflogs")) { + include_reflogs = 0; + continue; + } if (!strcmp(arg, "--full")) { check_full = 1; continue; diff --git a/git-lost-found.sh b/git-lost-found.sh index 9360804711..58570dff13 100755 --- a/git-lost-found.sh +++ b/git-lost-found.sh @@ -12,7 +12,7 @@ fi laf="$GIT_DIR/lost-found" rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit -git fsck --full | +git fsck --full --no-reflogs | while read dangling type sha1 do case "$dangling" in From 766b084f59c97bc8b096a59cd5c8d06df5aa2bc5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 5 Apr 2007 15:03:48 -0700 Subject: [PATCH 36/45] Fix dependency of common-cmds.h Say $(wildcard ...) when we mean it. Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b159ffd0ae..81dafe5ee3 100644 --- a/Makefile +++ b/Makefile @@ -684,7 +684,7 @@ help.o: common-cmds.h $(BUILT_INS): git$X $(QUIET_BUILT_IN)rm -f $@ && ln git$X $@ -common-cmds.h: Documentation/git-*.txt +common-cmds.h: $(wildcard Documentation/git-*.txt) $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh From 79ee194e52a140412da475e102145bad80d5d00a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 4 Apr 2007 11:19:14 -0400 Subject: [PATCH 37/45] Honor -p when applying git diffs If the user is trying to apply a Git generated diff file and they have specified a -p option, where is not 1, the user probably has a good reason for doing this. Such as they are me, trying to apply a patch generated in git.git for the git-gui subdirectory to the git-gui.git repository, where there is no git-gui subdirectory present. Users shouldn't supply -p2 unless they mean it. But if they are supplying it, they probably have thought about how to make this patch apply to their working directory, and want to risk whatever results may come from that. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- builtin-apply.c | 4 ++-- t/t4120-apply-popt.sh | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 t/t4120-apply-popt.sh diff --git a/builtin-apply.c b/builtin-apply.c index 27a182bfaa..a5d612655f 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -417,7 +417,7 @@ static int gitdiff_hdrend(const char *line, struct patch *patch) static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, const char *oldnew) { if (!orig_name && !isnull) - return find_name(line, NULL, 1, TERM_TAB); + return find_name(line, NULL, p_value, TERM_TAB); if (orig_name) { int len; @@ -427,7 +427,7 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, len = strlen(name); if (isnull) die("git-apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr); - another = find_name(line, NULL, 1, TERM_TAB); + another = find_name(line, NULL, p_value, TERM_TAB); if (!another || memcmp(another, name, len)) die("git-apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr); free(another); diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh new file mode 100755 index 0000000000..2f672f30d4 --- /dev/null +++ b/t/t4120-apply-popt.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (c) 2007 Shawn O. Pearce +# + +test_description='git-apply -p handling.' + +. ./test-lib.sh + +test_expect_success setup ' + mkdir sub && + echo A >sub/file1 && + cp sub/file1 file1 && + git add sub/file1 && + echo B >sub/file1 && + git diff >patch.file && + rm sub/file1 && + rmdir sub +' + +test_expect_success 'apply git diff with -p2' ' + git apply -p2 patch.file +' + +test_done From b18825876ae60e67e646097945c8365779175ee2 Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Wed, 4 Apr 2007 13:14:14 +0000 Subject: [PATCH 38/45] Show binary file size change in diff --stat Previously, a binary file in the diffstat would show as: some-binary-file.bin | Bin The space after the "Bin" was never used. This patch changes binary lines in the diffstat to be: some-binary-file.bin | Bin 12345 -> 123456 bytes The very nice "->" notation was suggested by Johannes Schindelin, and shows the before and after sizes more clearly than "+" and "-" would. If a size is 0 it's not shown (although it would probably be better to treat no-file differently from zero-byte-file). The user can see what changed in the binary file, and how big the new file is. This is in keeping with the information in the rest of the diffstat. The diffstat_t members "added" and "deleted" were unused when the file was binary, so this patch loads them with the file sizes in builtin_diffstat(). These figures are then read in show_stats() when the file is marked binary. Signed-off-by: Andy Parkins Signed-off-by: Junio C Hamano --- diff.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/diff.c b/diff.c index d8f9242ea8..fbb79d70a9 100644 --- a/diff.c +++ b/diff.c @@ -811,7 +811,12 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options) if (data->files[i]->is_binary) { show_name(prefix, name, len, reset, set); - printf(" Bin\n"); + printf(" Bin "); + printf("%s%d%s", del_c, deleted, reset); + printf(" -> "); + printf("%s%d%s", add_c, added, reset); + printf(" bytes"); + printf("\n"); goto free_diffstat_file; } else if (data->files[i]->is_unmerged) { @@ -1185,9 +1190,11 @@ static void builtin_diffstat(const char *name_a, const char *name_b, if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0) die("unable to read files to diff"); - if (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2)) + if (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2)) { data->is_binary = 1; - else { + data->added = mf2.size; + data->deleted = mf1.size; + } else { /* Crazy xdl interfaces.. */ xpparam_t xpp; xdemitconf_t xecfg; From 0424138d5715dbf8605bacfbd22210aac85a1a8f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 1 Apr 2007 21:13:27 -0700 Subject: [PATCH 39/45] Fix bogus error message from merge-recursive error path This error message should not usually trigger, but the function make_cache_entry() called by add_cacheinfo() can return early without calling into refresh_cache_entry() that sets cache_errno. Also the error message had a wrong function name reported, and it did not say anything about which path failed either. Signed-off-by: Junio C Hamano --- cache.h | 1 - merge-recursive.c | 2 +- read-cache.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cache.h b/cache.h index 1f128d55d2..467e6a579a 100644 --- a/cache.h +++ b/cache.h @@ -128,7 +128,6 @@ static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned in extern struct cache_entry **active_cache; extern unsigned int active_nr, active_alloc, active_cache_changed; extern struct cache_tree *active_cache_tree; -extern int cache_errno; enum object_type { OBJ_BAD = -1, diff --git a/merge-recursive.c b/merge-recursive.c index e1aebd7727..3611a2bdb7 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -221,7 +221,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1, struct cache_entry *ce; ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, refresh); if (!ce) - return error("cache_addinfo failed: %s", strerror(cache_errno)); + return error("addinfo_cache failed for path '%s'", path); return add_cache_entry(ce, options); } diff --git a/read-cache.c b/read-cache.c index 6339a278da..8a7506d909 100644 --- a/read-cache.c +++ b/read-cache.c @@ -24,7 +24,7 @@ unsigned int active_nr, active_alloc, active_cache_changed; struct cache_tree *active_cache_tree; -int cache_errno; +static int cache_errno; static void *cache_mmap; static size_t cache_mmap_size; From ec0cc704692a83c1d01b53f366b9919accdd4268 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 1 Apr 2007 21:34:34 -0700 Subject: [PATCH 40/45] Propagate cache error internal to refresh_cache() via parameter. The function refresh_cache() is the only user of cache_errno that switches its behaviour based on what internal function refresh_cache_entry() finds; pass the error status back in a parameter passed down to it, to get rid of the global variable cache_errno. Signed-off-by: Junio C Hamano --- read-cache.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/read-cache.c b/read-cache.c index 8a7506d909..747b50a99a 100644 --- a/read-cache.c +++ b/read-cache.c @@ -24,8 +24,6 @@ unsigned int active_nr, active_alloc, active_cache_changed; struct cache_tree *active_cache_tree; -static int cache_errno; - static void *cache_mmap; static size_t cache_mmap_size; @@ -643,14 +641,15 @@ int add_cache_entry(struct cache_entry *ce, int option) * For example, you'd want to do this after doing a "git-read-tree", * to link up the stat cache details with the proper files. */ -struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really) +static struct cache_entry *refresh_cache_ent(struct cache_entry *ce, int really, int *err) { struct stat st; struct cache_entry *updated; int changed, size; if (lstat(ce->name, &st) < 0) { - cache_errno = errno; + if (err) + *err = errno; return NULL; } @@ -664,7 +663,8 @@ struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really) } if (ce_modified(ce, &st, really)) { - cache_errno = EINVAL; + if (err) + *err = EINVAL; return NULL; } @@ -696,6 +696,8 @@ int refresh_cache(unsigned int flags) for (i = 0; i < active_nr; i++) { struct cache_entry *ce, *new; + int cache_errno = 0; + ce = active_cache[i]; if (ce_stage(ce)) { while ((i < active_nr) && @@ -709,7 +711,7 @@ int refresh_cache(unsigned int flags) continue; } - new = refresh_cache_entry(ce, really); + new = refresh_cache_ent(ce, really, &cache_errno); if (new == ce) continue; if (!new) { @@ -737,6 +739,11 @@ int refresh_cache(unsigned int flags) return has_errors; } +struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really) +{ + return refresh_cache_ent(ce, really, NULL); +} + static int verify_hdr(struct cache_header *hdr, unsigned long size) { SHA_CTX c; From 81e1bc47687dc78598ad003f0d02a328a6ddae72 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 1 Apr 2007 22:07:26 -0700 Subject: [PATCH 41/45] Rename internal function "add_file_to_cache" in builtin-update-index.c I'd like to consistently name all index-layer functions that operate on the default index xxx_cache(), and this application specific function interferes with the plan. Signed-off-by: Junio C Hamano --- builtin-update-index.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin-update-index.c b/builtin-update-index.c index 71cef633c0..d1e5cf7539 100644 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@ -60,7 +60,7 @@ static int mark_valid(const char *path) return -1; } -static int add_file_to_cache(const char *path) +static int process_file(const char *path) { int size, namelen, option, status; struct cache_entry *ce; @@ -210,7 +210,7 @@ static void update_one(const char *path, const char *prefix, int prefix_length) report("remove '%s'", path); goto free_return; } - if (add_file_to_cache(p)) + if (process_file(p)) die("Unable to process file %s", path); report("add '%s'", path); free_return: From 7da3bf372cfcd25ea44164afb90c306836b62e23 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 1 Apr 2007 22:46:06 -0700 Subject: [PATCH 42/45] Rename static variable write_index to update_index in builtin-apply.c This is an internal variable used to tell if we need to write out the resulting index. I'll be introducing write_index() function which would collide with it. Signed-off-by: Junio C Hamano --- builtin-apply.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/builtin-apply.c b/builtin-apply.c index 27a182bfaa..6a8292e2a5 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -30,7 +30,7 @@ static int unidiff_zero; static int p_value = 1; static int p_value_known; static int check_index; -static int write_index; +static int update_index; static int cached; static int diffstat; static int numstat; @@ -2308,7 +2308,7 @@ static void patch_stats(struct patch *patch) static void remove_file(struct patch *patch, int rmdir_empty) { - if (write_index) { + if (update_index) { if (remove_file_from_cache(patch->old_name) < 0) die("unable to remove %s from index", patch->old_name); cache_tree_invalidate_path(active_cache_tree, patch->old_name); @@ -2335,7 +2335,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned int namelen = strlen(path); unsigned ce_size = cache_entry_size(namelen); - if (!write_index) + if (!update_index) return; ce = xcalloc(1, ce_size); @@ -2662,8 +2662,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof) if (whitespace_error && (new_whitespace == error_on_whitespace)) apply = 0; - write_index = check_index && apply; - if (write_index && newfd < 0) + update_index = check_index && apply; + if (update_index && newfd < 0) newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1); if (check_index) { @@ -2870,7 +2870,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix) whitespace_error == 1 ? "s" : ""); } - if (write_index) { + if (update_index) { if (write_cache(newfd, active_cache, active_nr) || close(newfd) || commit_lock_file(&lock_file)) die("Unable to write new index file"); From fd1c3bf0533c6cc7e44646d4e52d378d5b5a1631 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 1 Apr 2007 22:14:40 -0700 Subject: [PATCH 43/45] Rename add_file_to_index() to add_file_to_cache() This function was not called "add_file_to_cache()" only because an ancient program, update-cache, used that name as an internal function name that does something slightly different. Now that is gone, we can take over the better name. The plan is to name all functions that operate on the default index xxx_cache(). Later patches create a variant of them that take an explicit parameter xxx_index(), and then turn xxx_cache() functions into macros that use "the_index". Signed-off-by: Junio C Hamano --- builtin-add.c | 2 +- builtin-mv.c | 2 +- cache.h | 2 +- read-cache.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin-add.c b/builtin-add.c index 871e23f0f6..7d1d5dc244 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -205,7 +205,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) } for (i = 0; i < dir.nr; i++) - add_file_to_index(dir.entries[i]->name, verbose); + add_file_to_cache(dir.entries[i]->name, verbose); if (active_cache_changed) { if (write_cache(newfd, active_cache, active_nr) || diff --git a/builtin-mv.c b/builtin-mv.c index 737af350b8..c4ab4784ce 100644 --- a/builtin-mv.c +++ b/builtin-mv.c @@ -273,7 +273,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) for (i = 0; i < added.nr; i++) { const char *path = added.items[i].path; - add_file_to_index(path, verbose); + add_file_to_cache(path, verbose); } for (i = 0; i < deleted.nr; i++) { diff --git a/cache.h b/cache.h index 467e6a579a..ece0c041f5 100644 --- a/cache.h +++ b/cache.h @@ -187,7 +187,7 @@ extern int add_cache_entry(struct cache_entry *ce, int option); extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really); extern int remove_cache_entry_at(int pos); extern int remove_file_from_cache(const char *path); -extern int add_file_to_index(const char *path, int verbose); +extern int add_file_to_cache(const char *path, int verbose); extern int ce_same_name(struct cache_entry *a, struct cache_entry *b); extern int ce_match_stat(struct cache_entry *ce, struct stat *st, int); extern int ce_modified(struct cache_entry *ce, struct stat *st, int); diff --git a/read-cache.c b/read-cache.c index 747b50a99a..a8f8a6b2b2 100644 --- a/read-cache.c +++ b/read-cache.c @@ -325,7 +325,7 @@ int remove_file_from_cache(const char *path) return 0; } -int add_file_to_index(const char *path, int verbose) +int add_file_to_cache(const char *path, int verbose) { int size, namelen; struct stat st; From 33580fbd308593e36395926fd35b501976ad322a Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Thu, 5 Apr 2007 21:31:53 +0200 Subject: [PATCH 44/45] Fix passing of TCLTK_PATH to git-gui GNU make does not include environment variables by default in its namespace. Just pass them in make command line. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ad321b35bf..507ad9103e 100644 --- a/Makefile +++ b/Makefile @@ -703,7 +703,7 @@ endif all:: ifndef NO_TCLTK - $(QUIET_SUBDIR0)git-gui TCLTK_PATH='$(TCLTK_PATH_SQ)' $(QUIET_SUBDIR1) all + $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) TCLTK_PATH='$(TCLTK_PATH_SQ)' all endif $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) From b5da24679ec73f458988523dce9dd17b4e9b0e02 Mon Sep 17 00:00:00 2001 From: Dana How Date: Thu, 5 Apr 2007 12:05:57 -0700 Subject: [PATCH 45/45] Fix lseek(2) calls with args 2 and 3 swapped Signed-off-by: Junio C Hamano --- http-fetch.c | 2 +- http-push.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/http-fetch.c b/http-fetch.c index 557b40322f..09baedc18a 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -198,7 +198,7 @@ static void start_object_request(struct object_request *obj_req) SHA1_Init(&obj_req->c); if (prev_posn>0) { prev_posn = 0; - lseek(obj_req->local, SEEK_SET, 0); + lseek(obj_req->local, 0, SEEK_SET); ftruncate(obj_req->local, 0); } } diff --git a/http-push.c b/http-push.c index 724720c562..e3f767582b 100644 --- a/http-push.c +++ b/http-push.c @@ -312,7 +312,7 @@ static void start_fetch_loose(struct transfer_request *request) SHA1_Init(&request->c); if (prev_posn>0) { prev_posn = 0; - lseek(request->local_fileno, SEEK_SET, 0); + lseek(request->local_fileno, 0, SEEK_SET); ftruncate(request->local_fileno, 0); } }