1. 04 8月, 2017 1 次提交
  2. 11 7月, 2017 1 次提交
  3. 17 6月, 2017 1 次提交
  4. 16 6月, 2017 1 次提交
  5. 14 6月, 2017 1 次提交
  6. 05 6月, 2017 1 次提交
  7. 02 6月, 2017 6 次提交
  8. 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
  9. 24 5月, 2017 1 次提交
  10. 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
  11. 08 5月, 2017 1 次提交
  12. 01 5月, 2017 1 次提交
  13. 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
  14. 27 3月, 2017 1 次提交
  15. 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
  16. 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
  17. 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
  18. 31 1月, 2017 3 次提交
  19. 13 1月, 2017 1 次提交
  20. 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
  21. 09 12月, 2016 1 次提交
    • J
      diff: handle --no-abbrev in no-index case · 43d1948b
      Jack Bates 提交于
      There are two different places where the --no-abbrev option is parsed,
      and two different places where SHA-1s are abbreviated. We normally parse
      --no-abbrev with setup_revisions(), but in the no-index case, "git diff"
      calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
      --no-abbrev until now. (It did handle --abbrev, however.) We normally
      abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666a ("diff:
      handle sha1 abbreviations outside of repository, 2016-10-20) recently
      introduced a special case when you run "git diff" outside of a
      repository.
      
      setup_revisions() does also call diff_opt_parse(), but not for --abbrev
      or --no-abbrev, which it handles itself. setup_revisions() sets
      rev_info->abbrev, and later copies that to diff_options->abbrev. It
      handles --no-abbrev by setting abbrev to zero. (This change doesn't
      touch that.)
      
      Setting abbrev to zero was broken in the outside-of-a-repository special
      case, which until now resulted in a truly zero-length SHA-1, rather than
      taking zero to mean do not abbreviate. The only way to trigger this bug,
      however, was by running "git diff --raw" without either the --abbrev or
      --no-abbrev options, because 1) without --raw it doesn't respect abbrev
      (which is bizarre, but has been that way forever), 2) we silently clamp
      --abbrev=0 to MINIMUM_ABBREV, and 3) --no-abbrev wasn't handled until
      now.
      
      The outside-of-a-repository case is one of three no-index cases. The
      other two are when one of the files you're comparing is outside of the
      repository you're in, and the --no-index option.
      Signed-off-by: NJack Bates <jack@nottheoilrig.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      43d1948b
  22. 15 11月, 2016 1 次提交
  23. 27 10月, 2016 3 次提交
    • J
      diff: handle sha1 abbreviations outside of repository · 4f03666a
      Jeff King 提交于
      When generating diffs outside a repository (e.g., with "diff
      --no-index"), we may write abbreviated sha1s as part of
      "--raw" output or the "index" lines of "--patch" output.
      Since we have no object database, we never find any
      collisions, and these sha1s get whatever static abbreviation
      length is configured (typically 7).
      
      However, we do blindly look in ".git/objects" to see if any
      objects exist, even though we know we are not in a
      repository. This is usually harmless because such a
      directory is unlikely to exist, but could be wrong in rare
      circumstances.
      
      Let's instead notice when we are not in a repository and
      behave as if the object database is empty (i.e., just use
      the default abbrev length). It would perhaps make sense to
      be conservative and show full sha1s in that case, but
      showing the default abbreviation is what we've always done
      (and is certainly less ugly).
      
      Note that this does mean that:
      
        cd /not/a/repo
        GIT_OBJECT_DIRECTORY=/some/real/objdir git diff --no-index ...
      
      used to look for collisions in /some/real/objdir but now
      does not. This could be considered either a bugfix (we do
      not look at objects if we have no repository) or a
      regression, but it seems unlikely that anybody would care
      much either way.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4f03666a
    • J
      diff_aligned_abbrev: use "struct oid" · d6cece51
      Jeff King 提交于
      Since we're modifying this function anyway, it's a good time
      to update it to the more modern "struct oid". We can also
      drop some of the magic numbers in favor of GIT_SHA1_HEXSZ,
      along with some descriptive comments.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d6cece51
    • J
      diff_unique_abbrev: rename to diff_aligned_abbrev · d5e3b01e
      Jeff King 提交于
      The word "align" describes how the function actually differs
      from find_unique_abbrev, and will make it less confusing
      when we add more diff-specific abbrevation functions that do
      not do this alignment.
      
      Since this is a globally available function, let's also move
      its descriptive comment to the header file, where we
      typically document function interfaces.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d5e3b01e
  24. 25 10月, 2016 1 次提交
  25. 18 10月, 2016 1 次提交
  26. 05 10月, 2016 3 次提交
  27. 04 10月, 2016 1 次提交
    • J
      abbrev: prepare for new world order · 7b5b7721
      Junio C Hamano 提交于
      The code that sets custom abbreviation length, in response to
      command line argument, often does something like this:
      
      	if (skip_prefix(arg, "--abbrev=", &arg))
      		abbrev = atoi(arg);
      	else if (!strcmp("--abbrev", &arg))
      		abbrev = DEFAULT_ABBREV;
      	/* make the value sane */
      	if (abbrev < 0 || 40 < abbrev)
      		abbrev = ... some sane value ...
      
      However, it is pointless to sanity-check and tweak the value
      obtained from DEFAULT_ABBREV.  We are going to allow it to be
      initially set to -1 to signal that the default abbreviation length
      must be auto sized upon the first request to abbreviate, based on
      the number of objects in the repository, and when that happens,
      rejecting or tweaking a negative value to a "saner" one will
      negatively interfere with the auto sizing.  The codepaths for
      
          git rev-parse --short <object>
          git diff --raw --abbrev
      
      do exactly that; allow them to pass possibly negative abbrevs
      intact, that will come from DEFAULT_ABBREV in the future.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7b5b7721