summaryrefslogtreecommitdiff
path: root/git-checkout.sh
Commit message (Collapse)AuthorAgeFilesLines
* tone down the detached head warningNicolas Pitre2007-01-311-3/+3
| | | | | | | | | This is not meant to frighten people or even to suggest they might be doing something wrong, but rather to notify them of a state change and provide a likely option in the case this state was entered by mistake. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* fix suggested branch creation command when detaching headNicolas Pitre2007-01-261-3/+3
| | | | | | | | | | | | | | | | | | | | Doing: $ git checkout HEAD^ Generates the following message: |warning: you are not on ANY branch anymore. |If you meant to create a new branch from the commit, you need -b to |associate a new branch with the wanted checkout. Example: | git checkout -b <new_branch_name> HEAD^ Of course if the user does as told at this point the created branch won't be located at the expected commit. Reword this message a bit to avoid such confusion. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-checkout -m: fix merge caseJunio C Hamano2007-01-231-10/+5
| | | | | | | | | | Commit c1a4278e switched the "merging checkout" implementation from 3-way read-tree to merge-recursive, but forgot that merge-recursive will signal an unmerged state with its own exit status code. This prevented the clean-up phase (paths cleanly merged should not be updated in the index) from running. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Use merge-recursive in git-checkout -m (branch switching)Junio C Hamano2007-01-161-2/+3
| | | | | | | This allows "git checkout -m <other-branch>" to notice renames and carry local changes in the working tree forward. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Use cd_to_toplevel in scripts that implement it by hand.Junio C Hamano2007-01-121-5/+1
| | | | | | | | | | This converts scripts that do "cd $(rev-parse --show-cdup)" by hand to use cd_to_toplevel. I think git-fetch does not have to go to the toplevel, but that should be dealt with in a separate patch. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'jc/bare'Junio C Hamano2007-01-111-0/+1
|\ | | | | | | | | | | | | | | * jc/bare: Disallow working directory commands in a bare repository. git-fetch: allow updating the current branch in a bare repository. Introduce is_bare_repository() and core.bare configuration variable Move initialization of log_all_ref_updates
| * Disallow working directory commands in a bare repository.Shawn O. Pearce2007-01-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the user tries to run a porcelainish command which requires a working directory in a bare repository they may get unexpected results which are difficult to predict and may differ from command to command. Instead we should detect that the current repository is a bare repository and refuse to run the command there, as there is no working directory associated with it. [jc: updated Shawn's original somewhat -- bugs are mine.] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | git-checkout: handle local changes sanely when detaching HEADJunio C Hamano2007-01-091-11/+25
| | | | | | | | | | | | | | | | | | | | When switching branches, we usually first try read-tree to make sure that we do not lose the local changes and then updated the HEAD using update-ref. However, we detached and updated HEAD before these checks, which was quite bad in a repository with local changes. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | git-checkout: safety check for detached HEAD checks existing refsJunio C Hamano2007-01-091-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | Checking for reachability from refs does not help much if the state we are currently on is somewhere in the middle. We will lose where we were. So this makes sureh that HEAD is something directly pointed at by one of the existing refs (most likely a tag for a user who has been "sightseeing"). Signed-off-by: Junio C Hamano <junkio@cox.net>
* | git-checkout: fix branch name output from the commandJunio C Hamano2007-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | When switching branches with "git checkout", we internally did $arg^0 (aka $arg^{commit}) suffix but there was no need to. The improvement is easily visible in the change to an existing test t/3200-branch.sh in this commit; it was expecting rather ugly message. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | git-checkout: safety when coming back from the detached HEAD state.Junio C Hamano2007-01-081-0/+18
| | | | | | | | | | | | | | | | | | After making commits in the detached HEAD state, if you run "git checkout" to switch to an existing branch, you will lose your work. Make sure the switched-to branch is a fast-forward of the current HEAD, or require -f when switching. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | git-checkout: rewording comments regarding detached HEAD.Junio C Hamano2007-01-081-9/+12
| | | | | | | | | | | | | | | | We used to say "you are not on a branch" before the initial commit. This is incorrect -- the user is on a branch yet to be born, but its name has been already determined. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | git-checkout: do not warn detaching HEAD when it is already detached.Junio C Hamano2007-01-081-3/+8
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Detached HEAD (experimental)Junio C Hamano2007-01-081-5/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows "git checkout v1.4.3" to dissociate the HEAD of repository from any branch. After this point, "git branch" starts reporting that you are not on any branch. You can go back to an existing branch by saying "git checkout master", for example. This is still experimental. While I think it makes sense to allow commits on top of detached HEAD, it is rather dangerous unless you are careful in the current form. Next "git checkout master" will obviously lose what you have done, so we might want to require "git checkout -f" out of a detached HEAD if we find that the HEAD commit is not an ancestor of any other branches. There is no such safety valve implemented right now. On the other hand, the reason the user did not start the ad-hoc work on a new branch with "git checkout -b" was probably because the work was of a throw-away nature, so the convenience of not having that safety valve might be even better. The user, after accumulating some commits on top of a detached HEAD, can always create a new branch with "git checkout -b" not to lose useful work done while the HEAD was detached. We'll see. Signed-off-by: Junio C Hamano <junkio@cox.net>
* checkout: make the message about the need for a new branch a bit clearerNicolas Pitre2006-12-221-2/+5
| | | | | Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Loosen "working file will be lost" check in Porcelain-ishJunio C Hamano2006-12-051-2/+3
| | | | | | | | This uses the previous update to read-tree in Porcelain-ish commands "git checkout" and "git merge" to loosen the check when switching branches. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-checkout: allow pathspec to recover lost working tree directoryJunio C Hamano2006-11-151-1/+5
| | | | | | | | | | | | | It is often wanted on the #git channel that this were to work to recover removed directory: rm -fr Documentation git checkout -- Documentation git checkout HEAD -- Documentation ;# alternatively Now it does. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-checkout: do not allow -f and -m at the same time.Junio C Hamano2006-11-151-0/+5
| | | | | | | Instead of silently ignoring one over the other, complain on this incompatible combination. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'master' into lj/refsJunio C Hamano2006-09-271-1/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (72 commits) runstatus: do not recurse into subdirectories if not needed grep: fix --fixed-strings combined with expression. grep: free expressions and patterns when done. Corrected copy-and-paste thinko in ignore executable bit test case. An illustration of rev-list --parents --pretty=raw Allow git-checkout when on a non-existant branch. gitweb: Decode long title for link tooltips git-svn: Fix fetch --no-ignore-externals with GIT_SVN_NO_LIB=1 Ignore executable bit when adding files if filemode=0. Remove empty ref directories that prevent creating a ref. Use const for interpolate arguments git-archive: update documentation Deprecate merge-recursive.py gitweb: fix over-eager application of esc_html(). Allow '(no author)' in git-svn's authors file. Allow 'svn fetch' on '(no date)' revisions in Subversion. git-repack: allow git-repack to run in subdirectory Remove upload-tar and make git-tar-tree a thin wrapper to git-archive git-tar-tree: Move code for git-archive --format=tar to archive-tar.c git-tar-tree: Remove duplicate git_config() call ...
| * Allow git-checkout when on a non-existant branch.Shawn Pearce2006-09-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've seen some users get into situtations where their HEAD symbolic-ref is pointing at a non-existant ref. (Sometimes this happens during clone when the remote repository lacks a 'master' branch.) If this happens the user is unable to use git-checkout to switch branches as there is no prior commit to merge from. So instead of giving the user low-level errors about how HEAD can't be resolved and how not a single revision was given change the type of checkout to be a force and go through with the user's request anyway. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Teach "git checkout" to use git-show-refLinus Torvalds2006-09-161-2/+3
|/ | | | | | | That way, it doesn't care how the refs are stored any more Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-checkout: allow "checkout HEAD -- path"Junio C Hamano2006-07-311-0/+4
| | | | | | | Even though -- is redundant in this case, we should allow it to prevent confusion. Signed-off-by: Junio C Hamano <junkio@cox.net>
* checkout -m: fix read-tree invocationv1.4.1-rc2Junio C Hamano2006-06-281-2/+1
| | | | | | | | When we updated "read-tree -m -u" to be careful about not removing untracked working tree files, we broke "checkout -m" to switch between branches. Signed-off-by: Junio C Hamano <junkio@cox.net>
* checkout -f: do not leave untracked working tree files.Junio C Hamano2006-06-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | Earlier we did not consider untracked working tree files "precious", but we have always considered them fair game to clobber. These days, branch switching by read-tree is more careful and tries to protect untracked working tree files. This caused the following workflow to stop working: git checkout one-branch-with-file-F git checkout -f another-without-file-F git pull . one-branch-with-file-F Because the second checkout leaves F from the previous state as untracked file in the working tree, the merge would fail, trying to protect F from being clobbered. This changes "git checkout -f" to remove working tree files that are known to git in the switched-from state but do not exist in the switched-to state, borrowing the same logic from "reset --hard". Signed-off-by: Junio C Hamano <junkio@cox.net>
* Test that git-branch -l works.Shawn Pearce2006-05-241-2/+2
| | | | | | | | | | | | | | | | | | If the user supplies -l to git-branch when creating a new branch then the new branch's log should be created automatically and the branch creation should be logged in that log. Further if a branch is being deleted and it had a log then also verify that the log was deleted. Test git-checkout -b foo -l for creating a new branch foo with a log and checking out that branch. Fixed git-checkout -b foo -l as the branch variable name was incorrect in the script. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Enable ref log creation in git checkout -b.Shawn Pearce2006-05-191-4/+15
| | | | | | | | | | | | | Switch git checkout -b to use git-update-ref rather than echo and a shell I/O redirection. This is more in line with typical GIT commands and allows -b to be logged according to the normal ref logging rules. Added -l option to allow users to create the ref log at the same time as creating a branch. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* checkout: use --aggressive when running a 3-way merge (-m).Junio C Hamano2006-05-091-1/+1
| | | | | | | | After doing an in-index 3-way merge, we always do the stock "merge-index merge-one-file" without doing anything fancy; use of --aggressive helps performance quite a bit. Signed-off-by: Junio C Hamano <junkio@cox.net>
* More useful/hinting error messages in git-checkoutv1.2.1Josef Weidendorfer2006-02-151-3/+10
| | | | | Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* checkout: fix dirty-file display.Junio C Hamano2006-02-141-2/+4
| | | | | | | When we refused to switch branches, we incorrectly showed differences from the branch we would have switched to. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-commit: show dirtiness including index.Junio C Hamano2006-02-121-1/+2
| | | | | | | | | | | | | Earlier, when we switched a branch we used diff-files to show paths that are dirty in the working tree. But we allow switching branches with updated index ("read-tree -m -u $old $new" works that way), and only showing paths that have differences in the working tree but not paths that are different in index was confusing. This shows both as modified from the top commit of the branch we just have switched to. Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] checkout: show dirty state upon switching branches.Junio C Hamano2006-01-141-0/+3
| | | | | | | | | This shows your working file state when you switch branches. As a side effect, "git checkout" without any branch name (i.e. stay on the current branch) becomes a more concise shorthand for the "git status" command. Signed-off-by: Junio C Hamano <junkio@cox.net>
* checkout: merge local modifications while switching branches.Junio C Hamano2006-01-131-22/+38
| | | | | | | | | | | | | | | | | | | * Instead of going interactive, introduce a command line switch '-m' to allow merging changes when normal two-way merge by read-tree prevents branch switching. * Leave the unmerged stages intact if automerge fails, but reset index entries of cleanly merged paths to that of the new branch, so that "git diff" (not "git diff HEAD") would show the local modifications. * Swap the order of trees in read-tree three-way merge used in the fallback, so that `git diff` to show the conflicts become more natural. * Describe the new option and give more examples in the documentation. Signed-off-by: Junio C Hamano <junkio@cox.net>
* checkout: automerge local changes while switching branches.Junio C Hamano2006-01-131-1/+27
| | | | | | | | | | | When switching branches, if the working tree has a local modification at paths that are different between current and new branches, we refused the operation saying "cannot merge." This attempts to do an automerge for such paths. This is still experimental. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Adjust to ls-tree --full-name when run from a subdirectory.Junio C Hamano2005-12-231-1/+1
|\ | | | | | | | | | | | | | | A proposed change to show cwd relative paths by default from ls-tree when run from a subdirectory means we would need to give --full-name option to it. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | checkout: sometimes work from a subdirectory.Junio C Hamano2005-12-221-0/+9
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | git-checkout does two very different things, and what they should do when run from subdirectory are quite different. It does not make any sense to run the one that switches the current head from anywhere other than the toplevel: git-checkout [-f] <branch> git-checkout [-b <branch>] <committish> We could of course chdir to top and do the whole-tree checkout in git-checkout, but the point is the operation does not make sense on a partial tree. The whole tree is checked out. The other form is to update the index file and working tree file selectively: git-checkout <treeish> <file>... ;# out of tree to index and file git-checkout -- <file>... ;# out of index to file This form _does_ make sense to run from subdirectory; and I myself often wish we supported this. So here is a patch to do both. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Comment fixes.Junio C Hamano2005-12-161-1/+1
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* Trivial usage string clean-upfreku045@student.liu.se2005-12-141-4/+2
| | | | | Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-sh-setup: die if outside git repository.Junio C Hamano2005-11-251-1/+1
| | | | | | | | Now all the users of this script detect its exit status and die, complaining that it is outside git repository. So move the code that dies from all callers to git-sh-setup script. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Teach update-index to read from ls-tree.Junio C Hamano2005-11-231-1/+0
| | | | | | | | | | | | git-update-index --index-info can almost be usable to read from ls-tree output to update the index (and not the working tree file) to HEAD commit, but not quite. It was designed to read from git-apply --index-info output, and does not want " blob " in ls-tree output. Accept that as well. This lets us update "git-checkout <ent> <path>" that used to filter the extra " blob " string out. Noted by Luben. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Do not fail on hierarchical branch names.Junio C Hamano2005-11-021-1/+3
| | | | | | | | | | | | "git-checkout -b frotz/nitfol master" failed to create $GIT_DIR/refs/heads/frotz/nitfol but went ahead and updated $GIT_DIR/HEAD to point at it, resulting in a corrupt repository. Exit when we cannot create the new branch with an error status. While we are at it, there is no reason to forbid subdirectories in refs/heads, so make sure we handle that correctly. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Add usage statement to git-checkout.shChris Shoemaker2005-10-301-0/+7
| | | | | Signed-off-by: Chris Shoemaker <c.shoemaker@cox.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-checkout: revert specific paths to either index or a given tree-ish.Junio C Hamano2005-10-181-15/+64
| | | | | | | | | | When extra paths arguments are given, git-checkout reverts only those paths to either the version recorded in the index or the version recorded in the given tree-ish. This has been on the TODO list for quite a while. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-check-ref-format: reject funny ref names.Junio C Hamano2005-10-151-0/+2
| | | | | | | | | | | | | | Update check_ref_format() function to reject ref names that: * has a path component that begins with a ".", or * has a double dots "..", or * has ASCII control character, "~", "^", ":" or SP, anywhere, or * ends with a "/". Use it in 'git-checkout -b', 'git-branch', and 'git-tag' to make sure that newly created refs are well-formed. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Add git-symbolic-refJunio C Hamano2005-10-011-1/+2
| | | | | | | | | | | | | This adds the counterpart of git-update-ref that lets you read and create "symbolic refs". By default it uses a symbolic link to represent ".git/HEAD -> refs/heads/master", but it can be compiled to use the textfile symbolic ref. The places that did 'readlink .git/HEAD' and 'ln -s refs/heads/blah .git/HEAD' have been converted to use new git-symbolic-ref command, so that they can deal with either implementation. Signed-off-by: Junio C Hamano <junio@twinsun.com>
* [PATCH] Remove total confusion from "git checkout"Linus Torvalds2005-09-191-1/+1
| | | | | | | | | | | | The target to check out does not need to be a branch. The _result_ of the checkout needs to be a branch. Don't confuse the two, and then insult the user. Insulting is ok, but I personally get really pissed off is a tool is both confused and insulting. At least be _correct_ and insulting. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] Make git-checkout failure message more friendly.Junio C Hamano2005-09-161-1/+2
| | | | | | ... or less so, perhaps ;-). Suggested by Jeff Garzik. Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] Make 'git checkout' a bit more forgiving when switching branches.Junio C Hamano2005-09-121-0/+1
| | | | | | | | | | | | | | | | | | If you make a commit on a path, and then make the path cache-dirty afterwards without changing its contents, 'git checkout' to switch to another branch is prevented because switching the branches done with 'read-tree -m -u $current $next' detects that the path is cache-dirty, but it does not bother noticing that the contents of the path has not been actualy changed. Since switching branches would involve checking out paths different in the two branches, hence it is reasonably expensive operation, we can afford to run update-index before running read-tree to reduce this kind of false change from triggering the check needlessly. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Big tool rename.Junio C Hamano2005-09-071-0/+76
As promised, this is the "big tool rename" patch. The primary differences since 0.99.6 are: (1) git-*-script are no more. The commands installed do not have any such suffix so users do not have to remember if something is implemented as a shell script or not. (2) Many command names with 'cache' in them are renamed with 'index' if that is what they mean. There are backward compatibility symblic links so that you and Porcelains can keep using the old names, but the backward compatibility support is expected to be removed in the near future. Signed-off-by: Junio C Hamano <junkio@cox.net>