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

Re: [PATCH] add: remove dead code

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 31, 2015, 16:41 UTC
Message-ID
<xmqqr3no5lfi.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1438301956-1658-1-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 5 quoted lines
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>
> So I was trying to understand how to implement "git add .gitmodules" as 
> I intend to rewrite git submodules in C.
A request and a suggestion.
 - Please keep Jens and Heiko in the loop and pick their brains ;-)
 - It may not be the best use of your time to attempt rewriting the
   whole of "git submodule" in C in a single pass (which is the
   impression I am getting from seeing you say "git add
   .gitmodules").
   The largest pain point a rewrite in C would solve is that "git
   submodule init" and "update" have to go sequencially even though
   (1) there is no inherent reason for cloning and fetching of
       different submodules to happen in some order;
   (2) there is no inherent reason for a failure to clone or fetch
       of one submodule to abort the entire session without cloning
       or fetching other submodules; and
   (3) the operation in each submodule takes human-scale time and
       the users would benefit greatly by parallel operations.
   One approach that may be beneficial would be to introduce "git
   submodule--helper" written in C to have selected primitives used
   in "git submodule" script to speed them up.  Perhaps the first
   subcommand would be "
    $ git submodule--helper foreach-parallel --cmd=$cmd $args...
   where it takes the arguments currently fed to module_list as
   $args... and runs $cmd in parallel.  The initial implementation
   of "git submodule update" then would replace the expensive and
   sequencial
       module_list "$@" | {
           ...
           while read mode sha1 stage sm_path
           do
           	...
	   done
       }
   loop with a call to the foreach-parallel subcommand.
   The end-user scripts that currently use "git submodule foreach"
   may or may not depend on the sequencial nature of the current
   implementation, so adding "git submodule foreach-parallel" may be
   a good way to expose this as a new "do it in parallel" feature.
   Once you have a solid infrastructure to implement the helper
   subcommand "foreach-parallel" (I'd expect the interface inside C
   into that function would be to give it a worker function with the
   data for the function to consume, and the above --cmd=$cmd form
   would use a worker function that essentially does run_command();
   the spawn(2)ing and wait(2)ing would be done on the more generic
   API side), you can rewrite the $cmd part in C little by little,
   and eventually you would get a full C implemention while keeping
   everything working and retaining debuggability during the course
   of development.
Thanks.
Previous: Stefan BellerNext: Stefan Beller
Message 2 of 15 in “add: remove dead code”
  1. add: remove dead codeStefan Beller, Jul 31, 2015
  2. Junio C HamanoJul 31, 2015
  3. 0/2 Submodules: refactoring the `module_list` functionStefan Beller, Jul 31, 2015
  4. 1/2 submodule: implement `module_list` as a builtin helperStefan Beller, Jul 31, 2015
  5. Junio C HamanoAug 1, 2015
  6. Stefan BellerAug 3, 2015
  7. Junio C HamanoAug 3, 2015
  8. submodule: implement `module_list` as a builtin helperStefan Beller, Aug 3, 2015
  9. Junio C HamanoAug 3, 2015
  10. Stefan BellerAug 3, 2015
  11. submodule: implement `module_list` as a builtin helperStefan Beller, Aug 3, 2015
  12. 2/2 Testing the new codeStefan Beller, Jul 31, 2015
  13. Junio C HamanoAug 1, 2015
  14. Stefan BellerAug 3, 2015
  15. Junio C HamanoAug 3, 2015

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.