Seth Robertson <in-gitvger@xxxxxxxx> wrote: > In message <4C96B97D.6030209@xxxxxxxxx>, Artur Skawina writes: > > On 09/20/10 01:54, Seth Robertson wrote: > > > I'd like a command that would tell me the right branch something was > > on whether it was on master or topic or whatever. If instead of > > "master" the branch was named "supertopic" and master commit AA had > > child D would that make a difference? > > Like i said, "arguably". In theory, no, there is no difference. In > practice, some branches will be more long-lived than others -- and > certain conventions will apply. Hence, i think that answer /is/ the > right one, in context -- that script was specifically looking for > info on /another/ branch. > > Only if the topic branch didn't have a merge on it. > > -AA-- subtopic > / \ > A---B---C topic > / \ > D---E---F---G---H---I---J---K---L---M---N master > \ / > O---P---Q another-topic > > > In the above example, the subtopic branch merge from AA to C prevents > you from finding out what branch B is on using the original script. When you say "the original script", are you talking about Artur's one-liner or my script? My script gives me exactly the information I want in all cases. For a given command $1 and a target branch $2, it shows you all merges that were involved in bringing $1 into $2. For example: Called with "B" "master", it returns H Called with "AA" "master", it returns C, H (and that's good, because for someone asking "what was AA's original branch?" it's not clear if he will be more interested in topic or sub-topic, so show him both) Called with "F" "master", it returns nothing The one limitation is that the result is empty both when $1 started on $2, and when $1 is not reachable from $2 at all, in which case it should probably error out (like when you call it with "F" "topic"). That's easy to add as an additional check at the beginning of the script, though. The script works even in cases where you have a long-running topic branch that is occasionally brought up to date with master, like this: F---G---H---I---J---O---P topic / / / \ A---B---C---D---E---K---L---M---N---Q master When called with "F" "master", it returns only N, but not H or J. Exactly what I need. (We have this kind of history a lot in our code base.) You could even call the script with "C" "topic" if you wanted to (in which case it would return H, but not J). It's not quite clear why you would want to though. -- Stefan Haller Berlin, Germany http://www.haller-berlin.de/ -- 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