1. 01 7月, 2017 13 次提交
  2. 17 6月, 2017 1 次提交
  3. 16 6月, 2017 1 次提交
  4. 14 6月, 2017 1 次提交
  5. 05 6月, 2017 1 次提交
  6. 02 6月, 2017 6 次提交
  7. 26 5月, 2017 1 次提交
    • N
      use xfopen() in more places · 23a9e071
      Nguyễn Thái Ngọc Duy 提交于
      xfopen()
      
       - provides error details
       - explains error on reading, or writing, or whatever operation
       - has l10n support
       - prints file name in the error
      
      Some of these are missing in the places that are replaced with xfopen(),
      which is a clear win. In some other places, it's just less code (not as
      clearly a win as the previous case but still is).
      
      The only slight regresssion is in remote-testsvn, where we don't report
      the file class (marks files) in the error messages anymore. But since
      this is a _test_ svn remote transport, I'm not too concerned.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      23a9e071
  8. 24 5月, 2017 1 次提交
  9. 09 5月, 2017 2 次提交
    • S
      diff: enable indent heuristic by default · 33de7163
      Stefan Beller 提交于
      The feature was included in v2.11 (released 2016-11-29) and we got no
      negative feedback. Quite the opposite, all feedback we got was positive.
      
      Turn it on by default. Users who dislike the feature can turn it off
      by setting diff.indentHeuristic (which also configures plumbing commands,
      see prior patches).
      
      The change to t/t4051-diff-function-context.sh is needed because the
      heuristic shifts the changed hunk in the patch.  To get the same result
      regardless of the heuristic configuration, we modify the test file
      differently:  We insert a completely new line after line 2, instead of
      simply duplicating it.
      Helped-by: NJeff King <peff@peff.net>
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NMarc Branchaud <marcnarc@xiplink.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      33de7163
    • M
      diff: make the indent heuristic part of diff's basic configuration · cf5e7722
      Marc Branchaud 提交于
      This heuristic was originally introduced as an experimental feature,
      and therefore part of the UI configuration.
      
      But the user often sees diffs generated by plumbing commands like
      diff-tree.  Moving the indent heuristic into diff's basic configuration
      prepares the way for diff plumbing commands to respect the setting.
      
      The heuristic itself merely makes the diffs more aesthetically
      pleasing, without changing their correctness.  Scripts that rely on
      the diff plumbing commands should not care whether or not the heuristic
      is employed.
      Signed-off-by: NMarc Branchaud <marcnarc@xiplink.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cf5e7722
  10. 08 5月, 2017 1 次提交
  11. 01 5月, 2017 1 次提交
  12. 31 3月, 2017 1 次提交
    • J
      diff: avoid fixed-size buffer for patch-ids · 977db6b4
      Jeff King 提交于
      To generate a patch id, we format the diff header into a
      fixed-size buffer, and then feed the result to our sha1
      computation. The fixed buffer has size '4*PATH_MAX + 20',
      which in theory accommodates the four filenames plus some
      extra data. Except:
      
        1. The filenames may not be constrained to PATH_MAX. The
           static value may not be a real limit on the current
           filesystem. Moreover, we may compute patch-ids for
           names stored only in git, without touching the current
           filesystem at all.
      
        2. The 20 bytes is not nearly enough to cover the
           extra content we put in the buffer.
      
      As a result, the data we feed to the sha1 computation may be
      truncated, and it's possible that a commit with a very long
      filename could erroneously collide in the patch-id space
      with another commit. For instance, if one commit modified
      "really-long-filename/foo" and another modified "bar" in the
      same directory.
      
      In practice this is unlikely. Because the filenames are
      repeated, and because there's a single cutoff at the end of
      the buffer, the offending filename would have to be on the
      order of four times larger than PATH_MAX.
      
      We could fix this by moving to a strbuf. However, we can
      observe that the purpose of formatting this in the first
      place is to feed it to git_SHA1_Update(). So instead, let's
      just feed each part of the formatted string directly. This
      actually ends up more readable, and we can even factor out
      some duplicated bits from the various conditional branches.
      
      Technically this may change the output of patch-id for very
      long filenames, but it's not worth making an exception for
      this in the --stable output. It was a bug, and one that only
      affected an unlikely set of paths.  And anyway, the exact
      value would have varied from platform to platform depending
      on the value of PATH_MAX, so there is no "stable" value.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      977db6b4
  13. 27 3月, 2017 1 次提交
  14. 22 3月, 2017 2 次提交
    • J
      prefix_filename: return newly allocated string · e4da43b1
      Jeff King 提交于
      The prefix_filename() function returns a pointer to static
      storage, which makes it easy to use dangerously. We already
      fixed one buggy caller in hash-object recently, and the
      calls in apply.c are suspicious (I didn't dig in enough to
      confirm that there is a bug, but we call the function once
      in apply_all_patches() and then again indirectly from
      parse_chunk()).
      
      Let's make it harder to get wrong by allocating the return
      value. For simplicity, we'll do this even when the prefix is
      empty (and we could just return the original file pointer).
      That will cause us to allocate sometimes when we wouldn't
      otherwise need to, but this function isn't called in
      performance critical code-paths (and it already _might_
      allocate on any given call, so a caller that cares about
      performance is questionable anyway).
      
      The downside is that the callers need to remember to free()
      the result to avoid leaking. Most of them already used
      xstrdup() on the result, so we know they are OK. The
      remainder have been converted to use free() as appropriate.
      
      I considered retaining a prefix_filename_unsafe() for cases
      where we know the static lifetime is OK (and handling the
      cleanup is awkward). This is only a handful of cases,
      though, and it's not worth the mental energy in worrying
      about whether the "unsafe" variant is OK to use in any
      situation.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e4da43b1
    • J
      prefix_filename: drop length parameter · 116fb64e
      Jeff King 提交于
      This function takes the prefix as a ptr/len pair, but in
      every caller the length is exactly strlen(ptr). Let's
      simplify the interface and just take the string. This saves
      callers specifying it (and in some cases handling a NULL
      prefix).
      
      In a handful of cases we had the length already without
      calling strlen, so this is technically slower. But it's not
      likely to matter (after all, if the prefix is non-empty
      we'll allocate and copy it into a buffer anyway).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      116fb64e
  15. 03 3月, 2017 1 次提交
    • J
      diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec() · 12426e11
      Junio C Hamano 提交于
      Callers of diff_populate_filespec() can choose to ask only for the
      size of the blob without grabbing the blob data, and the function,
      after running lstat() when the filespec points at a working tree
      file, returns by copying the value in size field of the stat
      structure into the size field of the filespec when this is the case.
      
      However, this short-cut cannot be taken if the contents from the
      path needs to go through convert_to_git(), whose resulting real blob
      data may be different from what is in the working tree file.
      
      As "git diff --quiet" compares the .size fields of filespec
      structures to skip content comparison, this bug manifests as a
      false "there are differences" for a file that needs eol conversion,
      for example.
      Reported-by: NMike Crowe <mac@mcrowe.com>
      Helped-by: NTorsten Bögershausen <tboegi@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      12426e11
  16. 09 2月, 2017 1 次提交
    • J
      diff: print line prefix for --name-only output · f5022b5f
      Jeff King 提交于
      If you run "git log --graph --name-only", the pathnames are
      not indented to go along with their matching commits (unlike
      all of the other diff formats). We need to output the line
      prefix for each item before writing it.
      
      The tests cover both --name-status and --name-only. The
      former actually gets this right already, because it builds
      on the --raw format functions. It's only --name-only which
      uses its own code (and this fix mirrors the code in
      diff_flush_raw()).
      
      Note that the tests don't follow our usual style of setting
      up the "expect" output inside the test block. This matches
      the surrounding style, but more importantly it is easier to
      read: we don't have to worry about embedded single-quotes,
      and the leading indentation is more obvious.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f5022b5f
  17. 31 1月, 2017 3 次提交
  18. 13 1月, 2017 1 次提交
  19. 24 12月, 2016 1 次提交
    • J
      diff: retire "compaction" heuristics · 3cde4e02
      Junio C Hamano 提交于
      When a patch inserts a block of lines, whose last lines are the
      same as the existing lines that appear before the inserted block,
      "git diff" can choose any place between these existing lines as the
      boundary between the pre-context and the added lines (adjusting the
      end of the inserted block as appropriate) to come up with variants
      of the same patch, and some variants are easier to read than others.
      
      We have been trying to improve the choice of this boundary, and Git
      2.11 shipped with an experimental "compaction-heuristic".  Since
      then another attempt to improve the logic further resulted in a new
      "indent-heuristic" logic.  It is agreed that the latter gives better
      result overall, and the former outlived its usefulness.
      
      Retire "compaction", and keep "indent" as an experimental feature.
      The latter hopefully will be turned on by default in a future
      release, but that should be done as a separate step.
      Suggested-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3cde4e02