1. 29 4月, 2016 4 次提交
    • J
      submodule: use prepare_submodule_repo_env consistently · c12e8656
      Jeff King 提交于
      Before 14111fc4 (git: submodule honor -c credential.* from
      command line, 2016-02-29), it was sufficient for code which
      spawned a process in a submodule to just set the child
      process's "env" field to "local_repo_env" to clear the
      environment of any repo-specific variables.
      
      That commit introduced a more complicated procedure, in
      which we clear most variables but allow through sanitized
      config. For C code, we used that procedure only for cloning,
      but not for any of the programs spawned by submodule.c. As a
      result, things like "git fetch --recurse-submodules" behave
      differently than "git clone --recursive"; the former will
      not pass through the sanitized config.
      
      We can fix this by using prepare_submodule_repo_env()
      everywhere in submodule.c.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c12e8656
    • J
      submodule: export sanitized GIT_CONFIG_PARAMETERS · 860cba61
      Jeff King 提交于
      Commit 14111fc4 (git: submodule honor -c credential.* from
      command line, 2016-02-29) taught git-submodule.sh to save
      the sanitized value of $GIT_CONFIG_PARAMETERS when clearing
      the environment for a submodule. However, it failed to
      export the result, meaning that it had no effect for any
      sub-programs.
      
      We didn't catch this in our initial tests because we checked
      only the "clone" case, which does not go through the shell
      script at all. Provoking "git submodule update" to do a
      fetch demonstrates the bug.
      Noticed-by: NLars Schneider <larsxschneider@gmail.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      860cba61
    • J
      t5550: break submodule config test into multiple sub-tests · 455d22c1
      Jeff King 提交于
      Right now we test only the cloning case, but there are other
      interesting cases (e.g., fetching). Let's pull the setup
      bits into their own test, which will make things flow more
      logically once we start adding more tests which use the
      setup.
      
      Let's also introduce some whitespace to the clone-test to
      split the two parts: making sure it fails without our
      cmdline config, and that it succeeds with it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      455d22c1
    • J
      t5550: fix typo in $HTTPD_URL · 1149ee21
      Jeff King 提交于
      Commit 14111fc4 (git: submodule honor -c credential.* from
      command line, 2016-02-29) accidentally wrote $HTTP_URL. It
      happened to work because we ended up with "credential..helper",
      which we treat the same as "credential.helper", applying it
      to all URLs.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1149ee21
  2. 02 3月, 2016 1 次提交
    • J
      git: submodule honor -c credential.* from command line · 14111fc4
      Jacob Keller 提交于
      Due to the way that the git-submodule code works, it clears all local
      git environment variables before entering submodules. This is normally
      a good thing since we want to clear settings such as GIT_WORKTREE and
      other variables which would affect the operation of submodule commands.
      However, GIT_CONFIG_PARAMETERS is special, and we actually do want to
      preserve these settings. However, we do not want to preserve all
      configuration as many things should be left specific to the parent
      project.
      
      Add a git submodule--helper function, sanitize-config, which shall be
      used to sanitize GIT_CONFIG_PARAMETERS, removing all key/value pairs
      except a small subset that are known to be safe and necessary.
      
      Replace all the calls to clear_local_git_env with a wrapped function
      that filters GIT_CONFIG_PARAMETERS using the new helper and then
      restores it to the filtered subset after clearing the rest of the
      environment.
      Signed-off-by: NJacob Keller <jacob.keller@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      14111fc4
  3. 05 1月, 2016 1 次提交
    • E
      t/t5550-http-fetch-dumb.sh: use the $( ... ) construct for command substitution · bacb1c01
      Elia Pinto 提交于
      The Git CodingGuidelines prefer the $(...) construct for command
      substitution instead of using the backquotes `...`.
      
      The backquoted form is the traditional method for command
      substitution, and is supported by POSIX.  However, all but the
      simplest uses become complicated quickly.  In particular, embedded
      command substitutions and/or the use of double quotes require
      careful escaping with the backslash character.
      
      The patch was generated by:
      
      for _f in $(find . -name "*.sh")
      do
      	perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
      done
      
      and then carefully proof-read.
      Signed-off-by: NElia Pinto <gitter.spiros@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bacb1c01
  4. 07 5月, 2015 1 次提交
  5. 21 3月, 2015 2 次提交
    • J
      t: use test_might_fail for diff and grep · 35da1bf5
      Jeff King 提交于
      Some tests run diff or grep to produce an output, and then
      compare the output to an expected value. We know the exit
      code we expect these processes to have (e.g., grep yields 0
      if it produced output and 1 otherwise), so it would not make
      the test wrong to look for it. But the difference between
      their output and the expected output (e.g., shown by
      test_cmp) is much more useful to somebody debugging the test
      than the test just bailing out.
      
      These tests break the &&-chain to skip the exit-code check
      of the process. However, we can get the same effect by using
      test_might_fail. Note that in some cases the test did use
      "|| return 1", which meant the test was not wrong, but it
      did fool --chain-lint.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      35da1bf5
    • J
      t: fix trivial &&-chain breakage · 99094a7a
      Jeff King 提交于
      These are tests which are missing a link in their &&-chain,
      but during a setup phase. We may fail to notice failure in
      commands that build the test environment, but these are
      typically not expected to fail at all (but it's still good
      to double-check that our test environment is what we
      expect).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      99094a7a
  6. 29 1月, 2015 1 次提交
    • Y
      http: add Accept-Language header if possible · f18604bb
      Yi EungJun 提交于
      Add an Accept-Language header which indicates the user's preferred
      languages defined by $LANGUAGE, $LC_ALL, $LC_MESSAGES and $LANG.
      
      Examples:
        LANGUAGE= -> ""
        LANGUAGE=ko:en -> "Accept-Language: ko, en;q=0.9, *;q=0.1"
        LANGUAGE=ko LANG=en_US.UTF-8 -> "Accept-Language: ko, *;q=0.1"
        LANGUAGE= LANG=en_US.UTF-8 -> "Accept-Language: en-US, *;q=0.1"
      
      This gives git servers a chance to display remote error messages in
      the user's preferred language.
      
      Limit the number of languages to 1,000 because q-value must not be
      smaller than 0.001, and limit the length of Accept-Language header to
      4,000 bytes for some HTTP servers which cannot accept such long header.
      Signed-off-by: NYi EungJun <eungjun.yi@navercorp.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f18604bb
  7. 28 1月, 2015 1 次提交
    • J
      dumb-http: do not pass NULL path to parse_pack_index · 8b9c2dd4
      Jeff King 提交于
      Once upon a time, dumb http always fetched .idx files
      directly into their final location, and then checked their
      validity with parse_pack_index. This was refactored in
      commit 750ef425 (http-fetch: Use temporary files for
      pack-*.idx until verified, 2010-04-19), which uses the
      following logic:
      
        1. If we have the idx already in place, see if it's
           valid (using parse_pack_index). If so, use it.
      
        2. Otherwise, fetch the .idx to a tempfile, check
           that, and if so move it into place.
      
        3. Either way, fetch the pack itself if necessary.
      
      However, it got step 1 wrong. We pass a NULL path parameter
      to parse_pack_index, so an existing .idx file always looks
      broken. Worse, we do not treat this broken .idx as an
      opportunity to re-fetch, but instead return an error,
      ignoring the pack entirely. This can lead to a dumb-http
      fetch failing to retrieve the necessary objects.
      
      This doesn't come up much in practice, because it must be a
      packfile that we found out about (and whose .idx we stored)
      during an earlier dumb-http fetch, but whose packfile we
      _didn't_ fetch. I.e., we did a partial clone of a
      repository, didn't need some packfiles, and now a followup
      fetch needs them.
      
      Discovery and tests by Charles Bailey <charles@hashpling.org>.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8b9c2dd4
  8. 18 6月, 2014 1 次提交
    • Y
      http: fix charset detection of extract_content_type() · f34a655d
      Yi EungJun 提交于
      extract_content_type() could not extract a charset parameter if the
      parameter is not the first one and there is a whitespace and a following
      semicolon just before the parameter. For example:
      
          text/plain; format=fixed ;charset=utf-8
      
      And it also could not handle correctly some other cases, such as:
      
          text/plain; charset=utf-8; format=fixed
          text/plain; some-param="a long value with ;semicolons;"; charset=utf-8
      
      Thanks-to: Jeff King <peff@peff.net>
      Signed-off-by: NYi EungJun <eungjun.yi@navercorp.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f34a655d
  9. 28 5月, 2014 2 次提交
    • J
      remote-curl: reencode http error messages · fc1b774c
      Jeff King 提交于
      We currently recognize an error message with a content-type
      "text/plain; charset=utf-16" as text, but we ignore the
      charset parameter entirely. Let's encode it to
      log_output_encoding, which is presumably something the
      user's terminal can handle.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fc1b774c
    • J
      http: extract type/subtype portion of content-type · bf197fd7
      Jeff King 提交于
      When we get a content-type from curl, we get the whole
      header line, including any parameters, and without any
      normalization (like downcasing or whitespace) applied.
      If we later try to match it with strcmp() or even
      strcasecmp(), we may get false negatives.
      
      This could cause two visible behaviors:
      
        1. We might fail to recognize a smart-http server by its
           content-type.
      
        2. We might fail to relay text/plain error messages to
           users (especially if they contain a charset parameter).
      
      This patch teaches the http code to extract and normalize
      just the type/subtype portion of the string. This is
      technically passing out less information to the callers, who
      can no longer see the parameters. But none of the current
      callers cares, and a future patch will add back an
      easier-to-use method for accessing those parameters.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bf197fd7
  10. 24 5月, 2014 1 次提交
  11. 11 2月, 2014 2 次提交
  12. 03 1月, 2014 1 次提交
    • J
      use distinct username/password for http auth tests · afbf5ca5
      Jeff King 提交于
      The httpd server we set up to test git's http client code
      knows about a single account, in which both the username and
      password are "user@host" (the unusual use of the "@" here is
      to verify that we handle the character correctly when URL
      escaped).
      
      This means that we may miss a certain class of errors in
      which the username and password are mixed up internally by
      git. We can make our tests more robust by having distinct
      values for the username and password.
      
      In addition to tweaking the server passwd file and the
      client URL, we must teach the "askpass" harness to accept
      multiple values. As a bonus, this makes the setup of some
      tests more obvious; when we are expecting git to ask
      only about the password, we can seed the username askpass
      response with a bogus value.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      afbf5ca5
  13. 04 4月, 2013 1 次提交
  14. 09 10月, 2012 1 次提交
  15. 28 8月, 2012 2 次提交
    • J
      t5550: factor out http auth setup · e837936c
      Jeff King 提交于
      The t5550 script sets up a nice askpass helper for
      simulating user input and checking what git prompted for.
      Let's make it available to other http scripts by migrating
      it to lib-httpd.
      
      We can use this immediately in t5540 to make our tests more
      robust (previously, we did not check at all that hitting the
      password-protected repo actually involved a password).
      Unfortunately, we end up failing the test because the
      current code erroneously prompts twice (once for
      git-remote-http, and then again when the former spawns
      git-http-push).
      
      More importantly, though, it will let us easily add
      smart-http authentication tests in t5541 and t5551; we
      currently do not test smart-http authentication at all.
      
      As part of making it generic, let's always look for and
      store auxiliary askpass files at the top-level trash
      directory; this makes it compatible with t5540, which runs
      some tests from sub-repositories. We can abstract away the
      ugliness with a short helper function.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e837936c
    • J
      t5550: put auth-required repo in auth/dumb · 726800a8
      Jeff King 提交于
      In most of our tests, we put repos to be accessed by dumb
      protocols in /dumb, and repos to be accessed by smart
      protocols in /smart.  In our test apache setup, the whole
      /auth hierarchy requires authentication. However, we don't
      bother to split it by smart and dumb here because we are not
      currently testing smart-http authentication at all.
      
      That will change in future patches, so let's be explicit
      that we are interested in testing dumb access here. This
      also happens to match what t5540 does for the push tests.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      726800a8
  16. 11 4月, 2012 2 次提交
  17. 05 1月, 2012 1 次提交
  18. 12 12月, 2011 5 次提交
    • J
      credential: make relevance of http path configurable · a78fbb4f
      Jeff King 提交于
      When parsing a URL into a credential struct, we carefully
      record each part of the URL, including the path on the
      remote host, and use the result as part of the credential
      context.
      
      This had two practical implications:
      
        1. Credential helpers which store a credential for later
           access are likely to use the "path" portion as part of
           the storage key. That means that a request to
      
             https://example.com/foo.git
      
           would not use the same credential that was stored in an
           earlier request for:
      
             https://example.com/bar.git
      
        2. The prompt shown to the user includes all relevant
           context, including the path.
      
      In most cases, however, users will have a single password
      per host. The behavior in (1) will be inconvenient, and the
      prompt in (2) will be overly long.
      
      This patch introduces a config option to toggle the
      relevance of http paths. When turned on, we use the path as
      before. When turned off, we drop the path component from the
      context: helpers don't see it, and it does not appear in the
      prompt.
      
      This is nothing you couldn't do with a clever credential
      helper at the start of your stack, like:
      
        [credential "http://"]
      	helper = "!f() { grep -v ^path= ; }; f"
      	helper = your_real_helper
      
      But doing this:
      
        [credential]
      	useHttpPath = false
      
      is way easier and more readable. Furthermore, since most
      users will want the "off" behavior, that is the new default.
      Users who want it "on" can set the variable (either for all
      credentials, or just for a subset using
      credential.*.useHttpPath).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a78fbb4f
    • J
      credential: add credential.*.username · d5742425
      Jeff King 提交于
      Credential helpers can help users avoid having to type their
      username and password over and over. However, some users may
      not want a helper for their password, or they may be running
      a helper which caches for a short time. In this case, it is
      convenient to provide the non-secret username portion of
      their credential via config.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d5742425
    • J
      credential: apply helper config · 11825072
      Jeff King 提交于
      The functionality for credential storage helpers is already
      there; we just need to give the users a way to turn it on.
      This patch provides a "credential.helper" configuration
      variable which allows the user to provide one or more helper
      strings.
      
      Rather than simply matching credential.helper, we will also
      compare URLs in subsection headings to the current context.
      This means you can apply configuration to a subset of
      credentials. For example:
      
        [credential "https://example.com"]
      	helper = foo
      
      would match a request for "https://example.com/foo.git", but
      not one for "https://kernel.org/foo.git".
      
      This is overkill for the "helper" variable, since users are
      unlikely to want different helpers for different sites (and
      since helpers run arbitrary code, they could do the matching
      themselves anyway).
      
      However, future patches will add new config variables where
      this extra feature will be more useful.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      11825072
    • J
      http: use credential API to get passwords · 148bb6a7
      Jeff King 提交于
      This patch converts the http code to use the new credential
      API, both for http authentication as well as for getting
      certificate passwords.
      
      Most of the code change is simply variable naming (the
      passwords are now contained inside the credential struct)
      or deletion of obsolete code (the credential code handles
      URL parsing and prompting for us).
      
      The behavior should be the same, with one exception: the
      credential code will prompt with a description based on the
      credential components. Therefore, the old prompt of:
      
        Username for 'example.com':
        Password for 'example.com':
      
      now looks like:
      
        Username for 'https://example.com/repo.git':
        Password for 'https://user@example.com/repo.git':
      
      Note that we include more information in each line,
      specifically:
      
        1. We now include the protocol. While more noisy, this is
           an important part of knowing what you are accessing
           (especially if you care about http vs https).
      
        2. We include the username in the password prompt. This is
           not a big deal when you have just been prompted for it,
           but the username may also come from the remote's URL
           (and after future patches, from configuration or
           credential helpers).  In that case, it's a nice
           reminder of the user for which you're giving the
           password.
      
        3. We include the path component of the URL. In many
           cases, the user won't care about this and it's simply
           noise (i.e., they'll use the same credential for a
           whole site). However, that is part of a larger
           question, which is whether path components should be
           part of credential context, both for prompting and for
           lookup by storage helpers. That issue will be addressed
           as a whole in a future patch.
      
      Similarly, for unlocking certificates, we used to say:
      
        Certificate Password for 'example.com':
      
      and we now say:
      
        Password for 'cert:///path/to/certificate':
      
      Showing the path to the client certificate makes more sense,
      as that is what you are unlocking, not "example.com".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      148bb6a7
    • J
      t5550: fix typo · 89650285
      Jeff King 提交于
      This didn't have an impact, because it was just setting up
      an "expect" file that happened to be identical to the one in
      the test before it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      89650285
  19. 18 10月, 2011 1 次提交
  20. 16 10月, 2011 1 次提交
  21. 21 7月, 2011 1 次提交
  22. 27 11月, 2010 2 次提交
  23. 18 11月, 2010 2 次提交
  24. 26 6月, 2010 1 次提交
  25. 20 4月, 2010 2 次提交
    • S
      http-fetch: Use temporary files for pack-*.idx until verified · 750ef425
      Shawn O. Pearce 提交于
      Verify that a downloaded pack-*.idx file is consistent and valid
      as an index file before we rename it into its final destination.
      This prevents a corrupt index file from later being treated as a
      usable file, confusing readers.
      
      Check that we do not have the pack index file before invoking
      fetch_pack_index(); that way, we can do without the has_pack_index()
      check in fetch_pack_index().
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      750ef425
    • S
      http-fetch: Use index-pack rather than verify-pack to check packs · fe72d420
      Shawn O. Pearce 提交于
      To ensure we don't leave a corrupt pack file positioned as though
      it were a valid pack file, run index-pack on the temporary pack
      before we rename it to its final name.  If index-pack crashes out
      when it discovers file corruption (e.g. GitHub's error HTML at the
      end of the file), simply delete the temporary files to cleanup.
      
      By waiting until the pack has been validated before we move it
      to its final name, we eliminate a race condition where another
      concurrent reader might try to access the pack at the same time
      that we are still trying to verify its not corrupt.
      
      Switching from verify-pack to index-pack is a change in behavior,
      but it should turn out better for users.  The index-pack algorithm
      tries to minimize disk seeks, as well as the number of times any
      given object is inflated, by organizing its work along delta chains.
      The verify-pack logic does not attempt to do this, thrashing the
      delta base cache and the filesystem cache.
      
      By recreating the index file locally, we also can automatically
      upgrade from a v1 pack table of contents to v2.  This makes the
      CRC32 data available for use during later repacks, even if the
      server didn't have them on hand.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Acked-by: NTay Ray Chuan <rctay89@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fe72d420