Git development
 help / color / mirror / Atom feed
* Re: gitweb wishlist
From: Kay Sievers @ 2005-05-14  2:34 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git
In-Reply-To: <20050513120618.GA26263@diku.dk>

On Fri, 2005-05-13 at 14:06 +0200, Jonas Fonseca wrote:
> I don't know if this is intentional, but it looks like gitweb discards
> everything after the first line starting with 'Signed-off-by:' on the
> log page. This will in some cases remove valuable log information when
> a second author or the committer adds additional comments to a commit:
> 
>         <log message by author>
> 
>         Signed-off-by: <author>
> 
>         <log message by committer>
> 
>         Signed-off-by: <committer>
> 
> The commit page gets it right, which is why I suspect it might just be a
> way to trim the amount of text on the log page.
> 
> I also noticed that there is a 'faulty' signed-off-by line in commit
> 14ebb908e10f068dc1901d35f4b716bc69143d19 in case the above is
> intentional. Dunno if that should be matched by relaxing the regexp a
> little.

All that should work now.

Thanks,
Kay


^ permalink raw reply

* Re: gitweb wishlist
From: Kay Sievers @ 2005-05-14  2:39 UTC (permalink / raw)
  To: Jan-Benedict Glaw; +Cc: Petr Baudis, git
In-Reply-To: <20050511093015.GK8176@lug-owl.de>

On Wed, 2005-05-11 at 11:30 +0200, Jan-Benedict Glaw wrote:
> On Wed, 2005-05-11 03:26:26 +0200, Petr Baudis <pasky@ucw.cz> wrote:
> >   I would be very happy if you could extend the gitweb scripts a little.
> > Basically, what I need is to have ability to create a permanent link to
> > a given file in the repository, which stays same across revisions (as
> > long as the file stays with the given name, obviously).
> 
> I've got another one. I'd like to see st_mtime on the file lists to see
> when a file was last touched...

We don't have that information in the trees. The date is only available
in the commits and reading all commits or storing that information in a
index or a database is beyond the scope of that simple cgi.

Thanks,
Kay


^ permalink raw reply

* Re: gitweb wishlist
From: Kay Sievers @ 2005-05-14  2:43 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git
In-Reply-To: <20050511012626.GL26384@pasky.ji.cz>

On Wed, 2005-05-11 at 03:26 +0200, Petr Baudis wrote:
>   I would be very happy if you could extend the gitweb scripts a little.
> Basically, what I need is to have ability to create a permanent link to
> a given file in the repository, which stays same across revisions (as
> long as the file stays with the given name, obviously).
> 
>   E.g. I would like to have something like
> 
> 	http://www.kernel.org/git/gitweb.cgi?p=cogito%2Fcogito.git;n=contrib/ciabot.pl
> 
> for file contrib/ciabot.pl in the latest Cogito tree, and

http://www.kernel.org/git/gitweb.cgi?p=cogito/cogito.git;a=blob;f=contrib/ciabot.pl

> 	http://www.kernel.org/git/gitweb.cgi?p=cogito%2Fcogito.git;n=contrib
> 
> for the list of the contrib/ directory in the latest Cogito tree.

http://www.kernel.org/git/gitweb.cgi?p=cogito/cogito.git;a=tree;f=contrib

>   I think I would prefer the link from the repository index to go not to
> the log page, but some "summary" page, which would have some short
> information about the repository (owner, description, list of branches
> if gitweb supports that, list of tags, link to the latest tree and link
> to the log).

Sounds reasonable, I will try that with the next round.

Thanks,
Kay


^ permalink raw reply

* [ANNOUNCE] mtkdiff-20050514 (integrated w/ gitk)
From: Tejun Heo @ 2005-05-14  2:58 UTC (permalink / raw)
  To: paulus; +Cc: git

 Hello, guys.

 This is mtkdiff-20050514.  I've modified gitk to invoke gitkdiff on
double click and right click.  If you double click on a commit mtkdiff
will show the commit.  If you right click on a commit while another
one is selected, mtkdiff will show the difference between the two
commits (as in bk revtool).  Also, I've modified gitk & gitkdiff to
show commit SHA1 in the info text when a commit is selected.

 The tarball can be found at

 http://home-tj.org/mtkdiff/files/mtkdiff-20050514.tar.gz

 Patch of the gitk changes follow.  (gitk-0.9 vs. the modified version)

 Thanks.

--- gitk-0.9	2005-05-14 11:57:02.000000000 +0900
+++ gitk	2005-05-14 11:57:04.000000000 +0900
@@ -175,6 +175,8 @@ proc makewindow {} {
     pack .ctop -side top -fill both -expand 1
 
     bindall <1> {selcanvline %x %y}
+    bindall <Double-1> {canvdclick %x %y}
+    bindall <3> {canvrclick %x %y}
     bindall <B1-Motion> {selcanvline %x %y}
     bindall <ButtonRelease-4> "allcanvs yview scroll -5 u"
     bindall <ButtonRelease-5> "allcanvs yview scroll 5 u"
@@ -473,7 +475,7 @@ proc drawgraph {start} {
     }
 }
 
