Skip to content
  • Jeff King's avatar
    credential: make relevance of http path configurable · a78fbb4f
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    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: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    a78fbb4f