1. 09 7月, 2016 7 次提交
    • J
      write_file: add format attribute · e04d08a4
      Jeff King 提交于
      This gives us compile-time checking of our format strings,
      which is a good thing.
      
      I had also hoped it would help with confusing write_file()
      and write_file_buf(), since the former's "..." can make it
      match the signature of the latter. But given that the buffer
      for write_file_buf() is generally not a string literal, the
      compiler won't complain unless -Wformat-nonliteral is on,
      and that creates a ton of false positives elsewhere in the
      code base.
      
      While we're there, let's also give the function a docstring,
      which it never had.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e04d08a4
    • J
      write_file: add pointer+len variant · 52563d7e
      Jeff King 提交于
      There are many callsites which could use write_file, but for
      which it is a little awkward because they have a strbuf or
      other pointer/len combo. Specifically:
      
       1. write_file() takes a format string, so we have to use
          "%s" or "%.*s", which are ugly.
      
       2. Using any form of "%s" does not handle embedded NULs in
          the output. That probably doesn't matter for our
          call-sites, but it's nicer not to have to worry.
      
       3. It's less efficient; we format into another strbuf
          just to do the write. That's probably not measurably
          slow for our uses, but it's simply inelegant.
      
      We can fix this by providing a helper to write out the
      formatted buffer, and just calling it from write_file().
      
      Note that we don't do the usual "complete with a newline"
      that write_file does. If the caller has their own buffer,
      there's a reasonable chance they're doing something more
      complicated than a single line, and they can call
      strbuf_complete_line() themselves.
      
      We could go even further and add strbuf_write_file(), but it
      doesn't save much:
      
        -  write_file_buf(path, sb.buf, sb.len);
        +  strbuf_write_file(&sb, path);
      
      It would also be somewhat asymmetric with strbuf_read_file,
      which actually returns errors rather than dying (and the
      error handling is most of the benefit of write_file() in the
      first place).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      52563d7e
    • J
      write_file: use xopen · ee861e0f
      Jeff King 提交于
      This simplifies the code a tiny bit, and provides consistent
      error messages with other users of xopen().
      
      While we're here, let's also switch to using O_WRONLY. We
      know we're only going to open/write/close the file, so
      there's no point in asking for O_RDWR.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ee861e0f
    • J
      write_file: drop "gently" form · ef22318c
      Jeff King 提交于
      There are no callers left of write_file_gently(). Let's drop
      it, as it doesn't seem likely for new callers to be added
      (since its inception, the only callers who wanted the gentle
      form generally just died immediately themselves, and have
      since been converted).
      
      While we're there, let's also drop the "int" return from
      write_file, as it is never meaningful (in the non-gentle
      form, we always either die or return 0).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ef22318c
    • J
      branch: use non-gentle write_file for branch description · 3d75bba2
      Jeff King 提交于
      We use write_file_gently() to do this job currently.
      However, if we see an error, we simply complain via
      error_errno() and then end up exiting with an error code.
      
      By switching to the non-gentle form, the function will die
      for us, with a better error. It is more specific about which
      syscall caused the error, and that mentions the
      actual filename we're trying to write.
      
      Our exit code for the error case does switch from "1" to
      "128", but that's OK; it wasn't a meaningful documented code
      (and in fact it was odd that it was a different exit code
      than most other error conditions).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3d75bba2
    • R
      am: ignore return value of write_file() · 1dad879a
      René Scharfe 提交于
      write_file() either returns 0 or dies, so there is no point in checking
      its return value.  The callers of the wrappers write_state_text(),
      write_state_count() and write_state_bool() consequently already ignore
      their return values.  Stop pretending we care and make them void.
      Signed-off-by: NRene Scharfe <l.s.r@web.de>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1dad879a
    • J
      config: fix bogus fd check when setting up default config · aabbd3f3
      Jeff King 提交于
      Since 9830534e (config --global --edit: create a template
      file if needed, 2014-07-25), an edit of the global config
      file will try to open() it with O_EXCL, and wants to handle
      three cases:
      
        1. We succeeded; the user has no config file, and we
           should fill in the default template.
      
        2. We got EEXIST; they have a file already, proceed as usual.
      
        3. We got another error; we should complain.
      
      However, the check for case 1 does "if (fd)", which will
      generally _always_ be true (except for the oddball case that
      somehow our stdin got closed and opening really did give us
      a new descriptor 0).
      
      So in the EEXIST case, we tried to write the default config
      anyway! Fortunately, this turns out to be a noop, since we
      just end up writing to and closing "-1", which does nothing.
      
      But in case 3, we would fail to notice any other errors, and
      just silently continue (given that we don't actually notice
      write errors for the template either, it's probably not that
      big a deal; we're about to spawn the editor, so it would
      notice any problems. But the code is clearly _trying_ to hit
      cover this case and failing).
      
      We can fix it easily by using "fd >= 0" for case 1.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aabbd3f3
  2. 14 6月, 2016 1 次提交
  3. 13 6月, 2016 1 次提交
    • J
      Merge tag 'l10n-2.9.0-rc0' of git://github.com/git-l10n/git-po · 25c7aeb1
      Junio C Hamano 提交于
      l10n-2.9.0-rc0
      
      * tag 'l10n-2.9.0-rc0' of git://github.com/git-l10n/git-po:
        l10n: ko.po: Update Korean translation
        l10n: ru.po: update Russian translation
        l10n: de.po: translate 104 new messages
        l10n: zh_CN: review for git v2.9.0 l10n round 1
        l10n: zh_CN: for git v2.9.0 l10n round 1
        l10n: pt_PT: update Portuguese translation
        l10n: pt_PT: update according to git-gui glossary
        l10n: pt_PT: merge git.pot file
        l10n: Updated Bulgarian translation of git (2597t,0f,0u)
        l10n: sv.po: Update Swedish translation (2597t0f0u)
        l10n: fr.po v2.9.0rnd1
        l10n: Updated Vietnamese translation (2597t)
        l10n: git.pot: v2.9.0 round 1 (104 new, 37 removed)
        l10n: fr.po Fixed grammar mistake
      25c7aeb1
  4. 12 6月, 2016 1 次提交
  5. 11 6月, 2016 8 次提交
  6. 09 6月, 2016 1 次提交
  7. 07 6月, 2016 9 次提交
  8. 06 6月, 2016 1 次提交
  9. 04 6月, 2016 10 次提交
  10. 02 6月, 2016 1 次提交