Git development
 help / color / mirror / Atom feed
* [PATCH 0/3] Enable parallelized tests
From: Johannes Schindelin @ 2008-08-08  5:59 UTC (permalink / raw)
  To: git, gitster


This patch pair enables parallel tests.  On a pretty beefy machine,

	$ /usr/bin/time make -j50

shows this:

	69.33user 92.33system 0:59.26elapsed 272%CPU (0avgtext+0avgdata
	0maxresident)k 0inputs+0outputs (0major+33007360minor)pagefaults 0swaps

vs.

	$ /usr/bin/time make

showing this:

	61.25user 75.10system 3:57.68elapsed 57%CPU (0avgtext+0avgdata
	0maxresident)k 0inputs+0outputs (0major+32897071minor)pagefaults 0swaps

Note: the machine was used for other tasks during the test, too.

These results are with SVN/CVS tests enabled.  I am pretty sure that the
results would be even more impressive without them (the SVN/CVS tests come
all at the end, and seem to idle the CPU mostly, and the last few seconds
are only spent on 2 tests).

Johannes Schindelin (3):
  t9700: remove useless check
  tests: Clarify dependencies between tests, 'aggregate-results' and
    'clean'
  Enable parallel tests

 t/Makefile      |   15 ++++++++++++---
 t/t9700/test.pl |    3 ---
 t/test-lib.sh   |   11 ++++++++++-
 3 files changed, 22 insertions(+), 7 deletions(-)

^ permalink raw reply

* [PATCH 1/3] t9700: remove useless check
From: Johannes Schindelin @ 2008-08-08  5:59 UTC (permalink / raw)
  To: git, gitster, Lea Wiemann
In-Reply-To: <alpine.DEB.1.00.0808080752210.9611@pacific.mpi-cbg.de.mpi-cbg.de>


t9700 used to check if the basename of the current directory is
'trash directory', the expensive way.

However, there is absolutely no good reason why this test should not
run in, say 'life is good' or 'i love tests'.  So remove the check
altogether.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t9700/test.pl |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 4d23125..851cea4 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -14,10 +14,7 @@ use File::Temp;
 BEGIN { use_ok('Git') }
 
 # set up
-our $repo_dir = "trash directory";
 our $abs_repo_dir = Cwd->cwd;
-die "this must be run by calling the t/t97* shell script(s)\n"
-    if basename(Cwd->cwd) ne $repo_dir;
 ok(our $r = Git->repository(Directory => "."), "open repository");
 
 # config
-- 
1.6.0.rc2.23.gd08e9

^ permalink raw reply related

* [PATCH 2/3] tests: Clarify dependencies between tests, 'aggregate-results' and 'clean'
From: Johannes Schindelin @ 2008-08-08  5:59 UTC (permalink / raw)
  To: git, gitster, Sverre Rabbelier
In-Reply-To: <alpine.DEB.1.00.0808080752210.9611@pacific.mpi-cbg.de.mpi-cbg.de>


The Makefile targets 'aggregate-results' and 'clean' pretended to be
independent.  This is not true, of course, since aggregate-results
needs the results _before_ they are removed.

Likewise, the tests should have been run already when the results are
to be aggregated.

However, as it is legitimate to run only a few tests, and then aggregate
just those results, so another target is introduced, that depends on all
tests, then aggregates the results, and only then removes the results.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/Makefile |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/t/Makefile b/t/Makefile
index 0d65ced..aa952e1 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -14,7 +14,8 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
 TSVN = $(wildcard t91[0-9][0-9]-*.sh)
 
-all: pre-clean $(T) aggregate-results clean
+all: pre-clean
+	$(MAKE) aggregate-results-and-cleanup
 
 $(T):
 	@echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
@@ -25,6 +26,10 @@ pre-clean:
 clean:
 	$(RM) -r 'trash directory' test-results
 
+aggregate-results-and-cleanup: $(T)
+	$(MAKE) aggregate-results
+	$(MAKE) clean
+
 aggregate-results:
 	'$(SHELL_PATH_SQ)' ./aggregate-results.sh test-results/t*-*
 
-- 
1.6.0.rc2.23.gd08e9

^ permalink raw reply related

* [PATCH 3/3] Enable parallel tests
From: Johannes Schindelin @ 2008-08-08  5:59 UTC (permalink / raw)
  To: git, gitster
In-Reply-To: <alpine.DEB.1.00.0808080752210.9611@pacific.mpi-cbg.de.mpi-cbg.de>


On multiprocessor machines, or with I/O heavy tests (that leave the
CPU waiting a lot), it makes sense to parallelize the tests.

However, care has to be taken that the different jobs use different
trash directories.

This commit does so, by inspecting the MAKEFLAGS variable to detect
if the option "-j" or "--jobs" was passed to make.  In that case, the
test is run with the new "--parallel" option.

If parallel mode was detected, the trash directories are created with
a suffix that is unique with regard to the test, as it is the test's
base name.

Parallel mode also triggers removal of the trash directory in the test
itself if everything went fine, so that the trash directories do not
pile up only to be removed at the very end.

If a test failed, the trash directory is not removed.  Chances are
that the exact error message is lost in the clutter, but you can still
see what test failed from the name of the trash directory, and repeat
the test (without -j).

If all was good, you will see the aggregated results.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/Makefile    |    8 ++++++--
 t/test-lib.sh |   11 ++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/t/Makefile b/t/Makefile
index aa952e1..fb2fba9 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -14,6 +14,11 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
 TSVN = $(wildcard t91[0-9][0-9]-*.sh)
 
+# MAKEFLAGS only sees the -j flag when expanded in the task, so we cannot
+# use ifeq() games here.  Instead we play shell games.
+GIT_TEST_OPTS += $(shell echo " $(MAKEFLAGS)" | \
+	sed -n "s/^.* \(--jobs\|\(-\|[^-]*\)j\).*/--parallel/p")
+
 all: pre-clean
 	$(MAKE) aggregate-results-and-cleanup
 
@@ -24,7 +29,7 @@ pre-clean:
 	$(RM) -r test-results
 
 clean:
-	$(RM) -r 'trash directory' test-results
+	$(RM) -rf 'trash directory' test-results
 
 aggregate-results-and-cleanup: $(T)
 	$(MAKE) aggregate-results
@@ -39,4 +44,3 @@ full-svn-test:
 	$(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8
 
 .PHONY: pre-clean $(T) aggregate-results clean
-.NOTPARALLEL:
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 11c0275..c5868c4 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -74,6 +74,7 @@ esac
 	) &&
 	color=t
 
+test="trash directory"
 while test "$#" -ne 0
 do
 	case "$1" in
@@ -94,6 +95,10 @@ do
 	--no-python)
 		# noop now...
 		shift ;;
+	--parallel)
+		test="$test.$(basename "$0" .sh)"
+		remove_trash="$(pwd)/$test"
+		shift ;;
 	*)
 		break ;;
 	esac
@@ -449,6 +454,11 @@ test_done () {
 		# we will leave things as they are.
 
 		say_color pass "passed all $msg"
+
+		test ! -z = "$remove_trash" &&
+		cd "$(dirname "$remove_trash")" &&
+		rm -rf "$(basename "$remove_trash")"
+
 		exit 0 ;;
 
 	*)
@@ -485,7 +495,6 @@ fi
 . ../GIT-BUILD-OPTIONS
 
 # Test repository