-proc selcanvline {x y} {
+proc coordtoline {x, y} {
     global canv canvy0 ctext linespc selectedline
     global lineid linehtag linentag linedtag
     set ymax [lindex [$canv cget -scrollregion] 3]
@@ -483,8 +485,38 @@ proc selcanvline {x y} {
     if {$l < 0} {
 	set l 0
     }
-    if {[info exists selectedline] && $selectedline == $l} return
-    selectline $l
+    if {[info exists selectedline] && $selectedline == $l} {
+	return -1
+    }
+    return $l
+}
+
+proc selcanvline {x y} {
+    set l [coordtoline $x, $y]
+    if {$l >= 0} {
+	selectline $l
+    }
+}
+
+proc canvdclick {x y} {
+    global lineid selectedline
+    selcanvline $x $y
+    if {[info exists selectedline]} {
+	exec gitkdiff -r $lineid($selectedline) &
+    }
+}
+
+proc canvrclick {x y} {
+    global selectedline lineid
+
+    if {[info exists selectedline]} {
+	set l [coordtoline $x, $y]
+	if {$selectedline != $l} {
+	    exec gitkdiff -r $lineid($selectedline) -r $lineid($l) &
+	}
+    } else {
+	selcanvline $x $y
+    }
 }
 
 proc selectline {l} {
@@ -521,6 +553,7 @@ proc selectline {l} {
     $ctext conf -state normal
     $ctext delete 0.0 end
     set info $commitinfo($id)
+    $ctext insert end "Commit: $id\n"
     $ctext insert end "Author: [lindex $info 1]  [lindex $info 2]\n"
     $ctext insert end "Committer: [lindex $info 3]  [lindex $info 4]\n"
     $ctext insert end "\n"

^ permalink raw reply

* Re: [PATCH] [RFD] Add repoid identifier to commit [its a workspace id, isn't it?]
From: Jon Seymour @ 2005-05-14  5:02 UTC (permalink / raw)
  To: Petr Baudis; +Cc: H. Peter Anvin, tglx, git
In-Reply-To: <2cfc403205051316495b46115e@mail.gmail.com>

Of course, this graph wasn't really the best example of a traditional
SCM branch or the point I was trying to make.
> 
> Rn -------------
> |      \         \
> Rn-1 Ba,n   Bb,n
> |     /             |
> Rn-2             |
> |       \           |
> Rn-3 Ba,n-1  |
> |    /             /
> Rn-4 -----------

It's more like:

Tn     B,W(a),n
|        |                 \
|        B,W(a),n-1   B,W(b),n-1
|        |                  |
Tn-1  |                   |
|        B,W(a),1------|
|       /
Tn-2

Branch B diverges from the main trunk T, parallel (but frequently
convergent) development in branch B happens in two workspaces W(a) and
W(b).

So a branchid would track all commits that contribute to a branch,
while a workspace id would track which commits happened in which
workspace, to enable the reconstruction of the merge order of the
global history with respect to the workspaces that perform commits.

jon.
-- 
homepage: http://www.zeta.org.au/~jon/
blog: http://orwelliantremors.blogspot.com/

^ permalink raw reply

* [PATCH 1/2] Test framework take two.
From: Junio C Hamano @ 2005-05-14  5:50 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

Petr Baudis raised many valid points at the earlier attempts in
git mailing list.  This round, test-lib.sh has beenupdated to a
bit more modern style, and the default output is made easier to
read.  Also included is one sample test script that tests the
very basics.  This test has already found one leftover bug
missed when we introduced symlink support, which has been fixed
since then.  The supplied Makefile is designed to run all the
available tests.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

t/Makefile       |   15 ++++
t/t0000-basic.sh |  179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
t/test-lib.sh    |  142 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 336 insertions(+)
t/Makefile (. --> 100644)
t/t0000-basic.sh (. --> 100755)
t/test-lib.sh (. --> 100755)

--- a/t/Makefile
+++ b/t/Makefile
@@ -0,0 +1,15 @@
+# Run tests
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+#OPTS=--verbose --debug
+OPTS=
+
+T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
+
+all::
+	@$(foreach t,$T,echo "*** $t ***"; sh $t $(OPTS) || exit; )
+	rm -fr trash
+
+clean::
+	rm -fr trash
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -0,0 +1,179 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='Test the very basics part #1.
+
+The rest of the test suite does not check the basic operation of git
+plumbing commands to work very carefully.  Their job is to concentrate
+on tricky features that caused bugs in the past to detect regression.
+
+This test runs very basic features, like registering things in cache,
+writing tree, etc.
+
+Note that this test *deliberately* hard-codes many expected object
+IDs.  When object ID computation changes, like in the previous case of
+swapping compression and hashing order, the person who is making the
+modification *should* take notice and update the test vectors here.
+'
+. ./test-lib.sh
+
+################################################################
+# init-db has been done in an empty repository.
+# make sure it is empty.
+
+find .git/objects -type f -print >should-be-empty
+test_expect_success \
+    '.git/objects should be empty after git-init-db in an empty repo.' \
+    'cmp -s /dev/null should-be-empty' 
+
+# also it should have 256 subdirectories.  257 is counting "objects"
+find .git/objects -type d -print >full-of-directories
+test_expect_success \
+    '.git/objects should have 256 subdirectories.' \
+    'test "$(wc -l full-of-directories | sed -e "s/ .*//")" = 257'
+
+################################################################
+# Basics of the basics
+
+# updating a new file without --add should fail.
+test_expect_failure \
+    'git-update-cache without --add should fail adding.' \
+    'git-update-cache should-be-empty'
+
+# and with --add it should succeed, even if it is empty (it used to fail).
+test_expect_success \
+    'git-update-cache with --add should succeed.' \
+    'git-update-cache --add should-be-empty'
+
+test_expect_success \
+    'writing tree out with git-write-tree' \
+    'tree=$(git-write-tree)'
+
+# we know the shape and contents of the tree and know the object ID for it.
+test_expect_success \
+    'validate object ID of a known tree.' \
+    'test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a'
+
+# Removing paths.
+rm -f should-be-empty full-of-directories
+test_expect_failure \
+    'git-update-cache without --remove should fail removing.' \
+    'git-update-cache should-be-empty'
+
+test_expect_success \
+    'git-update-cache with --remove should be able to remove.' \
+    'git-update-cache --remove should-be-empty'
+
+# Empty tree can be written with recent write-tree.
+test_expect_success \
+    'git-write-tree should be able to write an empty tree.' \
+    'tree=$(git-write-tree)'
+
+test_expect_success \
+    'validate object ID of a known tree.' \
+    'test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904'
+
+# Various types of objects
+mkdir path2 path3 path3/subp3
+for p in path0 path2/file2 path3/file3 path3/subp3/file3
+do
+    echo "hello $p" >$p
+    ln -s "hello $p" ${p}sym
+done
+test_expect_success \
+    'adding various types of objects with git-update-cache --add.' \
+    'find path* ! -type d -print0 | xargs -0 -r git-update-cache --add'
+
+# Show them and see that matches what we expect.
+test_expect_success \
+    'showing stage with git-ls-files --stage' \
+    'git-ls-files --stage >current'
+
+cat >expected <<\EOF
+100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
+120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0 path0sym
+100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0 path2/file2
+120000 d8ce161addc5173867a3c3c730924388daedbc38 0 path2/file2sym
+100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0 path3/file3
+120000 8599103969b43aff7e430efea79ca4636466794f 0 path3/file3sym
+100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0 path3/subp3/file3
+120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym
+EOF
+test_expect_success \
+    'validate git-ls-files output for a known tree.' \
+    'diff current expected'
+
+test_expect_success \
+    'writing tree out with git-write-tree.' \
+    'tree=$(git-write-tree)'
+test_expect_success \
+    'validate object ID for a known tree.' \
+    'test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b'
+
+test_expect_success \
+    'showing tree with git-ls-tree' \
+    'git-ls-tree $tree >current'
+cat >expected <<\EOF
+100644	blob	f87290f8eb2cbbea7857214459a0739927eab154	path0
+120000	blob	15a98433ae33114b085f3eb3bb03b832b3180a01	path0sym
+040000	tree	58a09c23e2ca152193f2786e06986b7b6712bdbe	path2
+040000	tree	21ae8269cacbe57ae09138dcc3a2887f904d02b3	path3
+EOF
+test_expect_success \
+    'git-ls-tree output for a known tree.' \
+    'diff current expected'
+
+test_expect_success \
+    'showing tree with git-ls-tree -r' \
+    'git-ls-tree -r $tree >current'
+cat >expected <<\EOF
+100644	blob	f87290f8eb2cbbea7857214459a0739927eab154	path0
+120000	blob	15a98433ae33114b085f3eb3bb03b832b3180a01	path0sym
+040000	tree	58a09c23e2ca152193f2786e06986b7b6712bdbe	path2
+100644	blob	3feff949ed00a62d9f7af97c15cd8a30595e7ac7	path2/file2
+120000	blob	d8ce161addc5173867a3c3c730924388daedbc38	path2/file2sym
+040000	tree	21ae8269cacbe57ae09138dcc3a2887f904d02b3	path3
+100644	blob	0aa34cae68d0878578ad119c86ca2b5ed5b28376	path3/file3
+120000	blob	8599103969b43aff7e430efea79ca4636466794f	path3/file3sym
+040000	tree	3c5e5399f3a333eddecce7a9b9465b63f65f51e2	path3/subp3
+100644	blob	00fb5908cb97c2564a9783c0c64087333b3b464f	path3/subp3/file3
+120000	blob	6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c	path3/subp3/file3sym
+EOF
+test_expect_success \
+    'git-ls-tree -r output for a known tree.' \
+    'diff current expected'
+
+################################################################
+rm .git/index
+test_expect_success \
+    'git-read-tree followed by write-tree should be idempotent.' \
+    'git-read-tree $tree &&
+     test -f .git/index &&
+     newtree=$(git-write-tree) &&
+     test "$newtree" = "$tree"'
+
+cat >expected <<\EOF
+*100644->100644	blob	f87290f8eb2cbbea7857214459a0739927eab154->0000000000000000000000000000000000000000	path0
+*120000->120000	blob	15a98433ae33114b085f3eb3bb03b832b3180a01->0000000000000000000000000000000000000000	path0sym
+*100644->100644	blob	3feff949ed00a62d9f7af97c15cd8a30595e7ac7->0000000000000000000000000000000000000000	path2/file2
+*120000->120000	blob	d8ce161addc5173867a3c3c730924388daedbc38->0000000000000000000000000000000000000000	path2/file2sym
+*100644->100644	blob	0aa34cae68d0878578ad119c86ca2b5ed5b28376->0000000000000000000000000000000000000000	path3/file3
+*120000->120000	blob	8599103969b43aff7e430efea79ca4636466794f->0000000000000000000000000000000000000000	path3/file3sym
+*100644->100644	blob	00fb5908cb97c2564a9783c0c64087333b3b464f->0000000000000000000000000000000000000000	path3/subp3/file3
+*120000->120000	blob	6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c->0000000000000000000000000000000000000000	path3/subp3/file3sym
+EOF
+test_expect_success \
+    'validate git-diff-files output for a know cache/work tree state.' \
+    'git-diff-files >current && cmp -s current expected'
+
+test_expect_success \
+    'git-update-cache --refresh should succeed.' \
+    'git-update-cache --refresh'
+
+test_expect_success \
+    'no diff after checkout and git-update-cache --refresh.' \
+    'git-diff-files >current && cmp -s current /dev/null'
+
+test_done
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -0,0 +1,142 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+# For repeatability, reset the environment to known value.
+LANG=C
+TZ=UTC
+export LANG TZ
+unset AUTHOR_DATE
+unset AUTHOR_EMAIL
+unset AUTHOR_NAME
+unset COMMIT_AUTHOR_EMAIL
+unset COMMIT_AUTHOR_NAME
+unset GIT_ALTERNATE_OBJECT_DIRECTORIES
+unset GIT_AUTHOR_DATE
+unset GIT_AUTHOR_EMAIL
+unset GIT_AUTHOR_NAME
+unset GIT_COMMITTER_EMAIL
+unset GIT_COMMITTER_NAME
+unset GIT_DIFF_OPTS
+unset GIT_DIR
+unset GIT_EXTERNAL_DIFF
+unset GIT_INDEX_FILE
+unset GIT_OBJECT_DIRECTORY
+unset SHA1_FILE_DIRECTORIES
+unset SHA1_FILE_DIRECTORY
+
+# Each test should start with something like this, after copyright notices:
+#
+# test_description='Description of this test...
+# This test checks if command xyzzy does the right thing...
+# '
+# . ./test-lib.sh
+
+error () {
+	echo "* error: $*"
+	exit 1
+}
+
+say () {
+	echo "* $*"
+}
+
+test "${test_description}" != "" ||
+error "Test script did not set test_description."
+
+while test "$#" -ne 0
+do
+	case "$1" in
+	-d|--d|--de|--deb|--debu|--debug)
+		debug=t; shift ;;
+	-h|--h|--he|--hel|--help)
+		echo "$test_description"
+		exit 0 ;;
+	-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
+		verbose=t; shift ;;
+	*)
+		break ;;
+	esac
+done
+
+if test "$verbose" = "t"
+then
+	exec 4>&2 3>&1
+else
+	exec 4>/dev/null 3>/dev/null
+fi
+
+test_failure=0
+test_count=0
+
+test_debug () {
+	test "$debug" == "" || eval "$1"
+}
+
+test_ok () {
+	test_count=$(expr "$test_count" + 1)
+	say "ok #$test_count: $@"
+}
+
+test_failure () {
+	test_count=$(expr "$test_count" + 1)
+	test_failure=$(expr "$test_failure" + 1);
+	say "NO #$test_count: $@"
+}
+
+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"
+	then
+		test_failure "$@"
+	else
+		test_ok "$1"
+	fi
+}
+
+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"
+	then
+		test_ok "$1"
+	else
+		test_failure "$@"
+	fi
+}
+
+test_done () {
+	case "$test_failure" in
+	0)	
+		# We could:
+		# cd .. && rm -fr trash
+		# but that means we forbid any tests that use their own
+		# subdirectory from calling test_done without coming back
+		# to where they started from.
+		# The Makefile provided will clean this test area so
+		# we will leave things as they are.
+
+		say "passed all $test_count test(s)"
+		exit 0 ;;
+
+	*)
+		say "failed $test_failure among $test_count test(s)"
+		exit 1 ;;
+
+	esac
+}
+
+# Test the binaries we have just built.  The tests are kept in
+# t/ subdirectory and are run in trash subdirectory.
+PATH=$(pwd)/..:$PATH
+
+# Test repository
+test=trash
+rm -fr "$test"
+mkdir "$test"
+cd "$test"
+git-init-db 2>/dev/null || error "cannot run git-init-db"
------------------------------------------------


^ permalink raw reply

* [PATCH 2/2] The core GIT tests: recent additions and fixes.
From: Junio C Hamano @ 2005-05-14  5:52 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

This set of scripts are designed to test the features and fixes
we recently added to core GIT.  The convention to call test
helper function has been changed during the framework cleanup
(take two), and these tests have been updated to use the cleaned
up test-lib.sh interface.

Note that the last test, t2000-diff.sh, assumes that we updated
the built-in diff driver with the mode change bits normalization
patch I sent earlier.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

t/t0100-environment-names.sh |   84 ++++++++++++++++++++++++++++++++++++++++
t/t0200-update-cache.sh      |   51 ++++++++++++++++++++++++
t/t0400-ls-files.sh          |   33 +++++++++++++++
t/t0500-ls-files.sh          |   61 +++++++++++++++++++++++++++++
t/t1000-checkout-cache.sh    |   56 ++++++++++++++++++++++++++
t/t1001-checkout-cache.sh    |   90 +++++++++++++++++++++++++++++++++++++++++++
t/t2000-diff.sh              |   50 +++++++++++++++++++++++
7 files changed, 425 insertions(+)
t/t0100-environment-names.sh (. --> 100755)
t/t0200-update-cache.sh (. --> 100755)
t/t0400-ls-files.sh (. --> 100755)
t/t0500-ls-files.sh (. --> 100755)
t/t1000-checkout-cache.sh (. --> 100755)
t/t1001-checkout-cache.sh (. --> 100755)
t/t2000-diff.sh (. --> 100755)

