1. 17 10月, 2015 1 次提交
  2. 29 9月, 2015 2 次提交
    • J
      merge-file: enforce MAX_XDIFF_SIZE on incoming files · 83c4d380
      Jeff King 提交于
      The previous commit enforces MAX_XDIFF_SIZE at the
      interfaces to xdiff: xdi_diff (which calls xdl_diff) and
      ll_xdl_merge (which calls xdl_merge).
      
      But we have another direct call to xdl_merge in
      merge-file.c. If it were written today, this probably would
      just use the ll_merge machinery. But it predates that code,
      and uses slightly different options to xdl_merge (e.g.,
      ZEALOUS_ALNUM).
      
      We could try to abstract out an xdi_merge to match the
      existing xdi_diff, but even that is difficult. Rather than
      simply report error, we try to treat large files as binary,
      and that distinction would happen outside of xdi_merge.
      
      The simplest fix is to just replicate the MAX_XDIFF_SIZE
      check in merge-file.c.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      83c4d380
    • J
      react to errors in xdi_diff · 3efb9880
      Jeff King 提交于
      When we call into xdiff to perform a diff, we generally lose
      the return code completely. Typically by ignoring the return
      of our xdi_diff wrapper, but sometimes we even propagate
      that return value up and then ignore it later.  This can
      lead to us silently producing incorrect diffs (e.g., "git
      log" might produce no output at all, not even a diff header,
      for a content-level diff).
      
      In practice this does not happen very often, because the
      typical reason for xdiff to report failure is that it
      malloc() failed (it uses straight malloc, and not our
      xmalloc wrapper).  But it could also happen when xdiff
      triggers one our callbacks, which returns an error (e.g.,
      outf() in builtin/rerere.c tries to report a write failure
      in this way). And the next patch also plans to add more
      failure modes.
      
      Let's notice an error return from xdiff and react
      appropriately. In most of the diff.c code, we can simply
      die(), which matches the surrounding code (e.g., that is
      what we do if we fail to load a file for diffing in the
      first place). This is not that elegant, but we are probably
      better off dying to let the user know there was a problem,
      rather than simply generating bogus output.
      
      We could also just die() directly in xdi_diff, but the
      callers typically have a bit more context, and can provide a
      better message (and if we do later decide to pass errors up,
      we're one step closer to doing so).
      
      There is one interesting case, which is in diff_grep(). Here
      if we cannot generate the diff, there is nothing to match,
      and we silently return "no hits". This is actually what the
      existing code does already, but we make it a little more
      explicit.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3efb9880
  3. 12 9月, 2015 2 次提交
  4. 07 9月, 2015 1 次提交
    • J
      am: match --signoff to the original scripted version · aab84542
      Junio C Hamano 提交于
      Linus noticed that the recently reimplemented "git am -s" defines
      the trailer block too rigidly, resulting in an unnecessary blank
      line between the existing sign-offs and his new sign-off.  An e-mail
      submission sent to Linus in real life ends with mixture of sign-offs
      and commentaries, e.g.
      
      	title here
      
      	message here
      Signed-off-by: NOriginal Author <original@auth.or>
      	[rv: tweaked frotz and nitfol]
      Signed-off-by: NRe Viewer <rv@ew.er>
      Signed-off-by: NOther Reviewer <other@rev.ewer>
      	---
      	patch here
      
      Because the reimplementation reused append_signoff() helper that is
      used by other codepaths, which is unaware that people intermix such
      comments with their sign-offs in the trailer block, such a message
      was judged to end with a non-trailer, resulting in an extra blank
      line before adding a new sign-off.
      
      The original scripted version of "git am" used a lot looser
      definition, i.e. "if and only if there is no line that begins with
      Signed-off-by:, add a blank line before adding a new sign-off".  For
      the upcoming release, stop using the append_signoff() in "git am"
      and reimplement the looser definition used by the scripted version
      to use only in "git am" to fix this regression in "am" while
      avoiding new regressions to other users of append_signoff().
      
      In the longer term, we should look into loosening append_signoff()
      so that other codepaths that add a new sign-off behave the same way
      as "git am -s", but that is a task for post-release.
      Reported-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aab84542
  5. 05 9月, 2015 1 次提交
  6. 02 9月, 2015 1 次提交
    • J
      rerere: release lockfile in non-writing functions · 9dd330e6
      Jeff King 提交于
      There's a bug in builtin/am.c in which we take a lock on
      MERGE_RR recursively. But rather than fix am.c, this patch
      fixes the confusing interface from rerere.c that caused the
      bug. Read on for the gory details.
      
      The setup_rerere() function both reads the existing MERGE_RR
      file, and takes MERGE_RR.lock. In the rerere() and
      rerere_forget() functions, we end up in write_rr(), which
      will then commit the lock file.
      
      But for functions like rerere_clear() that do not write to
      MERGE_RR, we expect the caller to have handled
      setup_rerere(). That caller would then need to release the
      lockfile, but it can't; the lock struct is local to
      rerere.c.
      
      For builtin/rerere.c, this is OK. We run a single rerere
      operation and then exit immediately, which has the side
      effect of rolling back the lockfile.
      
      But in builtin/am.c, this is actively wrong. If we run "git
      am -3 --skip", we call setup-rerere twice without releasing
      the lock:
      
        1. The "--skip" causes us to call am_rerere_clear(), which
           calls setup_rerere(), but never drops the lock.
      
        2. We then proceed to the next patch.
      
        3. The "--3way" may cause us to call rerere() to handle
           conflicts in that patch, but we are already holding the
           lock. The lockfile code dies with:
      
           BUG: prepare_tempfile_object called for active object
      
      We could fix this by having rerere_clear() call
      rollback_lock_file(). But it feels a bit odd for it to roll
      back a lockfile that it did not itself take. So let's
      simplify the interface further, and handle setup_rerere in
      the function itself, taking away the question from the
      caller over whether they need to do so.
      
      We can give rerere_gc() the same treatment, as well (even
      though it doesn't have any callers besides builtin/rerere.c
      at this point). Note that these functions don't take flags
      from their callers to pass along to setup_rerere; that's OK,
      because the flags would not be meaningful for what they are
      doing.
      
      Both of those functions need to hold the lock because even
      though they do not write to MERGE_RR, they are still writing
      and should be protected from a simultaneous "rerere" run.
      But rerere_remaining(), "rerere diff", and "rerere status"
      are all read-only operations. They want to setup_rerere(),
      but do not care about taking the lock in the first place.
      Since our update of MERGE_RR is the usual atomic rename done
      by commit_lock_file, they can just do a lockless read. For
      that, we teach setup_rerere a READONLY flag to avoid the
      lock.
      
      As a bonus, this pushes builtin/rerere.c's setup_rerere call
      closer to the functions that use it. Which means that "git
      rerere totally-bogus-command" will no longer silently
      exit(0) in a repository without rerere enabled.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9dd330e6
  7. 01 9月, 2015 1 次提交
  8. 31 8月, 2015 1 次提交
    • D
      commit: don't rewrite shared index unnecessarily · 475a3445
      David Turner 提交于
      Remove a cache invalidation which would cause the shared index to be
      rewritten on as-is commits.
      
      When the cache-tree has changed, we need to update it.  But we don't
      necessarily need to update the shared index.  So setting
      active_cache_changed to SOMETHING_CHANGED is unnecessary.  Instead, we
      let update_main_cache_tree just update the CACHE_TREE_CHANGED bit.
      
      In order to test this, make test-dump-split-index not segfault on
      missing replace_bitmap/delete_bitmap.  This new codepath is not called
      now that the test passes, but is necessary to avoid a segfault when the
      new test is run with the old builtin/commit.c code.
      Signed-off-by: NDavid Turner <dturner@twopensource.com>
      Acked-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      475a3445
  9. 29 8月, 2015 3 次提交
  10. 27 8月, 2015 1 次提交
  11. 26 8月, 2015 4 次提交
    • J
      builtin/log.c: minor reformat · 3acf8dd8
      Junio C Hamano 提交于
      Two logical lines that were not overly long was split in the middle,
      which made them read worse.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3acf8dd8
    • J
      write_file(): drop caller-supplied LF from calls to create a one-liner file · 1f76a10b
      Junio C Hamano 提交于
      All of the callsites covered by this change call write_file() or
      write_file_gently() to create a one-liner file.  Drop the caller
      supplied LF and let these callees to append it as necessary.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1f76a10b
    • J
      write_file_v(): do not leave incomplete line at the end · e7ffa38c
      Junio C Hamano 提交于
      All existing callers to this function use it to produce a text file
      or an empty file, and a new callsite that mimick them must end their
      payload with a LF.  If they forget to do so, the resulting file will
      end with an incomplete line.
      
      Teach write_file_v() to complete the incomplete line, if exists, so
      that the callers do not have to.
      
      With this, the caller-side fix in builtin/am.c becomes unnecessary.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e7ffa38c
    • S
      describe --contains: default to HEAD when no commit-ish is given · 2bd07065
      SZEDER Gábor 提交于
      'git describe --contains' doesn't default to HEAD when no commit is
      given, and it doesn't produce any output, not even an error:
      
        ~/src/git ((v2.5.0))$ ./git describe --contains
        ~/src/git ((v2.5.0))$ ./git describe --contains HEAD
        v2.5.0^0
      
      Unlike other 'git describe' options, the '--contains' code path is
      implemented by calling 'name-rev' with a bunch of options plus all the
      commit-ishes that were passed to 'git describe'.  If no commit-ish was
      present, then 'name-rev' got invoked with none, which then leads to the
      behavior illustrated above.
      
      Porcelain commands usually default to HEAD when no commit-ish is given,
      and 'git describe' already does so in all other cases, so it should do
      so with '--contains' as well.
      
      Pass HEAD to 'name-rev' when no commit-ish is given on the command line
      to make '--contains' behave consistently with other 'git describe'
      options.  While at it, use argv_array_pushv() instead of the loop to
      pass commit-ishes to 'git name-rev'.
      
      'git describe's short help already indicates that the commit-ish is
      optional, but the synopsis in the man page doesn't, so update it
      accordingly as well.
      Signed-off-by: NSZEDER Gábor <szeder@ira.uka.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2bd07065
  12. 25 8月, 2015 4 次提交
    • J
      write_file(): drop "fatal" parameter · 12d6ce1d
      Junio C Hamano 提交于
      All callers except three passed 1 for the "fatal" parameter to ask
      this function to die upon error, but to a casual reader of the code,
      it was not all obvious what that 1 meant.  Instead, split the
      function into two based on a common write_file_v() that takes the
      flag, introduce write_file_gently() as a new way to attempt creating
      a file without dying on error, and make three callers to call it.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      12d6ce1d
    • J
      builtin/am: make sure state files are text · 57c867ef
      Junio C Hamano 提交于
      We forgot to terminate the payload given to write_file() with LF,
      resulting in files that end with an incomplete line.  Teach the
      wrappers builtin/am uses to make sure it adds LF at the end as
      necessary.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      57c867ef
    • J
      builtin/am: introduce write_state_*() helper functions · 25b763ba
      Junio C Hamano 提交于
      There are many calls to write_file() that repeat the same pattern in
      the implementation of the builtin version of "am".  They all share
      the same traits, i.e they
      
       - produce a text file with a single string in it;
      
       - have enough information to produce the entire contents of that
         file;
      
       - generate the pathname of the file by making a call to am_path(); and
      
       - they ask write_file() to die() upon failure.
      
      The slight differences among the call sites throw them into roughly
      three categories:
      
       - many write either "t" or "f" based on a boolean value to a file;
      
       - some write the integer value in decimal text;
      
       - some others write more general string, e.g. an object name in
         hex, an empty string (i.e. the presense of the file itself serves
         as a flag), etc.
      
      Introduce three helpers, write_state_bool(), write_state_count() and
      write_state_text(), to reduce direct calls to write_file().
      
      This is a preparatory step for the next step to ensure that no
      "state" file this command leaves in $GIT_DIR is with an incomplete
      line at the end.
      Suggested-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      25b763ba
    • J
      rev-list: make it obvious that we do not support notes · 2aea7a51
      Jeff King 提交于
      The rev-list command does not have the internal
      infrastructure to display notes. Running:
      
        git rev-list --notes HEAD
      
      will silently ignore the "--notes" option. Running:
      
        git rev-list --notes --grep=. HEAD
      
      will crash on an assert. Running:
      
        git rev-list --format=%N HEAD
      
      will place a literal "%N" in the output (it does not even
      expand to an empty string).
      
      Let's have rev-list tell the user that it cannot fill the
      user's request, rather than silently producing wrong data.
      Likewise, let's remove mention of the notes options from the
      rev-list documentation.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2aea7a51
  13. 21 8月, 2015 8 次提交
    • J
      log: show merge commit when --cc is given · 82dee416
      Junio C Hamano 提交于
      We defaulted to ignoring merge diffs because long long ago, in a
      galaxy far away, we didn't have a great way to show the diffs.  The
      whole "--cc" option goes back to January '06 and commit d8f4790e
      ("diff-tree --cc: denser combined diff output for a merge commit").
      And before that option - so for about 8 months - we had no good way
      to show the diffs of merges in a good dense way.  So the whole
      "don't show diffs for merges by default" actually made a lot of
      sense originally, because our merge diffs were not very useful.
      
      And this was carried forward to this day.  "git log --cc" still
      ignores merge commits, and you need to say "git log -m --cc" to view
      a sensible rendition of merge and non-merge commits, even with the
      previous change to make "--cc" imply "-p".
      
      Teach "git log" that "--cc" means the user wants to see interesting
      changes in merge commits by turning "-m" on.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      82dee416
    • J
      log: when --cc is given, default to -p unless told otherwise · c7eaf8b4
      Junio C Hamano 提交于
      The "--cc" option to "git log" is clearly a request to show some
      sort of combined diff (be it --patch or --raw), but traditionally
      we required the command line to explicitly ask for "git log -p --cc".
      
      Teach the command line parser to treat a lone "--cc" as if the user
      specified "-p --cc".  Formats that do ask for other forms of diff
      output, e.g. "log --raw --cc", are not overriden.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c7eaf8b4
    • J
      log: rename "tweak" helpers · b130c706
      Junio C Hamano 提交于
      The revision walking API allows the callers to tweak its
      configuration at the last minute, immediately after all the revision
      and pathspec parameters are parsed from the command line but before
      the default actions are decided based on them, by defining a "tweak"
      callback function when calling setup_revisions().  Traditionally,
      this facility was used by "git show" to turn on the patch output
      "-p" by default when no diff output option (e.g.  "--raw" or "-s" to
      squelch the output altogether) is given on the command line, and
      further give dense combined diffs "--cc" for merge commits when no
      option to countermand it (e.g. "-m" to show pairwise patches).
      
      Recently, "git log" started using the same facility, but we named
      the callback function "default_follow_tweak()", as if the only kind
      of tweaking we would want for "git log" will forever be limited to
      turning "--follow" on by default when told by a configuration
      variable.  That was myopic.
      
      Rename it to more generic name "log_setup_revisions_tweak()", and
      match the one used by show "show_setup_revisions_tweak()".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b130c706
    • J
      get_urlmatch: avoid useless strbuf write · a92330d2
      Jeff King 提交于
      We create a strbuf only to insert a single string, pass the
      resulting buffer to a function (which does not modify the
      string), and then free it. We can just pass the original
      string instead.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a92330d2
    • J
      format_config: simplify buffer handling · f2259877
      Jeff King 提交于
      When formatting a config value into a strbuf, we may end
      up stringifying it into a fixed-size buffer using sprintf,
      and then copying that buffer into the strbuf. We can
      eliminate the middle-man (and drop some calls to sprintf!)
      by writing directly to the strbuf.
      
      The reason it was written this way in the first place is
      that we need to know before writing the value whether to
      insert a delimiter. Instead of delaying the write of the
      value, we speculatively write the delimiter, and roll it
      back in the single case that cares.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f2259877
    • J
      format_config: don't init strbuf · 9f1429df
      Jeff King 提交于
      It's unusual for a function which writes to a passed-in
      strbuf to call strbuf_init; that will throw away anything
      already there, leaking memory. In this case, there are
      exactly two callers; one relies on this initialization and
      the other passes in an already-initialized buffer.
      
      There's no leak, as the initialized buffer doesn't have
      anything in it. But let's bump the strbuf_init out to the
      one caller who needs it, making format_config more
      idiomatic.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9f1429df
    • S
      config: restructure format_config() for better control flow · ebca2d49
      SZEDER Gábor 提交于
      Commit 578625fa (config: add '--name-only' option to list only
      variable names, 2015-08-10) modified format_config() such that it
      returned from the middle of the function when showing only keys,
      resulting in ugly code structure.
      
      Reorganize the if statements and dealing with the key-value delimiter to
      make the function easier to read.
      Signed-off-by: NSZEDER Gábor <szeder@ira.uka.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ebca2d49
    • J
      ps_matched: xcalloc() takes nmemb and then element size · 8b54c234
      Junio C Hamano 提交于
      Even though multiplication is commutative, the order of arguments
      should be xcalloc(nmemb, size).  ps_matched is an array of 1-byte
      element whose size is the same as the number of pathspec elements.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8b54c234
  14. 20 8月, 2015 6 次提交
  15. 18 8月, 2015 3 次提交
  16. 13 8月, 2015 1 次提交