cherry-pick vs submodule, conflicts
- From
Jeff Epler <jepler@unpythonic.net>
- Date
- Nov 13, 2009, 18:05 UTC
- Message-ID
- <20091113180512.GA29783@unpythonic.net>
A fellow git user of mine encountered an unexpected problem cherry- picking from one branch to another. The conflict was 'added by us: sub' and I created a small program that leads to the same message.
#!/bin/bash # This script demonstrates that it doesn't work to cherry-pick when some (not # even touched) path is a submodule in HEAD but a regular subdirectory in the # branch being picked from. # # Furthermore, when using 'git mergetool', the (desired?) action 'c' # gives the error "fatal: unable to stat 'sub': No such file or directory". # # The behavior is essentially the same on # git version 1.6.3.3 # git version 1.6.5.rc1.49.ge970 # # maybe this is related to # http://kerneltrap.org/mailarchive/git/2007/7/7/250935 # but the case must be extended to cover submodules?
set -e
BASEDIR=$(pwd)
rm -rf main sub &&
mkdir sub main &&
(cd sub && git init && touch y && git add y && git commit -my) &&
# make a submodule
cd ../main &&
git init &&
touch x; git add x &&
git commit -mx && # initial commit
git branch b &&
mkdir sub && # on master, make sub a subdir
touch sub/y; git add sub/y &&
git commit -my &&
echo 1 > x &&
git commit -mx1 -a && # and create a second commit
CHERRY=$(git rev-parse HEAD) && # which is a tasty cherry
git checkout b &&
git submodule add file://$BASEDIR/sub sub &&
git submodule update &&
git commit -my && # on brach, make sub a submodule
! git cherry-pick $CHERRY && # pull second commit from master
git status # what happened?