Re: [PATCH] Add new git-remote-hd helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 18, 2012 at 5:44 AM, Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
> On Thu, Oct 18, 2012 at 12:59 AM, Jeff King <peff@xxxxxxxx> wrote:
>> On Wed, Oct 17, 2012 at 02:58:41PM +0200, Felipe Contreras wrote:
>>
>>> I've looked at many hg<->git tools and none satisfy me. Too complicated, or too
>>> slow, or to difficult to setup, etc.
>>
>> I run into this every few months, evaluate all of the options, and come
>> to the same conclusion. So I am excited at the prospect of something
>> simple that just works out of the box.
>>
>> Unfortunately, when I tried it, it did not work for me. :(

Ok, I've fixed all those issues:
http://github.com/felipec/git/blob/fc-remote-hg/contrib/remote-hg/git-remote-hg

Right now I've just added an error when using remote repositories. But
it seems there's no way around it; if we want to have support for
remote repos, we need to make a local clone.

> But at the moment it should fail at this point, I wonder why you get
> the errors below.
>
>>   error: refs/tags/VIMPERATOR_2_2_b1 does not point to a valid object!
>>   error: refs/tags/muttator-0.5 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b1 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b2 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b3 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b4 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b4.1 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b4.2 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b4.3 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b5 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b5.1 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b6 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b7 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0b7.1 does not point to a valid object!
>>   error: refs/tags/pentadactyl-1.0rc1 does not point to a valid object!
>>   error: refs/tags/vimperator-0.4.1 does not point to a valid object!
>>   error: refs/tags/vimperator-0.5 does not point to a valid object!
>>   error: refs/tags/vimperator-0.5-branch-HEAD-merge-1 does not point to a valid object!
>>   error: refs/tags/vimperator-0.5.1 does not point to a valid object!
>>   error: refs/tags/vimperator-0.5.2 does not point to a valid object!
>>   error: refs/tags/vimperator-0.5.3 does not point to a valid object!
>>   error: refs/tags/vimperator-1.0 does not point to a valid object!
>>   error: refs/tags/vimperator-1.1 does not point to a valid object!
>>   error: refs/tags/vimperator-1.2 does not point to a valid object!
>>   error: refs/tags/vimperator-2.0 does not point to a valid object!
>>   error: refs/tags/vimperator-2.0a1 does not point to a valid object!
>>   error: refs/tags/vimperator-2.1 does not point to a valid object!
>>   error: refs/tags/vimperator-2.2 does not point to a valid object!
>>   error: refs/tags/vimperator-2.2b1 does not point to a valid object!
>>   error: refs/tags/xulmus-0.1 does not point to a valid object!
>
> This is weird.

I think I know why the errors above show up; even though the helper
dies, transport-helper doesn't check the status until the very end.

Something like this should do the trick:

diff --git a/run-command.c b/run-command.c
index 1101ef7..0a859ca 100644
--- a/run-command.c
+++ b/run-command.c
@@ -559,6 +559,21 @@ int run_command(struct child_process *cmd)
 	return finish_command(cmd);
 }

+int check_command(struct child_process *cmd)
+{
+	int status;
+	pid_t pid;
+
+	pid = waitpid(cmd->pid, &status, WNOHANG);
+
+	if (pid != cmd->pid)
+		return -1;
+	if (WIFSIGNALED(status))
+		return WTERMSIG(status);
+	if (WIFEXITED(status))
+		return WEXITSTATUS(status);
+}
+
 static void prepare_run_command_v_opt(struct child_process *cmd,
 				      const char **argv,
 				      int opt)
diff --git a/run-command.h b/run-command.h
index 44f7d2b..9019e38 100644
--- a/run-command.h
+++ b/run-command.h
@@ -45,6 +45,7 @@ struct child_process {
 int start_command(struct child_process *);
 int finish_command(struct child_process *);
 int run_command(struct child_process *);
+int check_command(struct child_process *cmd);

 extern int run_hook(const char *index_file, const char *name, ...);

diff --git a/transport-helper.c b/transport-helper.c
index cfe0988..bc1349d 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -441,6 +441,10 @@ static int fetch_with_import(struct transport *transport,

 	if (finish_command(&fastimport))
 		die("Error while running fast-import");
+
+	if (check_command(data->helper))
+		die("Error while running helper");
+
 	free(fastimport.argv);
 	fastimport.argv = NULL;

@@ -784,6 +788,10 @@ static int push_refs_with_export(struct transport
*transport,

 	if (finish_command(&exporter))
 		die("Error while running fast-export");
+
+	if (check_command(data->helper))
+		die("Error while running helper");
+
 	push_update_refs_status(data, remote_refs);
 	return 0;
 }

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]