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

Re: Unexpected behavior of git-subtree

From
John Keeping <john@keeping.me.uk>
Date
Apr 29, 2013, 18:20 UTC
Message-ID
<20130429182052.GN472@serenity.lan>
In-Reply-To
<1003348467.20130429193427@stzedn.de>
On Mon, Apr 29, 2013 at 07:34:27PM +0200, Steffen Jaeckel wrote:
Show 30 quoted lines
> lately I used git-subtree to integrate a submodule directly into a
> repository. Now I wanted to push the changes back to the original
> repository of the submodule and I was a bit surprised by what
> happened...
> 
> 
> ---- snip ----
> sjaeckel@T7400-003 /h/projects/my_project (develop)
> $ GIT_TRACE=2 git subtree push --prefix=lib/com_lib/ git@git.local:com_lib develop -b develop
> trace: exec: 'git-subtree' 'push' '--prefix=lib/com_lib/' 'git@git.local:com_lib' 'develop' '-b' 'develop'
> trace: run_command: 'git-subtree' 'push' '--prefix=lib/com_lib/' 'git@git.local:com_lib' 'develop' '-b' 'develop'
> trace: built-in: git 'rev-parse' '--parseopt' '--' 'push' '--prefix=lib/com_lib/' 'git@git.local:com_lib' 'develop' '-b' 'develop'
> trace: built-in: git 'rev-parse' '--git-dir'
> trace: built-in: git 'rev-parse' '--show-cdup'
> git push using:  git@git.local:com_lib develop
> trace: exec: 'git-subtree' 'split' '--prefix=lib/com_lib/'
> trace: run_command: 'git-subtree' 'split' '--prefix=lib/com_lib/'
> trace: built-in: git 'rev-parse' '--parseopt' '--' 'split' '--prefix=lib/com_lib/'
> trace: built-in: git 'rev-parse' '--git-dir'
> trace: built-in: git 'rev-parse' '--show-cdup'
> trace: built-in: git 'rev-parse' '--default' 'HEAD' '--revs-only'
> trace: built-in: git 'rev-parse' '--no-revs' '--no-flags'
> trace: built-in: git 'log' '--grep=^git-subtree-dir: lib/com_lib/*$' '--pretty=format:START %H%n%s%n%n%b%nEND%n' '8068a810709f6284b04a18ff38dbb72c36b8d9c6'
> trace: built-in: git 'rev-list' '--topo-order' '--reverse' '--parents' '8068a810709f6284b04a18ff38dbb72c36b8d9c6'
> trace: built-in: git 'rev-list' '--topo-order' '--reverse' '--parents' '8068a810709f6284b04a18ff38dbb72c36b8d9c6'
> 1/    102 (0)trace: built-in: git 'ls-tree' 'f6e1457d345029cf4d376ff3cf780cbb8c3080b4' '--' 'lib/com_lib'
> ..... loads of more git 'ls-tree'...
> 71/    102 (70)72/    102 (70)trace: built-in: git 'ls-tree' '48dc0efb9a148b1146b013554f8bf4635adf7a0d' '--' 'lib/com_lib'
> trace: built-in: git 'log' '-1' '--pretty=format:%T' '6299b48765e11302aca48cc9fca88735aeab7c54' '--'
> fatal: bad object 6299b48765e11302aca48cc9fca88735aeab7c54

Without knowing much about git-subtree, this looks like the culprit. A quick look at cmd_push in git-subtree.sh indicates that it doesn't check for an error return from 'git subtree split --prefix=$prefix', so if that goes wrong you end up doing:

    git push $repository :refs/heads/$refspec
which deletes the branch.
Can you try running this:
    git subtree split --prefix=lib/com_lib/
and see if that gives the same "fatal: bad object" message as above?
Previous: Steffen JaeckelNext: Steffen Jaeckel
Message 2 of 3 in “Unexpected behavior of git-subtree”
  1. Steffen JaeckelApr 29, 2013
  2. John KeepingApr 29, 2013
  3. Steffen JaeckelApr 30, 2013

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.