--- a/t/t0100-environment-names.sh
+++ b/t/t0100-environment-names.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='general environment name warning test.
+
+This test makes sure that use of deprecated environment variables
+trigger the warnings from gitenv().'
+
+env_vars='GIT_AUTHOR_DATE:AUTHOR_DATE
+GIT_AUTHOR_EMAIL:AUTHOR_EMAIL
+GIT_AUTHOR_NAME:AUTHOR_NAME
+GIT_COMMITTER_EMAIL:COMMIT_AUTHOR_EMAIL
+GIT_COMMITTER_NAME:COMMIT_AUTHOR_NAME
+GIT_ALTERNATE_OBJECT_DIRECTORIES:SHA1_FILE_DIRECTORIES
+GIT_OBJECT_DIRECTORY:SHA1_FILE_DIRECTORY
+'
+
+. ./test-lib.sh
+
+export_them () {
+	for ev in $env_vars
+	do
+		new=$(expr "$ev" : '\(.*\):')
+		old=$(expr "$ev" : '.*:\(.*\)')
+		# Build and eval the following:
+		# case "${VAR+set}" in set) export VAR;; esac
+		evstr='case "${'$new'+set}" in set) export '$new';; esac'
+		eval "$evstr"
+		evstr='case "${'$old'+set}" in set) export '$old';; esac'
+		eval "$evstr"
+	done
+}
+
+date >path0
+git-update-cache --add path0
+tree=$(git-write-tree)
+
+AUTHOR_DATE='Wed May 11 23:55:18 2005'
+AUTHOR_EMAIL='author@example.xz'
+AUTHOR_NAME='A U Thor'
+COMMIT_AUTHOR_EMAIL='author@example.xz'
+COMMIT_AUTHOR_NAME='A U Thor'
+SHA1_FILE_DIRECTORY=.git/objects
+
+export_them
+
+echo 'foo' | git-commit-tree $tree >/dev/null 2>errmsg
+cat >expected-err <<\EOF
+warning: Attempting to use SHA1_FILE_DIRECTORY
+warning: GIT environment variables have been renamed.
+warning: Please adjust your scripts and environment.
+warning: old AUTHOR_DATE => new GIT_AUTHOR_DATE
+warning: old AUTHOR_EMAIL => new GIT_AUTHOR_EMAIL
+warning: old AUTHOR_NAME => new GIT_AUTHOR_NAME
+warning: old COMMIT_AUTHOR_EMAIL => new GIT_COMMITTER_EMAIL
+warning: old COMMIT_AUTHOR_NAME => new GIT_COMMITTER_NAME
+warning: old SHA1_FILE_DIRECTORY => new GIT_OBJECT_DIRECTORY
+EOF
+sed -ne '/^warning: /p' <errmsg >generated-err
+
+test_expect_success \
+    'using old names should issue warnings.' \
+    'cmp generated-err expected-err'
+
+for ev in $env_vars
+do
+	new=$(expr "$ev" : '\(.*\):')
+	old=$(expr "$ev" : '.*:\(.*\)')
+	# Build and eval the following:
+	# NEWENV=$OLDENV
+	evstr="$new=\$$old"
+	eval "$evstr"
+done
+export_them
+echo 'foo' | git-commit-tree $tree >/dev/null 2>errmsg
+sed -ne '/^warning: /p' <errmsg >generated-err
+
+test_expect_success \
+    'using old names but having new names should not issue warnings.' \
+    'cmp generated-err /dev/null'
+
+test_done
--- a/t/t0200-update-cache.sh
+++ b/t/t0200-update-cache.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='git-update-cache nonsense-path test.
+
+This test creates the following structure in the cache:
+
+    path0       - a file
+    path1       - a symlink
+    path2/file2 - a file in a directory
+    path3/file3 - a file in a directory
+
+and tries to git-update-cache --add the following:
+
+    path0/file0 - a file in a directory
+    path1/file1 - a file in a directory
+    path2       - a file
+    path3       - a symlink
+
+All of the attempts should fail.
+'
+
+. ./test-lib.sh
+
+mkdir path2 path3
+date >path0
+ln -s xyzzy path1
+date >path2/file2
+date >path3/file3
+
+test_expect_success \
+    'git-update-cache --add to add various paths.' \
+    'git-update-cache --add -- path0 path1 path2/file2 path3/file3'
+
+rm -fr path?
+
+mkdir path0 path1
+date >path2
+ln -s frotz path3
+date >path0/file0
+date >path1/file1
+
+for p in path0/file0 path1/file1 path2 path3
+do
+	test_expect_failure \
+	    "git-update-cache to add conflicting path $p should fail." \
+	    "git-update-cache --add -- $p"
+done
+test_done
--- a/t/t0400-ls-files.sh
+++ b/t/t0400-ls-files.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='git-ls-files test (--others should pick up symlinks).
+
+This test runs git-ls-files --others with the following on the
+filesystem.
+
+    path0       - a file
+    path1	- a symlink
+    path2/file2 - a file in a directory
+'
+. ./test-lib.sh
+
+date >path0
+ln -s xyzzy path1
+mkdir path2
+date >path2/file2
+test_expect_success \
+    'git-ls-files --others to show output.' \
+    'git-ls-files --others >.output'
+cat >.expected <<EOF
+path0
+path1
+path2/file2
+EOF
+
+test_expect_success \
+    'git-ls-files --others should pick up symlinks.' \
+    'diff .output .expected'
+test_done
--- a/t/t0500-ls-files.sh
+++ b/t/t0500-ls-files.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='git-ls-files -k flag test.
+
+This test prepares the following in the cache:
+
+    path0       - a file
+    path1       - a symlink
+    path2/file2 - a file in a directory
+    path3/file3 - a file in a directory
+
+and the following on the filesystem:
+
+    path0/file0 - a file in a directory
+    path1/file1 - a file in a directory
+    path2       - a file
+    path3       - a symlink
+    path4	- a file
+    path5	- a symlink
+    path6/file6 - a file in a directory
+
+git-ls-files -k should report that existing filesystem
+objects except path4, path5 and path6/file6 to be killed.
+'
+. ./test-lib.sh
+
+date >path0
+ln -s xyzzy path1
+mkdir path2 path3
+date >path2/file2
+date >path3/file3
+test_expect_success \
+    'git-update-cache --add to add various paths.' \
+    "git-update-cache --add -- path0 path1 path?/file?"
+
+rm -fr path?
+date >path2
+ln -s frotz path3
+ln -s nitfol path5
+mkdir path0 path1 path6
+date >path0/file0
+date >path1/file1
+date >path6/file6
+
+test_expect_success \
+    'git-ls-files -k to show killed files.' \
+    'git-ls-files -k >.output'
+cat >.expected <<EOF
+path0/file0
+path1/file1
+path2
+path3
+EOF
+
+test_expect_success \
+    'validate git-ls-files -k output.' \
+    'diff .output .expected'
+test_done
--- a/t/t1000-checkout-cache.sh
+++ b/t/t1000-checkout-cache.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='git-checkout-cache test.
+
+This test registers the following filesystem structure in the
+cache:
+
+    path0       - a file
+    path1/file1 - a file in a directory
+
+And then tries to checkout in a work tree that has the following:
+
+    path0/file0 - a file in a directory
+    path1       - a file
+
+The git-checkout-cache command should fail when attempting to checkout
+path0, finding it is occupied by a directory, and path1/file1, finding
+path1 is occupied by a non-directory.  With "-f" flag, it should remove
+the conflicting paths and succeed.
+'
+. ./test-lib.sh
+
+date >path0
+mkdir path1
+date >path1/file1
+
+test_expect_success \
+    'git-update-cache --add various paths.' \
+    'git-update-cache --add path0 path1/file1'
+
+rm -fr path0 path1
+mkdir path0
+date >path0/file0
+date >path1
+
+test_expect_failure \
+    'git-checkout-cache without -f should fail on conflicting work tree.' \
+    'git-checkout-cache -a'
+
+test_expect_success \
+    'git-checkout-cache with -f should succeed.' \
+    'git-checkout-cache -f -a'
+
+if test -f path0 && test -d path1 && test -f path1/file1
+then
+	test_ok "checkout successful"
+else
+	test_failure "checkout failed"
+fi
+
+test_done
+
+
--- a/t/t1001-checkout-cache.sh
+++ b/t/t1001-checkout-cache.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='git-checkout-cache test.
+
+This test registers the following filesystem structure in the cache:
+
+    path0/file0	- a file in a directory
+    path1/file1 - a file in a directory
+
+and attempts to check it out when the work tree has:
+
+    path0/file0 - a file in a directory
+    path1       - a symlink pointing at "path0"
+
+Checkout cache should fail to extract path1/file1 because the leading
+path path1 is occupied by a non-directory.  With "-f" it should remove
+the symlink path1 and create directory path1 and file path1/file1.
+'
+. ./test-lib.sh
+
+show_files() {
+	# show filesystem files, just [-dl] for type and name
+	find path? -ls |
+	sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /'
+	# what's in the cache, just mode and name
+	git-ls-files --stage |
+	sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /'
+	# what's in the tree, just mode and name.
+	git-ls-tree -r "$1" |
+	sed -e 's/^\([0-9]*\)	[^ ]*	[0-9a-f]*	/tr: \1 /'
+}
+
+mkdir path0
+date >path0/file0
+test_expect_success \
+    'git-update-cache --add path0/file0' \
+    'git-update-cache --add path0/file0'
+test_expect_success \
+    'writing tree out with git-write-tree' \
+    'tree1=$(git-write-tree)'
+test_debug 'show_files $tree1'
+
+mkdir path1
+date >path1/file1
+test_expect_success \
+    'git-update-cache --add path1/file1' \
+    'git-update-cache --add path1/file1'
+test_expect_success \
+    'writing tree out with git-write-tree' \
+    'tree2=$(git-write-tree)'
+test_debug 'show_files $tree2'
+
+rm -fr path1
+test_expect_success \
+    'read previously written tree and checkout.' \
+    'git-read-tree -m $tree1 && git-checkout-cache -f -a'
+test_debug 'show_files $tree1'
+
+ln -s path0 path1
+test_expect_success \
+    'git-update-cache --add a symlink.' \
+    'git-update-cache --add path1'
+test_expect_success \
+    'writing tree out with git-write-tree' \
+    'tree3=$(git-write-tree)'
+test_debug 'show_files $tree3'
+
+# Morten says "Got that?" here.
+# Test begins.
+
+test_expect_success \
+    'read previously written tree and checkout.' \
+    'git-read-tree $tree2 && git-checkout-cache -f -a'
+test_debug show_files $tree2
+
+if test ! -h path0 && test -d path0 &&
+   test ! -h path1 && test -d path1 &&
+   test ! -h path0/file0 && test -f path0/file0 &&
+   test ! -h path1/file1 && test -f path1/file1
+then
+    test_ok "checked out correctly."
+else
+    test_failure "did not check out correctly."
+fi
+
+test_done
+
--- a/t/t2000-diff.sh
+++ b/t/t2000-diff.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='Test built-in diff output engine.
+
+'
+. ./test-lib.sh
+
+echo >path0 'Line 1
+Line 2
+line 3'
+cat path0 >path1
+chmod +x path1
+
+test_expect_success \
+    'update-cache --add two files with and without +x.' \
+    'git-update-cache --add path0 path1'
+
+mv path0 path0-
+sed -e 's/line/Line/' <path0- >path0
+chmod +x path0
+rm -f path1
+test_expect_success \
+    'git-diff-files -p after editing work tree.' \
+    'git-diff-files -p >current'
+cat >expected <<\EOF
+# mode: 100644 100755 path0
+--- a/path0
++++ b/path0
+@@ -1,3 +1,3 @@
+ Line 1
+ Line 2
+-line 3
++Line 3
+# mode: 100755 . path1
+--- a/path1
++++ /dev/null
+@@ -1,3 +0,0 @@
+-Line 1
+-Line 2
+-line 3
+EOF
+
+test_expect_success \
+    'validate git-diff-files -p output.' \
+    'cmp -s current expected'
+
+test_done


^ permalink raw reply

* speeding up cg-log -u
From: Zack Brown @ 2005-05-14  6:19 UTC (permalink / raw)
  To: git

