为什么删除冲突的文件会破坏项目?

时间:2014-08-16 01:19:40

标签: git openssl

我现在已经三次遇到这种情况了,我想尝试修复它而不是删除项目并重新克隆它。例如,请参阅openssl-dev, link error [heartbeat_test] Error 2

我通过git clone git://git.openssl.org/openssl.git克隆了openssl-dev

今天,我做了一个git pull因为文件冲突而失败了。为了解决冲突,我执行了:

rm apps/Makefile
rm crypto/engine/Makefile
rm crypto/evp/Makefile
rm ssl/Makefile
rm test/Makefile

删除冲突后,git pull成功,我尝试构建。

现在,这是我迷路的地方。构建失败,带有重复的符号(如下所示)。如果我执行完全清理并且make(dclean是OpenSSL的dist-clean版本),则会失败:

make clean && make dclean && export KERNEL_BITS=64 && ./config && make

如果我投入make依赖,它就会失败:

make clean && make dclean && export KERNEL_BITS=64 && ./config && make depend && make

想到干净后可能会有一些目标文件,但没有:

$ find . -iname *.o
$ 

如果我执行一个新的克隆,那么一切都按预期工作。

导致此问题的git clonegit pull(带有清洁和制作)有什么区别?

或者git有什么问题,我该如何解决呢?


openssl-git$ make clean && make dclean && export KERNEL_BITS=64 && \
    ./config && make depend && make
...
cc -I.. -I../include  -I../fips -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H 
-arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT 
-DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM 
-DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM   -c -o heartbeat_test.o 
heartbeat_test.c

cc -I.. -I../include  -I../fips -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H 
-arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT 
-DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM 
-DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM   -c -o testutil.o testutil.c

( :; LIBDEPS="${LIBDEPS:--Wl,-search_paths_first ../libssl.a ../libcrypto.a  }"; 
LDCMD="${LDCMD:-cc}"; LDFLAGS="${LDFLAGS:--DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN 
-DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT 
-DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM 
-DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM}"; LIBPATH=`for x in $LIBDEPS; do 
echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; 
LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=heartbeat_test} 
heartbeat_test.o testutil.o ${LIBDEPS} )

duplicate symbol _main in:
    heartbeat_test.o
    testutil.o

ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [link_app.] Error 1
make[1]: *** [heartbeat_test] Error 2
make: *** [build_tests] Error 1

因为过去多次发生这种情况,我知道不是一次性问题。

我添加了标签,因为它是项目,但我很确定基本问题是git。

我保存了项目而不是删除它,所以我可以将其打开并上传以供检查(如果需要)。

最后:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.8.5
BuildVersion:   12F45

下面,openssl-git是我的OpenSSL副本所在的位置。它有我的mods和调整。 openssl-git-test是用于测试的新克隆。我在差异之前跑了find . -name '*.save' -exec rm -rf {} \;

