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

Re: [PATCH] Re: Bug with "git submodule update" + subrepo with differing path/name?

From
AUAndreas Urke <arurke@gmail.com>
Date
Dec 21, 2017, 16:21 UTC
Message-ID
<CAFBGMVMmLX4BjkQ8Xd4bQBCgoYYxWTU-p2pNF=b8JNsUsKXwUA@mail.gmail.com>
In-Reply-To
<CAGZ79kZf8GL1DY6Vmc-byEOOy+hrKF8X8qRPM6jNO-La+rD4uw@mail.gmail.com>

If I am entering into undefined behavior territory with the renaming then there might not be any point to pursue this further, but in any case, script below:

Apologies up-front for the verbosity, there are probably a lot of unnecessary steps and git shortcuts missed - I just wanted it to exactly match my scenario. Note that it is divided into two parts as it requires you to edit .gitmodules.

Part 1:

cd ~/ # Make sub repos and add a commit to each mkdir super && cd super mkdir sub1 && mkdir sub2 cd sub1 git init && touch first && git add . && git commit -m "first" cd ../sub2 git init && touch first && git add . && git commit -m "first" cd ..

# Make super repo, add subrepos, and commit git init git submodule add ./sub1 git submodule add ./sub2 git add . git commit -m "first"

# Edit .gitmodules, change sub2 name and path to sub2_newname: # $ cat .gitmodules # [submodule "sub1"] # path = sub1 # url = ./sub1 # [submodule "sub2_newname"] # path = sub2 # url = ./sub2_newname

Part 2:

cd ~/ # Sync submodule after we edited .gitmodules cd super git submodule sync

# Commit in subrepos and commit this to superrepo cd sub1 touch second && git add . && git commit -m "second" cd ../sub2 touch second && git add . && git commit -m "second" cd .. git add . git commit -m "second"

# Commit in subrepos and commit this to superrepo cd sub1 touch third && git add . && git commit -m "third" cd ../sub2 touch third && git add . && git commit -m "third" cd .. git add . git commit -m "third"

git checkout HEAD^ git status git submodule update git status # Observe only sub1 repo was updated

On 20 December 2017 at 18:54, Stefan Beller <sbeller@google.com> wrote:
Show 21 quoted lines
> On Wed, Dec 20, 2017 at 12:22 AM, Andreas Urke <arurke@gmail.com> wrote:
>> Thanks for looking into this.
>>
>> I was able to reproduce it from scratch, but I followed my earlier
>> workflow where I first created the subrepos, and then later renamed
>> it. At the time I was not able to find any command to rename without
>> changing the path (and I was not able find one now either, is there
>> any?), so I edited name and path in .gitmodules and ran git submodule
>> sync. Am I asking for trouble doing it that way?
>
> "rename without changing the path" sounds like a red flag to me,
> as the submodule name was introduced specifically to be a constant
> as the path may change, whereas the name ought to never change.
>
>
>
>
>>
>> Let me know if you need the exact steps I followed.
>
> Well yes, ideally as a shell script (or even embedded into our test suite).
Previous: Stefan BellerNext: Stefan Beller
Message 7 of 11 in “Bug with "git submodule update" + subrepo with differing path/name?”
  1. Andreas UrkeDec 18, 2017
  2. Re: Bug with "git submodule update" + subrepo with differing path/name?Stefan Beller, Dec 19, 2017
  3. Junio C HamanoDec 19, 2017
  4. Stefan BellerDec 19, 2017
  5. Andreas UrkeDec 20, 2017
  6. Stefan BellerDec 20, 2017
  7. Andreas UrkeDec 21, 2017
  8. Stefan BellerDec 21, 2017
  9. Andreas UrkeDec 21, 2017
  10. Stefan BellerDec 21, 2017
  11. Stefan BellerDec 21, 2017

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.