Hi folks,

I notice that cg-log takes a -u parameter, that lets you restrict the log
entries that are displayed, to match the argument you give it. So

cg-log -uKH

shows all the logs where Greg KH played a part.

Currently cg-log handles this by grabbing all the log data from git, and
then grepping through it.

Would it be faster to handle this on the git side, telling git to only
retrieve the logs that match the specified query? If feasible, this might
speed up various web interfaces into git repositories.

Be well,
Zack

-- 
Zack Brown

^ permalink raw reply

* Re: [ANNOUNCE] mtkdiff-20050514 (integrated w/ gitk)
From: Paul Mackerras @ 2005-05-14  6:50 UTC (permalink / raw)
  To: Tejun Heo; +Cc: git
In-Reply-To: <20050514025815.GA5845@htj.dyndns.org>

Tejun Heo writes:

>  This is mtkdiff-20050514.  I've modified gitk to invoke gitkdiff on
> double click and right click.  If you double click on a commit mtkdiff
> will show the commit.  If you right click on a commit while another
> one is selected, mtkdiff will show the difference between the two
> commits (as in bk revtool).  Also, I've modified gitk & gitkdiff to
> show commit SHA1 in the info text when a commit is selected.

Cute.  I was thinking along the same lines, but intending to use
dirdiff to display the differences.  I'll make the diff viewer
user-configurable, I think.  Also, I'm planning to put a bar with the
sha1 and a search facility in the next version of gitk.

Paul.

^ permalink raw reply

* [PATCH 1/2] Test suite fixup.
From: Junio C Hamano @ 2005-05-14  7:24 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

Exposing test_expect_success and test_expect_failure turns out
to be enough for the test scripts and there is no need for
exposing test_ok or test_failure.  This patch cleans it up and
fixes the users of test_ok and test_failure.

Also test scripts have acquired a new command line flag
'--immediate' to cause them to exit upon the first failure.
This is useful especially during the development of a new test.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

This is on top of the two "test suite take 2" patches.

t/t1000-checkout-cache.sh |    9 +++------
t/t1001-checkout-cache.sh |   15 ++++++---------
t/test-lib.sh             |   15 +++++++++------
3 files changed, 18 insertions(+), 21 deletions(-)

--- a/t/t1000-checkout-cache.sh
+++ b/t/t1000-checkout-cache.sh
@@ -44,12 +44,9 @@
     'git-checkout-cache with -f should succeed.' \
     'git-checkout-cache -f -a'
 
-if test -f path0 && test -d path1 && test -f path1/file1
-then
-	test_ok "checkout successful"
-else
-	test_failure "checkout failed"
-fi
+test_expect_success \
+    'git-checkout-cache conflicting paths.' \
+    'test -f path0 && test -d path1 && test -f path1/file1'
 
 test_done
 
--- a/t/t1001-checkout-cache.sh
+++ b/t/t1001-checkout-cache.sh
@@ -76,15 +76,12 @@
     'git-read-tree $tree2 && git-checkout-cache -f -a'
 test_debug show_files $tree2
 
-if test ! -h path0 && test -d path0 &&
-   test ! -h path1 && test -d path1 &&
-   test ! -h path0/file0 && test -f path0/file0 &&
-   test ! -h path1/file1 && test -f path1/file1
-then
-    test_ok "checked out correctly."
-else
-    test_failure "did not check out correctly."
-fi
+test_expect_success \
+    'checking out conflicting path with -f' \
+    'test ! -h path0 && test -d path0 &&
+     test ! -h path1 && test -d path1 &&
+     test ! -h path0/file0 && test -f path0/file0 &&
+     test ! -h path1/file1 && test -f path1/file1'
 
 test_done
 
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -50,6 +50,8 @@
 	case "$1" in
 	-d|--d|--de|--deb|--debu|--debug)
 		debug=t; shift ;;
+	-i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
+	immediate=t; shift ;;
 	-h|--h|--he|--hel|--help)
 		echo "$test_description"
 		exit 0 ;;
@@ -74,15 +76,16 @@
 	test "$debug" == "" || eval "$1"
 }
 
-test_ok () {
+test_ok_ () {
 	test_count=$(expr "$test_count" + 1)
 	say "ok #$test_count: $@"
 }
 
-test_failure () {
+test_failure_ () {
 	test_count=$(expr "$test_count" + 1)
 	test_failure=$(expr "$test_failure" + 1);
 	say "NO #$test_count: $@"
+	test "$immediate" == "" || exit 1
 }
 
 test_expect_failure () {
@@ -91,9 +94,9 @@
 	say >&3 "expecting failure: $2"
 	if eval >&3 2>&4 "$2"
 	then
-		test_failure "$@"
+		test_failure_ "$@"
 	else
-		test_ok "$1"
+		test_ok_ "$1"
 	fi
 }
 
@@ -103,9 +106,9 @@
 	say >&3 "expecting success: $2"
 	if eval >&3 2>&4 "$2"
 	then
-		test_ok "$1"
+		test_ok_ "$1"
 	else
-		test_failure "$@"
+		test_failure_ "$@"
 	fi
 }
 



^ permalink raw reply

* [PATCH 2/2] Test framework documentation.
From: Junio C Hamano @ 2005-05-14  7:25 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

This adds instruction for running tests, and writing new tests.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

t/README |  174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 174 insertions(+)
t/README (. --> 100644)

--- a/t/README
+++ b/t/README
@@ -0,0 +1,174 @@
+Core GIT Tests
+==============
+
+This directory holds many test scripts for core GIT tools.  The
+first part of this short document describes how to run the tests
+and read their output.
+
+When fixing the tools or adding enhancements, you are strongly
+encouraged to add tests in this directory to cover what you are
+trying to fix or enhance.  The later part of this short document
+describes how your test scripts should be organized.
+
+
+Running Tests
+-------------
+
+The easiest way to run tests is to say "make".  This runs all
+the tests.
+
+    *** t0000-basic.sh ***
+    * ok #1: .git/objects should be empty after git-init-db in an empty repo.
+    * ok #2: .git/objects should have 256 subdirectories.
+    * ok #3: git-update-cache without --add should fail adding.
+    ...
+    * ok #23: no diff after checkout and git-update-cache --refresh.
+    * passed all 23 test(s)
+    *** t0100-environment-names.sh ***
+    * ok #1: using old names should issue warnings.
+    * ok #2: using old names but having new names should not issue warnings.
+    ...
+
+Or you can run each test individually from command line, like
+this:
+
+    $ sh ./t0500-ls-files.sh
+    * ok #1: git-update-cache --add to add various paths.
+    * ok #2: git-ls-files -k to show killed files.
+    * ok #3: validate git-ls-files -k output.
+    * passed all 3 test(s)
+
+You can pass --verbose (or -v), --debug (or -d), and --immediate
+(or -i) command line argument to the test.
+
+--verbose::
+	This makes the test more verbose.  Specifically, the
+	command being run and their output if any are also
+	output.
+
+--debug::
+	This may help the person who is developing a new test.
+	It causes the command defined with test_debug to run.
+
+--immediate::
+	This causes the test to immediately exit upon the first
+	failed test.
+
+
+Writing Tests
+-------------
+
+The test script is written as a shell script.  It should start
+with the standard "#!/bin/sh" with copyright notices, and an
+assignment to variable 'test_description', like this:
+
+	#!/bin/sh
+	#
+	# Copyright (c) 2005 Junio C Hamano
+	#
+
+	test_description='xxx test (new option --frotz)
+
+	This test registers the following structure in the cache
+	and tries to run git-ls-files with new option --frotz.'
+
+Source 'test-lib.sh'
+--------------------
+
+After assigning test_description, the test script should source
+test-lib.sh like this:
+
+	. ./test-lib.sh
+
+This test harness library does the following things:
+
+ - If the script is invoked with command line argument --help
+   (or -h), it shows the test_description and exits.
+
+ - Creates an empty test directory with an empty .git/objects
+   database and chdir(2) into it.  This directory is 't/trash'
+   if you must know, but I do not think you care.
+
+ - Defines standard test helper functions for your scripts to
+   use.  These functions are designed to make all scripts behave
+   consistently when command line arguments --verbose (or -v),
+   --debug (or -d), and --immediate (or -i) is given.
+
+
+End with test_done
+------------------
+
+Your script will be a sequence of tests, using helper functions
+from the test harness library.  At the end of the script, call
+'test_done'.
+
+
+Test harness library
+--------------------
+
+There are a handful helper functions defined in the test harness
+library for your script to use.
+
+ - test_expect_success <message> <script>
+
+   This takes two strings as parameter, and evaluates the
+   <script>.  If it yields success, test is considered
+   successful.  <message> should state what it is testing.
+
+   Example:
+
+	test_expect_success \
+	    'git-write-tree should be able to write an empty tree.' \
+	    'tree=$(git-write-tree)'
+
+ - test_expect_failure <message> <script>
+
+   This is the opposite of test_expect_success.  If <script>
+   yields success, test is considered a failure.
+
+   Example:
+
+	test_expect_failure \
+	    'git-update-cache without --add should fail adding.' \
+	    'git-update-cache should-be-empty'
+
+ - test_debug <script>
+
+   This takes a single argument, <script>, and evaluates it only
+   when the test script is started with --debug command line
+   argument.  This is primarily meant for use during the
+   development of a new test script.
+
+ - test_done
+
+   Your test script must have test_done at the end.  Its purpose
+   is to summarize successes and failures in the test script and
+   exit with an appropriate error code.
+
+
+Tips for Writing Tests
+----------------------
+
+As with any programming projects, existing programs are the best
+source of the information.  However, do _not_ emulate
+t0000-basic.sh when writing your tests.  The test is special in
+that it tries to validate the very core of GIT.  For example, it
+knows that there will be 256 subdirectories under .git/objects/,
+and it knows that the object ID of an empty tree is a certain
+40-byte string.  This is deliberately done so in t0000-basic.sh
+because the things the very basic core test tries to achieve is
+to serve as a basis for people who are changing the GIT internal
+drastically.  For these people, after making certain changes,
+not seeing failures from the basic test _is_ a failure.  And
+such drastic changes to the core GIT that even changes these
+otherwise supposedly stable object IDs should be accompanied by
+an update to t0000-basic.sh.
+
+However, other tests that simply rely on basic parts of the core
+GIT working properly should not have that level of intimate
+knowledge of the core GIT internals.  If all the test scripts
+hardcoded the object IDs like t0000-basic.sh does, that defeats
+the purpose of t0000-basic.sh, which is to isolate that level of
+validation in one place.  Your test also ends up needing
+updating when such a change to the internal happens, so do _not_
+do it and leave the low level of validation to t0000-basic.sh.
------------------------------------------------


^ permalink raw reply

* Re: Regarding gitk
From: Paul Mackerras @ 2005-05-14  7:47 UTC (permalink / raw)
  To: Tejun Heo; +Cc: git
In-Reply-To: <20050513051923.GA15116@htj.dyndns.org>

Hi Tejun,

>  First of all, thanks a lot for gitk.  I was working on something using
> graphviz/pygtk to do about the same thing for a couple of weeks (and got
> pretty far with it) but ditched it as gitk seemed much better.  I really
> love how gitk shows the commit graph. :-)

