From b664550c066810b770ad3e19cafe2fbdd42c6793 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 11 Aug 2005 09:56:23 +1000 Subject: Refine the update heuristic to improve responsiveness a bit. The previous commit improved performance a lot but also meant that we waited longer to see something drawn. This refines the heuristics for when to call update so that (1) when we have finished processing a bufferfull of information from git-rev-list, we call update if enough time has elapsed, regardless of how many commits we've drawn, and (2) the number of commits drawn between updates scales with the total number of commits drawn: 1 for 1-99 commits, 10 for 100-9999 commits, or 100 for >= 10000 commits. --- gitk | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/gitk b/gitk index 6a6d4b2435..6dc4b24f06 100755 --- a/gitk +++ b/gitk @@ -31,7 +31,7 @@ proc getcommits {rargs} { set phase getcommits set startmsecs [clock clicks -milliseconds] set nextupdate [expr $startmsecs + 100] - set ncmupdate 0 + set ncmupdate 1 if [catch { set parse_args [concat --default HEAD $rargs] set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"] @@ -62,7 +62,6 @@ proc getcommitlines {commfd} { global commits parents cdate children nchildren global commitlisted phase commitinfo nextupdate global stopped redisplaying leftover - global numcommits ncmupdate set stuff [read $commfd] if {$stuff == {}} { @@ -110,10 +109,8 @@ to allow selection of commits to be displayed.)} set commitlisted($id) 1 parsecommit $id $cmit 1 drawcommit $id - if {[clock clicks -milliseconds] >= $nextupdate - && $numcommits >= $ncmupdate + 100} { - doupdate - set ncmupdate $numcommits + if {[clock clicks -milliseconds] >= $nextupdate} { + doupdate 1 } while {$redisplaying} { set redisplaying 0 @@ -123,10 +120,8 @@ to allow selection of commits to be displayed.)} foreach id $commits { drawcommit $id if {$stopped} break - if {[clock clicks -milliseconds] >= $nextupdate - && $numcommits >= $ncmupdate + 100} { - doupdate - set ncmupdate $numcommits + if {[clock clicks -milliseconds] >= $nextupdate} { + doupdate 1 } } } @@ -134,13 +129,24 @@ to allow selection of commits to be displayed.)} } } -proc doupdate {} { - global commfd nextupdate +proc doupdate {reading} { + global commfd nextupdate numcommits ncmupdate - incr nextupdate 100 - fileevent $commfd readable {} + if {$reading} { + fileevent $commfd readable {} + } update - fileevent $commfd readable [list getcommitlines $commfd] + set nextupdate [expr {[clock clicks -milliseconds] + 100}] + if {$numcommits < 100} { + set ncmupdate [expr {$numcommits + 1}] + } elseif {$numcommits < 10000} { + set ncmupdate [expr {$numcommits + 10}] + } else { + set ncmupdate [expr {$numcommits + 100}] + } + if {$reading} { + fileevent $commfd readable [list getcommitlines $commfd] + } } proc readcommit {id} { @@ -1127,8 +1133,7 @@ proc drawcommit {id} { } if {[clock clicks -milliseconds] >= $nextupdate && $numcommits >= $ncmupdate} { - doupdate - set ncmupdate $numcommits + doupdate 1 if {$stopped} break } } @@ -1171,7 +1176,7 @@ proc drawgraph {} { if {$startcommits == {}} return set startmsecs [clock clicks -milliseconds] set nextupdate [expr $startmsecs + 100] - set ncmupdate 0 + set ncmupdate 1 initgraph set todo [lindex $startcommits 0] drawrest 0 1 @@ -1210,10 +1215,8 @@ proc drawrest {level startix} { drawslants $level } if {[clock clicks -milliseconds] >= $nextupdate - && $numcommits >= $ncmupdate + 100} { - update - incr nextupdate 100 - set ncmupdate $numcommits + && $numcommits >= $ncmupdate} { + doupdate 0 } } } -- cgit v1.2.3 From 0b9442d618bedd5bef7ec4ef5829b82df57e89eb Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 10 Aug 2005 16:26:32 -0700 Subject: [PATCH] Speed up git-merge-base a lot In commit 4f7eb2e5a351e0d1f19fd4eab7e92834cc4528c2 I fixed git-merge-base getting confused by datestamps that caused it to traverse things in a non-obvious order. However, my fix was a very brute-force one, and it had some really horrible implications for more complex trees with lots of parallell development. It might end up traversing all the way to the root commit. Now, normally that isn't that horrible: it's used mainly for merging, and the bad cases really tend to happen fairly rarely, so if it takes a few seconds, we're not in too bad shape. However, gitk will also do the git-merge-base for every merge it shows, because it basically re-does the trivial merge in order to show the "interesting" parts. And there we'd really like the result to be instantaneous. This patch does that by walking the tree more completely, and using the same heuristic as git-rev-list to decide "ok, the rest is uninteresting". In one - hopefully fairly extreme - case, it made a git-merge-base go from just under five seconds(!) to a tenth of a second on my machine. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- merge-base.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/merge-base.c b/merge-base.c index 591956666d..18d81d08a5 100644 --- a/merge-base.c +++ b/merge-base.c @@ -2,6 +2,22 @@ #include "cache.h" #include "commit.h" +#define PARENT1 1 +#define PARENT2 2 +#define UNINTERESTING 4 + +static int interesting(struct commit_list *list) +{ + while (list) { + struct commit *commit = list->item; + list = list->next; + if (commit->object.flags & UNINTERESTING) + continue; + return 1; + } + return 0; +} + static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2) { struct commit_list *list = NULL; @@ -18,19 +34,18 @@ static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2) insert_by_date(rev1, &list); insert_by_date(rev2, &list); - while (list) { + while (interesting(list)) { struct commit *commit = list->item; struct commit_list *tmp = list, *parents; - int flags = commit->object.flags & 3; + int flags = commit->object.flags & 7; list = list->next; free(tmp); - switch (flags) { - case 3: + if (flags == 3) { insert_by_date(commit, &result); - continue; - case 0: - die("git-merge-base: commit without either parent?"); + + /* Mark children of a found merge uninteresting */ + flags |= UNINTERESTING; } parents = commit->parents; while (parents) { -- cgit v1.2.3 From b4ad66b7785c27ba05df78841b6f599e7207ee3d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 11 Aug 2005 18:13:55 -0700 Subject: merge-base.c: pathological case fix. Also add some illustration requested by Linus. Signed-off-by: Junio C Hamano --- merge-base.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/merge-base.c b/merge-base.c index 18d81d08a5..923256c821 100644 --- a/merge-base.c +++ b/merge-base.c @@ -6,18 +6,82 @@ #define PARENT2 2 #define UNINTERESTING 4 -static int interesting(struct commit_list *list) +static struct commit *interesting(struct commit_list *list) { while (list) { struct commit *commit = list->item; list = list->next; if (commit->object.flags & UNINTERESTING) continue; - return 1; + return commit; } - return 0; + return NULL; } +/* + * A pathological example of how this thing works. + * + * Suppose we had this commit graph, where chronologically + * the timestamp on the commit are A <= B <= C <= D <= E <= F + * and we are trying to figure out the merge base for E and F + * commits. + * + * F + * / \ + * E A D + * \ / / + * B / + * \ / + * C + * + * First we push E and F to list to be processed. E gets bit 1 + * and F gets bit 2. The list becomes: + * + * list=F(2) E(1), result=empty + * + * Then we pop F, the newest commit, from the list. Its flag is 2. + * We scan its parents, mark them reachable from the side that F is + * reachable from, and push them to the list: + * + * list=E(1) D(2) A(2), result=empty + * + * Next pop E and do the same. + * + * list=D(2) B(1) A(2), result=empty + * + * Next pop D and do the same. + * + * list=C(2) B(1) A(2), result=empty + * + * Next pop C and do the same. + * + * list=B(1) A(2), result=empty + * + * Now it is B's turn. We mark its parent, C, reachable from B's side, + * and push it to the list: + * + * list=C(3) A(2), result=empty + * + * Now pop C and notice it has flags==3. It is placed on the result list, + * and the list now contains: + * + * list=A(2), result=C(3) + * + * We pop A and do the same. + * + * list=B(3), result=C(3) + * + * Next, we pop B and something very interesting happens. It has flags==3 + * so it is also placed on the result list, and its parents are marked + * uninteresting, retroactively, and placed back on the list: + * + * list=C(7), result=C(7) B(3) + * + * Now, list does not have any interesting commit. So we find the newest + * commit from the result list that is not marked uninteresting. Which is + * commit B. + */ + static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2) { struct commit_list *list = NULL; @@ -58,9 +122,7 @@ static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2) insert_by_date(p, &list); } } - if (!result) - return NULL; - return result->item; + return interesting(result); } int main(int argc, char **argv) -- cgit v1.2.3 From 5acc5bfd6303f1fec4b3d175a15a2ff800983be7 Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Thu, 11 Aug 2005 01:54:36 +0200 Subject: Debian packaging fixes. - Split gitk off to its own package; it needs tk installed, but nothing else does. - Refer to GPL properly, don't install COPYING. - Fix maintainer. - Use dh_movefiles instead of dh_install; we don't want to list everything *except* gitk. Signed-off-by: Junio C Hamano --- debian/changelog | 8 ++++++++ debian/control | 10 ++++++++-- debian/copyright | 25 +++++++++++++++++++++++-- debian/docs | 2 -- debian/git-core.files | 1 + debian/git-core.install | 1 - debian/git-tk.files | 1 + debian/rules | 4 +++- 8 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 debian/git-core.files delete mode 100644 debian/git-core.install create mode 100644 debian/git-tk.files diff --git a/debian/changelog b/debian/changelog index dbc61209d8..85d4d0094f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +git-core (0.99.4-3) unstable; urgency=low + + * Split off gitk. + * Do not depend on diff which is an essential package. + * Use dh_movefiles, not dh_install, to stage two subpackages. + + -- Matthias Urlichs Thu, 11 Aug 2005 01:43:24 +0200 + git-core (0.99.4-2) unstable; urgency=low * Git 0.99.4 official release. diff --git a/debian/control b/debian/control index 8bdbd731f3..53b87f44a6 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.6.1 Package: git-core Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, patch, diff, rcs +Depends: ${shlibs:Depends}, ${misc:Depends}, patch, rcs Recommends: rsync, curl, ssh, libmail-sendmail-perl, libemail-valid-perl Conflicts: git Description: The git content addressable filesystem @@ -15,5 +15,11 @@ Description: The git content addressable filesystem and flexible filesystem-based database designed to store directory trees with regard to their history. The top layer is a SCM-like tool which enables human beings to work with the database in a manner to a degree - similar to other SCM tools (like CVS, BitKeeper or Monotone). + similar to other SCM tools. + +Package: git-tk +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, git-core, tk8.4 +Description: The git content addressable filesystem, GUI add-on + This package contains 'gitk', the git revision tree visualizer. diff --git a/debian/copyright b/debian/copyright index 32b7e9c540..ea61effc40 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,3 +1,24 @@ -License: +This package was downloaded from ftp.kernel.org:/pub/software/scm/git/. -GPL v2 (see COPYING for details) +Upstream Author: Linus Torvalds and many others + +Copyright: + + Copyright 2005, Linus Torvalds and others. + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 dated June, 1991. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. diff --git a/debian/docs b/debian/docs index a252d0f2ca..e845566c06 100644 --- a/debian/docs +++ b/debian/docs @@ -1,3 +1 @@ README -COPYING - diff --git a/debian/git-core.files b/debian/git-core.files new file mode 100644 index 0000000000..74e4e23b01 --- /dev/null +++ b/debian/git-core.files @@ -0,0 +1 @@ +/usr diff --git a/debian/git-core.install b/debian/git-core.install deleted file mode 100644 index 72e8ffc0db..0000000000 --- a/debian/git-core.install +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/debian/git-tk.files b/debian/git-tk.files new file mode 100644 index 0000000000..3801e7564b --- /dev/null +++ b/debian/git-tk.files @@ -0,0 +1 @@ +/usr/bin/gitk diff --git a/debian/rules b/debian/rules index 2c575ffa19..921aeecfb4 100755 --- a/debian/rules +++ b/debian/rules @@ -61,7 +61,9 @@ install: build mkdir -p $(DOC_DESTDIR) find $(DOC) '(' -name '*.txt' -o -name '*.html' ')' -exec install {} $(DOC_DESTDIR) ';' - dh_install --list-missing --sourcedir=$(DESTDIR) + dh_movefiles -p git-tk + dh_movefiles -p git-core + find debian/tmp -type d -o -print | sed -e 's/^/? /' binary: build install dh_testdir -- cgit v1.2.3 From 8e832ebce61e6b82c7187365cbf12b2ef614c188 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 10 Aug 2005 22:53:27 -0700 Subject: String comparison of test is done with '=', not '=='. Caught this during a test setting /bin/sh to (d)ash. Signed-off-by: Junio C Hamano --- t/test-lib.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index f97f8eb395..e62bd0408c 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -87,16 +87,16 @@ test_failure_ () { say "FAIL $test_count: $1" shift echo "$@" | sed -e 's/^/ /' - test "$immediate" == "" || exit 1 + test "$immediate" = "" || exit 1 } test_debug () { - test "$debug" == "" || eval "$1" + test "$debug" = "" || eval "$1" } test_expect_failure () { - test "$#" == 2 || + test "$#" = 2 || error "bug in the test script: not 2 parameters to test-expect-failure" say >&3 "expecting failure: $2" if eval >&3 2>&4 "$2" @@ -108,7 +108,7 @@ test_expect_failure () { } test_expect_success () { - test "$#" == 2 || + test "$#" = 2 || error "bug in the test script: not 2 parameters to test-expect-success" say >&3 "expecting success: $2" if eval >&3 2>&4 "$2" -- cgit v1.2.3 From da7bc9b081ad8e45c997678c4ab4e7da9cd335ed Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 10 Aug 2005 22:15:02 -0400 Subject: [PATCH] Missing test_done All test scripts should end with test_done, which reports the test results. In the future, it could be used for other purposes, e.g. to distinguish graceful end from "exit" in a test. This patch fixes scripts that don't call test_done. Signed-off-by: Pavel Roskin Signed-off-by: Junio C Hamano --- t/t2003-checkout-cache-mkdir.sh | 1 + t/t3001-ls-files-others-exclude.sh | 2 ++ t/t4101-apply-nonl.sh | 2 ++ t/t5400-send-pack.sh | 2 ++ 4 files changed, 7 insertions(+) diff --git a/t/t2003-checkout-cache-mkdir.sh b/t/t2003-checkout-cache-mkdir.sh index 6ec28179be..ed5e4ee516 100755 --- a/t/t2003-checkout-cache-mkdir.sh +++ b/t/t2003-checkout-cache-mkdir.sh @@ -93,3 +93,4 @@ test_expect_success \ test -d tmp-path1 && test -f tmp-path1/file1' +test_done diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index dbff346c0a..5beaaa3375 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -66,3 +66,5 @@ test_expect_success \ --exclude-from=.git/ignore \ >output && diff -u expect output' + +test_done diff --git a/t/t4101-apply-nonl.sh b/t/t4101-apply-nonl.sh index 380ef15a27..26b131d0d5 100755 --- a/t/t4101-apply-nonl.sh +++ b/t/t4101-apply-nonl.sh @@ -30,3 +30,5 @@ do "git-apply Date: Wed, 10 Aug 2005 22:10:01 -0400 Subject: [PATCH] Need to set PAGER in tests "t5400-send-pack.sh --verbose" stops waiting for user input. It happens because "git log" uses less for output now. To prevent this, PAGER should be set to cat. Signed-off-by: Pavel Roskin Signed-off-by: Junio C Hamano --- t/test-lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index e62bd0408c..5cdd41dd93 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -5,8 +5,9 @@ # For repeatability, reset the environment to known value. LANG=C +PAGER=cat TZ=UTC -export LANG TZ +export LANG PAGER TZ unset AUTHOR_DATE unset AUTHOR_EMAIL unset AUTHOR_NAME -- cgit v1.2.3 From 4d9d62fa7ca01c481d224e2a2187e38ec2f0996a Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 10 Aug 2005 23:56:21 -0400 Subject: [PATCH] Trapping exit in tests, using return for errors I have noticed that "make test" fails without any explanations when the "merge" utility is missing. I don't think tests should be silent in case of failure. It turned out that the particular test was using "exit" to interrupt the test in case of an error. This caused the whole test script to exit. No further tests would be run even if "--immediate" wasn't specified. No error message was printed. This patch does following: All instances of "exit", "exit 1" and "(exit 1)" in tests have been replaced with "return 1". In fact, "(exit 1)" had no effect. File descriptor 5 is duplicated from file descriptor 1. This is needed to print important error messages from tests. New function test_run_() has been introduced. Any "return" in the test would merely cause that function to return without skipping calls to test_failure_() and test_ok_(). The new function also traps "exit" and treats it like a fatal error (in case somebody reintroduces "exit" in the tests). test_expect_failure() and test_expect_success() check both the result of eval and the return value of test_run_(). If the later is not 0, it's always a failure because it indicates the the test didn't complete. Signed-off-by: Pavel Roskin Signed-off-by: Junio C Hamano --- t/t1001-read-tree-m-2way.sh | 8 ++++---- t/t1002-read-tree-m-u-2way.sh | 8 ++++---- t/t1005-read-tree-m-2way-emu23.sh | 10 +++++----- t/t4002-diff-basic.sh | 6 +++--- t/t5300-pack-object.sh | 12 ++++++------ t/t5400-send-pack.sh | 4 ++-- t/test-lib.sh | 19 +++++++++++++++---- 7 files changed, 39 insertions(+), 28 deletions(-) diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh index b3e6bd57d0..919f2b3109 100755 --- a/t/t1001-read-tree-m-2way.sh +++ b/t/t1001-read-tree-m-2way.sh @@ -100,7 +100,7 @@ test_expect_success \ git-checkout-cache -u -f -q -a && git-update-cache --add yomin && read_tree_twoway $treeH $treeM && - git-ls-files --stage >4.out || exit + git-ls-files --stage >4.out || return 1 diff -u M.out 4.out >4diff.out compare_change 4diff.out expected && check_cache_at yomin clean' @@ -114,7 +114,7 @@ test_expect_success \ git-update-cache --add yomin && echo yomin yomin >yomin && read_tree_twoway $treeH $treeM && - git-ls-files --stage >5.out || exit + git-ls-files --stage >5.out || return 1 diff -u M.out 5.out >5diff.out compare_change 5diff.out expected && check_cache_at yomin dirty' @@ -215,7 +215,7 @@ test_expect_success \ echo nitfol nitfol >nitfol && git-update-cache --add nitfol && read_tree_twoway $treeH $treeM && - git-ls-files --stage >14.out || exit + git-ls-files --stage >14.out || return 1 diff -u M.out 14.out >14diff.out compare_change 14diff.out expected && check_cache_at nitfol clean' @@ -229,7 +229,7 @@ test_expect_success \ git-update-cache --add nitfol && echo nitfol nitfol nitfol >nitfol && read_tree_twoway $treeH $treeM && - git-ls-files --stage >15.out || exit + git-ls-files --stage >15.out || return 1 diff -u M.out 15.out >15diff.out compare_change 15diff.out expected && check_cache_at nitfol dirty' diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh index 2f1ee79698..512d8977a2 100755 --- a/t/t1002-read-tree-m-u-2way.sh +++ b/t/t1002-read-tree-m-u-2way.sh @@ -73,7 +73,7 @@ test_expect_success \ 'rm -f .git/index && git-update-cache --add yomin && git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >4.out || exit + git-ls-files --stage >4.out || return 1 diff --unified=0 M.out 4.out >4diff.out compare_change 4diff.out expected && check_cache_at yomin clean && @@ -90,7 +90,7 @@ test_expect_success \ git-update-cache --add yomin && echo yomin yomin >yomin && git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >5.out || exit + git-ls-files --stage >5.out || return 1 diff --unified=0 M.out 5.out >5diff.out compare_change 5diff.out expected && check_cache_at yomin dirty && @@ -192,7 +192,7 @@ test_expect_success \ echo nitfol nitfol >nitfol && git-update-cache --add nitfol && git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >14.out || exit + git-ls-files --stage >14.out || return 1 diff --unified=0 M.out 14.out >14diff.out compare_change 14diff.out expected && sum bozbar frotz >actual14.sum && @@ -212,7 +212,7 @@ test_expect_success \ git-update-cache --add nitfol && echo nitfol nitfol nitfol >nitfol && git-read-tree -m -u $treeH $treeM && - git-ls-files --stage >15.out || exit + git-ls-files --stage >15.out || return 1 diff --unified=0 M.out 15.out >15diff.out compare_change 15diff.out expected && check_cache_at nitfol dirty && diff --git a/t/t1005-read-tree-m-2way-emu23.sh b/t/t1005-read-tree-m-2way-emu23.sh index d80752ddd5..9227254fce 100755 --- a/t/t1005-read-tree-m-2way-emu23.sh +++ b/t/t1005-read-tree-m-2way-emu23.sh @@ -120,7 +120,7 @@ test_expect_success \ git-checkout-cache -u -f -q -a && git-update-cache --add yomin && read_tree_twoway $treeH $treeM && - git-ls-files --stage >4.out || exit + git-ls-files --stage >4.out || return 1 diff -u M.out 4.out >4diff.out compare_change 4diff.out expected && check_cache_at yomin clean' @@ -136,7 +136,7 @@ test_expect_success \ git-update-cache --add yomin && echo yomin yomin >yomin && read_tree_twoway $treeH $treeM && - git-ls-files --stage >5.out || exit + git-ls-files --stage >5.out || return 1 diff -u M.out 5.out >5diff.out compare_change 5diff.out expected && check_cache_at yomin dirty' @@ -241,7 +241,7 @@ test_expect_success \ echo nitfol nitfol >nitfol && git-update-cache --add nitfol && read_tree_twoway $treeH $treeM && - git-ls-files --stage >14.out || exit + git-ls-files --stage >14.out || return 1 diff -u M.out 14.out >14diff.out compare_change 14diff.out expected && check_cache_at nitfol clean' @@ -255,7 +255,7 @@ test_expect_success \ git-update-cache --add nitfol && echo nitfol nitfol nitfol >nitfol && read_tree_twoway $treeH $treeM && - git-ls-files --stage >15.out || exit + git-ls-files --stage >15.out || return 1 diff -u M.out 15.out >15diff.out compare_change 15diff.out expected && check_cache_at nitfol dirty' @@ -352,7 +352,7 @@ test_expect_success \ sed -e "s/such as/SUCH AS/" bozbar-old >bozbar && git-update-cache --add bozbar && read_tree_twoway $treeH $treeM && - git-ls-files --stage >22.out || exit + git-ls-files --stage >22.out || return 1 diff -u M.out 22.out >22diff.out compare_change 22diff.out && check_cache_at bozbar clean' diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh index 03fc4b9830..2ec2961189 100755 --- a/t/t4002-diff-basic.sh +++ b/t/t4002-diff-basic.sh @@ -191,7 +191,7 @@ test_expect_success \ 'rm -fr Z [A-Z][A-Z] && git-read-tree $tree_A && git-checkout-cache -f -a && - git-read-tree -m $tree_O || (exit 1) + git-read-tree -m $tree_O || return 1 git-update-cache --refresh >/dev/null ;# this can exit non-zero git-diff-files >.test-a && cmp_diff_files_output .test-a .test-recursive-OA' @@ -201,7 +201,7 @@ test_expect_success \ 'rm -fr Z [A-Z][A-Z] && git-read-tree $tree_B && git-checkout-cache -f -a && - git-read-tree -m $tree_O || (exit 1) + git-read-tree -m $tree_O || return 1 git-update-cache --refresh >/dev/null ;# this can exit non-zero git-diff-files >.test-a && cmp_diff_files_output .test-a .test-recursive-OB' @@ -211,7 +211,7 @@ test_expect_success \ 'rm -fr Z [A-Z][A-Z] && git-read-tree $tree_B && git-checkout-cache -f -a && - git-read-tree -m $tree_A || (exit 1) + git-read-tree -m $tree_A || return 1 git-update-cache --refresh >/dev/null ;# this can exit non-zero git-diff-files >.test-a && cmp_diff_files_output .test-a .test-recursive-AB' diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index b0b9329573..03951242d3 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -16,7 +16,7 @@ test_expect_success \ for i in a b c do dd if=/dev/zero bs=4k count=1 | tr "\\0" $i >$i && - git-update-cache --add $i || exit + git-update-cache --add $i || return 1 done && cat c >d && echo foo >>d && git-update-cache --add d && tree=`git-write-tree` && @@ -29,7 +29,7 @@ test_expect_success \ while read object do t=`git-cat-file -t $object` && - git-cat-file $t $object || exit 1 + git-cat-file $t $object || return 1 done expect' @@ -58,7 +58,7 @@ test_expect_success \ do cmp $path ../.git/$path || { echo $path differs. - exit 1 + return 1 } done' cd $TRASH @@ -88,7 +88,7 @@ test_expect_success \ do cmp $path ../.git/$path || { echo $path differs. - exit 1 + return 1 } done' cd $TRASH @@ -106,7 +106,7 @@ test_expect_success \ while read object do t=`git-cat-file -t $object` && - git-cat-file $t $object || exit 1 + git-cat-file $t $object || return 1 done current && diff expect current' @@ -122,7 +122,7 @@ test_expect_success \ while read object do t=`git-cat-file -t $object` && - git-cat-file $t $object || exit 1 + git-cat-file $t $object || return 1 done current && diff expect current' diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index a362c6ebe0..2c142dfeb0 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -18,7 +18,7 @@ test_expect_success setup ' do sleep 1 && commit=$(echo "Commit #$i" | git-commit-tree $tree -p $parent) && - parent=$commit || exit + parent=$commit || return 1 done && echo "$commit" >.git/HEAD && git clone -l ./. victim && @@ -31,7 +31,7 @@ test_expect_success setup ' do sleep 1 && commit=$(echo "Rebase #$i" | git-commit-tree $tree -p $parent) && - parent=$commit || exit + parent=$commit || return 1 done && echo "$commit" >.git/HEAD && echo Rebase && diff --git a/t/test-lib.sh b/t/test-lib.sh index 5cdd41dd93..abcf90323e 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -63,6 +63,7 @@ do esac done +exec 5>&1 if test "$verbose" = "t" then exec 4>&2 3>&1 @@ -96,15 +97,24 @@ test_debug () { test "$debug" = "" || eval "$1" } +test_run_ () { + trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit + eval >&3 2>&4 "$1" + eval_ret="$?" + trap - exit + return 0 +} + test_expect_failure () { test "$#" = 2 || error "bug in the test script: not 2 parameters to test-expect-failure" say >&3 "expecting failure: $2" - if eval >&3 2>&4 "$2" + test_run_ "$2" + if [ "$?" = 0 -a "$eval_ret" != 0 ] then - test_failure_ "$@" - else test_ok_ "$1" + else + test_failure_ "$@" fi } @@ -112,7 +122,8 @@ test_expect_success () { test "$#" = 2 || error "bug in the test script: not 2 parameters to test-expect-success" say >&3 "expecting success: $2" - if eval >&3 2>&4 "$2" + test_run_ "$2" + if [ "$?" = 0 -a "$eval_ret" = 0 ] then test_ok_ "$1" else -- cgit v1.2.3 From 41184273d173c252532b3aba730ee7fdf35291f4 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Thu, 11 Aug 2005 12:00:40 -0400 Subject: [PATCH] Trapping exit in tests, using return for errors: further fixes. "return" from a test would leave the exit trap set, which could cause a spurious error message if it's the last test in the script or --immediate is used. The easiest solution would be to have a global trap that is set when test-lib.sh is sourced and unset either by test_done(), error() or by test_failure_() with --immediate. Signed-off-by: Pavel Roskin Signed-off-by: Junio C Hamano --- t/test-lib.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index abcf90323e..1523d2ebbf 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -36,6 +36,7 @@ unset SHA1_FILE_DIRECTORY error () { echo "* error: $*" + trap - exit exit 1 } @@ -74,6 +75,8 @@ fi test_failure=0 test_count=0 +trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit + # You are not expected to call test_ok_ and test_failure_ directly, use # the text_expect_* functions instead. @@ -89,7 +92,7 @@ test_failure_ () { say "FAIL $test_count: $1" shift echo "$@" | sed -e 's/^/ /' - test "$immediate" = "" || exit 1 + test "$immediate" = "" || { trap - exit; exit 1; } } @@ -98,10 +101,8 @@ test_debug () { } test_run_ () { - trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit eval >&3 2>&4 "$1" eval_ret="$?" - trap - exit return 0 } @@ -132,6 +133,7 @@ test_expect_success () { } test_done () { + trap - exit case "$test_failure" in 0) # We could: -- cgit v1.2.3 From a6bc31338ee99b1ade13b260c96800ea826bb9d1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 11 Aug 2005 18:52:34 -0700 Subject: Clean generated deb files. Do not forgot that we have a separate git-tk package these days. Signed-off-by: Junio C Hamano --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e0ea88fbae..e8441af577 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,8 @@ deb: dist clean: rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROG) $(LIB_FILE) - rm -f $(GIT_TARNAME).tar.gz git-core.spec git-core_$(GIT_VERSION)-*.deb + rm -f $(GIT_TARNAME).tar.gz git-core.spec + rm -f git-core_$(GIT_VERSION)-*.deb git-tk_$(GIT_VERSION)-*.deb rm -rf $(GIT_TARNAME) $(MAKE) -C tools/ clean $(MAKE) -C Documentation/ clean -- cgit v1.2.3 From f88fcf8bab6a3dcd1255bc64f50235c745458962 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Thu, 11 Aug 2005 19:38:09 -0400 Subject: [PATCH] Fix parallel pull dependancy tracking. It didn't refetch an object it already had (good), but didn't process it, either (bad). Synchronously process anything you already have. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- pull.c | 57 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/pull.c b/pull.c index 950d9f47bd..cf3ec73841 100644 --- a/pull.c +++ b/pull.c @@ -98,12 +98,38 @@ static int process_tag(struct tag *tag) static struct object_list *process_queue = NULL; static struct object_list **process_queue_end = &process_queue; -static int process(unsigned char *sha1, const char *type) +static int process_object(struct object *obj) { - struct object *obj; - if (has_sha1_file(sha1)) + if (obj->type == commit_type) { + if (process_commit((struct commit *)obj)) + return -1; + return 0; + } + if (obj->type == tree_type) { + if (process_tree((struct tree *)obj)) + return -1; + return 0; + } + if (obj->type == blob_type) { + return 0; + } + if (obj->type == tag_type) { + if (process_tag((struct tag *)obj)) + return -1; return 0; - obj = lookup_object_type(sha1, type); + } + return error("Unable to determine requirements " + "of type %s for %s", + obj->type, sha1_to_hex(obj->sha1)); +} + +static int process(unsigned char *sha1, const char *type) +{ + struct object *obj = lookup_object_type(sha1, type); + if (has_sha1_file(sha1)) { + /* We already have it, so we should scan it now. */ + return process_object(obj); + } if (object_list_contains(process_queue, obj)) return 0; object_list_insert(obj, process_queue_end); @@ -134,27 +160,8 @@ static int loop(void) return -1; if (!obj->type) parse_object(obj->sha1); - if (obj->type == commit_type) { - if (process_commit((struct commit *)obj)) - return -1; - continue; - } - if (obj->type == tree_type) { - if (process_tree((struct tree *)obj)) - return -1; - continue; - } - if (obj->type == blob_type) { - continue; - } - if (obj->type == tag_type) { - if (process_tag((struct tag *)obj)) - return -1; - continue; - } - return error("Unable to determine requirements " - "of type %s for %s", - obj->type, sha1_to_hex(obj->sha1)); + if (process_object(obj)) + return -1; } return 0; } -- cgit v1.2.3 From 0d62fb5672c7b6e3fc6c5418d61ff39bf6034741 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Thu, 11 Aug 2005 23:17:55 -0400 Subject: [PATCH] Also parse objects we already have In the case where we don't know from context what type an object is, but we don't have to fetch it, we need to parse it to determine the type before processing it. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- pull.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pull.c b/pull.c index cf3ec73841..e7bf83bb03 100644 --- a/pull.c +++ b/pull.c @@ -127,6 +127,7 @@ static int process(unsigned char *sha1, const char *type) { struct object *obj = lookup_object_type(sha1, type); if (has_sha1_file(sha1)) { + parse_object(sha1); /* We already have it, so we should scan it now. */ return process_object(obj); } -- cgit v1.2.3