summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-03-10Merge branch 'jk/http-auth'Libravatar Junio C Hamano1-4/+46
Reduce authentication round-trip over HTTP when the server supports just a single authentication method. * jk/http-auth: http: add an "auto" mode for http.emptyauth http: restrict auth methods to what the server advertises
2017-03-10Merge branch 'jh/send-email-one-cc'Libravatar Junio C Hamano2-5/+4
"Cc:" on the trailer part does not have to conform to RFC strictly, unlike in the e-mail header. "git send-email" has been updated to ignore anything after '>' when picking addresses, to allow non-address cruft like " # stable 4.4" after the address. * jh/send-email-one-cc: send-email: only allow one address per body tag
2017-03-10Merge branch 'rs/strbuf-add-real-path'Libravatar Junio C Hamano6-2/+49
An helper function to make it easier to append the result from real_path() to a strbuf has been added. * rs/strbuf-add-real-path: strbuf: add strbuf_add_real_path() cocci: use ALLOC_ARRAY
2017-03-10Merge branch 'rs/sha1-file-plug-fallback-base-leak'Libravatar Junio C Hamano1-0/+4
A leak in a codepath to read from a packed object in (rare) cases has been plugged. * rs/sha1-file-plug-fallback-base-leak: sha1_file: release fallback base's memory in unpack_entry()
2017-03-10Merge branch 'rs/commit-parsing-optim'Libravatar Junio C Hamano1-12/+10
The code that parses header fields in the commit object has been updated for (micro)performance and code hygiene. * rs/commit-parsing-optim: commit: don't check for space twice when looking for header commit: be more precise when searching for headers
2017-03-10Merge branch 'jk/t6300-cleanup'Libravatar Junio C Hamano1-1/+1
A test that creates a confusing branch whose name is HEAD has been corrected not to do so. * jk/t6300-cleanup: t6300: avoid creating refs/heads/HEAD
2017-03-10Merge branch 'jk/parse-config-key-cleanup'Libravatar Junio C Hamano3-11/+16
The "parse_config_key()" API function has been cleaned up. * jk/parse-config-key-cleanup: parse_hide_refs_config: tell parse_config_key we don't want a subsection parse_config_key: allow matching single-level config parse_config_key: use skip_prefix instead of starts_with
2017-03-10Merge branch 'sb/parse-hide-refs-config-cleanup'Libravatar Junio C Hamano1-3/+4
Code clean-up. * sb/parse-hide-refs-config-cleanup: refs: parse_hide_refs_config to use parse_config_key
2017-03-10Merge branch 'jt/upload-pack-error-report'Libravatar Junio C Hamano1-1/+5
"git upload-pack", which is a counter-part of "git fetch", did not report a request for a ref that was not advertised as invalid. This is generally not a problem (because "git fetch" will stop before making such a request), but is the right thing to do. * jt/upload-pack-error-report: upload-pack: report "not our ref" to client
2017-03-10Merge branch 'jk/ident-empty'Libravatar Junio C Hamano2-19/+66
user.email that consists of only cruft chars should consistently error out, but didn't. * jk/ident-empty: ident: do not ignore empty config name/email ident: reject all-crud ident name ident: handle NULL email when complaining of empty name ident: mark error messages for translation
2017-03-10Merge branch 'jc/config-case-cmdline-take-2'Libravatar Junio C Hamano2-97/+163
The code to parse "git -c VAR=VAL cmd" and set configuration variable for the duration of cmd had two small bugs, which have been fixed. * jc/config-case-cmdline-take-2: config: use git_config_parse_key() in git_config_parse_parameter() config: move a few helper functions up
2017-03-07git svn: fix authentication with 'branch'Libravatar Hiroshi Shirosaki1-3/+3
Authentication fails with svn branch while svn rebase and svn dcommit work fine without authentication failures. $ git svn branch v7_3 Copying https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx at r27519 to https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/v7_3... Can't create session: Unable to connect to a repository at URL 'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': No more credentials or we tried too many times. Authentication failed at C:\Program Files\Git\mingw64/libexec/git-core\git-svn line 1200. We add auth configuration to SVN::Client->new() to fix the issue. Signed-off-by: Hiroshi Shirosaki <h.shirosaki@gmail.com> Signed-off-by: Eric Wong <e@80x24.org>
2017-02-27First batch after 2.12Libravatar Junio C Hamano3-2/+153
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-27Merge branch 'rl/remote-allow-missing-branch-name-merge'Libravatar Junio C Hamano2-1/+22
"git remote rm X", when a branch has remote X configured as the value of its branch.*.remote, tried to remove branch.*.remote and branch.*.merge and failed if either is unset. * rl/remote-allow-missing-branch-name-merge: remote: ignore failure to remove missing branch.<name>.merge
2017-02-27Merge branch 'km/delete-ref-reflog-message'Libravatar Junio C Hamano18-30/+58
"git update-ref -d" and other operations to delete references did not leave any entry in HEAD's reflog when the reference being deleted was the current branch. This is not a problem in practice because you do not want to delete the branch you are currently on, but caused renaming of the current branch to something else not to be logged in a useful way. * km/delete-ref-reflog-message: branch: record creation of renamed branch in HEAD's log rename_ref: replace empty message in HEAD's log update-ref: pass reflog message to delete_ref() delete_ref: accept a reflog message argument
2017-02-27Merge branch 'jk/tempfile-ferror-fclose-confusion'Libravatar Junio C Hamano1-2/+7
A caller of tempfile API that uses stdio interface to write to files may ignore errors while writing, which is detected when tempfile is closed (with a call to ferror()). By that time, the original errno that may have told us what went wrong is likely to be long gone and was overwritten by an irrelevant value. close_tempfile() now resets errno to EIO to make errno at least predictable. * jk/tempfile-ferror-fclose-confusion: tempfile: set errno to a known value before calling ferror()
2017-02-27Merge branch 'vn/xdiff-func-context'Libravatar Junio C Hamano1-8/+6
"git diff -W" has been taught to handle the case where a new function is added at the end of the file better. * vn/xdiff-func-context: xdiff -W: relax end-of-file function detection
2017-02-27Merge branch 'js/git-path-in-subdir'Libravatar Junio C Hamano4-5/+64
The "--git-path", "--git-common-dir", and "--shared-index-path" options of "git rev-parse" did not produce usable output. They are now updated to show the path to the correct file, relative to where the caller is. * js/git-path-in-subdir: rev-parse: fix several options when running in a subdirectory rev-parse tests: add tests executed from a subdirectory
2017-02-27Merge branch 'mm/two-more-xstrfmt'Libravatar Junio C Hamano2-11/+9
Code clean-up and a string truncation fix. * mm/two-more-xstrfmt: bisect_next_all: convert xsnprintf to xstrfmt stop_progress_msg: convert xsnprintf to xstrfmt
2017-02-27Merge branch 'nd/clean-preserve-errno-in-warning'Libravatar Junio C Hamano1-4/+12
Some warning() messages from "git clean" were updated to show the errno from failed system calls. * nd/clean-preserve-errno-in-warning: clean: use warning_errno() when appropriate
2017-02-27Merge branch 'jk/show-branch-lift-name-len-limit'Libravatar Junio C Hamano1-29/+13
"git show-branch" expected there were only very short branch names in the repository and used a fixed-length buffer to hold them without checking for overflow. * jk/show-branch-lift-name-len-limit: show-branch: use skip_prefix to drop magic numbers show-branch: store resolved head in heap buffer show-branch: drop head_len variable
2017-02-27Merge branch 'jn/remote-helpers-with-git-dir'Libravatar Junio C Hamano4-3/+22
"git ls-remote" and "git archive --remote" are designed to work without being in a directory under Git's control. However, recent updates revealed that we randomly look into a directory called .git/ without actually doing necessary set-up when working in a repository. Stop doing so. * jn/remote-helpers-with-git-dir: remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR remote: avoid reading $GIT_DIR config in non-repo
2017-02-27Merge branch 'jk/grep-no-index-fix'Libravatar Junio C Hamano2-27/+121
The code to parse the command line "git grep <patterns>... <rev> [[--] <pathspec>...]" has been cleaned up, and a handful of bugs have been fixed (e.g. we used to check "--" if it is a rev). * jk/grep-no-index-fix: grep: treat revs the same for --untracked as for --no-index grep: do not diagnose misspelt revs with --no-index grep: avoid resolving revision names in --no-index case grep: fix "--" rev/pathspec disambiguation grep: re-order rev-parsing loop grep: do not unnecessarily query repo for "--" grep: move thread initialization a little lower
2017-02-27Merge branch 'dt/gc-ignore-old-gc-logs'Libravatar Junio C Hamano3-7/+71
A "gc.log" file left by a backgrounded "gc --auto" disables further automatic gc; it has been taught to run at least once a day (by default) by ignoring a stale "gc.log" file that is too old. * dt/gc-ignore-old-gc-logs: gc: ignore old gc.log files
2017-02-27Merge branch 'jh/preload-index-skip-skip'Libravatar Junio C Hamano1-0/+2
The preload-index code has been taught not to bother with the index entries that are paths that are not checked out by "sparse checkout". * jh/preload-index-skip-skip: preload-index: avoid lstat for skip-worktree items
2017-02-27Merge branch 'mh/submodule-hash'Libravatar Junio C Hamano3-112/+134
Code and design clean-up for the refs API. * mh/submodule-hash: read_loose_refs(): read refs using resolve_ref_recursively() files_ref_store::submodule: use NULL for the main repository base_ref_store_init(): remove submodule argument refs: push the submodule attribute down refs: store submodule ref stores in a hashmap register_ref_store(): new function refs: remove some unnecessary handling of submodule == "" refs: make some ref_store lookup functions private refs: reorder some function definitions
2017-02-27Merge branch 'sf/putty-w-args'Libravatar Junio C Hamano4-19/+133
The command line options for ssh invocation needs to be tweaked for some implementations of SSH (e.g. PuTTY plink wants "-P <port>" while OpenSSH wants "-p <port>" to specify port to connect to), and the variant was guessed when GIT_SSH environment variable is used to specify it. The logic to guess now applies to the command specified by the newer GIT_SSH_COMMAND and also core.sshcommand configuration variable, and comes with an escape hatch for users to deal with misdetected cases. * sf/putty-w-args: connect.c: stop conflating ssh command names and overrides connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config git_connect(): factor out SSH variant handling connect: rename tortoiseplink and putty variables connect: handle putty/plink also in GIT_SSH_COMMAND
2017-02-27Merge branch 'js/rebase-helper'Libravatar Junio C Hamano7-1/+58
"git rebase -i" starts using the recently updated "sequencer" code. * js/rebase-helper: rebase -i: use the rebase--helper builtin rebase--helper: add a builtin helper for interactive rebases
2017-02-27Merge branch 'bw/attr'Libravatar Junio C Hamano14-444/+816
The gitattributes machinery is being taught to work better in a multi-threaded environment. * bw/attr: (27 commits) attr: reformat git_attr_set_direction() function attr: push the bare repo check into read_attr() attr: store attribute stack in attr_check structure attr: tighten const correctness with git_attr and match_attr attr: remove maybe-real, maybe-macro from git_attr attr: eliminate global check_all_attr array attr: use hashmap for attribute dictionary attr: change validity check for attribute names to use positive logic attr: pass struct attr_check to collect_some_attrs attr: retire git_check_attrs() API attr: convert git_check_attrs() callers to use the new API attr: convert git_all_attrs() to use "struct attr_check" attr: (re)introduce git_check_attr() and struct attr_check attr: rename function and struct related to checking attributes attr.c: outline the future plans by heavily commenting Documentation: fix a typo attr.c: add push_stack() helper attr: support quoting pathname patterns in C style attr.c: plug small leak in parse_attr_line() attr.c: tighten constness around "git_attr" structure ...
2017-02-27Merge branch 'sg/completion'Libravatar Junio C Hamano5-168/+690
Clean-up and updates to command line completion (in contrib/). * sg/completion: (22 commits) completion: restore removed line continuating backslash completion: cache the path to the repository completion: extract repository discovery from __gitdir() completion: don't guard git executions with __gitdir() completion: consolidate silencing errors from git commands completion: don't use __gitdir() for git commands completion: respect 'git -C <path>' rev-parse: add '--absolute-git-dir' option completion: fix completion after 'git -C <path>' completion: don't offer commands when 'git --opt' needs an argument completion: list short refs from a remote given as a URL completion: don't list 'HEAD' when trying refs completion outside of a repo completion: list refs from remote when remote's name matches a directory completion: respect 'git --git-dir=<path>' when listing remote refs completion: fix most spots not respecting 'git --git-dir=<path>' completion: ensure that the repository path given on the command line exists completion tests: add tests for the __git_refs() helper function completion tests: check __gitdir()'s output in the error cases completion tests: consolidate getting path of current working directory completion tests: make the $cur variable local to the test helper functions ...
2017-02-27Merge branch 'lt/pathspec-negative'Libravatar Junio C Hamano3-9/+24
The "negative" pathspec feature was somewhat more cumbersome to use than necessary in that its short-hand used "!" which needed to be escaped from shells, and it required "exclude from what?" specified. * lt/pathspec-negative: pathspec: don't error out on all-exclusionary pathspec patterns pathspec magic: add '^' as alias for '!'
2017-02-27Merge branch 'cw/tag-reflog-message'Libravatar Junio C Hamano2-2/+70
"git tag" did not leave useful message when adding a new entry to reflog; this was left unnoticed for a long time because refs/tags/* doesn't keep reflog by default. * cw/tag-reflog-message: tag: generate useful reflog message
2017-02-27Merge branch 'jk/alternate-ref-optim'Libravatar Junio C Hamano9-49/+249
Optimizes resource usage while enumerating refs from alternate object store, to help receiving end of "push" that hosts a repository with many "forks". * jk/alternate-ref-optim: receive-pack: avoid duplicates between our refs and alternates receive-pack: treat namespace .have lines like alternates receive-pack: fix misleading namespace/.have comment receive-pack: use oidset to de-duplicate .have lines add oidset API fetch-pack: cache results of for_each_alternate_ref for_each_alternate_ref: replace transport code with for-each-ref for_each_alternate_ref: pass name/oid instead of ref struct for_each_alternate_ref: use strbuf for path allocation for_each_alternate_ref: stop trimming trailing slashes for_each_alternate_ref: handle failure from real_pathdup()
2017-02-27Merge branch 'kn/ref-filter-branch-list'Libravatar Junio C Hamano10-303/+798
The code to list branches in "git branch" has been consolidated with the more generic ref-filter API. * kn/ref-filter-branch-list: (21 commits) ref-filter: resurrect "strip" as a synonym to "lstrip" branch: implement '--format' option branch: use ref-filter printing APIs branch, tag: use porcelain output ref-filter: allow porcelain to translate messages in the output ref-filter: add an 'rstrip=<N>' option to atoms which deal with refnames ref-filter: modify the 'lstrip=<N>' option to work with negative '<N>' ref-filter: Do not abruptly die when using the 'lstrip=<N>' option ref-filter: rename the 'strip' option to 'lstrip' ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal() ref-filter: introduce refname_atom_parser() ref-filter: introduce refname_atom_parser_internal() ref-filter: make "%(symref)" atom work with the ':short' modifier ref-filter: add support for %(upstream:track,nobracket) ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams ref-filter: introduce format_ref_array_item() ref-filter: move get_head_description() from branch.c ref-filter: modify "%(objectname:short)" to take length ref-filter: implement %(if:equals=<string>) and %(if:notequals=<string>) ref-filter: include reference to 'used_atom' within 'atom_value' ...
2017-02-27Merge branch 'ps/urlmatch-wildcard'Libravatar Junio C Hamano5-40/+220
The <url> part in "http.<url>.<variable>" configuration variable can now be spelled with '*' that serves as wildcard. E.g. "http.https://*.example.com.proxy" can be used to specify the proxy used for https://a.example.com, https://b.example.com, etc., i.e. any host in the example.com domain. * ps/urlmatch-wildcard: urlmatch: allow globbing for the URL host part urlmatch: include host in urlmatch ranking urlmatch: split host and port fields in `struct url_info` urlmatch: enable normalization of URLs with globs mailmap: add Patrick Steinhardt's work address
2017-02-27Merge branch 'mm/merge-rename-delete-message'Libravatar Junio C Hamano2-54/+86
When "git merge" detects a path that is renamed in one history while the other history deleted (or modified) it, it now reports both paths to help the user understand what is going on in the two histories being merged. * mm/merge-rename-delete-message: merge-recursive: make "CONFLICT (rename/delete)" message show both paths
2017-02-27Merge branch 'mh/ref-remove-empty-directory'Libravatar Junio C Hamano6-195/+351
Deletion of a branch "foo/bar" could remove .git/refs/heads/foo once there no longer is any other branch whose name begins with "foo/", but we didn't do so so far. Now we do. * mh/ref-remove-empty-directory: (23 commits) files_transaction_commit(): clean up empty directories try_remove_empty_parents(): teach to remove parents of reflogs, too try_remove_empty_parents(): don't trash argument contents try_remove_empty_parents(): rename parameter "name" -> "refname" delete_ref_loose(): inline function delete_ref_loose(): derive loose reference path from lock log_ref_write_1(): inline function log_ref_setup(): manage the name of the reflog file internally log_ref_write_1(): don't depend on logfile argument log_ref_setup(): pass the open file descriptor back to the caller log_ref_setup(): improve robustness against races log_ref_setup(): separate code for create vs non-create log_ref_write(): inline function rename_tmp_log(): improve error reporting rename_tmp_log(): use raceproof_create_file() lock_ref_sha1_basic(): use raceproof_create_file() lock_ref_sha1_basic(): inline constant raceproof_create_file(): new function safe_create_leading_directories(): set errno on SCLD_EXISTS safe_create_leading_directories_const(): preserve errno ...
2017-02-27Merge branch 'jk/delta-chain-limit'Libravatar Junio C Hamano3-23/+207
"git repack --depth=<n>" for a long time busted the specified depth when reusing delta from existing packs. This has been corrected. * jk/delta-chain-limit: pack-objects: convert recursion to iteration in break_delta_chain() pack-objects: enforce --depth limit in reused deltas
2017-02-27Merge branch 'jk/describe-omit-some-refs'Libravatar Junio C Hamano8-21/+187
"git describe" and "git name-rev" have been taught to take more than one refname patterns to restrict the set of refs to base their naming output on, and also learned to take negative patterns to name refs not to be used for naming via their "--exclude" option. * jk/describe-omit-some-refs: describe: teach describe negative pattern matches describe: teach --match to accept multiple patterns name-rev: add support to exclude refs by pattern match name-rev: extend --refs to accept multiple patterns doc: add documentation for OPT_STRING_LIST
2017-02-27t6300: avoid creating refs/heads/HEADLibravatar Jeff King1-1/+1
In one test, we use "git checkout --orphan HEAD" to create an unborn branch. Confusingly, the resulting branch is named "refs/heads/HEAD". The original probably meant something like: git checkout --orphan orphaned-branch HEAD Let's just use "orphaned-branch" here to make this less confusing. Putting HEAD in the second argument is already implied. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-27commit: don't check for space twice when looking for headerLibravatar René Scharfe1-10/+8
Both standard_header_field() and excluded_header_field() check if there's a space after the buffer that's handed to them. We already check in the caller if that space is present. Don't bother calling the functions if it's missing, as they are guaranteed to return 0 in that case, and remove the now redundant checks from them. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-27commit: be more precise when searching for headersLibravatar René Scharfe1-2/+2
Search for a space character only within the current line in read_commit_extra_header_lines() instead of searching in the whole buffer (and possibly beyond, if it's not NUL-terminated) and then discarding any results after the end of the current line. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-27strbuf: add strbuf_add_real_path()Libravatar René Scharfe4-1/+32
Add a function for appending the canonized absolute pathname of a given path to a strbuf. It keeps the existing contents intact, as expected of a function of the strbuf_add() family, while avoiding copying the result if the given strbuf is empty. It's more consistent with the rest of the strbuf API than strbuf_realpath(), which it's wrapping. Also add a semantic patch demonstrating its intended usage and apply it to the current tree. Using strbuf_add_real_path() instead of calling strbuf_addstr() and real_path() avoids an extra copy to a static buffer. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-27cocci: use ALLOC_ARRAYLibravatar René Scharfe2-1/+17
Add a semantic patch for using ALLOC_ARRAY to allocate arrays and apply the transformation on the current source tree. The macro checks for multiplication overflow and infers the element size automatically; the result is shorter and safer code. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-27sha1_file: release fallback base's memory in unpack_entry()Libravatar René Scharfe1-0/+4
If a pack entry that's used as a delta base is corrupt, unpack_entry() marks it as unusable and then searches the object again in the hope that it can be found in another pack or in a loose file. The memory for this external base object is never released. Free it after use. Signed-off-by: Rene Scharfe <l.s.r@web.de> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-27http: add an "auto" mode for http.emptyauthLibravatar Jeff King1-5/+45
This variable needs to be specified to make some types of non-basic authentication work, but ideally this would just work out of the box for everyone. However, simply setting it to "1" by default introduces an extra round-trip for cases where it _isn't_ useful. We end up sending a bogus empty credential that the server rejects. Instead, let's introduce an automatic mode, that works like this: 1. We won't try to send the bogus credential on the first request. We'll wait to get an HTTP 401, as usual. 2. After seeing an HTTP 401, the empty-auth hack will kick in only when we know there is an auth method available that might make use of it (i.e., something besides "Basic" or "Digest"). That should make it work out of the box, without incurring any extra round-trips for people hitting Basic-only servers. This _does_ incur an extra round-trip if you really want to use "Basic" but your server advertises other methods (the emptyauth hack will kick in but fail, and then Git will actually ask for a password). The auto mode may incur an extra round-trip over setting http.emptyauth=true, because part of the emptyauth hack is to feed this blank password to curl even before we've made a single request. Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-27send-email: only allow one address per body tagLibravatar Johan Hovold2-5/+4
Adding comments after a tag in the body is a common practise (e.g. in the Linux kernel) and git-send-email has been supporting this for years by removing any trailing cruft after the address. After some recent changes, any trailing comment is now instead appended to the recipient name (with some random white space inserted) resulting in undesirable noise in the headers, for example: CC: "# 3 . 3 . x : 1b9508f : sched : Rate-limit newidle" <stable@vger.kernel.org> Revert to the earlier behaviour of discarding anything after the (first) address in a tag while parsing the body. Note that multiple addresses after are still allowed after a command line switch (and in a CC header field). Also note that --suppress-cc=self was never honoured when using multiple addresses in a tag. Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-24parse_hide_refs_config: tell parse_config_key we don't want a subsectionLibravatar Jeff King1-4/+3
This lets us avoid declaring some otherwise useless variables. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-24parse_config_key: allow matching single-level configLibravatar Jeff King2-3/+10
The parse_config_key() function was introduced to make it easier to match "section.subsection.key" variables. It also handles the simpler "section.key", and the caller is responsible for distinguishing the two from its out-parameters. Most callers who _only_ want "section.key" would just use a strcmp(var, "section.key"), since there is no parsing required. However, they may still use parse_config_key() if their "section" variable isn't a constant (an example of this is in parse_hide_refs_config). Using the parse_config_key is a bit clunky, though: const char *subsection; int subsection_len; const char *key; if (!parse_config_key(var, section, &subsection, &subsection_len, &key) && !subsection) { /* matched! */ } Instead, let's treat a NULL subsection as an indication that the caller does not expect one. That lets us write: const char *key; if (!parse_config_key(var, section, NULL, NULL, &key)) { /* matched! */ } Existing callers should be unaffected, as passing a NULL subsection would currently segfault. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-24parse_config_key: use skip_prefix instead of starts_withLibravatar Jeff King1-4/+3
This saves us having to repeatedly add in "section_len" (and also avoids walking over the first part of the string multiple times for a strlen() and strrchr()). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>