Yes, I was pleased with how it turned out.

>  As I don't wanna ditch any more of my time, it would be great if you
> let me know what you're currently working on, so that I can coordinate
> with you.  Here are the things I have on mind.
> 
> * integrate two-way diff view w/ diff map into gitk from mgdiff.

I guess mgdiff and dirdiff do very similar things, although dirdiff
can display the diffs between up to 5 trees (limited mainly by the
number of easily distinguishable colors between red and green).  Doing
3-way diffs is useful for most merges (diffing the output vs. the
inputs) and for diffing two arbitrary commits (diffing the two vs. the
nearest common ancestor).

I recently changed dirdiff to be able to diff git commits with each
other or the working directory, and I was intending to add a way to
invoke that from gitk.

> * show the current cache and working files at the head of graph

Interesting idea.  I had mostly been thinking of gitk in terms of the
way I use it, which is to help me follow what others are doing rather
than looking at what I have done.

> * demand-load commits as the user scrolls down the graph

It would be nice to at least be a bit asynchronous, so that the graph
is drawn as the commits are read, rather than having to wait for all
the commits are read before anything is drawn.  I need to hack
git-rev-tree, I guess.

>  I wrote a commit viewing utility (gitkdiff) modified from mgdiff two
> weeks ago so I'm quite familiar with mgdiff source, and implemented
> demand-loading of commits in my own project in python, but writing a
> separate c utility with the same algorithm wouldn't take that much time.

Does that algorithm let you say "commits reachable from A but not from
B" like git-rev-tree does?

Regards,
Paul.

^ permalink raw reply

* Re: speeding up cg-log -u
From: Junio C Hamano @ 2005-05-14  8:13 UTC (permalink / raw)
  To: Zack Brown; +Cc: git
In-Reply-To: <20050514061914.GB14353@tumblerings.org>

>>>>> "ZB" == Zack Brown <zbrown@tumblerings.org> writes:

ZB> Would it be faster to handle this on the git side, telling git to only
ZB> retrieve the logs that match the specified query? If feasible, this might
ZB> speed up various web interfaces into git repositories.

