1. 02 4月, 2019 2 次提交
  2. 24 2月, 2019 1 次提交
  3. 24 1月, 2019 1 次提交
  4. 09 1月, 2019 1 次提交
    • T
      checkout: introduce --{,no-}overlay option · 091e04bc
      Thomas Gummerer 提交于
      Currently 'git checkout' is defined as an overlay operation, which
      means that if in 'git checkout <tree-ish> -- [<pathspec>]' we have an
      entry in the index that matches <pathspec>, but that doesn't exist in
      <tree-ish>, that entry will not be removed from the index or the
      working tree.
      
      Introduce a new --{,no-}overlay option, which allows using 'git
      checkout' in non-overlay mode, thus removing files from the working
      tree if they do not exist in <tree-ish> but match <pathspec>.
      
      Note that 'git checkout -p <tree-ish> -- [<pathspec>]' already works
      this way, so no changes are needed for the patch mode.  We disallow
      'git checkout --overlay -p' to avoid confusing users who would expect
      to be able to force overlay mode in 'git checkout -p' this way.
      
      Untracked files are not affected by this change, so 'git checkout
      --no-overlay HEAD -- untracked' will not remove untracked from the
      working tree.  This is so e.g. 'git checkout --no-overlay HEAD -- dir/'
      doesn't delete all untracked files in dir/, but rather just resets the
      state of files that are known to git.
      Suggested-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      091e04bc
  5. 14 11月, 2018 1 次提交
    • N
      checkout: disambiguate dwim tracking branches and local files · be4908f1
      Nguyễn Thái Ngọc Duy 提交于
      When checkout dwim is added in [1], it is restricted to only dwim when
      certain conditions are met and fall back to default checkout behavior
      otherwise. It turns out falling back could be confusing. One of the
      conditions to turn
      
          git checkout frotz
      
      to
      
          git checkout -b frotz origin/frotz
      
      is that frotz must not exist as a file. But when the user comes to
      expect "git checkout frotz" to create the branch "frotz" and there
      happens to be a file named "frotz", git's silently reverting "frotz"
      file content is not helping. This is reported in Git mailing list [2]
      and even used as an example of "Git is bad" elsewhere [3].
      
      We normally try to do the right thing, but when there are multiple
      "right things" to do, it's best to leave it to the user to decide.
      Check this case, ask the user to to disambiguate:
      
      - "git checkout -- foo" will check out path "foo"
      - "git checkout foo --" will dwim and create branch "foo" [4]
      
      For users who do not want dwim, use --no-guess. It's useless in this
      particular case because "git checkout --no-guess foo --" will just
      fail. But it could be used by scripts.
      
      [1] 70c9ac2f (DWIM "git checkout frotz" to "git checkout -b frotz
          origin/frotz" - 2009-10-18)
      [2] https://public-inbox.org/git/CACsJy8B2TVr1g+k+eSQ=pBEO3WN4_LtgLo9gpur8X7Z9GOFL_A@mail.gmail.com/
      [3] https://news.ycombinator.com/item?id=18230655
      [4] a047fafc (checkout: allow dwim for branch creation for "git
          checkout $branch --" - 2013-10-18)
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      be4908f1
  6. 23 10月, 2018 1 次提交
  7. 12 6月, 2018 1 次提交
    • Æ
      checkout & worktree: introduce checkout.defaultRemote · 8d7b558b
      Ævar Arnfjörð Bjarmason 提交于
      Introduce a checkout.defaultRemote setting which can be used to
      designate a remote to prefer (via checkout.defaultRemote=origin) when
      running e.g. "git checkout master" to mean origin/master, even though
      there's other remotes that have the "master" branch.
      
      I want this because it's very handy to use this workflow to checkout a
      repository and create a topic branch, then get back to a "master" as
      retrieved from upstream:
      
          (
              cd /tmp &&
              rm -rf tbdiff &&
              git clone git@github.com:trast/tbdiff.git &&
              cd tbdiff &&
              git branch -m topic &&
              git checkout master
          )
      
      That will output:
      
          Branch 'master' set up to track remote branch 'master' from 'origin'.
          Switched to a new branch 'master'
      
      But as soon as a new remote is added (e.g. just to inspect something
      from someone else) the DWIMery goes away:
      
          (
              cd /tmp &&
              rm -rf tbdiff &&
              git clone git@github.com:trast/tbdiff.git &&
              cd tbdiff &&
              git branch -m topic &&
              git remote add avar git@github.com:avar/tbdiff.git &&
              git fetch avar &&
              git checkout master
          )
      
      Will output (without the advice output added earlier in this series):
      
          error: pathspec 'master' did not match any file(s) known to git.
      
      The new checkout.defaultRemote config allows me to say that whenever
      that ambiguity comes up I'd like to prefer "origin", and it'll still
      work as though the only remote I had was "origin".
      
      Also adjust the advice.checkoutAmbiguousRemoteBranchName message to
      mention this new config setting to the user, the full output on my
      git.git is now (the last paragraph is new):
      
          $ ./git --exec-path=$PWD checkout master
          error: pathspec 'master' did not match any file(s) known to git.
          hint: 'master' matched more than one remote tracking branch.
          hint: We found 26 remotes with a reference that matched. So we fell back
          hint: on trying to resolve the argument as a path, but failed there too!
          hint:
          hint: If you meant to check out a remote tracking branch on, e.g. 'origin',
          hint: you can do so by fully qualifying the name with the --track option:
          hint:
          hint:     git checkout --track origin/<name>
          hint:
          hint: If you'd like to always have checkouts of an ambiguous <name> prefer
          hint: one remote, e.g. the 'origin' remote, consider setting
          hint: checkout.defaultRemote=origin in your config.
      
      I considered splitting this into checkout.defaultRemote and
      worktree.defaultRemote, but it's probably less confusing to break our
      own rules that anything shared between config should live in core.*
      than have two config settings, and I couldn't come up with a short
      name under core.* that made sense (core.defaultRemoteForCheckout?).
      
      See also 70c9ac2f ("DWIM "git checkout frotz" to "git checkout -b
      frotz origin/frotz"", 2009-10-18) which introduced this DWIM feature
      to begin with, and 4e853331 ("worktree: make add <path> <branch>
      dwim", 2017-11-26) which added it to git-worktree.
      Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8d7b558b
  8. 28 11月, 2017 1 次提交
  9. 11 10月, 2017 1 次提交
    • J
      checkout doc: clarify command line args for "checkout paths" mode · b59698ae
      Junio C Hamano 提交于
      There are "git checkout [-p][<tree-ish>][--][<paths>...]" in the
      SYNOPSIS section, and "git checkout [-p][<tree-ish>][--]<paths>..."
      as the header for the section that explains the "check out paths
      from index/tree-ish" mode.  It is unclear if we require at least one
      path, or it is entirely optional.
      
      Actually, both are wrong.  Without the "-p(atch)" option, you must
      have <pathspec> (otherwise, with a commit that is a <tree-ish>, you
      would be checking out that commit to build a new history on top of
      it).  With it, it is already clear that you are checking out paths,
      it is optional.  In other words, you cannot omit both.
      
      The source of the confusion is that -p(atch) is described as if it
      is just another "optional" part and its description is lumped
      together with the non patch mode, even though the actual end user
      experience is vastly different.
      
      Let's split the entry into two, and describe the regular mode and
      the patch mode separately.  This allows us to make it clear that the
      regular mode MUST be given at least one pathspec, that the patch
      mode can be invoked with either '-p' or '--patch' but one of these
      must be given, and that the pathspec is entirely optional in the
      patch mode.
      
      Also, revamp the explanation of "checkout paths" by removing
      extraneous description at the beginning, that says "checking out
      paths is not checking out a branch".  Explaining what it is for and
      when the user wants to use it upfront is the most direct way to help
      the readers.
      
      Noticed-by: Robert P J Day
      Helped-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b59698ae
  10. 14 9月, 2017 1 次提交
  11. 29 7月, 2017 1 次提交
  12. 17 3月, 2017 1 次提交
  13. 21 9月, 2016 1 次提交
  14. 28 6月, 2016 1 次提交
  15. 02 11月, 2015 1 次提交
  16. 13 7月, 2015 2 次提交
  17. 08 7月, 2015 1 次提交
  18. 07 7月, 2015 3 次提交
  19. 18 6月, 2015 1 次提交
  20. 14 3月, 2015 1 次提交
  21. 08 1月, 2015 2 次提交
  22. 02 12月, 2014 3 次提交
  23. 22 1月, 2014 1 次提交
  24. 12 9月, 2013 1 次提交
  25. 22 4月, 2013 1 次提交
    • J
      checkout: Use remote refspecs when DWIMming tracking branches · fa83a33b
      Johan Herland 提交于
      The DWIM mode of checkout allows you to run "git checkout foo" when there
      is no existing local ref or path called "foo", and there is exactly _one_
      remote with a remote-tracking branch called "foo". Git will automatically
      create a new local branch called "foo" using the remote-tracking "foo" as
      its starting point and configured upstream.
      
      For example, consider the following unconventional (but perfectly valid)
      remote setup:
      
      	[remote "origin"]
      		fetch = refs/heads/*:refs/remotes/origin/*
      	[remote "frotz"]
      		fetch = refs/heads/*:refs/remotes/frotz/nitfol/*
      
      Case 1: Assume both "origin" and "frotz" have remote-tracking branches called
      "foo", at "refs/remotes/origin/foo" and "refs/remotes/frotz/nitfol/foo"
      respectively. In this case "git checkout foo" should fail, because there is
      more than one remote with a "foo" branch.
      
      Case 2: Assume only "frotz" have a remote-tracking branch called "foo". In
      this case "git checkout foo" should succeed, and create a local branch "foo"
      from "refs/remotes/frotz/nitfol/foo", using remote branch "foo" from "frotz"
      as its upstream.
      
      The current code hardcodes the assumption that all remote-tracking branches
      must match the "refs/remotes/$remote/*" pattern (which is true for remotes
      with "conventional" refspecs, but not true for the "frotz" remote above).
      When running "git checkout foo", the current code looks for exactly one ref
      matching "refs/remotes/*/foo", hence in the above example, it fails to find
      "refs/remotes/frotz/nitfol/foo", which causes it to fail both case #1 and #2.
      
      The better way to handle the above example is to actually study the fetch
      refspecs to deduce the candidate remote-tracking branches for "foo"; i.e.
      assume "foo" is a remote branch being fetched, and then map "refs/heads/foo"
      through the refspecs in order to get the corresponding remote-tracking
      branches "refs/remotes/origin/foo" and "refs/remotes/frotz/nitfol/foo".
      Finally we check which of these happens to exist in the local repo, and
      if there is exactly one, we have an unambiguous match for "git checkout foo",
      and may proceed.
      
      This fixes most of the failing tests introduced in the previous patch.
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fa83a33b
  26. 15 4月, 2013 1 次提交
  27. 02 2月, 2013 1 次提交
  28. 19 12月, 2012 2 次提交
  29. 04 9月, 2012 1 次提交
  30. 27 8月, 2012 1 次提交
  31. 27 4月, 2012 1 次提交
    • J
      docs: stop using asciidoc no-inline-literal · 6cf378f0
      Jeff King 提交于
      In asciidoc 7, backticks like `foo` produced a typographic
      effect, but did not otherwise affect the syntax. In asciidoc
      8, backticks introduce an "inline literal" inside which markup
      is not interpreted. To keep compatibility with existing
      documents, asciidoc 8 has a "no-inline-literal" attribute to
      keep the old behavior. We enabled this so that the
      documentation could be built on either version.
      
      It has been several years now, and asciidoc 7 is no longer
      in wide use. We can now decide whether or not we want
      inline literals on their own merits, which are:
      
        1. The source is much easier to read when the literal
           contains punctuation. You can use `master~1` instead
           of `master{tilde}1`.
      
        2. They are less error-prone. Because of point (1), we
           tend to make mistakes and forget the extra layer of
           quoting.
      
      This patch removes the no-inline-literal attribute from the
      Makefile and converts every use of backticks in the
      documentation to an inline literal (they must be cleaned up,
      or the example above would literally show "{tilde}" in the
      output).
      
      Problematic sites were found by grepping for '`.*[{\\]' and
      examined and fixed manually. The results were then verified
      by comparing the output of "html2text" on the set of
      generated html pages. Doing so revealed that in addition to
      making the source more readable, this patch fixes several
      formatting bugs:
      
        - HTML rendering used the ellipsis character instead of
          literal "..." in code examples (like "git log A...B")
      
        - some code examples used the right-arrow character
          instead of '->' because they failed to quote
      
        - api-config.txt did not quote tilde, and the resulting
          HTML contained a bogus snippet like:
      
            <tt><sub></tt> foo <tt></sub>bar</tt>
      
          which caused some parsers to choke and omit whole
          sections of the page.
      
        - git-commit.txt confused ``foo`` (backticks inside a
          literal) with ``foo'' (matched double-quotes)
      
        - mentions of `A U Thor <author@example.com>` used to
          erroneously auto-generate a mailto footnote for
          author@example.com
      
        - the description of --word-diff=plain incorrectly showed
          the output as "[-removed-] and {added}", not "{+added+}".
      
        - using "prime" notation like:
      
            commit `C` and its replacement `C'`
      
          confused asciidoc into thinking that everything between
          the first backtick and the final apostrophe were meant
          to be inside matched quotes
      
        - asciidoc got confused by the escaping of some of our
          asterisks. In particular,
      
            `credential.\*` and `credential.<url>.\*`
      
          properly escaped the asterisk in the first case, but
          literally passed through the backslash in the second
          case.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6cf378f0
  32. 06 5月, 2011 1 次提交