1. 21 8月, 2012 1 次提交
  2. 04 8月, 2012 1 次提交
    • T
      diff_setup_done(): return void · 28452655
      Thomas Rast 提交于
      diff_setup_done() has historically returned an error code, but lost
      the last nonzero return in 943d5b73 (allow diff.renamelimit to be set
      regardless of -M/-C, 2006-08-09).  The callers were in a pretty
      confused state: some actually checked for the return code, and some
      did not.
      
      Let it return void, and patch all callers to take this into account.
      This conveniently also gets rid of a handful of different(!) error
      messages that could never be triggered anyway.
      
      Note that the function can still die().
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28452655
  3. 26 7月, 2012 1 次提交
    • J
      checkout: don't confuse ref and object flags · add416a6
      Jeff King 提交于
      When we are leaving a detached HEAD, we do a revision traversal to
      check whether we are orphaning any commits, marking the commit we're
      leaving as the start of the traversal, and all existing refs as
      uninteresting.
      
      Prior to commit 468224e5, we did so by calling for_each_ref, and
      feeding each resulting refname to setup_revisions.  Commit 468224e5
      refactored this to simply mark the pending objects, saving an extra
      lookup.
      
      However, it confused the "flags" parameter to the each_ref_fn
      clalback, which is about the flags we found while looking up the ref
      with the object flag.  Because REF_ISSYMREF ("this ref is a symbolic
      ref, e.g. refs/remotes/origin/HEAD") happens to be the same bit
      pattern as SEEN ("we have picked this object up from the pending
      list and moved it to revs.commits list"), we incorrectly reported
      that a commit previously at the detached HEAD will become
      unreachable if the only ref that can reach the commit happens to be
      pointed at by a symbolic ref.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      add416a6
  4. 12 7月, 2012 1 次提交
    • T
      Strip namelen out of ce_flags into a ce_namelen field · b60e188c
      Thomas Gummerer 提交于
      Strip the name length from the ce_flags field and move it
      into its own ce_namelen field in struct cache_entry. This
      will both give us a tiny bit of a performance enhancement
      when working with long pathnames and is a refactoring for
      more readability of the code.
      
      It enhances readability, by making it more clear what
      is a flag, and where the length is stored and make it clear
      which functions use stages in comparisions and which only
      use the length.
      
      It also makes CE_NAMEMASK private, so that users don't
      mistakenly write the name length in the flags.
      Signed-off-by: NThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b60e188c
  5. 27 6月, 2012 1 次提交
  6. 25 5月, 2012 1 次提交
    • A
      checkout: no progress messages if !isatty(2). · e9fc64c6
      Avery Pennarun 提交于
      If stderr isn't a tty, we shouldn't be printing incremental progress
      messages.  In particular, this affects 'git checkout -f . >&logfile'
      unless you provided -q.  And git-new-workdir has no way to provide -q.
      
      It would probably be better to have progress.c check isatty(2) all the time,
      but that wouldn't allow things like 'git push --progress' to force progress
      reporting to on, so I won't try to solve the general case right now.
      
      Actual fix suggested by Jeff King.
      Signed-off-by: NAvery Pennarun <apenwarr@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e9fc64c6
  7. 09 5月, 2012 1 次提交
    • E
      checkout: do not corrupt HEAD on empty repo · 8338f771
      Erik Faye-Lund 提交于
      In abe19980 ("git checkout -b: allow switching out of an unborn
      branch"), a code-path overly-optimisticly assumed that a
      branch-name was specified. This is not always the case, and as
      a result a NULL-pointer was attempted printed to .git/HEAD.
      
      This could lead to at least two different failure modes:
       1) vsnprintf formated the NULL-string as something useful (e.g
          "(null)")
       2) vsnprintf crashed
      
      Neither were very convenient for formatting a new HEAD-reference.
      
      To fix this, reintroduce some strictness so we only take this
      new codepath if a banch-name was specified.
      Signed-off-by: NErik Faye-Lund <kusmabite@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8338f771
  8. 05 5月, 2012 1 次提交
  9. 27 3月, 2012 1 次提交
  10. 07 2月, 2012 1 次提交
    • J
      git checkout -b: allow switching out of an unborn branch · abe19980
      Junio C Hamano 提交于
      Running "git checkout -b another" immediately after "git init" when you do
      not even have a commit on 'master' fails with:
      
          $ git checkout -b another
          fatal: You are on a branch yet to be born
      
      This is unnecessary, if we redefine "git checkout -b $name" that does not
      take any $start_point (which has to be a commit) as "I want to check out a
      new branch $name from the state I am in".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      abe19980
  11. 17 1月, 2012 1 次提交
  12. 16 12月, 2011 1 次提交
    • J
      checkout_merged(): squelch false warning from some gcc · 335c6e40
      Junio C Hamano 提交于
      gcc 4.6.2 (there may be others) does not realize that the variable "mode"
      can never be used uninitialized in this function and issues a false warning
      under -Wuninitialized option.
      
      Squelch it with an unnecessary initialization; it is not like a single
      assignment matters to the performance in this codepath that writes out
      to the filesystem with checkout_entry() anyway.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      335c6e40
  13. 14 12月, 2011 1 次提交
  14. 07 12月, 2011 1 次提交
  15. 06 12月, 2011 1 次提交
    • N
      Copy resolve_ref() return value for longer use · d5a35c11
      Nguyễn Thái Ngọc Duy 提交于
      resolve_ref() may return a pointer to a static buffer. Callers that
      use this value longer than a couple of statements should copy the
      value to avoid some hidden resolve_ref() call that may change the
      static buffer's value.
      
      The bug found by Tony Wang <wwwjfy@gmail.com> in builtin/merge.c
      demonstrates this. The first call is in cmd_merge()
      
      branch = resolve_ref("HEAD", head_sha1, 0, &flag);
      
      Then deep in lookup_commit_or_die() a few lines after, resolve_ref()
      may be called again and destroy "branch".
      
      lookup_commit_or_die
       lookup_commit_reference
        lookup_commit_reference_gently
         parse_object
          lookup_replace_object
           do_lookup_replace_object
            prepare_replace_object
             for_each_replace_ref
              do_for_each_ref
               get_loose_refs
                get_ref_dir
                 get_ref_dir
                  resolve_ref
      
      All call sites are checked and made sure that xstrdup() is called if
      the value should be saved.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d5a35c11
  16. 29 11月, 2011 3 次提交
  17. 14 11月, 2011 1 次提交
  18. 06 10月, 2011 1 次提交
    • M
      Change check_ref_format() to take a flags argument · 8d9c5010
      Michael Haggerty 提交于
      Change check_ref_format() to take a flags argument that indicates what
      is acceptable in the reference name (analogous to "git
      check-ref-format"'s "--allow-onelevel" and "--refspec-pattern").  This
      is more convenient for callers and also fixes a failure in the test
      suite (and likely elsewhere in the code) by enabling "onelevel" and
      "refspec-pattern" to be allowed independently of each other.
      
      Also rename check_ref_format() to check_refname_format() to make it
      obvious that it deals with refnames rather than references themselves.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8d9c5010
  19. 04 10月, 2011 3 次提交
  20. 01 10月, 2011 1 次提交
    • J
      checkout $tree $path: do not clobber local changes in $path not in $tree · 0a1283bc
      Junio C Hamano 提交于
      Checking paths out of a tree is (currently) defined to do:
      
       - Grab the paths from the named tree that match the given pathspec,
         and add them to the index;
      
       - Check out the contents from the index for paths that match the
         pathspec to the working tree; and while at it
      
       - If the given pathspec did not match anything, suspect a typo from the
         command line and error out without updating the index nor the working
         tree.
      
      Suppose that the branch you are working on has dir/myfile, and the "other"
      branch has dir/other but not dir/myfile. Further imagine that you have
      either modified or removed dir/myfile in your working tree, but you have
      not run "git add dir/myfile" or "git rm dir/myfile" to tell Git about your
      local change. Running
      
       $ git checkout other dir
      
      would add dir/other to the index with the contents taken out of the
      "other" branch, and check out the paths from the index that match the
      pathspec "dir", namely, "dir/other" and "dir/myfile", overwriting your
      local changes to "dir/myfile", even though "other" branch does not even
      know about that file.
      
      Fix it by updating the working tree only with the index entries that
      was read from the "other" tree.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0a1283bc
  21. 17 9月, 2011 1 次提交
    • J
      branch --set-upstream: regression fix · fa799376
      Junio C Hamano 提交于
      The "git branch" command, while not in listing mode, calls create_branch()
      even when the target branch already exists, and it does so even when it is
      not interested in updating the value of the branch (i.e. the name of the
      commit object that sits at the tip of the existing branch). This happens
      when the command is run with "--set-upstream" option.
      
      The earlier safety-measure to prevent "git branch -f $branch $commit" from
      updating the currently checked out branch did not take it into account,
      and we no longer can update the tracking information of the current branch.
      
      Minimally fix this regression by telling the validation code if it is
      called to really update the value of a potentially existing branch, or if
      the caller merely is interested in updating auxiliary aspects of a branch.
      
      Reported-and-Tested-by: Jay Soffian
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fa799376
  22. 15 9月, 2011 1 次提交
  23. 23 8月, 2011 1 次提交
    • C
      Prevent force-updating of the current branch · 55c4a673
      Conrad Irwin 提交于
      "git branch -M <foo> <current-branch>" allows updating the current branch
      which HEAD points, without the necessary house-keeping that git reset
      normally does to make this operation sensible. It also leaves the reflog
      in a confusing state (you would be warned when trying to read it).
      
      "git checkout -B <current branch> <foo>" is also partly vulnerable to this
      bug; due to inconsistent pre-flight checks it would perform half of its
      task and then abort just before rewriting the branch. Again this
      manifested itself as the index file getting out-of-sync with HEAD.
      
      "git branch -f" already guarded against this problem, and aborts with
      a fatal error.
      
      Update "git branch -M", "git checkout -B" and "git branch -f" to share the
      same check before allowing a branch to be created. These prevent you from
      updating the current branch.
      
      We considered suggesting the use of "git reset" in the failure message
      but concluded that it was not possible to discern what the user was
      actually trying to do.
      Signed-off-by: NConrad Irwin <conrad.irwin@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      55c4a673
  24. 12 8月, 2011 1 次提交
    • C
      ls-files: fix pathspec display on error · 0f64bfa9
      Clemens Buchacher 提交于
      The following sequence of commands reveals an issue with error
      reporting of relative paths:
      
       $ mkdir sub
       $ cd sub
       $ git ls-files --error-unmatch ../bbbbb
       error: pathspec 'b' did not match any file(s) known to git.
       $ git commit --error-unmatch ../bbbbb
       error: pathspec 'b' did not match any file(s) known to git.
      
      This bug is visible only if the normalized path (i.e., the relative
      path from the repository root) is longer than the prefix.
      Otherwise, the code skips over the normalized path and reads from
      an unused memory location which still contains a leftover of the
      original command line argument.
      
      So instead, use the existing facilities to deal with relative paths
      correctly.
      
      Also fix inconsistency between "checkout" and "commit", e.g.
      
          $ cd Documentation
          $ git checkout nosuch.txt
          error: pathspec 'Documentation/nosuch.txt' did not match...
          $ git commit nosuch.txt
          error: pathspec 'nosuch.txt' did not match...
      
      by propagating the prefix down the codepath that reports the error.
      Signed-off-by: NClemens Buchacher <drizzd@aon.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0f64bfa9
  25. 06 6月, 2011 1 次提交
    • J
      checkout -b <name>: correctly detect existing branch · c17b2294
      Junio 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-g02ac9837", and we should
      be able to use that name to refer to the object whose name is 02ac9837.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c17b2294
  26. 27 5月, 2011 1 次提交
  27. 25 5月, 2011 1 次提交
    • J
      checkout: make advice when reattaching the HEAD less loud · f807b3dc
      Junio C Hamano 提交于
      When switching away from a detached HEAD with "git checkout", we give a
      listing of the commits about to be lost, and then tell how to resurrect
      them since 8e2dc6ac (commit: give final warning when reattaching HEAD to
      leave commits behind, 2011-02-18).
      
      This is a good safety measure for people who are not comfortable with the
      detached HEAD state, but the advice on how to keep the state you just left
      was given even to those who set advice.detachedHead to false.
      
      Keep the warning and informational commit listing, but honor the setting
      of advice.detachedHead to squelch the advice.
      Helped-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f807b3dc
  28. 12 4月, 2011 2 次提交
  29. 26 3月, 2011 1 次提交
  30. 21 3月, 2011 2 次提交
    • J
      checkout: tweak detached-orphan warning format · 0be240cc
      Jeff 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: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0be240cc
    • J
      checkout: clear commit marks after detached-orphan check · 5c08dc48
      Jeff 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: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5c08dc48
  31. 10 3月, 2011 4 次提交