git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Heiko Voigt <hvoigt@hvoigt.net>
To: Julian Ibarz <julian.ibarz@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Jens Lehmann <Jens.Lehmann@web.de>,
	git@vger.kernel.org
Subject: Re: Re: Re: Updating a submodule with a compatible version from another submodule version using the parent meta-repository
Date: Sun, 6 Feb 2011 19:51:41 +0100	[thread overview]
Message-ID: <20110206185140.GA61833@book.hvoigt.net> (raw)
In-Reply-To: <AANLkTim2G0kF+omPZ1_fk0P6oGDaKDWd79XNR5GXUkWG@mail.gmail.com>

Hi Julian,

interesting work so far.

One thing regarding the mailing list: Please do not top post and try to cut non
relevant text (the one you are not replying to) from your replies.

On Wed, Feb 02, 2011 at 11:31:40PM -0500, Julian Ibarz wrote:
> After a couple of hours, I have finally succeeded to go through the
> entire history of a repository and I can detect the submodules in a
> tree of a commit. For those interested here is the source code:
> 
> http://gitorious.org/julian_ibarz_git/julian_ibarz_git/blobs/submodule_checkout/builtin/submodulecheckout.c
> 
> Next time I will build the list of commits of a submodule in the
> entire history.

Sounds great. That will be one tool you need. Here is a small script
snippet which already does that as an example for the msysgit repository
(git://repo.or.cz/msysgit.git):

export sub=git
git log --pretty="%h" -- $sub | \
    while read i; do git ls-tree $i -- $sub; done | \
        cut -f3 -d" " | cut -f1

It outputs all the hashes that have been registered for the git
submodule. Maybe thats a good starting point to find example code in C.
You can use it for other submodules also just change the name in the variable
sub.

> Then I will need to find the distance of each commit
> in the list compared to the current  commit of a submodule and keep
> the closest one (which has to be a parent so an algebric distance
> would be good to have).

Have a look at the codepath that is used for

  git branch --contains <sha1>

It essentially does the thing you want (find all refs that contain a
commit). An approach could be to extend this mechanism not to iterate
through all refs but e.g. take a list of sha1's for iteration.

> So now my two questions that could save me some time are:
> - is there a function that gives the distance between two commits? I'm
> sure there is something like this coded somewhere but I didn't find it
> yet
> - is the struct decorate a hash map and if yes could someone explain
> me how to use it or point me to a location where it is used?

Please see the tips above.

> Except from that I think I have all the information I need.

There are a few points I would like to mention:

 * Citing my drawing:
> >>   superproject A:
> >>
> >>      O---O---X''---O
> >>               \
> >>   submodule B: \
> >>                 \
> >>      O---X---O---X'---O---O

   There can be multiple X' which contain X. These are all valid
   candidates. The same applies to X'' where there can be multiple
   candidates that record a specific X'. IMO, all of them need to be
   considered. If in the end they all reduce to one commit in submodule C
   you can check that out. If not printing a list of all candidates is
   probably the best option.

 * If we want your code to go upstream it probably needs to be
   integrated as a subcommand into the current submodule script. I can
   offer to help you on the bash scripting side. I think once the tools
   to find the appropriate commits are ready that will not be a big
   issue.

 * I think for protoyping the tools you can later use in the submodule
   script its fine to implement your own command. Keep in mind that you
   later on you should probably integrate your code into the appropriate
   existing commands. Here some suggestions.

   To support proper bash scripting two parts come into my mind:

   1. A tool to output all of the submodules commits which are
      candidates for X'' like the script snippet above.

   2. A tool that takes the list from 1. and then reduces that list to
      a list of commits that actually register the possible commits X'.
      If that is one commit X'' we can directly checkout. If not we
      print the list in a nice format and let the user choose.

Looking forward to your work.

Cheers Heiko

  reply	other threads:[~2011-02-06 18:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTinN1XVsAZXGLqkuhysrJ8-TCtGm4pOu2RfCEVVp@mail.gmail.com>
2011-01-26 18:32 ` Updating a submodule with a compatible version from another submodule version using the parent meta-repository Julian Ibarz
2011-01-26 19:06   ` Jens Lehmann
2011-01-26 19:10     ` Julian Ibarz
2011-01-26 19:39       ` Jens Lehmann
2011-01-26 19:48         ` Julian Ibarz
2011-01-26 20:31           ` Jens Lehmann
2011-01-26 20:43             ` Julian Ibarz
2011-01-26 20:41           ` Junio C Hamano
2011-01-26 20:45             ` Julian Ibarz
2011-01-26 22:05               ` Junio C Hamano
2011-01-29 11:08                 ` Heiko Voigt
2011-01-30  9:44                   ` Julian Ibarz
2011-02-03  4:31                     ` Julian Ibarz
2011-02-06 18:51                       ` Heiko Voigt [this message]
2011-02-09 19:36                       ` Heiko Voigt
2011-02-12 20:32                         ` Julian Ibarz
2011-02-13 13:30                           ` Heiko Voigt
2011-02-13 18:59                             ` Julian Ibarz
2011-02-14 21:13                               ` Heiko Voigt
2011-02-20  1:15                                 ` Julian Ibarz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110206185140.GA61833@book.hvoigt.net \
    --to=hvoigt@hvoigt.net \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=julian.ibarz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).