Fixed issue #714: add "FETCH_HEAD" to reference drop down list.
commit6ad58ccb0c22869846f5e77cfb1cce5629ea097d
authorJohan 't Hart <johanthart@gmail.com>
Wed, 9 Mar 2011 22:27:23 +0000 (9 23:27 +0100)
committerFrank Li <lznuaa@gmail.com>
Thu, 10 Mar 2011 23:05:24 +0000 (11 07:05 +0800)
tree1951cb6a221cbb92e4af3c9999f485570fce3be4
parent684fca5f6e3ad46c0d160cccb8a3d84009515da6
Fixed issue #714: add "FETCH_HEAD" to reference drop down list.

Git cannot always parse FETCH_HEAD to a hash value correctly. As mentioned earlier, git uses the first hash found in de FETCH_HEAD file. This is OK when it contains just 1 hash, like when you did something like:
git fetch git://github.com/Jopie64/tortoisegit master

But when you do something like:
git fetch

the FETCH_HEAD file looks like:

9a3de1f4895f9783f9ce213346dfa74c03345876 not-for-merge branch 'graph' of git://repo.or.cz/TortoiseGit
d6243bca70a6f8dfed786afa9ea236e54c4683a9 not-for-merge branch 'log_perfomance' of git://repo.or.cz/TortoiseGit
3c6e4d6094953bc8482588a6fceb8ab471d0eefc not-for-merge branch 'log_speed' of git://repo.or.cz/TortoiseGit
2150d6faa5c0aa3ddaecfe0941643c5959b6734e branch 'master' of git://repo.or.cz/TortoiseGit
884a5bf5a93f5ff1fa3420f60b2e88cc16c789bd not-for-merge branch 'myagi_overlay_exe' of git://repo.or.cz/TortoiseGit
c8d9a75a7bac5cbff2ff35a2c42331a3a4a1b5f9 not-for-merge branch 'myapi_overlay' of git://repo.or.cz/TortoiseGit
69c3400152b3040e74787f543bf0e51217a07d31 not-for-merge branch 'update_overlay' of git://repo.or.cz/TortoiseGit
f285dc3182c6f437c015db10e19a594a272effb8 not-for-merge branch 'upgrade_plink' of git://repo.or.cz/TortoiseGit
5d24e29ed857618be83072a73b868c78ada725d4 not-for-merge tag 'REL_1.6.3.0_EXTERNAL' of git://repo.or.cz/TortoiseGit
dea133d17a39d0a21c325c76908e566a14b69c38 not-for-merge tag 'REL_1.6.4.0_INTERNAL' of git://repo.or.cz/TortoiseGit

When you execute "git merge FETCH_HEAD" now, it merges ref 9a3de1f489... into the current branch because it uses "git rev-parse FETCH_HEAD" which picks the first hash found in the file. Instead it should pick the one without the "not-for-merge" tag. In this case: 2150d6faa...
FixBranchName("FETCH_HEAD") would return 2150d6faa... in this case.

I did not find a git command to do this. The only one which actually parses FETCH_HEAD the right way is "git pull". This command does "git fetch" and then parses FETCH_HEAD to "git merge" the right hash(es) into the current HEAD.

There could be more lines without the "not-for-merge" tag. In this case, git pull would execute an octopus merge. FixBranchName() does not support this case and returns an empty HASH in this case. Also, the FETCH_HEAD ref will not appear in the combo in this case. I did not implement this because I think this git feature is not used often.
13 files changed:
ext/libgit2
src/Changelog.txt
src/Git/Git.cpp
src/Git/Git.h
src/Git/GitRev.cpp
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/BranchCombox.h
src/TortoiseProc/ChooseVersion.h
src/TortoiseProc/Commands/FormatPatchCommand.cpp
src/TortoiseProc/FileDiffDlg.cpp
src/TortoiseProc/FormatPatchDlg.cpp
src/TortoiseProc/RebaseDlg.cpp
src/TortoiseProc/SyncDlg.cpp