-test="trash directory"
 rm -fr "$test" || {
 	trap - exit
 	echo >&5 "FATAL: Cannot prepare test area"
-- 
1.6.0.rc2.23.gd08e9

^ permalink raw reply related

* Re: [PATCH] clone --mirror: avoid storing repeated tags
From: Junio C Hamano @ 2008-08-08  6:41 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <7vej50gl3v.fsf@gitster.siamese.dyndns.org>

Junio C Hamano <gitster@pobox.com> writes:

> Thanks for reporting and a quick fix.

By the way, Dscho, do you have comments on recent filter-branch thread and
patches?

^ permalink raw reply

* [TopGit PATCH] tg.sh: it's info/attributes not info/gitattributes
From: Bert Wesarg @ 2008-08-08  6:43 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Bert Wesarg, git

The merge attribute hasn't any effect, because the wrong attribute file was
used.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 tg.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tg.sh b/tg.sh
index 03a392b..209b69e 100644
--- a/tg.sh
+++ b/tg.sh
@@ -45,11 +45,11 @@ setup_hook()
 # setup_ours (no arguments)
 setup_ours()
 {
-	if [ ! -s "$git_dir/info/gitattributes" ] || ! grep -q topmsg "$git_dir/info/gitattributes"; then
+	if [ ! -s "$git_dir/info/attributes" ] || ! grep -q topmsg "$git_dir/info/attributes"; then
 		{
 			echo -e ".topmsg\tmerge=ours"
 			echo -e ".topdeps\tmerge=ours"
-		} >>"$git_dir/info/gitattributes"
+		} >>"$git_dir/info/attributes"
 	fi
 	if ! git config merge.ours.driver >/dev/null; then
 		git config merge.ours.name '"always keep ours" merge driver'
-- 
tg: (e311d15..) t/its-info-attributes (depends on: master)

^ permalink raw reply related

* Re: [PATCH 3/3] Enable parallel tests
From: Junio C Hamano @ 2008-08-08  6:52 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster
In-Reply-To: <alpine.DEB.1.00.0808080754230.9611@pacific.mpi-cbg.de.mpi-cbg.de>

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> On multiprocessor machines, or with I/O heavy tests (that leave the
> CPU waiting a lot), it makes sense to parallelize the tests.

I was actually thinking about doing this eventually.  Thanks for beating
me to it.

> Parallel mode also triggers removal of the trash directory in the test
> itself if everything went fine, so that the trash directories do not
> pile up only to be removed at the very end.

I think making the tests remove their own mess makes sense regardless.

I have to wonder why you would want to make this change conditional on
MAKEFLAGS.  I was envisioning that parallel tests would run in "trash
directory/$(basename $0)" or something.

Are there downsides of doing this change unconditionally?

>  clean:
> -	$(RM) -r 'trash directory' test-results
> +	$(RM) -rf 'trash directory' test-results

This is not needed, I think, as RM is defined with -f already.

^ permalink raw reply

* Re: git filter-branch --subdirectory-filter, still a mistery
From: Jan Wielemaker @ 2008-08-08  7:44 UTC (permalink / raw)
  To: Thomas Rast; +Cc: git
In-Reply-To: <200808080148.27384.trast@student.ethz.ch>

Hi Thomas,

Thanks for looking into this!

On Friday 08 August 2008 01:48:05 Thomas Rast wrote:
> Jan Wielemaker wrote:
> >   Ref 'refs/tags/V5.6.50' was rewritten
> >   error: Ref refs/tags/V5.6.50 is at
> > 8678b32f71178019c06aefa40e2d3fb9a2e8ef25 but
> > 	expected 2e8aef64e2fed088720a19ac2ffa2481e5bc7806
> >   fatal: Cannot lock the ref 'refs/tags/V5.6.50'.
> >   Could not rewrite refs/tags/V5.6.50
>
> [...]
>
> > Now, if I look in .git/packed-refs [...] and I changed all these to
> > `lightweight' tags
>
> This appears to be a bug.  I've whipped up a patch that will follow
> and should fix the bug.  It has nothing to do with packed-refs; the
> current filter-branch chokes on annotated tags during
> --subdirectory-filter, even though there is support for tag rewriting.
>
> However, to enable tag rewriting, you need to say --tag-name-filter
> cat.

Great.  I knew a more fundamental approach was asked for, but I bet my
simple-minded work-around gives the same result, no?

> > Now it runs to the end.  Unfortunagtely the history is completely
> > screwed up :-(:
> >
> > 	* There are a lot of commits that are not related to the dir
> > 	* Commits start long before the directory came into existence,
> > 	Looks like it just shows the whole project at this place.
>
> For some reason the ancestor detection does not work right.  I'm also
> following up with an RFH patch that significantly improves the success
> rate (in terms of branches and tags successfully mapped to a rewritten
> commit) in the case of your repository.  I doubt more staring at the
> code would yield any more ideas at this hour, so ideas would be
> appreciated.

Thanks. As I'm using the GIT version anyway, I'll apply these patches
and see what happens. The trouble is related to tags and possibly to
branches. I get completely correct result if I delete all branches and
tags before filtering.  That at least helps for this particular subproject
(though some of the tags are useful).

I didn't further investigate branches (I think the packages/chr
directory is not involved in any branch; if you are interested, the boot
directory should show traces of the V57X branch).

I did see that (all/some?) tags that involve changes to the packages/chr
directory nicely end up in its history, but others do not appear on the
filtered master branch and give access to the complete project. See for
example V5.6.59 (the latest release tag). Try (in the filtered branch)

	git diff V5.6.59..

That should only show some small changes, but it diffs the entire project
against the subdir ...

> The rest is just the other commits/tags showing a lot of the history.
> I don't know of any built-in way to prune the branches and tags that
> aren't part of the new master, but
>
>   git branch -a --no-merged master
>
> can tell you which branches aren't ancestors of master.

Thanks for the tip.

	Cheers --- Jan

^ permalink raw reply

* Re: [PATCH 3/3] Enable parallel tests
From: René Scharfe @ 2008-08-08  7:44 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster
In-Reply-To: <alpine.DEB.1.00.0808080754230.9611@pacific.mpi-cbg.de.mpi-cbg.de>

Johannes Schindelin schrieb:
> On multiprocessor machines, or with I/O heavy tests (that leave the
> CPU waiting a lot), it makes sense to parallelize the tests.
> 
> However, care has to be taken that the different jobs use different
> trash directories.

Good idea!

> This commit does so, by inspecting the MAKEFLAGS variable to detect
> if the option "-j" or "--jobs" was passed to make.  In that case, the
> test is run with the new "--parallel" option.

How about making the test harness be able to run multiple tests in
parallel by default, i.e. always use a different trash directory name
for each test, without adding the new option?  The implementation would
be a bit simpler (no -j detection needed) and the documentation would be
simpler, too.  We could say "look in 'trash directory/tNNNN'" instead of
"look in this place unless you used -j".

> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 11c0275..c5868c4 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -74,6 +74,7 @@ esac
>  	) &&
>  	color=t
>  
> +test="trash directory"
>  while test "$#" -ne 0
>  do
>  	case "$1" in
> @@ -94,6 +95,10 @@ do
>  	--no-python)
>  		# noop now...
>  		shift ;;
> +	--parallel)
> +		test="$test.$(basename "$0" .sh)"
> +		remove_trash="$(pwd)/$test"
> +		shift ;;

test="trash directory/$this_test"?

The advantage would be that all trash was still inside "trash
directory".  Not sure if the extra directory level would break
something.  (Note: $this_test is defined a bit later in the script.)

test="trash for $this_test"?

This one still has a space in it..

>  	*)
>  		break ;;
>  	esac
> @@ -449,6 +454,11 @@ test_done () {
>  		# we will leave things as they are.
>  
>  		say_color pass "passed all $msg"
> +
> +		test ! -z = "$remove_trash" &&

This test succeeds always, because = is not an empty string.

René

^ permalink raw reply

* [PATCH] Documentation: commit-tree: remove 16 parents restriction
From: Thomas Rast @ 2008-08-08  7:52 UTC (permalink / raw)
  To: git; +Cc: gitster, Johannes Schindelin

ef98c5ca lifted the 16 parents restriction in builtin-commit-tree.c,
but forgot to update the documentation.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 Documentation/git-commit-tree.txt |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt
index feec584..92ab3ab 100644
--- a/Documentation/git-commit-tree.txt
+++ b/Documentation/git-commit-tree.txt
@@ -16,12 +16,12 @@ This is usually not what an end user wants to run directly.  See
 linkgit:git-commit[1] instead.
 
 Creates a new commit object based on the provided tree object and
-emits the new commit object id on stdout. If no parent is given then
-it is considered to be an initial tree.
+emits the new commit object id on stdout.
 
-A commit object usually has 1 parent (a commit after a change) or up
-to 16 parents.  More than one parent represents a merge of branches
-that led to them.
+A commit object may have any number of parents. With exactly one
+parent, it is an ordinary commit. Having more than one parent makes
+the commit a merge between several lines of history. Initial (root)
+commits have no parents.
 
 While a tree represents a particular directory state of a working
 directory, a commit represents that state in "time", and explains how
-- 
1.6.0.rc2.19.g3c9ba

^ permalink raw reply related

* [StGit] kha/{safe,experimental} updated
From: Karl Hasselström @ 2008-08-08  8:27 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git, Samuel Tardieu, Daniel White

Catalin has pulled the safe and stable branches, but I've accumulated
some new stuff in kha/safe.

The stack log stuff (and nothing else) is still in kha/experimental.
It's unchanged since my last status mail, except for the addition of
an optimization at the end (will post as a follow-up to this mail).


                                 -+-


The following changes since commit 36a06e0194e013552499677e431e528ecb2faee9:
  Karl Hasselström (1):
        Global performance logging

are available in the git repository at:

  git://repo.or.cz/stgit/kha.git safe

Daniel White (7):
      Fix Makefile to correctly pass prefix option
      Remove variables regarding section 7 man pages
      Fix default install location for manpages
      Add install-doc target to makefile
      Add install-html target to makefile
      Remove installation of documentation from setup.py
      Updated INSTALL with documentation of Makefile

Karl Hasselström (1):
      Add some tests of refreshing removed files

Samuel Tardieu (2):
      Do not insert an empty line before the diffstat info
      Do not mess-up with commit message formatting when sending email

 Documentation/Makefile     |   25 +++++------
 INSTALL                    |   15 ++++--
 Makefile                   |   12 ++++-
 setup.py                   |    2 +-
 stgit/commands/mail.py     |    4 +-
 t/t2702-refresh-rm.sh      |  101 ++++++++++++++++++++++++++++++++++++++++++++
 templates/mailattch.tmpl   |    1 -
 templates/patchexport.tmpl |    1 -
 templates/patchmail.tmpl   |    1 -
 9 files changed, 135 insertions(+), 27 deletions(-)
 create mode 100755 t/t2702-refresh-rm.sh


                                 -+-


The following changes since commit 42857cbe036ba5917eacc9dbb5644d395f638ed9:
  Samuel Tardieu (1):
        Do not mess-up with commit message formatting when sending email

are available in the git repository at:

  git://repo.or.cz/stgit/kha.git experimental

Karl Hasselström (17):
      Write to a stack log when stack is modified
      New command: stg reset
      Log conflicts separately
      Log conflicts separately for all commands
      Add a --hard flag to stg reset
      Don't write a log entry if there were no changes
      Move stack reset function to a shared location
      New command: stg undo
      New command: stg redo
      Log and undo external modifications
      Make "stg log" show stack log instead of patch log
      Convert "stg refresh" to the new infrastructure
      New refresh tests
      Remove --undo flags from stg commands and docs
      Refactor stgit.commands.edit
      Implement "stg refresh --edit" again
      Read several objects at once with git cat-file --batch

 Documentation/tutorial.txt   |    4 +-
 TODO                         |    2 -
 stgit/commands/branch.py     |   19 +-
 stgit/commands/clone.py      |    2 +-
 stgit/commands/coalesce.py   |    2 +-
 stgit/commands/common.py     |   18 ++-
 stgit/commands/diff.py       |    6 +-
 stgit/commands/edit.py       |   82 +------
 stgit/commands/export.py     |    2 +-
 stgit/commands/files.py      |    6 +-
 stgit/commands/float.py      |    2 +-
 stgit/commands/fold.py       |    2 +-
 stgit/commands/goto.py       |    3 +-
 stgit/commands/hide.py       |    2 +-
 stgit/commands/id.py         |    2 +-
 stgit/commands/imprt.py      |    4 +-
 stgit/commands/log.py        |  169 +++++----------
 stgit/commands/mail.py       |    8 +-
 stgit/commands/new.py        |    3 +-
 stgit/commands/patches.py    |    2 +-
 stgit/commands/pick.py       |    2 +-
 stgit/commands/pop.py        |    4 +-
 stgit/commands/pull.py       |    2 +-
 stgit/commands/push.py       |   31 +--
 stgit/commands/rebase.py     |    4 +-
 stgit/commands/redo.py       |   52 ++++
 stgit/commands/refresh.py    |  338 ++++++++++++++++++---------
 stgit/commands/rename.py     |    2 +-
 stgit/commands/repair.py     |   11 +-
 stgit/commands/reset.py      |   57 +++++
 stgit/commands/resolved.py   |    2 +-
 stgit/commands/show.py       |    2 +-
 stgit/commands/sink.py       |    2 +-
 stgit/commands/status.py     |    3 +-
 stgit/commands/sync.py       |   26 +--
 stgit/commands/undo.py       |   49 ++++
 stgit/commands/unhide.py     |    2 +-
 stgit/git.py                 |    4 -
 stgit/lib/edit.py            |   99 ++++++++
 stgit/lib/git.py             |  108 ++++++++-
 stgit/lib/log.py             |  524 ++++++++++++++++++++++++++++++++++++++++++
 stgit/lib/stack.py           |   25 ++
 stgit/lib/transaction.py     |  125 +++++++----
 stgit/main.py                |    8 +
 stgit/run.py                 |   17 ++
 stgit/stack.py               |   45 +----
 stgit/utils.py               |   18 +-
 t/t1200-push-modified.sh     |    2 +-
 t/t1201-pull-trailing.sh     |    2 +-
 t/t1202-push-undo.sh         |    8 +-
 t/t1400-patch-history.sh     |  103 --------
 t/t2300-refresh-subdir.sh    |   29 +++-
 t/t2701-refresh-p.sh         |    2 +-
 t/t3100-reset.sh             |  160 +++++++++++++
 t/t3101-reset-hard.sh        |   56 +++++
 t/t3102-undo.sh              |   86 +++++++
 t/t3103-undo-hard.sh         |   56 +++++
 t/t3104-redo.sh              |  122 ++++++++++
 t/t3105-undo-external-mod.sh |   68 ++++++
 t/t3300-edit.sh              |    4 +-
 60 files changed, 1986 insertions(+), 614 deletions(-)
 create mode 100644 stgit/commands/redo.py
 create mode 100644 stgit/commands/reset.py
 create mode 100644 stgit/commands/undo.py
 create mode 100644 stgit/lib/edit.py
 create mode 100644 stgit/lib/log.py
 delete mode 100755 t/t1400-patch-history.sh
 create mode 100755 t/t3100-reset.sh
 create mode 100755 t/t3101-reset-hard.sh
 create mode 100755 t/t3102-undo.sh
 create mode 100755 t/t3103-undo-hard.sh
 create mode 100755 t/t3104-redo.sh
 create mode 100755 t/t3105-undo-external-mod.sh

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply

* [StGit PATCH] Read several objects at once with git cat-file --batch
From: Karl Hasselström @ 2008-08-08  8:07 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <20080808082728.GA24017@diana.vm.bytemark.co.uk>

Instead of spawning a separate cat-file process for every blob and
commit we want to read. This speeds things up slightly: about 6-8%
when uncommitting and rebasing 1470 linux-kernel patches (perftest.py
rebase-newrebase-add-file-linux).

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/lib/git.py |   34 +++++++++++++++++++++++++++++++++-
 stgit/run.py     |   17 +++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletions(-)


diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 648e190..95efd9a 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -520,6 +520,37 @@ class RunWithEnvCwd(RunWithEnv):
         @param args: Command and argument vector"""
         return RunWithEnv.run(self, args, self.env_in_cwd)
 
+class CatFileProcess(object):
+    def __init__(self, repo):
+        self.__repo = repo
+        self.__proc = None
+    def __get_process(self):
+        if not self.__proc:
+            self.__proc = self.__repo.run(['git', 'cat-file', '--batch']
+                                          ).run_background()
+        return self.__proc
+    def cat_file(self, sha1):
+        p = self.__get_process()
+        p.stdin.write('%s\n' % sha1)
+        p.stdin.flush()
+
+        # Read until we have the entire status line.
+        s = ''
+        while not '\n' in s:
+            s += os.read(p.stdout.fileno(), 4096)
+        h, b = s.split('\n', 1)
+        if h == '%s missing' % sha1:
+            raise SomeException()
+        hash, type, length = h.split()
+        assert hash == sha1
+        length = int(length)
+
+        # Read until we have the entire object plus the trailing
+        # newline.
+        while len(b) < length + 1:
+            b += os.read(p.stdout.fileno(), 4096)
+        return type, b[:-1]
+
 class Repository(RunWithEnv):
     """Represents a git repository."""
     def __init__(self, directory):
@@ -531,6 +562,7 @@ class Repository(RunWithEnv):
         self.__default_index = None
         self.__default_worktree = None
         self.__default_iw = None
+        self.__catfile = CatFileProcess(self)
     env = property(lambda self: { 'GIT_DIR': self.__git_dir })
     @classmethod
     def default(cls):
@@ -580,7 +612,7 @@ class Repository(RunWithEnv):
     directory = property(lambda self: self.__git_dir)
     refs = property(lambda self: self.__refs)
     def cat_object(self, sha1):
-        return self.run(['git', 'cat-file', '-p', sha1]).raw_output()
+        return self.__catfile.cat_file(sha1)[1]
     def rev_parse(self, rev):
         try:
             return self.get_commit(self.run(
diff --git a/stgit/run.py b/stgit/run.py
index 7493ed3..ccca059 100644
--- a/stgit/run.py
+++ b/stgit/run.py
@@ -130,6 +130,19 @@ class Run:
             raise self.exc('%s failed: %s' % (self.__cmd[0], e))
         self.__log_end(self.exitcode)
         self.__check_exitcode()
+    def __run_background(self):
+        """Run in background."""
+        assert self.__indata == None
+        try:
+            p = subprocess.Popen(self.__cmd, env = self.__env, cwd = self.__cwd,
+                                 stdin = subprocess.PIPE,
+                                 stdout = subprocess.PIPE,
+                                 stderr = subprocess.PIPE)
+        except OSError, e:
+            raise self.exc('%s failed: %s' % (self.__cmd[0], e))
+        self.stdin = p.stdin
+        self.stdout = p.stdout
+        self.stderr = p.stderr
     def returns(self, retvals):
         self.__good_retvals = retvals
         return self
@@ -181,6 +194,10 @@ class Run:
     def run(self):
         """Just run, with no IO redirection."""
         self.__run_noio()
+    def run_background(self):
+        """Run as a background process."""
+        self.__run_background()
+        return self
     def xargs(self, xargs):
         """Just run, with no IO redirection. The extra arguments are
         appended to the command line a few at a time; the command is

^ permalink raw reply related

* Re: [PATCH 3/3] Enable parallel tests
From: Junio C Hamano @ 2008-08-08  8:28 UTC (permalink / raw)
  To: René Scharfe; +Cc: Johannes Schindelin, git, gitster
In-Reply-To: <489BF95F.1070000@lsrfire.ath.cx>

René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:

> test="trash directory/$this_test"?
>
> The advantage would be that all trash was still inside "trash
> directory".  Not sure if the extra directory level would break
> something.  (Note: $this_test is defined a bit later in the script.)

The extra directory level may break some tests that refer to their
precomputed test vectors in ../tXXXX, but I think they should be fixed
regardless.  That's what $TEST_DIRECTORY is for.

I'd very much prefer having 't/trash directory/t1234-test-name/' so that
we can say "make clean" to clean "t/trash directory" in one go.

^ permalink raw reply

* Re: On PPC64, the parsing of integers on the commandline is  bitshifted.
From: Pierre Habouzit @ 2008-08-08  8:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Brandon Casey, Robin H. Johnson, git
In-Reply-To: <7vhc9wijsq.fsf@gitster.siamese.dyndns.org>

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

On Thu, Aug 07, 2008 at 09:42:29PM +0000, Junio C Hamano wrote:
> Brandon Casey <casey@nrlssc.navy.mil> writes:
> 
> > Brandon Casey wrote:
> >> Robin H. Johnson wrote:
> >>> In a 64-bit userland, big-endian environment, the parser gets integers
> >>> wrong.
> >> 
> >> There is a fix on master. Can you try that out?
> >> Unfortunately, looks like it did not make it into 1.5.6.5
> >
> > Also, just so you know, it is test-parse-options.c that is broken, not
> > the parsing code. So, the rest of git should be using an int with
> > OPT_INTEGER() and should operate correctly.
> 
> Yup, that is why it is not on 'maint' --- but somebody should audit the
> parse_options() users in the real programs to make sure that there is no
> similar breakages, namely, giving a pointer to long to OPT_INTEGER().

  Well FWIW I'll probably write some __GNUC__ guarded glue using
__builtin_types_compatible and friends to ensure we're not passing crap
to the OPT_* macros. I just didn't have time to yet.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: [PATCH v2 0/2] git-svn multi-glob fix and extension
From: Eric Wong @ 2008-08-08  8:40 UTC (permalink / raw)
  To: Marcus Griep; +Cc: Git Mailing List, Junio C Hamano
In-Reply-To: <1218123242-26260-1-git-send-email-marcus@griep.us>

Marcus Griep <marcus@griep.us> wrote:
> 
> This patch series fixes and extends globs for branches and tags.
> 
> The first patch fixes the assertion that protects git-svn from allowing
> multi-globs in branch names, whereas the second removes that restriction
> altogether, allowing up to one multi-glob set in defining a branch hierarchy.
> 
> Also, patches are now under 80 chars wide except for a couple of echos in the
> test cases.

Thanks.  At least I can apply the patches now :)
I've made couple of fixups which will be replies to this message.

Eric Wong (1):
      git-svn: wrap long lines in a few places

Marcus Griep (2):
      Fix multi-glob assertion in git-svn
      git-svn: Allow deep branch names by supporting multi-globs

---
 git-svn.perl                               |   67 +++++++++---
 t/t9108-git-svn-glob.sh                    |   24 ++++-
 t/t9108-git-svn-multi-glob.sh              |  157 ++++++++++++++++++++++++++++
 t/t9125-git-svn-multi-glob-branch-names.sh |   37 +++++++
 4 files changed, 267 insertions(+), 18 deletions(-)

-- 
Eric Wong

^ permalink raw reply

* [PATCH 1/3] Fix multi-glob assertion in git-svn
From: Eric Wong @ 2008-08-08  8:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Marcus Griep
In-Reply-To: <20080808084025.GA8718@untitled>

From: Marcus Griep <marcus@griep.us>

Fixes bad regex match check for multiple globs (would always return
one glob regardless of actual number).

[ew: fixed a bashism in the test and some minor line-wrapping]

Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl            |    5 +++--
 t/t9108-git-svn-glob.sh |   21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 06a82c8..503a7c9 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4915,14 +4915,15 @@ sub new {
 	my ($class, $glob) = @_;
 	my $re = $glob;
 	$re =~ s!/+$!!g; # no need for trailing slashes
-	my $nr = ($re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g);
-	my ($left, $right) = ($1, $2);
+	my $nr = $re =~ tr/*/*/;
 	if ($nr > 1) {
 		die "Only one '*' wildcard expansion ",
 		    "is supported (got $nr): '$glob'\n";
 	} elsif ($nr == 0) {
 		die "One '*' is needed for glob: '$glob'\n";
 	}
+	$re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g;
+	my ($left, $right) = ($1, $2);
 	$re = quotemeta($left) . $re . quotemeta($right);
 	if (length $left && !($left =~ s!/+$!!g)) {
 		die "Missing trailing '/' on left side of: '$glob' ($left)\n";
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index f6f71d0..a6f88bd 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -83,4 +83,25 @@ test_expect_success 'test left-hand-side only globbing' '
 	cmp expect.two output.two
 	'
 
+echo "Only one '*' wildcard expansion is supported (got 2): 'branches/*/*'" \
+     > expect.three
+echo "" >> expect.three
+
+test_expect_success 'test disallow multi-globs' '
+	git config --add svn-remote.three.url "$svnrepo" &&
+	git config --add svn-remote.three.fetch \
+	                 trunk:refs/remotes/three/trunk &&
+	git config --add svn-remote.three.branches \
+	                 "branches/*/*:refs/remotes/three/branches/*" &&
+	git config --add svn-remote.three.tags \
+	                 "tags/*/*:refs/remotes/three/tags/*" &&
+	cd tmp &&
+		echo "try try" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "try to try"
+		cd .. &&
+	test_must_fail git-svn fetch three 2> stderr.three &&
+	cmp expect.three stderr.three
+	'
+
 test_done
-- 
1.6.0.rc2.4.g0643f

^ permalink raw reply related

* [PATCH 3/3] git-svn: wrap long lines in a few places
From: Eric Wong @ 2008-08-08  8:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Marcus Griep, Eric Wong
In-Reply-To: <20080808084025.GA8718@untitled>

Oops, I let a few patches slip by with long lines in them.
Extracted from an unrelated patch by: Marcus Griep <marcus@griep.us>

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 47ad378..d7a884d 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -171,7 +171,8 @@ my %cmd = (
 			  'color' => \$Git::SVN::Log::color,
 			  'pager=s' => \$Git::SVN::Log::pager
 			} ],
-	'find-rev' => [ \&cmd_find_rev, "Translate between SVN revision numbers and tree-ish",
+	'find-rev' => [ \&cmd_find_rev,
+	                "Translate between SVN revision numbers and tree-ish",
 			{} ],
 	'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory",
 			{ 'merge|m|M' => \$_merge,
@@ -231,7 +232,9 @@ unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
 
 read_repo_config(\%opts);
-Getopt::Long::Configure('pass_through') if ($cmd && ($cmd eq 'log' || $cmd eq 'blame'));
+if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
+	Getopt::Long::Configure('pass_through');
+}
 my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,
                     'minimize-connections' => \$Git::SVN::Migration::_minimize,
                     'id|i=s' => \$Git::SVN::default_ref_id,
-- 
1.6.0.rc2.4.g0643f

^ permalink raw reply related

* [PATCH 2/3] git-svn: Allow deep branch names by supporting multi-globs
From: Eric Wong @ 2008-08-08  8:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Marcus Griep
In-Reply-To: <20080808084025.GA8718@untitled>

From: Marcus Griep <marcus@griep.us>

Some repositories use a deep branching strategy, such as:
branches/1.0/1.0.rc1
branches/1.0/1.0.rc2
branches/1.0/1.0.rtm
branches/1.0/1.0.gold

Only allowing a single glob stiffles this.

This change allows for a single glob 'set' to accept this deep
branching strategy.

The ref glob depth must match the branch glob depth.  When using
the -b or -t options for init or clone, this is automatically
done.

For example, using the above branches:
  svn-remote.svn.branches = branches/*/*:refs/remote/*/*
gives the following branch names:
  1.0/1.0.rc1
  1.0/1.0.rc2
  1.0/1.0.rtm
  1.0/1.0.gold

[ew:
  * removed unrelated line-wrapping changes
  * fixed line-wrapping in a few more places
  * removed trailing whitespace
  * fixed bashism in test
  * removed unnecessary httpd startup in test
  * changed copyright on tests to 2008 Marcus Griep
  * added executable permissions to new tests
]

Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl                               |   61 ++++++++---
 t/t9108-git-svn-glob.sh                    |    9 +-
 t/t9108-git-svn-multi-glob.sh              |  157 ++++++++++++++++++++++++++++
 t/t9125-git-svn-multi-glob-branch-names.sh |   37 +++++++
 4 files changed, 244 insertions(+), 20 deletions(-)
 create mode 100755 t/t9108-git-svn-multi-glob.sh
 create mode 100755 t/t9125-git-svn-multi-glob-branch-names.sh

diff --git a/git-svn.perl b/git-svn.perl
index 503a7c9..47ad378 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -987,8 +987,10 @@ sub complete_url_ls_init {
 	if (length $pfx && $pfx !~ m#/$#) {
 		die "--prefix='$pfx' must have a trailing slash '/'\n";
 	}
-	command_noisy('config', "svn-remote.$gs->{repo_id}.$n",
-				"$remote_path:refs/remotes/$pfx*");
+	command_noisy('config',
+	              "svn-remote.$gs->{repo_id}.$n",
+	              "$remote_path:refs/remotes/$pfx*" .
+	                ('/*' x (($remote_path =~ tr/*/*/) - 1)) );
 }
 
 sub verify_ref {
@@ -4124,16 +4126,38 @@ sub gs_fetch_loop_common {
 	Git::SVN::gc();
 }
 
+sub get_dir_globbed {
+	my ($self, $left, $depth, $r) = @_;
+
+	my @x = eval { $self->get_dir($left, $r) };
+	return unless scalar @x == 3;
+	my $dirents = $x[0];
+	my @finalents;
+	foreach my $de (keys %$dirents) {
+		next if $dirents->{$de}->{kind} != $SVN::Node::dir;
+		if ($depth > 1) {
+			my @args = ("$left/$de", $depth - 1, $r);
+			foreach my $dir ($self->get_dir_globbed(@args)) {
+				push @finalents, "$de/$dir";
+			}
+		} else {
+			push @finalents, $de;
+		}
+	}
+	@finalents;
+}
+
 sub match_globs {
 	my ($self, $exists, $paths, $globs, $r) = @_;
 
 	sub get_dir_check {
 		my ($self, $exists, $g, $r) = @_;
-		my @x = eval { $self->get_dir($g->{path}->{left}, $r) };
-		return unless scalar @x == 3;
-		my $dirents = $x[0];
-		foreach my $de (keys %$dirents) {
-			next if $dirents->{$de}->{kind} != $SVN::Node::dir;
+
+		my @dirs = $self->get_dir_globbed($g->{path}->{left},
+		                                  $g->{path}->{depth},
+		                                  $r);
+
+		foreach my $de (@dirs) {
 			my $p = $g->{path}->full_path($de);
 			next if $exists->{$p};
 			next if (length $g->{path}->{right} &&
@@ -4915,16 +4939,21 @@ sub new {
 	my ($class, $glob) = @_;
 	my $re = $glob;
 	$re =~ s!/+$!!g; # no need for trailing slashes
-	my $nr = $re =~ tr/*/*/;
-	if ($nr > 1) {
-		die "Only one '*' wildcard expansion ",
-		    "is supported (got $nr): '$glob'\n";
-	} elsif ($nr == 0) {
+	$re =~ m!^([^*]*)(\*(?:/\*)*)([^*]*)$!;
+	my $temp = $re;
+	my ($left, $right) = ($1, $3);
+	$re = $2;
+	my $depth = $re =~ tr/*/*/;
+	if ($depth != $temp =~ tr/*/*/) {
+		die "Only one set of wildcard directories " .
+			"(e.g. '*' or '*/*/*') is supported: '$glob'\n";
+	}
+	if ($depth == 0) {
 		die "One '*' is needed for glob: '$glob'\n";
 	}
-	$re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g;
-	my ($left, $right) = ($1, $2);
-	$re = quotemeta($left) . $re . quotemeta($right);
+	$re =~ s!\*!\[^/\]*!g;
+#	$re =~ s!\?!\[^/\]!g;
+	$re = quotemeta($left) . "($re)" . quotemeta($right);
 	if (length $left && !($left =~ s!/+$!!g)) {
 		die "Missing trailing '/' on left side of: '$glob' ($left)\n";
 	}
@@ -4933,7 +4962,7 @@ sub new {
 	}
 	my $left_re = qr/^\/\Q$left\E(\/|$)/;
 	bless { left => $left, right => $right, left_regex => $left_re,
-	        regex => qr/$re/, glob => $glob }, $class;
+	        regex => qr/$re/, glob => $glob, depth => $depth }, $class;
 }
 
 sub full_path {
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index a6f88bd..bb9df56 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -52,7 +52,8 @@ test_expect_success 'test refspec globbing' '
 	test "`git rev-parse refs/remotes/tags/end~1`" = \
 		"`git rev-parse refs/remotes/branches/start`" &&
 	test "`git rev-parse refs/remotes/branches/start~2`" = \
-		"`git rev-parse refs/remotes/trunk`"
+		"`git rev-parse refs/remotes/trunk`" &&
+	test_must_fail git rev-parse refs/remotes/tags/end@3
 	'
 
 echo try to try > expect.two
@@ -83,8 +84,8 @@ test_expect_success 'test left-hand-side only globbing' '
 	cmp expect.two output.two
 	'
 
-echo "Only one '*' wildcard expansion is supported (got 2): 'branches/*/*'" \
-     > expect.three
+echo "Only one set of wildcard directories" \
+     "(e.g. '*' or '*/*/*') is supported: 'branches/*/t/*'" > expect.three
 echo "" >> expect.three
 
 test_expect_success 'test disallow multi-globs' '
@@ -92,7 +93,7 @@ test_expect_success 'test disallow multi-globs' '
 	git config --add svn-remote.three.fetch \
 	                 trunk:refs/remotes/three/trunk &&
 	git config --add svn-remote.three.branches \
-	                 "branches/*/*:refs/remotes/three/branches/*" &&
+	                 "branches/*/t/*:refs/remotes/three/branches/*" &&
 	git config --add svn-remote.three.tags \
 	                 "tags/*/*:refs/remotes/three/tags/*" &&
 	cd tmp &&
diff --git a/t/t9108-git-svn-multi-glob.sh b/t/t9108-git-svn-multi-glob.sh
new file mode 100755
index 0000000..9fb51d6
--- /dev/null
+++ b/t/t9108-git-svn-multi-glob.sh
@@ -0,0 +1,157 @@
+#!/bin/sh
+# Copyright (c) 2007 Eric Wong
+test_description='git-svn globbing refspecs'
+. ./lib-git-svn.sh
+
+cat > expect.end <<EOF
+the end
+hi
+start a new branch
+initial
+EOF
+
+test_expect_success 'test refspec globbing' '
+	mkdir -p trunk/src/a trunk/src/b trunk/doc &&
+	echo "hello world" > trunk/src/a/readme &&
+	echo "goodbye world" > trunk/src/b/readme &&
+	svn import -m "initial" trunk "$svnrepo"/trunk &&
+	svn co "$svnrepo" tmp &&
+	cd tmp &&
+		mkdir branches branches/v1 tags &&
+		svn add branches tags &&
+		svn cp trunk branches/v1/start &&
+		svn commit -m "start a new branch" &&
+		svn up &&
+		echo "hi" >> branches/v1/start/src/b/readme &&
+		poke branches/v1/start/src/b/readme &&
+		echo "hey" >> branches/v1/start/src/a/readme &&
+		poke branches/v1/start/src/a/readme &&
+		svn commit -m "hi" &&
+		svn up &&
+		svn cp branches/v1/start tags/end &&
+		echo "bye" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		echo "aye" >> tags/end/src/a/readme &&
+		poke tags/end/src/a/readme &&
+		svn commit -m "the end" &&
+		echo "byebye" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "nothing to see here"
+		cd .. &&
+	git config --add svn-remote.svn.url "$svnrepo" &&
+	git config --add svn-remote.svn.fetch \
+	                 "trunk/src/a:refs/remotes/trunk" &&
+	git config --add svn-remote.svn.branches \
+	                 "branches/*/*/src/a:refs/remotes/branches/*/*" &&
+	git config --add svn-remote.svn.tags\
+	                 "tags/*/src/a:refs/remotes/tags/*" &&
+	git-svn multi-fetch &&
+	git log --pretty=oneline refs/remotes/tags/end | \
+	    sed -e "s/^.\{41\}//" > output.end &&
+	cmp expect.end output.end &&
+	test "`git rev-parse refs/remotes/tags/end~1`" = \
+		"`git rev-parse refs/remotes/branches/v1/start`" &&
+	test "`git rev-parse refs/remotes/branches/v1/start~2`" = \
+		"`git rev-parse refs/remotes/trunk`" &&
+	test_must_fail git rev-parse refs/remotes/tags/end@3
+	'
+
+echo try to try > expect.two
+echo nothing to see here >> expect.two
+cat expect.end >> expect.two
+
+test_expect_success 'test left-hand-side only globbing' '
+	git config --add svn-remote.two.url "$svnrepo" &&
+	git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
+	git config --add svn-remote.two.branches \
+	                 "branches/*/*:refs/remotes/two/branches/*/*" &&
+	git config --add svn-remote.two.tags \
+	                 "tags/*:refs/remotes/two/tags/*" &&
+	cd tmp &&
+		echo "try try" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "try to try"
+		cd .. &&
+	git-svn fetch two &&
+	test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 &&
+	test `git rev-list refs/remotes/two/branches/v1/start | wc -l` -eq 3 &&
+	test `git rev-parse refs/remotes/two/branches/v1/start~2` = \
+	     `git rev-parse refs/remotes/two/trunk` &&
+	test `git rev-parse refs/remotes/two/tags/end~3` = \
+	     `git rev-parse refs/remotes/two/branches/v1/start` &&
+	git log --pretty=oneline refs/remotes/two/tags/end | \
+	    sed -e "s/^.\{41\}//" > output.two &&
+	cmp expect.two output.two
+	'
+cat > expect.four <<EOF
+adios
+adding more
+Changed 2 in v2/start
+Another versioned branch
+initial
+EOF
+
+test_expect_success 'test another branch' '
+	(
+		cd tmp &&
+		mkdir branches/v2 &&
+		svn add branches/v2 &&
+		svn cp trunk branches/v2/start &&
+		svn commit -m "Another versioned branch" &&
+		svn up &&
+		echo "hello" >> branches/v2/start/src/b/readme &&
+		poke branches/v2/start/src/b/readme &&
+		echo "howdy" >> branches/v2/start/src/a/readme &&
+		poke branches/v2/start/src/a/readme &&
+		svn commit -m "Changed 2 in v2/start" &&
+		svn up &&
+		svn cp branches/v2/start tags/next &&
+		echo "bye" >> tags/next/src/b/readme &&
+		poke tags/next/src/b/readme &&
+		echo "aye" >> tags/next/src/a/readme &&
+		poke tags/next/src/a/readme &&
+		svn commit -m "adding more" &&
+		echo "byebye" >> tags/next/src/b/readme &&
+		poke tags/next/src/b/readme &&
+		svn commit -m "adios"
+	) &&
+	git config --add svn-remote.four.url "$svnrepo" &&
+	git config --add svn-remote.four.fetch trunk:refs/remotes/four/trunk &&
+	git config --add svn-remote.four.branches \
+	                 "branches/*/*:refs/remotes/four/branches/*/*" &&
+	git config --add svn-remote.four.tags \
+	                 "tags/*:refs/remotes/four/tags/*" &&
+	git-svn fetch four &&
+	test `git rev-list refs/remotes/four/tags/next | wc -l` -eq 5 &&
+	test `git rev-list refs/remotes/four/branches/v2/start | wc -l` -eq 3 &&
+	test `git rev-parse refs/remotes/four/branches/v2/start~2` = \
+	     `git rev-parse refs/remotes/four/trunk` &&
+	test `git rev-parse refs/remotes/four/tags/next~2` = \
+	     `git rev-parse refs/remotes/four/branches/v2/start` &&
+	git log --pretty=oneline refs/remotes/four/tags/next | \
+	    sed -e "s/^.\{41\}//" > output.four &&
+	cmp expect.four output.four
+	'
+
+echo "Only one set of wildcard directories" \
+     "(e.g. '*' or '*/*/*') is supported: 'branches/*/t/*'" > expect.three
+echo "" >> expect.three
+
+test_expect_success 'test disallow multiple globs' '
+	git config --add svn-remote.three.url "$svnrepo" &&
+	git config --add svn-remote.three.fetch \
+	                 trunk:refs/remotes/three/trunk &&
+	git config --add svn-remote.three.branches \
+	                 "branches/*/t/*:refs/remotes/three/branches/*/*" &&
+	git config --add svn-remote.three.tags \
+	                 "tags/*:refs/remotes/three/tags/*" &&
+	cd tmp &&
+		echo "try try" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "try to try"
+		cd .. &&
+	test_must_fail git-svn fetch three 2> stderr.three &&
+	cmp expect.three stderr.three
+	'
+
+test_done
diff --git a/t/t9125-git-svn-multi-glob-branch-names.sh b/t/t9125-git-svn-multi-glob-branch-names.sh
new file mode 100755
index 0000000..6b62b52
--- /dev/null
+++ b/t/t9125-git-svn-multi-glob-branch-names.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (c) 2008 Marcus Griep
+
+test_description='git-svn multi-glob branch names'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup svnrepo' '
+	mkdir project project/trunk project/branches \
+			project/branches/v14.1 project/tags &&
+	echo foo > project/trunk/foo &&
+	svn import -m "$test_description" project "$svnrepo/project" &&
+	rm -rf project &&
+	svn cp -m "fun" "$svnrepo/project/trunk" \
+	                "$svnrepo/project/branches/v14.1/beta" &&
+	svn cp -m "more fun!" "$svnrepo/project/branches/v14.1/beta" \
+	                      "$svnrepo/project/branches/v14.1/gold"
+	'
+
+test_expect_success 'test clone with multi-glob in branch names' '
+	git svn clone -T trunk -b branches/*/* -t tags \
+	              "$svnrepo/project" project &&
+	cd project &&
+		git rev-parse "refs/remotes/v14.1/beta" &&
+		git rev-parse "refs/remotes/v14.1/gold" &&
+	cd ..
+	'
+
+test_expect_success 'test dcommit to multi-globbed branch' "
+	cd project &&
+	git reset --hard 'refs/remotes/v14.1/gold' &&
+	echo hello >> foo &&
+	git commit -m 'hello' -- foo &&
+	git svn dcommit &&
+	cd ..
+	"
+
+test_done
-- 
1.6.0.rc2.4.g0643f

^ permalink raw reply related

* Re: GIT-VERSION-GEN gives "-dirty" when file metadata changed
From: Christian Jaeger @ 2008-08-08  8:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Gerrit Pape
In-Reply-To: <7vd4kkijjd.fsf@gitster.siamese.dyndns.org>

Junio C Hamano wrote:
> Christian Jaeger <christian@jaeger.mine.nu> writes:
>
>   
>> Today I've created custom Debian packages from Git for the first time (yes I know there are Debian packages already, I'm doing it so that I can patch Git and still have the convenience of a package system),
>>     
>
> I personally think that _you_ are responsible for doing the refresh
> yourself after becoming root, if you checkout as yourself and then build
> as root (or use fakeroot to build as if it is built as root).
>
> By the way "man fakeroot" says...
>
>        -u, --unknown-is-real
>               Use the real ownership of files previously unknown  to  fakeroot
>               instead of pretending they are owned by root:root.
>
>
> which sounds like a sensible thing to do (I would even imagine that would
> be a sensible default for fakeroot in general), and I would imagine that
> would help.
>   

That's true, running "dpkg-buildpackage -uc -us -b -r'fakeroot -u'" 
makes the dirty bit go away.

Although my guess is that most users who haven't read this thread will 
run into the same issue until they understand the reason after some half 
or full hour of debugging or so.

Also I don't see why I should keep in mind to run the refresh 
explicitely if any changes happened (are there any users who are using 
Git to report metadata changes to them (occasionally) which aren't 
changes that would be stored in Git when running commit?).

> Not that an extra update-index --refresh would be a huge performance hit,
> but I hesitate to take a patch that adds something that should
> conceptually be unnecessary.
>   

Isn't conceptually of interest whether the *contents* of the files have 
changed (or a metadata piece that matters to Git)? As mentioned, even 
just moving the sources to another partition using "mv" after checkout 
but before running "make" will give a binary that is "dirty", and the 
user might be confused and led into wrong conclusions or needless 
investigations.

I realize that also some git porcellain does not fall back to checking 
the contents, for example the current gitk will report the working dir 
as having "local uncommitted changes" (which in fact did confuse me when 
it happened to me, IIRC because of "mv"-ing a checkout, and left a 
feeling of slight brokenness). Still at the more relevant places like 
"git commit" there will of course be the content check.

I personally think it would be cleaner to always only report changes if 
really changes which can be stored in Git have happened. Not only in 
GIT-VERSION-GEN but also in gitk and maybe some other places. Isn't the 
metadata checking only used as a performance optimization? It would be 
sensible to report changes if metadata has changed that is actually 
being stored in Git, i.e. the exec bit, of course (and then no content 
check would be necessary).

Christian.

^ permalink raw reply

* [PATCH 1/3] Fix multi-glob assertion in git-svn
From: Eric Wong @ 2008-08-08  8:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Marcus Griep
In-Reply-To: <20080808084025.GA8718@untitled>

From: Marcus Griep <marcus@griep.us>
Date: Thu, 7 Aug 2008 11:34:01 -0400
Subject: [PATCH 1/3] Fix multi-glob assertion in git-svn

Fixes bad regex match check for multiple globs (would always return
one glob regardless of actual number).

[ew: fixed a bashism in the test and some minor line-wrapping]

Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
---

 Oops, resent as I forgot to change the From: header

 git-svn.perl            |    5 +++--
 t/t9108-git-svn-glob.sh |   21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 06a82c8..503a7c9 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4915,14 +4915,15 @@ sub new {
 	my ($class, $glob) = @_;
 	my $re = $glob;
 	$re =~ s!/+$!!g; # no need for trailing slashes
-	my $nr = ($re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g);
-	my ($left, $right) = ($1, $2);
+	my $nr = $re =~ tr/*/*/;
 	if ($nr > 1) {
 		die "Only one '*' wildcard expansion ",
 		    "is supported (got $nr): '$glob'\n";
 	} elsif ($nr == 0) {
 		die "One '*' is needed for glob: '$glob'\n";
 	}
+	$re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g;
+	my ($left, $right) = ($1, $2);
 	$re = quotemeta($left) . $re . quotemeta($right);
 	if (length $left && !($left =~ s!/+$!!g)) {
 		die "Missing trailing '/' on left side of: '$glob' ($left)\n";
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index f6f71d0..a6f88bd 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -83,4 +83,25 @@ test_expect_success 'test left-hand-side only globbing' '
 	cmp expect.two output.two
 	'
 
+echo "Only one '*' wildcard expansion is supported (got 2): 'branches/*/*'" \
+     > expect.three
+echo "" >> expect.three
+
+test_expect_success 'test disallow multi-globs' '
+	git config --add svn-remote.three.url "$svnrepo" &&
+	git config --add svn-remote.three.fetch \
+	                 trunk:refs/remotes/three/trunk &&
+	git config --add svn-remote.three.branches \
+	                 "branches/*/*:refs/remotes/three/branches/*" &&
+	git config --add svn-remote.three.tags \
+	                 "tags/*/*:refs/remotes/three/tags/*" &&
+	cd tmp &&
+		echo "try try" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "try to try"
+		cd .. &&
+	test_must_fail git-svn fetch three 2> stderr.three &&
+	cmp expect.three stderr.three
+	'
+
 test_done
-- 
1.6.0.rc2.4.g0643f

^ permalink raw reply related

* [PATCH 2/3] git-svn: Allow deep branch names by supporting multi-globs
From: Eric Wong @ 2008-08-08  8:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Marcus Griep
In-Reply-To: <20080808084025.GA8718@untitled>

From: Marcus Griep <marcus@griep.us>
Date: Thu, 7 Aug 2008 11:34:02 -0400
Subject: [PATCH 2/3] git-svn: Allow deep branch names by supporting multi-globs

Some repositories use a deep branching strategy, such as:
branches/1.0/1.0.rc1
branches/1.0/1.0.rc2
branches/1.0/1.0.rtm
branches/1.0/1.0.gold

Only allowing a single glob stiffles this.

This change allows for a single glob 'set' to accept this deep
branching strategy.

The ref glob depth must match the branch glob depth.  When using
the -b or -t options for init or clone, this is automatically
done.

For example, using the above branches:
  svn-remote.svn.branches = branches/*/*:refs/remote/*/*
gives the following branch names:
  1.0/1.0.rc1
  1.0/1.0.rc2
  1.0/1.0.rtm
  1.0/1.0.gold

[ew:
  * removed unrelated line-wrapping changes
  * fixed line-wrapping in a few more places
  * removed trailing whitespace
  * fixed bashism in test
  * removed unnecessary httpd startup in test
  * changed copyright on tests to 2008 Marcus Griep
  * added executable permissions to new tests
]

Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
---
 Oops, resent as I forgot to change the From: header

 git-svn.perl                               |   61 ++++++++---
 t/t9108-git-svn-glob.sh                    |    9 +-
 t/t9108-git-svn-multi-glob.sh              |  157 ++++++++++++++++++++++++++++
 t/t9125-git-svn-multi-glob-branch-names.sh |   37 +++++++
 4 files changed, 244 insertions(+), 20 deletions(-)
 create mode 100755 t/t9108-git-svn-multi-glob.sh
 create mode 100755 t/t9125-git-svn-multi-glob-branch-names.sh

diff --git a/git-svn.perl b/git-svn.perl
index 503a7c9..47ad378 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -987,8 +987,10 @@ sub complete_url_ls_init {
 	if (length $pfx && $pfx !~ m#/$#) {
 		die "--prefix='$pfx' must have a trailing slash '/'\n";
 	}
-	command_noisy('config', "svn-remote.$gs->{repo_id}.$n",
-				"$remote_path:refs/remotes/$pfx*");
+	command_noisy('config',
+	              "svn-remote.$gs->{repo_id}.$n",
+	              "$remote_path:refs/remotes/$pfx*" .
+	                ('/*' x (($remote_path =~ tr/*/*/) - 1)) );
 }
 
 sub verify_ref {
@@ -4124,16 +4126,38 @@ sub gs_fetch_loop_common {
 	Git::SVN::gc();
 }
 
+sub get_dir_globbed {
+	my ($self, $left, $depth, $r) = @_;
+
+	my @x = eval { $self->get_dir($left, $r) };
+	return unless scalar @x == 3;
+	my $dirents = $x[0];
+	my @finalents;
+	foreach my $de (keys %$dirents) {
+		next if $dirents->{$de}->{kind} != $SVN::Node::dir;
+		if ($depth > 1) {
+			my @args = ("$left/$de", $depth - 1, $r);
+			foreach my $dir ($self->get_dir_globbed(@args)) {
+				push @finalents, "$de/$dir";
+			}
+		} else {
+			push @finalents, $de;
+		}
+	}
+	@finalents;
+}
+
 sub match_globs {
 	my ($self, $exists, $paths, $globs, $r) = @_;
 
 	sub get_dir_check {
 		my ($self, $exists, $g, $r) = @_;
-		my @x = eval { $self->get_dir($g->{path}->{left}, $r) };
-		return unless scalar @x == 3;
-		my $dirents = $x[0];
-		foreach my $de (keys %$dirents) {
-			next if $dirents->{$de}->{kind} != $SVN::Node::dir;
+
+		my @dirs = $self->get_dir_globbed($g->{path}->{left},
+		                                  $g->{path}->{depth},
+		                                  $r);
+
+		foreach my $de (@dirs) {
 			my $p = $g->{path}->full_path($de);
 			next if $exists->{$p};
 			next if (length $g->{path}->{right} &&
@@ -4915,16 +4939,21 @@ sub new {
 	my ($class, $glob) = @_;
 	my $re = $glob;
 	$re =~ s!/+$!!g; # no need for trailing slashes
-	my $nr = $re =~ tr/*/*/;
-	if ($nr > 1) {
-		die "Only one '*' wildcard expansion ",
-		    "is supported (got $nr): '$glob'\n";
-	} elsif ($nr == 0) {
+	$re =~ m!^([^*]*)(\*(?:/\*)*)([^*]*)$!;
+	my $temp = $re;
+	my ($left, $right) = ($1, $3);
+	$re = $2;
+	my $depth = $re =~ tr/*/*/;
+	if ($depth != $temp =~ tr/*/*/) {
+		die "Only one set of wildcard directories " .
+			"(e.g. '*' or '*/*/*') is supported: '$glob'\n";
+	}
+	if ($depth == 0) {
 		die "One '*' is needed for glob: '$glob'\n";
 	}
-	$re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g;
-	my ($left, $right) = ($1, $2);
-	$re = quotemeta($left) . $re . quotemeta($right);
+	$re =~ s!\*!\[^/\]*!g;
+#	$re =~ s!\?!\[^/\]!g;
+	$re = quotemeta($left) . "($re)" . quotemeta($right);
 	if (length $left && !($left =~ s!/+$!!g)) {
 		die "Missing trailing '/' on left side of: '$glob' ($left)\n";
 	}
@@ -4933,7 +4962,7 @@ sub new {
 	}
 	my $left_re = qr/^\/\Q$left\E(\/|$)/;
 	bless { left => $left, right => $right, left_regex => $left_re,
-	        regex => qr/$re/, glob => $glob }, $class;
+	        regex => qr/$re/, glob => $glob, depth => $depth }, $class;
 }
 
 sub full_path {
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index a6f88bd..bb9df56 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -52,7 +52,8 @@ test_expect_success 'test refspec globbing' '
 	test "`git rev-parse refs/remotes/tags/end~1`" = \
 		"`git rev-parse refs/remotes/branches/start`" &&
 	test "`git rev-parse refs/remotes/branches/start~2`" = \
-		"`git rev-parse refs/remotes/trunk`"
+		"`git rev-parse refs/remotes/trunk`" &&
+	test_must_fail git rev-parse refs/remotes/tags/end@3
 	'
 
 echo try to try > expect.two
@@ -83,8 +84,8 @@ test_expect_success 'test left-hand-side only globbing' '
 	cmp expect.two output.two
 	'
 
-echo "Only one '*' wildcard expansion is supported (got 2): 'branches/*/*'" \
-     > expect.three
+echo "Only one set of wildcard directories" \
+     "(e.g. '*' or '*/*/*') is supported: 'branches/*/t/*'" > expect.three
 echo "" >> expect.three
 
 test_expect_success 'test disallow multi-globs' '
@@ -92,7 +93,7 @@ test_expect_success 'test disallow multi-globs' '
 	git config --add svn-remote.three.fetch \
 	                 trunk:refs/remotes/three/trunk &&
 	git config --add svn-remote.three.branches \
-	                 "branches/*/*:refs/remotes/three/branches/*" &&
+	                 "branches/*/t/*:refs/remotes/three/branches/*" &&
 	git config --add svn-remote.three.tags \
 	                 "tags/*/*:refs/remotes/three/tags/*" &&
 	cd tmp &&
diff --git a/t/t9108-git-svn-multi-glob.sh b/t/t9108-git-svn-multi-glob.sh
new file mode 100755
index 0000000..9fb51d6
--- /dev/null
+++ b/t/t9108-git-svn-multi-glob.sh
@@ -0,0 +1,157 @@
+#!/bin/sh
+# Copyright (c) 2007 Eric Wong
+test_description='git-svn globbing refspecs'
+. ./lib-git-svn.sh
+
+cat > expect.end <<EOF
+the end
+hi
+start a new branch
+initial
+EOF
+
+test_expect_success 'test refspec globbing' '
+	mkdir -p trunk/src/a trunk/src/b trunk/doc &&
+	echo "hello world" > trunk/src/a/readme &&
+	echo "goodbye world" > trunk/src/b/readme &&
+	svn import -m "initial" trunk "$svnrepo"/trunk &&
+	svn co "$svnrepo" tmp &&
+	cd tmp &&
+		mkdir branches branches/v1 tags &&
+		svn add branches tags &&
+		svn cp trunk branches/v1/start &&
+		svn commit -m "start a new branch" &&
+		svn up &&
+		echo "hi" >> branches/v1/start/src/b/readme &&
+		poke branches/v1/start/src/b/readme &&
+		echo "hey" >> branches/v1/start/src/a/readme &&
+		poke branches/v1/start/src/a/readme &&
+		svn commit -m "hi" &&
+		svn up &&
+		svn cp branches/v1/start tags/end &&
+		echo "bye" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		echo "aye" >> tags/end/src/a/readme &&
+		poke tags/end/src/a/readme &&
+		svn commit -m "the end" &&
+		echo "byebye" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "nothing to see here"
+		cd .. &&
+	git config --add svn-remote.svn.url "$svnrepo" &&
+	git config --add svn-remote.svn.fetch \
+	                 "trunk/src/a:refs/remotes/trunk" &&
+	git config --add svn-remote.svn.branches \
+	                 "branches/*/*/src/a:refs/remotes/branches/*/*" &&
+	git config --add svn-remote.svn.tags\
+	                 "tags/*/src/a:refs/remotes/tags/*" &&
+	git-svn multi-fetch &&
+	git log --pretty=oneline refs/remotes/tags/end | \
+	    sed -e "s/^.\{41\}//" > output.end &&
+	cmp expect.end output.end &&
+	test "`git rev-parse refs/remotes/tags/end~1`" = \
+		"`git rev-parse refs/remotes/branches/v1/start`" &&
+	test "`git rev-parse refs/remotes/branches/v1/start~2`" = \
+		"`git rev-parse refs/remotes/trunk`" &&
+	test_must_fail git rev-parse refs/remotes/tags/end@3
+	'
+
+echo try to try > expect.two
+echo nothing to see here >> expect.two
+cat expect.end >> expect.two
+
+test_expect_success 'test left-hand-side only globbing' '
+	git config --add svn-remote.two.url "$svnrepo" &&
+	git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
+	git config --add svn-remote.two.branches \
+	                 "branches/*/*:refs/remotes/two/branches/*/*" &&
+	git config --add svn-remote.two.tags \
+	                 "tags/*:refs/remotes/two/tags/*" &&
+	cd tmp &&
+		echo "try try" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "try to try"
+		cd .. &&
+	git-svn fetch two &&
+	test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 &&
+	test `git rev-list refs/remotes/two/branches/v1/start | wc -l` -eq 3 &&
+	test `git rev-parse refs/remotes/two/branches/v1/start~2` = \
+	     `git rev-parse refs/remotes/two/trunk` &&
+	test `git rev-parse refs/remotes/two/tags/end~3` = \
+	     `git rev-parse refs/remotes/two/branches/v1/start` &&
+	git log --pretty=oneline refs/remotes/two/tags/end | \
+	    sed -e "s/^.\{41\}//" > output.two &&
+	cmp expect.two output.two
+	'
+cat > expect.four <<EOF
+adios
+adding more
+Changed 2 in v2/start
+Another versioned branch
+initial
+EOF
+
+test_expect_success 'test another branch' '
+	(
+		cd tmp &&
+		mkdir branches/v2 &&
+		svn add branches/v2 &&
+		svn cp trunk branches/v2/start &&
+		svn commit -m "Another versioned branch" &&
+		svn up &&
+		echo "hello" >> branches/v2/start/src/b/readme &&
+		poke branches/v2/start/src/b/readme &&
+		echo "howdy" >> branches/v2/start/src/a/readme &&
+		poke branches/v2/start/src/a/readme &&
+		svn commit -m "Changed 2 in v2/start" &&
+		svn up &&
+		svn cp branches/v2/start tags/next &&
+		echo "bye" >> tags/next/src/b/readme &&
+		poke tags/next/src/b/readme &&
+		echo "aye" >> tags/next/src/a/readme &&
+		poke tags/next/src/a/readme &&
+		svn commit -m "adding more" &&
+		echo "byebye" >> tags/next/src/b/readme &&
+		poke tags/next/src/b/readme &&
+		svn commit -m "adios"
+	) &&
+	git config --add svn-remote.four.url "$svnrepo" &&
+	git config --add svn-remote.four.fetch trunk:refs/remotes/four/trunk &&
+	git config --add svn-remote.four.branches \
+	                 "branches/*/*:refs/remotes/four/branches/*/*" &&
+	git config --add svn-remote.four.tags \
+	                 "tags/*:refs/remotes/four/tags/*" &&
+	git-svn fetch four &&
+	test `git rev-list refs/remotes/four/tags/next | wc -l` -eq 5 &&
+	test `git rev-list refs/remotes/four/branches/v2/start | wc -l` -eq 3 &&
+	test `git rev-parse refs/remotes/four/branches/v2/start~2` = \
+	     `git rev-parse refs/remotes/four/trunk` &&
+	test `git rev-parse refs/remotes/four/tags/next~2` = \
+	     `git rev-parse refs/remotes/four/branches/v2/start` &&
+	git log --pretty=oneline refs/remotes/four/tags/next | \
+	    sed -e "s/^.\{41\}//" > output.four &&
+	cmp expect.four output.four
+	'
+
+echo "Only one set of wildcard directories" \
+     "(e.g. '*' or '*/*/*') is supported: 'branches/*/t/*'" > expect.three
+echo "" >> expect.three
+
+test_expect_success 'test disallow multiple globs' '
+	git config --add svn-remote.three.url "$svnrepo" &&
+	git config --add svn-remote.three.fetch \
+	                 trunk:refs/remotes/three/trunk &&
+	git config --add svn-remote.three.branches \
+	                 "branches/*/t/*:refs/remotes/three/branches/*/*" &&
+	git config --add svn-remote.three.tags \
+	                 "tags/*:refs/remotes/three/tags/*" &&
+	cd tmp &&
+		echo "try try" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "try to try"
+		cd .. &&
+	test_must_fail git-svn fetch three 2> stderr.three &&
+	cmp expect.three stderr.three
+	'
+
+test_done
diff --git a/t/t9125-git-svn-multi-glob-branch-names.sh b/t/t9125-git-svn-multi-glob-branch-names.sh
new file mode 100755
index 0000000..6b62b52
--- /dev/null
+++ b/t/t9125-git-svn-multi-glob-branch-names.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (c) 2008 Marcus Griep
+
+test_description='git-svn multi-glob branch names'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup svnrepo' '
+	mkdir project project/trunk project/branches \
+			project/branches/v14.1 project/tags &&
+	echo foo > project/trunk/foo &&
+	svn import -m "$test_description" project "$svnrepo/project" &&
+	rm -rf project &&
+	svn cp -m "fun" "$svnrepo/project/trunk" \
+	                "$svnrepo/project/branches/v14.1/beta" &&
+	svn cp -m "more fun!" "$svnrepo/project/branches/v14.1/beta" \
+	                      "$svnrepo/project/branches/v14.1/gold"
+	'
+
+test_expect_success 'test clone with multi-glob in branch names' '
+	git svn clone -T trunk -b branches/*/* -t tags \
+	              "$svnrepo/project" project &&
+	cd project &&
+		git rev-parse "refs/remotes/v14.1/beta" &&
+		git rev-parse "refs/remotes/v14.1/gold" &&
+	cd ..
+	'
+
+test_expect_success 'test dcommit to multi-globbed branch' "
+	cd project &&
+	git reset --hard 'refs/remotes/v14.1/gold' &&
+	echo hello >> foo &&
+	git commit -m 'hello' -- foo &&
+	git svn dcommit &&
+	cd ..
+	"
+
+test_done
-- 
1.6.0.rc2.4.g0643f

^ permalink raw reply related

* [PATCH] tests: use $TEST_DIRECTORY to refer to the t/ directory
From: Junio C Hamano @ 2008-08-08  9:31 UTC (permalink / raw)
  To: René Scharfe; +Cc: Johannes Schindelin, git, gitster
In-Reply-To: <7vprojgbbu.fsf@gitster.siamese.dyndns.org>

I'll push this out as 'test-deeper' branch to repo.or.cz (alt-git.git)
because the test suite has unprintable bytes that are inappropriate for
e-mail transmission.

-- >8 --
Many test scripts assumed that they will start in a 'trash' subdirectory
that is a single level down from the t/ directory, and referred to their
test vector files by asking for files like "../t9999/expect".  This will
break if we move the 'trash' subdirectory elsewhere.

To solve this, we earlier introduced "$TEST_DIRECTORY" so that they can
refer to t/ directory reliably.  This finally makes all the tests use
it to refer to the outside environment.

With this patch, and a one-liner not included here (because it would
contradict with what Dscho really wants to do):

| diff --git a/t/test-lib.sh b/t/test-lib.sh
| index 70ea7e0..60e69e4 100644
| --- a/t/test-lib.sh
| +++ b/t/test-lib.sh
| @@ -485,7 +485,7 @@ fi
|  . ../GIT-BUILD-OPTIONS
|
|  # Test repository
| -test="trash directory"
| +test="trash directory/another level/yet another"
|  rm -fr "$test" || {
|         trap - exit
|         echo >&5 "FATAL: Cannot prepare test area"

all the tests still pass, but we would want extra sets of eyeballs on this
type of change to really make sure.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t0022-crlf-rename.sh                   |    4 ++--
 t/t1000-read-tree-m-3way.sh              |    2 +-
 t/t3900-i18n-commit.sh                   |   18 +++++++++---------
 t/t3901-i18n-patch.sh                    |   28 ++++++++++++++--------------
 t/t4000-diff-format.sh                   |    2 +-
 t/t4001-diff-rename.sh                   |    2 +-
 t/t4002-diff-basic.sh                    |    2 +-
 t/t4003-diff-rename-1.sh                 |    6 +++---
 t/t4004-diff-rename-symlink.sh           |    2 +-
 t/t4005-diff-rename-2.sh                 |    6 +++---
 t/t4007-rename-3.sh                      |    4 ++--
 t/t4008-diff-break-rewrite.sh            |    6 +++---
 t/t4009-diff-rename-4.sh                 |    6 +++---
 t/t4010-diff-pathspec.sh                 |    2 +-
 t/t4011-diff-symlink.sh                  |    2 +-
 t/t4012-diff-binary.sh                   |    2 +-
 t/t4013-diff-various.sh                  |    2 +-
 t/t4015-diff-whitespace.sh               |    2 +-
 t/t4020-diff-external.sh                 |    2 +-
 t/t4022-diff-rewrite.sh                  |    4 ++--
 t/t4023-diff-rename-typechange.sh        |   14 +++++++-------
 t/t4027-diff-submodule.sh                |    2 +-
 t/t4100-apply-stat.sh                    |    4 ++--
 t/t4101-apply-nonl.sh                    |    2 +-
 t/t5100-mailinfo.sh                      |   18 +++++++++---------
 t/t5515-fetch-merge-logic.sh             |    4 ++--
 t/t5540-http-push.sh                     |    2 +-
 t/t6002-rev-list-bisect.sh               |    2 +-
 t/t6003-rev-list-topo-order.sh           |    2 +-
 t/t6023-merge-file.sh                    |    2 +-
 t/t6027-merge-binary.sh                  |    2 +-
 t/t6101-rev-parse-parents.sh             |    2 +-
 t/t6200-fmt-merge-msg.sh                 |    4 ++--
 t/t7001-mv.sh                            |    4 ++--
 t/t7004-tag.sh                           |    2 +-
 t/t7101-reset.sh                         |   10 +++++-----
 t/t7500-commit.sh                        |   16 ++++++++--------
 t/t8001-annotate.sh                      |    2 +-
 t/t8002-blame.sh                         |    2 +-
 t/t9110-git-svn-use-svm-props.sh         |    2 +-
 t/t9111-git-svn-use-svnsync-props.sh     |    2 +-
 t/t9115-git-svn-dcommit-funky-renames.sh |    2 +-
 t/t9121-git-svn-fetch-renamed-dir.sh     |    2 +-
 t/t9200-git-cvsexportcommit.sh           |   14 +++++++-------
 t/t9300-fast-import.sh                   |    2 +-
 t/t9301-fast-export.sh                   |    2 +-
 t/t9500-gitweb-standalone-no-errors.sh   |   16 ++++++++--------
 t/t9700-perl-git.sh                      |    2 +-
 t/t9700/test.pl                          |    3 ---
 t/test-lib.sh                            |    2 +-
 50 files changed, 123 insertions(+), 126 deletions(-)

^ permalink raw reply

* git diff/log --check exitcode and PAGER environment variable
From: "Peter Valdemar Mørch (Lists)" @ 2008-08-08  9:39 UTC (permalink / raw)
  To: git

Using my default PAGER=less, git log --check exits with exit code 0, 
contrary to documentation.

There is this old thread:
"[PATCH 1/5] "diff --check" should affect exit status"
http://thread.gmane.org/gmane.comp.version-control.git/68145/focus=68148
which seemed not to reach a conclusion.

For git log, I still have not been able to make it exit with anything 
other than 0 - contrary to documentation.

May I propose a change to either documentation or behavior of "git diff 
--check". The current one has:

--check::
	Warn if changes introduce trailing whitespace
	or an indent that uses a space before a tab. Exits with
	non-zero status if problems are found. Not compatible with
	--exit-code.

This, clearly, is not correct:

$ PAGER=less git diff --check
(my default PAGER)
or
$ unset PAGER ; git diff --check
always exits with exit code 0. But

$ git --no-pager diff --check
or
$ PAGER=cat git diff --check
or
$ PAGER= git diff --check
exits with exit code 2 on error
(curiously PAGER= and unset PAGER give different results)

But the --exit-code overrides any of that:

$ git --no-pager diff --check --exit-code
exits with exit code 3 on error (with or without the --no-pager).

I'm not sure about a good rephrasing. How about:
'... "git diff" exits with non-zero status if problems are found and run 
with --exit-code.'

While this documentation string is found in diff-options.txt and 
included in:

git-diff-files.txt
git-diff-index.txt
git-diff-tree.txt
git-diff.txt
git-format-patch.txt
git-log.txt

At least for the git-log cases, the behavior is not the same as for 
git-diff:

$ PAGER=cat git --no-pager log HEAD~20..HEAD --check --exit-code
$ echo $?
0
Though there are several check failures (red squares in output), it 
exits with 0, even when using all the tricks that work with "git diff".

Clearly here, the documentation is "even more wrong". Hence the explicit 
mention of "git diff" in the help string for the --check option.

What do you think?

Peter
-- 
Peter Valdemar Mørch
http://www.morch.com

^ permalink raw reply

* Re: [PATCH 1/3] Fix multi-glob assertion in git-svn
From: Junio C Hamano @ 2008-08-08  9:41 UTC (permalink / raw)
  To: Eric Wong; +Cc: git, Marcus Griep
In-Reply-To: <1218184918-9135-1-git-send-email-normalperson@yhbt.net>

Eric Wong <normalperson@yhbt.net> writes:

> From: Marcus Griep <marcus@griep.us>
>
> Fixes bad regex match check for multiple globs (would always return
> one glob regardless of actual number).
>
> [ew: fixed a bashism in the test and some minor line-wrapping]

Thanks both.

> +test_expect_success 'test disallow multi-globs' '
> ...
> +	cd tmp &&
> +		echo "try try" >> tags/end/src/b/readme &&
> +		poke tags/end/src/b/readme &&
> +		svn commit -m "try to try"
> +		cd .. &&

Do you want to ignore exit code from 'svn commit -m' here?

In any case, I'd want to see "temporarily work in subdirectory" done in a
subshell when applicable, so that we won't have to worry about where we
are when we later add more tests, like this:

	(
        	cd tmp &&
                echo "try try" >>tags/end/src/b/readme &&
                poke tags/end/src/b/readme &&
                svn commit -m "try to try" &&
	) &&

> +	test_must_fail git-svn fetch three 2> stderr.three &&
> +	cmp expect.three stderr.three

s/cmp/test_cmp/;

^ permalink raw reply

* Re: git diff/log --check exitcode and PAGER environment variable
From: Junio C Hamano @ 2008-08-08  9:44 UTC (permalink / raw)
  To: Peter Valdemar Mørch (Lists); +Cc: git
In-Reply-To: <489C145B.5090400@sneakemail.com>

"Peter Valdemar Mørch (Lists)"  <4ux6as402@sneakemail.com> writes:

> There is this old thread:
> "[PATCH 1/5] "diff --check" should affect exit status"
> http://thread.gmane.org/gmane.comp.version-control.git/68145/focus=68148
> which seemed not to reach a conclusion.

Conclusion was (1) if you really care about the exit code, do not use
pager; (2) after 1.6.0 we will swap the child/parent between git and pager
to expose exit code from us, but not before.

Or am I mistaken?

^ 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