1. 03 1月, 2014 1 次提交
    • J
      Revert "prompt: clean up strbuf usage" · e1c1a324
      Jeff King 提交于
      This reverts commit 31b49d9b.
      
      That commit taught do_askpass to hand ownership of our
      buffer back to the caller rather than simply return a
      pointer into our internal strbuf.  What it failed to notice,
      though, was that our internal strbuf is static, because we
      are trying to emulate the getpass() interface.
      
      By handing off ownership, we created a memory leak that
      cannot be solved. Sometimes git_prompt returns a static
      buffer from getpass() (or our smarter git_terminal_prompt
      wrapper), and sometimes it returns an allocated string from
      do_askpass.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e1c1a324
  2. 04 2月, 2012 2 次提交
    • J
      prompt: fall back to terminal if askpass fails · 84d72733
      Jeff King 提交于
      The current askpass code simply dies if calling an askpass
      helper fails. Worse, in some failure modes it doesn't even
      print an error (if start_command fails, then it prints its
      own error; if reading fails, we print an error; but if the
      command exits non-zero, finish_command fails and we print
      nothing!).
      
      Let's be more kind to the user by printing an error message
      when askpass doesn't work out, and then falling back to the
      terminal (which also may fail, of course, but we die already
      there with a nice message).
      
      While we're at it, let's clean up the existing error
      messages a bit.  Now that our prompts are very long and
      contain quotes and colons themselves, our error messages are
      hard to read.
      
      So the new failure modes look like:
      
        [before, with a terminal]
        $ GIT_ASKPASS=false git push
        $ echo $?
        128
      
        [before, with no terminal, and we must give up]
        $ setsid git push
        fatal: could not read 'Password for 'https://peff@github.com': ': No such device or address
      
        [after, with a terminal]
        $ GIT_ASKPASS=false git push
        error: unable to read askpass response from 'false'
        Password for 'https://peff@github.com':
      
        [after, with no terminal, and we must give up]
        $ GIT_ASKPASS=false setsid git push
        error: unable to read askpass response from 'false'
        fatal: could not read Password for 'https://peff@github.com': No such device or address
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      84d72733
    • J
      prompt: clean up strbuf usage · 31b49d9b
      Jeff King 提交于
      The do_askpass function inherited a few bad habits from the
      original git_getpass. One, there's no need to strbuf_reset a
      buffer which was just initialized. And two, it's a good
      habit to use strbuf_detach to claim ownership of a buffer's
      string (even though in this case the owning buffer goes out
      of scope, so it's effectively the same thing).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      31b49d9b
  3. 13 12月, 2011 3 次提交