$ diff --brief -r openssl-git/ openssl-git-test/
Only in openssl-git/: .DS_Store
Only in openssl-git/.git: FETCH_HEAD
Only in openssl-git/.git: ORIG_HEAD
Files openssl-git/.git/index and openssl-git-test/.git/index differ
Files openssl-git/.git/logs/HEAD and openssl-git-test/.git/logs/HEAD differ
Files openssl-git/.git/logs/refs/heads/master and openssl-git-test/.git/logs/refs/heads/master differ
Files openssl-git/.git/logs/refs/remotes/origin/HEAD and openssl-git-test/.git/logs/refs/remotes/origin/HEAD differ
Only in openssl-git/.git/logs/refs/remotes/origin: OpenSSL_0_9_8-stable
Only in openssl-git/.git/logs/refs/remotes/origin: OpenSSL_1_0_0-stable
Only in openssl-git/.git/logs/refs/remotes/origin: OpenSSL_1_0_1-stable
Only in openssl-git/.git/logs/refs/remotes/origin: OpenSSL_1_0_2-stable
Only in openssl-git/.git/logs/refs/remotes/origin: master
Only in openssl-git/.git/objects: 00
Only in openssl-git/.git/objects: 02
Only in openssl-git/.git/objects: 05
Only in openssl-git/.git/objects: 07
Only in openssl-git/.git/objects: 08
Only in openssl-git/.git/objects: 09
Only in openssl-git/.git/objects: 0a
Only in openssl-git/.git/objects: 0e
Only in openssl-git/.git/objects: 0f
Only in openssl-git/.git/objects: 13
Only in openssl-git/.git/objects: 18
Only in openssl-git/.git/objects: 1b
Only in openssl-git/.git/objects: 1c
Only in openssl-git/.git/objects: 1d
Only in openssl-git/.git/objects: 23
Only in openssl-git/.git/objects: 24
Only in openssl-git/.git/objects: 25
Only in openssl-git/.git/objects: 28
Only in openssl-git/.git/objects: 2a
Only in openssl-git/.git/objects: 2c
Only in openssl-git/.git/objects: 36
Only in openssl-git/.git/objects: 37
Only in openssl-git/.git/objects: 38
Only in openssl-git/.git/objects: 3e
Only in openssl-git/.git/objects: 3f
Only in openssl-git/.git/objects: 42
Only in openssl-git/.git/objects: 44
Only in openssl-git/.git/objects: 4a
Only in openssl-git/.git/objects: 54
Only in openssl-git/.git/objects: 58
Only in openssl-git/.git/objects: 5c
Only in openssl-git/.git/objects: 5d
Only in openssl-git/.git/objects: 60
Only in openssl-git/.git/objects: 61
Only in openssl-git/.git/objects: 63
Only in openssl-git/.git/objects: 66
Only in openssl-git/.git/objects: 67
Only in openssl-git/.git/objects: 68
Only in openssl-git/.git/objects: 6e
Only in openssl-git/.git/objects: 6f
Only in openssl-git/.git/objects: 71
Only in openssl-git/.git/objects: 72
Only in openssl-git/.git/objects: 78
Only in openssl-git/.git/objects: 79
Only in openssl-git/.git/objects: 7b
Only in openssl-git/.git/objects: 80
Only in openssl-git/.git/objects: 82
Only in openssl-git/.git/objects: 84
Only in openssl-git/.git/objects: 87
Only in openssl-git/.git/objects: 88
Only in openssl-git/.git/objects: 8d
Only in openssl-git/.git/objects: 8e
Only in openssl-git/.git/objects: 99
Only in openssl-git/.git/objects: 9f
Only in openssl-git/.git/objects: a0
Only in openssl-git/.git/objects: a3
Only in openssl-git/.git/objects: a4
Only in openssl-git/.git/objects: a8
Only in openssl-git/.git/objects: a9
Only in openssl-git/.git/objects: ae
Only in openssl-git/.git/objects: af
Only in openssl-git/.git/objects: b2
Only in openssl-git/.git/objects: b5
Only in openssl-git/.git/objects: ba
Only in openssl-git/.git/objects: bc
Only in openssl-git/.git/objects: bd
Only in openssl-git/.git/objects: be
Only in openssl-git/.git/objects: c4
Only in openssl-git/.git/objects: c5
Only in openssl-git/.git/objects: c6
Only in openssl-git/.git/objects: d3
Only in openssl-git/.git/objects: d5
Only in openssl-git/.git/objects: d6
Only in openssl-git/.git/objects: d7
Only in openssl-git/.git/objects: da
Only in openssl-git/.git/objects: db
Only in openssl-git/.git/objects: de
Only in openssl-git/.git/objects: e0
Only in openssl-git/.git/objects: e3
Only in openssl-git/.git/objects: e7
Only in openssl-git/.git/objects: e8
Only in openssl-git/.git/objects: e9
Only in openssl-git/.git/objects: ed
Only in openssl-git/.git/objects: ef
Only in openssl-git/.git/objects: f2
Only in openssl-git/.git/objects: fa
Only in openssl-git/.git/objects: fb
Only in openssl-git/.git/objects: fc
Only in openssl-git/.git/objects/pack: pack-663dfba6981c559658fb9253e5456938cd330c97.idx
Only in openssl-git/.git/objects/pack: pack-663dfba6981c559658fb9253e5456938cd330c97.pack
Only in openssl-git-test/.git/objects/pack: pack-97e4b04a1ce519e33653e4f4ef941fed44f53332.idx
Only in openssl-git-test/.git/objects/pack: pack-97e4b04a1ce519e33653e4f4ef941fed44f53332.pack
Only in openssl-git/.git/objects/pack: pack-a5611b625ffa369803ca57e5d198864c4c3933a4.idx
Only in openssl-git/.git/objects/pack: pack-a5611b625ffa369803ca57e5d198864c4c3933a4.pack
Only in openssl-git/.git/objects/pack: pack-feccfacff9cc5bff523280a162d04c2c3813bba8.idx
Only in openssl-git/.git/objects/pack: pack-feccfacff9cc5bff523280a162d04c2c3813bba8.pack
Files openssl-git/.git/packed-refs and openssl-git-test/.git/packed-refs differ
Files openssl-git/.git/refs/heads/master and openssl-git-test/.git/refs/heads/master differ
Only in openssl-git/.git/refs/remotes/origin: OpenSSL_0_9_8-stable
Only in openssl-git/.git/refs/remotes/origin: OpenSSL_1_0_0-stable
Only in openssl-git/.git/refs/remotes/origin: OpenSSL_1_0_1-stable
Only in openssl-git/.git/refs/remotes/origin: OpenSSL_1_0_2-stable
Only in openssl-git/.git/refs/remotes/origin: master
Only in openssl-git/.git/refs/tags: OpenSSL_0_9_8zb
Only in openssl-git/.git/refs/tags: OpenSSL_1_0_0n
Only in openssl-git/.git/refs/tags: OpenSSL_1_0_1i
Files openssl-git/doc/apps/ciphers.pod and openssl-git-test/doc/apps/ciphers.pod differ
Files openssl-git/doc/apps/pkcs8.pod and openssl-git-test/doc/apps/pkcs8.pod differ
Only in openssl-git/engines: e_padlock-x86.s
Only in openssl-git/: s3_enc.c.diff
Files openssl-git/ssl/s3_clnt.c and openssl-git-test/ssl/s3_clnt.c differ
Files openssl-git/ssl/s3_enc.c and openssl-git-test/ssl/s3_enc.c differ
Files openssl-git/ssl/s3_lib.c and openssl-git-test/ssl/s3_lib.c differ
Files openssl-git/ssl/tls1.h and openssl-git-test/ssl/tls1.h differ

