git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Oct 18, 2012, 05:18 UTC
Message-ID
<CAMP44s1b=dNaCbm1WkFBv6368Y+jDYdkPuscEFdiUnVJBStfVg@mail.gmail.com>
In-Reply-To
<CAMP44s0+Fhtj2rMQ1Av-49Koa=DumX8JZs5angOFSRzqtDc+9Q@mail.gmail.com>

On Thu, Oct 18, 2012 at 5:44 AM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 11 quoted lines
> On Thu, Oct 18, 2012 at 12:59 AM, Jeff King <peff@peff.net> 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.

Show 36 quoted lines
> 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
Previous: Felipe ContrerasNext: Sverre Rabbelier
Message 19 of 27 in “Add new git-remote-hd helper”
  1. Add new git-remote-hd helperFelipe Contreras, Oct 17, 2012
  2. Johannes SchindelinOct 17, 2012
  3. Felipe ContrerasOct 17, 2012
  4. Johannes SchindelinOct 17, 2012
  5. Felipe ContrerasOct 17, 2012
  6. Sverre RabbelierOct 17, 2012
  7. Felipe ContrerasOct 17, 2012
  8. Johannes SchindelinOct 18, 2012
  9. Felipe ContrerasOct 18, 2012
  10. Johannes SchindelinOct 18, 2012
  11. Junio C HamanoOct 18, 2012
  12. Felipe ContrerasOct 18, 2012
  13. Matthieu MoyOct 18, 2012
  14. Felipe ContrerasOct 21, 2012
  15. Johannes SchindelinOct 21, 2012
  16. Felipe ContrerasOct 21, 2012
  17. Jeff KingOct 17, 2012
  18. Felipe ContrerasOct 18, 2012
  19. Felipe ContrerasOct 18, 2012
  20. Sverre RabbelierOct 18, 2012
  21. Felipe ContrerasOct 18, 2012
  22. Johannes SchindelinOct 18, 2012
  23. Felipe ContrerasOct 18, 2012
  24. Felipe ContrerasOct 26, 2012
  25. Felipe ContrerasOct 18, 2012
  26. Michael J GruberOct 18, 2012
  27. Felipe ContrerasOct 18, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.