summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
AgeCommit message (Collapse)Author
2011-08-16Merge branch 'jc/checkout-reflog-fix' into maintJunio C Hamano
* jc/checkout-reflog-fix: checkout: do not write bogus reflog entry out
2011-08-01Merge branch 'jc/maint-1.7.3-checkout-describe' into maintJunio C Hamano
* jc/maint-1.7.3-checkout-describe: checkout -b <name>: correctly detect existing branch
2011-07-06Merge commit 'v1.7.6' into jc/checkout-reflog-fixJunio C Hamano
* commit 'v1.7.6': (3211 commits) Git 1.7.6 completion: replace core.abbrevguard to core.abbrev Git 1.7.6-rc3 Documentation: git diff --check respects core.whitespace gitweb: 'pickaxe' and 'grep' features requires 'search' to be enabled t7810: avoid unportable use of "echo" plug a few coverity-spotted leaks builtin/gc.c: add missing newline in message tests: link shell libraries into valgrind directory t/Makefile: pass test opts to valgrind target properly sh-i18n--envsubst.c: do not #include getopt.h Fix typo: existant->existent Git 1.7.6-rc2 gitweb: do not misparse nonnumeric content tag files that contain a digit Git 1.7.6-rc1 fetch: do not leak a refspec t3703: skip more tests using colons in file names on Windows gitweb: Fix usability of $prevent_xss gitweb: Move "Requirements" up in gitweb/INSTALL gitweb: Describe CSSMIN and JSMIN in gitweb/INSTALL ...
2011-06-06checkout -b <name>: correctly detect existing branchJunio C Hamano
When create a new branch, we fed "refs/heads/<proposed name>" as a string to get_sha1() and expected it to fail when a branch already exists. The right way to check if a ref exists is to check with resolve_ref(). A naïve solution that might appear attractive but does not work is to forbid slashes in get_describe_name() but that will not work. A describe name is is in the form of "ANYTHING-g<short sha1>", and that ANYTHING part comes from a original tag name used in the repository the user ran the describe command. A sick user could have a confusing hierarchical tag whose name is "refs/heads/foobar" (stored as refs/tags/refs/heads/foobar") to generate a describe name "refs/heads/foobar-6-g02ac983", and we should be able to use that name to refer to the object whose name is 02ac983. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-31Merge branch 'jk/format-patch-am'Junio C Hamano
* jk/format-patch-am: format-patch: preserve subject newlines with -k clean up calling conventions for pretty.c functions pretty: add pp_commit_easy function for simple callers mailinfo: always clean up rfc822 header folding t: test subject handling in format-patch / am pipeline Conflicts: builtin/branch.c builtin/log.c commit.h
2011-05-26pretty: add pp_commit_easy function for simple callersJeff King
Many callers don't actually care about the pretty print context at all; let's just give them a simple way of pretty-printing a commit without having to create a context struct. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-06Merge branch 'nd/struct-pathspec'Junio C Hamano
* nd/struct-pathspec: pathspec: rename per-item field has_wildcard to use_wildcard Improve tree_entry_interesting() handling code Convert read_tree{,_recursive} to support struct pathspec Reimplement read_tree_recursive() using tree_entry_interesting()
2011-04-12i18n: mark checkout plural warning for translationÆvar Arnfjörð Bjarmason
Mark the "Warning: you are leaving %d commit(s) behind" message added in v1.7.5-rc0~74^2 (commit: give final warning when reattaching HEAD to leave commits behind) by Junio C Hamano for translation. This message requires the use of ngettext() features, and is the first message to use the Q_() wrapper around ngettext(). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-12i18n: mark checkout --detach messages for translationÆvar Arnfjörð Bjarmason
Mark messages added in v1.7.5-rc0~117^2~2 (checkout: introduce --detach synonym for "git checkout foo^{commit}") by Junio C Hamano for translation. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-02Merge branch 'ab/i18n-st'Junio C Hamano
* ab/i18n-st: (69 commits) i18n: git-shortlog basic messages i18n: git-revert split up "could not revert/apply" message i18n: git-revert literal "me" messages i18n: git-revert "Your local changes" message i18n: git-revert basic messages i18n: git-notes GIT_NOTES_REWRITE_MODE error message i18n: git-notes basic commands i18n: git-gc "Auto packing the repository" message i18n: git-gc basic messages i18n: git-describe basic messages i18n: git-clean clean.requireForce messages i18n: git-clean basic messages i18n: git-bundle basic messages i18n: git-archive basic messages i18n: git-status "renamed: " message i18n: git-status "Initial commit" message i18n: git-status "Changes to be committed" message i18n: git-status shortstatus messages i18n: git-status "nothing to commit" messages i18n: git-status basic messages ... Conflicts: builtin/branch.c builtin/checkout.c builtin/clone.c builtin/commit.c builtin/grep.c builtin/merge.c builtin/push.c builtin/revert.c t/t3507-cherry-pick-conflict.sh t/t7607-merge-overwrite.sh
2011-03-25Convert read_tree{,_recursive} to support struct pathspecNguyễn Thái Ngọc Duy
This patch changes behavior of the two functions. Previously it does prefix matching only. Now it can also do wildcard matching. All callers are updated. Some gain wildcard matching (archive, checkout), others reset pathspec_item.has_wildcard to retain old behavior (ls-files, ls-tree as they are plumbing). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-20checkout: tweak detached-orphan warning formatJeff King
When orphaning a commit on a detached HEAD, the warning currently looks like: Warning: you are leaving 3 commits behind, not connected to any of your branches: - commit subject 1 - commit subject 2 - commit subject 3 If you want to keep them by creating a new branch, this may be a good time to do so with: git branch new_branch_name 933a615ab0bc566dcfd8c01ec8af159f770d3fe5 Instead of using the "-" list, let's provide a more traditional oneline format, with the abbreviated sha1 before each subject. Users are accustomed to seeing commits in this format, and having the sha1 of each commit can be useful if you want to cherry-pick instead of creating a new branch. The new format looks like: Warning: you are leaving 3 commits behind, not connected to any of your branches: 933a615 commit subject 1 824fcde commit subject 2 fa49b1a commit subject 3 Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-20checkout: clear commit marks after detached-orphan checkJeff King
When leaving a detached HEAD, we do a revision walk to make sure the commit we are leaving isn't being orphaned. However, this leaves crufty marks in the commit objects which can confuse later walkers, like the one in stat_tracking_info. Let's clean up after ourselves to prevent this conflict. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-15Merge branch 'jc/checkout-orphan-warning'Junio C Hamano
* jc/checkout-orphan-warning: commit: give final warning when reattaching HEAD to leave commits behind
2011-03-10i18n: git-checkout "Switched to a .. branch" messageÆvar Arnfjörð Bjarmason
Split up the "Switched to and reset branch" and "Switched to a new branch" messages to make them easier to translate. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-10i18n: git-checkout "HEAD is now at" messageÆvar Arnfjörð Bjarmason
Gettextize the "HEAD is now at" messages. Several tests in t7201-co.sh explicitly checked for this message. Change them to skip under GETTEXT_POISON=YesPlease. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-10i18n: git-checkout describe_detached_head messagesÆvar Arnfjörð Bjarmason
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-10i18n: git-checkout: our/their version messageÆvar Arnfjörð Bjarmason
Split up the "does not have our/their version" message to make it easier to translate. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-10i18n: git-checkout basic messagesÆvar Arnfjörð Bjarmason
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-28Merge branch 'uk/checkout-ambiguous-ref'Junio C Hamano
* uk/checkout-ambiguous-ref: Rename t2019 with typo "amiguous" that meant "ambiguous" checkout: rearrange update_refs_for_switch for clarity checkout: introduce --detach synonym for "git checkout foo^{commit}" checkout: split off a function to peel away branchname arg checkout: fix bug with ambiguous refs Conflicts: builtin/checkout.c
2011-02-24commit: give final warning when reattaching HEAD to leave commits behindJunio C Hamano
You can detach the HEAD at an arbitrary commit in order to browse the files in various points in the history or build older versions of the software, without recording any new commit, and come back to an existing branch. When used in this "sightseer" mode, detached HEAD is a perfectly safe mechanism. It also is a useful state to experiment with throw-away commits. When coming back to an existing branch with "git checkout master", however, the commits that were created on the detached HEAD will become unreachable from anywhere but the reflog of the HEAD. Check if the commit we are about to leave is connected to some ref, and give a final warning otherwise to remind the user for safety. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-23checkout: add missing const to describe_detached_headJonathan Nieder
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-14correct type of EMPTY_TREE_SHA1_BINJonathan Nieder
Functions such as hashcmp that expect a binary SHA-1 value take parameters of type "unsigned char *" to avoid accepting a textual SHA-1 passed by mistake. Unfortunately, this means passing the string literal EMPTY_TREE_SHA1_BIN requires an ugly cast. Tweak the definition of EMPTY_TREE_SHA1_BIN to produce a value of more convenient type. In the future the definition might change to extern const unsigned char empty_tree_sha1_bin[20]; #define EMPTY_TREE_SHA1_BIN empty_tree_sha1_bin Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-08checkout: rearrange update_refs_for_switch for clarityJonathan Nieder
Take care of simple, exceptional cases before the meat of the "check out by branch name" code begins. After this change, the function vaguely follows the following pseudocode: if (-B or -b) create branch; if (plain "git checkout" or "git checkout HEAD") ; else if (--detach or checking out by non-branch commit name) detach HEAD; else if (checking out by branch name) attach HEAD; One nice side benefit is to make it possible to remove handling of the --detach option from outside switch_branches. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-08checkout: introduce --detach synonym for "git checkout foo^{commit}"Junio C Hamano
For example, one might use this when making a temporary merge to test that two topics work well together. Patch by Junio, with tests from Jeff King. [jn: with some extra checks for bogus commandline usage] Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-08checkout: split off a function to peel away branchname argJonathan Nieder
The code to parse and consume the tree name and "--" in commands such as "git checkout @{-1} -- '*.c'" is intimidatingly long. Split it out into a separate function and make it easier to skip on first reading by making the data it uses and produces more explicit. No functional change intended. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-01-11checkout: fix bug with ambiguous refsJunio C Hamano
The usual dwim_ref lookup prefers tags to branches. Because checkout primarily works on branches, though, we switch that behavior to prefer branches. However, there was a bug in the implementation in which we used lookup_commit_reference (which used the regular lookup rules) to get the actual commit to checkout. Checking out an ambiguous ref therefore ended up putting us in an extremely broken state in which we wrote the branch ref into HEAD, but actually checked out the tree for the tag. This patch fixes the bug by always attempting to pull the commit to be checked out from the branch-ified version of the name we were given. Patch by Junio, tests and commit message from Jeff King. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-24Merge branch 'rs/opt-help-text'Junio C Hamano
* rs/opt-help-text: verify-tag: document --verbose branch: improve --verbose description archive: improve --verbose description Describe various forms of "be quiet" using OPT__QUIET add OPT__FORCE add description parameter to OPT__QUIET add description parameter to OPT__DRY_RUN add description parameter to OPT__VERBOSE
2010-11-15Describe various forms of "be quiet" using OPT__QUIETJonathan Nieder
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-15add OPT__FORCERené Scharfe
Add OPT__FORCE as a helper macro in the same spirit as OPT__VERBOSE et.al. to simplify defining -f/--force options. Signed-off-by: Rene Scharfe <rene.scharfe@lstfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-15add description parameter to OPT__QUIETRené Scharfe
Allows better help text to be defined than "be quiet". Also make use of the macro in a place that already had a different description. No object code changes intended. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-03Change "tracking branch" to "remote-tracking branch"Matthieu Moy
One more step towards consistancy. We change the documentation and the C code in a single patch, since the only instances in the C code are in comment and usage strings. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-03Replace "remote tracking" with "remote-tracking"Matthieu Moy
"remote-tracking" branch makes it explicit that the branch is "tracking a remote", as opposed to "remote, and tracking something". See discussion in e.g. http://mid.gmane.org/8835ADF9-45E5-4A26-9F7F-A72ECC065BB2@gmail.com for more details. This patch is a straightforward application of perl -pi -e 's/remote tracking branch/remote-tracking branch/' except in the RelNotes directory. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-27Merge branch 'jf/merge-ignore-ws'Junio C Hamano
* jf/merge-ignore-ws: merge-recursive: options to ignore whitespace changes merge-recursive --patience ll-merge: replace flag argument with options struct merge-recursive: expose merge options for builtin merge
2010-09-27Improvements to `git checkout -h`Daniel Knittl-Frank
be a little more verbose about what each option does Signed-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-04Merge branch 'jl/submodule-ignore-diff'Junio C Hamano
* jl/submodule-ignore-diff: checkout: Use submodule.*.ignore settings from .git/config and .gitmodules checkout: Add test for diff.ignoreSubmodules checkout: respect diff.ignoreSubmodules setting Conflicts: builtin/checkout.c
2010-09-04Merge branch 'dg/local-mod-error-messages'Junio C Hamano
* dg/local-mod-error-messages: t7609-merge-co-error-msgs: test non-fast forward case too. Move "show_all_errors = 1" to setup_unpack_trees_porcelain() setup_unpack_trees_porcelain: take the whole options struct as parameter Move set_porcelain_error_msgs to unpack-trees.c and rename it Conflicts: merge-recursive.c
2010-09-03Merge branch 'jn/merge-renormalize'Junio C Hamano
* jn/merge-renormalize: merge-recursive --renormalize rerere: never renormalize rerere: migrate to parse-options API t4200 (rerere): modernize style ll-merge: let caller decide whether to renormalize ll-merge: make flag easier to populate Documentation/technical: document ll_merge merge-trees: let caller decide whether to renormalize merge-trees: push choice to renormalize away from low level t6038 (merge.renormalize): check that it can be turned off t6038 (merge.renormalize): try checkout -m and cherry-pick t6038 (merge.renormalize): style nitpicks Don't expand CRLFs when normalizing text during merge Try normalizing files to avoid delete/modify conflicts when merging Avoid conflicts when merging branches with mixed normalization Conflicts: builtin/rerere.c t/t4200-rerere.sh
2010-09-03Move "show_all_errors = 1" to setup_unpack_trees_porcelain()Matthieu Moy
Not only this makes the code clearer since setting up the porcelain error message is meant to work with show_all_errors, but this fixes a call to setup_unpack_trees_porcelain() in git_merge_trees() which did not set show_all_errors. add_rejected_path() used to double-check whether it was running in plumbing mode. This check was ineffective since it was setting show_all_errors too late for traverse_trees() to see it, and is made useless by this patch. Remove it. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-03setup_unpack_trees_porcelain: take the whole options struct as parameterMatthieu Moy
This is a preparation patch to let setup_unpack_trees_porcelain set show_all_errors itself. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-03Move set_porcelain_error_msgs to unpack-trees.c and rename itMatthieu Moy
The function is currently dealing only with error messages, but the intent of calling it is really to notify the unpack-tree mechanics that it is running in porcelain mode. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-30checkout: Use submodule.*.ignore settings from .git/config and .gitmodulesJens Lehmann
For "git status" and the diff family the submodule.*.ignore settings from .git/config and .gitmodules can be used to override the default set via diff.ignoreSubmodules on a per-submodule basis. Let's do this consistently and teach checkout to use these settings too. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-26ll-merge: replace flag argument with options structJonathan Nieder
Keeping track of the flag bits is proving more trouble than it's worth. Instead, use a pointer to an options struct like most similar APIs do. Callers with no special requests can pass NULL to request the default options. Cc: Bert Wesarg <bert.wesarg@googlemail.com> Cc: Avery Pennarun <apenwarr@gmail.com> Helped-by: Justin Frankel <justin@cockos.com> Helped-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-25checkout: respect diff.ignoreSubmodules settingJohannes Schindelin
When 'git checkout' reports uncommitted changes, it also does so for submodules. The default mode is now to look really hard into submodules, not only for different commits, but also for modified files. Since this can be pretty expensive when there are a lot (and large) submodules, there is the diff.ignoreSubmodules option. Let's respect that setting when 'git checkout' reports the uncommitted changes, since it does nothing else than a 'git diff --name-status'. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-22Merge branch 'dg/local-mod-error-messages'Junio C Hamano
* dg/local-mod-error-messages: t7609: test merge and checkout error messages unpack_trees: group error messages by type merge-recursive: distinguish "removed" and "overwritten" messages merge-recursive: porcelain messages for checkout Turn unpack_trees_options.msgs into an array + enum Conflicts: t/t3400-rebase.sh
2010-08-20builtin/checkout: Fix message when switching to an existing branchRamkumar Ramachandra
Fix "Switched to a new branch <name>" to read "Switched to branch <name>" when <name> corresponds to an existing branch. This bug was introduced in 02ac983 while introducing the `-B` switch. Cc: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-18Merge branch 'jn/fix-abbrev'Junio C Hamano
* jn/fix-abbrev: examples/commit: use --abbrev for commit summary checkout, commit: remove confusing assignments to rev.abbrev archive: abbreviate substituted commit ids again
2010-08-11unpack_trees: group error messages by typeMatthieu Moy
When an error is encountered, it calls add_rejected_file() which either - directly displays the error message and stops if in plumbing mode (i.e. if show_all_errors is not initialized at 1) - or stores it so that it will be displayed at the end with display_error_msgs(), Storing the files by error type permits to have a list of files for which there is the same error instead of having a serie of almost identical errors. As each bind_overlap error combines a file and an old file, a list cannot be done, therefore, theses errors are not stored but directly displayed. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11merge-recursive: porcelain messages for checkoutDiane Gasselin
A porcelain message was first added in checkout.c in the commit 8ccba008 (Junio C Hamano, Sat May 17 21:03:49 2008, unpack-trees: allow Porcelain to give different error messages) to give better feedback in the case of merge errors. This patch adapts the porcelain messages for the case of checkout instead. This way, when having a checkout error, "merge" no longer appears in the error message. While we're there, we add an advice in the case of would_lose_untracked_file. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11Turn unpack_trees_options.msgs into an array + enumMatthieu Moy
The list of error messages was introduced as a structure, but an array indexed over an enum is more flexible, since it allows one to store a type of error message (index in the array) in a variable. This change needs to rename would_lose_untracked -> would_lose_untracked_file to avoid a clash with the function would_lose_untracked in merge-recursive.c. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>