Here are two places you can add a simple hook.  Implementation
of author_match() function is left as an exercise for you ;-).
Let us know if you get speed improvements, please.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
$ jit-diff
# - 9: (Anonymous snapshot)
# + (working tree)
--- a/cache.h
+++ b/cache.h
@@ -178,6 +178,7 @@ extern void *read_object_with_reference(
 const char *show_date(unsigned long time, int timezone);
 void parse_date(char *date, char *buf, int bufsize);
 void datestamp(char *buf, int bufsize);
+int author_match(struct commit *, const char *);
 
 static inline void *xmalloc(int size)
 {
--- a/rev-list.c
+++ b/rev-list.c
@@ -11,6 +11,7 @@ int main(int argc, char **argv)
 	unsigned long max_age = -1;
 	unsigned long min_age = -1;
 	int max_count = -1;
+	const char *author = NULL;
 
 	for (i = 1 ; i < argc; i++) {
 		char *arg = argv[i];
@@ -21,6 +22,8 @@ int main(int argc, char **argv)
 			max_age = atoi(arg + 10);
 		} else if (!strncmp(arg, "--min-age=", 10)) {
 			min_age = atoi(arg + 10);
+		} else if (!strncmp(arg, "--author=", 9)) {
+			author = arg + 9;
 		} else {
 			commit_arg = arg;
 		}
@@ -28,6 +31,7 @@ int main(int argc, char **argv)
 
 	if (!commit_arg || get_sha1(commit_arg, sha1))
 		usage("usage: rev-list [OPTION] commit-id\n"
+		      "  --author=author\n"
 		      "  --max-count=nr\n"
 		      "  --max-age=epoch\n"
 		      "  --min-age=epoch\n");
@@ -44,6 +48,8 @@ int main(int argc, char **argv)
 			continue;
 		if (max_age != -1 && (commit->date < max_age))
 			break;
+		if (!author_match(commit, author))
+			continue;
 		if (max_count != -1 && !max_count--)
 			break;
 		printf("%s\n", sha1_to_hex(commit->object.sha1));
--- a/rev-tree.c
+++ b/rev-tree.c
@@ -64,7 +64,7 @@ void process_commit(unsigned char *sha1)
 }
 
 /*
- * Usage: rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id2>]
+ * Usage: rev-tree [--edges] [--author <author>] [--cache <cache-file>] <commit-id> [<commit-id2>]
  *
  * The cache-file can be quite important for big trees. This is an
  * expensive operation if you have to walk the whole chain of
@@ -75,6 +75,7 @@ int main(int argc, char **argv)
 	int i;
 	int nr = 0;
 	unsigned char sha1[MAX_COMMITS][20];
+	const char *author = NULL; 
 
 	/*
 	 * First - pick up all the revisions we can (both from
@@ -83,6 +84,11 @@ int main(int argc, char **argv)
 	for (i = 1; i < argc ; i++) {
 		char *arg = argv[i];
 
+		if (!strcmp(arg, "--author")) {
+			author = argv[++i];
+			continue;
+		}
+
 		if (!strcmp(arg, "--cache")) {
 			read_cache_file(argv[++i]);
 			continue;
@@ -98,7 +104,7 @@ int main(int argc, char **argv)
 			basemask |= 1<<nr;
 		}
 		if (nr >= MAX_COMMITS || get_sha1(arg, sha1[nr]))
-			usage("rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id>]");
+			usage("rev-tree [--edges] [--author <author>] [--cache <cache-file>] <commit-id> [<commit-id>]");
 		process_commit(sha1[nr]);
 		nr++;
 	}
@@ -125,6 +131,9 @@ int main(int argc, char **argv)
 		if (!interesting(commit))
 			continue;
 
+		if (!author_match(commit, author))
+			continue;
+
 		printf("%lu %s:%d", commit->date, sha1_to_hex(obj->sha1), 
 		       obj->flags);
 		p = commit->parents;




^ permalink raw reply

* Re: [PATCH 2/2] update cg-* to use cg-Xignore
From: David Greaves @ 2005-05-14  8:24 UTC (permalink / raw)
  To: Petr Baudis; +Cc: GIT Mailing Lists
In-Reply-To: <20050513225516.GG32232@pasky.ji.cz>

Petr Baudis wrote:

>Dear diary, on Sat, May 14, 2005 at 12:32:22AM CEST, I got a letter
>where David Greaves <david@dgreaves.com> told me that...
>  
>
>>Updated
>>    cg-add
>>    cg-commit
>>    
>>
>
>I consider this Bad Thing (tm). Or could you please point a situation
>where this would be actually useful? If you explicitly cg-add, you
>likely know what are you doing, and same thing with cg-commit - if it's
>already added, it should be watches, no matter what ignore patterns, I
>think.
>  
>
OK, lets say I'm clever and know what an ignore pattern is.
I can
find * | xargs cg-add
my laziness something my hubris acknowledges :)

And in fact this has come up a few times on the list already - it was
that code snippet in cg-init that caused me to create cg-Xignore because
as someone pointed out, even finding files/links would still cause probs
with files beginning with '.'
does that sway you?

>>--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-commit  (mode:100755)
>>+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-commit  (mode:100755)
>>@@ -65,6 +65,15 @@
>> 	[ -s $_git/merging ] && merging=$(cat $_git/merging | sed 's/^/-p /')
>> fi
>> 
>>+# strip ignored files - *1 at a time* - any attempt to stream from 1
>>+# while loop to another uses a subprocess and can't pass the variable
>>+# back
>>+# Also I don't know if this can be put in a shell function
>>+for file in ${commitfiles[@]}
>>+  do
>>+  commitfiles[$i]=`echo $file | cg-Xignore`
>>+  ((i++))
>>+done
>> 
>> LOGMSG=$(mktemp -t gitci.XXXXXX)
>> LOGMSG2=$(mktemp -t gitci.XXXXXX)
>>    
>>
>
>The variable? What variable?
>  
>
well basically we want to edit the commitfiles variable - perl map()
a more efficient method in shell appears to be:
foreach file in commitfiles; echo file | filter | read into commitfiles
I spent ages trying not to exec a cg-Ignore process per file comparison

>>Index: cg-status
>>===================================================================
>>--- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-status  (mode:100755)
>>+++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-status  (mode:100755)
>>@@ -15,21 +15,11 @@
>> 
>> {
>> 	git-ls-files -z -t --others --deleted --unmerged $EXCLUDE
>>-} | sort -z -k 2 | xargs -0 sh -c '
>>-while [ "$1" ]; do
>>-	tag=${1% *};
>>-	filename=${1#* };
>>-	case "$filename" in
>>-	*.[ao] | tags | ,,merge*) ;;
>>-	*)   echo "$tag $filename";;
>>-	esac
>>-	shift
>>-done
>>-' padding
>>+} | sort -z -k 2 | cg-Xignore -0 -t | tr "\000" "\n"
>>    
>>
>
>So you have two ignores now - exclude and Xignore.
>  
>
No, cogito has an ignore.
git has a less powerful exclude.
cogito users won't need exclude but power-users aren't barred from it.


David

-- 


^ permalink raw reply

* Re: [PATCH] Ignore file filter
From: David Greaves @ 2005-05-14  8:28 UTC (permalink / raw)
  To: Petr Baudis; +Cc: GIT Mailing Lists
In-Reply-To: <20050513231229.GI32232@pasky.ji.cz>

Petr Baudis wrote:

>Dear diary, on Thu, May 12, 2005 at 11:30:32PM CEST, I got a letter
>where David Greaves <david@dgreaves.com> told me that...
>  
>
>># This doesn't allow the -h which is the [ arg for symlinks...
>>    
>>
>
>But so is -L. And I'd just use -l...
>  
>
OK

>>#. ${COGITO_LIB}cg-Xlib
>>_git=${GIT_DIR:-.git}
>>    
>>
>
>...but it makes no sense anyway I think to reinclude this stuff from a
>cg-Xfile you are including from other scripts anyway.
>  
>
cg-Xignore isn't included - only called.
it's also just a library program.
Also I don't think cg-Xlib should be doing arg handling.
As an include it should provide an arg handling function that the
scripts call.

>>	    if [[ $file =~ $patt ]]; then
>>    
>>
>
>I'm sorry but this is really nothing my bash-2.05.0(1)-release supports.
>We're already bash-only, but further reducing that to bash3 really won't
>work. I *might* get convinced to add some bash2+-only feature, but only
>if you'll be really good at explaining that it makes sense.
>  
>
Ah
OK
I don't know how to do that.
I was actually aiming for glob matching when I came upon this in the
manpage.
I just thought it was bash and didn't think to check what version it was
introduced with.

>Besides, I'd prefer just the shell globs in the ignore file, as it is
>done in the rest of the world, and in all the real-world scenarios I've
>seen, the globs were powerful enough.
>
>Also, how does this interact with git-ls-files --exclude and
>.git/exclude? We would have two ignoring mechanisms...
>
>  
>
because one was cogito's and one was git's.
Cogitos was supposed to have a more powerful, pattern based abroach.

David

-- 


^ permalink raw reply

* [PATCH] Test GIT environment use.
From: Junio C Hamano @ 2005-05-14  8:45 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

This test makes sure that use of deprecated environment variables still
works, using both new and old names makes new one take
precedence, and GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES mechanisms
work.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

t/t0110-environment-names.sh |  134 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 134 insertions(+)
t/t0110-environment-names.sh (. --> 100755)

--- a/t/t0110-environment-names.sh
+++ b/t/t0110-environment-names.sh
@@ -0,0 +1,134 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='Using new and old environment names.
+
+This test makes sure that use of deprecated environment variables
+still works, using both new and old names makes new one take precedence,
+and GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES mechanism works.'
+
+env_vars='GIT_AUTHOR_DATE:AUTHOR_DATE
+GIT_AUTHOR_EMAIL:AUTHOR_EMAIL
+GIT_AUTHOR_NAME:AUTHOR_NAME
+GIT_COMMITTER_EMAIL:COMMIT_AUTHOR_EMAIL
+GIT_COMMITTER_NAME:COMMIT_AUTHOR_NAME
+GIT_ALTERNATE_OBJECT_DIRECTORIES:SHA1_FILE_DIRECTORIES
+GIT_OBJECT_DIRECTORY:SHA1_FILE_DIRECTORY
+'
+
+. ./test-lib.sh
+
+export_them () {
+	for ev in $env_vars
+	do
+		new=$(expr "$ev" : '\(.*\):')
+		old=$(expr "$ev" : '.*:\(.*\)')
+		# Build and eval the following:
+		# case "${VAR+set}" in set) export VAR;; esac
+		evstr='case "${'$new'+set}" in set) export '$new';; esac'
+		eval "$evstr"
+		evstr='case "${'$old'+set}" in set) export '$old';; esac'
+		eval "$evstr"
+	done
+}
+
+SHA1_FILE_DIRECTORY=.svn/objects ;# whoa
+export SHA1_FILE_DIRECTORY
+
+rm -fr .git
+mkdir .svn
+test_expect_success \
+    'using SHA1_FILE_DIRECTORY in git-init-db' \
+    'git-init-db && test -d .svn/objects/cb'
+
+unset SHA1_FILE_DIRECTORY
+GIT_DIR=.svn
+export GIT_DIR
+rm -fr .git .svn
+mkdir .svn
+test_expect_success \
+    'using GIT_DIR in git-init-db' \
+    'git-init-db && test -d .svn/objects/cb'
+
+date >path0
+test_expect_success \
+    'using GIT_DIR in git-update-cache' \
+    'git-update-cache --add path0 && test -f .svn/index'
+
+sedScript='s|\(..\)|.svn/objects/\1/|'
+
+test_expect_success \
+    'using GIT_DIR in git-write-tree' \
+    'tree=$(git-write-tree) &&
+     test -f $(echo "$tree" | sed -e "$sedScript")'
+
+AUTHOR_DATE='Sat May 14 00:00:00 2005 -0000'
+AUTHOR_EMAIL='author@example.xz'
+AUTHOR_NAME='A U Thor'
+COMMIT_AUTHOR_EMAIL='author@example.xz'
+COMMIT_AUTHOR_NAME='A U Thor'
+export_them
+
+test_expect_success \
+    'using GIT_DIR and old variable names in git-commit-tree' \
+    'commit=$(echo foo | git-commit-tree $tree) &&
+     test -f $(echo "$commit" | sed -e "$sedScript")'
+
+test_expect_success \
+    'using GIT_DIR in git-cat-file' \
+    'git-cat-file commit $commit >current'
+
+cat >expected <<\EOF
+author A U Thor <author@example.xz>
+committer A U Thor <author@example.xz>
+EOF
+test_expect_success \
+    'verify old AUTHOR variables were used correctly in commit' \
+    'sed -ne '\''/^\(author\|committer\)/s|>.*|>|p'\'' current |
+     cmp - expected'
+
+unset GIT_DIR
+test_expect_success \
+    'git-init-db without GIT_DIR' \
+    'git-init-db && test -d .git && test -d .git/objects/ef'
+
+SHA1_FILE_DIRECTORIES=.svn/objects
+export SHA1_FILE_DIRECTORIES
+
+test_expect_success \
+    'using SHA1_FILE_DIRECTORIES with git-ls-tree' \
+    'git-ls-tree $commit && git-ls-tree $tree'
+
+GIT_AUTHOR_DATE='Sat May 14 12:00:00 2005 -0000'
+GIT_AUTHOR_EMAIL='rohtua@example.xz'
+GIT_AUTHOR_NAME='R O Htua'
+GIT_COMMITTER_EMAIL='rohtua@example.xz'
+GIT_COMMITTER_NAME='R O Htua'
+export_them
+
+sedScript='s|\(..\)|.git/objects/\1/|'
+test_expect_success \
+    'using new author variables with git-commit-tree' \
+    'commit2=$(echo foo | git-commit-tree $tree) &&
+     test -f $(echo "$commit2" | sed -e "$sedScript")'
+
+GIT_ALTERNATE_OBJECT_DIRECTORIES=.git/objects
+GIT_DIR=nowhere
+export GIT_DIR GIT_ALTERNATE_OBJECT_DIRECTORIES
+
+test_expect_success \
+    'git-cat-file with GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES' \
+    'git-cat-file commit $commit2 >current'
+
+cat >expected <<\EOF
+author R O Htua <rohtua@example.xz>
+committer R O Htua <rohtua@example.xz>
+EOF
+test_expect_success \
+    'verify new AUTHOR variables were used correctly in commit.' \
+    'sed -ne '\''/^\(author\|committer\)/s|>.*|>|p'\'' current |
+     cmp - expected'
+
+test_done
------------------------------------------------


^ permalink raw reply

* [PATCH] Add the merge test Linus called "test script from hell".
From: Junio C Hamano @ 2005-05-14  8:46 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

This is an adaptation to the test framework of a historic test
that was used before three way merge form of read-tree was
introduced, and subsequently used to validate the read-tree -m
merge works correctly.  It covers all the tricky cases known
back then and also have been updated to cover conflicting
files/directories cases since then.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

t/t0700-read-tree.sh |  313 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 313 insertions(+)
t/t0700-read-tree.sh (. --> 100755)

--- a/t/t0700-read-tree.sh
+++ b/t/t0700-read-tree.sh
@@ -0,0 +1,313 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='Three way merge with read-tree -m
+
+This test tries three-way merge with read-tree -m
+
+There is one ancestor (called O for Original) and two branches A
+and B derived from it.  We want to do a 3-way merge between A and
+B, using O as the common ancestor.
+
+    merge A O B
+
+Decisions are made by comparing contents of O, A and B pathname
+by pathname.  The result is determined by the following guiding
+principle:
+
+ - If only A does something to it and B does not touch it, take
+   whatever A does.
+
+ - If only B does something to it and A does not touch it, take
+   whatever B does.
+
+ - If both A and B does something but in the same way, take
+   whatever they do.
+
+ - If A and B does something but different things, we need a
+   3-way merge:
+
+   - We cannot do anything about the following cases:
+
+     * O does not have it.  A and B both must be adding to the
+       same path independently.
+
+     * A deletes it.  B must be modifying.
+
+   - Otherwise, A and B are modifying.  Run 3-way merge.
+
+First, the case matrix.
+
+ - Vertical axis is for A'\''s actions.
+ - Horizontal axis is for B'\''s actions.
+
+.----------------------------------------------------------------.
+| A        B | No Action  |   Delete   |   Modify   |    Add     |
+|------------+------------+------------+------------+------------|
+| No Action  |            |            |            |            |
+|            | select O   | delete     | select B   | select B   |
+|            |            |            |            |            |
+|------------+------------+------------+------------+------------|
+| Delete     |            |            | ********** |    can     |
+|            | delete     | delete     | merge      |    not     |
+|            |            |            |            |  happen    |
+|------------+------------+------------+------------+------------|
+| Modify     |            | ********** | ?????????? |    can     |
+|            | select A   | merge      | select A=B |    not     |
+|            |            |            | merge      |  happen    |
+|------------+------------+------------+------------+------------|
+| Add        |            |    can     |    can     | ?????????? |
+|            | select A   |    not     |    not     | select A=B |
+|            |            |  happen    |  happen    | merge      |
+.----------------------------------------------------------------.
+
+In addition:
+
+ SS: a special case of MM, where A and B makes the same modification.
+ LL: a special case of AA, where A and B creates the same file.
+ TT: a special case of MM, where A and B makes mergeable changes.
+ DF: a special case, where A makes a directory and B makes a file.
+
+'
+
+. ./test-lib.sh
+
+# Original tree.
+mkdir Z
+for a in N D M
+do
+    for b in N D M
+    do
+        p=$a$b
+	echo This is $p from the original tree. >$p
+	echo This is Z/$p from the original tree. >Z/$p
+	test_expect_success \
+	    "adding test file $p and Z/$p" \
+	    'git-update-cache --add $p &&
+	    git-update-cache --add Z/$p'
+    done
+done
+echo This is SS from the original tree. >SS
+test_expect_success \
+    'adding test file SS' \
+    'git-update-cache --add SS'
+cat >TT <<\EOF
+This is a trivial merge sample text.
+Branch A is expected to upcase this word, here.
+There are some filler lines to avoid diff context
+conflicts here,
+like this one,
+and this one,
+and this one is yet another one of them.
+At the very end, here comes another line, that is
+the word, expected to be upcased by Branch B.
+This concludes the trivial merge sample file.
+EOF
+test_expect_success \
+    'adding test file TT' \
+    'git-update-cache --add TT'
+test_expect_success \
+    'prepare initial tree' \
+    'tree_O=$(git-write-tree)'
+
+test_expect_success \
+    'commit initial tree' \
+    'commit_O=$(echo "Original tree for the merge test." |
+     git-commit-tree $tree_O)'
+echo $commit_O >.git/HEAD-O
+
+################################################################
+# Branch A and B makes the changes according to the above matrix.
+
+################################################################
+# Branch A
+
+to_remove=$(echo D? Z/D?)
+rm -f $to_remove
+test_expect_success \
+    'change in branch A (removal)' \
+    'git-update-cache --remove $to_remove'
+
+for p in M? Z/M?
+do
+    echo This is modified $p in the branch A. >$p
+    test_expect_success \
+	'change in branch A (modification)' \
+        "git-update-cache $p"
+done
+
+for p in AN AA Z/AN Z/AA
+do
+    echo This is added $p in the branch A. >$p
+    test_expect_success \
+	'change in branch A (addition)' \
+	"git-update-cache --add $p"
+done
+
+echo This is SS from the modified tree. >SS
+echo This is LL from the modified tree. >LL
+test_expect_success \
+    'change in branch A (addition)' \
+    'git-update-cache --add LL &&
+     git-update-cache SS'
+mv TT TT-
+sed -e '/Branch A/s/word/WORD/g' <TT- >TT
+rm -f TT-
+test_expect_success \
+    'change in branch A (edit)' \
+    'git-update-cache TT'
+
+mkdir DF
+echo Branch A makes a file at DF/DF, creating a directory DF. >DF/DF
+test_expect_success \
+    'change in branch A (change file to directory)' \
+    'git-update-cache --add DF/DF'
+
+test_expect_success \
+    'recording branch A tree' \
+    'tree_A=$(git-write-tree)'
+test_expect_success \
+    'committing branch A changes' \
+    'commit_A=$(echo "Branch A for the merge test." |
+           git-commit-tree $tree_A -p $commit_O)'
+echo $commit_A >.git/HEAD-A
+	   
+################################################################
+# Branch B
+# Start from O
+
+rm -rf [NDMASLT][NDMASLT] Z DF
+mkdir Z
+test_expect_success \
+    'reading original tree and checking out' \
+    'git-read-tree $tree_O &&
+     git-checkout-cache -a'
+
+to_remove=$(echo ?D Z/?D)
+rm -f $to_remove
+test_expect_success \
+    'change in branch B (removal)' \
+    "git-update-cache --remove $to_remove"
+
+for p in ?M Z/?M
+do
+    echo This is modified $p in the branch B. >$p
+    test_expect_success \
+	'change in branch B (modification)' \
+	"git-update-cache $p"
+done
+
+for p in NA AA Z/NA Z/AA
+do
+    echo This is added $p in the branch B. >$p
+    test_expect_success \
+	'change in branch B (addition)' \
+	"git-update-cache --add $p"
+done
+echo This is SS from the modified tree. >SS
+echo This is LL from the modified tree. >LL
+test_expect_success \
+    'change in branch B (addition and modification)' \
+    'git-update-cache --add LL &&
+     git-update-cache SS'
+mv TT TT-
+sed -e '/Branch B/s/word/WORD/g' <TT- >TT
+rm -f TT-
+test_expect_success \
+    'change in branch B (modification)' \
+    'git-update-cache TT'
+
+echo Branch B makes a file at DF. >DF
+test_expect_success \
+    'change in branch B (addition of a file to conflict with directory)' \
+    'git-update-cache --add DF'
+
+test_expect_success \
+    'recording branch B tree' \
+    'tree_B=$(git-write-tree)'
+test_expect_success \
+    'committing branch B changes' \
+    'commit_B=$(echo "Branch B for the merge test." |
+           git-commit-tree $tree_B -p $commit_O)'
+echo $commit_B >.git/HEAD-B
+
+################################################################
+# Done preparation.
+
+test_debug '
+    for T in O A B
+    do
+	echo "# $T $(eval git-cat-file commit \$commit_$T | sed -e 1q)"
+    done
+'
+
+################################################################
+# Try merging and showing the various diffs
+
+test_expect_success \
+    '3-way merge with git-read-tree -m' \
+    "git-read-tree -m $tree_O $tree_A $tree_B"
+
+strip_object_id='s/^\([0-7]*\) [0-9a-f]* \([0-3].*\)$/\1 \2/'
+
+test_expect_success \
+    'git-ls-files --stage of the merge result' \
+    'git-ls-files --stage >current- &&
+     sed -e "$strip_object_id" <current- >current'
+
+cat >expected <<\EOF
+100644 2 AA
+100644 3 AA
+100644 2 AN
+100644 1 DD
+100644 3 DF
+100644 2 DF/DF
+100644 1 DM
+100644 3 DM
+100644 1 DN
+100644 3 DN
+100644 2 LL
+100644 3 LL
+100644 1 MD
+100644 2 MD
+100644 1 MM
+100644 2 MM
+100644 3 MM
+100644 0 MN
+100644 3 NA
+100644 1 ND
+100644 2 ND
+100644 0 NM
+100644 0 NN
+100644 0 SS
+100644 1 TT
+100644 2 TT
+100644 3 TT
+100644 2 Z/AA
+100644 3 Z/AA
+100644 2 Z/AN
+100644 1 Z/DD
+100644 1 Z/DM
+100644 3 Z/DM
+100644 1 Z/DN
+100644 3 Z/DN
+100644 1 Z/MD
+100644 2 Z/MD
+100644 1 Z/MM
+100644 2 Z/MM
+100644 3 Z/MM
+100644 0 Z/MN
+100644 3 Z/NA
+100644 1 Z/ND
+100644 2 Z/ND
+100644 0 Z/NM
+100644 0 Z/NN
+EOF
+
+test_expect_success \
+    'validate merge result' \
+    'diff current expected'
+
+test_done
------------------------------------------------


^ permalink raw reply

* Re: [PATCH] Ignore file filter
From: Junio C Hamano @ 2005-05-14  9:01 UTC (permalink / raw)
  To: David Greaves; +Cc: Petr Baudis, GIT Mailing Lists
In-Reply-To: <4285B6A8.4080309@dgreaves.com>

>>>>> "DG" == David Greaves <david@dgreaves.com> writes:

>>> if [[ $file =~ $patt ]]; then
>> 
>> I'm sorry but this is really nothing my bash-2.05.0(1)-release supports.
DG> OK
DG> I don't know how to do that.

Is that regexp or shell glob?  If regexp, expr is your friend,
like this:

    if expr "$file" : "$patt" >/dev/null; then

For a glob:

    patt='?.sh'
    file=1.sh

    case "$file" in
    $patt)
            echo Yeah ;;
    *)
            echo No ;;
    esac


^ permalink raw reply

* [PATCH] Add --author match to git-rev-list and git-rev-tree.
From: Junio C Hamano @ 2005-05-14  9:50 UTC (permalink / raw)
  To: Zack Brown, pasky, torvalds; +Cc: git
In-Reply-To: <20050514061914.GB14353@tumblerings.org>

Zack Brown wondered if handling author match at core GIT level
would make cg-log -u go faster (JIT also can use this in jit-log
--author).  Here is a patch to implement it.

I considered adding author and committer strings to commit
objects for general use as commit objects are parsed, but I was
unsure about the lifetime rules of the commit objects (nobody
seems to free them in the current code), so refrained from doing
so for the time being.  The code instead re-reads the commit
object when it needs to filter them by the author.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

commit.c   |   42 ++++++++++++++++++++++++++++++++++++++++++
commit.h   |    2 ++
rev-list.c |    6 ++++++
rev-tree.c |   13 +++++++++++--
4 files changed, 61 insertions(+), 2 deletions(-)

--- a/commit.c
+++ b/commit.c
@@ -152,3 +152,45 @@
 	}
 	return ret;
 }
+
+int author_match(const struct commit *item, const char *author)
+{
+	char type[20];
+	void *buffer;
+	char *author_line, *ep;
+	unsigned long size;
+	int ret;
+
+	buffer = read_sha1_file(item->object.sha1, type, &size);
+	if (!buffer)
+		return error("Could not read %s",
+			     sha1_to_hex(item->object.sha1));
+	if (strcmp(type, commit_type)) {
+		free(buffer);
+		error("Object %s not a commit",
+		      sha1_to_hex(item->object.sha1));
+		return 0;
+	}
+	/* we do not care what is in the message; we do not
+	 * want to overrun with strstr and strchr.
+	 */
+	ep = buffer + (size -1);
+	*ep = 0;
+	if ((author_line = strstr(buffer, "\nauthor ")) == 0) {
+		free(buffer);
+		error("Commit %s does not have author.",
+		      sha1_to_hex(item->object.sha1));
+		return 0;
+	}
+	author_line = strchr(author_line, ' ') + 1;
+	if ((ep = strchr(author_line, '>')) == 0) {
+		free(buffer);
+		error("Commit %s has a malformed author line.",
+		      sha1_to_hex(item->object.sha1));
+		return 0;
+	}
+	*++ep = 0;
+	ret = (strstr(author_line, author) != 0);
+	free(buffer);
+	return ret;
+}
--- a/commit.h
+++ b/commit.h
@@ -36,4 +36,6 @@
 struct commit *pop_most_recent_commit(struct commit_list **list, 
 				      unsigned int mark);
 
