1. 12 9月, 2018 1 次提交
  2. 30 8月, 2018 3 次提交
    • J
      show_dirstat: simplify same-content check · d9f62dfa
      Jeff King 提交于
      We use two nested conditionals to store a content_changed
      variable, but only bother to look at the result once,
      directly after we set it. We can drop the variable entirely
      and just use a single "if".
      
      This needless complexity is the result of 2ff3a803 (Teach
      --dirstat not to completely ignore rearranged lines within a
      file, 2011-04-11). Before that, we held onto the
      content_changed variable much longer.
      
      While we're touching the condition, we can swap out oidcmp()
      for !oideq(). Our coccinelle patches didn't previously find
      this case because of the intermediate variable, but now it's
      a simple boolean in a conditional.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d9f62dfa
    • J
      convert "oidcmp() != 0" to "!oideq()" · 9001dc2a
      Jeff King 提交于
      This is the flip side of the previous two patches: checking
      for a non-zero oidcmp() can be more strictly expressed as
      inequality. Like those patches, we write "!= 0" in the
      coccinelle transformation, which covers by isomorphism the
      more common:
      
        if (oidcmp(E1, E2))
      
      As with the previous two patches, this patch can be achieved
      almost entirely by running "make coccicheck"; the only
      differences are manual line-wrap fixes to match the original
      code.
      
      There is one thing to note for anybody replicating this,
      though: coccinelle 1.0.4 seems to miss the case in
      builtin/tag.c, even though it's basically the same as all
      the others. Running with 1.0.7 does catch this, so
      presumably it's just a coccinelle bug that was fixed in the
      interim.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9001dc2a
    • J
      convert "oidcmp() == 0" to oideq() · 4a7e27e9
      Jeff King 提交于
      Using the more restrictive oideq() should, in the long run,
      give the compiler more opportunities to optimize these
      callsites. For now, this conversion should be a complete
      noop with respect to the generated code.
      
      The result is also perhaps a little more readable, as it
      avoids the "zero is equal" idiom. Since it's so prevalent in
      C, I think seasoned programmers tend not to even notice it
      anymore, but it can sometimes make for awkward double
      negations (e.g., we can drop a few !!oidcmp() instances
      here).
      
      This patch was generated almost entirely by the included
      coccinelle patch. This mechanical conversion should be
      completely safe, because we check explicitly for cases where
      oidcmp() is compared to 0, which is what oideq() is doing
      under the hood. Note that we don't have to catch "!oidcmp()"
      separately; coccinelle's standard isomorphisms make sure the
      two are treated equivalently.
      
      I say "almost" because I did hand-edit the coccinelle output
      to fix up a few style violations (it mostly keeps the
      original formatting, but sometimes unwraps long lines).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4a7e27e9
  3. 21 8月, 2018 1 次提交
  4. 15 8月, 2018 6 次提交
  5. 14 8月, 2018 6 次提交
    • N
      convert.c: remove an implicit dependency on the_index · 7f944e26
      Nguyễn Thái Ngọc Duy 提交于
      Make the convert API take an index_state instead of assuming the_index
      in convert.c. All external call sites are converted blindly to keep
      the patch simple and retain current behavior. Individual call sites
      may receive further updates to use the right index instead of
      the_index.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7f944e26
    • N
      diff.c: move read_index() code back to the caller · ff7fe37b
      Nguyễn Thái Ngọc Duy 提交于
      This code is only needed for diff-tree (since f0c6b2a2 ([PATCH]
      Optimize diff-tree -[CM] --stdin - 2005-05-27)). Let the caller do the
      preparation instead and avoid read_index() in diff.c code.
      
      read_index() should be avoided (in addition to the_index) because it
      uses get_index_file() underneath to get the path $GIT_DIR/index. This
      effectively pulls the_repository in and may become the only reason to
      pull a 'struct repository *' in diff.c. Let's keep the dependencies as
      few as possible and kick it back to diff-tree.c
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ff7fe37b
    • J
      range-diff: use dim/bold cues to improve dual color mode · a7be92ac
      Johannes Schindelin 提交于
      It *is* a confusing thing to look at a diff of diffs. All too easy is it
      to mix up whether the -/+ markers refer to the "inner" or the "outer"
      diff, i.e. whether a `+` indicates that a line was added by either the
      old or the new diff (or both), or whether the new diff does something
      different than the old diff.
      
      To make things easier to process for normal developers, we introduced
      the dual color mode which colors the lines according to the commit diff,
      i.e. lines that are added by a commit (whether old, new, or both) are
      colored in green. In non-dual color mode, the lines would be colored
      according to the outer diff: if the old commit added a line, it would be
      colored red (because that line addition is only present in the first
      commit range that was specified on the command-line, i.e. the "old"
      commit, but not in the second commit range, i.e. the "new" commit).
      
      However, this dual color mode is still not making things clear enough,
      as we are looking at two levels of diffs, and we still only pick a color
      according to *one* of them (the outer diff marker is colored
      differently, of course, but in particular with deep indentation, it is
      easy to lose track of that outer diff marker's background color).
      
      Therefore, let's add another dimension to the mix. Still use
      green/red/normal according to the commit diffs, but now also dim the
      lines that were only in the old commit, and use bold face for the lines
      that are only in the new commit.
      
      That way, it is much easier not to lose track of, say, when we are
      looking at a line that was added in the previous iteration of a patch
      series but the new iteration adds a slightly different version: the
      obsolete change will be dimmed, the current version of the patch will be
      bold.
      
      At least this developer has a much easier time reading the range-diffs
      that way.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a7be92ac
    • J
      range-diff --dual-color: skip white-space warnings · 0b91faa0
      Johannes Schindelin 提交于
      When displaying a diff of diffs, it is possible that there is an outer
      `+` before a context line. That happens when the context changed between
      old and new commit. When that context line starts with a tab (after the
      space that marks it as context line), our diff machinery spits out a
      white-space error (space before tab), but in this case, that is
      incorrect.
      
      Rather than adding a specific whitespace flag that specifically ignores
      the first space in the output (and might miss other problems with the
      white-space warnings), let's just skip handling white-space errors in
      dual color mode to begin with.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0b91faa0
    • J
      diff: add an internal option to dual-color diffs of diffs · f7c3b4e2
      Johannes Schindelin 提交于
      When diffing diffs, it can be quite daunting to figure out what the heck
      is going on, as there are nested +/- signs.
      
      Let's make this easier by adding a flag in diff_options that allows
      color-coding the outer diff sign with inverted colors, so that the
      preimage and postimage is colored like the diff it is.
      
      Of course, this really only makes sense when the preimage and postimage
      *are* diffs. So let's not expose this flag via a command-line option for
      now.
      
      This is a feature that was invented by git-tbdiff, and it will be used
      by `git range-diff` in the next commit, by offering it via a new option:
      `--dual-color`.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f7c3b4e2
    • J
      range-diff: suppress the diff headers · 1cdde296
      Johannes Schindelin 提交于
      When showing the diff between corresponding patches of the two branch
      versions, we have to make up a fake filename to run the diff machinery.
      
      That filename does not carry any meaningful information, hence tbdiff
      suppresses it. So we should, too.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1cdde296
  6. 26 7月, 2018 1 次提交
  7. 24 7月, 2018 1 次提交
    • N
      Update messages in preparation for i18n · 1a07e59c
      Nguyễn Thái Ngọc Duy 提交于
      Many messages will be marked for translation in the following
      commits. This commit updates some of them to be more consistent and
      reduce diff noise in those commits. Changes are
      
      - keep the first letter of die(), error() and warning() in lowercase
      - no full stop in die(), error() or warning() if it's single sentence
        messages
      - indentation
      - some messages are turned to BUG(), or prefixed with "BUG:" and will
        not be marked for i18n
      - some messages are improved to give more information
      - some messages are broken down by sentence to be i18n friendly
        (on the same token, combine multiple warning() into one big string)
      - the trailing \n is converted to printf_ln if possible, or deleted
        if not redundant
      - errno_errno() is used instead of explicit strerror()
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1a07e59c
  8. 20 7月, 2018 2 次提交
    • S
    • S
      diff.c: add white space mode to move detection that allows indent changes · ca1f4ae4
      Stefan Beller 提交于
      The option of --color-moved has proven to be useful as observed on the
      mailing list. However when refactoring sometimes the indentation changes,
      for example when partitioning a functions into smaller helper functions
      the code usually mostly moved around except for a decrease in indentation.
      
      To just review the moved code ignoring the change in indentation, a mode
      to ignore spaces in the move detection as implemented in a previous patch
      would be enough.  However the whole move coloring as motivated in commit
      2e2d5ac1 (diff.c: color moved lines differently, 2017-06-30), brought
      up the notion of the reviewer being able to trust the move of a "block".
      
      As there are languages such as python, which depend on proper relative
      indentation for the control flow of the program, ignoring any white space
      change in a block would not uphold the promises of 2e2d5ac1 that allows
      reviewers to pay less attention to the inside of a block, as inside
      the reviewer wants to assume the same program flow.
      
      This new mode of white space ignorance will take this into account and will
      only allow the same white space changes per line in each block. This patch
      even allows only for the same change at the beginning of the lines.
      
      As this is a white space mode, it is made exclusive to other white space
      modes in the move detection.
      
      This patch brings some challenges, related to the detection of blocks.
      We need a wide net to catch the possible moved lines, but then need to
      narrow down to check if the blocks are still intact. Consider this
      example (ignoring block sizes):
      
       - A
       - B
       - C
       +    A
       +    B
       +    C
      
      At the beginning of a block when checking if there is a counterpart
      for A, we have to ignore all space changes. However at the following
      lines we have to check if the indent change stayed the same.
      
      Checking if the indentation change did stay the same, is done by computing
      the indentation change by the difference in line length, and then assume
      the change is only in the beginning of the longer line, the common tail
      is the same. That is why the test contains lines like:
      
       - <TAB> A
       ...
       + A <TAB>
       ...
      
      As the first line starting a block is caught using a compare function that
      ignores white spaces unlike the rest of the block, where the white space
      delta is taken into account for the comparison, we also have to think about
      the following situation:
      
       - A
       - B
       -   A
       -   B
       +    A
       +    B
       +      A
       +      B
      
      When checking if the first A (both in the + and - lines) is a start of
      a block, we have to check all 'A' and record all the white space deltas
      such that we can find the example above to be just one block that is
      indented.
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ca1f4ae4
  9. 18 7月, 2018 5 次提交
  10. 17 7月, 2018 1 次提交
  11. 29 5月, 2018 2 次提交
  12. 16 5月, 2018 1 次提交
    • S
      object-store: move object access functions to object-store.h · cbd53a21
      Stefan Beller 提交于
      This should make these functions easier to find and cache.h less
      overwhelming to read.
      
      In particular, this moves:
      - read_object_file
      - oid_object_info
      - write_object_file
      
      As a result, most of the codebase needs to #include object-store.h.
      In this patch the #include is only added to files that would fail to
      compile otherwise.  It would be better to #include wherever
      identifiers from the header are used.  That can happen later
      when we have better tooling for it.
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cbd53a21
  13. 13 5月, 2018 1 次提交
    • B
      add status config and command line options for rename detection · e8b2dc2c
      Ben Peart 提交于
      After performing a merge that has conflicts git status will, by default,
      attempt to detect renames which causes many objects to be examined.  In a
      virtualized repo, those objects do not exist locally so the rename logic
      triggers them to be fetched from the server. This results in the status call
      taking hours to complete on very large repos vs seconds with this patch.
      
      Add a new config status.renames setting to enable turning off rename
      detection during status and commit.  This setting will default to the value
      of diff.renames.
      
      Add a new config status.renamelimit setting to to enable bounding the time
      spent finding out inexact renames during status and commit.  This setting
      will default to the value of diff.renamelimit.
      
      Add --no-renames command line option to status that enables overriding the
      config setting from the command line. Add --find-renames[=<n>] command line
      option to status that enables detecting renames and optionally setting the
      similarity index.
      Reviewed-by: NElijah Newren <newren@gmail.com>
      Original-Patch-by: NAlejandro Pauly <alpauly@microsoft.com>
      Signed-off-by: NBen Peart <Ben.Peart@microsoft.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e8b2dc2c
  14. 08 5月, 2018 1 次提交
  15. 06 5月, 2018 1 次提交
    • J
      Replace all die("BUG: ...") calls by BUG() ones · 033abf97
      Johannes Schindelin 提交于
      In d8193743 (usage.c: add BUG() function, 2017-05-12), a new macro
      was introduced to use for reporting bugs instead of die(). It was then
      subsequently used to convert one single caller in 588a538a
      (setup_git_env: convert die("BUG") to BUG(), 2017-05-12).
      
      The cover letter of the patch series containing this patch
      (cf 20170513032414.mfrwabt4hovujde2@sigill.intra.peff.net) is not
      terribly clear why only one call site was converted, or what the plan
      is for other, similar calls to die() to report bugs.
      
      Let's just convert all remaining ones in one fell swoop.
      
      This trick was performed by this invocation:
      
      	sed -i 's/die("BUG: /BUG("/g' $(git grep -l 'die("BUG' \*.c)
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      033abf97
  16. 02 5月, 2018 2 次提交
  17. 26 4月, 2018 1 次提交
  18. 15 3月, 2018 3 次提交
    • B
      sha1_file: convert read_sha1_file to struct object_id · b4f5aca4
      brian m. carlson 提交于
      Convert read_sha1_file to take a pointer to struct object_id and rename
      it read_object_file.  Do the same for read_sha1_file_extended.
      
      Convert one use in grep.c to use the new function without any other code
      change, since the pointer being passed is a void pointer that is already
      initialized with a pointer to struct object_id.  Update the declaration
      and definitions of the modified functions, and apply the following
      semantic patch to convert the remaining callers:
      
      @@
      expression E1, E2, E3;
      @@
      - read_sha1_file(E1.hash, E2, E3)
      + read_object_file(&E1, E2, E3)
      
      @@
      expression E1, E2, E3;
      @@
      - read_sha1_file(E1->hash, E2, E3)
      + read_object_file(E1, E2, E3)
      
      @@
      expression E1, E2, E3, E4;
      @@
      - read_sha1_file_extended(E1.hash, E2, E3, E4)
      + read_object_file_extended(&E1, E2, E3, E4)
      
      @@
      expression E1, E2, E3, E4;
      @@
      - read_sha1_file_extended(E1->hash, E2, E3, E4)
      + read_object_file_extended(E1, E2, E3, E4)
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b4f5aca4
    • B
      sha1_file: convert sha1_object_info* to object_id · abef9020
      brian m. carlson 提交于
      Convert sha1_object_info and sha1_object_info_extended to take pointers
      to struct object_id and rename them to use "oid" instead of "sha1" in
      their names.  Update the declaration and definition and apply the
      following semantic patch, plus the standard object_id transforms:
      
      @@
      expression E1, E2;
      @@
      - sha1_object_info(E1.hash, E2)
      + oid_object_info(&E1, E2)
      
      @@
      expression E1, E2;
      @@
      - sha1_object_info(E1->hash, E2)
      + oid_object_info(E1, E2)
      
      @@
      expression E1, E2, E3;
      @@
      - sha1_object_info_extended(E1.hash, E2, E3)
      + oid_object_info_extended(&E1, E2, E3)
      
      @@
      expression E1, E2, E3;
      @@
      - sha1_object_info_extended(E1->hash, E2, E3)
      + oid_object_info_extended(E1, E2, E3)
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      abef9020
    • B
      Convert find_unique_abbrev* to struct object_id · aab9583f
      brian m. carlson 提交于
      Convert find_unique_abbrev and find_unique_abbrev_r to each take a
      pointer to struct object_id.
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aab9583f
  19. 28 2月, 2018 1 次提交
    • N
      diff: add --compact-summary · ddf88fa6
      Nguyễn Thái Ngọc Duy 提交于
      Certain information is currently shown with --summary, but when used
      in combination with --stat it's a bit hard to read since info of the
      same file is in two places (--stat and --summary).
      
      On top of that, commits that add or remove files double the number of
      display lines, which could be a lot if you add or remove a lot of
      files.
      
      --compact-summary embeds most of --summary back in --stat in the
      little space between the file name part and the graph line, e.g. with
      commit 0433d533:
      
         Documentation/merge-config.txt         |  4 +
         builtin/merge.c                        |  2 +
         ...-pull-verify-signatures.sh (new +x) | 81 ++++++++++++++
         t/t7612-merge-verify-signatures.sh     | 45 ++++++++
         4 files changed, 132 insertions(+)
      
      It helps both condensing information and saving some text
      space. What's new in diffstat is:
      
      - A new 0644 file is shown as (new)
      - A new 0755 file is shown as (new +x)
      - A new symlink is shown as (new +l)
      - A deleted file is shown as (gone)
      - A mode change adding executable bit is shown as (mode +x)
      - A mode change removing it is shown as (mode -x)
      
      Note that --compact-summary does not contain all the information
      --summary provides. Rewrite percentage is not shown but it could be
      added later, like R50% or C20%.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ddf88fa6