1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 14:57:52 +01:00
git/builtin
Eric Sunshine c990a4c11d checkout: fix bug with --to and relative HEAD
Given "git checkout --to <path> HEAD~1", the new worktree's HEAD should
begin life at the current branch's HEAD~1, however, it actually ends up
at HEAD~2. This happens because:

    1. git-checkout resolves HEAD~1

    2. to satisfy is_git_directory(), prepare_linked_worktree() creates
       a HEAD for the new worktree with the value of the resolved HEAD~1

    3. git-checkout re-invokes itself with the same arguments within the
       new worktree to populate the worktree

    4. the sub git-checkout resolves HEAD~1 relative to its own HEAD,
       which is the resolved HEAD~1 from the original invocation,
       resulting unexpectedly and incorrectly in HEAD~2 (relative to the
       original)

Fix this by unconditionally assigning the current worktree's HEAD as the
value of the new worktree's HEAD.

As a side-effect, this change also eliminates a dependence within
prepare_linked_checkout() upon 'struct branch_info'. The plan is to
eventually relocate "git checkout --to" functionality to "git worktree
add", and worktree.c won't have knowledge of 'struct branch_info', so
removal of this dependency is a step toward that goal.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-06 11:07:44 -07:00
..
add.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
annotate.c
apply.c Merge branch 'rs/more-uses-of-skip-prefix' 2014-10-14 10:50:07 -07:00
archive.c
bisect--helper.c
blame.c refs.c: change resolve_ref_unsafe reading argument to be a flags field 2014-10-15 10:47:24 -07:00
branch.c use new wrapper write_file() for simple file writing 2014-12-01 11:00:16 -08:00
bundle.c
cat-file.c use skip_prefix() to avoid more magic numbers 2014-10-07 11:09:16 -07:00
check-attr.c
check-ignore.c
check-mailmap.c
check-ref-format.c
checkout-index.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
checkout.c checkout: fix bug with --to and relative HEAD 2015-07-06 11:07:44 -07:00
clean.c Merge branch 'jn/parse-config-slot' 2014-10-20 12:23:48 -07:00
clone.c path.c: make get_pathname() call sites return const char * 2014-12-01 11:00:10 -08:00
column.c
commit-tree.c
commit.c commit: use SEQ_DIR instead of hardcoding "sequencer" 2014-12-01 11:00:12 -08:00
config.c Merge branch 'jn/parse-config-slot' 2014-10-20 12:23:48 -07:00
count-objects.c count-objects: report unused files in $GIT_DIR/worktrees/... 2014-12-01 11:00:18 -08:00
credential.c
describe.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
diff-files.c
diff-index.c
diff-tree.c diff-tree: avoid lookup_unknown_object 2014-07-28 10:14:34 -07:00
diff.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
fast-export.c teach fast-export an --anonymize option 2014-08-27 10:42:16 -07:00
fetch-pack.c
fetch.c path.c: make get_pathname() call sites return const char * 2014-12-01 11:00:10 -08:00
fmt-merge-msg.c refs.c: change resolve_ref_unsafe reading argument to be a flags field 2014-10-15 10:47:24 -07:00
for-each-ref.c Merge branch 'rs/ref-transaction' 2014-10-21 13:28:10 -07:00
fsck.c path.c: make get_pathname() call sites return const char * 2014-12-01 11:00:10 -08:00
gc.c worktree: new place for "git prune --worktrees" 2015-06-29 08:48:44 -07:00
get-tar-commit-id.c use skip_prefix() to avoid more magic numbers 2014-10-07 11:09:16 -07:00
grep.c make add_object_array_with_context interface more sane 2014-10-16 10:10:44 -07:00
hash-object.c hash-object: add --literally option 2014-09-11 14:23:51 -07:00
help.c doc: add 'everyday' to 'git help' 2014-10-10 16:02:26 -07:00
index-pack.c index-pack: fix compilation with NO_PTHREADS 2014-10-13 12:33:30 -07:00
init-db.c use new wrapper write_file() for simple file writing 2014-12-01 11:00:16 -08:00
interpret-trailers.c trailer: add interpret-trailers command 2014-10-13 13:55:27 -07:00
log.c Merge branch 'rs/ref-transaction' 2014-10-21 13:28:10 -07:00
ls-files.c grammofix in user-facing messages 2014-09-02 12:00:30 -07:00
ls-remote.c
ls-tree.c
mailinfo.c mailinfo: work around -Wstring-plus-int warning 2014-09-22 13:46:43 -07:00
mailsplit.c mailsplit: remove unnecessary unlink(2) call 2014-10-07 10:49:57 -07:00
merge-base.c
merge-file.c
merge-index.c
merge-ours.c
merge-recursive.c
merge-tree.c merge-tree: remove unused df_conflict arguments 2014-09-02 11:02:58 -07:00
merge.c refs.c: change resolve_ref_unsafe reading argument to be a flags field 2014-10-15 10:47:24 -07:00
mktag.c
mktree.c
mv.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
name-rev.c
notes.c refs.c: change resolve_ref_unsafe reading argument to be a flags field 2014-10-15 10:47:24 -07:00
pack-objects.c Merge branch 'jk/prune-mtime' 2014-10-29 10:07:56 -07:00
pack-redundant.c
pack-refs.c
patch-id.c
prune-packed.c prune-packed: use for_each_loose_file_in_objdir 2014-10-16 10:10:40 -07:00
prune.c worktree: new place for "git prune --worktrees" 2015-06-29 08:48:44 -07:00
push.c push: heed user.signingkey for signed pushes 2014-10-24 10:50:05 -07:00
read-tree.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
receive-pack.c path.c: make get_pathname() call sites return const char * 2014-12-01 11:00:10 -08:00
reflog.c reflog: avoid constructing .lock path with git_path 2014-12-01 11:00:12 -08:00
remote-ext.c use skip_prefix() to avoid more magic numbers 2014-10-07 11:09:16 -07:00
remote-fd.c
remote.c path.c: make get_pathname() call sites return const char * 2014-12-01 11:00:10 -08:00
repack.c path.c: make get_pathname() call sites return const char * 2014-12-01 11:00:10 -08:00
replace.c refs.c: pass the ref log message to _create/delete/update instead of _commit 2014-10-15 10:47:22 -07:00
rerere.c
reset.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
rev-list.c
rev-parse.c setup.c: support multi-checkout repo setup 2014-12-01 11:00:15 -08:00
revert.c
rm.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
send-pack.c Merge branch 'jc/push-cert' 2014-10-08 13:05:25 -07:00
shortlog.c
show-branch.c refs.c: change resolve_ref_unsafe reading argument to be a flags field 2014-10-15 10:47:24 -07:00
show-ref.c
stripspace.c
symbolic-ref.c refs.c: change resolve_ref_unsafe reading argument to be a flags field 2014-10-15 10:47:24 -07:00
tag.c refs.c: pass the ref log message to _create/delete/update instead of _commit 2014-10-15 10:47:22 -07:00
unpack-file.c
unpack-objects.c fsck_object(): allow passing object data separately from the object itself 2014-09-10 13:54:21 -07:00
update-index.c lockfile.h: extract new header file for the functions in lockfile.c 2014-10-01 13:56:14 -07:00
update-ref.c refs.c: pass the ref log message to _create/delete/update instead of _commit 2014-10-15 10:47:22 -07:00
update-server-info.c
upload-archive.c
var.c
verify-commit.c
verify-pack.c run-command: introduce CHILD_PROCESS_INIT 2014-08-20 09:53:37 -07:00
verify-tag.c
worktree.c worktree: new place for "git prune --worktrees" 2015-06-29 08:48:44 -07:00
write-tree.c