+int author_match(const struct commit *, const char *);
+
 #endif /* COMMIT_H */
--- a/rev-list.c
+++ b/rev-list.c
@@ -11,6 +11,7 @@
 	unsigned long max_age = -1;
 	unsigned long min_age = -1;
 	int max_count = -1;
+	const char *author = NULL;
 
 	for (i = 1 ; i < argc; i++) {
 		char *arg = argv[i];
@@ -21,6 +22,8 @@
 			max_age = atoi(arg + 10);
 		} else if (!strncmp(arg, "--min-age=", 10)) {
 			min_age = atoi(arg + 10);
+		} else if (!strncmp(arg, "--author=", 9)) {
+			author = arg + 9;
 		} else {
 			commit_arg = arg;
 		}
@@ -28,6 +31,7 @@
 
 	if (!commit_arg || get_sha1(commit_arg, sha1))
 		usage("usage: rev-list [OPTION] commit-id\n"
+		      "  --author=author\n"
 		      "  --max-count=nr\n"
 		      "  --max-age=epoch\n"
 		      "  --min-age=epoch\n");
@@ -44,6 +48,8 @@
 			continue;
 		if (max_age != -1 && (commit->date < max_age))
 			break;
+		if (author && !author_match(commit, author))
+			continue;
 		if (max_count != -1 && !max_count--)
 			break;
 		printf("%s\n", sha1_to_hex(commit->object.sha1));
