git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Hedges  Alexander" <ahedges@student.ethz.ch>
To: Jacob Keller <jacob.keller@gmail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Feature Request: Branch-Aware Submodules
Date: Thu, 1 Sep 2016 11:34:28 +0000	[thread overview]
Message-ID: <AAED3CA2-3BDA-49CF-8930-FBC96F1EFE34@student.ethz.ch> (raw)
In-Reply-To: <CA+P7+xqA_3a8EPZ=2Y5pgkL+N=_F1v5pfyzErwest9aoKZC37w@mail.gmail.com>

Since I don’t want to change any history in the subproject, to me the most 
expected behavior would be:

git submodule update —-recursive

with submodule.*.update set to the command:

```
#!/bin/bash

branches=`git branch --points-at "$1"`

if [ ! $branches ] ; then
    git checkout "$1"
    echo "do normal checkout"
else
    points_to_master=
    other_branch=
    for b in $branches ; do
        if [ "$b" = "master" ] ; then
            points_to_master="true"
        else
            other_branch="$b"
        fi
    done
    if [ points_to_master ] ; then
        git checkout master
    else
        git checkout "$other_branch"
    fi
fi
```

Now, this is not perfect and I’m sure I’ll refine it whenever I find it doesn’t
suit my needs, but I’m sure you can see the intentions here. I’m also not quite
sure whether to prioritize tags over branches or the other way around.

Thanks for the suggestion. I hope this or a similar behavior could sometime
become the default in git. Until the suggested quick fix will do for me.

Best Regards,
Alexander Hedges

> On 29 Aug 2016, at 04:17, Jacob Keller <jacob.keller@gmail.com> wrote:
> 
> On Fri, Aug 26, 2016 at 8:12 AM, Hedges  Alexander
> <ahedges@student.ethz.ch> wrote:
>>> On 25 Aug 2016, at 19:45, Stefan Beller <sbeller@google.com> wrote:
>>> [1] https://github.com/jlehmann/git-submod-enhancements
>>> which has some attempts for checkout including the submodules.
>>> I also tried writing some patches which integrate checking out submodules
>>> via checkout as well. A quicker `solution` would be a config option that
>>> just runs `git submodule update` after each checkout/pull etc.
>>> 
>> 
>> I see. The quick fix is almost what I’m looking for, except that it leaves
>> the repo in a detached head state. Could the submodule update be made
>> automatically and intelligently pick the branch?
>> 
> 
> You probably want "git submodule update --rebase" or "git submodule
> update --merge" See git help submodule under the update section, or
> even a custom command variant where you can write your own bit of
> shell that does what your project expects.
> 
> Thanks,
> Jake


  reply	other threads:[~2016-09-01 11:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5EA7D232-5D41-4653-9E35-21C502C79C92@student.ethz.ch>
2016-08-26 15:12 ` Feature Request: Branch-Aware Submodules Hedges  Alexander
2016-08-29  2:17   ` Jacob Keller
2016-09-01 11:34     ` Hedges  Alexander [this message]
2016-08-25  9:00 Hedges  Alexander
2016-08-25 17:45 ` Stefan Beller
2016-08-25 20:50   ` Junio C Hamano
2016-08-25 20:55     ` Stefan Beller
2016-08-25 21:25       ` Junio C Hamano
2016-08-25 17:46 ` Junio C Hamano

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=AAED3CA2-3BDA-49CF-8930-FBC96F1EFE34@student.ethz.ch \
    --to=ahedges@student.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=jacob.keller@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).