1. 22 1月, 2016 2 次提交
  2. 06 10月, 2015 1 次提交
    • J
      use strbuf_complete to conditionally append slash · 00b6c178
      Jeff King 提交于
      When working with paths in strbufs, we frequently want to
      ensure that a directory contains a trailing slash before
      appending to it. We can shorten this code (and make the
      intent more obvious) by calling strbuf_complete.
      
      Most of these cases are trivially identical conversions, but
      there are two things to note:
      
        - in a few cases we did not check that the strbuf is
          non-empty (which would lead to an out-of-bounds memory
          access). These were generally not triggerable in
          practice, either from earlier assertions, or typically
          because we would have just fed the strbuf to opendir(),
          which would choke on an empty path.
      
        - in a few cases we indexed the buffer with "original_len"
          or similar, rather than the current sb->len, and it is
          not immediately obvious from the diff that they are the
          same. In all of these cases, I manually verified that
          the strbuf does not change between the assignment and
          the strbuf_complete call.
      
      This does not convert cases which look like:
      
        if (sb->len && !is_dir_sep(sb->buf[sb->len - 1]))
      	  strbuf_addch(sb, '/');
      
      as those are obviously semantically different. Some of these
      cases arguably should be doing that, but that is out of
      scope for this change, which aims purely for cleanup with no
      behavior change (and at least it will make such sites easier
      to find and examine in the future, as we can grep for
      strbuf_complete).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      00b6c178
  3. 27 3月, 2015 1 次提交
    • J
      diff-no-index: align D/F handling with that of normal Git · 06151739
      Junio C Hamano 提交于
      When a commit changes a path P that used to be a file to a directory
      and creates a new path P/X in it, "git show" would say that file P
      was removed and file P/X was created for such a commit.
      
      However, if we compare two directories, D1 and D2, where D1 has a
      file D1/P in it and D2 has a directory D2/P under which there is a
      file D2/P/X, and ask "git diff --no-index D1 D2" to show their
      differences, we simply get a refusal "file/directory conflict".
      
      Surely, that may be what GNU diff does, but we can do better and it
      is easy to do so.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      06151739
  4. 26 3月, 2015 1 次提交
    • J
      diff-no-index: DWIM "diff D F" into "diff D/F F" · c9e1f2c7
      Junio C Hamano 提交于
      "git diff --no-index" was supposed to be a poor-man's approach to
      allow using Git diff goodies outside of a Git repository, without
      having to patch mainstream diff implementations.
      
      Unlike a POSIX diff that treats "diff D F" (or "diff F D") as a
      request to compare D/F and F (or F and D/F) when D is a directory
      and F is a file, however, we did not accept such a command line and
      instead barfed with "file/directory conflict".
      
      Imitate what POSIX diff does and append the basename of the file
      after the name of the directory before comparing.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c9e1f2c7
  5. 01 4月, 2014 1 次提交
    • J
      diff-no-index: correctly diagnose error return from diff_opt_parse() · ad1c3fbd
      Junio C Hamano 提交于
      diff_opt_parse() returns the number of options parsed, or often
      returns error() which is defined to return -1.  Yes, return value of
      0 is "I did not process that option at all", which should cause the
      caller to say that, but negative return should not be forgotten.
      
      This bug caused "diff --no-index" to infinitely show the same error
      message because the returned value was used to decrement the loop
      control variable, e.g.
      
              $ git diff --no-index --color=words a b
              error: option `color' expects "always", "auto", or "never"
              error: option `color' expects "always", "auto", or "never"
              ...
      
      Instead, make it act like so:
      
              $ git diff --no-index --color=words a b
              error: option `color' expects "always", "auto", or "never"
              fatal: invalid diff option/value: --color=words
      Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ad1c3fbd
  6. 20 3月, 2014 2 次提交
  7. 13 12月, 2013 1 次提交
  8. 23 8月, 2013 1 次提交
  9. 20 7月, 2013 2 次提交
  10. 09 5月, 2013 1 次提交
    • J
      mingw: rename WIN32 cpp macro to GIT_WINDOWS_NATIVE · 380395d0
      Jonathan Nieder 提交于
      Throughout git, it is assumed that the WIN32 preprocessor symbol is
      defined on native Windows setups (mingw and msvc) and not on Cygwin.
      On Cygwin, most of the time git can pretend this is just another Unix
      machine, and Windows-specific magic is generally counterproductive.
      
      Unfortunately Cygwin *does* define the WIN32 symbol in some headers.
      Best to rely on a new git-specific symbol GIT_WINDOWS_NATIVE instead,
      defined as follows:
      
      	#if defined(WIN32) && !defined(__CYGWIN__)
      	# define GIT_WINDOWS_NATIVE
      	#endif
      
      After this change, it should be possible to drop the
      CYGWIN_V15_WIN32API setting without any negative effect.
      
      [rj: %s/WINDOWS_NATIVE/GIT_WINDOWS_NATIVE/g ]
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NRamsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      380395d0
  11. 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
  12. 30 7月, 2012 1 次提交
    • J
      diff: do not use null sha1 as a sentinel value · e5450100
      Jeff King 提交于
      The diff code represents paths using the diff_filespec
      struct. This struct has a sha1 to represent the sha1 of the
      content at that path, as well as a sha1_valid member which
      indicates whether its sha1 field is actually useful. If
      sha1_valid is not true, then the filespec represents a
      working tree file (e.g., for the no-index case, or for when
      the index is not up-to-date).
      
      The diff_filespec is only used internally, though. At the
      interfaces to the diff subsystem, callers feed the sha1
      directly, and we create a diff_filespec from it. It's at
      that point that we look at the sha1 and decide whether it is
      valid or not; callers may pass the null sha1 as a sentinel
      value to indicate that it is not.
      
      We should not typically see the null sha1 coming from any
      other source (e.g., in the index itself, or from a tree).
      However, a corrupt tree might have a null sha1, which would
      cause "diff --patch" to accidentally diff the working tree
      version of a file instead of treating it as a blob.
      
      This patch extends the edges of the diff interface to accept
      a "sha1_valid" flag whenever we accept a sha1, and to use
      that flag when creating a filespec. In some cases, this
      means passing the flag through several layers, making the
      code change larger than would be desirable.
      
      One alternative would be to simply die() upon seeing
      corrupted trees with null sha1s. However, this fix more
      directly addresses the problem (while bogus sha1s in a tree
      are probably a bad thing, it is really the sentinel
      confusion sending us down the wrong code path that is what
      makes it devastating). And it means that git is more capable
      of examining and debugging these corrupted trees. For
      example, you can still "diff --raw" such a tree to find out
      when the bogus entry was introduced; you just cannot do a
      "--patch" diff (just as you could not with any other
      corrupted tree, as we do not have any content to diff).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e5450100
  13. 29 6月, 2012 3 次提交
    • J
      diff-index.c: "git diff" has no need to read blob from the standard input · 4682d852
      Junio C Hamano 提交于
      Only "diff --no-index -" does.  Bolting the logic into the low-level
      function diff_populate_filespec() was a layering violation from day
      one.  Move populate_from_stdin() function out of the generic diff.c
      to its only user, diff-index.c.
      
      Also make sure "-" from the command line stays a special token "read
      from the standard input", even if we later decide to sanitize the
      result from prefix_filename() function in a few obvious ways,
      e.g. removing unnecessary "./" prefix, duplicated slashes "//" in
      the middle, etc.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4682d852
    • J
      diff-index.c: unify handling of command line paths · 3b069b1b
      Junio C Hamano 提交于
      Regardless of where in the directory hierarchy you are, "-" on the
      command line means the standard input.  The old code knew too much
      about how the low level machinery uses paths to read from the
      working tree and did not bother to have the same check for "-" when
      the command is run from the top-level.
      
      Unify the codepaths for subdirectory case and toplevel case into one
      and make it clearer.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3b069b1b
    • J
      diff-index.c: do not pretend paths are pathspecs · c20f5926
      Junio C Hamano 提交于
      "git diff --no-index" takes exactly two paths, not pathspecs, and
      has its own way queue_diff() to populate the diff_queue.  Do not
      call diff_tree_setup_paths(), pretending as it takes pathspecs.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c20f5926
  14. 23 6月, 2012 2 次提交
  15. 16 6月, 2012 2 次提交
    • J
      do not run pager with diff --no-index --quiet · af63b543
      Jeff King 提交于
      There is no point in running a pager when --quiet is given,
      since we are producing no output. The regular diff code path
      handles this already, because --quiet implies --exit-code,
      and we check for --exit-code when deciding not to run the
      pager.
      
      However, the "quiet implies exit-code" logic is done in
      diff_setup_done, and the no-index code path sets up its
      pager before running diff_setup_done, and misses this case.
      
      We can fix this by reordering our initialization.
      Currently we do:
      
        1. read command line arguments into diff_options
      
        2. Set pager if EXIT_CODE not requested
      
        3. always set EXIT_CODE, since we are emulating
           traditional diff
      
        4. call diff_setup_done
      
      We can fix the problem by moving pager initialization (step
      2) after step 4. But step 3 must come after step 2 (since we
      want to know whether the _user_ requested --exit-code, not
      whether we turned it on unconditionally). So we must move
      both.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      af63b543
    • J
      fix pager.diff with diff --no-index · 1af3d977
      Jeff King 提交于
      git-diff does not rely on the git wrapper to setup its
      pager; instead, it sets it up on its own after seeing
      whether --quiet or --exit-code has been specified.  After
      diff_no_index was split off from cmd_diff, commit b3fde6cc
      (git diff --no-index: default to page like other diff
      frontends, 2008-05-26) duplicated the one-liner from
      cmd_diff to turn on the pager.
      
      Later, commit 8f0359f0 (Allow pager of diff command be
      enabled/disabled, 2008-07-21) taught the the version in
      cmd_diff to respect the pager.diff config, but the version
      in diff_no_index was left behind. This meant that
      
        git -c pager.diff=0 diff a b
      
      would not use a pager, but
      
        git -c pager.diff=0 diff --no-index a b
      
      would.  Let's fix it by factoring out a common function.
      
      While we're there, let's update the antiquated comment,
      which claims that the pager interferes with propagating the
      exit code; this has not been the case since ea27a18c (spawn
      pager via run_command interface, 2008-07-22).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1af3d977
  16. 17 5月, 2012 2 次提交
  17. 27 4月, 2012 1 次提交
  18. 17 4月, 2012 1 次提交
  19. 04 2月, 2011 2 次提交
  20. 06 7月, 2010 1 次提交
  21. 28 6月, 2010 1 次提交
  22. 26 5月, 2010 1 次提交
  23. 11 11月, 2009 1 次提交
  24. 02 5月, 2009 1 次提交
  25. 26 3月, 2009 1 次提交
  26. 08 3月, 2009 1 次提交
  27. 19 2月, 2009 1 次提交
    • M
      Skip timestamp differences for diff --no-index · d61027b2
      Michael Spang 提交于
      We display empty diffs for files whose timestamps have changed.
      Usually, refreshing the index makes those empty diffs go away.
      However, when not using the index they are not very useful and
      there is no option to suppress them.
      
      This forces on the skip_stat_unmatch option for diff --no-index,
      suppressing any empty diffs. This option is also used for diffs
      against the index when "diff.autorefreshindex" is set, but that
      option does not apply to diff --no-index.
      Signed-off-by: NMichael Spang <mspang@uwaterloo.ca>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d61027b2
  28. 31 1月, 2009 1 次提交
  29. 08 1月, 2009 1 次提交
  30. 07 1月, 2009 2 次提交