--- a/rev-tree.c
+++ b/rev-tree.c
@@ -64,7 +64,7 @@
 }
 
 /*
- * Usage: rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id2>]
+ * Usage: rev-tree [--edges] [--author <author>] [--cache <cache-file>] <commit-id> [<commit-id2>]
  *
  * The cache-file can be quite important for big trees. This is an
  * expensive operation if you have to walk the whole chain of
@@ -75,6 +75,7 @@
 	int i;
 	int nr = 0;
 	unsigned char sha1[MAX_COMMITS][20];
+	const char *author = NULL; 
 
 	/*
 	 * First - pick up all the revisions we can (both from
@@ -83,6 +84,11 @@
 	for (i = 1; i < argc ; i++) {
 		char *arg = argv[i];
 
+		if (!strcmp(arg, "--author")) {
+			author = argv[++i];
+			continue;
+		}
+
 		if (!strcmp(arg, "--cache")) {
 			read_cache_file(argv[++i]);
 			continue;
@@ -98,7 +104,7 @@
 			basemask |= 1<<nr;
 		}
 		if (nr >= MAX_COMMITS || get_sha1(arg, sha1[nr]))
-			usage("rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id>]");
+			usage("rev-tree [--edges] [--author <author>] [--cache <cache-file>] <commit-id> [<commit-id>]");
 		process_commit(sha1[nr]);
 		nr++;
 	}
@@ -125,6 +131,9 @@
 		if (!interesting(commit))
 			continue;
 
+		if (author && !author_match(commit, author))
+			continue;
+
 		printf("%lu %s:%d", commit->date, sha1_to_hex(obj->sha1), 
 		       obj->flags);
 		p = commit->parents;
------------------------------------------------


^ permalink raw reply

* [PATCH] Add --author match to git-rev-list and git-rev-tree (Documentation)
From: Junio C Hamano @ 2005-05-14  9:56 UTC (permalink / raw)
  To: Zack Brown, pasky, torvalds; +Cc: git

This documents the --author match to the two commands.
It also fixes git-rev-list documentation, which lacked
descriptions for existing options.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

Documentation/git-rev-list.txt |   16 +++++++++++++++-
Documentation/git-rev-tree.txt |    5 ++++-
2 files changed, 19 insertions(+), 2 deletions(-)

--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -9,7 +9,7 @@
 
 SYNOPSIS
 --------
-'git-rev-list' <commit>
+'git-rev-list' [--author=author] [--max-count=count] [--max-age=unixtime] [--min-age=unixtime] <commit>
 
 DESCRIPTION
 -----------
@@ -18,6 +18,20 @@
 useful to produce human-readable log output.
 
 
+OPTIONS
+-------
+--author::
+	Limit the final output to commits made by the author.
+
+--max-count::
+	Stop after showing the specified number of commits.
+
+--max-age::
+	Stop before showing the commits older than specified time.
+
+--min-age::
+	Do not show the commits newer than specified time.
+
 Author
 ------
 Written by Linus Torvalds <torvalds@osdl.org>
--- a/Documentation/git-rev-tree.txt
+++ b/Documentation/git-rev-tree.txt
@@ -9,7 +9,7 @@
 
 SYNOPSIS
 --------
-'git-rev-tree' [--edges] [--cache <cache-file>] [^]<commit> [[^]<commit>]
+'git-rev-tree' [--author author] [--edges] [--cache <cache-file>] [^]<commit> [[^]<commit>]
 
 DESCRIPTION
 -----------
@@ -17,6 +17,9 @@
 
 OPTIONS
 -------
+--author::
+	Limit the final output to commits made by the author.
+
 --edges::
 	Show edges (ie places where the marking changes between parent
 	and child)
------------------------------------------------


^ permalink raw reply

* Re: speeding up cg-log -u
From: Petr Baudis @ 2005-05-14 10:39 UTC (permalink / raw)
  To: Zack Brown, Junio C Hamano; +Cc: git, torvalds
In-Reply-To: <20050514061914.GB14353@tumblerings.org>

Dear diary, on Sat, May 14, 2005 at 08:19:14AM CEST, I got a letter
where Zack Brown <zbrown@tumblerings.org> told me that...
> Currently cg-log handles this by grabbing all the log data from git, and
> then grepping through it.

Which is clearly suboptimal since cg-log now does git-cat-file up to
_three_ times per commit. It should instead process the commit only
once.

Dear diary, on Sat, May 14, 2005 at 11:50:24AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> +	buffer = read_sha1_file(item->object.sha1, type, &size);

If it do that, I wonder how much speedup would be using this instead.
But probably still significant one.

What I don't like is that it searches only the author field. I find the
behaviour that it searches in the committer field as well very useful,
since I can easily check whose patches on a file I checked it - that's
useful when porting own stuff to another branch, or frequently it's the
only thing I actually remember. :-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply

* Summary of core GIT while you are away.
From: Junio C Hamano @ 2005-05-14 10:51 UTC (permalink / raw)
  To: torvalds; +Cc: pasky, braddr, nico, david, git

Hoping that you had a good time during your vacation, and at the
same time also hoping to help you catch up with GIT traffic,
here is my version of the summary of things that happened in the
GIT community around core GIT [*1*].

 - Just when I was forced to discontinue git-jc tree because my
   ISP webspace was running out, Petr Baudis started git-pb tree
   hosted at kernel.org next to his cogito repository, promising
   to pick up and keep good bits from the mailing list traffic.

   He's been doing quite a good job at it and if you pull from
   his tree, you will not miss anything worth keeping.  I can
   personally vouch for the crap-free-ness of his tree up to
   commit 95649d6cf9ec68f05d1dc57ec1b989b8d263a7ae (not that I
   suspect Petr will put crap in the tree after that, but that
   is the head as of this writing).  They consist of half
   bugfixes and half enhancements; all of them help Porcelain
   layers and end users.  Old git-jc tree has all been sucked
   into git-pb before being shut down, so we did not lose
   anything from there either.

 - A notable change you need to adjust your scripts and .profile
   to is that GIT environment variable names have changed.  All
   of them now have GIT_ as prefix.  Old names continue to work
   for now, though.

 - Nicolas Pitre's deltification patch is still cooking and in
   its latest incarnation it looked quite promising to me (the
   impact to the core is kept reasonably small and cleanly
   isolated).  Once fsck is made aware of it in the next round,
   I expect it to be ready to merge.

 - Brad Roberts has been working on libification to remove the
   assumption of having a single active_cache array.  I have
   minor qualms about it (I think it should also be tied with
   the index.lock handling for updates), but other than that, it
   looked admirably cleanly done.  I expect it to be in a
   mergeable state in the next round if/when he catches up with
   the tip of git-pb tree.

 - David Greaves has done all the heavy lifting for core GIT
   documentation.  It now is hosted at kernel.org with a nice
   web interface.

 - I have sent out about a dozen patches Petr has not caught up,
   mostly because we work in different timezones.  Other than
   that I have not seen anything immediately mergeable to the
   core GIT in the mailing list traffic.

 - Also you see names of many people in the git-pb log who
   contributed bugfixes and enhancements.  I am not belittling
   their contributions, but just not going to repeat what you
   can get from the log yourself.

That's about it.  Now please start pulling from 

	rsync://rsync.kernel.org/pub/scm/cogito/git-pb.git/

[Footnote]

*1* Porcelain layer seems to have had many more interesting
discussions, but I am not qualified to comment on them (I was
not following most of them).


^ permalink raw reply

* Re: gitweb wishlist
From: Jonas Fonseca @ 2005-05-14 10:54 UTC (permalink / raw)
  To: Kay Sievers; +Cc: Petr Baudis, git
In-Reply-To: <1116038598.9317.22.camel@dhcp-188.off.vrfy.org>

Kay Sievers <kay.sievers@vrfy.org> wrote Sat, May 14, 2005:
> On Wed, 2005-05-11 at 03:26 +0200, Petr Baudis wrote:
> >   I would be very happy if you could extend the gitweb scripts a little.
> > Basically, what I need is to have ability to create a permanent link to
> > a given file in the repository, which stays same across revisions (as
> > long as the file stays with the given name, obviously).
> > 
> >   E.g. I would like to have something like
> > 
> > 	http://www.kernel.org/git/gitweb.cgi?p=cogito%2Fcogito.git;n=contrib/ciabot.pl
> > 
> > for file contrib/ciabot.pl in the latest Cogito tree, and
> 
> http://www.kernel.org/git/gitweb.cgi?p=cogito/cogito.git;a=blob;f=contrib/ciabot.pl

How about support for getting the 'raw' files and diffs without all the
HTML markup?

-- 
Jonas Fonseca

^ permalink raw reply

* [PATCH cogito] "cg-whatsnew" command
From: Catalin Marinas @ 2005-05-14 10:58 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

This patch adds a simple command that shows the unmerged changes on a
branch. I find it quite useful to be able to see the diff or the log
before merging (gnuarch has something similar with "missing").

Catalin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-cg-whatsnew --]
[-- Type: text/x-patch, Size: 3243 bytes --]

Added the "cg-whatsnew" command

The command shows the unmerged changes on a branch (defaulting to 
"origin") as either a diff, log or patch.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

---
commit e396c64c7f84c45a1360d34bcb6092b62183df7d
tree c143a31ed694000b705c5019bb10ec3b3f911344
parent fa6e9eb368e949e78c4e66217461cf624b52b0a2
author Catalin Marinas <cmarinas@pc1117.cambridge.arm.com> Sat, 14 May 2005 11:47:52 +0100
committer Catalin Marinas <cmarinas@pc1117.cambridge.arm.com> Sat, 14 May 2005 11:47:52 +0100

 Makefile    |    3 +-
 cg-help     |    1 
 cg-whatsnew |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+), 1 deletion(-)

Index: Makefile
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/Makefile  (mode:100644)
+++ c143a31ed694000b705c5019bb10ec3b3f911344/Makefile  (mode:100644)
@@ -49,7 +49,8 @@
 SCRIPT=	commit-id tree-id parent-id cg-add cg-admin-lsobj cg-admin-uncommit \
 	cg-branch-add cg-branch-ls cg-cancel cg-clone cg-commit cg-diff \
 	cg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch cg-patch \
-	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update
+	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \
+	cg-whatsnew
 
 LIB_SCRIPT=cg-Xlib cg-Xdiffdo cg-Xmergefile
 
Index: cg-help
===================================================================
--- de641904363cd3759f132ee7c0dfaf8a2ee58388/cg-help  (mode:100755)
+++ c143a31ed694000b705c5019bb10ec3b3f911344/cg-help  (mode:100755)
@@ -44,6 +44,7 @@
 	cg-tag-ls
 	cg-update	[BNAME]
 	cg-version
+	cg-whatsnew	[-n] [-l | -m] [BNAME]
 
 Advanced (low-level or dangerous) commands:
 	cg-admin-lsobj	[OBJTYPE]
Index: cg-whatsnew
===================================================================
--- /dev/null  (tree:de641904363cd3759f132ee7c0dfaf8a2ee58388)
+++ c143a31ed694000b705c5019bb10ec3b3f911344/cg-whatsnew  (mode:100755)
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+#
+# Shows the unmerged changes on a branch
+# Copyright (c) Catalin Marinas, 2005
+#
+# Takes a parameter identifying the branch (defaulting to "origin").
+# Optional "-n" parameter specifies not to pull the changes from the branch.
+#
+# By default, shows the unmerged diff of the branch.
+# Optional "-l" parameter specifies to show the log instead of the diff
+# Optional "-m" parameter specifies to show the mkpatch instead of the diff
+
+. ${COGITO_LIB:-/home/cmarinas/lib/cogito/}cg-Xlib
+
+head=$(commit-id)
+show_cmd=cg-diff
+
+do_not_pull=
+if [ "$1" = "-n" ]; then
+	shift
+	do_not_pull=1
+fi
+
+while [ "$1" ]; do
+	case "$1" in
+	-n)
+		do_not_pull=1
+		shift
+		;;
+	-l)
+		show_cmd=cg-log
+		shift
+		;;
+	-m)
+		show_cmd=cg-mkpatch
+		shift
+		;;
+	-*)
+		die "Unknown option: $1"
+		;;
+	*)
+		break
+		;;
+	esac
+done
+
+if [ "$1" ]; then
+	branchname="$1"
+else
+	branchname=origin
+fi
+
+[ "$do_not_pull" ] || cg-pull $branchname
+
+branch=$(commit-id "$branchname") || exit 1
+base=$(git-merge-base "$head" "$branch")
+[ "$base" ] || die "Unable to determine the merge base"
+
+if [ "$base" = "$branch" ]; then
+	echo "Branch already fully merged" >&2
+else
+	$show_cmd -r $base:$branch
+fi

^ permalink raw reply

* Re: [PATCH cogito] "cg-whatsnew" command
From: Petr Baudis @ 2005-05-14 11:09 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <tnx64xm5b2b.fsf@arm.com>

Dear diary, on Sat, May 14, 2005 at 12:58:04PM CEST, I got a letter
where Catalin Marinas <catalin.marinas@arm.com> told me that...
> This patch adds a simple command that shows the unmerged changes on a
> branch. I find it quite useful to be able to see the diff or the log
> before merging (gnuarch has something similar with "missing").

I'd prefer this to be functionality builtin to cg-log and cg-mkpatch.
Perhaps some

	cg-log -m $branch2 [$branch1]

to show stuff in branch2 not yet merged to branch1.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox