git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remote-testgit: properly check for errors
@ 2012-10-22 20:56 Felipe Contreras
  2012-10-22 21:01 ` Sverre Rabbelier
  0 siblings, 1 reply; 3+ messages in thread
From: Felipe Contreras @ 2012-10-22 20:56 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Sverre Rabbelier, Shawn O. Pearce,
	Felipe Contreras

'feature done' was missing, which allowed fast-import exit properly, and
transport-helper to continue checking for refs and what not when in fact
the remote-helper died.

Let's enable that, and make sure the error paths are triggered.

Now transport-helper correctly detects the errors from fast-import,
unfortunately, not from fast-export because it might finish before
detecting a SIGPIPE. This means transport-helper will quit silently and
the user will not see any errors, which is bad. Hopefully the helper
will print the error before dying anyway, so not all is lost.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 git-remote-testgit.py     |  8 ++++++++
 t/t5800-remote-helpers.sh | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/git-remote-testgit.py b/git-remote-testgit.py
index 5f3ebd2..b8707e6 100644
--- a/git-remote-testgit.py
+++ b/git-remote-testgit.py
@@ -159,6 +159,11 @@ def do_import(repo, args):
         ref = line[7:].strip()
         refs.append(ref)
 
+    print "feature done"
+
+    if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
+        die('Told to fail')
+
     repo = update_local_repo(repo)
     repo.exporter.export_repo(repo.gitdir, refs)
 
@@ -172,6 +177,9 @@ def do_export(repo, args):
     if not repo.gitdir:
         die("Need gitdir to export")
 
+    if os.environ.get("GIT_REMOTE_TESTGIT_FAILURE"):
+        die('Told to fail')
+
     update_local_repo(repo)
     changed = repo.importer.do_import(repo.gitdir)
 
diff --git a/t/t5800-remote-helpers.sh b/t/t5800-remote-helpers.sh
index e7dc668..446cc8e 100755
--- a/t/t5800-remote-helpers.sh
+++ b/t/t5800-remote-helpers.sh
@@ -145,4 +145,25 @@ test_expect_failure 'push new branch with old:new refspec' '
 	compare_refs clone HEAD server refs/heads/new-refspec
 '
 
+test_expect_success 'proper failure checks for fetching' '
+	(GIT_REMOTE_TESTGIT_FAILURE=1 &&
+	export GIT_REMOTE_TESTGIT_FAILURE &&
+	cd localclone &&
+	test_must_fail git fetch 2>&1 | \
+		grep "Error while running fast-import"
+	)
+'
+
+# We sleep to give fast-export a chance to catch the SIGPIPE
+test_expect_failure 'proper failure checks for pushing' '
+	(GIT_REMOTE_TESTGIT_FAILURE=1 &&
+	export GIT_REMOTE_TESTGIT_FAILURE &&
+	GIT_REMOTE_TESTGIT_SLEEPY=1 &&
+	export GIT_REMOTE_TESTGIT_SLEEPY &&
+	cd localclone &&
+	test_must_fail git push --all 2>&1 | \
+		grep "Error while running fast-export"
+	)
+'
+
 test_done
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] remote-testgit: properly check for errors
  2012-10-22 20:56 [PATCH] remote-testgit: properly check for errors Felipe Contreras
@ 2012-10-22 21:01 ` Sverre Rabbelier
  2012-10-23  0:57   ` Felipe Contreras
  0 siblings, 1 reply; 3+ messages in thread
From: Sverre Rabbelier @ 2012-10-22 21:01 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git, Junio C Hamano, Jeff King, Shawn O. Pearce

On Mon, Oct 22, 2012 at 1:56 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> diff --git a/git-remote-testgit.py b/git-remote-testgit.py
> index 5f3ebd2..b8707e6 100644
> --- a/git-remote-testgit.py
> +++ b/git-remote-testgit.py
> @@ -159,6 +159,11 @@ def do_import(repo, args):
>          ref = line[7:].strip()
>          refs.append(ref)
>
> +    print "feature done"

There's not enough context for me to see in which part of the code
this is, import or export? If you advertise 'feature done', shouldn't
you also print 'done' when you finish writing the fast-export stream?
If that's already the case feel free to ignore me :)

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] remote-testgit: properly check for errors
  2012-10-22 21:01 ` Sverre Rabbelier
@ 2012-10-23  0:57   ` Felipe Contreras
  0 siblings, 0 replies; 3+ messages in thread
From: Felipe Contreras @ 2012-10-23  0:57 UTC (permalink / raw)
  To: Sverre Rabbelier; +Cc: git, Junio C Hamano, Jeff King, Shawn O. Pearce

On Mon, Oct 22, 2012 at 11:01 PM, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> On Mon, Oct 22, 2012 at 1:56 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> diff --git a/git-remote-testgit.py b/git-remote-testgit.py
>> index 5f3ebd2..b8707e6 100644
>> --- a/git-remote-testgit.py
>> +++ b/git-remote-testgit.py
>> @@ -159,6 +159,11 @@ def do_import(repo, args):
>>          ref = line[7:].strip()
>>          refs.append(ref)
>>
>> +    print "feature done"
>
> There's not enough context for me to see in which part of the code
> this is, import or export?

Isn't this enough?
>> @@ -159,6 +159,11 @@ def do_import(repo, args):

It's import.

> If you advertise 'feature done', shouldn't
> you also print 'done' when you finish writing the fast-export stream?
> If that's already the case feel free to ignore me :)

It's already there:
http://git.kernel.org/?p=git/git.git;a=blob;f=git-remote-testgit.py#l165

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-23  0:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-22 20:56 [PATCH] remote-testgit: properly check for errors Felipe Contreras
2012-10-22 21:01 ` Sverre Rabbelier
2012-10-23  0:57   ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).