2 个答案:

答案 0 :(得分:2)

我猜的是基于一些地方发现的其他一些项目,但听起来像是:

  • 你正在使用git克隆一些东西只是为了得到它的一些版本,你打算不编辑它。
  • 你正在克隆的东西在它自己的源代码树中,在正常的操作过程中编辑本身。这对git或者大多数版本控制系统来说都非常糟糕。 (使用VCS-es执行此操作的“正确”方法是将变量,不断变化,自生成,非源控制的内容保存在单独的区域中 - 这可以像常规源中的单独文件一样简单区域,您可以告诉VCS忽略,就像使用git的.gitignore文件一样。)
  • 对于使用svn的人,他们可以“作弊”:存储库本身可以存储在那里(想象箭头指向网络),当你正在处理的东西编辑自己时,你只需删除东西和让它再次检查它们到你的工作树。所以这最终只是半可见的。但是,使用git,您可以自动将存储库放在此处,这样VCS就会发现您已经更改了内容,并坚持要求您更改内容,然后才能更新任何内容。

这个问题有几个(也许很多)解决方案。最好的方法是按照上面提到的“正确的方式”对待事物,但这需要在另一端进行合作。这留下了几个解决方法:

  1. 明确git:“擦掉我的东西。”

    git reset --hard && git fetch && git merge
    

    reset --hard表示“清除我的所有更改”。 (您可能还需要git clean -fdx来删除构建产品。或者,您可以将它们保留在那里,并仅重置git知道的那些文件,即最初从克隆步骤结帐中提取的文件。 )确保你真的是这个意思;这没有“哎呀,等等,我改变主意”的选择。

    git fetch && git merge步骤可以缩写为git pull(虽然它们不完全相同,尤其是在旧版本的git中)。这是理解这里发生了什么的关键: pull只是fetch后跟merge您正在使用git checkout和所有git的版本控制的东西,当你删除文件时,git得到所有有用的 1 并坚持你保存你的工作,因为你很确定你试图版本控制你自己的更改,并融合他们以某种方式与他们(“他们”是你fetch的任何人)。

  2. 将git的存储库与源代码和构建树分开,就像你根本不使用版本控制系统一样。特别是,您可以使用镜像(或裸克隆)使git“像”SVN一样“。这为您提供了本地存储库,但(至少对于镜像)以一种您从未接触过的方式,除了从远程版本更新它:

    git clone --mirror git://whatever... local-clone.git
    

    然后,使用镜像将最新版本提取到空树中:

    cd local-clone; git --work-tree=/somewhere/else checkout master
    

    或:

    cd /somewhere; mkdir else; cd else
    git --git-dir=/path/to/local/clone.git checkout master
    

    (或者,您可以使用git --work-tree=... reset --hardgit --git-dir=... reset --hard将某些文件恢复到原始状态,但之后您也可以使用第一种方法。)这里的主要优点是,因为git存储库离工作树“足够远”,没有人意外地尝试使用git在/somewhere/else中工作,认为他们正在获得所有常用的git保证。

  3. 如果您使用--mirror方法(现在我认为它可能比第一种方法更有效),请注意git fetch将直接更新您的(镜像)分支。在这种情况下,没有什么可以合并,事实上你不能使用镜像来保存你自己的更改:当你运行git fetch --prune(或git remote update -p时,它们将会丢失)从遥控器中获取新的更改。


    1 或者一些不太可打印的形容词。 : - )

答案 1 :(得分:0)

在一个相关问题中回答了这个问题:Can I use the files present after a git clone?

问题是make dclean删除了test/目录(感谢@hvd)。 dclean是与distclean等效的OpenSSL。不幸的是,该项目充满了残骸,diff dclean几乎无用(见Bug #3492: Make dclean creates a 630K+ git diff)。

这个问题似乎与git无关。 (虽然我承认我以非常简单的方式使用它,并且许多人不同意这种简单性。)