Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
4,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 476.50 KB | None | 0 0
  1. git svn: fix authentication with 'branch'
  2.  
  3. Authentication fails with svn branch while svn rebase and
  4. svn dcommit work fine without authentication failures.
  5.  
  6. $ git svn branch v7_3
  7. Copying https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx at r27519
  8. to https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/v7_3...
  9. Can't create session: Unable to connect to a repository at URL
  10. 'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': No more
  11. credentials or we tried too many times.
  12. Authentication failed at
  13. C:\Program Files\Git\mingw64/libexec/git-core\git-svn line 1200.
  14.  
  15. We add auth configuration to SVN::Client->new() to fix the issue.
  16.  
  17. Signed-off-by: Hiroshi Shirosaki <h.shirosaki@gmail.com>
  18. Signed-off-by: Eric Wong <e@80x24.org>
  19.  
  20. First batch after 2.12
  21.  
  22. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  23.  
  24. Merge branch 'rl/remote-allow-missing-branch-name-merge'
  25.  
  26. "git remote rm X", when a branch has remote X configured as the
  27. value of its branch.*.remote, tried to remove branch.*.remote and
  28. branch.*.merge and failed if either is unset.
  29.  
  30. * rl/remote-allow-missing-branch-name-merge:
  31. remote: ignore failure to remove missing branch.<name>.merge
  32.  
  33. Merge branch 'km/delete-ref-reflog-message'
  34.  
  35. "git update-ref -d" and other operations to delete references did
  36. not leave any entry in HEAD's reflog when the reference being
  37. deleted was the current branch. This is not a problem in practice
  38. because you do not want to delete the branch you are currently on,
  39. but caused renaming of the current branch to something else not to
  40. be logged in a useful way.
  41.  
  42. * km/delete-ref-reflog-message:
  43. branch: record creation of renamed branch in HEAD's log
  44. rename_ref: replace empty message in HEAD's log
  45. update-ref: pass reflog message to delete_ref()
  46. delete_ref: accept a reflog message argument
  47.  
  48. Merge branch 'jk/tempfile-ferror-fclose-confusion'
  49.  
  50. A caller of tempfile API that uses stdio interface to write to
  51. files may ignore errors while writing, which is detected when
  52. tempfile is closed (with a call to ferror()). By that time, the
  53. original errno that may have told us what went wrong is likely to
  54. be long gone and was overwritten by an irrelevant value.
  55. close_tempfile() now resets errno to EIO to make errno at least
  56. predictable.
  57.  
  58. * jk/tempfile-ferror-fclose-confusion:
  59. tempfile: set errno to a known value before calling ferror()
  60.  
  61. Merge branch 'vn/xdiff-func-context'
  62.  
  63. "git diff -W" has been taught to handle the case where a new
  64. function is added at the end of the file better.
  65.  
  66. * vn/xdiff-func-context:
  67. xdiff -W: relax end-of-file function detection
  68.  
  69. Merge branch 'js/git-path-in-subdir'
  70.  
  71. The "--git-path", "--git-common-dir", and "--shared-index-path"
  72. options of "git rev-parse" did not produce usable output. They are
  73. now updated to show the path to the correct file, relative to where
  74. the caller is.
  75.  
  76. * js/git-path-in-subdir:
  77. rev-parse: fix several options when running in a subdirectory
  78. rev-parse tests: add tests executed from a subdirectory
  79.  
  80. Merge branch 'mm/two-more-xstrfmt'
  81.  
  82. Code clean-up and a string truncation fix.
  83.  
  84. * mm/two-more-xstrfmt:
  85. bisect_next_all: convert xsnprintf to xstrfmt
  86. stop_progress_msg: convert xsnprintf to xstrfmt
  87.  
  88. Merge branch 'nd/clean-preserve-errno-in-warning'
  89.  
  90. Some warning() messages from "git clean" were updated to show the
  91. errno from failed system calls.
  92.  
  93. * nd/clean-preserve-errno-in-warning:
  94. clean: use warning_errno() when appropriate
  95.  
  96. Merge branch 'jk/show-branch-lift-name-len-limit'
  97.  
  98. "git show-branch" expected there were only very short branch names
  99. in the repository and used a fixed-length buffer to hold them
  100. without checking for overflow.
  101.  
  102. * jk/show-branch-lift-name-len-limit:
  103. show-branch: use skip_prefix to drop magic numbers
  104. show-branch: store resolved head in heap buffer
  105. show-branch: drop head_len variable
  106.  
  107. Merge branch 'jn/remote-helpers-with-git-dir'
  108.  
  109. "git ls-remote" and "git archive --remote" are designed to work
  110. without being in a directory under Git's control. However, recent
  111. updates revealed that we randomly look into a directory called
  112. .git/ without actually doing necessary set-up when working in a
  113. repository. Stop doing so.
  114.  
  115. * jn/remote-helpers-with-git-dir:
  116. remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR
  117. remote: avoid reading $GIT_DIR config in non-repo
  118.  
  119. Merge branch 'jk/grep-no-index-fix'
  120.  
  121. The code to parse the command line "git grep <patterns>... <rev>
  122. [[--] <pathspec>...]" has been cleaned up, and a handful of bugs
  123. have been fixed (e.g. we used to check "--" if it is a rev).
  124.  
  125. * jk/grep-no-index-fix:
  126. grep: treat revs the same for --untracked as for --no-index
  127. grep: do not diagnose misspelt revs with --no-index
  128. grep: avoid resolving revision names in --no-index case
  129. grep: fix "--" rev/pathspec disambiguation
  130. grep: re-order rev-parsing loop
  131. grep: do not unnecessarily query repo for "--"
  132. grep: move thread initialization a little lower
  133.  
  134. Merge branch 'dt/gc-ignore-old-gc-logs'
  135.  
  136. A "gc.log" file left by a backgrounded "gc --auto" disables further
  137. automatic gc; it has been taught to run at least once a day (by
  138. default) by ignoring a stale "gc.log" file that is too old.
  139.  
  140. * dt/gc-ignore-old-gc-logs:
  141. gc: ignore old gc.log files
  142.  
  143. Merge branch 'jh/preload-index-skip-skip'
  144.  
  145. The preload-index code has been taught not to bother with the index
  146. entries that are paths that are not checked out by "sparse checkout".
  147.  
  148. * jh/preload-index-skip-skip:
  149. preload-index: avoid lstat for skip-worktree items
  150.  
  151. Merge branch 'mh/submodule-hash'
  152.  
  153. Code and design clean-up for the refs API.
  154.  
  155. * mh/submodule-hash:
  156. read_loose_refs(): read refs using resolve_ref_recursively()
  157. files_ref_store::submodule: use NULL for the main repository
  158. base_ref_store_init(): remove submodule argument
  159. refs: push the submodule attribute down
  160. refs: store submodule ref stores in a hashmap
  161. register_ref_store(): new function
  162. refs: remove some unnecessary handling of submodule == ""
  163. refs: make some ref_store lookup functions private
  164. refs: reorder some function definitions
  165.  
  166. Merge branch 'sf/putty-w-args'
  167.  
  168. The command line options for ssh invocation needs to be tweaked for
  169. some implementations of SSH (e.g. PuTTY plink wants "-P <port>"
  170. while OpenSSH wants "-p <port>" to specify port to connect to), and
  171. the variant was guessed when GIT_SSH environment variable is used
  172. to specify it. The logic to guess now applies to the command
  173. specified by the newer GIT_SSH_COMMAND and also core.sshcommand
  174. configuration variable, and comes with an escape hatch for users to
  175. deal with misdetected cases.
  176.  
  177. * sf/putty-w-args:
  178. connect.c: stop conflating ssh command names and overrides
  179. connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config
  180. git_connect(): factor out SSH variant handling
  181. connect: rename tortoiseplink and putty variables
  182. connect: handle putty/plink also in GIT_SSH_COMMAND
  183.  
  184. Merge branch 'js/rebase-helper'
  185.  
  186. "git rebase -i" starts using the recently updated "sequencer" code.
  187.  
  188. * js/rebase-helper:
  189. rebase -i: use the rebase--helper builtin
  190. rebase--helper: add a builtin helper for interactive rebases
  191.  
  192. Merge branch 'bw/attr'
  193.  
  194. The gitattributes machinery is being taught to work better in a
  195. multi-threaded environment.
  196.  
  197. * bw/attr: (27 commits)
  198. attr: reformat git_attr_set_direction() function
  199. attr: push the bare repo check into read_attr()
  200. attr: store attribute stack in attr_check structure
  201. attr: tighten const correctness with git_attr and match_attr
  202. attr: remove maybe-real, maybe-macro from git_attr
  203. attr: eliminate global check_all_attr array
  204. attr: use hashmap for attribute dictionary
  205. attr: change validity check for attribute names to use positive logic
  206. attr: pass struct attr_check to collect_some_attrs
  207. attr: retire git_check_attrs() API
  208. attr: convert git_check_attrs() callers to use the new API
  209. attr: convert git_all_attrs() to use "struct attr_check"
  210. attr: (re)introduce git_check_attr() and struct attr_check
  211. attr: rename function and struct related to checking attributes
  212. attr.c: outline the future plans by heavily commenting
  213. Documentation: fix a typo
  214. attr.c: add push_stack() helper
  215. attr: support quoting pathname patterns in C style
  216. attr.c: plug small leak in parse_attr_line()
  217. attr.c: tighten constness around "git_attr" structure
  218. ...
  219.  
  220. Merge branch 'sg/completion'
  221.  
  222. Clean-up and updates to command line completion (in contrib/).
  223.  
  224. * sg/completion: (22 commits)
  225. completion: restore removed line continuating backslash
  226. completion: cache the path to the repository
  227. completion: extract repository discovery from __gitdir()
  228. completion: don't guard git executions with __gitdir()
  229. completion: consolidate silencing errors from git commands
  230. completion: don't use __gitdir() for git commands
  231. completion: respect 'git -C <path>'
  232. rev-parse: add '--absolute-git-dir' option
  233. completion: fix completion after 'git -C <path>'
  234. completion: don't offer commands when 'git --opt' needs an argument
  235. completion: list short refs from a remote given as a URL
  236. completion: don't list 'HEAD' when trying refs completion outside of a repo
  237. completion: list refs from remote when remote's name matches a directory
  238. completion: respect 'git --git-dir=<path>' when listing remote refs
  239. completion: fix most spots not respecting 'git --git-dir=<path>'
  240. completion: ensure that the repository path given on the command line exists
  241. completion tests: add tests for the __git_refs() helper function
  242. completion tests: check __gitdir()'s output in the error cases
  243. completion tests: consolidate getting path of current working directory
  244. completion tests: make the $cur variable local to the test helper functions
  245. ...
  246.  
  247. Merge branch 'lt/pathspec-negative'
  248.  
  249. The "negative" pathspec feature was somewhat more cumbersome to use
  250. than necessary in that its short-hand used "!" which needed to be
  251. escaped from shells, and it required "exclude from what?" specified.
  252.  
  253. * lt/pathspec-negative:
  254. pathspec: don't error out on all-exclusionary pathspec patterns
  255. pathspec magic: add '^' as alias for '!'
  256.  
  257. Merge branch 'cw/tag-reflog-message'
  258.  
  259. "git tag" did not leave useful message when adding a new entry to
  260. reflog; this was left unnoticed for a long time because refs/tags/*
  261. doesn't keep reflog by default.
  262.  
  263. * cw/tag-reflog-message:
  264. tag: generate useful reflog message
  265.  
  266. Merge branch 'jk/alternate-ref-optim'
  267.  
  268. Optimizes resource usage while enumerating refs from alternate
  269. object store, to help receiving end of "push" that hosts a
  270. repository with many "forks".
  271.  
  272. * jk/alternate-ref-optim:
  273. receive-pack: avoid duplicates between our refs and alternates
  274. receive-pack: treat namespace .have lines like alternates
  275. receive-pack: fix misleading namespace/.have comment
  276. receive-pack: use oidset to de-duplicate .have lines
  277. add oidset API
  278. fetch-pack: cache results of for_each_alternate_ref
  279. for_each_alternate_ref: replace transport code with for-each-ref
  280. for_each_alternate_ref: pass name/oid instead of ref struct
  281. for_each_alternate_ref: use strbuf for path allocation
  282. for_each_alternate_ref: stop trimming trailing slashes
  283. for_each_alternate_ref: handle failure from real_pathdup()
  284.  
  285. Merge branch 'kn/ref-filter-branch-list'
  286.  
  287. The code to list branches in "git branch" has been consolidated
  288. with the more generic ref-filter API.
  289.  
  290. * kn/ref-filter-branch-list: (21 commits)
  291. ref-filter: resurrect "strip" as a synonym to "lstrip"
  292. branch: implement '--format' option
  293. branch: use ref-filter printing APIs
  294. branch, tag: use porcelain output
  295. ref-filter: allow porcelain to translate messages in the output
  296. ref-filter: add an 'rstrip=<N>' option to atoms which deal with refnames
  297. ref-filter: modify the 'lstrip=<N>' option to work with negative '<N>'
  298. ref-filter: Do not abruptly die when using the 'lstrip=<N>' option
  299. ref-filter: rename the 'strip' option to 'lstrip'
  300. ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()
  301. ref-filter: introduce refname_atom_parser()
  302. ref-filter: introduce refname_atom_parser_internal()
  303. ref-filter: make "%(symref)" atom work with the ':short' modifier
  304. ref-filter: add support for %(upstream:track,nobracket)
  305. ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams
  306. ref-filter: introduce format_ref_array_item()
  307. ref-filter: move get_head_description() from branch.c
  308. ref-filter: modify "%(objectname:short)" to take length
  309. ref-filter: implement %(if:equals=<string>) and %(if:notequals=<string>)
  310. ref-filter: include reference to 'used_atom' within 'atom_value'
  311. ...
  312.  
  313. Merge branch 'ps/urlmatch-wildcard'
  314.  
  315. The <url> part in "http.<url>.<variable>" configuration variable
  316. can now be spelled with '*' that serves as wildcard.
  317. E.g. "http.https://*.example.com.proxy" can be used to specify the
  318. proxy used for https://a.example.com, https://b.example.com, etc.,
  319. i.e. any host in the example.com domain.
  320.  
  321. * ps/urlmatch-wildcard:
  322. urlmatch: allow globbing for the URL host part
  323. urlmatch: include host in urlmatch ranking
  324. urlmatch: split host and port fields in `struct url_info`
  325. urlmatch: enable normalization of URLs with globs
  326. mailmap: add Patrick Steinhardt's work address
  327.  
  328. Merge branch 'mm/merge-rename-delete-message'
  329.  
  330. When "git merge" detects a path that is renamed in one history
  331. while the other history deleted (or modified) it, it now reports
  332. both paths to help the user understand what is going on in the two
  333. histories being merged.
  334.  
  335. * mm/merge-rename-delete-message:
  336. merge-recursive: make "CONFLICT (rename/delete)" message show both paths
  337.  
  338. Merge branch 'mh/ref-remove-empty-directory'
  339.  
  340. Deletion of a branch "foo/bar" could remove .git/refs/heads/foo
  341. once there no longer is any other branch whose name begins with
  342. "foo/", but we didn't do so so far. Now we do.
  343.  
  344. * mh/ref-remove-empty-directory: (23 commits)
  345. files_transaction_commit(): clean up empty directories
  346. try_remove_empty_parents(): teach to remove parents of reflogs, too
  347. try_remove_empty_parents(): don't trash argument contents
  348. try_remove_empty_parents(): rename parameter "name" -> "refname"
  349. delete_ref_loose(): inline function
  350. delete_ref_loose(): derive loose reference path from lock
  351. log_ref_write_1(): inline function
  352. log_ref_setup(): manage the name of the reflog file internally
  353. log_ref_write_1(): don't depend on logfile argument
  354. log_ref_setup(): pass the open file descriptor back to the caller
  355. log_ref_setup(): improve robustness against races
  356. log_ref_setup(): separate code for create vs non-create
  357. log_ref_write(): inline function
  358. rename_tmp_log(): improve error reporting
  359. rename_tmp_log(): use raceproof_create_file()
  360. lock_ref_sha1_basic(): use raceproof_create_file()
  361. lock_ref_sha1_basic(): inline constant
  362. raceproof_create_file(): new function
  363. safe_create_leading_directories(): set errno on SCLD_EXISTS
  364. safe_create_leading_directories_const(): preserve errno
  365. ...
  366.  
  367. Merge branch 'jk/delta-chain-limit'
  368.  
  369. "git repack --depth=<n>" for a long time busted the specified depth
  370. when reusing delta from existing packs. This has been corrected.
  371.  
  372. * jk/delta-chain-limit:
  373. pack-objects: convert recursion to iteration in break_delta_chain()
  374. pack-objects: enforce --depth limit in reused deltas
  375.  
  376. Merge branch 'jk/describe-omit-some-refs'
  377.  
  378. "git describe" and "git name-rev" have been taught to take more
  379. than one refname patterns to restrict the set of refs to base their
  380. naming output on, and also learned to take negative patterns to
  381. name refs not to be used for naming via their "--exclude" option.
  382.  
  383. * jk/describe-omit-some-refs:
  384. describe: teach describe negative pattern matches
  385. describe: teach --match to accept multiple patterns
  386. name-rev: add support to exclude refs by pattern match
  387. name-rev: extend --refs to accept multiple patterns
  388. doc: add documentation for OPT_STRING_LIST
  389.  
  390. Git 2.12
  391.  
  392. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  393.  
  394. Merge branch 'ps/doc-gc-aggressive-depth-update'
  395.  
  396. Doc update.
  397.  
  398. * ps/doc-gc-aggressive-depth-update:
  399. docs/git-gc: fix default value for `--aggressiveDepth`
  400.  
  401. Merge branch 'bc/worktree-doc-fix-detached'
  402.  
  403. Doc update.
  404.  
  405. * bc/worktree-doc-fix-detached:
  406. Documentation: correctly spell git worktree --detach
  407.  
  408. Merge branch 'dr/doc-check-ref-format-normalize'
  409.  
  410. Doc update.
  411.  
  412. * dr/doc-check-ref-format-normalize:
  413. git-check-ref-format: clarify documentation for --normalize
  414.  
  415. Merge branch 'gp/document-dotfiles-in-templates-are-not-copied'
  416.  
  417. Doc update.
  418.  
  419. * gp/document-dotfiles-in-templates-are-not-copied:
  420. init: document dotfiles exclusion on template copy
  421.  
  422. Merge branch 'rt/align-add-i-help-text'
  423.  
  424. Doc update.
  425.  
  426. * rt/align-add-i-help-text:
  427. git add -i: replace \t with blanks in the help message
  428.  
  429. Merge branch 'bc/blame-doc-fix'
  430.  
  431. Doc update.
  432.  
  433. * bc/blame-doc-fix:
  434. Documentation: use brackets for optional arguments
  435.  
  436. docs/git-gc: fix default value for `--aggressiveDepth`
  437.  
  438. In commit 07e7dbf0d (gc: default aggressive depth to 50, 2016-08-11),
  439. the default aggressive depth of git-gc has been changed to 50. While
  440. git-config(1) has been updated to represent the new default value,
  441. git-gc(1) still mentions the old value. This patch fixes it.
  442.  
  443. Signed-off-by: Patrick Steinhardt <ps@pks.im>
  444. Reviewed-by: Jeff King <peff@peff.net>
  445. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  446.  
  447. Merge tag 'l10n-2.12.0-rnd2' of git://github.com/git-l10n/git-po
  448.  
  449. l10n-2.12.0-rnd2
  450.  
  451. * tag 'l10n-2.12.0-rnd2' of git://github.com/git-l10n/git-po: (22 commits)
  452. l10n: zh_CN: for git v2.12.0 l10n round 2
  453. l10n: Update Catalan translation
  454. l10n: pt_PT: update Portuguese tranlation
  455. l10n: sv.po: Update Swedish translation (3139t0f0u)
  456. l10n: de.po: translate 241 messages
  457. l10n: ko.po: Update Korean translation
  458. l10n: vi.po (3139t): Updated 2 new messages for rc1
  459. l10n: fr.po: v2.12.0 round 2 3139t
  460. l10n: git.pot: v2.12.0 round 2 (2 new)
  461. l10n: vi.po: Updated Vietnamese translation (3137t)
  462. l10n: update Catalan translation
  463. l10n: sv.po: Update Swedish translation (3137t0f0u)
  464. l10n: fr.po: v2.11-rc0 first round
  465. l10n: ko.po: Update Korean translation
  466. l10n: fr.po: Fix a typo in the French translation
  467. l10n: fr.po: Remove gender specific adjectives
  468. l10n: fr.po: Fix typos
  469. l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)
  470. l10n: bg: Updated Bulgarian translation (2913t+0f+0u)
  471. l10n: fixes to Catalan translation
  472. ...
  473.  
  474. l10n: zh_CN: for git v2.12.0 l10n round 2
  475.  
  476. Translate 241 messages (3139t0f0u) for git v2.12.0-rc1.
  477.  
  478. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
  479.  
  480. l10n: Update Catalan translation
  481.  
  482. Signed-off-by: Jordi Mas <jmas@softcatala.org>
  483.  
  484. l10n: pt_PT: update Portuguese tranlation
  485.  
  486. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  487.  
  488. git add -i: replace \t with blanks in the help message
  489.  
  490. Within the help message of 'git add -i', the 'diff' command uses one
  491. tab character and blanks to create the space between the name and the
  492. description while the others use blanks only. So if the tab size is
  493. not at 4 characters, this description will not be in range.
  494. Replace the tab character with blanks.
  495.  
  496. Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
  497. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  498.  
  499. Documentation: use brackets for optional arguments
  500.  
  501. The documentation for git blame used vertical bars for optional
  502. arguments to -M and -C, which is unusual and potentially confusing.
  503. Since most man pages use brackets for optional items, and that's
  504. consistent with how we document the same options for git diff and
  505. friends, use brackets here, too.
  506.  
  507. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  508. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  509.  
  510. Documentation: correctly spell git worktree --detach
  511.  
  512. The option is “--detach”, but we accidentally spelled it “--detached” at
  513. one point in the man page.
  514.  
  515. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  516. Reported-by: Casey Rodarmor <casey@rodarmor.com>
  517. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  518.  
  519. remote: ignore failure to remove missing branch.<name>.merge
  520.  
  521. It is not all too unusual for a branch to use "branch.<name>.remote"
  522. without "branch.<name>.merge". You may be using the 'push.default'
  523. configuration set to 'current', for example, and do
  524.  
  525. $ git checkout -b side colleague/side
  526. $ git config branch.side.remote colleague
  527.  
  528. However, "git remote rm" to remove the remote used in such a manner
  529. fails with
  530.  
  531. "fatal: could not unset 'branch.<name>.merge'"
  532.  
  533. because it assumes that a branch that has .remote defined must also
  534. have .merge defined. Detect the "cannot unset because it is not set
  535. to begin with" case and ignore it.
  536.  
  537. Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
  538. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  539.  
  540. git-check-ref-format: clarify documentation for --normalize
  541.  
  542. Use of 'iff' may be confusing to people not familiar with this term.
  543.  
  544. Improving the --normalize option's documentation to remove the use of
  545. 'iff', and clearly describe what happens when the condition is not met.
  546.  
  547. Signed-off-by: Damien Regad <dregad@mantisbt.org>
  548. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  549.  
  550. Merge branch 'master' of git://github.com/nafmo/git-l10n-sv
  551.  
  552. * 'master' of git://github.com/nafmo/git-l10n-sv:
  553. l10n: sv.po: Update Swedish translation (3139t0f0u)
  554.  
  555. branch: record creation of renamed branch in HEAD's log
  556.  
  557. Renaming the current branch adds an event to the current branch's log
  558. and to HEAD's log. However, the logged entries differ. The entry in
  559. the branch's log represents the entire renaming operation (the old and
  560. new hash are identical), whereas the entry in HEAD's log represents
  561. the deletion only (the new sha1 is null).
  562.  
  563. Extend replace_each_worktree_head_symref(), whose only caller is
  564. branch_rename(), to take a reflog message argument. This allows the
  565. creation of the new ref to be recorded in HEAD's log. As a result,
  566. the renaming event is represented by two entries (a deletion and a
  567. creation entry) in HEAD's log.
  568.  
  569. It's a bit unfortunate that the branch's log and HEAD's log now
  570. represent the renaming event in different ways. Given that the
  571. renaming operation is not atomic, the two-entry form is a more
  572. accurate representation of the operation and is more useful for
  573. debugging purposes if a failure occurs between the deletion and
  574. creation events. It would make sense to move the branch's log to the
  575. two-entry form, but this would involve changes to how the rename is
  576. carried out and to how the update flags and reflogs are processed for
  577. deletions, so it may not be worth the effort.
  578.  
  579. Based-on-patch-by: Jeff King <peff@peff.net>
  580. Signed-off-by: Kyle Meyer <kyle@kyleam.com>
  581. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  582.  
  583. rename_ref: replace empty message in HEAD's log
  584.  
  585. When the current branch is renamed, the deletion of the old ref is
  586. recorded in HEAD's log with an empty message. Now that delete_ref()
  587. accepts a reflog message, provide a more descriptive message by
  588. passing along the log message that is given to rename_ref().
  589.  
  590. The next step will be to extend HEAD's log to also include the second
  591. part of the rename, the creation of the new branch.
  592.  
  593. Helped-by: Jeff King <peff@peff.net>
  594. Signed-off-by: Kyle Meyer <kyle@kyleam.com>
  595. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  596.  
  597. update-ref: pass reflog message to delete_ref()
  598.  
  599. Now that delete_ref() accepts a reflog message, pass the user-provided
  600. message to delete_ref() rather than silently dropping it.
  601.  
  602. Signed-off-by: Kyle Meyer <kyle@kyleam.com>
  603. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  604.  
  605. delete_ref: accept a reflog message argument
  606.  
  607. When the current branch is renamed with 'git branch -m/-M' or deleted
  608. with 'git update-ref -m<msg> -d', the event is recorded in HEAD's log
  609. with an empty message. In preparation for adding a more meaningful
  610. message to HEAD's log in these cases, update delete_ref() to take a
  611. message argument and pass it along to ref_transaction_delete().
  612. Modify all callers to pass NULL for the new message argument; no
  613. change in behavior is intended.
  614.  
  615. Note that this is relevant for HEAD's log but not for the deleted
  616. ref's log, which is currently deleted along with the ref. Even if it
  617. were not, an entry for the deletion wouldn't be present in the deleted
  618. ref's log. files_transaction_commit() writes to the log if
  619. REF_NEEDS_COMMIT or REF_LOG_ONLY are set, but lock_ref_for_update()
  620. doesn't set REF_NEEDS_COMMIT for the deleted ref because REF_DELETING
  621. is set. In contrast, the update for HEAD has REF_LOG_ONLY set by
  622. split_head_update(), resulting in the deletion being logged.
  623.  
  624. Signed-off-by: Kyle Meyer <kyle@kyleam.com>
  625. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  626.  
  627. Merge branch 'svn-escape-backslash' of git://bogomips.org/git-svn
  628.  
  629. * 'svn-escape-backslash' of git://bogomips.org/git-svn:
  630. git-svn: escape backslashes in refnames
  631.  
  632. l10n: sv.po: Update Swedish translation (3139t0f0u)
  633.  
  634. Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
  635.  
  636. l10n: de.po: translate 241 messages
  637.  
  638. Translate 241 messages came from git.pot update in 673bfad09
  639. (l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)) and a4d94835a
  640. (l10n: git.pot: v2.12.0 round 2 (2 new)).
  641.  
  642. Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
  643. Acked-by: Phillip Sz <phillip.szelat@gmail.com>
  644.  
  645. Merge branch 'ko/merge-l10n' of https://github.com/changwoo/git-l10n-ko
  646.  
  647. * 'ko/merge-l10n' of https://github.com/changwoo/git-l10n-ko:
  648. l10n: ko.po: Update Korean translation
  649.  
  650. Merge branch 'master' of https://github.com/vnwildman/git
  651.  
  652. * 'master' of https://github.com/vnwildman/git:
  653. l10n: vi.po (3139t): Updated 2 new messages for rc1
  654.  
  655. l10n: ko.po: Update Korean translation
  656.  
  657. Signed-off-by: Changwoo Ryu <cwryu@debian.org>
  658.  
  659. l10n: vi.po (3139t): Updated 2 new messages for rc1
  660.  
  661. Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
  662.  
  663. init: document dotfiles exclusion on template copy
  664.  
  665. Not just . and .., but any path that begins with dot is not copied
  666. when copying the template directory to a new repository. You can
  667. customize the template directory, copying some dotfiles might make
  668. sense, but it's actually a good thing not to, because you would not
  669. want to have your git directory copied in every git directory that
  670. is created should you decide to put your template directory under
  671. version control, for example. Plus, it might be used as a feature
  672. by people who would want to exclude some files.
  673.  
  674. Signed-off-by: Grégoire Paris <postmaster@greg0ire.fr>
  675. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  676.  
  677. l10n: fr.po: v2.12.0 round 2 3139t
  678.  
  679. Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
  680.  
  681. tempfile: set errno to a known value before calling ferror()
  682.  
  683. In close_tempfile(), we return an error if ferror()
  684. indicated a previous failure, or if fclose() failed. In the
  685. latter case, errno is set and it is useful for callers to
  686. report it.
  687.  
  688. However, if _only_ ferror() triggers, then the value of
  689. errno is based on whatever syscall happened to last fail,
  690. which may not be related to our filehandle at all. A caller
  691. cannot tell the difference between the two cases, and may
  692. use "die_errno()" or similar to report a nonsense errno value.
  693.  
  694. One solution would be to actually pass back separate return
  695. values for the two cases, so a caller can write a more
  696. appropriate message for each case. But that makes the
  697. interface clunky.
  698.  
  699. Instead, let's just set errno to the generic EIO in this case.
  700. That's not as descriptive as we'd like, but at least it's
  701. predictable. So it's better than the status quo in all cases
  702. but one: when the last syscall really did involve a failure
  703. on our filehandle, we'll be wiping that out. But that's a
  704. fragile thing for us to rely on.
  705.  
  706. In any case, we'll let the errno result from fclose() take
  707. precedence over our value, as we know that's recent and
  708. accurate (and many I/O errors will persist through the
  709. fclose anyway).
  710.  
  711. Signed-off-by: Jeff King <peff@peff.net>
  712. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  713.  
  714. Git 2.12-rc2
  715.  
  716. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  717.  
  718. rev-parse: fix several options when running in a subdirectory
  719.  
  720. In addition to making git_path() aware of certain file names that need
  721. to be handled differently e.g. when running in worktrees, the commit
  722. 557bd833bb (git_path(): be aware of file relocation in $GIT_DIR,
  723. 2014-11-30) also snuck in a new option for `git rev-parse`:
  724. `--git-path`.
  725.  
  726. On the face of it, there is no obvious bug in that commit's diff: it
  727. faithfully calls git_path() on the argument and prints it out, i.e. `git
  728. rev-parse --git-path <filename>` has the same precise behavior as
  729. calling `git_path("<filename>")` in C.
  730.  
  731. The problem lies deeper, much deeper. In hindsight (which is always
  732. unfair), implementing the .git/ directory discovery in
  733. `setup_git_directory()` by changing the working directory may have
  734. allowed us to avoid passing around a struct that contains information
  735. about the current repository, but it bought us many, many problems.
  736.  
  737. In this case, when being called in a subdirectory, `git rev-parse`
  738. changes the working directory to the top-level directory before calling
  739. `git_path()`. In the new working directory, the result is correct. But
  740. in the working directory of the calling script, it is incorrect.
  741.  
  742. Example: when calling `git rev-parse --git-path HEAD` in, say, the
  743. Documentation/ subdirectory of Git's own source code, the string
  744. `.git/HEAD` is printed.
  745.  
  746. Side note: that bug is hidden when running in a subdirectory of a
  747. worktree that was added by the `git worktree` command: in that case, the
  748. (correct) absolute path of the `HEAD` file is printed.
  749.  
  750. In the interest of time, this patch does not go the "correct" route to
  751. introduce a struct with repository information (and removing global
  752. state in the process), instead this patch chooses to detect when the
  753. command was called in a subdirectory and forces the result to be an
  754. absolute path.
  755.  
  756. While at it, we are also fixing the output of --git-common-dir and
  757. --shared-index-path.
  758.  
  759. Lastly, please note that we reuse the same strbuf for all of the
  760. relative_path() calls; this avoids frequent allocation (and duplicated
  761. code), and it does not risk memory leaks, for two reasons: 1) the
  762. cmd_rev_parse() function does not return anywhere between the use of
  763. the new strbuf instance and its final release, and 2) git-rev-parse is
  764. one of these "one-shot" programs in Git, i.e. it exits after running
  765. for a very short time, meaning that all allocated memory is released
  766. with the exit() call anyway.
  767.  
  768. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  769. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  770.  
  771. rev-parse tests: add tests executed from a subdirectory
  772.  
  773. t2027-worktree-list has an incorrect expectation for --git-common-dir
  774. which has been adjusted and marked to expect failure.
  775.  
  776. Some of the tests added have been marked to expect failure. These
  777. demonstrate a problem with the way that some options to git rev-parse
  778. behave when executed from a subdirectory of the main worktree.
  779.  
  780. [jes: fixed incorrect assumption that objects/ lives in the
  781. worktree-specific git-dir (it lives in the common dir instead). Also
  782. adjusted t1700 so that the test case does not *need* to be the last
  783. one in that script.]
  784.  
  785. Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
  786. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  787. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  788.  
  789. l10n: git.pot: v2.12.0 round 2 (2 new)
  790.  
  791. Generate po/git.pot from v2.12.0-rc1 for git v2.12.0 l10n round 2.
  792.  
  793. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
  794.  
  795. Merge branch 'master' of git://github.com/git-l10n/git-po
  796.  
  797. * 'master' of git://github.com/git-l10n/git-po:
  798. l10n: vi.po: Updated Vietnamese translation (3137t)
  799. l10n: update Catalan translation
  800. l10n: sv.po: Update Swedish translation (3137t0f0u)
  801. l10n: fr.po: v2.11-rc0 first round
  802. l10n: ko.po: Update Korean translation
  803. l10n: fr.po: Fix a typo in the French translation
  804. l10n: fr.po: Remove gender specific adjectives
  805. l10n: fr.po: Fix typos
  806. l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)
  807. l10n: bg: Updated Bulgarian translation (2913t+0f+0u)
  808. l10n: fixes to Catalan translation
  809. l10n: zh_CN: review for git v2.11.0 l10n
  810. l10n: New Catalan translation maintainer
  811.  
  812. Merge branch 'master' of https://github.com/vnwildman/git
  813.  
  814. * 'master' of https://github.com/vnwildman/git:
  815. l10n: vi.po: Updated Vietnamese translation (3137t)
  816.  
  817. Merge branch 'master' of https://github.com/Softcatala/git-po
  818.  
  819. * 'master' of https://github.com/Softcatala/git-po:
  820. l10n: update Catalan translation
  821.  
  822. l10n: vi.po: Updated Vietnamese translation (3137t)
  823.  
  824. Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
  825.  
  826. Hopefully the final batch of mini-topics before the final
  827.  
  828. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  829.  
  830. Merge branch 'jk/tempfile-ferror-fclose-confusion'
  831.  
  832. Code clean-up.
  833.  
  834. * jk/tempfile-ferror-fclose-confusion:
  835. tempfile: avoid "ferror | fclose" trick
  836.  
  837. Merge branch 'dp/submodule-doc-markup-fix'
  838.  
  839. Doc fix.
  840.  
  841. * dp/submodule-doc-markup-fix:
  842. config.txt: fix formatting of submodule.alternateErrorStrategy section
  843.  
  844. Merge branch 'jk/reset-to-break-a-commit-doc-updated'
  845.  
  846. Doc update.
  847.  
  848. * jk/reset-to-break-a-commit-doc-updated:
  849. reset: add an example of how to split a commit into two
  850.  
  851. Merge branch 'jk/reset-to-break-a-commit-doc'
  852.  
  853. Doc update.
  854.  
  855. * jk/reset-to-break-a-commit-doc:
  856. Revert "reset: add an example of how to split a commit into two"
  857.  
  858. Merge branch 'js/mingw-isatty'
  859.  
  860. A hotfix for a topic already in 'master'.
  861.  
  862. * js/mingw-isatty:
  863. mingw: make stderr unbuffered again
  864.  
  865. Merge branch 'rs/strbuf-cleanup-in-rmdir-recursively'
  866.  
  867. Code clean-up.
  868.  
  869. * rs/strbuf-cleanup-in-rmdir-recursively:
  870. rm: reuse strbuf for all remove_dir_recursively() calls, again
  871.  
  872. Merge branch 'rs/ls-files-partial-optim'
  873.  
  874. "ls-files" run with pathspec has been micro-optimized to avoid
  875. having to memmove(3) unnecessary bytes.
  876.  
  877. * rs/ls-files-partial-optim:
  878. ls-files: move only kept cache entries in prune_cache()
  879. ls-files: pass prefix length explicitly to prune_cache()
  880.  
  881. Merge branch 'rs/cocci-check-free-only-null'
  882.  
  883. A new coccinelle rule that catches a check of !pointer before the
  884. pointer is free(3)d, which most likely is a bug.
  885.  
  886. * rs/cocci-check-free-only-null:
  887. cocci: detect useless free(3) calls
  888.  
  889. Merge branch 'ls/p4-path-encoding'
  890.  
  891. When "git p4" imports changelist that removes paths, it failed to
  892. convert pathnames when the p4 used encoding different from the one
  893. used on the Git side. This has been corrected.
  894.  
  895. * ls/p4-path-encoding:
  896. git-p4: fix git-p4.pathEncoding for removed files
  897.  
  898. tempfile: avoid "ferror | fclose" trick
  899.  
  900. The current code wants to record an error condition from
  901. either ferror() or fclose(), but makes sure that we always
  902. call both functions. So it can't use logical-OR "||", which
  903. would short-circuit when ferror() is true. Instead, it uses
  904. bitwise-OR "|" to evaluate both functions and set one or
  905. more bits in the "err" flag if they reported a failure.
  906.  
  907. Unlike logical-OR, though, bitwise-OR does not introduce a
  908. sequence point, and the order of evaluation for its operands
  909. is unspecified. So a compiler would be free to generate code
  910. which calls fclose() first, and then ferror() on the
  911. now-freed filehandle.
  912.  
  913. There's no indication that this has happened in practice,
  914. but let's write it out in a way that follows the standard.
  915.  
  916. Noticed-by: Andreas Schwab <schwab@linux-m68k.org>
  917. Signed-off-by: Jeff King <peff@peff.net>
  918. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  919.  
  920. config.txt: fix formatting of submodule.alternateErrorStrategy section
  921.  
  922. Add missing `::` after the title.
  923.  
  924. Signed-off-by: David Pursehouse <dpursehouse@collab.net>
  925. Acked-by: Stefan Beller <sbeller@google.com>
  926. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  927.  
  928. clean: use warning_errno() when appropriate
  929.  
  930. All these warning() calls are preceded by a system call. Report the
  931. actual error to help the user understand why we fail to remove
  932. something.
  933.  
  934. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  935. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  936.  
  937. reset: add an example of how to split a commit into two
  938.  
  939. It is often useful to break a commit into multiple parts that are more
  940. logical separations. This can be tricky to learn how to do without the
  941. brute-force method if re-writing code or commit messages from scratch.
  942.  
  943. Add a section to the git-reset documentation which shows an example
  944. process for how to use git add -p and git commit -c HEAD@{1} to
  945. interactively break a commit apart and re-use the original commit
  946. message as a starting point when making the new commit message.
  947.  
  948. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  949. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  950.  
  951. Revert "reset: add an example of how to split a commit into two"
  952.  
  953. This reverts commit 7326451bedaa67d29afe02184b166e28d9393c91; a
  954. better rewrite will be queued separately.
  955.  
  956. bisect_next_all: convert xsnprintf to xstrfmt
  957.  
  958. Git can't run bisect between 2048+ commits if use russian
  959. translation, because the translated string is too long for the fixed
  960. buffer it uses (this can be reproduced "LANG=ru_RU.UTF8 git bisect
  961. start v4.9 v4.8" on linux sources).
  962.  
  963. Use xstrfmt() to format the message string to sufficiently sized
  964. buffer instead to fix this.
  965.  
  966. Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
  967. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  968.  
  969. stop_progress_msg: convert xsnprintf to xstrfmt
  970.  
  971. Simplify code by replacing buffer allocation with a call to xstrfmt().
  972.  
  973. Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
  974. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  975.  
  976. l10n: update Catalan translation
  977.  
  978. Signed-off-by: Jordi Mas <jmas@softcatala.org>
  979.  
  980. A bit more for -rc2
  981.  
  982. Merge branch 'tg/stash-doc-cleanup'
  983.  
  984. The documentation explained what "git stash" does to the working
  985. tree (after stashing away the local changes) in terms of "reset
  986. --hard", which was exposing an unnecessary implementation detail.
  987.  
  988. * tg/stash-doc-cleanup:
  989. Documentation/stash: remove mention of git reset --hard
  990.  
  991. Merge branch 'jk/doc-submodule-markup-fix'
  992.  
  993. Doc markup fix.
  994.  
  995. * jk/doc-submodule-markup-fix:
  996. docs/git-submodule: fix unbalanced quote
  997.  
  998. Merge branch 'jk/doc-remote-helpers-markup-fix'
  999.  
  1000. Doc markup fix.
  1001.  
  1002. * jk/doc-remote-helpers-markup-fix:
  1003. docs/gitremote-helpers: fix unbalanced quotes
  1004.  
  1005. show-branch: use skip_prefix to drop magic numbers
  1006.  
  1007. We make several starts_with() calls, only to advance
  1008. pointers. This is exactly what skip_prefix() is for, which
  1009. lets us avoid manually-counted magic numbers.
  1010.  
  1011. Helped-by: Pranit Bauva <pranit.bauva@gmail.com>
  1012. Signed-off-by: Jeff King <peff@peff.net>
  1013. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1014.  
  1015. Merge branch 'sb/doc-unify-bottom'
  1016.  
  1017. Doc clean-up.
  1018.  
  1019. * sb/doc-unify-bottom:
  1020. Documentation: unify bottom "part of git suite" lines
  1021.  
  1022. Merge branch 'sb/push-options-via-transport'
  1023.  
  1024. The push-options given via the "--push-options" option were not
  1025. passed through to external remote helpers such as "smart HTTP" that
  1026. are invoked via the transport helper.
  1027.  
  1028. * sb/push-options-via-transport:
  1029. push options: pass push options to the transport helper
  1030.  
  1031. Merge branch 'cw/completion'
  1032.  
  1033. More command line completion (in contrib/) for recent additions.
  1034.  
  1035. * cw/completion:
  1036. completion: recognize more long-options
  1037. completion: teach remote subcommands to complete options
  1038. completion: teach replace to complete options
  1039. completion: teach ls-remote to complete options
  1040. completion: improve bash completion for git-add
  1041. completion: add subcommand completion for rerere
  1042. completion: teach submodule subcommands to complete options
  1043.  
  1044. Merge branch 'rs/swap'
  1045.  
  1046. Code clean-up.
  1047.  
  1048. * rs/swap:
  1049. graph: use SWAP macro
  1050. diff: use SWAP macro
  1051. use SWAP macro
  1052. apply: use SWAP macro
  1053. add SWAP macro
  1054.  
  1055. Merge branch 'sb/submodule-doc'
  1056.  
  1057. Doc updates.
  1058.  
  1059. * sb/submodule-doc:
  1060. submodule update documentation: don't repeat ourselves
  1061. submodule documentation: add options to the subcommand
  1062.  
  1063. grep: treat revs the same for --untracked as for --no-index
  1064.  
  1065. git-grep has always disallowed grepping in a tree (as
  1066. opposed to the working directory) with both --untracked
  1067. and --no-index. But we traditionally did so by first
  1068. collecting the revs, and then complaining when any were
  1069. provided.
  1070.  
  1071. The --no-index option recently learned to detect revs
  1072. much earlier. This has two user-visible effects:
  1073.  
  1074. - we don't bother to resolve revision names at all. So
  1075. when there's a rev/path ambiguity, we always choose to
  1076. treat it as a path.
  1077.  
  1078. - likewise, when you do specify a revision without "--",
  1079. the error you get is "no such path" and not "--untracked
  1080. cannot be used with revs".
  1081.  
  1082. The rationale for doing this with --no-index is that it is
  1083. meant to be used outside a repository, and so parsing revs
  1084. at all does not make sense.
  1085.  
  1086. This patch gives --untracked the same treatment. While it
  1087. _is_ meant to be used in a repository, it is explicitly
  1088. about grepping the non-repository contents. Telling the user
  1089. "we found a rev, but you are not allowed to use revs" is
  1090. not really helpful compared to "we treated your argument as
  1091. a path, and could not find it".
  1092.  
  1093. Signed-off-by: Jeff King <peff@peff.net>
  1094. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1095.  
  1096. remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR
  1097.  
  1098. To push from or fetch to the current repository, remote helpers need
  1099. to know what repository that is. Accordingly, Git sets the GIT_DIR
  1100. environment variable to the path to the current repository when
  1101. invoking remote helpers.
  1102.  
  1103. There is a special case it does not handle: "git ls-remote" and "git
  1104. archive --remote" can be run to inspect a remote repository without
  1105. being run from any local repository. GIT_DIR is not useful in this
  1106. scenario:
  1107.  
  1108. - if we are not in a repository, we don't need to set GIT_DIR to
  1109. override an existing GIT_DIR value from the environment. If GIT_DIR
  1110. is present then we would be in a repository if it were valid and
  1111. would have called die() if it weren't.
  1112.  
  1113. - not setting GIT_DIR may cause a helper to do the usual discovery
  1114. walk to find the repository. But we know we're not in one, or we
  1115. would have found it ourselves. So in the worst case it may expend
  1116. a little extra effort to try to find a repository and fail (for
  1117. example, remote-curl would do this to try to find repository-level
  1118. configuration).
  1119.  
  1120. So leave GIT_DIR unset in this case. This makes GIT_DIR easier to
  1121. understand for remote helper authors and makes transport code less of
  1122. a special case for repository discovery.
  1123.  
  1124. Noticed using b1ef400e (setup_git_env: avoid blind fall-back to
  1125. ".git", 2016-10-20) from 'next':
  1126.  
  1127. $ cd /tmp
  1128. $ git ls-remote https://kernel.googlesource.com/pub/scm/git/git
  1129. fatal: BUG: setup_git_env called without repository
  1130.  
  1131. Helped-by: Jeff King <peff@peff.net>
  1132. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
  1133. Signed-off-by: Jeff King <peff@peff.net>
  1134. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1135.  
  1136. remote: avoid reading $GIT_DIR config in non-repo
  1137.  
  1138. The "git ls-remote" command can be run outside of a
  1139. repository, but needs to look up configured remotes. The
  1140. config code is smart enough to handle this case itself, but
  1141. we also check the historical "branches" and "remotes" paths
  1142. in $GIT_DIR. The git_path() function causes us to blindly
  1143. look at ".git/remotes", even if we know we aren't in a git
  1144. repository.
  1145.  
  1146. For now, this is just an unlikely bug (you probably don't
  1147. have such a file if you're not in a repository), but it will
  1148. become more obvious once we merge b1ef400ee (setup_git_env:
  1149. avoid blind fall-back to ".git", 2016-10-20):
  1150.  
  1151. [now]
  1152. $ git ls-remote
  1153. fatal: No remote configured to list refs from.
  1154.  
  1155. [with b1ef400ee]
  1156. $ git ls-remote
  1157. fatal: BUG: setup_git_env called without repository
  1158.  
  1159. We can fix this by skipping these sources entirely when
  1160. we're outside of a repository.
  1161.  
  1162. The test is a little more complex than the demonstration
  1163. above. Rather than detect the correct behavior by parsing
  1164. the error message, we can actually set up a case where the
  1165. remote name we give is a valid repository, but b1ef400ee
  1166. would cause us to die in the configuration step.
  1167.  
  1168. This test doesn't fail now, but it future-proofs us for the
  1169. b1ef400ee change.
  1170.  
  1171. Signed-off-by: Jeff King <peff@peff.net>
  1172. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1173.  
  1174. show-branch: store resolved head in heap buffer
  1175.  
  1176. We resolve HEAD and copy the result to a fixed-size buffer
  1177. with memcpy, never checking that it actually fits. This bug
  1178. dates back to 8098a178b (Add git-symbolic-ref, 2005-09-30).
  1179. Before that we used readlink(), which took a maximum buffer
  1180. size.
  1181.  
  1182. We can fix this by using resolve_refdup(), which duplicates
  1183. the buffer on the heap. That also lets us just check
  1184. for a NULL pointer to see if we have resolved HEAD, and
  1185. drop the extra head_p variable.
  1186.  
  1187. Signed-off-by: Jeff King <peff@peff.net>
  1188. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1189.  
  1190. show-branch: drop head_len variable
  1191.  
  1192. We copy the result of resolving HEAD into a buffer and keep
  1193. track of its length. But we never actually use the length
  1194. for anything besides the copy. Let's stop passing it around.
  1195.  
  1196. Signed-off-by: Jeff King <peff@peff.net>
  1197. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1198.  
  1199. grep: do not diagnose misspelt revs with --no-index
  1200.  
  1201. If we are using --no-index, then our arguments cannot be
  1202. revs in the first place. Not only is it pointless to
  1203. diagnose them, but if we are not in a repository, we should
  1204. not be trying to resolve any names.
  1205.  
  1206. Signed-off-by: Jeff King <peff@peff.net>
  1207. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1208.  
  1209. grep: avoid resolving revision names in --no-index case
  1210.  
  1211. We disallow the use of revisions with --no-index, but we
  1212. don't actually check and complain until well after we've
  1213. parsed the revisions.
  1214.  
  1215. This is the cause of a few problems:
  1216.  
  1217. 1. We shouldn't be calling get_sha1() at all when we aren't
  1218. in a repository, as it might access the ref or object
  1219. databases. For now, this should generally just return
  1220. failure, but eventually it will become a BUG().
  1221.  
  1222. 2. When there's a "--" disambiguator and you're outside a
  1223. repository, we'll complain early with "unable to resolve
  1224. revision". But we can give a much more specific error.
  1225.  
  1226. 3. When there isn't a "--" disambiguator, we still do the
  1227. normal rev/path checks. This is silly, as we know we
  1228. cannot have any revs with --no-index. Everything we see
  1229. must be a path.
  1230.  
  1231. Outside of a repository this doesn't matter (since we
  1232. know it won't resolve), but inside one, we may complain
  1233. unnecessarily if a filename happens to also match a
  1234. refname.
  1235.  
  1236. This patch skips the get_sha1() call entirely in the
  1237. no-index case, and behaves as if it failed (with the
  1238. exception of giving a better error message).
  1239.  
  1240. Signed-off-by: Jeff King <peff@peff.net>
  1241. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1242.  
  1243. grep: fix "--" rev/pathspec disambiguation
  1244.  
  1245. If we see "git grep pattern rev -- file" then we apply the
  1246. usual rev/pathspec disambiguation rules: any "rev" before
  1247. the "--" must be a revision, and we do not need to apply the
  1248. verify_non_filename() check.
  1249.  
  1250. But there are two bugs here:
  1251.  
  1252. 1. We keep a seen_dashdash flag to handle this case, but
  1253. we set it in the same left-to-right pass over the
  1254. arguments in which we parse "rev".
  1255.  
  1256. So when we see "rev", we do not yet know that there is
  1257. a "--", and we mistakenly complain if there is a
  1258. matching file.
  1259.  
  1260. We can fix this by making a preliminary pass over the
  1261. arguments to find the "--", and only then checking the rev
  1262. arguments.
  1263.  
  1264. 2. If we can't resolve "rev" but there isn't a dashdash,
  1265. that's OK. We treat it like a path, and complain later
  1266. if it doesn't exist.
  1267.  
  1268. But if there _is_ a dashdash, then we know it must be a
  1269. rev, and should treat it as such, complaining if it
  1270. does not resolve. The current code instead ignores it
  1271. and tries to treat it like a path.
  1272.  
  1273. This patch fixes both bugs, and tries to comment the parsing
  1274. flow a bit better.
  1275.  
  1276. It adds tests that cover the two bugs, but also some related
  1277. situations (which already worked, but this confirms that our
  1278. fixes did not break anything).
  1279.  
  1280. Signed-off-by: Jeff King <peff@peff.net>
  1281. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1282.  
  1283. grep: re-order rev-parsing loop
  1284.  
  1285. We loop over the arguments, but every branch of the loop
  1286. hits either a "continue" or a "break". Surely we can make
  1287. this simpler.
  1288.  
  1289. The final conditional is:
  1290.  
  1291. if (arg is a rev) {
  1292. ... handle rev ...
  1293. continue;
  1294. }
  1295. break;
  1296.  
  1297. We can rewrite this as:
  1298.  
  1299. if (arg is not a rev)
  1300. break;
  1301.  
  1302. ... handle rev ...
  1303.  
  1304. That makes the flow a little bit simpler, and will make
  1305. things much easier to follow when we add more logic in
  1306. future patches.
  1307.  
  1308. Signed-off-by: Jeff King <peff@peff.net>
  1309. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1310.  
  1311. grep: do not unnecessarily query repo for "--"
  1312.  
  1313. When running a command of the form
  1314.  
  1315. git grep --no-index pattern -- path
  1316.  
  1317. in the absence of a Git repository, an error message will be printed:
  1318.  
  1319. fatal: BUG: setup_git_env called without repository
  1320.  
  1321. This is because "git grep" tries to interpret "--" as a rev. "git grep"
  1322. has always tried to first interpret "--" as a rev for at least a few
  1323. years, but this issue was upgraded from a pessimization to a bug in
  1324. commit 59332d1 ("Resurrect "git grep --no-index"", 2010-02-06), which
  1325. calls get_sha1 regardless of whether --no-index was specified. This bug
  1326. appeared to be benign until commit b1ef400 ("setup_git_env: avoid blind
  1327. fall-back to ".git"", 2016-10-20) when Git was taught to die in this
  1328. situation. (This "git grep" bug appears to be one of the bugs that
  1329. commit b1ef400 is meant to flush out.)
  1330.  
  1331. Therefore, always interpret "--" as signaling the end of options,
  1332. instead of trying to interpret it as a rev first.
  1333.  
  1334. Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
  1335. Signed-off-by: Jeff King <peff@peff.net>
  1336. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1337.  
  1338. grep: move thread initialization a little lower
  1339.  
  1340. Originally, we set up the threads for grep before parsing
  1341. the non-option arguments. In 53b8d931b (grep: disable
  1342. threading in non-worktree case, 2011-12-12), the thread code
  1343. got bumped lower in the function because it now needed to
  1344. know whether we got any revision arguments.
  1345.  
  1346. That put a big block of code in between the parsing of revs
  1347. and the parsing of pathspecs, both of which share some loop
  1348. variables. That makes it harder to read the code than the
  1349. original, where the shared loops were right next to each
  1350. other.
  1351.  
  1352. Let's bump the thread initialization until after all of the
  1353. parsing is done.
  1354.  
  1355. Signed-off-by: Jeff King <peff@peff.net>
  1356. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1357.  
  1358. mingw: make stderr unbuffered again
  1359.  
  1360. When removing the hack for isatty(), we actually removed more than just
  1361. an isatty() hack: we removed the hack where internal data structures of
  1362. the MSVC runtime are modified in order to redirect stdout/stderr.
  1363.  
  1364. Instead of using that hack (that does not work with newer versions of
  1365. the runtime, anyway), we replaced it by reopening the respective file
  1366. descriptors.
  1367.  
  1368. What we forgot was to mark stderr as unbuffered again.
  1369.  
  1370. Reported by Hannes Sixt. Fixed with Jeff Hostetler's assistance.
  1371.  
  1372. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  1373. Tested-by: Johannes Sixt <j6t@kdbg.org>
  1374. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1375.  
  1376. gc: ignore old gc.log files
  1377.  
  1378. A server can end up in a state where there are lots of unreferenced
  1379. loose objects (say, because many users are doing a bunch of rebasing
  1380. and pushing their rebased branches). Running "git gc --auto" in
  1381. this state would cause a gc.log file to be created, preventing
  1382. future auto gcs, causing pack files to pile up. Since many git
  1383. operations are O(n) in the number of pack files, this would lead to
  1384. poor performance.
  1385.  
  1386. Git should never get itself into a state where it refuses to do any
  1387. maintenance, just because at some point some piece of the maintenance
  1388. didn't make progress.
  1389.  
  1390. Teach Git to ignore gc.log files which are older than (by default)
  1391. one day old, which can be tweaked via the gc.logExpiry configuration
  1392. variable. That way, these pack files will get cleaned up, if
  1393. necessary, at least once per day. And operators who find a need for
  1394. more-frequent gcs can adjust gc.logExpiry to meet their needs.
  1395.  
  1396. There is also some cleanup: a successful manual gc, or a
  1397. warning-free auto gc with an old log file, will remove any old
  1398. gc.log files.
  1399.  
  1400. It might still happen that manual intervention is required
  1401. (e.g. because the repo is corrupt), but at the very least it won't
  1402. be because Git is too dumb to try again.
  1403.  
  1404. Signed-off-by: David Turner <dturner@twosigma.com>
  1405. Helped-by: Jeff King <peff@peff.net>
  1406. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1407.  
  1408. read_loose_refs(): read refs using resolve_ref_recursively()
  1409.  
  1410. There is no need to call read_ref_full() or resolve_gitlink_ref() from
  1411. read_loose_refs(), because we already have a ref_store object in hand.
  1412. So we can call resolve_ref_recursively() ourselves. Happily, this
  1413. unifies the code for the submodule vs. non-submodule cases.
  1414.  
  1415. This requires resolve_ref_recursively() to be exposed to the refs
  1416. subsystem, though not to non-refs code.
  1417.  
  1418. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1419. Reviewed-by: Jeff King <peff@peff.net>
  1420. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1421.  
  1422. rm: reuse strbuf for all remove_dir_recursively() calls, again
  1423.  
  1424. Don't throw the memory allocated for remove_dir_recursively() away after
  1425. a single call, use it for the other entries as well instead.
  1426.  
  1427. This change was done before in deb8e15a (rm: reuse strbuf for all
  1428. remove_dir_recursively() calls), but was reverted as a side-effect of
  1429. 55856a35 (rm: absorb a submodules git dir before deletion). Reinstate
  1430. the optimization.
  1431.  
  1432. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  1433. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1434.  
  1435. Documentation/stash: remove mention of git reset --hard
  1436.  
  1437. Don't mention git reset --hard in the documentation for git stash save.
  1438. It's an implementation detail that doesn't matter to the end user and
  1439. thus shouldn't be exposed to them. In addition it's not quite true for
  1440. git stash -p, and will not be true when a filename argument to limit the
  1441. stash to a few files is introduced.
  1442.  
  1443. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
  1444. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1445.  
  1446. docs/git-submodule: fix unbalanced quote
  1447.  
  1448. The documentation gives an example of the submodule foreach
  1449. command that uses both backticks and single-quotes. We stick
  1450. the whole thing inside "+" markers to make it monospace, but
  1451. the inside punctuation still needs escaping. We handle the
  1452. backticks with "{backtick}", and use backslash-escaping for
  1453. the single-quotes.
  1454.  
  1455. But we missed the escaping on the second quote. Fortunately,
  1456. asciidoc renders this unbalanced quote as we want (showing
  1457. the quote), but asciidoctor does not. We could fix it by
  1458. adding the missing backslash.
  1459.  
  1460. However, let's take a step back. Even when rendered
  1461. correctly, it's hard to read a long command stuck into the
  1462. middle of a paragraph, and the important punctuation is hard
  1463. to notice. Let's instead bump it into its own single-line
  1464. code block. That makes both the source and the rendered
  1465. result more readable, and as a bonus we don't have to worry
  1466. about quoting at all.
  1467.  
  1468. Signed-off-by: Jeff King <peff@peff.net>
  1469. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1470.  
  1471. docs/gitremote-helpers: fix unbalanced quotes
  1472.  
  1473. Each of these options is missing the closing single-quote on
  1474. the option name. This understandably confuses asciidoc,
  1475. which ends up rendering a stray quote, like:
  1476.  
  1477. option cloning {'true|false}
  1478.  
  1479. Signed-off-by: Jeff King <peff@peff.net>
  1480. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1481.  
  1482. completion: restore removed line continuating backslash
  1483.  
  1484. Recent commit 1cd23e9e0 (completion: don't use __gitdir() for git
  1485. commands, 2017-02-03) rewrapped a couple of long lines, and while
  1486. doing so it inadvertently removed a '\' from the end of a line, thus
  1487. breaking completion for 'git config remote.name.push <TAB>'.
  1488.  
  1489. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  1490. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1491.  
  1492. ls-files: move only kept cache entries in prune_cache()
  1493.  
  1494. prune_cache() first identifies those entries at the start of the sorted
  1495. array that can be discarded. Then it moves the rest of the entries up.
  1496. Last it identifies the unwanted trailing entries among the moved ones
  1497. and cuts them off.
  1498.  
  1499. Change the order: Identify both start *and* end of the range to keep
  1500. first and then move only those entries to the top. The resulting code
  1501. is slightly shorter and a bit more efficient.
  1502.  
  1503. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  1504. Reviewed-by: Brandon Williams <bmwill@google.com>
  1505. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1506.  
  1507. ls-files: pass prefix length explicitly to prune_cache()
  1508.  
  1509. The function prune_cache() relies on the fact that it is only called on
  1510. max_prefix and sneakily uses the matching global variable max_prefix_len
  1511. directly. Tighten its interface by passing both the string and its
  1512. length as parameters. While at it move the NULL check into the function
  1513. to collect all cache-pruning related logic in one place.
  1514.  
  1515. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  1516. Reviewed-by: Brandon Williams <bmwill@google.com>
  1517. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1518.  
  1519. Merge branch 'master' of git://github.com/nafmo/git-l10n-sv
  1520.  
  1521. * 'master' of git://github.com/nafmo/git-l10n-sv:
  1522. l10n: sv.po: Update Swedish translation (3137t0f0u)
  1523.  
  1524. Merge branch 'fr_v2.11.0_rnd1' of git://github.com/jnavila/git
  1525.  
  1526. * 'fr_v2.11.0_rnd1' of git://github.com/jnavila/git:
  1527. l10n: fr.po: v2.11-rc0 first round
  1528. l10n: fr.po: Fix a typo in the French translation
  1529. l10n: fr.po: Remove gender specific adjectives
  1530. l10n: fr.po: Fix typos
  1531.  
  1532. cocci: detect useless free(3) calls
  1533.  
  1534. Add a semantic patch for removing checks that cause free(3) to only be
  1535. called with a NULL pointer, as that must be a programming mistake.
  1536.  
  1537. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  1538. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1539.  
  1540. l10n: sv.po: Update Swedish translation (3137t0f0u)
  1541.  
  1542. Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
  1543.  
  1544. l10n: fr.po: v2.11-rc0 first round
  1545.  
  1546. Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
  1547.  
  1548. l10n: ko.po: Update Korean translation
  1549.  
  1550. Signed-off-by: Changwoo Ryu <cwryu@debian.org>
  1551.  
  1552. preload-index: avoid lstat for skip-worktree items
  1553.  
  1554. Teach preload-index to avoid lstat() calls for index-entries
  1555. with skip-worktree bit set. This is a performance optimization.
  1556.  
  1557. During a sparse-checkout, the skip-worktree bit is set on items
  1558. that were not populated and therefore are not present in the
  1559. worktree. The per-thread preload-index loop performs a series
  1560. of tests on each index-entry as it attempts to compare the
  1561. worktree version with the index and mark them up-to-date.
  1562. This patch short-cuts that work.
  1563.  
  1564. On a Windows 10 system with a very large repo (450MB index)
  1565. and various levels of sparseness, performance was improved
  1566. in the {preloadindex=true, fscache=false} case by 80% and
  1567. in the {preloadindex=true, fscache=true} case by 20% for various
  1568. commands.
  1569.  
  1570. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  1571. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  1572. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1573.  
  1574. git-p4: fix git-p4.pathEncoding for removed files
  1575.  
  1576. In a9e38359e3 we taught git-p4 a way to re-encode path names from what
  1577. was used in Perforce to UTF-8. This path re-encoding worked properly for
  1578. "added" paths. "Removed" paths were not re-encoded and therefore
  1579. different from the "added" paths. Consequently, these files were not
  1580. removed in a git-p4 cloned Git repository because the path names did not
  1581. match.
  1582.  
  1583. Fix this by moving the re-encoding to a place that affects "added" and
  1584. "removed" paths. Add a test to demonstrate the issue.
  1585.  
  1586. Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
  1587. Reviewed-by: Luke Diamand <luke@diamand.org>
  1588. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1589.  
  1590. connect.c: stop conflating ssh command names and overrides
  1591.  
  1592. dd33e07766 ("connect: Add the envvar GIT_SSH_VARIANT and ssh.variant
  1593. config", 2017-02-01) attempted to add support for configuration and
  1594. environment variable to override the different handling of
  1595. port_option and needs_batch settings suitable for variants of the
  1596. ssh implementation that was autodetected by looking at the ssh
  1597. command name. Because it piggybacked on the code that turns command
  1598. name to specific override (e.g. "plink.exe" and "plink" means
  1599. port_option needs to be set to 'P' instead of the default 'p'), yet
  1600. it defined a separate namespace for these overrides (e.g. "putty"
  1601. can be usable to signal that port_option needs to be 'P'), however,
  1602. it made the auto-detection based on the command name less robust
  1603. (e.g. the code now accepts "putty" as a SSH command name and applies
  1604. the same override).
  1605.  
  1606. Separate the code that interprets the override that was read from
  1607. the configuration & environment from the original code that handles
  1608. the command names, as they are in separate namespaces, to fix this
  1609. confusion.
  1610.  
  1611. This incidentally also makes it easier for future enhancement of the
  1612. override syntax (e.g. "port_option=p,needs_batch=1" may want to be
  1613. accepted as a more explicit syntax) without affecting the code for
  1614. auto-detection based on the command name.
  1615.  
  1616. While at it, update the return type of the handle_ssh_variant()
  1617. helper function to void; the caller does not use it, and the
  1618. function does not return any meaningful value.
  1619.  
  1620. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1621.  
  1622. pathspec: don't error out on all-exclusionary pathspec patterns
  1623.  
  1624. Instead of erroring out and telling the user that they should add a
  1625. positive pattern that covers everything else, just _do_ that.
  1626.  
  1627. For commands where we honor the current cwd by default (ie grep, ls-files
  1628. etc), we make that default positive pathspec be the current working
  1629. directory. And for commands that default to the whole project (ie diff,
  1630. log, etc), the default positive pathspec is the whole project.
  1631.  
  1632. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  1633. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1634.  
  1635. pathspec magic: add '^' as alias for '!'
  1636.  
  1637. The choice of '!' for a negative pathspec ends up not only not matching
  1638. what we do for revisions, it's also a horrible character for shell
  1639. expansion since it needs quoting.
  1640.  
  1641. So add '^' as an alternative alias for an excluding pathspec entry.
  1642.  
  1643. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  1644. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1645.  
  1646. Git 2.12-rc1
  1647.  
  1648. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1649.  
  1650. Merge branch 'nd/rev-list-all-includes-HEAD-doc'
  1651.  
  1652. Doc update.
  1653.  
  1654. * nd/rev-list-all-includes-HEAD-doc:
  1655. rev-list-options.txt: update --all about HEAD
  1656.  
  1657. Merge branch 'rs/fill-directory-optim'
  1658.  
  1659. Code clean-up.
  1660.  
  1661. * rs/fill-directory-optim:
  1662. dir: avoid allocation in fill_directory()
  1663.  
  1664. Merge branch 'jk/log-graph-name-only'
  1665.  
  1666. "git log --graph" did not work well with "--name-only", even though
  1667. other forms of "diff" output were handled correctly.
  1668.  
  1669. * jk/log-graph-name-only:
  1670. diff: print line prefix for --name-only output
  1671.  
  1672. Merge branch 'da/t7800-cleanup'
  1673.  
  1674. Test updates.
  1675.  
  1676. * da/t7800-cleanup:
  1677. t7800: replace "wc -l" with test_line_count
  1678.  
  1679. Merge branch 'dl/difftool-doc-no-gui-option'
  1680.  
  1681. Doc update.
  1682.  
  1683. * dl/difftool-doc-no-gui-option:
  1684. Document the --no-gui option in difftool
  1685.  
  1686. Merge branch 'js/difftool-builtin'
  1687.  
  1688. A few hot-fixes to C-rewrite of "git difftool".
  1689.  
  1690. * js/difftool-builtin:
  1691. t7800: simplify basic usage test
  1692. difftool: fix bug when printing usage
  1693.  
  1694. Merge branch 'rs/p5302-create-repositories-before-tests'
  1695.  
  1696. Adjust a perf test to new world order where commands that do
  1697. require a repository are really strict about having a repository.
  1698.  
  1699. * rs/p5302-create-repositories-before-tests:
  1700. p5302: create repositories for index-pack results explicitly
  1701.  
  1702. Merge branch 'ps/worktree-prune-help-fix'
  1703.  
  1704. Incorrect usage help message for "git worktree prune" has been fixed.
  1705.  
  1706. * ps/worktree-prune-help-fix:
  1707. worktree: fix option descriptions for `prune`
  1708.  
  1709. Merge branch 'ew/complete-svn-authorship-options'
  1710.  
  1711. Correct command line completion (in contrib/) on "git svn"
  1712.  
  1713. * ew/complete-svn-authorship-options:
  1714. completion: fix git svn authorship switches
  1715.  
  1716. Merge branch 'jk/reset-to-break-a-commit-doc'
  1717.  
  1718. A minor doc update.
  1719.  
  1720. * jk/reset-to-break-a-commit-doc:
  1721. reset: add an example of how to split a commit into two
  1722.  
  1723. Merge branch 'bw/push-submodule-only'
  1724.  
  1725. Add missing documentation update to a recent topic.
  1726.  
  1727. * bw/push-submodule-only:
  1728. completion: add completion for --recurse-submodules=only
  1729. doc: add doc for git-push --recurse-submodules=only
  1730.  
  1731. files_ref_store::submodule: use NULL for the main repository
  1732.  
  1733. The old practice of storing the empty string in this member for the main
  1734. repository was a holdover from before 00eebe3 (refs: create a base class
  1735. "ref_store" for files_ref_store, 2016-09-04), when the submodule was
  1736. stored in a flex array at the end of `struct files_ref_store`. Storing
  1737. NULL for this case is more idiomatic and a tiny bit less code.
  1738.  
  1739. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1740. Reviewed-by: Jeff King <peff@peff.net>
  1741. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1742.  
  1743. base_ref_store_init(): remove submodule argument
  1744.  
  1745. This is another step towards weakening the 1:1 relationship between
  1746. ref_stores and submodules.
  1747.  
  1748. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1749. Reviewed-by: Jeff King <peff@peff.net>
  1750. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1751.  
  1752. refs: push the submodule attribute down
  1753.  
  1754. Push the submodule attribute down from ref_store to files_ref_store.
  1755. This is another step towards loosening the 1:1 connection between
  1756. ref_stores and submodules.
  1757.  
  1758. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1759. Reviewed-by: Jeff King <peff@peff.net>
  1760. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1761.  
  1762. refs: store submodule ref stores in a hashmap
  1763.  
  1764. Aside from scaling better, this means that the submodule name needn't be
  1765. stored in the ref_store instance anymore (which will be changed in a
  1766. moment). This, in turn, will help loosen the strict 1:1 relationship
  1767. between ref_stores and submodules.
  1768.  
  1769. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1770. Reviewed-by: Jeff King <peff@peff.net>
  1771. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1772.  
  1773. register_ref_store(): new function
  1774.  
  1775. Move the responsibility for registering the ref_store for a submodule
  1776. from base_ref_store_init() to a new function, register_ref_store(). Call
  1777. the latter from ref_store_init().
  1778.  
  1779. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1780. Reviewed-by: Jeff King <peff@peff.net>
  1781. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1782.  
  1783. refs: remove some unnecessary handling of submodule == ""
  1784.  
  1785. The only external entry point to the ref_store lookup functions is
  1786. get_ref_store(), which ensures that submodule == "" is passed along as
  1787. NULL. So ref_store_init() and lookup_ref_store() don't have to handle
  1788. submodule being specified as the empty string.
  1789.  
  1790. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1791. Reviewed-by: Jeff King <peff@peff.net>
  1792. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1793.  
  1794. refs: make some ref_store lookup functions private
  1795.  
  1796. The following functions currently don't need to be exposed:
  1797.  
  1798. * ref_store_init()
  1799. * lookup_ref_store()
  1800.  
  1801. That might change in the future, but for now make them private.
  1802.  
  1803. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1804. Reviewed-by: Jeff King <peff@peff.net>
  1805. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1806.  
  1807. refs: reorder some function definitions
  1808.  
  1809. This avoids the need to add forward declarations in the next step.
  1810.  
  1811. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  1812. Reviewed-by: Jeff King <peff@peff.net>
  1813. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1814.  
  1815. Documentation: unify bottom "part of git suite" lines
  1816.  
  1817. We currently have 168 man pages that mention they are part of Git, you
  1818. can check yourself easily via:
  1819. $ git grep "Part of the linkgit:git\[1\] suite" |wc -l
  1820. 168
  1821. However some have a trailing period, i.e.
  1822. $ git grep "Part of the linkgit:git\[1\] suite." |wc -l
  1823. 8
  1824.  
  1825. Unify the bottom line in all man pages to not end with a period.
  1826.  
  1827. Signed-off-by: Stefan Beller <sbeller@google.com>
  1828. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1829.  
  1830. rebase -i: use the rebase--helper builtin
  1831.  
  1832. Now that the sequencer learned to process a "normal" interactive rebase,
  1833. we use it. The original shell script is still used for "non-normal"
  1834. interactive rebases, i.e. when --root or --preserve-merges was passed.
  1835.  
  1836. Please note that the --root option (via the $squash_onto variable) needs
  1837. special handling only for the very first command, hence it is still okay
  1838. to use the helper upon continue/skip.
  1839.  
  1840. Also please note that the --no-ff setting is volatile, i.e. when the
  1841. interactive rebase is interrupted at any stage, there is no record of
  1842. it. Therefore, we have to pass it from the shell script to the
  1843. rebase--helper.
  1844.  
  1845. Note: the test t3404 had to be adjusted because the the error messages
  1846. produced by the sequencer comply with our current convention to start with
  1847. a lower-case letter.
  1848.  
  1849. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  1850. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1851.  
  1852. rebase--helper: add a builtin helper for interactive rebases
  1853.  
  1854. Git's interactive rebase is still implemented as a shell script, despite
  1855. its complexity. This implies that it suffers from the portability point
  1856. of view, from lack of expressibility, and of course also from
  1857. performance. The latter issue is particularly serious on Windows, where
  1858. we pay a hefty price for relying so much on POSIX.
  1859.  
  1860. Unfortunately, being such a huge shell script also means that we missed
  1861. the train when it would have been relatively easy to port it to C, and
  1862. instead piled feature upon feature onto that poor script that originally
  1863. never intended to be more than a slightly pimped cherry-pick in a loop.
  1864.  
  1865. To open the road toward better performance (in addition to all the other
  1866. benefits of C over shell scripts), let's just start *somewhere*.
  1867.  
  1868. The approach taken here is to add a builtin helper that at first intends
  1869. to take care of the parts of the interactive rebase that are most
  1870. affected by the performance penalties mentioned above.
  1871.  
  1872. In particular, after we spent all those efforts on preparing the sequencer
  1873. to process rebase -i's git-rebase-todo scripts, we implement the `git
  1874. rebase -i --continue` functionality as a new builtin, git-rebase--helper.
  1875.  
  1876. Once that is in place, we can work gradually on tackling the rest of the
  1877. technical debt.
  1878.  
  1879. Note that the rebase--helper needs to learn about the transient
  1880. --ff/--no-ff options of git-rebase, as the corresponding flag is not
  1881. persisted to, and re-read from, the state directory.
  1882.  
  1883. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  1884. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1885.  
  1886. push options: pass push options to the transport helper
  1887.  
  1888. When using non-builtin protocols relying on a transport helper
  1889. (such as http), push options are not propagated to the helper.
  1890.  
  1891. The user could ask for push options and a push would seemingly succeed,
  1892. but the push options would never be transported to the server,
  1893. misleading the users expectation.
  1894.  
  1895. Fix this by propagating the push options to the transport helper.
  1896.  
  1897. This is only addressing the first issue of
  1898. (1) the helper protocol does not propagate push-option
  1899. (2) the http helper is not prepared to handle push-option
  1900.  
  1901. Once we fix (2), the http transport helper can make use of push options
  1902. as well, but that happens as a follow up. (1) is a bug fix, whereas (2)
  1903. is a feature, which is why we only do (1) here.
  1904.  
  1905. Signed-off-by: Stefan Beller <sbeller@google.com>
  1906. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1907.  
  1908. tag: generate useful reflog message
  1909.  
  1910. When tags are created with `--create-reflog` or with the option
  1911. `core.logAllRefUpdates` set to 'always', a reflog is created for them.
  1912. So far, the description of reflog entries for tags was empty, making the
  1913. reflog hard to understand. For example:
  1914. 6e3a7b3 refs/tags/test@{0}:
  1915.  
  1916. Now, a reflog message is generated when creating a tag, following the
  1917. pattern "tag: tagging <short-sha1> (<description>)". If
  1918. GIT_REFLOG_ACTION is set, the message becomes "$GIT_REFLOG_ACTION
  1919. (<description>)" instead. If the tag references a commit object, the
  1920. description is set to the subject line of the commit, followed by its
  1921. commit date. For example:
  1922. 6e3a7b3 refs/tags/test@{0}: tag: tagging 6e3a7b3398 (Git 2.12-rc0, 2017-02-03)
  1923.  
  1924. If the tag points to a tree/blob/tag objects, the following static
  1925. strings are taken as description:
  1926.  
  1927. - "tree object"
  1928. - "blob object"
  1929. - "other tag object"
  1930.  
  1931. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  1932. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1933.  
  1934. receive-pack: avoid duplicates between our refs and alternates
  1935.  
  1936. We de-duplicate ".have" refs among themselves, but never
  1937. check if they are duplicates of our local refs. It's not
  1938. unreasonable that they would be if we are a "--shared" or
  1939. "--reference" clone of a similar repository; we'd have all
  1940. the same tags.
  1941.  
  1942. We can handle this by inserting our local refs into the
  1943. oidset, but obviously not suppressing duplicates (since the
  1944. refnames are important).
  1945.  
  1946. Note that this also switches the order in which we advertise
  1947. refs, processing ours first and then any alternates. The
  1948. order shouldn't matter (and arguably showing our refs first
  1949. makes more sense).
  1950.  
  1951. Signed-off-by: Jeff King <peff@peff.net>
  1952. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1953.  
  1954. receive-pack: treat namespace .have lines like alternates
  1955.  
  1956. Namely, de-duplicate them. We use the same set as the
  1957. alternates, since we call them both ".have" (i.e., there is
  1958. no value in showing one versus the other).
  1959.  
  1960. Signed-off-by: Jeff King <peff@peff.net>
  1961. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1962.  
  1963. receive-pack: fix misleading namespace/.have comment
  1964.  
  1965. The comment claims that we handle alternate ".have" lines
  1966. through this function, but that hasn't been the case since
  1967. 85f251045 (write_head_info(): handle "extra refs" locally,
  1968. 2012-01-06).
  1969.  
  1970. Signed-off-by: Jeff King <peff@peff.net>
  1971. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  1972.  
  1973. receive-pack: use oidset to de-duplicate .have lines
  1974.  
  1975. If you have an alternate object store with a very large
  1976. number of refs, the peak memory usage of the sha1_array can
  1977. grow high, even if most of them are duplicates that end up
  1978. not being printed at all.
  1979.  
  1980. The similar for_each_alternate_ref() code-paths in
  1981. fetch-pack solve this by using flags in "struct object" to
  1982. de-duplicate (and so are relying on obj_hash at the core).
  1983.  
  1984. But we don't have a "struct object" at all in this case. We
  1985. could call lookup_unknown_object() to get one, but if our
  1986. goal is reducing memory footprint, it's not great:
  1987.  
  1988. - an unknown object is as large as the largest object type
  1989. (a commit), which is bigger than an oidset entry
  1990.  
  1991. - we can free the memory after our ref advertisement, but
  1992. "struct object" entries persist forever (and the
  1993. receive-pack may hang around for a long time, as the
  1994. bottleneck is often client upload bandwidth).
  1995.  
  1996. So let's use an oidset. Note that unlike a sha1-array it
  1997. doesn't sort the output as a side effect. However, our
  1998. output is at least stable, because for_each_alternate_ref()
  1999. will give us the sha1s in ref-sorted order.
  2000.  
  2001. In one particularly pathological case with an alternate that
  2002. has 60,000 unique refs out of 80 million total, this reduced
  2003. the peak heap usage of "git receive-pack . </dev/null" from
  2004. 13GB to 14MB.
  2005.  
  2006. Signed-off-by: Jeff King <peff@peff.net>
  2007. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2008.  
  2009. add oidset API
  2010.  
  2011. This is similar to many of our uses of sha1-array, but it
  2012. overcomes one limitation of a sha1-array: when you are
  2013. de-duplicating a large input with relatively few unique
  2014. entries, sha1-array uses 20 bytes per non-unique entry.
  2015. Whereas this set will use memory linear in the number of
  2016. unique entries (albeit a few more than 20 bytes due to
  2017. hashmap overhead).
  2018.  
  2019. Signed-off-by: Jeff King <peff@peff.net>
  2020. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2021.  
  2022. fetch-pack: cache results of for_each_alternate_ref
  2023.  
  2024. We may run for_each_alternate_ref() twice, once in
  2025. find_common() and once in everything_local(). This operation
  2026. can be expensive, because it involves running a sub-process
  2027. which must freshly load all of the alternate's refs from
  2028. disk.
  2029.  
  2030. Let's cache and reuse the results between the two calls. We
  2031. can make some optimizations based on the particular use
  2032. pattern in fetch-pack to keep our memory usage down.
  2033.  
  2034. The first is that we only care about the sha1s, not the refs
  2035. themselves. So it's OK to store only the sha1s, and to
  2036. suppress duplicates. The natural fit would therefore be a
  2037. sha1_array.
  2038.  
  2039. However, sha1_array's de-duplication happens only after it
  2040. has read and sorted all entries. It still stores each
  2041. duplicate. For an alternate with a large number of refs
  2042. pointing to the same commits, this is a needless expense.
  2043.  
  2044. Instead, we'd prefer to eliminate duplicates before putting
  2045. them in the cache, which implies using a hash. We can
  2046. further note that fetch-pack will call parse_object() on
  2047. each alternate sha1. We can therefore keep our cache as a
  2048. set of pointers to "struct object". That gives us a place to
  2049. put our "already seen" bit with an optimized hash lookup.
  2050. And as a bonus, the object stores the sha1 for us, so
  2051. pointer-to-object is all we need.
  2052.  
  2053. There are two extra optimizations I didn't do here:
  2054.  
  2055. - we actually store an array of pointer-to-object.
  2056. Technically we could just walk the obj_hash table
  2057. looking for entries with the ALTERNATE flag set (because
  2058. our use case doesn't care about the order here).
  2059.  
  2060. But that hash table may be mostly composed of
  2061. non-ALTERNATE entries, so we'd waste time walking over
  2062. them. So it would be a slight win in memory use, but a
  2063. loss in CPU.
  2064.  
  2065. - the items we pull out of the cache are actual "struct
  2066. object"s, but then we feed "obj->sha1" to our
  2067. sub-functions, which promptly call parse_object().
  2068.  
  2069. This second parse is cheap, because it starts with
  2070. lookup_object() and will bail immediately when it sees
  2071. we've already parsed the object. We could save the extra
  2072. hash lookup, but it would involve refactoring the
  2073. functions we call. It may or may not be worth the
  2074. trouble.
  2075.  
  2076. Signed-off-by: Jeff King <peff@peff.net>
  2077. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2078.  
  2079. for_each_alternate_ref: replace transport code with for-each-ref
  2080.  
  2081. The current method for getting the refs from an alternate is
  2082. to run upload-pack in the alternate and parse its output
  2083. using the normal transport code. This works and is
  2084. reasonably short, but it has a very bad memory footprint
  2085. when there are a lot of refs in the alternate. There are two
  2086. problems:
  2087.  
  2088. 1. It reads in all of the refs before passing any back to
  2089. us. Which means that our peak memory usage has to store
  2090. every ref (including duplicates for peeled variants),
  2091. even if our callback could determine that some are not
  2092. interesting (e.g., because they point to the same sha1
  2093. as another ref).
  2094.  
  2095. 2. It allocates a "struct ref" for each one. Among other
  2096. things, this contains 3 separate 20-byte oids, along
  2097. with the name and various pointers. That can add up,
  2098. especially if the callback is only interested in the
  2099. sha1 (which it can store in a sha1_array as just 20
  2100. bytes).
  2101.  
  2102. On a particularly pathological case, where the alternate had
  2103. over 80 million refs pointing to only around 60,000 unique
  2104. objects, the peak heap usage of "git clone --reference" grew
  2105. to over 25GB.
  2106.  
  2107. This patch instead calls git-for-each-ref in the alternate
  2108. repository, and passes each line to the callback as we read
  2109. it. That drops the peak heap of the same command to 50MB.
  2110.  
  2111. I considered and rejected a few alternatives.
  2112.  
  2113. We could read all of the refs in the alternate using our own
  2114. ref code, just as we do with submodules. However, as memory
  2115. footprint is one of the concerns here, we want to avoid
  2116. loading those refs into our own memory as a whole.
  2117.  
  2118. It's possible that this will be a better technique in the
  2119. future when the ref code can more easily iterate without
  2120. loading all of packed-refs into memory.
  2121.  
  2122. Another option is to keep calling upload-pack, and just
  2123. parse its output ourselves in a streaming fashion. Besides
  2124. for-each-ref being simpler (we get to define the format
  2125. ourselves, and don't have to deal with speaking the git
  2126. protocol), it's more flexible for possible future changes.
  2127.  
  2128. For instance, it might be useful for the caller to be able
  2129. to limit the set of "interesting" alternate refs. The
  2130. motivating example is one where many "forks" of a particular
  2131. repository share object storage, and the shared storage has
  2132. refs for each fork (which is why so many of the refs are
  2133. duplicates; each fork has the same tags). A plausible
  2134. future optimization would be to ask for the alternate refs
  2135. for just _one_ fork (if you had some out-of-band way of
  2136. knowing which was the most interesting or important for the
  2137. current operation).
  2138.  
  2139. Similarly, no callbacks actually care about the symref value
  2140. of alternate refs, and as before, this patch ignores them
  2141. entirely. However, if we wanted to add them, for-each-ref's
  2142. "%(symref)" is going to be more flexible than upload-pack,
  2143. because the latter only handles the HEAD symref due to
  2144. historical constraints.
  2145.  
  2146. There is one potential downside, though: unlike upload-pack,
  2147. our for-each-ref command doesn't report the peeled value of
  2148. refs. The existing code calls the alternate_ref_fn callback
  2149. twice for tags: once for the tag, and once for the peeled
  2150. value with the refname set to "ref^{}".
  2151.  
  2152. For the callers in fetch-pack, this doesn't matter at all.
  2153. We immediately peel each tag down to a commit either way (so
  2154. there's a slight improvement, as do not bother passing the
  2155. redundant data over the pipe). For the caller in
  2156. receive-pack, it means we will not advertise the peeled
  2157. values of tags in our alternate. However, we also don't
  2158. advertise peeled values for our _own_ tags, so this is
  2159. actually making things more consistent.
  2160.  
  2161. It's unclear whether receive-pack advertising peeled values
  2162. is a win or not. On one hand, giving more information to the
  2163. other side may let it omit some objects from the push. On
  2164. the other hand, for tags which both sides have, they simply
  2165. bloat the advertisement. The upload-pack advertisement of
  2166. git.git is about 30% larger than the receive-pack
  2167. advertisement due to its peeled information.
  2168.  
  2169. This patch omits the peeled information from
  2170. for_each_alternate_ref entirely, and leaves it up to the
  2171. caller whether they want to dig up the information.
  2172.  
  2173. Signed-off-by: Jeff King <peff@peff.net>
  2174. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2175.  
  2176. for_each_alternate_ref: pass name/oid instead of ref struct
  2177.  
  2178. Breaking down the fields in the interface makes it easier to
  2179. change the backend of for_each_alternate_ref to something
  2180. that doesn't use "struct ref" internally.
  2181.  
  2182. The only field that callers actually look at is the oid,
  2183. anyway. The refname is kept in the interface as a plausible
  2184. thing for future code to want.
  2185.  
  2186. Signed-off-by: Jeff King <peff@peff.net>
  2187. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2188.  
  2189. for_each_alternate_ref: use strbuf for path allocation
  2190.  
  2191. We have a string with ".../objects" pointing to the
  2192. alternate object store, and overwrite bits of it to look at
  2193. other paths in the (potential) git repository holding it.
  2194. This works because the only path we care about is "refs",
  2195. which is shorter than "objects".
  2196.  
  2197. Using a strbuf to hold the path lets us get rid of some
  2198. magic numbers, and makes it more obvious that the memory
  2199. operations are safe.
  2200.  
  2201. Signed-off-by: Jeff King <peff@peff.net>
  2202. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2203.  
  2204. for_each_alternate_ref: stop trimming trailing slashes
  2205.  
  2206. The real_pathdup() function will have removed extra slashes
  2207. for us already (on top of the normalize_path() done when we
  2208. created the alternate_object_database struct in the first
  2209. place).
  2210.  
  2211. Incidentally, this also fixes the case where the path is
  2212. just "/", which would read off the start of the array.
  2213. That doesn't seem possible to trigger in practice, though,
  2214. as link_alt_odb_entry() blindly eats trailing slashes,
  2215. including a bare "/".
  2216.  
  2217. Signed-off-by: Jeff King <peff@peff.net>
  2218. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2219.  
  2220. for_each_alternate_ref: handle failure from real_pathdup()
  2221.  
  2222. In older versions of git, if real_path() failed to resolve
  2223. the alternate object store path, we would die() with an
  2224. error. However, since 4ac9006f8 (real_path: have callers use
  2225. real_pathdup and strbuf_realpath, 2016-12-12) we use the
  2226. real_pathdup() function, which may return NULL. Since we
  2227. don't check the return value, we can segfault.
  2228.  
  2229. This is hard to trigger in practice, since we check that the
  2230. path is accessible before creating the alternate_object_database
  2231. struct. But it could be removed racily, or we could see a
  2232. transient filesystem error.
  2233.  
  2234. We could restore the original behavior by switching back to
  2235. xstrdup(real_path()). However, dying is probably not the
  2236. best option here. This whole function is best-effort
  2237. already; there might not even be a repository around the
  2238. shared objects at all. And if the alternate store has gone
  2239. away, there are no objects to show.
  2240.  
  2241. So let's just quietly return, as we would if we failed to
  2242. open "refs/", or if upload-pack failed to start, etc.
  2243.  
  2244. Signed-off-by: Jeff King <peff@peff.net>
  2245. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2246.  
  2247. diff: print line prefix for --name-only output
  2248.  
  2249. If you run "git log --graph --name-only", the pathnames are
  2250. not indented to go along with their matching commits (unlike
  2251. all of the other diff formats). We need to output the line
  2252. prefix for each item before writing it.
  2253.  
  2254. The tests cover both --name-status and --name-only. The
  2255. former actually gets this right already, because it builds
  2256. on the --raw format functions. It's only --name-only which
  2257. uses its own code (and this fix mirrors the code in
  2258. diff_flush_raw()).
  2259.  
  2260. Note that the tests don't follow our usual style of setting
  2261. up the "expect" output inside the test block. This matches
  2262. the surrounding style, but more importantly it is easier to
  2263. read: we don't have to worry about embedded single-quotes,
  2264. and the leading indentation is more obvious.
  2265.  
  2266. Signed-off-by: Jeff King <peff@peff.net>
  2267. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2268.  
  2269. dir: avoid allocation in fill_directory()
  2270.  
  2271. Pass the match member of the first pathspec item directly to
  2272. read_directory() instead of using common_prefix() to duplicate it first,
  2273. thus avoiding memory duplication, strlen(3) and free(3).
  2274.  
  2275. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  2276. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2277.  
  2278. rev-list-options.txt: update --all about HEAD
  2279.  
  2280. This is the document patch for f0298cf1c6 (revision walker: include a
  2281. detached HEAD in --all - 2009-01-16).
  2282.  
  2283. Even though that commit is about detached HEAD, as Jeff pointed out,
  2284. always adding HEAD in that case may have subtle differences with
  2285. --source or --exclude. So the document mentions nothing about the
  2286. detached-ness.
  2287.  
  2288. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  2289. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2290.  
  2291. t7800: replace "wc -l" with test_line_count
  2292.  
  2293. Make t7800 easier to debug by capturing output into temporary files and
  2294. using test_line_count to make assertions on those files.
  2295.  
  2296. Signed-off-by: David Aguilar <davvid@gmail.com>
  2297. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2298.  
  2299. Merge branch 'da/difftool-dir-diff-fix' into da/t7800-cleanup
  2300.  
  2301. * da/difftool-dir-diff-fix:
  2302. difftool: fix dir-diff index creation when in a subdirectory
  2303.  
  2304. t7800: simplify basic usage test
  2305.  
  2306. Use "test_line_count" instead of "wc -l", use "git -C" instead of a
  2307. subshell, and use test_expect_code when calling difftool. Ease
  2308. debugging by capturing output into temporary files.
  2309.  
  2310. Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  2311. Signed-off-by: David Aguilar <davvid@gmail.com>
  2312. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2313.  
  2314. Document the --no-gui option in difftool
  2315.  
  2316. Prior to this, the `--no-gui` option was not documented in the manpage.
  2317. This commit introduces this into the manpage
  2318.  
  2319. Signed-off-by: Denton Liu <liu.denton@gmail.com>
  2320. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2321.  
  2322. ref-filter: resurrect "strip" as a synonym to "lstrip"
  2323.  
  2324. We forgot that "strip" was introduced at 0571979bd6 ("tag: do not
  2325. show ambiguous tag names as "tags/foo"", 2016-01-25) as part of Git
  2326. 2.8 (and 2.7.1) when we started calling this "lstrip" to make it
  2327. easier to explain the new "rstrip" operation.
  2328.  
  2329. We shouldn't have renamed the existing one; "lstrip" should have
  2330. been a new synonym that means the same thing as "strip". Scripts
  2331. in the wild are surely using the original form already.
  2332.  
  2333. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2334.  
  2335. worktree: fix option descriptions for `prune`
  2336.  
  2337. The `verbose` and `expire` options of the `git worktree prune`
  2338. subcommand have wrong descriptions in that they pretend to relate to
  2339. objects. But as the git-worktree(1) correctly states, these options have
  2340. nothing to do with objects but only with worktrees. Fix the description
  2341. accordingly.
  2342.  
  2343. Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
  2344. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2345.  
  2346. p5302: create repositories for index-pack results explicitly
  2347.  
  2348. Before 7176a314 (index-pack: complain when --stdin is used outside of a
  2349. repo) index-pack silently created a non-existing target directory; now
  2350. the command refuses to work unless it's used against a valid repository.
  2351. That causes p5302 to fail, which relies on the former behavior. Fix it
  2352. by setting up the destinations for its performance tests using git init.
  2353.  
  2354. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  2355. Acked-by: Jeff King <peff@peff.net>
  2356. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2357.  
  2358. completion: fix git svn authorship switches
  2359.  
  2360. --add-author-from and --use-log-author are for "git svn dcommit",
  2361. not "git svn (init|clone)"
  2362.  
  2363. Signed-off-by: Eric Wong <e@80x24.org>
  2364. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2365.  
  2366. difftool: fix bug when printing usage
  2367.  
  2368. "git difftool -h" reports an error:
  2369.  
  2370. fatal: BUG: setup_git_env called without repository
  2371.  
  2372. Defer repository setup so that the help option processing happens before
  2373. the repository is initialized.
  2374.  
  2375. Add tests to ensure that the basic usage works inside and outside of a
  2376. repository.
  2377.  
  2378. Signed-off-by: David Aguilar <davvid@gmail.com>
  2379. Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  2380. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2381.  
  2382. l10n: fr.po: Fix a typo in the French translation
  2383.  
  2384. Signed-off-by: Anthony Ramine <n.oxyde@gmail.com>
  2385.  
  2386. l10n: fr.po: Remove gender specific adjectives
  2387.  
  2388. Signed-off-by: Joachim Jablon <ewjoachim@gmail.com>
  2389. Reviewed-by: Jean-Noel Avila <jn.avila@free.fr>
  2390.  
  2391. l10n: fr.po: Fix typos
  2392.  
  2393. Reviewed-by: Jean-Noel Avila <jn.avila@free.fr>
  2394. Signed-off-by: Joachim Jablon <ewjoachim@gmail.com>
  2395.  
  2396. reset: add an example of how to split a commit into two
  2397.  
  2398. It is often useful to break a commit into multiple parts that are more
  2399. logical separations. This can be tricky to learn how to do without the
  2400. brute-force method if re-writing code or commit messages from scratch.
  2401.  
  2402. Add a section to the git-reset documentation which shows an example
  2403. process for how to use git add -p and git commit -c HEAD@{1} to
  2404. interactively break a commit apart and re-use the original commit
  2405. message as a starting point when making the new commit message.
  2406.  
  2407. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  2408. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2409.  
  2410. completion: recognize more long-options
  2411.  
  2412. Command completion only recognizes a subset of the available options for
  2413. the various git commands. The set of recognized options needs to balance
  2414. between having all useful options and to not clutter the terminal.
  2415.  
  2416. This commit adds all long-options that are mentioned in the man-page
  2417. synopsis of the respective git command. Possibly dangerous options are
  2418. not included in this set, to avoid accidental data loss. The added
  2419. options are:
  2420.  
  2421. - apply: --recount --directory=
  2422. - archive: --output
  2423. - branch: --column --no-column --sort= --points-at
  2424. - clone: --no-single-branch --shallow-submodules
  2425. - commit: --patch --short --date --allow-empty
  2426. - describe: --first-parent
  2427. - fetch, pull: --unshallow --update-shallow
  2428. - fsck: --name-objects
  2429. - grep: --break --heading --show-function --function-context
  2430. --untracked --no-index
  2431. - mergetool: --prompt --no-prompt
  2432. - reset: --keep
  2433. - revert: --strategy= --strategy-option=
  2434. - shortlog: --email
  2435. - tag: --merged --no-merged --create-reflog
  2436.  
  2437. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  2438. Helped-by: Johannes Sixt <j6t@kdbg.org>
  2439. Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
  2440. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2441.  
  2442. completion: teach remote subcommands to complete options
  2443.  
  2444. Git-remote needs to complete remote names, its subcommands, and options
  2445. thereof. In addition to the existing subcommand and remote name
  2446. completion, do also complete the options
  2447.  
  2448. - add: --track --master --fetch --tags --no-tags --mirror=
  2449. - set-url: --push --add --delete
  2450. - get-url: --push --all
  2451. - prune: --dry-run
  2452.  
  2453. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  2454. Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
  2455. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2456.  
  2457. completion: teach replace to complete options
  2458.  
  2459. Git-replace needs to complete references and its own options. In
  2460. addition to the existing references completions, do also complete the
  2461. options --edit --graft --format= --list --delete.
  2462.  
  2463. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  2464. Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
  2465. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2466.  
  2467. completion: teach ls-remote to complete options
  2468.  
  2469. ls-remote needs to complete remote names and its own options. In
  2470. addition to the existing remote name completions, do also complete
  2471. the options --heads, --tags, --refs, --get-url, and --symref.
  2472.  
  2473. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  2474. Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
  2475. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2476.  
  2477. completion: improve bash completion for git-add
  2478.  
  2479. Command completion for git-add did not recognize some long-options.
  2480. This commits adds completion for all long-options that are mentioned in
  2481. the man-page synopsis. In addition, if the user specified `--update` or
  2482. `-u`, path completion will only suggest modified tracked files.
  2483.  
  2484. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  2485. Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
  2486. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2487.  
  2488. completion: add subcommand completion for rerere
  2489.  
  2490. Managing recorded resolutions requires command-line usage of git-rerere.
  2491. Added subcommand completion for rerere and path completion for its
  2492. subcommand forget.
  2493.  
  2494. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  2495. Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
  2496. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2497.  
  2498. completion: teach submodule subcommands to complete options
  2499.  
  2500. Each submodule subcommand has specific long-options. Therefore, teach
  2501. bash completion to support option completion based on the current
  2502. subcommand. All long-options that are mentioned in the man-page synopsis
  2503. are added.
  2504.  
  2505. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  2506. Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
  2507. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2508.  
  2509. completion: cache the path to the repository
  2510.  
  2511. After the previous changes in this series there are only a handful of
  2512. $(__gitdir) command substitutions left in the completion script, but
  2513. there is still a bit of room for improvements:
  2514.  
  2515. 1. The command substitution involves the forking of a subshell,
  2516. which has considerable overhead on some platforms.
  2517.  
  2518. 2. There are a few cases, where this command substitution is
  2519. executed more than once during a single completion, which means
  2520. multiple subshells and possibly multiple 'git rev-parse'
  2521. executions. __gitdir() is invoked twice while completing refs
  2522. for e.g. 'git log', 'git rebase', 'gitk', or while completing
  2523. remote refs for 'git fetch' or 'git push'.
  2524.  
  2525. Both of these points can be addressed by using the
  2526. __git_find_repo_path() helper function introduced in the previous
  2527. commit:
  2528.  
  2529. 1. __git_find_repo_path() stores the path to the repository in a
  2530. variable instead of printing it, so the command substitution
  2531. around the function can be avoided. Or rather: the command
  2532. substitution should be avoided to make the new value of the
  2533. variable set inside the function visible to the callers.
  2534. (Yes, there is now a command substitution inside
  2535. __git_find_repo_path() around each 'git rev-parse', but that's
  2536. executed only if necessary, and only once per completion, see
  2537. point 2. below.)
  2538.  
  2539. 2. $__git_repo_path, the variable holding the path to the
  2540. repository, is declared local in the toplevel completion
  2541. functions __git_main() and __gitk_main(). Thus, once set, the
  2542. path is visible in all completion functions, including all
  2543. subsequent calls to __git_find_repo_path(), meaning that they
  2544. wouldn't have to re-discover the path to the repository.
  2545.  
  2546. So call __git_find_repo_path() and use $__git_repo_path instead of the
  2547. $(__gitdir) command substitution to access paths in the .git
  2548. directory. Turn tests checking __gitdir()'s repository discovery into
  2549. tests of __git_find_repo_path() such that only the tested function
  2550. changes but the expected results don't, ensuring that repo discovery
  2551. keeps working as it did before.
  2552.  
  2553. As __gitdir() is not used anymore in the completion script, mark it as
  2554. deprecated and direct users' attention to __git_find_repo_path() and
  2555. $__git_repo_path. Yet keep four __gitdir() tests to ensure that it
  2556. handles success and failure of __git_find_repo_path() and that it
  2557. still handles its optional remote argument, because users' custom
  2558. completion scriptlets might depend on it.
  2559.  
  2560. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2561. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2562.  
  2563. completion: extract repository discovery from __gitdir()
  2564.  
  2565. To prepare for caching the path to the repository in the following
  2566. commit, extract the repository discovering part of __gitdir() into the
  2567. __git_find_repo_path() helper function, which stores the found path in
  2568. the $__git_repo_path variable instead of printing it. Make __gitdir()
  2569. a wrapper around this new function. Declare $__git_repo_path local in
  2570. the toplevel completion functions __git_main() and __gitk_main() to
  2571. ensure that it never leaks into the environment and influences
  2572. subsequent completions (though this isn't necessary right now, as
  2573. __gitdir() is still only executed in subshells, but will matter for
  2574. the following commit).
  2575.  
  2576. Adjust tests checking __gitdir() or any other completion function
  2577. calling __gitdir() to perform those checks in a subshell to prevent
  2578. $__git_repo_path from leaking into the test environment. Otherwise
  2579. leave the tests unchanged to demonstrate that this change doesn't
  2580. alter __gitdir()'s behavior.
  2581.  
  2582. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2583. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2584.  
  2585. completion: don't guard git executions with __gitdir()
  2586.  
  2587. Three completion functions, namely __git_index_files(), __git_heads()
  2588. and __git_tags(), first run __gitdir() and check that the path it
  2589. outputs exists, i.e. that there is a git repository, and run a git
  2590. command only if there is one.
  2591.  
  2592. After the previous changes in this series there are no further uses of
  2593. __gitdir()'s output in these functions besides those checks. And
  2594. those checks are unnecessary, because we can just execute those git
  2595. commands outside of a repository and let them error out. We don't
  2596. perform such a check in other places either.
  2597.  
  2598. Remove this check and the __gitdir() call from these functions,
  2599. sparing the fork()+exec() overhead of the command substitution and the
  2600. potential 'git rev-parse' execution.
  2601.  
  2602. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2603. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2604.  
  2605. completion: consolidate silencing errors from git commands
  2606.  
  2607. Outputting error messages during completion is bad: they disrupt the
  2608. command line, can't be deleted, and the user is forced to Ctrl-C and
  2609. start over most of the time. We already silence stderr of many git
  2610. commands in our Bash completion script, but there are still some in
  2611. there that can spew error messages when something goes wrong.
  2612.  
  2613. We could add the missing stderr redirections to all the remaining
  2614. places, but instead let's leverage that git commands are now executed
  2615. through the previously introduced __git() wrapper function, and
  2616. redirect standard error to /dev/null only in that function. This way
  2617. we need only one redirection to take care of errors from almost all
  2618. git commands. Redirecting standard error of the __git() wrapper
  2619. function thus became redundant, remove them.
  2620.  
  2621. The exceptions, i.e. the repo-independent git executions and those in
  2622. the __gitdir() function that don't go through __git() already have
  2623. their standard error silenced.
  2624.  
  2625. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2626. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2627.  
  2628. completion: don't use __gitdir() for git commands
  2629.  
  2630. Several completion functions contain the following pattern to run git
  2631. commands respecting the path to the repository specified on the
  2632. command line:
  2633.  
  2634. git --git-dir="$(__gitdir)" <cmd> <options>
  2635.  
  2636. This imposes the overhead of fork()ing a subshell for the command
  2637. substitution and potentially fork()+exec()ing 'git rev-parse' inside
  2638. __gitdir().
  2639.  
  2640. Now, if neither '--gitdir=<path>' nor '-C <path>' options are
  2641. specified on the command line, then those git commands are perfectly
  2642. capable to discover the repository on their own. If either one or
  2643. both of those options are specified on the command line, then, again,
  2644. the git commands could discover the repository, if we pass them all of
  2645. those options from the command line.
  2646.  
  2647. This means we don't have to run __gitdir() at all for git commands and
  2648. can spare its fork()+exec() overhead.
  2649.  
  2650. Use Bash parameter expansions to check the $__git_dir variable and
  2651. $__git_C_args array and to assemble the appropriate '--git-dir=<path>'
  2652. and '-C <path>' options if either one or both are present on the
  2653. command line. These parameter expansions are, however, rather long,
  2654. so instead of changing all git executions and make already long lines
  2655. even longer, encapsulate running git with '--git-dir=<path> -C <path>'
  2656. options into the new __git() wrapper function. Furthermore, this
  2657. wrapper function will also enable us to silence error messages from
  2658. git commands uniformly in one place in a later commit.
  2659.  
  2660. There's one tricky case, though: in __git_refs() local refs are listed
  2661. with 'git for-each-ref', where "local" is not necessarily the
  2662. repository we are currently in, but it might mean a remote repository
  2663. in the filesystem (e.g. listing refs for 'git fetch /some/other/repo
  2664. <TAB>'). Use one-shot variable assignment to override $__git_dir with
  2665. the path of the repository where the refs should come from. Although
  2666. one-shot variable assignments in front of shell functions are to be
  2667. avoided in our scripts in general, in the Bash completion script we
  2668. can do that safely.
  2669.  
  2670. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2671. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2672.  
  2673. completion: respect 'git -C <path>'
  2674.  
  2675. 'git -C <path>' option(s) on the command line should be taken into
  2676. account during completion, because
  2677.  
  2678. - like '--git-dir=<path>', it can lead us to a different repository,
  2679.  
  2680. - a few git commands executed in the completion script do care about
  2681. in which directory they are executed, and
  2682.  
  2683. - the command for which we are providing completion might care about
  2684. in which directory it will be executed.
  2685.  
  2686. However, unlike '--git-dir=<path>', the '-C <path>' option can be
  2687. specified multiple times and their effect is cumulative, so we can't
  2688. just store a single '<path>' in a variable. Nor can we simply
  2689. concatenate a path from '-C <path1> -C <path2> ...', because e.g. (in
  2690. an arguably pathological corner case) a relative path might be
  2691. followed by an absolute path.
  2692.  
  2693. Instead, store all '-C <path>' options word by word in the
  2694. $__git_C_args array in the main git completion function, and pass this
  2695. array, if present, to 'git rev-parse --absolute-git-dir' when
  2696. discovering the repository in __gitdir(), and let it take care of
  2697. multiple options, relative paths, absolute paths and everything.
  2698.  
  2699. Also pass all '-C <path> options via the $__git_C_args array to those
  2700. git executions which require a worktree and for which it matters from
  2701. which directory they are executed from. There are only three such
  2702. cases:
  2703.  
  2704. - 'git diff-index' and 'git ls-files' in __git_ls_files_helper()
  2705. used for git-aware filename completion, and
  2706.  
  2707. - the 'git ls-tree' used for completing the 'ref:path' notation.
  2708.  
  2709. The other git commands executed in the completion script don't need
  2710. these '-C <path>' options, because __gitdir() already took those
  2711. options into account. It would not hurt them, either, but let's not
  2712. induce unnecessary code churn.
  2713.  
  2714. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2715. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2716.  
  2717. rev-parse: add '--absolute-git-dir' option
  2718.  
  2719. The output of 'git rev-parse --git-dir' can be either a relative or an
  2720. absolute path, depending on whether the current working directory is
  2721. at the top of the worktree or the .git directory or not, or how the
  2722. path to the repository is specified via the '--git-dir=<path>' option
  2723. or the $GIT_DIR environment variable. And if that output is a
  2724. relative path, then it is relative to the directory where any 'git
  2725. -C <path>' options might have led us.
  2726.  
  2727. This doesn't matter at all for regular scripts, because the git
  2728. wrapper automatically takes care of changing directories according to
  2729. the '-C <path>' options, and the scripts can then simply follow any
  2730. path returned by 'git rev-parse --git-dir', even if it's a relative
  2731. path.
  2732.  
  2733. Our Bash completion script, however, is unique in that it must run
  2734. directly in the user's interactive shell environment. This means that
  2735. it's not executed through the git wrapper and would have to take care
  2736. of any '-C <path> options on its own, and it can't just change
  2737. directories as it pleases. Consequently, adding support for taking
  2738. any '-C <path>' options on the command line into account during
  2739. completion turned out to be considerably more difficult, error prone
  2740. and required more subshells and git processes when it had to cope with
  2741. a relative path to the .git directory.
  2742.  
  2743. Help this rather special use case and teach 'git rev-parse' a new
  2744. '--absolute-git-dir' option which always outputs a canonicalized
  2745. absolute path to the .git directory, regardless of whether the path is
  2746. discovered automatically or is specified via $GIT_DIR or 'git
  2747. --git-dir=<path>'.
  2748.  
  2749. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2750. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2751.  
  2752. completion: fix completion after 'git -C <path>'
  2753.  
  2754. The main completion function finds the name of the git command by
  2755. iterating through all the words on the command line in search for the
  2756. first non-option-looking word. As it is not aware of 'git -C's
  2757. mandatory path argument, if the '-C <path>' option is present, 'path'
  2758. will be the first such word and it will be mistaken for a git command.
  2759. This breaks completion in various ways:
  2760.  
  2761. - If 'path' happens to match one of the commands supported by the
  2762. completion script, then options of that command will be offered.
  2763.  
  2764. - If 'path' doesn't match a supported command and doesn't contain any
  2765. characters not allowed in Bash identifier names, then the
  2766. completion script does basically nothing and Bash in turn falls
  2767. back to filename completion for all subsequent words.
  2768.  
  2769. - Otherwise, if 'path' does contain such an unallowed character, then
  2770. it leads to a more or less ugly error message in the middle of the
  2771. command line. The standard '/' directory separator is such a
  2772. character, and it happens to trigger one of the uglier errors:
  2773.  
  2774. $ git -C some/path <TAB>sh.exe": declare: `_git_some/path': not a valid identifier
  2775. error: invalid key: alias.some/path
  2776.  
  2777. Fix this by skipping 'git -C's mandatory path argument while iterating
  2778. over the words on the command line. Extend the relevant test with
  2779. this case and, while at it, with cases that needed similar treatment
  2780. in the past ('--git-dir', '-c', '--work-tree' and '--namespace').
  2781.  
  2782. Additionally, silence the standard error of the 'declare' builtins
  2783. looking for the completion function associated with the git command
  2784. and of the 'git config' query for the aliased command. So if git ever
  2785. learns a new option with a mandatory argument in the future, then,
  2786. though the completion script will again misbehave, at least the
  2787. command line will not be utterly disrupted by those error messages.
  2788.  
  2789. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2790. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2791.  
  2792. completion: don't offer commands when 'git --opt' needs an argument
  2793.  
  2794. The main git options '--git-dir', '-c', '-C', '--worktree' and
  2795. '--namespace' require an argument, but attempting completion right
  2796. after them lists git commands.
  2797.  
  2798. Don't offer anything right after these options, thus let Bash fall
  2799. back to filename completion, because
  2800.  
  2801. - the three options '--git-dir', '-C' and '--worktree' do actually
  2802. require a path argument, and
  2803.  
  2804. - we don't complete the required argument of '-c' and '--namespace',
  2805. and in that case the "standard" behavior of our completion script
  2806. is to not offer anything, but fall back to filename completion.
  2807.  
  2808. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2809. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2810.  
  2811. completion: list short refs from a remote given as a URL
  2812.  
  2813. e832f5c09680 (completion: avoid ls-remote in certain scenarios,
  2814. 2013-05-28) turned a 'git ls-remote <remote>' query into a 'git
  2815. for-each-ref refs/remotes/<remote>/' to improve responsiveness of
  2816. remote refs completion by avoiding potential network communication.
  2817. However, it inadvertently made impossible to complete short refs from
  2818. a remote given as a URL, e.g. 'git fetch git://server.com/repo.git
  2819. <TAB>', because there is, of course, no such thing as
  2820. 'refs/remotes/git://server.com/repo.git'.
  2821.  
  2822. Since the previous commit we tell apart configured remotes, i.e. those
  2823. that can have a hierarchy under 'refs/remotes/', from others that
  2824. don't, including remotes given as URL, so we know when we can't use
  2825. the faster 'git for-each-ref'-based approach.
  2826.  
  2827. Resurrect the old, pre-e832f5c09680 'git ls-remote'-based code for the
  2828. latter case to support listing short refs from remotes given as a URL.
  2829. The code is slightly updated from the original to
  2830.  
  2831. - take into account the path to the repository given on the command
  2832. line (if any), and
  2833. - omit 'ORIG_HEAD' from the query, as 'git ls-remote' will never
  2834. list it anyway.
  2835.  
  2836. When the remote given to __git_refs() doesn't exist, then it will be
  2837. handled by this resurrected 'git ls-remote' query. This code path
  2838. doesn't list 'HEAD' unconditionally, which has the nice side effect of
  2839. fixing two more expected test failures.
  2840.  
  2841. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2842. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2843.  
  2844. completion: don't list 'HEAD' when trying refs completion outside of a repo
  2845.  
  2846. When refs completion is attempted while not in a git repository, the
  2847. completion script offers 'HEAD' erroneously.
  2848.  
  2849. Check early in __git_refs() that there is either a repository or a
  2850. remote to work on, and return early if neither is given.
  2851.  
  2852. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2853. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2854.  
  2855. completion: list refs from remote when remote's name matches a directory
  2856.  
  2857. If the remote given to __git_refs() happens to match both the name of
  2858. a configured remote and the name of a directory in the current working
  2859. directory, then that directory is assumed to be a git repository, and
  2860. listing refs from that directory will be attempted. This is wrong,
  2861. because in such a situation git commands (e.g. 'git fetch|pull|push
  2862. <remote>' whom these refs will eventually be passed to) give
  2863. precedence to the configured remote. Therefore, __git_refs() should
  2864. list refs from the configured remote as well.
  2865.  
  2866. Add the helper function __git_is_configured_remote() that checks
  2867. whether its argument matches the name of a configured remote. Use
  2868. this helper to decide how to handle the remote passed to __git_refs().
  2869.  
  2870. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2871. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2872.  
  2873. completion: respect 'git --git-dir=<path>' when listing remote refs
  2874.  
  2875. In __git_refs() the git commands listing refs, both short and full,
  2876. from a given remote repository are run without giving them the path to
  2877. the git repository which might have been specified on the command line
  2878. via 'git --git-dir=<path>'. This is bad, those git commands should
  2879. access the 'refs/remotes/<remote>/' hierarchy or the remote and
  2880. credentials configuration in that specified repository.
  2881.  
  2882. Use the __gitdir() helper only to find the path to the .git directory
  2883. and pass the resulting path to the 'git ls-remote' and 'for-each-ref'
  2884. executions that list remote refs. While modifying that 'for-each-ref'
  2885. line, remove the superfluous disambiguating doubledash.
  2886.  
  2887. Don't use __gitdir() to check that the given remote is on the file
  2888. system: basically it performs only a single if statement for us at the
  2889. considerable cost of fork()ing a subshell for a command substitution.
  2890. We are better off to perform all the necessary checks of the remote in
  2891. __git_refs().
  2892.  
  2893. Though __git_refs() was the last remaining callsite that passed a
  2894. remote to __gitdir(), don't delete __gitdir()'s remote-handling part
  2895. yet, just in case some users' custom completion scriptlets depend on
  2896. it.
  2897.  
  2898. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2899. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2900.  
  2901. completion: fix most spots not respecting 'git --git-dir=<path>'
  2902.  
  2903. The completion script already respects the path to the repository
  2904. specified on the command line most of the time, here we add the
  2905. necessary '--git-dir=$(__gitdir)' options to most of the places where
  2906. git was executed without it. The exceptions where said option is not
  2907. added are the git invocations:
  2908.  
  2909. - in __git_refs() which are non-trivial and will be the subject of
  2910. the following patch,
  2911.  
  2912. - getting the list of git commands, merge strategies and archive
  2913. formats, because these are independent from the repository and
  2914. thus don't need it, and
  2915.  
  2916. - the 'git rev-parse --git-dir' in __gitdir() itself.
  2917.  
  2918. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2919. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2920.  
  2921. completion: ensure that the repository path given on the command line exists
  2922.  
  2923. The __gitdir() helper function prints the path to the git repository
  2924. to its stdout or stays silent and returns with error when it can't
  2925. find a repository or when the repository given via $GIT_DIR doesn't
  2926. exist.
  2927.  
  2928. This is not the case, however, when the path in $__git_dir, i.e. the
  2929. path to the repository specified on the command line via 'git
  2930. --git-dir=<path>', doesn't exist: __gitdir() still outputs it as if it
  2931. were a real existing repository, making some completion functions
  2932. believe that they operate on an existing repository.
  2933.  
  2934. Check that the path in $__git_dir exists and return with error without
  2935. printing anything to stdout if it doesn't.
  2936.  
  2937. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2938. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2939.  
  2940. completion tests: add tests for the __git_refs() helper function
  2941.  
  2942. Check how __git_refs() lists refs in different scenarios, i.e.
  2943.  
  2944. - short and full refs,
  2945. - from a local or from a remote repository,
  2946. - remote specified via path, name or URL,
  2947. - with or without a repository specified on the command line,
  2948. - non-existing remote,
  2949. - unique remote branches for 'git checkout's tracking DWIMery,
  2950. - not in a git repository, and
  2951. - interesting combinations of the above.
  2952.  
  2953. Seven of these tests expect failure, mostly demonstrating bugs related
  2954. to listing refs from a remote repository:
  2955.  
  2956. - ignoring the repository specified on the command line (2 tests),
  2957. - listing refs from the wrong place when the name of a configured
  2958. remote happens to match a directory,
  2959. - listing only 'HEAD' but no short refs from a remote given as URL,
  2960. - listing 'HEAD' even from non-existing remotes (2 tests), and
  2961. - listing 'HEAD' when not in a repository.
  2962.  
  2963. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2964. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2965.  
  2966. completion tests: check __gitdir()'s output in the error cases
  2967.  
  2968. The __gitdir() helper function shouldn't output anything if not in a
  2969. git repository. The relevant tests only checked its error code, so
  2970. extend them to ensure that there's no output.
  2971.  
  2972. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2973. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2974.  
  2975. completion tests: consolidate getting path of current working directory
  2976.  
  2977. Some tests of the __gitdir() helper function use the $TRASH_DIRECTORY
  2978. variable in direct path comparisons. In general this should be
  2979. avoided, because it might contain symbolic links. There happens to be
  2980. no issues with this here, however, because those tests use
  2981. $TRASH_DIRECTORY both for specifying the expected result and for
  2982. specifying input which in turn is just 'echo'ed verbatim.
  2983.  
  2984. Other __gitdir() tests ask for the path of the trash directory by
  2985. running $(pwd -P) in each test, sometimes even twice in a single test.
  2986.  
  2987. Run $(pwd) only once at the beginning of the test script to store the
  2988. path of the trash directory in a variable, and use that variable in
  2989. all __gitdir() tests.
  2990.  
  2991. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  2992. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2993.  
  2994. completion tests: make the $cur variable local to the test helper functions
  2995.  
  2996. The test helper functions test_gitcomp() and test_gitcomp_nl() leak
  2997. the $cur variable into the test environment. Since this variable has
  2998. a special role in the Bash completion script (it holds the word
  2999. currently being completed) it influences the behavior of most
  3000. completion functions and thus this leakage could interfere with
  3001. subsequent tests. Although there are no such issues in the current
  3002. tests, early versions of the new tests that will be added later in
  3003. this series suffered because of this.
  3004.  
  3005. It's better to play safe and declare $cur local in those test helper
  3006. functions. 'local' is bashism, of course, but the tests of the Bash
  3007. completion script are run under Bash anyway, and there are already
  3008. other variables declared local in this test script.
  3009.  
  3010. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  3011. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3012.  
  3013. completion tests: don't add test cruft to the test repository
  3014.  
  3015. While preparing commits, three tests added newly created files to the
  3016. index using 'git add .', which added not only the files in question
  3017. but leftover test cruft from previous tests like the files 'expected'
  3018. and 'actual' as well. Luckily, this had no effect on the tests'
  3019. correctness.
  3020.  
  3021. Add only the files we are actually interested in.
  3022.  
  3023. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  3024. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3025.  
  3026. completion: improve __git_refs()'s in-code documentation
  3027.  
  3028. That "first argument is passed to __gitdir()" statement in particular
  3029. is not really helpful, and after this series it won't be the case
  3030. anyway.
  3031.  
  3032. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  3033. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3034.  
  3035. l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)
  3036.  
  3037. Generate po/git.pot from v2.12.0-rc0 for git v2.12.0 l10n round 1.
  3038.  
  3039. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
  3040.  
  3041. Merge branch 'master' of git://github.com/git-l10n/git-po
  3042.  
  3043. * 'master' of git://github.com/git-l10n/git-po:
  3044. l10n: bg: Updated Bulgarian translation (2913t+0f+0u)
  3045. l10n: fixes to Catalan translation
  3046. l10n: zh_CN: review for git v2.11.0 l10n
  3047. l10n: New Catalan translation maintainer
  3048.  
  3049. Git 2.12-rc0
  3050.  
  3051. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3052.  
  3053. Merge branch 'cw/log-updates-for-all-refs-really'
  3054.  
  3055. The "core.logAllRefUpdates" that used to be boolean has been
  3056. enhanced to take 'always' as well, to record ref updates to refs
  3057. other than the ones that are expected to be updated (i.e. branches,
  3058. remote-tracking branches and notes).
  3059.  
  3060. * cw/log-updates-for-all-refs-really:
  3061. doc: add note about ignoring '--no-create-reflog'
  3062. update-ref: add test cases for bare repository
  3063. refs: add option core.logAllRefUpdates = always
  3064. config: add markup to core.logAllRefUpdates doc
  3065.  
  3066. Merge branch 'pl/complete-diff-submodule-diff'
  3067.  
  3068. The command line completion (in contrib/) learned that
  3069. "git diff --submodule=" can take "diff" as a recently added option.
  3070.  
  3071. * pl/complete-diff-submodule-diff:
  3072. Completion: Add support for --submodule=diff
  3073.  
  3074. Merge branch 'rs/object-id'
  3075.  
  3076. "uchar [40]" to "struct object_id" conversion continues.
  3077.  
  3078. * rs/object-id:
  3079. checkout: convert post_checkout_hook() to struct object_id
  3080. use oidcpy() for copying hashes between instances of struct object_id
  3081. use oid_to_hex_r() for converting struct object_id hashes to hex strings
  3082.  
  3083. Merge branch 'js/re-running-failed-tests'
  3084.  
  3085. "make -C t failed" will now run only the tests that failed in the
  3086. previous run. This is usable only when prove is not use, and gives
  3087. a useless error message when run after "make clean", but otherwise
  3088. is serviceable.
  3089.  
  3090. * js/re-running-failed-tests:
  3091. t/Makefile: add a rule to re-run previously-failed tests
  3092.  
  3093. Merge branch 'sb/submodule-update-initial-runs-custom-script'
  3094.  
  3095. The user can specify a custom update method that is run when
  3096. "submodule update" updates an already checked out submodule. This
  3097. was ignored when checking the submodule out for the first time and
  3098. we instead always just checked out the commit that is bound to the
  3099. path in the superproject's index.
  3100.  
  3101. * sb/submodule-update-initial-runs-custom-script:
  3102. submodule update: run custom update script for initial populating as well
  3103.  
  3104. Merge branch 'sb/submodule-recursive-absorb'
  3105.  
  3106. When a submodule "A", which has another submodule "B" nested within
  3107. it, is "absorbed" into the top-level superproject, the inner
  3108. submodule "B" used to be left in a strange state. The logic to
  3109. adjust the .git pointers in these submodules has been corrected.
  3110.  
  3111. * sb/submodule-recursive-absorb:
  3112. submodule absorbing: fix worktree/gitdir pointers recursively for non-moves
  3113. cache.h: expose the dying procedure for reading gitlinks
  3114. setup: add gentle version of resolve_git_dir
  3115.  
  3116. Merge branch 'sb/unpack-trees-super-prefix'
  3117.  
  3118. "git read-tree" and its underlying unpack_trees() machinery learned
  3119. to report problematic paths prefixed with the --super-prefix option.
  3120.  
  3121. * sb/unpack-trees-super-prefix:
  3122. unpack-trees: support super-prefix option
  3123. t1001: modernize style
  3124. t1000: modernize style
  3125. read-tree: use OPT_BOOL instead of OPT_SET_INT
  3126.  
  3127. Sync with v2.11.1
  3128.  
  3129. * maint:
  3130. Git 2.11.1
  3131.  
  3132. Ninth batch for 2.12; almost ready for -rc0
  3133.  
  3134. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3135.  
  3136. Merge branch 'nd/log-graph-configurable-colors'
  3137.  
  3138. Some people feel the default set of colors used by "git log --graph"
  3139. rather limiting. A mechanism to customize the set of colors has
  3140. been introduced.
  3141.  
  3142. * nd/log-graph-configurable-colors:
  3143. document behavior of empty color name
  3144. color_parse_mem: allow empty color spec
  3145. log --graph: customize the graph lines with config log.graphColors
  3146. color.c: trim leading spaces in color_parse_mem()
  3147. color.c: fix color_parse_mem() with value_len == 0
  3148.  
  3149. Merge branch 'ep/commit-static-buf-cleanup'
  3150.  
  3151. Code clean-up.
  3152.  
  3153. * ep/commit-static-buf-cleanup:
  3154. builtin/commit.c: switch to strbuf, instead of snprintf()
  3155. builtin/commit.c: remove the PATH_MAX limitation via dynamic allocation
  3156.  
  3157. Merge branch 'bc/use-asciidoctor-opt'
  3158.  
  3159. Asciidoctor, an alternative reimplementation of AsciiDoc, still
  3160. needs some changes to work with documents meant to be formatted
  3161. with AsciiDoc. "make USE_ASCIIDOCTOR=YesPlease" to use it out of
  3162. the box to document our pages is getting closer to reality.
  3163.  
  3164. * bc/use-asciidoctor-opt:
  3165. Documentation: implement linkgit macro for Asciidoctor
  3166. Makefile: add a knob to enable the use of Asciidoctor
  3167. Documentation: move dblatex arguments into variable
  3168. Documentation: add XSLT to fix DocBook for Texinfo
  3169. Documentation: sort sources for gitman.texi
  3170. Documentation: remove unneeded argument in cat-texi.perl
  3171. Documentation: modernize cat-texi.perl
  3172. Documentation: fix warning in cat-texi.perl
  3173.  
  3174. Merge branch 'sg/mailmap-self'
  3175.  
  3176. * sg/mailmap-self:
  3177. .mailmap: update Gábor Szeder's email address
  3178.  
  3179. Merge branch 'js/mingw-hooks-with-exe-suffix'
  3180.  
  3181. Names of the various hook scripts must be spelled exactly, but on
  3182. Windows, an .exe binary must be named with .exe suffix; notice
  3183. $GIT_DIR/hooks/<hookname>.exe as a valid <hookname> hook.
  3184.  
  3185. * js/mingw-hooks-with-exe-suffix:
  3186. mingw: allow hooks to be .exe files
  3187.  
  3188. Merge branch 'rs/receive-pack-cleanup'
  3189.  
  3190. Code clean-up.
  3191.  
  3192. * rs/receive-pack-cleanup:
  3193. receive-pack: call string_list_clear() unconditionally
  3194.  
  3195. Merge branch 'mm/reset-facl-before-umask-test'
  3196.  
  3197. Test tweaks for those who have default ACL in their git source tree
  3198. that interfere with the umask test.
  3199.  
  3200. * mm/reset-facl-before-umask-test:
  3201. t0001: don't let a default ACL interfere with the umask test
  3202.  
  3203. Merge branch 'hv/mingw-help-is-executable'
  3204.  
  3205. "git help" enumerates executable files in $PATH; the implementation
  3206. of "is this file executable?" on Windows has been optimized.
  3207.  
  3208. * hv/mingw-help-is-executable:
  3209. help: improve is_executable() on Windows
  3210.  
  3211. Merge branch 'gv/mingw-p4-mapuser'
  3212.  
  3213. "git p4" did not work well with multiple git-p4.mapUser entries on
  3214. Windows.
  3215.  
  3216. * gv/mingw-p4-mapuser:
  3217. git-p4: fix git-p4.mapUser on Windows
  3218.  
  3219. Merge branch 'rs/absolute-pathdup'
  3220.  
  3221. Code cleanup.
  3222.  
  3223. * rs/absolute-pathdup:
  3224. use absolute_pathdup()
  3225. abspath: add absolute_pathdup()
  3226.  
  3227. Merge branch 'js/unzip-in-usr-bin-workaround'
  3228.  
  3229. Test tweak for FreeBSD where /usr/bin/unzip is unsuitable to run
  3230. our tests but /usr/local/bin/unzip is usable.
  3231.  
  3232. * js/unzip-in-usr-bin-workaround:
  3233. test-lib: on FreeBSD, look for unzip(1) in /usr/local/bin/
  3234.  
  3235. Merge branch 'cw/doc-sign-off'
  3236.  
  3237. Doc update.
  3238.  
  3239. * cw/doc-sign-off:
  3240. doc: clarify distinction between sign-off and pgp-signing
  3241.  
  3242. Merge branch 'js/status-pre-rebase-i'
  3243.  
  3244. After starting "git rebase -i", which first opens the user's editor
  3245. to edit the series of patches to apply, but before saving the
  3246. contents of that file, "git status" failed to show the current
  3247. state (i.e. you are in an interactive rebase session, but you have
  3248. applied no steps yet) correctly.
  3249.  
  3250. * js/status-pre-rebase-i:
  3251. status: be prepared for not-yet-started interactive rebase
  3252.  
  3253. Merge branch 'js/retire-relink'
  3254.  
  3255. Cruft removal.
  3256.  
  3257. * js/retire-relink:
  3258. relink: really remove the command
  3259. relink: retire the command
  3260.  
  3261. Merge branch 'sb/submodule-add-force'
  3262.  
  3263. "git submodule add" used to be confused and refused to add a
  3264. locally created repository; users can now use "--force" option
  3265. to add them.
  3266.  
  3267. * sb/submodule-add-force:
  3268. submodule add: extend force flag to add existing repos
  3269.  
  3270. Git 2.11.1
  3271.  
  3272. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3273.  
  3274. Merge branch 'ws/request-pull-code-cleanup' into maint
  3275.  
  3276. Code clean-up.
  3277.  
  3278. * ws/request-pull-code-cleanup:
  3279. request-pull: drop old USAGE stuff
  3280.  
  3281. Merge branch 'jk/execv-dashed-external' into maint
  3282.  
  3283. Typing ^C to pager, which usually does not kill it, killed Git and
  3284. took the pager down as a collateral damage in certain process-tree
  3285. structure. This has been fixed.
  3286.  
  3287. * jk/execv-dashed-external:
  3288. execv_dashed_external: wait for child on signal death
  3289. execv_dashed_external: stop exiting with negative code
  3290. execv_dashed_external: use child_process struct
  3291.  
  3292. document behavior of empty color name
  3293.  
  3294. Commit 55cccf4bb (color_parse_mem: allow empty color spec,
  3295. 2017-02-01) clearly defined the behavior of an empty color
  3296. config variable. Let's document that, and give a hint about
  3297. why it might be useful.
  3298.  
  3299. It's important not to say that it makes the item uncolored,
  3300. because it doesn't. It just sets no attributes, which means
  3301. that any previous attributes continue to take effect.
  3302.  
  3303. Signed-off-by: Jeff King <peff@peff.net>
  3304. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3305.  
  3306. doc: add note about ignoring '--no-create-reflog'
  3307.  
  3308. The commands git-branch and git-tag accept the '--create-reflog'
  3309. option, and create reflog even when core.logallrefupdates
  3310. configuration is explicitly set not to.
  3311.  
  3312. On the other hand, the negated form '--no-create-reflog' is accepted
  3313. as a valid option but has no effect (other than overriding an
  3314. earlier '--create-reflog' on the command line). This silent noop may
  3315. puzzle users. To communicate that this is a known limitation, add a
  3316. short note in the manuals for git-branch and git-tag.
  3317.  
  3318. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  3319. Helped-by: Jeff King <peff@peff.net>
  3320. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3321.  
  3322. completion: add completion for --recurse-submodules=only
  3323.  
  3324. Command completion for 'git-push --recurse-submodules' already knows to
  3325. complete some modes. However, the recently added mode 'only' is missing.
  3326.  
  3327. Adding 'only' to the recognized modes completes the list of non-trivial
  3328. modes.
  3329.  
  3330. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  3331. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3332.  
  3333. doc: add doc for git-push --recurse-submodules=only
  3334.  
  3335. Add documentation for the `--recurse-submodules=only` option of
  3336. git-push. The feature was added in commit 225e8bf (add option to
  3337. push only submodules).
  3338.  
  3339. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  3340. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3341.  
  3342. attr: reformat git_attr_set_direction() function
  3343.  
  3344. Move the 'git_attr_set_direction()' up to be closer to the variables
  3345. that it modifies as well as a small formatting by renaming the variable
  3346. 'new' to 'new_direction' so that it is more descriptive.
  3347.  
  3348. Update the comment about how 'direction' is used to read the state of
  3349. the world. It should be noted that callers of
  3350. 'git_attr_set_direction()' should ensure that other threads are not
  3351. making calls into the attribute system until after the call to
  3352. 'git_attr_set_direction()' completes. This function essentially acts as
  3353. reset button for the attribute system and should be handled with care.
  3354.  
  3355. Signed-off-by: Brandon Williams <bmwill@google.com>
  3356. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3357.  
  3358. attr: push the bare repo check into read_attr()
  3359.  
  3360. Push the bare repository check into the 'read_attr()' function. This
  3361. avoids needing to have extra logic which creates an empty stack frame
  3362. when inside a bare repo as a similar bit of logic already exists in the
  3363. 'read_attr()' function.
  3364.  
  3365. Signed-off-by: Brandon Williams <bmwill@google.com>
  3366. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3367.  
  3368. attr: store attribute stack in attr_check structure
  3369.  
  3370. The last big hurdle towards a thread-safe API for the attribute system
  3371. is the reliance on a global attribute stack that is modified during each
  3372. call into the attribute system.
  3373.  
  3374. This patch removes this global stack and instead a stack is stored
  3375. locally in each attr_check instance. This opens up the opportunity for
  3376. future optimizations to customize the attribute stack for the attributes
  3377. that a particular attr_check struct is interested in.
  3378.  
  3379. One caveat with pushing the attribute stack into the attr_check
  3380. structure is that the attribute system now needs to keep track of all
  3381. active attr_check instances. Due to the direction mechanism the stack
  3382. needs to be dropped when the direction is switched. In order to ensure
  3383. correctness when the direction is changed the attribute system needs to
  3384. iterate through all active attr_check instances and drop each of their
  3385. stacks.
  3386.  
  3387. Signed-off-by: Brandon Williams <bmwill@google.com>
  3388. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3389.  
  3390. attr: tighten const correctness with git_attr and match_attr
  3391.  
  3392. Signed-off-by: Brandon Williams <bmwill@google.com>
  3393. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3394.  
  3395. attr: remove maybe-real, maybe-macro from git_attr
  3396.  
  3397. Whether or not a git attribute is real or a macro isn't a property of
  3398. the attribute but rather it depends on the attribute stack (which
  3399. .gitattribute files were read).
  3400.  
  3401. This patch removes the 'maybe_real' and 'maybe_macro' fields in a
  3402. git_attr and instead adds the 'macro' field to a attr_check_item. The
  3403. 'macro' indicates (if non-NULL) that a particular attribute is a macro
  3404. for the given attribute stack. It's populated, through a quick scan of
  3405. the attribute stack, with the match_attr that corresponds to the macro's
  3406. definition. This way the attribute stack only needs to be scanned a
  3407. single time prior to attribute collection instead of each time a macro
  3408. needs to be expanded.
  3409.  
  3410. Signed-off-by: Brandon Williams <bmwill@google.com>
  3411. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3412.  
  3413. attr: eliminate global check_all_attr array
  3414.  
  3415. Currently there is a reliance on 'check_all_attr' which is a global
  3416. array of 'attr_check_item' items which is used to store the value of
  3417. each attribute during the collection process.
  3418.  
  3419. This patch eliminates this global and instead creates an array per
  3420. 'attr_check' instance which is then used in the attribute collection
  3421. process. This brings the attribute system one step closer to being
  3422. thread-safe.
  3423.  
  3424. Signed-off-by: Brandon Williams <bmwill@google.com>
  3425. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3426.  
  3427. attr: use hashmap for attribute dictionary
  3428.  
  3429. The current implementation of the attribute dictionary uses a custom
  3430. hashtable. This modernizes the dictionary by converting it to the builtin
  3431. 'hashmap' structure.
  3432.  
  3433. Also, in order to enable a threaded API in the future add an
  3434. accompanying mutex which must be acquired prior to accessing the
  3435. dictionary of interned attributes.
  3436.  
  3437. Signed-off-by: Brandon Williams <bmwill@google.com>
  3438. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3439.  
  3440. attr: change validity check for attribute names to use positive logic
  3441.  
  3442. Convert 'invalid_attr_name()' to 'attr_name_valid()' and use positive
  3443. logic for the return value. In addition create a helper function that
  3444. prints out an error message when an invalid attribute name is used.
  3445.  
  3446. We could later update the message to exactly spell out what the
  3447. rules for a good attribute name are, etc.
  3448.  
  3449. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3450. Signed-off-by: Stefan Beller <sbeller@google.com>
  3451. Signed-off-by: Brandon Williams <bmwill@google.com>
  3452. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3453.  
  3454. attr: pass struct attr_check to collect_some_attrs
  3455.  
  3456. The old callchain used to take an array of attr_check_item items.
  3457. Instead pass the 'attr_check' container object to 'collect_some_attrs()'
  3458. and access the fields in the data structure directly.
  3459.  
  3460. Signed-off-by: Brandon Williams <bmwill@google.com>
  3461. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3462.  
  3463. attr: retire git_check_attrs() API
  3464.  
  3465. Since nobody uses the old API, make it file-scope static, and update
  3466. the documentation to describe the new API.
  3467.  
  3468. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3469. Signed-off-by: Stefan Beller <sbeller@google.com>
  3470. Signed-off-by: Brandon Williams <bmwill@google.com>
  3471. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3472.  
  3473. attr: convert git_check_attrs() callers to use the new API
  3474.  
  3475. The remaining callers are all simple "I have N attributes I am
  3476. interested in. I'll ask about them with various paths one by one".
  3477.  
  3478. After this step, no caller to git_check_attrs() remains. After
  3479. removing it, we can extend "struct attr_check" struct with data
  3480. that can be used in optimizing the query for the specific N
  3481. attributes it contains.
  3482.  
  3483. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3484. Signed-off-by: Stefan Beller <sbeller@google.com>
  3485. Signed-off-by: Brandon Williams <bmwill@google.com>
  3486. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3487.  
  3488. attr: convert git_all_attrs() to use "struct attr_check"
  3489.  
  3490. This updates the other two ways the attribute check is done via an
  3491. array of "struct attr_check_item" elements. These two niches
  3492. appear only in "git check-attr".
  3493.  
  3494. * The caller does not know offhand what attributes it wants to ask
  3495. about and cannot use attr_check_initl() to prepare the
  3496. attr_check structure.
  3497.  
  3498. * The caller may not know what attributes it wants to ask at all,
  3499. and instead wants to learn everything that the given path has.
  3500.  
  3501. Such a caller can call attr_check_alloc() to allocate an empty
  3502. attr_check, and then call attr_check_append() to add attribute names
  3503. one by one.
  3504.  
  3505. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3506. Signed-off-by: Stefan Beller <sbeller@google.com>
  3507. Signed-off-by: Brandon Williams <bmwill@google.com>
  3508. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3509.  
  3510. attr: (re)introduce git_check_attr() and struct attr_check
  3511.  
  3512. A common pattern to check N attributes for many paths is to
  3513.  
  3514. (1) prepare an array A of N attr_check_item items;
  3515. (2) call git_attr() to intern the N attribute names and fill A;
  3516. (3) repeatedly call git_check_attrs() for path with N and A;
  3517.  
  3518. A look-up for these N attributes for a single path P scans the
  3519. entire attr_stack, starting from the .git/info/attributes file and
  3520. then .gitattributes file in the directory the path P is in, going
  3521. upwards to find .gitattributes file found in parent directories.
  3522.  
  3523. An earlier commit 06a604e6 (attr: avoid heavy work when we know the
  3524. specified attr is not defined, 2014-12-28) tried to optimize out
  3525. this scanning for one trivial special case: when the attribute being
  3526. sought is known not to exist, we do not have to scan for it. While
  3527. this may be a cheap and effective heuristic, it would not work well
  3528. when N is (much) more than 1.
  3529.  
  3530. What we would want is a more customized way to skip irrelevant
  3531. entries in the attribute stack, and the definition of irrelevance
  3532. is tied to the set of attributes passed to git_check_attrs() call,
  3533. i.e. the set of attributes being sought. The data necessary for
  3534. this optimization needs to live alongside the set of attributes, but
  3535. a simple array of git_attr_check_elem simply does not have any place
  3536. for that.
  3537.  
  3538. Introduce "struct attr_check" that contains N, the number of
  3539. attributes being sought, and A, the array that holds N
  3540. attr_check_item items, and a function git_check_attr() that
  3541. takes a path P and this structure as its parameters. This structure
  3542. can later be extended to hold extra data necessary for optimization.
  3543.  
  3544. Also, to make it easier to write the first two steps in common
  3545. cases, introduce git_attr_check_initl() helper function, which takes
  3546. a NULL-terminated list of attribute names and initialize this
  3547. structure.
  3548.  
  3549. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3550. Signed-off-by: Stefan Beller <sbeller@google.com>
  3551. Signed-off-by: Brandon Williams <bmwill@google.com>
  3552. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3553.  
  3554. attr: rename function and struct related to checking attributes
  3555.  
  3556. The traditional API to check attributes is to prepare an N-element
  3557. array of "struct git_attr_check" and pass N and the array to the
  3558. function "git_check_attr()" as arguments.
  3559.  
  3560. In preparation to revamp the API to pass a single structure, in
  3561. which these N elements are held, rename the type used for these
  3562. individual array elements to "struct attr_check_item" and rename
  3563. the function to "git_check_attrs()".
  3564.  
  3565. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3566. Signed-off-by: Stefan Beller <sbeller@google.com>
  3567. Signed-off-by: Brandon Williams <bmwill@google.com>
  3568. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3569.  
  3570. attr.c: outline the future plans by heavily commenting
  3571.  
  3572. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3573. Signed-off-by: Stefan Beller <sbeller@google.com>
  3574. Signed-off-by: Brandon Williams <bmwill@google.com>
  3575. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3576.  
  3577. Documentation: fix a typo
  3578.  
  3579. Signed-off-by: Stefan Beller <sbeller@google.com>
  3580. Signed-off-by: Brandon Williams <bmwill@google.com>
  3581. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3582.  
  3583. attr.c: add push_stack() helper
  3584.  
  3585. There are too many repetitious "I have this new attr_stack element;
  3586. push it at the top of the stack" sequence. The new helper function
  3587. push_stack() gives us a way to express what is going on at these
  3588. places, and as a side effect, halves the number of times we mention
  3589. the attr_stack global variable.
  3590.  
  3591. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3592. Signed-off-by: Stefan Beller <sbeller@google.com>
  3593. Signed-off-by: Brandon Williams <bmwill@google.com>
  3594. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3595.  
  3596. attr: support quoting pathname patterns in C style
  3597.  
  3598. Full pattern must be quoted. So 'pat"t"ern attr' will give exactly
  3599. 'pat"t"ern', not 'pattern'. Also clarify that leading whitespaces are
  3600. not part of the pattern and document comment syntax.
  3601.  
  3602. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  3603. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3604. Signed-off-by: Stefan Beller <sbeller@google.com>
  3605. Signed-off-by: Brandon Williams <bmwill@google.com>
  3606. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3607.  
  3608. attr.c: plug small leak in parse_attr_line()
  3609.  
  3610. If any error is noticed after the match_attr structure is allocated,
  3611. we shouldn't just return NULL from this function.
  3612.  
  3613. Add a fail_return label that frees the allocated structure and
  3614. returns NULL, and consistently jump there when we want to return
  3615. NULL after cleaning up.
  3616.  
  3617. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3618. Signed-off-by: Stefan Beller <sbeller@google.com>
  3619. Signed-off-by: Brandon Williams <bmwill@google.com>
  3620. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3621.  
  3622. attr.c: tighten constness around "git_attr" structure
  3623.  
  3624. It holds an interned string, and git_attr_name() is a way to peek
  3625. into it. Make sure the involved pointer types are pointer-to-const.
  3626.  
  3627. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3628. Signed-off-by: Stefan Beller <sbeller@google.com>
  3629. Signed-off-by: Brandon Williams <bmwill@google.com>
  3630. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3631.  
  3632. attr.c: simplify macroexpand_one()
  3633.  
  3634. The double-loop wants to do an early return immediately when one
  3635. matching macro is found. Eliminate the extra variable 'a' used for
  3636. that purpose and rewrite the "assign the found item to 'a' to make
  3637. it non-NULL and force the loop(s) to terminate" with a direct return
  3638. from there.
  3639.  
  3640. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3641. Signed-off-by: Stefan Beller <sbeller@google.com>
  3642. Signed-off-by: Brandon Williams <bmwill@google.com>
  3643. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3644.  
  3645. attr.c: mark where #if DEBUG ends more clearly
  3646.  
  3647. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3648. Signed-off-by: Stefan Beller <sbeller@google.com>
  3649. Signed-off-by: Brandon Williams <bmwill@google.com>
  3650. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3651.  
  3652. attr.c: complete a sentence in a comment
  3653.  
  3654. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3655. Signed-off-by: Stefan Beller <sbeller@google.com>
  3656. Signed-off-by: Brandon Williams <bmwill@google.com>
  3657. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3658.  
  3659. attr.c: explain the lack of attr-name syntax check in parse_attr()
  3660.  
  3661. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3662. Signed-off-by: Stefan Beller <sbeller@google.com>
  3663. Signed-off-by: Brandon Williams <bmwill@google.com>
  3664. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3665.  
  3666. attr.c: update a stale comment on "struct match_attr"
  3667.  
  3668. When 82dce998 (attr: more matching optimizations from .gitignore,
  3669. 2012-10-15) changed a pointer to a string "*pattern" into an
  3670. embedded "struct pattern" in struct match_attr, it forgot to update
  3671. the comment that describes the structure.
  3672.  
  3673. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3674. Signed-off-by: Stefan Beller <sbeller@google.com>
  3675. Signed-off-by: Brandon Williams <bmwill@google.com>
  3676. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3677.  
  3678. attr.c: use strchrnul() to scan for one line
  3679.  
  3680. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3681. Signed-off-by: Stefan Beller <sbeller@google.com>
  3682. Signed-off-by: Brandon Williams <bmwill@google.com>
  3683. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3684.  
  3685. commit.c: use strchrnul() to scan for one line
  3686.  
  3687. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3688. Signed-off-by: Stefan Beller <sbeller@google.com>
  3689. Signed-off-by: Brandon Williams <bmwill@google.com>
  3690. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3691.  
  3692. urlmatch: allow globbing for the URL host part
  3693.  
  3694. The URL matching function computes for two URLs whether they match not.
  3695. The match is performed by splitting up the URL into different parts and
  3696. then doing an exact comparison with the to-be-matched URL.
  3697.  
  3698. The main user of `urlmatch` is the configuration subsystem. It allows to
  3699. set certain configurations based on the URL which is being connected to
  3700. via keys like `http.<url>.*`. A common use case for this is to set
  3701. proxies for only some remotes which match the given URL. Unfortunately,
  3702. having exact matches for all parts of the URL can become quite tedious
  3703. in some setups. Imagine for example a corporate network where there are
  3704. dozens or even hundreds of subdomains, which would have to be configured
  3705. individually.
  3706.  
  3707. Allow users to write an asterisk '*' in place of any 'host' or
  3708. 'subdomain' label as part of the host name. For example,
  3709. "http.https://*.example.com.proxy" sets "http.proxy" for all direct
  3710. subdomains of "https://example.com", e.g. "https://foo.example.com", but
  3711. not "https://foo.bar.example.com".
  3712.  
  3713. Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
  3714. Helped-by: Junio C Hamano <gitster@pobox.com>
  3715. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3716.  
  3717. urlmatch: include host in urlmatch ranking
  3718.  
  3719. In order to be able to rank positive matches by `urlmatch`, we inspect
  3720. the path length and user part to decide whether a match is better than
  3721. another match. As all other parts are matched exactly between both URLs,
  3722. this is the correct thing to do right now.
  3723.  
  3724. In the future, though, we want to introduce wild cards for the domain
  3725. part. When doing this, it does not make sense anymore to only compare
  3726. the path lengths. Instead, we also want to compare the domain lengths to
  3727. determine which of both URLs matches the host part more closely.
  3728.  
  3729. Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
  3730. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3731.  
  3732. connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config
  3733.  
  3734. This environment variable and configuration value allow to
  3735. override the autodetection of plink/tortoiseplink in case that
  3736. Git gets it wrong.
  3737.  
  3738. [jes: wrapped overly-long lines, factored out and changed
  3739. get_ssh_variant() to handle_ssh_variant() to accomodate the
  3740. change from the putty/tortoiseplink variables to
  3741. port_option/needs_batch, adjusted the documentation, free()d
  3742. value obtained from the config.]
  3743.  
  3744. Signed-off-by: Segev Finer <segev208@gmail.com>
  3745. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  3746. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3747.  
  3748. git_connect(): factor out SSH variant handling
  3749.  
  3750. We handle plink and tortoiseplink as OpenSSH replacements, by passing
  3751. the correct command-line options when detecting that they are used.
  3752.  
  3753. To let users override that auto-detection (in case Git gets it wrong),
  3754. we need to introduce new code to that end.
  3755.  
  3756. In preparation for this code, let's factor out the SSH variant handling
  3757. into its own function, handle_ssh_variant().
  3758.  
  3759. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  3760. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3761.  
  3762. color_parse_mem: allow empty color spec
  3763.  
  3764. Prior to c2f41bf52 (color.c: fix color_parse_mem() with
  3765. value_len == 0, 2017-01-19), the empty string was
  3766. interpreted as a color "reset". This was an accidental
  3767. outcome, and that commit turned it into an error.
  3768.  
  3769. However, scripts may pass the empty string as a default
  3770. value to "git config --get-color" to disable color when the
  3771. value is not defined. The git-add--interactive script does
  3772. this. As a result, the script is unusable since c2f41bf52
  3773. unless you have color.diff.plain defined (if it is defined,
  3774. then we don't parse the empty default at all).
  3775.  
  3776. Our test scripts didn't notice the recent breakage because
  3777. they run without a terminal, and thus without color. They
  3778. never hit this code path at all. And nobody noticed the
  3779. original buggy "reset" behavior, because it was effectively
  3780. a noop.
  3781.  
  3782. Let's fix the code to have an empty color name produce an
  3783. empty sequence of color codes. The tests need a few fixups:
  3784.  
  3785. - we'll add a new test in t4026 to cover this case. But
  3786. note that we need to tweak the color() helper. While
  3787. we're there, let's factor out the literal ANSI ESC
  3788. character. Otherwise it makes the diff quite hard to
  3789. read.
  3790.  
  3791. - we'll add a basic sanity-check in t4026 that "git add
  3792. -p" works at all when color is enabled. That would have
  3793. caught this bug, as well as any others that are specific
  3794. to the color code paths.
  3795.  
  3796. - 73c727d69 (log --graph: customize the graph lines with
  3797. config log.graphColors, 2017-01-19) added a test to
  3798. t4202 that checks some "invalid" graph color config.
  3799. Since ",, blue" before yielded only "blue" as valid, and
  3800. now yields "empty, empty, blue", we don't match the
  3801. expected output.
  3802.  
  3803. One way to fix this would be to change the expectation
  3804. to the empty color strings. But that makes the test much
  3805. less interesting, since we show only two graph lines,
  3806. both of which would be colorless.
  3807.  
  3808. Since the empty-string case is now covered by t4026,
  3809. let's remove them entirely here. They're just in the way
  3810. of the primary thing the test is supposed to be
  3811. checking.
  3812.  
  3813. Signed-off-by: Jeff King <peff@peff.net>
  3814. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3815.  
  3816. .mailmap: update Gábor Szeder's email address
  3817.  
  3818. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  3819. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3820.  
  3821. Sync with maint
  3822.  
  3823. * maint:
  3824. Ready for 2.11.1
  3825.  
  3826. Ready for 2.11.1
  3827.  
  3828. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3829.  
  3830. Merge branch 'sb/in-core-index-doc' into maint
  3831.  
  3832. Documentation and in-code comments updates.
  3833.  
  3834. * sb/in-core-index-doc:
  3835. documentation: retire unfinished documentation
  3836. cache.h: document add_[file_]to_index
  3837. cache.h: document remove_index_entry_at
  3838. cache.h: document index_name_pos
  3839.  
  3840. Merge branch 'js/mingw-isatty' into maint
  3841.  
  3842. An update to a topic that is already in 'master'.
  3843.  
  3844. * js/mingw-isatty:
  3845. mingw: follow-up to "replace isatty() hack"
  3846.  
  3847. Merge branch 'jk/coding-guidelines-update' into maint
  3848.  
  3849. Developer doc update.
  3850.  
  3851. * jk/coding-guidelines-update:
  3852. CodingGuidelines: clarify multi-line brace style
  3853.  
  3854. Merge branch 'js/exec-path-coverity-workaround' into maint
  3855.  
  3856. Code cleanup.
  3857.  
  3858. * js/exec-path-coverity-workaround:
  3859. git_exec_path: do not return the result of getenv()
  3860. git_exec_path: avoid Coverity warning about unfree()d result
  3861.  
  3862. Merge branch 'ad/bisect-terms' into maint
  3863.  
  3864. Documentation fix.
  3865.  
  3866. * ad/bisect-terms:
  3867. Documentation/bisect: improve on (bad|new) and (good|bad)
  3868.  
  3869. Merge branch 'jk/grep-e-could-be-extended-beyond-posix' into maint
  3870.  
  3871. Tighten a test to avoid mistaking an extended ERE regexp engine as
  3872. a PRE regexp engine.
  3873.  
  3874. * jk/grep-e-could-be-extended-beyond-posix:
  3875. t7810: avoid assumption about invalid regex syntax
  3876.  
  3877. Merge branch 'km/branch-get-push-while-detached' into maint
  3878.  
  3879. "git <cmd> @{push}" on a detached HEAD used to segfault; it has
  3880. been corrected to error out with a message.
  3881.  
  3882. * km/branch-get-push-while-detached:
  3883. branch_get_push: do not segfault when HEAD is detached
  3884.  
  3885. Merge branch 'jk/rebase-i-squash-count-fix' into maint
  3886.  
  3887. "git rebase -i" with a recent update started showing an incorrect
  3888. count when squashing more than 10 commits.
  3889.  
  3890. * jk/rebase-i-squash-count-fix:
  3891. rebase--interactive: count squash commits above 10 correctly
  3892.  
  3893. Merge branch 'jk/blame-fixes' into maint
  3894.  
  3895. "git blame --porcelain" misidentified the "previous" <commit, path>
  3896. pair (aka "source") when contents came from two or more files.
  3897.  
  3898. * jk/blame-fixes:
  3899. blame: output porcelain "previous" header for each file
  3900. blame: handle --no-abbrev
  3901. blame: fix alignment with --abbrev=40
  3902.  
  3903. Merge branch 'jk/archive-zip-userdiff-config' into maint
  3904.  
  3905. "git archive" did not read the standard configuration files, and
  3906. failed to notice a file that is marked as binary via the userdiff
  3907. driver configuration.
  3908.  
  3909. * jk/archive-zip-userdiff-config:
  3910. archive-zip: load userdiff config
  3911.  
  3912. Merge branch 'dt/disable-bitmap-in-auto-gc' into maint
  3913.  
  3914. It is natural that "git gc --auto" may not attempt to pack
  3915. everything into a single pack, and there is no point in warning
  3916. when the user has configured the system to use the pack bitmap,
  3917. leading to disabling further "gc".
  3918.  
  3919. * dt/disable-bitmap-in-auto-gc:
  3920. repack: die on incremental + write-bitmap-index
  3921. auto gc: don't write bitmaps for incremental repacks
  3922.  
  3923. Merge branch 'nd/config-misc-fixes' into maint
  3924.  
  3925. Leakage of lockfiles in the config subsystem has been fixed.
  3926.  
  3927. * nd/config-misc-fixes:
  3928. config.c: handle lock file in error case in git_config_rename_...
  3929. config.c: rename label unlock_and_out
  3930. config.c: handle error case for fstat() calls
  3931.  
  3932. Merge branch 'jc/abbrev-autoscale-config' into maint
  3933.  
  3934. Recent update to the default abbreviation length that auto-scales
  3935. lacked documentation update, which has been corrected.
  3936.  
  3937. * jc/abbrev-autoscale-config:
  3938. config.abbrev: document the new default that auto-scales
  3939.  
  3940. Merge branch 'mh/fast-import-notes-fix-new' into maint
  3941.  
  3942. "git fast-import" sometimes mishandled while rebalancing notes
  3943. tree, which has been fixed.
  3944.  
  3945. * mh/fast-import-notes-fix-new:
  3946. fast-import: properly fanout notes when tree is imported
  3947.  
  3948. Merge branch 'jc/compression-config' into maint
  3949.  
  3950. Compression setting for producing packfiles were spread across
  3951. three codepaths, one of which did not honor any configuration.
  3952. Unify these so that all of them honor core.compression and
  3953. pack.compression variables the same way.
  3954.  
  3955. * jc/compression-config:
  3956. compression: unify pack.compression configuration parsing
  3957.  
  3958. Merge branch 'ew/svn-fixes' into maint
  3959.  
  3960. Meant eventually for 'maint'.
  3961.  
  3962. * ew/svn-fixes:
  3963. git-svn: document useLogAuthor and addAuthorFrom config keys
  3964. git-svn: allow "0" in SVN path components
  3965.  
  3966. Merge branch 'ls/travis-p4-on-macos' into maint
  3967.  
  3968. Update the definition of the MacOSX test environment used by
  3969. TravisCI.
  3970.  
  3971. * ls/travis-p4-on-macos:
  3972. travis-ci: fix Perforce install on macOS
  3973.  
  3974. Merge branch 'jk/make-tags-find-sources-tweak' into maint
  3975.  
  3976. Update the procedure to generate "tags" for developer support.
  3977.  
  3978. * jk/make-tags-find-sources-tweak:
  3979. Makefile: exclude contrib from FIND_SOURCE_FILES
  3980. Makefile: match shell scripts in FIND_SOURCE_FILES
  3981. Makefile: exclude test cruft from FIND_SOURCE_FILES
  3982. Makefile: reformat FIND_SOURCE_FILES
  3983.  
  3984. Merge branch 'jc/latin-1' into maint
  3985.  
  3986. Some platforms no longer understand "latin-1" that is still seen in
  3987. the wild in e-mail headers; replace them with "iso-8859-1" that is
  3988. more widely known when conversion fails from/to it.
  3989.  
  3990. * jc/latin-1:
  3991. utf8: accept "latin-1" as ISO-8859-1
  3992. utf8: refactor code to decide fallback encoding
  3993.  
  3994. Eighth batch for 2.12
  3995.  
  3996. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3997.  
  3998. Merge branch 'jk/fsck-connectivity-check-fix'
  3999.  
  4000. "git fsck --connectivity-check" was not working at all.
  4001.  
  4002. * jk/fsck-connectivity-check-fix:
  4003. fsck: lazily load types under --connectivity-only
  4004. fsck: move typename() printing to its own function
  4005. t1450: use "mv -f" within loose object directory
  4006. fsck: check HAS_OBJ more consistently
  4007. fsck: do not fallback "git fsck <bogus>" to "git fsck"
  4008. fsck: tighten error-checks of "git fsck <head>"
  4009. fsck: prepare dummy objects for --connectivity-check
  4010. fsck: report trees as dangling
  4011. t1450: clean up sub-objects in duplicate-entry test
  4012.  
  4013. Merge branch 'js/difftool-builtin'
  4014.  
  4015. Rewrite a scripted porcelain "git difftool" in C.
  4016.  
  4017. * js/difftool-builtin:
  4018. difftool: hack around -Wzero-length-format warning
  4019. difftool: retire the scripted version
  4020. difftool: implement the functionality in the builtin
  4021. difftool: add a skeleton for the upcoming builtin
  4022.  
  4023. Merge branch 'rs/qsort-s'
  4024.  
  4025. A few codepaths had to rely on a global variable when sorting
  4026. elements of an array because sort(3) API does not allow extra data
  4027. to be passed to the comparison function. Use qsort_s() when
  4028. natively available, and a fallback implementation of it when not,
  4029. to eliminate the need, which is a prerequisite for making the
  4030. codepath reentrant.
  4031.  
  4032. * rs/qsort-s:
  4033. ref-filter: use QSORT_S in ref_array_sort()
  4034. string-list: use QSORT_S in string_list_sort()
  4035. perf: add basic sort performance test
  4036. add QSORT_S
  4037. compat: add qsort_s()
  4038.  
  4039. Merge branch 'ls/travis-p4-on-macos'
  4040.  
  4041. Update the definition of the MacOSX test environment used by
  4042. TravisCI.
  4043.  
  4044. * ls/travis-p4-on-macos:
  4045. travis-ci: fix Perforce install on macOS
  4046.  
  4047. Merge branch 'vp/show-ref-verify-head'
  4048.  
  4049. "git show-ref HEAD" used with "--verify" because the user is not
  4050. interested in seeing refs/remotes/origin/HEAD, and used with
  4051. "--head" because the user does not want HEAD to be filtered out,
  4052. i.e. "git show-ref --head --verify HEAD", did not work as expected.
  4053.  
  4054. * vp/show-ref-verify-head:
  4055. show-ref: remove a stale comment
  4056. show-ref: remove dead `if (verify)' check
  4057. show-ref: detect dangling refs under --verify as well
  4058. show-ref: move --quiet handling into show_one()
  4059. show-ref: allow -d to work with --verify
  4060. show-ref: accept HEAD with --verify
  4061.  
  4062. Merge branch 'sb/retire-convert-objects-from-contrib'
  4063.  
  4064. Remove an ancient tool left in contrib/.
  4065.  
  4066. * sb/retire-convert-objects-from-contrib:
  4067. contrib: remove git-convert-objects
  4068.  
  4069. Merge branch 'sb/in-core-index-doc'
  4070.  
  4071. Documentation and in-code comments updates.
  4072.  
  4073. * sb/in-core-index-doc:
  4074. documentation: retire unfinished documentation
  4075. cache.h: document add_[file_]to_index
  4076. cache.h: document remove_index_entry_at
  4077. cache.h: document index_name_pos
  4078.  
  4079. Merge branch 'js/remote-rename-with-half-configured-remote'
  4080.  
  4081. With anticipatory tweaking for remotes defined in ~/.gitconfig
  4082. (e.g. "remote.origin.prune" set to true, even though there may or
  4083. may not actually be "origin" remote defined in a particular Git
  4084. repository), "git remote rename" and other commands misinterpreted
  4085. and behaved as if such a non-existing remote actually existed.
  4086.  
  4087. * js/remote-rename-with-half-configured-remote:
  4088. remote rename: more carefully determine whether a remote is configured
  4089. remote rename: demonstrate a bogus "remote exists" bug
  4090.  
  4091. Merge branch 'jk/clear-delta-base-cache-fix'
  4092.  
  4093. A crashing bug introduced in v2.11 timeframe has been found (it is
  4094. triggerable only in fast-import) and fixed.
  4095.  
  4096. * jk/clear-delta-base-cache-fix:
  4097. clear_delta_base_cache(): don't modify hashmap while iterating
  4098.  
  4099. Merge branch 'st/verify-tag'
  4100.  
  4101. "git tag" and "git verify-tag" learned to put GPG verification
  4102. status in their "--format=<placeholders>" output format.
  4103.  
  4104. * st/verify-tag:
  4105. t/t7004-tag: Add --format specifier tests
  4106. t/t7030-verify-tag: Add --format specifier tests
  4107. builtin/tag: add --format argument for tag -v
  4108. builtin/verify-tag: add --format to verify-tag
  4109. ref-filter: add function to print single ref_array_item
  4110. gpg-interface, tag: add GPG_VERIFY_OMIT_STATUS flag
  4111.  
  4112. Merge branch 'js/mingw-isatty'
  4113.  
  4114. An update to a topic that is already in 'master'.
  4115.  
  4116. * js/mingw-isatty:
  4117. mingw: follow-up to "replace isatty() hack"
  4118.  
  4119. Merge branch 'js/sequencer-i-countdown-3'
  4120.  
  4121. The sequencer machinery has been further enhanced so that a later
  4122. set of patches can start using it to reimplement "rebase -i".
  4123.  
  4124. * js/sequencer-i-countdown-3: (38 commits)
  4125. sequencer (rebase -i): write out the final message
  4126. sequencer (rebase -i): write the progress into files
  4127. sequencer (rebase -i): show the progress
  4128. sequencer (rebase -i): suggest --edit-todo upon unknown command
  4129. sequencer (rebase -i): show only failed cherry-picks' output
  4130. sequencer (rebase -i): show only failed `git commit`'s output
  4131. sequencer: use run_command() directly
  4132. sequencer: update reading author-script
  4133. sequencer (rebase -i): differentiate between comments and 'noop'
  4134. sequencer (rebase -i): implement the 'drop' command
  4135. sequencer (rebase -i): allow rescheduling commands
  4136. sequencer (rebase -i): respect strategy/strategy_opts settings
  4137. sequencer (rebase -i): respect the rebase.autostash setting
  4138. sequencer (rebase -i): run the post-rewrite hook, if needed
  4139. sequencer (rebase -i): record interrupted commits in rewritten, too
  4140. sequencer (rebase -i): copy commit notes at end
  4141. sequencer (rebase -i): set the reflog message consistently
  4142. sequencer (rebase -i): refactor setting the reflog message
  4143. sequencer (rebase -i): allow fast-forwarding for edit/reword
  4144. sequencer (rebase -i): implement the 'reword' command
  4145. ...
  4146.  
  4147. Merge branch 'jk/coding-guidelines-update'
  4148.  
  4149. Developer doc update.
  4150.  
  4151. * jk/coding-guidelines-update:
  4152. CodingGuidelines: clarify multi-line brace style
  4153.  
  4154. Merge branch 'jk/loose-object-fsck'
  4155.  
  4156. "git fsck" inspects loose objects more carefully now.
  4157.  
  4158. * jk/loose-object-fsck:
  4159. fsck: detect trailing garbage in all object types
  4160. fsck: parse loose object paths directly
  4161. sha1_file: add read_loose_object() function
  4162. t1450: test fsck of packed objects
  4163. sha1_file: fix error message for alternate objects
  4164. t1450: refactor loose-object removal
  4165.  
  4166. Merge branch 'js/exec-path-coverity-workaround'
  4167.  
  4168. Code cleanup.
  4169.  
  4170. * js/exec-path-coverity-workaround:
  4171. git_exec_path: do not return the result of getenv()
  4172. git_exec_path: avoid Coverity warning about unfree()d result
  4173.  
  4174. Merge branch 'bw/push-submodule-only'
  4175.  
  4176. "git submodule push" learned "--recurse-submodules=only option to
  4177. push submodules out without pushing the top-level superproject.
  4178.  
  4179. * bw/push-submodule-only:
  4180. push: add option to push only submodules
  4181. submodules: add RECURSE_SUBMODULES_ONLY value
  4182. transport: reformat flag #defines to be more readable
  4183.  
  4184. Merge branch 'jk/vreport-sanitize'
  4185.  
  4186. An error message with an ASCII control character like '\r' in it
  4187. can alter the message to hide its early part, which is problematic
  4188. when a remote side gives such an error message that the local side
  4189. will relay with a "remote: " prefix.
  4190.  
  4191. * jk/vreport-sanitize:
  4192. vreport: sanitize ASCII control chars
  4193. Revert "vreportf: avoid intermediate buffer"
  4194.  
  4195. branch: implement '--format' option
  4196.  
  4197. Implement the '--format' option provided by 'ref-filter'. This lets the
  4198. user list branches as per desired format similar to the implementation
  4199. in 'git for-each-ref'.
  4200.  
  4201. Add tests and documentation for the same.
  4202.  
  4203. Mentored-by: Christian Couder <christian.couder@gmail.com>
  4204. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  4205. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  4206. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4207.  
  4208. branch: use ref-filter printing APIs
  4209.  
  4210. Port branch.c to use ref-filter APIs for printing. This clears out
  4211. most of the code used in branch.c for printing and replaces them with
  4212. calls made to the ref-filter library.
  4213.  
  4214. Introduce build_format() which gets the format required for printing
  4215. of refs. Make amendments to print_ref_list() to reflect these changes.
  4216.  
  4217. The strings included in build_format() may not be safely quoted for
  4218. inclusion (i.e. it might contain '%' which needs to be escaped with an
  4219. additional '%'). Introduce quote_literal_for_format() as a helper
  4220. function which takes a string and returns a version of the string that
  4221. is safely quoted to be used in the for-each-ref format which is built
  4222. in build_format().
  4223.  
  4224. Change calc_maxwidth() to also account for the length of HEAD ref, by
  4225. calling ref-filter:get_head_discription().
  4226.  
  4227. Also change the test in t6040 to reflect the changes.
  4228.  
  4229. Before this patch, all cross-prefix symrefs weren't shortened. Since
  4230. we're using ref-filter APIs, we shorten all symrefs by default. We also
  4231. allow the user to change the format if needed with the introduction of
  4232. the '--format' option in the next patch.
  4233.  
  4234. Mentored-by: Christian Couder <christian.couder@gmail.com>
  4235. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  4236. Helped-by: Junio C Hamano <gitster@pobox.com>
  4237. Helped-by: Jeff King <peff@peff.net>
  4238. Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
  4239. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  4240. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4241.  
  4242. branch, tag: use porcelain output
  4243.  
  4244. Call ref-filter's setup_ref_filter_porcelain_msg() to enable
  4245. translated messages for the %(upstream:tack) atom. Although branch.c
  4246. doesn't currently use ref-filter's printing API's, this will ensure
  4247. that when it does in the future patches, we do not need to worry about
  4248. translation.
  4249.  
  4250. Written-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  4251. Mentored-by: Christian Couder <christian.couder@gmail.com>
  4252. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  4253. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  4254. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4255.  
  4256. ref-filter: allow porcelain to translate messages in the output
  4257.  
  4258. Introduce setup_ref_filter_porcelain_msg() so that the messages used in
  4259. the atom %(upstream:track) can be translated if needed. By default, keep
  4260. the messages untranslated, which is the right behavior for plumbing
  4261. commands. This is needed as we port branch.c to use ref-filter's
  4262. printing API's.
  4263.  
  4264. Written-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  4265. Mentored-by: Christian Couder <christian.couder@gmail.com>
  4266. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  4267. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  4268. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4269.  
  4270. ref-filter: add an 'rstrip=<N>' option to atoms which deal with refnames
  4271.  
  4272. Complimenting the existing 'lstrip=<N>' option, add an 'rstrip=<N>'
  4273. option which strips `<N>` slash-separated path components from the end
  4274. of the refname (e.g., `%(refname:rstrip=2)` turns `refs/tags/foo` into
  4275. `refs`).
  4276.  
  4277. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  4278. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4279.  
  4280. ref-filter: modify the 'lstrip=<N>' option to work with negative '<N>'
  4281.  
  4282. Currently the 'lstrip=<N>' option only takes a positive value '<N>'
  4283. and strips '<N>' slash-separated path components from the left. Modify
  4284. the 'lstrip' option to also take a negative number '<N>' which would
  4285. strip from the left as necessary and _leave_ behind only 'N'
  4286. slash-separated path components from the right-most end.
  4287.  
  4288. For e.g. %(refname:lstrip=-1) would make 'foo/goo/abc' into 'abc'.
  4289.  
  4290. Add documentation and tests for the same.
  4291.  
  4292. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  4293. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4294.  
  4295. Documentation: implement linkgit macro for Asciidoctor
  4296.  
  4297. AsciiDoc uses a configuration file to implement macros like linkgit,
  4298. while Asciidoctor uses Ruby extensions. Implement a Ruby extension that
  4299. implements the linkgit macro for Asciidoctor in the same way that
  4300. asciidoc.conf does for AsciiDoc. Adjust the Makefile to use it by
  4301. default.
  4302.  
  4303. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  4304. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4305.  
  4306. builtin/commit.c: switch to strbuf, instead of snprintf()
  4307.  
  4308. Switch to dynamic allocation with strbuf, so we can avoid dealing
  4309. with magic numbers in the code and reduce the cognitive burden from
  4310. the programmers. The original code is correct, but programmers no
  4311. longer have to count bytes needed for static allocation to know that.
  4312.  
  4313. As a side effect of this change, we also reduce the snprintf()
  4314. calls, that may silently truncate results if the programmer is not
  4315. careful.
  4316.  
  4317. Helped-by: René Scharfe <l.s.r@web.de>
  4318. Helped-by: Junio C Hamano <gitster@pobox.com>
  4319. Helped-by: Jeff King <peff@peff.net>
  4320. Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
  4321. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4322.  
  4323. urlmatch: split host and port fields in `struct url_info`
  4324.  
  4325. The `url_info` structure contains information about a normalized URL
  4326. with the URL's components being represented by different fields. The
  4327. host and port part though are to be accessed by the same `host` field,
  4328. so that getting the host and/or port separately becomes more involved
  4329. than really necessary.
  4330.  
  4331. To make the port more readily accessible, split up the host and port
  4332. fields. Namely, the `host_len` will not include the port length anymore
  4333. and a new `port_off` field has been added which includes the offset to
  4334. the port, if available.
  4335.  
  4336. The only user of these fields is `url_normalize_1`. This change makes it
  4337. easier later on to treat host and port differently when introducing
  4338. globs for domains.
  4339.  
  4340. Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
  4341. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4342.  
  4343. urlmatch: enable normalization of URLs with globs
  4344.  
  4345. The `url_normalize` function is used to validate and normalize URLs. As
  4346. such, it does not allow for some special characters to be part of the
  4347. URLs that are to be normalized. As we want to allow using globs in some
  4348. configuration keys making use of URLs, namely `http.<url>.<key>`, but
  4349. still normalize them, we need to somehow enable some additional allowed
  4350. characters.
  4351.  
  4352. To do this without having to change all callers of `url_normalize`,
  4353. where most do not actually want globbing at all, we split off another
  4354. function `url_normalize_1`. This function accepts an additional
  4355. parameter `allow_globs`, which is subsequently called by `url_normalize`
  4356. with `allow_globs=0`.
  4357.  
  4358. As of now, this function is not used with globbing enabled. A caller
  4359. will be added in the following commit.
  4360.  
  4361. Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
  4362. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4363.  
  4364. mailmap: add Patrick Steinhardt's work address
  4365.  
  4366. Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
  4367. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4368.  
  4369. update-ref: add test cases for bare repository
  4370.  
  4371. The default behavior of update-ref to create reflogs differs in
  4372. repositories with worktree and bare ones. The existing tests cover only
  4373. the behavior of repositories with worktree.
  4374.  
  4375. This commit adds tests that assert the correct behavior in bare
  4376. repositories for update-ref. Two cases are covered:
  4377.  
  4378. - If core.logAllRefUpdates is not set, no reflogs should be created
  4379. - If core.logAllRefUpdates is true, reflogs should be created
  4380.  
  4381. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  4382. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4383.  
  4384. refs: add option core.logAllRefUpdates = always
  4385.  
  4386. When core.logallrefupdates is true, we only create a new reflog for refs
  4387. that are under certain well-known hierarchies. The reason is that we
  4388. know that some hierarchies (like refs/tags) are not meant to change, and
  4389. that unknown hierarchies might not want reflogs at all (e.g., a
  4390. hypothetical refs/foo might be meant to change often and drop old
  4391. history immediately).
  4392.  
  4393. However, sometimes it is useful to override this decision and simply log
  4394. for all refs, because the safety and audit trail is more important than
  4395. the performance implications of keeping the log around.
  4396.  
  4397. This patch introduces a new "always" mode for the core.logallrefupdates
  4398. option which will log updates to everything under refs/, regardless
  4399. where in the hierarchy it is (we still will not log things like
  4400. ORIG_HEAD and FETCH_HEAD, which are known to be transient).
  4401.  
  4402. Based-on-patch-by: Jeff King <peff@peff.net>
  4403. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  4404. Reviewed-by: Jeff King <peff@peff.net>
  4405. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4406.  
  4407. l10n: bg: Updated Bulgarian translation (2913t+0f+0u)
  4408.  
  4409. Signed-off-by: Alexander Shopov <ash@kambanaria.org>
  4410.  
  4411. receive-pack: call string_list_clear() unconditionally
  4412.  
  4413. string_list_clear() handles empty lists just fine, so remove the
  4414. redundant check.
  4415.  
  4416. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4417. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4418.  
  4419. Completion: Add support for --submodule=diff
  4420.  
  4421. Teach git-completion.bash about the 'diff' option to 'git diff
  4422. --submodule=', which was added in Git 2.11.
  4423.  
  4424. Signed-off-by: Peter Law <PeterJCLaw@gmail.com>
  4425. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4426.  
  4427. checkout: convert post_checkout_hook() to struct object_id
  4428.  
  4429. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4430. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4431.  
  4432. use oidcpy() for copying hashes between instances of struct object_id
  4433.  
  4434. Patch generated by Coccinelle and contrib/coccinelle/object_id.cocci.
  4435.  
  4436. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4437. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4438.  
  4439. use oid_to_hex_r() for converting struct object_id hashes to hex strings
  4440.  
  4441. Patch generated by Coccinelle and contrib/coccinelle/object_id.cocci.
  4442.  
  4443. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4444. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4445.  
  4446. graph: use SWAP macro
  4447.  
  4448. Exchange the values of graph->columns and graph->new_columns using the
  4449. macro SWAP instead of hand-rolled code. The result is shorter and
  4450. easier to read.
  4451.  
  4452. This transformation was not done by the semantic patch swap.cocci
  4453. because there's an unrelated statement between the second and the last
  4454. step of the exchange, so it didn't match the expected pattern.
  4455.  
  4456. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4457. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4458.  
  4459. diff: use SWAP macro
  4460.  
  4461. Use the macro SWAP to exchange the value of pairs of variables instead
  4462. of swapping them manually with the help of a temporary variable. The
  4463. resulting code is shorter and easier to read.
  4464.  
  4465. The two cases were not transformed by the semantic patch swap.cocci
  4466. because it's extra careful and handles only cases where the types of all
  4467. variables are the same -- and here we swap two ints and use an unsigned
  4468. temporary variable for that. Nevertheless the conversion is safe, as
  4469. the value range is preserved with and without the patch.
  4470.  
  4471. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4472. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4473.  
  4474. use SWAP macro
  4475.  
  4476. Apply the semantic patch swap.cocci to convert hand-rolled swaps to use
  4477. the macro SWAP. The resulting code is shorter and easier to read, the
  4478. object code is effectively unchanged.
  4479.  
  4480. The patch for object.c had to be hand-edited in order to preserve the
  4481. comment before the change; Coccinelle tried to eat it for some reason.
  4482.  
  4483. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4484. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4485.  
  4486. apply: use SWAP macro
  4487.  
  4488. Use the exported macro SWAP instead of the file-scoped macro swap and
  4489. remove the latter's definition.
  4490.  
  4491. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4492. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4493.  
  4494. add SWAP macro
  4495.  
  4496. Add a macro for exchanging the values of variables. It allows users
  4497. to avoid repetition and takes care of the temporary variable for them.
  4498. It also makes sure that the storage sizes of its two parameters are the
  4499. same. Its memcpy(1) calls are optimized away by current compilers.
  4500.  
  4501. Also add a conservative semantic patch for transforming only swaps of
  4502. variables of the same type.
  4503.  
  4504. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4505. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4506.  
  4507. merge-recursive: make "CONFLICT (rename/delete)" message show both paths
  4508.  
  4509. The current message printed by "git merge-recursive" for a rename/delete
  4510. conflict is like this:
  4511.  
  4512. CONFLICT (rename/delete): new-path deleted in HEAD and renamed in
  4513. other-branch. Version other-branch of new-path left in tree.
  4514.  
  4515. To be more helpful, the message should show both paths of the rename and
  4516. state that the deletion occurred at the old path, not the new path. So
  4517. change the message to the following format:
  4518.  
  4519. CONFLICT (rename/delete): old-path deleted in HEAD and renamed to
  4520. new-path in other-branch. Version other-branch of new-path left in tree.
  4521.  
  4522. Since this doubles the number of cases in handle_change_delete (modify vs.
  4523. rename), refactor the code to halve the number of cases again by merging the
  4524. cases where o->branch1 has the change and o->branch2 has the delete with the
  4525. cases that are the other way around.
  4526.  
  4527. Also add a simple test of the new conflict message.
  4528.  
  4529. Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
  4530. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4531.  
  4532. t0001: don't let a default ACL interfere with the umask test
  4533.  
  4534. The "init creates a new deep directory (umask vs. shared)" test expects
  4535. the permissions of newly created files to be based on the umask, which
  4536. fails if a default ACL is inherited from the working tree for git. So
  4537. attempt to remove a default ACL if there is one. Same idea as
  4538. 8ed0a740dd42bd0724aebed6e3b07c4ea2a2d5e8. (I guess I'm the only one who
  4539. ever runs the test suite with a default ACL set.)
  4540.  
  4541. Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
  4542. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4543.  
  4544. config: add markup to core.logAllRefUpdates doc
  4545.  
  4546. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  4547. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4548.  
  4549. git-p4: fix git-p4.mapUser on Windows
  4550.  
  4551. When running git-p4 on Windows, with multiple git-p4.mapUser entries in
  4552. git config - no user mappings are applied to the generated repository.
  4553.  
  4554. Reproduction Steps:
  4555.  
  4556. 1. Add multiple git-p4.mapUser entries to git config on a Windows
  4557. machine
  4558. 2. Attempt to clone a p4 repository
  4559.  
  4560. None of the user mappings will be applied.
  4561.  
  4562. This issue is actually caused by gitConfigList, using split(os.linesep)
  4563. to convert the output of git config --get-all into a list. On Windows,
  4564. os.linesep is equal to '\r\n' - however git.exe returns configuration
  4565. with a line seperator of '\n'.
  4566.  
  4567. This leads to the list returned by gitConfigList containing only one
  4568. element - which contains the full output of git config --get-all in
  4569. string form, which causes problems for the code introduced to
  4570. getUserMapFromPerforceServer in 10d08a149d ("git-p4: map a P4 user to
  4571. Git author name and email address", 2016-03-01)
  4572.  
  4573. This issue should be caught by the test introduced in 10d08a1, however
  4574. would require running on Windows to reproduce.
  4575.  
  4576. Using splitlines solves this issue, by splitting config on all
  4577. typical delimiters ('\n', '\r\n' etc.)
  4578.  
  4579. Signed-off-by: George Vanburgh <gvanburgh@bloomberg.net>
  4580. Reviewed-by: Luke Diamand <luke@diamand.org>
  4581. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4582.  
  4583. help: improve is_executable() on Windows
  4584.  
  4585. On Windows, executables need to have the file extension `.exe`, or they
  4586. are not executables. Hence, to support scripts, Git for Windows also
  4587. looks for a she-bang line by opening the file in question, and executing
  4588. it via the specified script interpreter.
  4589.  
  4590. To figure out whether files in the `PATH` are executable, `git help` has
  4591. code that imitates this behavior. With one exception: it *always* opens
  4592. the files and looks for a she-bang line *or* an `MZ` tell-tale
  4593. (nevermind that files with the magic `MZ` but without file extension
  4594. `.exe` would still not be executable).
  4595.  
  4596. Opening this many files leads to performance problems that are even more
  4597. serious when a virus scanner is running. Therefore, let's change the
  4598. code to look for the file extension `.exe` early, and avoid opening the
  4599. file altogether if we already know that it is executable.
  4600.  
  4601. See the following measurements (in seconds) as an example, where we
  4602. execute a simple program that simply lists the directory contents and
  4603. calls open() on every listed file:
  4604.  
  4605. With virus scanner running (coldcache):
  4606.  
  4607. $ ./a.exe /libexec/git-core/
  4608. before open (git-add.exe): 0.000000
  4609. after open (git-add.exe): 0.412873
  4610. before open (git-annotate.exe): 0.000175
  4611. after open (git-annotate.exe): 0.397925
  4612. before open (git-apply.exe): 0.000243
  4613. after open (git-apply.exe): 0.399996
  4614. before open (git-archive.exe): 0.000147
  4615. after open (git-archive.exe): 0.397783
  4616. before open (git-bisect--helper.exe): 0.000160
  4617. after open (git-bisect--helper.exe): 0.397700
  4618. before open (git-blame.exe): 0.000160
  4619. after open (git-blame.exe): 0.399136
  4620. ...
  4621.  
  4622. With virus scanner running (hotcache):
  4623.  
  4624. $ ./a.exe /libexec/git-core/
  4625. before open (git-add.exe): 0.000000
  4626. after open (git-add.exe): 0.000325
  4627. before open (git-annotate.exe): 0.000229
  4628. after open (git-annotate.exe): 0.000177
  4629. before open (git-apply.exe): 0.000167
  4630. after open (git-apply.exe): 0.000150
  4631. before open (git-archive.exe): 0.000154
  4632. after open (git-archive.exe): 0.000156
  4633. before open (git-bisect--helper.exe): 0.000132
  4634. after open (git-bisect--helper.exe): 0.000180
  4635. before open (git-blame.exe): 0.000718
  4636. after open (git-blame.exe): 0.000724
  4637. ...
  4638.  
  4639. With this patch I get:
  4640.  
  4641. $ time git help git
  4642. Launching default browser to display HTML ...
  4643.  
  4644. real 0m8.723s
  4645. user 0m0.000s
  4646. sys 0m0.000s
  4647.  
  4648. and without
  4649.  
  4650. $ time git help git
  4651. Launching default browser to display HTML ...
  4652.  
  4653. real 1m37.734s
  4654. user 0m0.000s
  4655. sys 0m0.031s
  4656.  
  4657. both tests with cold cache and giving the machine some time to settle
  4658. down after restart.
  4659.  
  4660. [jes: adjusted the commit message]
  4661.  
  4662. Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de>
  4663. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  4664. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4665.  
  4666. mingw: allow hooks to be .exe files
  4667.  
  4668. Executable files in Windows need to have the extension '.exe', otherwise
  4669. they do not work. Extend the hooks to not just look at the hard coded
  4670. names, but also at the names extended by the custom STRIP_EXTENSION,
  4671. which is defined as '.exe' in Windows.
  4672.  
  4673. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  4674. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4675.  
  4676. pack-objects: convert recursion to iteration in break_delta_chain()
  4677.  
  4678. The break_delta_chain() function is recursive over the depth
  4679. of a given delta chain, which can lead to possibly running
  4680. out of stack space. Normally delta depth is quite small, but
  4681. if there _is_ a pathological case, this is where we would
  4682. find and fix it, so we should be more careful.
  4683.  
  4684. We can do it without recursion at all, but there's a little
  4685. bit of cleverness needed to do so. It's easiest to explain
  4686. by covering the less-clever strategies first.
  4687.  
  4688. The obvious thing to try is just keeping our own stack on
  4689. the heap. Whenever we would recurse, push the new entry onto
  4690. the stack and loop instead. But this gets tricky; when we
  4691. see an ACTIVE entry, we need to care if we just pushed it
  4692. (in which case it's a cycle) or if we just popped it (in
  4693. which case we dealt with its bases, and no we need to clear
  4694. the ACTIVE flag and compute its depth).
  4695.  
  4696. You can hack around that in various ways, like keeping a
  4697. "just pushed" flag, but the logic gets muddled. However, we
  4698. can observe that we do all of our pushes first, and then all
  4699. of our pops afterwards. In other words, we can do this in
  4700. two passes. First dig down to the base, stopping when we see
  4701. a cycle, and pushing each item onto our stack. Then pop the
  4702. stack elements, clearing the ACTIVE flag and computing the
  4703. depth for each.
  4704.  
  4705. This works, and is reasonably elegant. However, why do we
  4706. need the stack for the second pass? We can just walk the
  4707. delta pointers again. There's one complication. Popping the
  4708. stack went over our list in reverse, so we could compute the
  4709. depth of each entry by incrementing the depth of its base,
  4710. which we will have just computed. To go forward in the
  4711. second pass, we have to compute the total depth on the way
  4712. down, and then assign it as we go.
  4713.  
  4714. This patch implements this final strategy, because it not
  4715. only keeps the memory off the stack, but it eliminates it
  4716. entirely. Credit for the cleverness in that approach goes to
  4717. Michael Haggerty; bugs are mine.
  4718.  
  4719. Signed-off-by: Jeff King <peff@peff.net>
  4720. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4721.  
  4722. pack-objects: enforce --depth limit in reused deltas
  4723.  
  4724. Since 898b14c (pack-objects: rework check_delta_limit usage,
  4725. 2007-04-16), we check the delta depth limit only when
  4726. figuring out whether we should make a new delta. We don't
  4727. consider it at all when reusing deltas, which means that
  4728. packing once with --depth=250, and then again with
  4729. --depth=50, the second pack may still contain chains larger
  4730. than 50.
  4731.  
  4732. This is generally considered a feature, as the results of
  4733. earlier high-depth repacks are carried forward, used for
  4734. serving fetches, etc. However, since we started using
  4735. cross-pack deltas in c9af708b1 (pack-objects: use mru list
  4736. when iterating over packs, 2016-08-11), we are no longer
  4737. bounded by the length of an existing delta chain in a single
  4738. pack.
  4739.  
  4740. Here's one particular pathological case: a sequence of N
  4741. packs, each with 2 objects, the base of which is stored as a
  4742. delta in a previous pack. If we chain all the deltas
  4743. together, we have a cycle of length N. We break the cycle,
  4744. but the tip delta is still at depth N-1.
  4745.  
  4746. This is less unlikely than it might sound. See the included
  4747. test for a reconstruction based on real-world actions. I
  4748. ran into such a case in the wild, where a client was rapidly
  4749. sending packs, and we had accumulated 10,000 before doing a
  4750. server-side repack. The pack that "git repack" tried to
  4751. generate had a very deep chain, which caused pack-objects to
  4752. run out of stack space in the recursive write_one().
  4753.  
  4754. This patch bounds the length of delta chains in the output
  4755. pack based on --depth, regardless of whether they are caused
  4756. by cross-pack deltas or existed in the input packs. This
  4757. fixes the problem, but does have two possible downsides:
  4758.  
  4759. 1. High-depth aggressive repacks followed by "normal"
  4760. repacks will throw away the high-depth chains.
  4761.  
  4762. In the long run this is probably OK; investigation
  4763. showed that high-depth repacks aren't actually
  4764. beneficial, and we dropped the aggressive depth default
  4765. to match the normal case in 07e7dbf0d (gc: default
  4766. aggressive depth to 50, 2016-08-11).
  4767.  
  4768. 2. If you really do want to store high-depth deltas on
  4769. disk, they may be discarded and new delta computed when
  4770. serving a fetch, unless you set pack.depth to match
  4771. your high-depth size.
  4772.  
  4773. The implementation uses the existing search for delta
  4774. cycles. That lets us compute the depth of any node based on
  4775. the depth of its base, because we know the base is DFS_DONE
  4776. by the time we look at it (modulo any cycles in the graph,
  4777. but we know there cannot be any because we break them as we
  4778. see them).
  4779.  
  4780. There is some subtlety worth mentioning, though. We record
  4781. the depth of each object as we compute it. It might seem
  4782. like we could save the per-object storage space by just
  4783. keeping track of the depth of our traversal (i.e., have
  4784. break_delta_chains() report how deep it went). But we may
  4785. visit an object through multiple delta paths, and on
  4786. subsequent paths we want to know its depth immediately,
  4787. without having to walk back down to its final base (doing so
  4788. would make our graph walk quadratic rather than linear).
  4789.  
  4790. Likewise, one could try to record the depth not from the
  4791. base, but from our starting point (i.e., start
  4792. recursion_depth at 0, and pass "recursion_depth + 1" to each
  4793. invocation of break_delta_chains()). And then when
  4794. recursion_depth gets too big, we know that we must cut the
  4795. delta chain. But that technique is wrong if we do not visit
  4796. the nodes in topological order. In a chain A->B->C, it
  4797. if we visit "C", then "B", then "A", we will never recurse
  4798. deeper than 1 link (because we see at each node that we have
  4799. already visited it).
  4800.  
  4801. Signed-off-by: Jeff King <peff@peff.net>
  4802. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4803.  
  4804. doc: clarify distinction between sign-off and pgp-signing
  4805.  
  4806. The documentation for submission discourages pgp-signing, but demands
  4807. a proper sign-off by contributors. However, when skimming the headings,
  4808. the wording of the section for sign-off could mistakenly be understood
  4809. as concerning pgp-signing. Thus, new contributors could oversee the
  4810. necessary sign-off.
  4811.  
  4812. This commit improves the wording such that the section about sign-off
  4813. cannot be misunderstood as pgp-signing. In addition, the paragraph about
  4814. pgp-signing is changed such that it avoids the impression that
  4815. pgp-signing could be relevant at later stages of the submission.
  4816.  
  4817. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
  4818. Helped-by: Philip Oakley <philipoakley@iee.org>
  4819. Helped-by: Stefan Beller <sbeller@google.com>
  4820. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4821.  
  4822. test-lib: on FreeBSD, look for unzip(1) in /usr/local/bin/
  4823.  
  4824. Eric Wong reported that while FreeBSD has a /usr/bin/unzip, it uses
  4825. different semantics from those that are needed by Git's tests: When
  4826. passing the -a option to Info-Zip, it heeds the text attribute of the
  4827. .zip file's central directory, while FreeBSD's unzip ignores that
  4828. attribute.
  4829.  
  4830. The common work-around is to install Info-Zip on FreeBSD, into
  4831. /usr/local/bin/.
  4832.  
  4833. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  4834. Tested-by: Eric Wong <e@80x24.org>
  4835. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4836.  
  4837. t/Makefile: add a rule to re-run previously-failed tests
  4838.  
  4839. This patch automates the process of determining which tests failed
  4840. previously and re-running them.
  4841.  
  4842. While developing patch series, it is a good practice to run the test
  4843. suite from time to time, just to make sure that obvious bugs are caught
  4844. early. With complex patch series, it is common to run `make -j15 -k
  4845. test`, i.e. run the tests in parallel and *not* stop at the first
  4846. failing test but continue. This has the advantage of identifying
  4847. possibly multiple problems in one big test run.
  4848.  
  4849. It is particularly important to reduce the turn-around time thusly on
  4850. Windows, where the test suite spends 45 minutes on the computer on which
  4851. this patch was developed.
  4852.  
  4853. It is the most convenient way to determine which tests failed after
  4854. running the entire test suite, in parallel, to look for left-over "trash
  4855. directory.t*" subdirectories in the t/ subdirectory. However, those
  4856. directories might live outside t/ when overridden using the
  4857. --root=<directory> option, to which the Makefile has no access. The next
  4858. best method is to grep explicitly for failed tests in the test-results/
  4859. directory, which the Makefile *can* access.
  4860.  
  4861. Please note that the often-recommended `prove` tool requires Perl, and
  4862. that opens a whole new can of worms on Windows. As no native Windows Perl
  4863. comes with Subversion bindings, we have to use a Perl in Git for Windows
  4864. that uses the POSIX emulation layer named MSYS2 (which is a portable
  4865. version of Cygwin). When using this emulation layer under stress, e.g.
  4866. when running massively-parallel tests, unexplicable crashes occur quite
  4867. frequently, and instead of having a solution to the original problem, the
  4868. developer now has an additional, quite huge problem. For that reason, this
  4869. developer rejected `prove` as a solution and went with this patch instead.
  4870.  
  4871. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  4872. Reviewed-by: Jeff King <peff@peff.net>
  4873. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4874.  
  4875. use absolute_pathdup()
  4876.  
  4877. Apply the semantic patch for converting callers that duplicate the
  4878. result of absolute_path() to call absolute_pathdup() instead, which
  4879. avoids an extra string copy to a static buffer.
  4880.  
  4881. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4882. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4883.  
  4884. abspath: add absolute_pathdup()
  4885.  
  4886. Add a function that returns a buffer containing the absolute path of its
  4887. argument and a semantic patch for its intended use. It avoids an extra
  4888. string copy to a static buffer.
  4889.  
  4890. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  4891. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4892.  
  4893. status: be prepared for not-yet-started interactive rebase
  4894.  
  4895. Some developers might want to call `git status` in a working
  4896. directory where they just started an interactive rebase, but the
  4897. edit script is still opened in the editor.
  4898.  
  4899. Let's show a meaningful message in such cases.
  4900.  
  4901. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  4902. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4903.  
  4904. connect: rename tortoiseplink and putty variables
  4905.  
  4906. One of these two may have originally been named after "what exact
  4907. SSH implementation do we have?" so that we can tweak the command
  4908. line options for that exact implementation. But "putty=1" no longer
  4909. means "We are using the plink SSH implementation that comes with
  4910. PuTTY" these days. It is set when we guess that either PuTTY plink
  4911. or Tortoiseplink is in use.
  4912.  
  4913. Rename them after what effect is desired. The current 'putty'
  4914. option is about using "-P <port>" when OpenSSH would use "-p <port>",
  4915. so rename it to 'port_option' whose value is either 'p' or 'P". The
  4916. other one is about passing an extra command line option "-batch",
  4917. so rename it to 'needs_batch'.
  4918.  
  4919. [jes: wrapped overly-long line]
  4920.  
  4921. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4922. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  4923. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4924.  
  4925. submodule update: run custom update script for initial populating as well
  4926.  
  4927. In 1b4735d9f3 (submodule: no [--merge|--rebase] when newly cloned,
  4928. 2011-02-17), all actions were defaulted to checkout for populating
  4929. a submodule initially, because merging or rebasing makes no sense
  4930. in that situation.
  4931.  
  4932. Other commands however do make sense, such as the custom command
  4933. that was added later (6cb5728c43, submodule update: allow custom
  4934. command to update submodule working tree, 2013-07-03).
  4935.  
  4936. I am unsure about the "none" command, as I can see an initial
  4937. checkout there as a useful thing. On the other hand going strictly
  4938. by our own documentation, we should do nothing in case of "none"
  4939. as well, because the user asked for it.
  4940.  
  4941. Reported-by: Han-Wen Nienhuys <hanwen@google.com>
  4942. Signed-off-by: Stefan Beller <sbeller@google.com>
  4943. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4944.  
  4945. submodule absorbing: fix worktree/gitdir pointers recursively for non-moves
  4946.  
  4947. Consider having a submodule 'sub' and a nested submodule at 'sub/nested'.
  4948. When nested is already absorbed into sub, but sub is not absorbed into
  4949. its superproject, then we need to fixup the gitfile and core.worktree
  4950. setting for 'nested' when absorbing 'sub', but we do not need to move
  4951. its git dir around.
  4952.  
  4953. Previously 'nested's gitfile contained "gitdir: ../.git/modules/nested";
  4954. it has to be corrected to "gitdir: ../../.git/modules/sub1/modules/nested".
  4955.  
  4956. An alternative I considered to do this work lazily, i.e. when resolving
  4957. "../.git/modules/nested", we would notice the ".git" being a gitfile
  4958. linking to another path. That seemed to be robuster by design, but harder
  4959. to get the implementation right. Maybe we have to do that anyway once we
  4960. try to have submodules and worktrees working nicely together, but for now
  4961. just produce 'correct' (i.e. direct) pointers.
  4962.  
  4963. Signed-off-by: Stefan Beller <sbeller@google.com>
  4964. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4965.  
  4966. cache.h: expose the dying procedure for reading gitlinks
  4967.  
  4968. In a later patch we want to react to only a subset of errors, defaulting
  4969. the rest to die as usual. Separate the block that takes care of dying
  4970. into its own function so we have easy access to it.
  4971.  
  4972. Signed-off-by: Stefan Beller <sbeller@google.com>
  4973. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4974.  
  4975. setup: add gentle version of resolve_git_dir
  4976.  
  4977. This follows a93bedada (setup: add gentle version of read_gitfile,
  4978. 2015-06-09), and assumes the same reasoning. resolve_git_dir is unsuited
  4979. for speculative calls, so we want to use the gentle version to find out
  4980. about potential errors.
  4981.  
  4982. Signed-off-by: Stefan Beller <sbeller@google.com>
  4983. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4984.  
  4985. fsck: lazily load types under --connectivity-only
  4986.  
  4987. The recent fixes to "fsck --connectivity-only" load all of
  4988. the objects with their correct types. This keeps the
  4989. connectivity-only code path close to the regular one, but it
  4990. also introduces some unnecessary inefficiency. While getting
  4991. the type of an object is cheap compared to actually opening
  4992. and parsing the object (as the non-connectivity-only case
  4993. would do), it's still not free.
  4994.  
  4995. For reachable non-blob objects, we end up having to parse
  4996. them later anyway (to see what they point to), making our
  4997. type lookup here redundant.
  4998.  
  4999. For unreachable objects, we might never hit them at all in
  5000. the reachability traversal, making the lookup completely
  5001. wasted. And in some cases, we might have quite a few
  5002. unreachable objects (e.g., when alternates are used for
  5003. shared object storage between repositories, it's normal for
  5004. there to be objects reachable from other repositories but
  5005. not the one running fsck).
  5006.  
  5007. The comment in mark_object_for_connectivity() claims two
  5008. benefits to getting the type up front:
  5009.  
  5010. 1. We need to know the types during fsck_walk(). (And not
  5011. explicitly mentioned, but we also need them when
  5012. printing the types of broken or dangling commits).
  5013.  
  5014. We can address this by lazy-loading the types as
  5015. necessary. Most objects never need this lazy-load at
  5016. all, because they fall into one of these categories:
  5017.  
  5018. a. Reachable from our tips, and are coerced into the
  5019. correct type as we traverse (e.g., a parent link
  5020. will call lookup_commit(), which converts OBJ_NONE
  5021. to OBJ_COMMIT).
  5022.  
  5023. b. Unreachable, but not at the tip of a chunk of
  5024. unreachable history. We only mention the tips as
  5025. "dangling", so an unreachable commit which links
  5026. to hundreds of other objects needs only report the
  5027. type of the tip commit.
  5028.  
  5029. 2. It serves as a cross-check that the coercion in (1a) is
  5030. correct (i.e., we'll complain about a parent link that
  5031. points to a blob). But we get most of this for free
  5032. already, because right after coercing, we'll parse any
  5033. non-blob objects. So we'd notice then if we expected a
  5034. commit and got a blob.
  5035.  
  5036. The one exception is when we expect a blob, in which
  5037. case we never actually read the object contents.
  5038.  
  5039. So this is a slight weakening, but given that the whole
  5040. point of --connectivity-only is to sacrifice some data
  5041. integrity checks for speed, this seems like an
  5042. acceptable tradeoff.
  5043.  
  5044. Here are before and after timings for an extreme case with
  5045. ~5M reachable objects and another ~12M unreachable (it's the
  5046. torvalds/linux repository on GitHub, connected to shared
  5047. storage for all of the other kernel forks):
  5048.  
  5049. [before]
  5050. $ time git fsck --no-dangling --connectivity-only
  5051. real 3m4.323s
  5052. user 1m25.121s
  5053. sys 1m38.710s
  5054.  
  5055. [after]
  5056. $ time git fsck --no-dangling --connectivity-only
  5057. real 0m51.497s
  5058. user 0m49.575s
  5059. sys 0m1.776s
  5060.  
  5061. Signed-off-by: Jeff King <peff@peff.net>
  5062. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5063.  
  5064. fsck: move typename() printing to its own function
  5065.  
  5066. When an object has a problem, we mention its type. But we do
  5067. so by feeding the result of typename() directly to
  5068. fprintf(). This is potentially dangerous because typename()
  5069. can return NULL for some type values (like OBJ_NONE).
  5070.  
  5071. It's doubtful that this can be triggered in practice with
  5072. the current code, so this is probably not fixing a bug. But
  5073. it future-proofs us against modifications that make things
  5074. like OBJ_NONE more likely (and gives future patches a
  5075. central point to handle them).
  5076.  
  5077. Signed-off-by: Jeff King <peff@peff.net>
  5078. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5079.  
  5080. relink: really remove the command
  5081.  
  5082. The files in contrib/examples are meant to illustrate "you could
  5083. combine plumbing commands to implement something like these"; this
  5084. is an opposite and is an example of what not to do, e.g. accessing
  5085. the object store directly bypassing Git.
  5086.  
  5087. Remove it.
  5088.  
  5089. Suggested-by: Jeff King <peff@peff.net>
  5090. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5091.  
  5092. relink: retire the command
  5093.  
  5094. Back in the olden days, when all objects were loose and rubber boots were
  5095. made out of wood, it made sense to try to share (immutable) objects
  5096. between repositories.
  5097.  
  5098. Ever since the arrival of pack files, it is but an anachronism.
  5099.  
  5100. Let's move the script to the contrib/examples/ directory and no longer
  5101. offer it.
  5102.  
  5103. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  5104. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5105.  
  5106. connect: handle putty/plink also in GIT_SSH_COMMAND
  5107.  
  5108. Git for Windows has special support for the popular SSH client PuTTY:
  5109. when using PuTTY's non-interactive version ("plink.exe"), we use the -P
  5110. option to specify the port rather than OpenSSH's -p option. TortoiseGit
  5111. ships with its own, forked version of plink.exe, that adds support for
  5112. the -batch option, and for good measure we special-case that, too.
  5113.  
  5114. However, this special-casing of PuTTY only covers the case where the
  5115. user overrides the SSH command via the environment variable GIT_SSH
  5116. (which allows specifying the name of the executable), not
  5117. GIT_SSH_COMMAND (which allows specifying a full command, including
  5118. additional command-line options).
  5119.  
  5120. When users want to pass any additional arguments to (Tortoise-)Plink,
  5121. such as setting a private key, they are required to either use a shell
  5122. script named plink or tortoiseplink or duplicate the logic that is
  5123. already in Git for passing the correct style of command line arguments,
  5124. which can be difficult, error prone and annoying to get right.
  5125.  
  5126. This patch simply reuses the existing logic and expands it to cover
  5127. GIT_SSH_COMMAND, too.
  5128.  
  5129. Note: it may look a little heavy-handed to duplicate the entire
  5130. command-line and then split it, only to extract the name of the
  5131. executable. However, this is not a performance-critical code path, and
  5132. the code is much more readable this way.
  5133.  
  5134. Signed-off-by: Segev Finer <segev208@gmail.com>
  5135. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  5136. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5137.  
  5138. difftool: hack around -Wzero-length-format warning
  5139.  
  5140. Building with "gcc -Wall" will complain that the format in:
  5141.  
  5142. warning("")
  5143.  
  5144. is empty. Which is true, but the warning is over-eager. We
  5145. are calling the function for its side effect of printing
  5146. "warning:", even with an empty string.
  5147.  
  5148. Our DEVELOPER Makefile knob disables the warning, but not
  5149. everybody uses it. Let's silence the warning in the code so
  5150. that nobody reports it or tries to "fix" it.
  5151.  
  5152. Signed-off-by: Jeff King <peff@peff.net>
  5153. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5154.  
  5155. unpack-trees: support super-prefix option
  5156.  
  5157. In the future we want to support working tree operations within submodules,
  5158. e.g. "git checkout --recurse-submodules", which will update the submodule
  5159. to the commit as recorded in its superproject. In the submodule the
  5160. unpack-tree operation is carried out as usual, but the reporting to the
  5161. user needs to prefix any path with the superproject. The mechanism for
  5162. this is the super-prefix. (see 74866d757, git: make super-prefix option)
  5163.  
  5164. Add support for the super-prefix option for commands that unpack trees
  5165. by wrapping any path output in unpacking trees in the newly introduced
  5166. super_prefixed function. This new function prefixes any path with the
  5167. super-prefix if there is one. Assuming the submodule case doesn't happen
  5168. in the majority of the cases, we'd want to have a fast behavior for no
  5169. super prefix, i.e. no reallocation/copying, but just returning path.
  5170.  
  5171. Another aspect of introducing the `super_prefixed` function is to consider
  5172. who owns the memory and if this is the right place where the path gets
  5173. modified. As the super prefix ought to change the output behavior only and
  5174. not the actual unpack tree part, it is fine to be that late in the line.
  5175. As we get passed in 'const char *path', we cannot change the path itself,
  5176. which means in case of a super prefix we have to copy over the path.
  5177. We need two static buffers in that function as the error messages
  5178. contain at most two paths.
  5179.  
  5180. For testing purposes enable it in read-tree, which has no output
  5181. of paths other than an unpack-trees.c. These are all converted in
  5182. this patch.
  5183.  
  5184. Signed-off-by: Stefan Beller <sbeller@google.com>
  5185. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5186.  
  5187. t1450: use "mv -f" within loose object directory
  5188.  
  5189. The loose objects are created with mode 0444. That doesn't
  5190. prevent them being overwritten by rename(), but some
  5191. versions of "mv" will be extra careful and prompt the user,
  5192. even without "-i".
  5193.  
  5194. Reportedly macOS does this, at least in the Travis builds.
  5195. The prompt reads from /dev/null, defaulting to "no", and the
  5196. object isn't moved. Then to make matters even more
  5197. interesting, it still returns "0" and the rest of the test
  5198. proceeds, but with a broken setup.
  5199.  
  5200. We can work around it by using "mv -f" to override the
  5201. prompt. This should work as it's already used in t5504 for
  5202. the same purpose.
  5203.  
  5204. Signed-off-by: Jeff King <peff@peff.net>
  5205. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5206.  
  5207. Merge branch 'master' of https://github.com/Softcatala/git-po
  5208.  
  5209. * 'master' of https://github.com/Softcatala/git-po:
  5210. l10n: fixes to Catalan translation
  5211.  
  5212. show-ref: remove a stale comment
  5213.  
  5214. When cf0adba788 ("Store peeled refs in packed-refs file.",
  5215. 2006-11-19) made the command to die with a message on error even
  5216. when --quiet is passed, it left the comment to say it changed the
  5217. semantics. But that kind of information belongs to the log message,
  5218. not in-code comment. Besides, the behaviour after the change has
  5219. been the established one for the past 10 years ;-)
  5220.  
  5221. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5222.  
  5223. describe: teach describe negative pattern matches
  5224.  
  5225. Teach git-describe the `--exclude` option which will allow specifying
  5226. a glob pattern of tags to ignore. This can be combined with the
  5227. `--match` patterns to enable more flexibility in determining which tags
  5228. to consider.
  5229.  
  5230. For example, suppose you wish to find the first official release tag
  5231. that contains a certain commit. If we assume that official release tags
  5232. are of the form "v*" and pre-release candidates include "*rc*" in their
  5233. name, we can now find the first release tag that introduces the commit
  5234. abcdef:
  5235.  
  5236. git describe --contains --match="v*" --exclude="*rc*" abcdef
  5237.  
  5238. Add documentation, tests, and completion for this change.
  5239.  
  5240. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  5241. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5242.  
  5243. describe: teach --match to accept multiple patterns
  5244.  
  5245. Teach `--match` to be accepted multiple times, accumulating a list of
  5246. patterns to match into a string list. Each pattern is inclusive, such
  5247. that a tag need only match one of the provided patterns to be
  5248. considered for matching.
  5249.  
  5250. This extension is useful as it enables more flexibility in what tags
  5251. match, and may avoid the need to run the describe command multiple
  5252. times to get the same result.
  5253.  
  5254. Add tests and update the documentation for this change.
  5255.  
  5256. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  5257. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5258.  
  5259. name-rev: add support to exclude refs by pattern match
  5260.  
  5261. Extend git-name-rev to support excluding refs which match shell patterns
  5262. using --exclude. These patterns can be used to limit the scope of refs
  5263. by excluding any ref that matches one of the --exclude patterns. A ref
  5264. will only be used for naming when it matches at least one --refs pattern
  5265. but does not match any of the --exclude patterns. Thus, --exclude
  5266. patterns are given precedence over --refs patterns.
  5267.  
  5268. For example, suppose you wish to name a series of commits based on an
  5269. official release tag of the form "v*" but excluding any pre-release tags
  5270. which match "*rc*". You can use the following to do so:
  5271.  
  5272. git name-rev --refs="v*" --exclude="*rc*" --all
  5273.  
  5274. Add tests and update Documentation for this change.
  5275.  
  5276. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  5277. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5278.  
  5279. name-rev: extend --refs to accept multiple patterns
  5280.  
  5281. Teach git name-rev to take multiple --refs stored as a string list of
  5282. patterns. The list of patterns will be matched inclusively, and each ref
  5283. only needs to match one pattern to be included. A ref will only be
  5284. excluded if it does not match any of the given patterns. Additionally,
  5285. if any of the patterns would allow abbreviation, then we will abbreviate
  5286. the ref, even if another pattern is more strict and would not have
  5287. allowed abbreviation on its own.
  5288.  
  5289. Add tests and documentation for this change. The tests expected output
  5290. is dynamically generated. This is in order to avoid hard-coding
  5291. a commit object name in the test results (as the expected output is to
  5292. simply leave the commit object unnamed).
  5293.  
  5294. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  5295. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5296.  
  5297. log --graph: customize the graph lines with config log.graphColors
  5298.  
  5299. If you have a 256 colors terminal (or one with true color support), then
  5300. the predefined 12 colors seem limited. On the other hand, you don't want
  5301. to draw graph lines with every single color in this mode because the two
  5302. colors could look extremely similar. This option allows you to hand pick
  5303. the colors you want.
  5304.  
  5305. Even with standard terminal, if your background color is neither black
  5306. or white, then the graph line may match your background and become
  5307. hidden. You can exclude your background color (or simply the colors you
  5308. hate) with this.
  5309.  
  5310. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  5311. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5312.  
  5313. Seventh batch for 2.12
  5314.  
  5315. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5316.  
  5317. Merge branch 'ws/request-pull-code-cleanup'
  5318.  
  5319. Code clean-up.
  5320.  
  5321. * ws/request-pull-code-cleanup:
  5322. request-pull: drop old USAGE stuff
  5323.  
  5324. Merge branch 'rh/diff-orderfile-doc'
  5325.  
  5326. Documentation fix.
  5327.  
  5328. * rh/diff-orderfile-doc:
  5329. diff: document the format of the -O (diff.orderFile) file
  5330. diff: document behavior of relative diff.orderFile
  5331.  
  5332. Merge branch 'sb/cd-then-git-can-be-written-as-git-c'
  5333.  
  5334. Test clean-up.
  5335.  
  5336. * sb/cd-then-git-can-be-written-as-git-c:
  5337. lib-submodule-update.sh: reduce use of subshell by using "git -C"
  5338.  
  5339. Merge branch 'ad/bisect-terms'
  5340.  
  5341. Documentation fix.
  5342.  
  5343. * ad/bisect-terms:
  5344. Documentation/bisect: improve on (bad|new) and (good|bad)
  5345.  
  5346. Merge branch 'sg/fix-versioncmp-with-common-suffix'
  5347.  
  5348. The prereleaseSuffix feature of version comparison that is used in
  5349. "git tag -l" did not correctly when two or more prereleases for the
  5350. same release were present (e.g. when 2.0, 2.0-beta1, and 2.0-beta2
  5351. are there and the code needs to compare 2.0-beta1 and 2.0-beta2).
  5352.  
  5353. * sg/fix-versioncmp-with-common-suffix:
  5354. versioncmp: generalize version sort suffix reordering
  5355. versioncmp: factor out helper for suffix matching
  5356. versioncmp: use earliest-longest contained suffix to determine sorting order
  5357. versioncmp: cope with common part overlapping with prerelease suffix
  5358. versioncmp: pass full tagnames to swap_prereleases()
  5359. t7004-tag: add version sort tests to show prerelease reordering issues
  5360. t7004-tag: use test_config helper
  5361. t7004-tag: delete unnecessary tags with test_when_finished
  5362.  
  5363. Merge branch 'vn/diff-ihc-config'
  5364.  
  5365. "git diff" learned diff.interHunkContext configuration variable
  5366. that gives the default value for its --inter-hunk-context option.
  5367.  
  5368. * vn/diff-ihc-config:
  5369. diff: add interhunk context config option
  5370.  
  5371. Merge branch 'sb/submodule-init'
  5372.  
  5373. Error message fix.
  5374.  
  5375. * sb/submodule-init:
  5376. submodule update --init: display correct path from submodule
  5377.  
  5378. Merge branch 'sb/submodule-embed-gitdir'
  5379.  
  5380. Help-text fix.
  5381.  
  5382. * sb/submodule-embed-gitdir:
  5383. submodule absorbgitdirs: mention in docstring help
  5384.  
  5385. Merge branch 'sb/submodule-config-tests'
  5386.  
  5387. Test updates.
  5388.  
  5389. * sb/submodule-config-tests:
  5390. t7411: test lookup of uninitialized submodules
  5391. t7411: quote URLs
  5392.  
  5393. Merge branch 'jk/grep-e-could-be-extended-beyond-posix'
  5394.  
  5395. Tighten a test to avoid mistaking an extended ERE regexp engine as
  5396. a PRE regexp engine.
  5397.  
  5398. * jk/grep-e-could-be-extended-beyond-posix:
  5399. t7810: avoid assumption about invalid regex syntax
  5400.  
  5401. Merge branch 'bw/read-blob-data-does-not-modify-index-state'
  5402.  
  5403. Code clean-up.
  5404.  
  5405. * bw/read-blob-data-does-not-modify-index-state:
  5406. index: improve constness for reading blob data
  5407.  
  5408. show-ref: remove dead `if (verify)' check
  5409.  
  5410. As show_ref() is only ever called on the path where --verify is not
  5411. specified, `verify' can never possibly be true here.
  5412.  
  5413. Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
  5414. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5415.  
  5416. show-ref: detect dangling refs under --verify as well
  5417.  
  5418. Move detection of dangling refs into show_one(), so that they are
  5419. detected when --verify is present as well as when it is absent.
  5420.  
  5421. Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
  5422. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5423.  
  5424. show-ref: move --quiet handling into show_one()
  5425.  
  5426. Do the same with --quiet as was done with -d, to remove the need to
  5427. perform this check at show_one()'s call site from the --verify branch.
  5428.  
  5429. Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
  5430. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5431.  
  5432. show-ref: allow -d to work with --verify
  5433.  
  5434. Move handling of -d into show_one(), so that it takes effect when
  5435. --verify is present as well as when it is absent. This is useful when
  5436. the user wishes to avoid the costly iteration of refs.
  5437.  
  5438. Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
  5439. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5440.  
  5441. show-ref: accept HEAD with --verify
  5442.  
  5443. Previously, when --verify was specified, show-ref would use a separate
  5444. code path which did not handle HEAD and treated it as an invalid
  5445. ref. Thus, "git show-ref --verify HEAD" (where "--verify" is used
  5446. because the user is not interested in seeing refs/remotes/origin/HEAD)
  5447. did not work as expected.
  5448.  
  5449. Instead of insisting that the input begins with "refs/", allow "HEAD"
  5450. as well in the codepath that handles "--verify", so that all valid
  5451. full refnames including HEAD are passed to the same output machinery.
  5452.  
  5453. Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
  5454. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5455.  
  5456. ref-filter: use QSORT_S in ref_array_sort()
  5457.  
  5458. Pass the array of sort keys to compare_refs() via the context parameter
  5459. of qsort_s() instead of using a global variable; that's cleaner and
  5460. simpler. If ref_array_sort() is to be called from multiple parallel
  5461. threads then care still needs to be taken that the global variable
  5462. used_atom is not modified concurrently.
  5463.  
  5464. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  5465. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5466.  
  5467. string-list: use QSORT_S in string_list_sort()
  5468.  
  5469. Pass the comparison function to cmp_items() via the context parameter of
  5470. qsort_s() instead of using a global variable. That allows calling
  5471. string_list_sort() from multiple parallel threads.
  5472.  
  5473. Our qsort_s() in compat/ is slightly slower than qsort(1) from glibc
  5474. 2.24 for sorting lots of lines:
  5475.  
  5476. Test HEAD^ HEAD
  5477. ---------------------------------------------------------------------
  5478. 0071.2: sort(1) 0.10(0.22+0.01) 0.09(0.21+0.00) -10.0%
  5479. 0071.3: string_list_sort() 0.16(0.15+0.01) 0.17(0.15+0.00) +6.3%
  5480.  
  5481. GNU sort(1) version 8.26 is significantly faster because it uses
  5482. multiple parallel threads; with the unportable option --parallel=1 it
  5483. becomes slower:
  5484.  
  5485. Test HEAD^ HEAD
  5486. --------------------------------------------------------------------
  5487. 0071.2: sort(1) 0.21(0.18+0.01) 0.20(0.18+0.01) -4.8%
  5488. 0071.3: string_list_sort() 0.16(0.13+0.02) 0.17(0.15+0.01) +6.3%
  5489.  
  5490. There is some instability -- the numbers for the sort(1) check shouldn't
  5491. be affected by this patch. Anyway, the performance of our qsort_s()
  5492. implementation is apparently good enough, at least for this test.
  5493.  
  5494. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  5495. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5496.  
  5497. perf: add basic sort performance test
  5498.  
  5499. Add a sort command to test-string-list that reads lines from stdin,
  5500. stores them in a string_list and then sorts it. Use it in a simple
  5501. perf test script to measure the performance of string_list_sort().
  5502.  
  5503. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  5504. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5505.  
  5506. add QSORT_S
  5507.  
  5508. Add the macro QSORT_S, a convenient wrapper for qsort_s() that infers
  5509. the size of the array elements and dies on error.
  5510.  
  5511. Basically all possible errors are programming mistakes (passing NULL as
  5512. base of a non-empty array, passing NULL as comparison function,
  5513. out-of-bounds accesses), so terminating the program should be acceptable
  5514. for most callers.
  5515.  
  5516. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  5517. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5518.  
  5519. compat: add qsort_s()
  5520.  
  5521. The function qsort_s() was introduced with C11 Annex K; it provides the
  5522. ability to pass a context pointer to the comparison function, supports
  5523. the convention of using a NULL pointer for an empty array and performs a
  5524. few safety checks.
  5525.  
  5526. Add an implementation based on compat/qsort.c for platforms that lack a
  5527. native standards-compliant qsort_s() (i.e. basically everyone). It
  5528. doesn't perform the full range of possible checks: It uses size_t
  5529. instead of rsize_t and doesn't check nmemb and size against RSIZE_MAX
  5530. because we probably don't have the restricted size type defined. For
  5531. the same reason it returns int instead of errno_t.
  5532.  
  5533. Signed-off-by: Rene Scharfe <l.s.r@web.de>
  5534. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5535.  
  5536. Makefile: add a knob to enable the use of Asciidoctor
  5537.  
  5538. While Git has traditionally built its documentation using AsciiDoc, some
  5539. people wish to use Asciidoctor for speed or other reasons. Add a
  5540. Makefile knob, USE_ASCIIDOCTOR, that sets various options in order to
  5541. produce acceptable output. For HTML output, XHTML5 was chosen, since
  5542. the AsciiDoc options also produce XHTML, albeit XHTML 1.1.
  5543.  
  5544. Asciidoctor does not have built-in support for the linkgit macro, but it
  5545. is available using the Asciidoctor Extensions Lab. Add a macro to
  5546. enable the use of this extension if it is available. Without it, the
  5547. linkgit macros are emitted into the output.
  5548.  
  5549. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  5550. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5551.  
  5552. Documentation: move dblatex arguments into variable
  5553.  
  5554. Our dblatex invocation uses several style components from the AsciiDoc
  5555. distribution, but those components are not available when building with
  5556. Asciidoctor. Move the command line arguments into a variable so it can
  5557. be overridden by the user or makefile configuration options.
  5558.  
  5559. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  5560. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5561.  
  5562. Documentation: add XSLT to fix DocBook for Texinfo
  5563.  
  5564. There are two ways to create a section in a reference document (i.e.,
  5565. manpage) in DocBook 4: refsection elements and refsect, refsect2, and
  5566. refsect3 elements. Either form is acceptable as of DocBook 4.2, but
  5567. they cannot be mixed. Prior to DocBook 4.2, only the numbered forms
  5568. were acceptable.
  5569.  
  5570. docbook2texi only accepts the numbered forms, and this has not generally
  5571. been a problem, since AsciiDoc produces the numbered forms.
  5572. Asciidoctor, on the other hand, uses a shared backend for DocBook 4 and
  5573. 5, and uses the unnumbered refsection elements instead.
  5574.  
  5575. If we don't convert the unnumbered form to the numbered form,
  5576. docbook2texi omits section headings, which is undesirable. Add an XSLT
  5577. stylesheet to transform the unnumbered forms to the numbered forms
  5578. automatically, and preprocess the DocBook XML as part of the
  5579. transformation to Texinfo format.
  5580.  
  5581. Note that this transformation is only necessary for Texinfo, since
  5582. docbook2texi provides its own stylesheets. The DocBook stylesheets,
  5583. which we use for other formats, provide the full range of DocBook 4 and
  5584. 5 compatibility, and don't have this issue.
  5585.  
  5586. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  5587. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5588.  
  5589. Documentation: sort sources for gitman.texi
  5590.  
  5591. Sorting the sources makes it easier to compare the output using diff.
  5592. In addition, it aids groups creating reproducible builds, as the order
  5593. of the files is no longer dependent on the file system or other
  5594. irrelevant factors.
  5595.  
  5596. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  5597. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5598.  
  5599. Documentation: remove unneeded argument in cat-texi.perl
  5600.  
  5601. The newly-added use of the warnings pragma exposes that the $menu[0]
  5602. argument to printf has long been silently ignored, since there is no
  5603. format specifier for it. It doesn't appear that the argument is
  5604. actually needed, either: there is no reason to insert the name of one
  5605. particular documentation page anywhere in the header that's being
  5606. generated.
  5607.  
  5608. Remove the unused argument, and since the format specification
  5609. functionality is no longer needed, convert the printf to a simple print.
  5610.  
  5611. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  5612. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5613.  
  5614. Documentation: modernize cat-texi.perl
  5615.  
  5616. Good style for Perl includes using the strict and warnings pragmas, and
  5617. preferring lexical file handles over bareword file handles. Using
  5618. lexical file handles necessitates being explicit when $_ is printed, so
  5619. that Perl does not get confused and instead print the glob ref.
  5620.  
  5621. The benefit of this modernization is that a formerly obscured bug is now
  5622. visible, which will be fixed in a followup patch.
  5623.  
  5624. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  5625. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5626.  
  5627. Documentation: fix warning in cat-texi.perl
  5628.  
  5629. Newer versions of Perl produce the warning "Unescaped left brace in
  5630. regex is deprecated, passed through in regex" when an unescaped left
  5631. brace occurs in a regex. Escape the brace to avoid this warning.
  5632.  
  5633. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
  5634. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5635.  
  5636. travis-ci: fix Perforce install on macOS
  5637.  
  5638. The `perforce` and `perforce-server` package were moved from brew [1][2]
  5639. to cask [3]. Teach TravisCI the new location.
  5640.  
  5641. Perforce updates their binaries without version bumps. That made the
  5642. brew install (legitimately!) fail due to checksum mismatches. The
  5643. workaround is not necessary anymore as Cask [4] allows to disable the
  5644. checksum test for individual formulas.
  5645.  
  5646. [1] https://github.com/Homebrew/homebrew-binary/commit/1394e42de04d07445f82f9512627e864ff4ca4c6
  5647. [2] https://github.com/Homebrew/homebrew-binary/commit/f8da22d6b8dbcfcfdb2dfa9ac1a5e5d8e05aac2b
  5648. [3] https://github.com/caskroom/homebrew-cask/pull/29180
  5649. [4] https://caskroom.github.io/
  5650.  
  5651. Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
  5652. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5653.  
  5654. contrib: remove git-convert-objects
  5655.  
  5656. git-convert-objects, originally named git-convert-cache was used in
  5657. early 2005 to convert ancient repositories where objects are named
  5658. after the hash of their compressed contents to the current object
  5659. naming sheme where they are named after the hash of their pre-compression
  5660. contents.
  5661.  
  5662. By now the need for conversion of the very early repositories is
  5663. less relevant, we no longer need to keep it in contrib; remove it.
  5664.  
  5665. Signed-off-by: Stefan Beller <sbeller@google.com>
  5666. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5667.  
  5668. remote rename: more carefully determine whether a remote is configured
  5669.  
  5670. One of the really nice features of the ~/.gitconfig file is that users
  5671. can override defaults by their own preferred settings for all of their
  5672. repositories.
  5673.  
  5674. One such default that some users like to override is whether the
  5675. "origin" remote gets auto-pruned or not. The user would simply call
  5676.  
  5677. git config --global remote.origin.prune true
  5678.  
  5679. and from now on all "origin" remotes would be pruned automatically when
  5680. fetching into the local repository.
  5681.  
  5682. There is just one catch: now Git thinks that the "origin" remote is
  5683. configured, even if the repository config has no [remote "origin"]
  5684. section at all, as it does not realize that the "prune" setting was
  5685. configured globally and that there really is no "origin" remote
  5686. configured in this repository.
  5687.  
  5688. That is a problem e.g. when renaming a remote to a new name, when Git
  5689. may be fooled into thinking that there is already a remote of that new
  5690. name.
  5691.  
  5692. Let's fix this by paying more attention to *where* the remote settings
  5693. came from: if they are configured in the local repository config, we
  5694. must not overwrite them. If they were configured elsewhere, we cannot
  5695. overwrite them to begin with, as we only write the repository config.
  5696.  
  5697. There is only one caller of remote_is_configured() (in `git fetch`) that
  5698. may want to take remotes into account even if they were configured
  5699. outside the repository config; all other callers essentially try to
  5700. prevent the Git command from overwriting settings in the repository
  5701. config.
  5702.  
  5703. To accommodate that fact, the remote_is_configured() function now
  5704. requires a parameter that states whether the caller is interested in all
  5705. remotes, or only in those that were configured in the repository config.
  5706.  
  5707. Many thanks to Jeff King whose tireless review helped with settling for
  5708. nothing less than the current strategy.
  5709.  
  5710. This fixes https://github.com/git-for-windows/git/issues/888
  5711.  
  5712. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  5713. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5714.  
  5715. remote rename: demonstrate a bogus "remote exists" bug
  5716.  
  5717. Some users like to set `remote.origin.prune = true` in their ~/.gitconfig
  5718. so that all of their repositories use that default.
  5719.  
  5720. However, our code is ill-prepared for this, mistaking that single entry to
  5721. mean that there is already a remote of the name "origin", even if there is
  5722. not.
  5723.  
  5724. This patch adds a test case demonstrating this issue.
  5725.  
  5726. Reported by Andrew Arnott.
  5727.  
  5728. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  5729. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5730.  
  5731. difftool: retire the scripted version
  5732.  
  5733. It served its purpose, but now we have a builtin difftool. Time for the
  5734. Perl script to enjoy Florida.
  5735.  
  5736. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  5737. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5738.  
  5739. difftool: implement the functionality in the builtin
  5740.  
  5741. This patch gives life to the skeleton added in the previous patch.
  5742.  
  5743. The motivation for converting the difftool is that Perl scripts are not at
  5744. all native on Windows, and that `git difftool` therefore is pretty slow on
  5745. that platform, when there is no good reason for it to be slow.
  5746.  
  5747. In addition, Perl does not really have access to Git's internals. That
  5748. means that any script will always have to jump through unnecessary
  5749. hoops, and it will often need to perform unnecessary work (e.g. when
  5750. reading the entire config every time `git config` is called to query a
  5751. single config value).
  5752.  
  5753. The current version of the builtin difftool does not, however, make full
  5754. use of the internals but instead chooses to spawn a couple of Git
  5755. processes, still, to make for an easier conversion. There remains a lot
  5756. of room for improvement, left later.
  5757.  
  5758. Note: to play it safe, the original difftool is still called unless the
  5759. config setting difftool.useBuiltin is set to true.
  5760.  
  5761. The reason: this new, experimental, builtin difftool was shipped as part
  5762. of Git for Windows v2.11.0, to allow for easier large-scale testing, but
  5763. of course as an opt-in feature.
  5764.  
  5765. The speedup is actually more noticable on Linux than on Windows: a quick
  5766. test shows that t7800-difftool.sh runs in (2.183s/0.052s/0.108s)
  5767. (real/user/sys) in a Linux VM, down from (6.529s/3.112s/0.644s), while on
  5768. Windows, it is (36.064s/2.730s/7.194s), down from (47.637s/2.407s/6.863s).
  5769. The culprit is most likely the overhead incurred from *still* having to
  5770. shell out to mergetool-lib.sh and difftool--helper.sh.
  5771.  
  5772. Still, it is an improvement.
  5773.  
  5774. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  5775. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5776.  
  5777. doc: add documentation for OPT_STRING_LIST
  5778.  
  5779. Commit c8ba16391655 ("parse-options: add OPT_STRING_LIST helper",
  5780. 2011-06-09) added the OPT_STRING_LIST as a way to accumulate a repeated
  5781. list of strings. However, this was not documented in the
  5782. api-parse-options documentation. Add documentation now so that future
  5783. developers may learn of its existence.
  5784.  
  5785. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  5786. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5787.  
  5788. documentation: retire unfinished documentation
  5789.  
  5790. When looking for documentation for a specific function, you may be tempted
  5791. to run
  5792.  
  5793. git -C Documentation grep index_name_pos
  5794.  
  5795. only to find the file technical/api-in-core-index.txt, which doesn't
  5796. help for understanding the given function. It would be better to not find
  5797. these functions in the documentation, such that people directly dive into
  5798. the code instead.
  5799.  
  5800. In the previous patches we have documented
  5801. * index_name_pos()
  5802. * remove_index_entry_at()
  5803. * add_[file_]to_index()
  5804. in cache.h
  5805.  
  5806. We already have documentation for:
  5807. * add_index_entry()
  5808. * read_index()
  5809.  
  5810. Which leaves us with a TODO for:
  5811. * cache -> the_index macros
  5812. * refresh_index()
  5813. * discard_index()
  5814. * ie_match_stat() and ie_modified(); how they are different and when to
  5815. use which.
  5816. * write_index() that was renamed to write_locked_index
  5817. * cache_tree_invalidate_path()
  5818. * cache_tree_update()
  5819.  
  5820. Signed-off-by: Stefan Beller <sbeller@google.com>
  5821. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5822.  
  5823. cache.h: document add_[file_]to_index
  5824.  
  5825. Helped-by: Junio C Hamano <gitster@pobox.com>
  5826. Signed-off-by: Stefan Beller <sbeller@google.com>
  5827. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5828.  
  5829. cache.h: document remove_index_entry_at
  5830.  
  5831. Do this by moving the existing documentation from
  5832. read-cache.c to cache.h.
  5833.  
  5834. Signed-off-by: Stefan Beller <sbeller@google.com>
  5835. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5836.  
  5837. cache.h: document index_name_pos
  5838.  
  5839. Signed-off-by: Stefan Beller <sbeller@google.com>
  5840. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5841.  
  5842. color.c: trim leading spaces in color_parse_mem()
  5843.  
  5844. Normally color_parse_mem() is called from config parser which trims the
  5845. leading spaces already. The new caller in the next patch won't. Let's be
  5846. tidy and trim leading spaces too (we already trim trailing spaces
  5847. after a word).
  5848.  
  5849. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  5850. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5851.  
  5852. color.c: fix color_parse_mem() with value_len == 0
  5853.  
  5854. In this code we want to match the word "reset". If len is zero,
  5855. strncasecmp() will return zero and we incorrectly assume it's "reset" as
  5856. a result.
  5857.  
  5858. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  5859. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5860.  
  5861. clear_delta_base_cache(): don't modify hashmap while iterating
  5862.  
  5863. On Thu, Jan 19, 2017 at 03:03:46PM +0100, Ulrich Spörlein wrote:
  5864.  
  5865. > > I suspect the patch below may fix things for you. It works around it by
  5866. > > walking over the lru list (either is fine, as they both contain all
  5867. > > entries, and since we're clearing everything, we don't care about the
  5868. > > order).
  5869. >
  5870. > Confirmed. With the patch applied, I can import the whole 55G in one go
  5871. > without any crashes or aborts. Thanks much!
  5872.  
  5873. Thanks. Here it is rolled up with a commit message.
  5874.  
  5875. -- >8 --
  5876. Subject: clear_delta_base_cache(): don't modify hashmap while iterating
  5877.  
  5878. Removing entries while iterating causes fast-import to
  5879. access an already-freed `struct packed_git`, leading to
  5880. various confusing errors.
  5881.  
  5882. What happens is that clear_delta_base_cache() drops the
  5883. whole contents of the cache by iterating over the hashmap,
  5884. calling release_delta_base_cache() on each entry. That
  5885. function removes the item from the hashmap. The hashmap code
  5886. may then shrink the table, but the hashmap_iter struct
  5887. retains an offset from the old table.
  5888.  
  5889. As a result, the next call to hashmap_iter_next() may claim
  5890. that the iteration is done, even though some items haven't
  5891. been visited.
  5892.  
  5893. The only caller of clear_delta_base_cache() is fast-import,
  5894. which wants to clear the cache because it is discarding the
  5895. packed_git struct for its temporary pack. So by failing to
  5896. remove all of the entries, we still have references to the
  5897. freed packed_git.
  5898.  
  5899. To make things even more confusing, this doesn't seem to
  5900. trigger with the test suite, because it depends on
  5901. complexities like the size of the hash table, which entries
  5902. got cleared, whether we try to access them before they're
  5903. evicted from the cache, etc.
  5904.  
  5905. So I've been able to identify the problem with large
  5906. imports like freebsd's svn import, or a fast-export of
  5907. linux.git. But nothing that would be reasonable to run as
  5908. part of the normal test suite.
  5909.  
  5910. We can fix this easily by iterating over the lru linked list
  5911. instead of the hashmap. They both contain the same entries,
  5912. and we can use the "safe" variant of the list iterator,
  5913. which exists for exactly this case.
  5914.  
  5915. Let's also add a warning to the hashmap API documentation to
  5916. reduce the chances of getting bit by this again.
  5917.  
  5918. Reported-by: Ulrich Spörlein <uqs@freebsd.org>
  5919. Signed-off-by: Jeff King <peff@peff.net>
  5920. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5921.  
  5922. Sixth batch for 2.12
  5923.  
  5924. Merge branch 'sb/remove-gitview'
  5925.  
  5926. Retire long unused/unmaintained gitview from the contrib/ area.
  5927.  
  5928. * sb/remove-gitview:
  5929. doc: git-gui browser does not default to HEAD
  5930. doc: gitk: add the upstream repo location
  5931. doc: gitk: remove gitview reference
  5932. contrib: remove gitview
  5933.  
  5934. Merge branch 'js/asciidoctor-tweaks'
  5935.  
  5936. Adjust documentation to help AsciiDoctor render better while not
  5937. breaking the rendering done by AsciiDoc.
  5938.  
  5939. * js/asciidoctor-tweaks:
  5940. asciidoctor: fix user-manual to be built by `asciidoctor`
  5941. giteveryday: unbreak rendering with AsciiDoctor
  5942.  
  5943. Merge branch 'sb/unpack-trees-cleanup'
  5944.  
  5945. Code cleanup.
  5946.  
  5947. * sb/unpack-trees-cleanup:
  5948. unpack-trees: factor progress setup out of check_updates
  5949. unpack-trees: remove unneeded continue
  5950. unpack-trees: move checkout state into check_updates
  5951.  
  5952. Merge branch 'rh/mergetool-regression-fix'
  5953.  
  5954. "git mergetool" without any pathspec on the command line that is
  5955. run from a subdirectory became no-op in Git v2.11 by mistake, which
  5956. has been fixed.
  5957.  
  5958. * rh/mergetool-regression-fix:
  5959. mergetool: fix running in subdir when rerere enabled
  5960. mergetool: take the "-O" out of $orderfile
  5961. t7610: add test case for rerere+mergetool+subdir bug
  5962. t7610: spell 'git reset --hard' consistently
  5963. t7610: don't assume the checked-out commit
  5964. t7610: always work on a test-specific branch
  5965. t7610: delete some now-unnecessary 'git reset --hard' lines
  5966. t7610: run 'git reset --hard' after each test to clean up
  5967. t7610: don't rely on state from previous test
  5968. t7610: use test_when_finished for cleanup tasks
  5969. t7610: move setup code to the 'setup' test case
  5970. t7610: update branch names to match test number
  5971. rev-parse doc: pass "--" to rev-parse in the --prefix example
  5972. .mailmap: record canonical email for Richard Hansen
  5973.  
  5974. Merge branch 'bw/realpath-wo-chdir'
  5975.  
  5976. The implementation of "real_path()" was to go there with chdir(2)
  5977. and call getcwd(3), but this obviously wouldn't be usable in a
  5978. threaded environment. Rewrite it to manually resolve relative
  5979. paths including symbolic links in path components.
  5980.  
  5981. * bw/realpath-wo-chdir:
  5982. real_path: set errno when max number of symlinks is exceeded
  5983. real_path: prevent redefinition of MAXSYMLINKS
  5984.  
  5985. Merge branch 'jk/execv-dashed-external'
  5986.  
  5987. Typing ^C to pager, which usually does not kill it, killed Git and
  5988. took the pager down as a collateral damage in certain process-tree
  5989. structure. This has been fixed.
  5990.  
  5991. * jk/execv-dashed-external:
  5992. execv_dashed_external: wait for child on signal death
  5993. execv_dashed_external: stop exiting with negative code
  5994. execv_dashed_external: use child_process struct
  5995.  
  5996. Merge branch 'sp/cygwin-build-fixes'
  5997.  
  5998. Build updates for Cygwin.
  5999.  
  6000. * sp/cygwin-build-fixes:
  6001. Makefile: put LIBS after LDFLAGS for imap-send
  6002. Makefile: POSIX windres
  6003.  
  6004. Merge branch 'sb/pathspec-errors'
  6005.  
  6006. Running "git add a/b" when "a" is a submodule correctly errored
  6007. out, but without a meaningful error message.
  6008.  
  6009. * sb/pathspec-errors:
  6010. pathspec: give better message for submodule related pathspec error
  6011.  
  6012. Merge branch 'pb/test-must-fail-is-for-git'
  6013.  
  6014. Test cleanup.
  6015.  
  6016. * pb/test-must-fail-is-for-git:
  6017. t9813: avoid using pipes
  6018. don't use test_must_fail with grep
  6019.  
  6020. Merge branch 'bw/pathspec-cleanup'
  6021.  
  6022. Code clean-up in the pathspec API.
  6023.  
  6024. * bw/pathspec-cleanup:
  6025. pathspec: rename prefix_pathspec to init_pathspec_item
  6026. pathspec: small readability changes
  6027. pathspec: create strip submodule slash helpers
  6028. pathspec: create parse_element_magic helper
  6029. pathspec: create parse_long_magic function
  6030. pathspec: create parse_short_magic function
  6031. pathspec: factor global magic into its own function
  6032. pathspec: simpler logic to prefix original pathspec elements
  6033. pathspec: always show mnemonic and name in unsupported_magic
  6034. pathspec: remove unused variable from unsupported_magic
  6035. pathspec: copy and free owned memory
  6036. pathspec: remove the deprecated get_pathspec function
  6037. ls-tree: convert show_recursive to use the pathspec struct interface
  6038. dir: convert fill_directory to use the pathspec struct interface
  6039. dir: remove struct path_simplify
  6040. mv: remove use of deprecated 'get_pathspec()'
  6041.  
  6042. Merge branch 'js/mingw-test-push-unc-path'
  6043.  
  6044. "git push \\server\share\dir" has recently regressed and then
  6045. fixed. A test has retroactively been added for this breakage.
  6046.  
  6047. * js/mingw-test-push-unc-path:
  6048. mingw: add a regression test for pushing to UNC paths
  6049.  
  6050. Merge branch 'sb/submodule-cleanup-export-git-dir-env'
  6051.  
  6052. Code cleanup.
  6053.  
  6054. * sb/submodule-cleanup-export-git-dir-env:
  6055. submodule.c: use GIT_DIR_ENVIRONMENT consistently
  6056.  
  6057. Merge branch 'km/branch-get-push-while-detached'
  6058.  
  6059. "git <cmd> @{push}" on a detached HEAD used to segfault; it has
  6060. been corrected to error out with a message.
  6061.  
  6062. * km/branch-get-push-while-detached:
  6063. branch_get_push: do not segfault when HEAD is detached
  6064.  
  6065. Merge branch 'jk/rebase-i-squash-count-fix'
  6066.  
  6067. "git rebase -i" with a recent update started showing an incorrect
  6068. count when squashing more than 10 commits.
  6069.  
  6070. * jk/rebase-i-squash-count-fix:
  6071. rebase--interactive: count squash commits above 10 correctly
  6072.  
  6073. Merge branch 'jk/blame-fixes'
  6074.  
  6075. "git blame --porcelain" misidentified the "previous" <commit, path>
  6076. pair (aka "source") when contents came from two or more files.
  6077.  
  6078. * jk/blame-fixes:
  6079. blame: output porcelain "previous" header for each file
  6080. blame: handle --no-abbrev
  6081. blame: fix alignment with --abbrev=40
  6082.  
  6083. Merge branch 'jk/archive-zip-userdiff-config'
  6084.  
  6085. "git archive" did not read the standard configuration files, and
  6086. failed to notice a file that is marked as binary via the userdiff
  6087. driver configuration.
  6088.  
  6089. * jk/archive-zip-userdiff-config:
  6090. archive-zip: load userdiff config
  6091.  
  6092. Merge branch 'dt/disable-bitmap-in-auto-gc'
  6093.  
  6094. It is natural that "git gc --auto" may not attempt to pack
  6095. everything into a single pack, and there is no point in warning
  6096. when the user has configured the system to use the pack bitmap,
  6097. leading to disabling further "gc".
  6098.  
  6099. * dt/disable-bitmap-in-auto-gc:
  6100. repack: die on incremental + write-bitmap-index
  6101. auto gc: don't write bitmaps for incremental repacks
  6102.  
  6103. Merge branch 'ls/p4-retry-thrice'
  6104.  
  6105. A recent updates to "git p4" was not usable for older p4 but it
  6106. could be made to work with minimum changes. Do so.
  6107.  
  6108. * ls/p4-retry-thrice:
  6109. git-p4: do not pass '-r 0' to p4 commands
  6110.  
  6111. Merge branch 'sb/submodule-rm-absorb'
  6112.  
  6113. "git rm" used to refuse to remove a submodule when it has its own
  6114. git repository embedded in its working tree. It learned to move
  6115. the repository away to $GIT_DIR/modules/ of the superproject
  6116. instead, and allow the submodule to be deleted (as long as there
  6117. will be no loss of local modifications, that is).
  6118.  
  6119. * sb/submodule-rm-absorb:
  6120. rm: absorb a submodules git dir before deletion
  6121. submodule: rename and add flags to ok_to_remove_submodule
  6122. submodule: modernize ok_to_remove_submodule to use argv_array
  6123. submodule.h: add extern keyword to functions
  6124.  
  6125. Merge branch 'bw/grep-recurse-submodules'
  6126.  
  6127. "git grep" has been taught to optionally recurse into submodules.
  6128.  
  6129. * bw/grep-recurse-submodules:
  6130. grep: search history of moved submodules
  6131. grep: enable recurse-submodules to work on <tree> objects
  6132. grep: optionally recurse into submodules
  6133. grep: add submodules as a grep source type
  6134. submodules: load gitmodules file from commit sha1
  6135. submodules: add helper to determine if a submodule is initialized
  6136. submodules: add helper to determine if a submodule is populated
  6137. real_path: canonicalize directory separators in root parts
  6138. real_path: have callers use real_pathdup and strbuf_realpath
  6139. real_path: create real_pathdup
  6140. real_path: convert real_path_internal to strbuf_realpath
  6141. real_path: resolve symlinks by hand
  6142.  
  6143. mingw: follow-up to "replace isatty() hack"
  6144.  
  6145. The version of the "replace isatty() hack" that got merged a few
  6146. weeks ago did not actually reflect the latest iteration of the patch
  6147. series: v3 was sent out with these changes, as requested by the
  6148. reviewer Johannes Sixt:
  6149.  
  6150. - reworded the comment about "recycling handles"
  6151.  
  6152. - moved the reassignment of the `console` variable before the dup2()
  6153. call so that it is valid at all times
  6154.  
  6155. - removed the "handle = INVALID_HANDLE_VALUE" assignment, as the local
  6156. variable `handle` is not used afterwards anyway
  6157.  
  6158. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6159. Reviewed-by: Johannes Sixt <j6t@kdbg.org>
  6160. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6161.  
  6162. t/t7004-tag: Add --format specifier tests
  6163.  
  6164. tag -v now supports --format specifiers to inspect the contents of a tag
  6165. upon verification. Add two tests to ensure this behavior is respected in
  6166. future changes.
  6167.  
  6168. Signed-off-by: Santiago Torres <santiago@nyu.edu>
  6169. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6170.  
  6171. t/t7030-verify-tag: Add --format specifier tests
  6172.  
  6173. Verify-tag now provides --format specifiers to inspect and ensure the
  6174. contents of the tag are proper. We add two tests to ensure this
  6175. functionality works as expected: the return value should indicate if
  6176. verification passed, and the format specifiers must be respected.
  6177.  
  6178. Signed-off-by: Santiago Torres <santiago@nyu.edu>
  6179. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6180.  
  6181. builtin/tag: add --format argument for tag -v
  6182.  
  6183. Adding --format to git tag -v mutes the default output of the GPG
  6184. verification and instead prints the formatted tag object.
  6185. This allows callers to cross-check the tagname from refs/tags with
  6186. the tagname from the tag object header upon GPG verification.
  6187.  
  6188. The callback function for for_each_tag_name() didn't allow callers to
  6189. pass custom data to their callback functions. Add a new opaque pointer
  6190. to each_tag_name_fn's parameter to allow this.
  6191.  
  6192. Signed-off-by: Lukas Puehringer <luk.puehringer@gmail.com>
  6193. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6194.  
  6195. Merge git://ozlabs.org/~paulus/gitk
  6196.  
  6197. * 'master' of git://ozlabs.org/~paulus/gitk:
  6198. gitk: Remove translated message from comments
  6199. gitk: ru.po: Update Russian translation
  6200. gitk: Update copyright notice to 2016
  6201. gitk: Clear array 'commitinfo' on reload
  6202. gitk: Remove closed file descriptors from $blobdifffd
  6203. gitk: Turn off undo manager in the text widget
  6204. gitk: Fix Japanese translation for "marked commit"
  6205. gitk: Fix missing commits when using -S or -G
  6206. gitk: Use explicit RGB green instead of "lime"
  6207. gitk: Add Portuguese translation
  6208. gitk: Makefile: create install bin directory
  6209. gitk: Include commit title in branch dialog
  6210. gitk: Allow checking out a remote branch
  6211. gitk: Add a 'rename' option to the branch context menu
  6212.  
  6213. gitk: Remove translated message from comments
  6214.  
  6215. "make update-po" fails because a previously untranslated string
  6216. has now been translated:
  6217.  
  6218. Updating po/sv.po
  6219. po/sv.po:1388: duplicate message definition...
  6220. po/sv.po:380: ...this is the location of the first definition
  6221.  
  6222. Remove the duplicate message definition.
  6223.  
  6224. Reported-by: Junio C Hamano <gitster@pobox.com>
  6225. Signed-off-by: David Aguilar <davvid@gmail.com>
  6226. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  6227.  
  6228. builtin/verify-tag: add --format to verify-tag
  6229.  
  6230. Callers of verify-tag may want to cross-check the tagname from refs/tags
  6231. with the tagname from the tag object header upon GPG verification. This
  6232. is to avoid tag refs that point to an incorrect object.
  6233.  
  6234. Add a --format parameter to git verify-tag to print the formatted tag
  6235. object header in addition to or instead of the --verbose or --raw GPG
  6236. verification output.
  6237.  
  6238. Signed-off-by: Santiago Torres <santiago@nyu.edu>
  6239. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6240.  
  6241. ref-filter: add function to print single ref_array_item
  6242.  
  6243. ref-filter functions are useful for printing git object information
  6244. using a format specifier. However, some other modules may not want to use
  6245. this functionality on a ref-array but only print a single item.
  6246.  
  6247. Expose a pretty_print_ref function to create, pretty print and free
  6248. individual ref-items.
  6249.  
  6250. Signed-off-by: Lukas Puehringer <luk.puehringer@gmail.com>
  6251. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6252.  
  6253. gpg-interface, tag: add GPG_VERIFY_OMIT_STATUS flag
  6254.  
  6255. Functions that print git object information may require that the
  6256. gpg-interface functions be silent. Add GPG_VERIFY_OMIT_STATUS flag and
  6257. prevent print_signature_buffer from being called if flag is set.
  6258.  
  6259. Signed-off-by: Lukas Puehringer <luk.puehringer@gmail.com>
  6260. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6261.  
  6262. RelNotes: drop merge-later comments for maint
  6263.  
  6264. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6265.  
  6266. Merge branch 'maint'
  6267.  
  6268. Almost ready for 2.11.1
  6269.  
  6270. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6271.  
  6272. Merge branch 'mm/gc-safety-doc' into maint
  6273.  
  6274. Doc update.
  6275.  
  6276. * mm/gc-safety-doc:
  6277. git-gc.txt: expand discussion of races with other processes
  6278.  
  6279. Merge branch 'mm/push-social-engineering-attack-doc' into maint
  6280.  
  6281. Doc update on fetching and pushing.
  6282.  
  6283. * mm/push-social-engineering-attack-doc:
  6284. doc: mention transfer data leaks in more places
  6285.  
  6286. Merge branch 'jt/fetch-no-redundant-tag-fetch-map' into maint
  6287.  
  6288. Code cleanup to avoid using redundant refspecs while fetching with
  6289. the --tags option.
  6290.  
  6291. * jt/fetch-no-redundant-tag-fetch-map:
  6292. fetch: do not redundantly calculate tag refmap
  6293.  
  6294. Merge branch 'ls/filter-process' into maint
  6295.  
  6296. Doc update.
  6297.  
  6298. * ls/filter-process:
  6299. t0021: fix flaky test
  6300. docs: warn about possible '=' in clean/smudge filter process values
  6301.  
  6302. Merge branch 'kh/tutorial-grammofix' into maint
  6303.  
  6304. * kh/tutorial-grammofix:
  6305. doc: omit needless "for"
  6306. doc: make the intent of sentence clearer
  6307. doc: add verb in front of command to run
  6308. doc: add articles (grammar)
  6309.  
  6310. Merge branch 'lr/doc-fix-cet' into maint
  6311.  
  6312. * lr/doc-fix-cet:
  6313. date-formats.txt: Typo fix
  6314.  
  6315. Merge branch 'sb/t3600-cleanup' into maint
  6316.  
  6317. Code cleanup.
  6318.  
  6319. * sb/t3600-cleanup:
  6320. t3600: slightly modernize style
  6321. t3600: remove useless redirect
  6322.  
  6323. Merge branch 'jk/readme-gmane-is-no-more' into maint
  6324.  
  6325. * jk/readme-gmane-is-no-more:
  6326. README: replace gmane link with public-inbox
  6327.  
  6328. Merge branch 'sb/unpack-trees-grammofix' into maint
  6329.  
  6330. * sb/unpack-trees-grammofix:
  6331. unpack-trees: fix grammar for untracked files in directories
  6332.  
  6333. Merge branch 'ls/t0021-fixup' into maint
  6334.  
  6335. * ls/t0021-fixup:
  6336. t0021: minor filter process test cleanup
  6337.  
  6338. Merge branch 'ak/lazy-prereq-mktemp' into maint
  6339.  
  6340. Test code clean-up.
  6341.  
  6342. * ak/lazy-prereq-mktemp:
  6343. t7610: clean up foo.XXXXXX tmpdir
  6344.  
  6345. Merge branch 'nd/qsort-in-merge-recursive' into maint
  6346.  
  6347. Code simplification.
  6348.  
  6349. * nd/qsort-in-merge-recursive:
  6350. merge-recursive.c: use string_list_sort instead of qsort
  6351.  
  6352. Merge branch 'dt/smart-http-detect-server-going-away' into maint
  6353.  
  6354. When the http server gives an incomplete response to a smart-http
  6355. rpc call, it could lead to client waiting for a full response that
  6356. will never come. Teach the client side to notice this condition
  6357. and abort the transfer.
  6358.  
  6359. An improvement counterproposal has failed.
  6360. cf. <20161114194049.mktpsvgdhex2f4zv@sigill.intra.peff.net>
  6361.  
  6362. * dt/smart-http-detect-server-going-away:
  6363. upload-pack: optionally allow fetching any sha1
  6364. remote-curl: don't hang when a server dies before any output
  6365.  
  6366. Merge branch 'mk/mingw-winansi-ttyname-termination-fix' into maint
  6367.  
  6368. A potential but unlikely buffer overflow in Windows port has been
  6369. fixed.
  6370.  
  6371. * mk/mingw-winansi-ttyname-termination-fix:
  6372. mingw: consider that UNICODE_STRING::Length counts bytes
  6373.  
  6374. Merge branch 'gv/p4-multi-path-commit-fix' into maint
  6375.  
  6376. "git p4" that tracks multile p4 paths imported a single changelist
  6377. that touches files in these multiple paths as one commit, followed
  6378. by many empty commits. This has been fixed.
  6379.  
  6380. * gv/p4-multi-path-commit-fix:
  6381. git-p4: fix multi-path changelist empty commits
  6382.  
  6383. Merge branch 'jk/difftool-in-subdir' into maint
  6384.  
  6385. Even though an fix was attempted in Git 2.9.3 days, but running
  6386. "git difftool --dir-diff" from a subdirectory never worked. This
  6387. has been fixed.
  6388.  
  6389. * jk/difftool-in-subdir:
  6390. difftool: rename variables for consistency
  6391. difftool: chdir as early as possible
  6392. difftool: sanitize $workdir as early as possible
  6393. difftool: fix dir-diff index creation when in a subdirectory
  6394.  
  6395. Merge branch 'ld/p4-compare-dir-vs-symlink' into maint
  6396.  
  6397. "git p4" misbehaved when swapping a directory and a symbolic link.
  6398.  
  6399. * ld/p4-compare-dir-vs-symlink:
  6400. git-p4: avoid crash adding symlinked directory
  6401.  
  6402. Merge branch 'jc/push-default-explicit' into maint
  6403.  
  6404. A lazy "git push" without refspec did not internally use a fully
  6405. specified refspec to perform 'current', 'simple', or 'upstream'
  6406. push, causing unnecessary "ambiguous ref" errors.
  6407.  
  6408. * jc/push-default-explicit:
  6409. push: test pushing ambiguously named branches
  6410. push: do not use potentially ambiguous default refspec
  6411.  
  6412. Merge branch 'jt/mailinfo-fold-in-body-headers' into maint
  6413.  
  6414. Fix for NDEBUG builds.
  6415.  
  6416. * jt/mailinfo-fold-in-body-headers:
  6417. mailinfo.c: move side-effects outside of assert
  6418.  
  6419. Merge branch 'jk/index-pack-wo-repo-from-stdin' into maint
  6420.  
  6421. "git index-pack --stdin" needs an access to an existing repository,
  6422. but "git index-pack file.pack" to generate an .idx file that
  6423. corresponds to a packfile does not.
  6424.  
  6425. * jk/index-pack-wo-repo-from-stdin:
  6426. index-pack: skip collision check when not in repository
  6427. t: use nongit() function where applicable
  6428. index-pack: complain when --stdin is used outside of a repo
  6429. t5000: extract nongit function to test-lib-functions.sh
  6430.  
  6431. Merge branch 'jk/parseopt-usage-msg-opt' into maint
  6432.  
  6433. The function usage_msg_opt() has been updated to say "fatal:"
  6434. before the custom message programs give, when they want to die
  6435. with a message about wrong command line options followed by the
  6436. standard usage string.
  6437.  
  6438. * jk/parseopt-usage-msg-opt:
  6439. parse-options: print "fatal:" before usage_msg_opt()
  6440.  
  6441. Merge branch 'jk/quote-env-path-list-component' into maint
  6442.  
  6443. A recent update to receive-pack to make it easier to drop garbage
  6444. objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot
  6445. have a pathname with a colon in it (no surprise!), and this in turn
  6446. made it impossible to push into a repository at such a path. This
  6447. has been fixed by introducing a quoting mechanism used when
  6448. appending such a path to the colon-separated list.
  6449.  
  6450. * jk/quote-env-path-list-component:
  6451. t5615-alternate-env: double-quotes in file names do not work on Windows
  6452. t5547-push-quarantine: run the path separator test on Windows, too
  6453. tmp-objdir: quote paths we add to alternates
  6454. alternates: accept double-quoted paths
  6455.  
  6456. Merge branch 'nd/shallow-fixup' into maint
  6457.  
  6458. Code cleanup in shallow boundary computation.
  6459.  
  6460. * nd/shallow-fixup:
  6461. shallow.c: remove useless code
  6462. shallow.c: bit manipulation tweaks
  6463. shallow.c: avoid theoretical pointer wrap-around
  6464. shallow.c: make paint_alloc slightly more robust
  6465. shallow.c: stop abusing COMMIT_SLAB_SIZE for paint_info's memory pools
  6466. shallow.c: rename fields in paint_info to better express their purposes
  6467.  
  6468. Merge branch 'sb/sequencer-abort-safety' into maint
  6469.  
  6470. Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
  6471. to where cherry-pick started while picking multiple changes, when
  6472. the cherry-pick stopped to ask for help from the user, and the user
  6473. did "git reset --hard" to a different commit in order to re-attempt
  6474. the operation.
  6475.  
  6476. * sb/sequencer-abort-safety:
  6477. Revert "sequencer: remove useless get_dir() function"
  6478. sequencer: remove useless get_dir() function
  6479. sequencer: make sequencer abort safer
  6480. t3510: test that cherry-pick --abort does not unsafely change HEAD
  6481. am: change safe_to_abort()'s not rewinding error into a warning
  6482. am: fix filename in safe_to_abort() error message
  6483.  
  6484. Merge branch 'da/mergetool-xxdiff-hotkey' into maint
  6485.  
  6486. The way to specify hotkeys to "xxdiff" that is used by "git
  6487. mergetool" has been modernized to match recent versions of xxdiff.
  6488.  
  6489. * da/mergetool-xxdiff-hotkey:
  6490. mergetools: fix xxdiff hotkeys
  6491.  
  6492. Merge branch 'jc/pull-rebase-ff' into maint
  6493.  
  6494. "git pull --rebase", when there is no new commits on our side since
  6495. we forked from the upstream, should be able to fast-forward without
  6496. invoking "git rebase", but it didn't.
  6497.  
  6498. * jc/pull-rebase-ff:
  6499. pull: fast-forward "pull --rebase=true"
  6500.  
  6501. Merge branch 'js/normalize-path-copy-ceil' into maint
  6502.  
  6503. A pathname that begins with "//" or "\\" on Windows is special but
  6504. path normalization logic was unaware of it.
  6505.  
  6506. * js/normalize-path-copy-ceil:
  6507. normalize_path_copy(): fix pushing to //server/share/dir on Windows
  6508.  
  6509. Merge branch 'ak/commit-only-allow-empty' into maint
  6510.  
  6511. "git commit --allow-empty --only" (no pathspec) with dirty index
  6512. ought to be an acceptable way to create a new commit that does not
  6513. change any paths, but it was forbidden, perhaps because nobody
  6514. needed it so far.
  6515.  
  6516. * ak/commit-only-allow-empty:
  6517. commit: remove 'Clever' message for --only --amend
  6518. commit: make --only --allow-empty work without paths
  6519.  
  6520. Merge branch 'da/difftool-dir-diff-fix' into maint
  6521.  
  6522. "git difftool --dir-diff" had a minor regression when started from
  6523. a subdirectory, which has been fixed.
  6524.  
  6525. * da/difftool-dir-diff-fix:
  6526. difftool: fix dir-diff index creation when in a subdirectory
  6527.  
  6528. Merge branch 'jb/diff-no-index-no-abbrev' into maint
  6529.  
  6530. "git diff --no-index" did not take "--no-abbrev" option.
  6531.  
  6532. * jb/diff-no-index-no-abbrev:
  6533. diff: handle --no-abbrev in no-index case
  6534.  
  6535. Merge branch 'jk/stash-disable-renames-internally' into maint
  6536.  
  6537. When diff.renames configuration is on (and with Git 2.9 and later,
  6538. it is enabled by default, which made it worse), "git stash"
  6539. misbehaved if a file is removed and another file with a very
  6540. similar content is added.
  6541.  
  6542. * jk/stash-disable-renames-internally:
  6543. stash: prefer plumbing over git-diff
  6544.  
  6545. Merge branch 'jk/http-walker-limit-redirect' into maint
  6546.  
  6547. Update the error messages from the dumb-http client when it fails
  6548. to obtain loose objects; we used to give sensible error message
  6549. only upon 404 but we now forbid unexpected redirects that needs to
  6550. be reported with something sensible.
  6551.  
  6552. * jk/http-walker-limit-redirect:
  6553. http-walker: complain about non-404 loose object errors
  6554. http: treat http-alternates like redirects
  6555. http: make redirects more obvious
  6556. remote-curl: rename shadowed options variable
  6557. http: always update the base URL for redirects
  6558. http: simplify update_url_from_redirect
  6559.  
  6560. Merge branch 'jc/renormalize-merge-kill-safer-crlf' into maint
  6561.  
  6562. Fix a corner case in merge-recursive regression that crept in
  6563. during 2.10 development cycle.
  6564.  
  6565. * jc/renormalize-merge-kill-safer-crlf:
  6566. convert: git cherry-pick -Xrenormalize did not work
  6567. merge-recursive: handle NULL in add_cacheinfo() correctly
  6568. cherry-pick: demonstrate a segmentation fault
  6569.  
  6570. Merge branch 'ls/p4-empty-file-on-lfs' into maint
  6571.  
  6572. "git p4" LFS support was broken when LFS stores an empty blob.
  6573.  
  6574. * ls/p4-empty-file-on-lfs:
  6575. git-p4: fix empty file processing for large file system backend GitLFS
  6576.  
  6577. Merge branch 'da/mergetool-trust-exit-code' into maint
  6578.  
  6579. mergetool.<tool>.trustExitCode configuration variable did not apply
  6580. to built-in tools, but now it does.
  6581.  
  6582. * da/mergetool-trust-exit-code:
  6583. mergetools/vimdiff: trust Vim's exit code
  6584. mergetool: honor mergetool.$tool.trustExitCode for built-in tools
  6585.  
  6586. Merge branch 'nd/worktree-list-fixup' into maint
  6587.  
  6588. The output from "git worktree list" was made in readdir() order,
  6589. and was unstable.
  6590.  
  6591. * nd/worktree-list-fixup:
  6592. worktree list: keep the list sorted
  6593. worktree.c: get_worktrees() takes a new flag argument
  6594. get_worktrees() must return main worktree as first item even on error
  6595. worktree: reorder an if statement
  6596. worktree.c: zero new 'struct worktree' on allocation
  6597.  
  6598. Merge branch 'bw/push-dry-run' into maint
  6599.  
  6600. "git push --dry-run --recurse-submodule=on-demand" wasn't
  6601. "--dry-run" in the submodules.
  6602.  
  6603. * bw/push-dry-run:
  6604. push: fix --dry-run to not push submodules
  6605. push: --dry-run updates submodules when --recurse-submodules=on-demand
  6606.  
  6607. Merge branch 'hv/submodule-not-yet-pushed-fix' into maint
  6608.  
  6609. The code in "git push" to compute if any commit being pushed in the
  6610. superproject binds a commit in a submodule that hasn't been pushed
  6611. out was overly inefficient, making it unusable even for a small
  6612. project that does not have any submodule but have a reasonable
  6613. number of refs.
  6614.  
  6615. * hv/submodule-not-yet-pushed-fix:
  6616. submodule_needs_pushing(): explain the behaviour when we cannot answer
  6617. batch check whether submodule needs pushing into one call
  6618. serialize collection of refs that contain submodule changes
  6619. serialize collection of changed submodules
  6620.  
  6621. Merge branch 'dt/empty-submodule-in-merge' into maint
  6622.  
  6623. An empty directory in a working tree that can simply be nuked used
  6624. to interfere while merging or cherry-picking a change to create a
  6625. submodule directory there, which has been fixed..
  6626.  
  6627. * dt/empty-submodule-in-merge:
  6628. submodules: allow empty working-tree dirs in merge/cherry-pick
  6629.  
  6630. Merge branch 'jk/rev-parse-symbolic-parents-fix' into maint
  6631.  
  6632. "git rev-parse --symbolic" failed with a more recent notation like
  6633. "HEAD^-1" and "HEAD^!".
  6634.  
  6635. * jk/rev-parse-symbolic-parents-fix:
  6636. rev-parse: fix parent shorthands with --symbolic
  6637.  
  6638. Merge branch 'js/mingw-isatty' into maint
  6639.  
  6640. Update the isatty() emulation for Windows by updating the previous
  6641. hack that depended on internals of (older) MSVC runtime.
  6642.  
  6643. * js/mingw-isatty:
  6644. mingw: replace isatty() hack
  6645. mingw: fix colourization on Cygwin pseudo terminals
  6646. mingw: adjust is_console() to work with stdin
  6647. mingw: intercept isatty() to handle /dev/null as Git expects it
  6648.  
  6649. Merge branch 'bb/unicode-9.0' into maint
  6650.  
  6651. The character width table has been updated to match Unicode 9.0
  6652.  
  6653. * bb/unicode-9.0:
  6654. unicode_width.h: update the width tables to Unicode 9.0
  6655. update_unicode.sh: remove the plane filter
  6656. update_unicode.sh: automatically download newer definition files
  6657. update_unicode.sh: pin the uniset repo to a known good commit
  6658. update_unicode.sh: remove an unnecessary subshell level
  6659. update_unicode.sh: move it into contrib/update-unicode
  6660.  
  6661. Merge branch 'ls/travis-update-p4-and-lfs' into maint
  6662.  
  6663. The default Travis-CI configuration specifies newer P4 and GitLFS.
  6664.  
  6665. * ls/travis-update-p4-and-lfs:
  6666. travis-ci: update P4 to 16.2 and GitLFS to 1.5.2 in Linux build
  6667.  
  6668. CodingGuidelines: clarify multi-line brace style
  6669.  
  6670. There are some "gray areas" around when to omit braces from
  6671. a conditional or loop body. Since that seems to have
  6672. resulted in some arguments, let's be a little more clear
  6673. about our preferred style.
  6674.  
  6675. Signed-off-by: Jeff King <peff@peff.net>
  6676. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6677.  
  6678. fsck: check HAS_OBJ more consistently
  6679.  
  6680. There are two spots that call lookup_object() and assume
  6681. that a non-NULL result means we have the object:
  6682.  
  6683. 1. When we're checking the objects given to us by the user
  6684. on the command line.
  6685.  
  6686. 2. When we're checking if a reflog entry is valid.
  6687.  
  6688. This generally follows fsck's mental model that we will have
  6689. looked at and loaded a "struct object" for each object in
  6690. the repository. But it misses one case: if another object
  6691. _mentioned_ an object, but we didn't actually parse it or
  6692. verify that it exists, it will still have a struct.
  6693.  
  6694. It's not clear if this is a triggerable bug or not.
  6695. Certainly the later parts of the reachability check need to
  6696. be careful of this, and do so by checking the HAS_OBJ flag.
  6697. But both of these steps happen before we start traversing,
  6698. so probably we won't have followed any links yet. Still,
  6699. it's easy enough to be defensive here.
  6700.  
  6701. Signed-off-by: Jeff King <peff@peff.net>
  6702. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6703.  
  6704. fsck: do not fallback "git fsck <bogus>" to "git fsck"
  6705.  
  6706. Since fsck tries to continue as much as it can after seeing
  6707. an error, we still do the reachability check even if some
  6708. heads we were given on the command-line are bogus. But if
  6709. _none_ of the heads is is valid, we fallback to checking all
  6710. refs and the index, which is not what the user asked for at
  6711. all.
  6712.  
  6713. Instead of checking "heads", the number of successful heads
  6714. we got, check "argc" (which we know only has non-options in
  6715. it, because parse_options removed the others).
  6716.  
  6717. Signed-off-by: Jeff King <peff@peff.net>
  6718. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6719.  
  6720. fsck: tighten error-checks of "git fsck <head>"
  6721.  
  6722. Instead of checking reachability from the refs, you can ask
  6723. fsck to check from a particular set of heads. However, the
  6724. error checking here is quite lax. In particular:
  6725.  
  6726. 1. It claims lookup_object() will report an error, which
  6727. is not true. It only does a hash lookup, and the user
  6728. has no clue that their argument was skipped.
  6729.  
  6730. 2. When either the name or sha1 cannot be resolved, we
  6731. continue to exit with a successful error code, even
  6732. though we didn't check what the user asked us to.
  6733.  
  6734. This patch fixes both of these cases.
  6735.  
  6736. Signed-off-by: Jeff King <peff@peff.net>
  6737. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6738.  
  6739. fsck: prepare dummy objects for --connectivity-check
  6740.  
  6741. Normally fsck makes a pass over all objects to check their
  6742. integrity, and then follows up with a reachability check to
  6743. make sure we have all of the referenced objects (and to know
  6744. which ones are dangling). The latter checks for the HAS_OBJ
  6745. flag in obj->flags to see if we found the object in the
  6746. first pass.
  6747.  
  6748. Commit 02976bf85 (fsck: introduce `git fsck --connectivity-only`,
  6749. 2015-06-22) taught fsck to skip the initial pass, and to
  6750. fallback to has_sha1_file() instead of the HAS_OBJ check.
  6751.  
  6752. However, it converted only one HAS_OBJ check to use
  6753. has_sha1_file(). But there are many other places in
  6754. builtin/fsck.c that assume that the flag is set (or that
  6755. lookup_object() will return an object at all). This leads to
  6756. several bugs with --connectivity-only:
  6757.  
  6758. 1. mark_object() will not queue objects for examination,
  6759. so recursively following links from commits to trees,
  6760. etc, did nothing. I.e., we were checking the
  6761. reachability of hardly anything at all.
  6762.  
  6763. 2. When a set of heads is given on the command-line, we
  6764. use lookup_object() to see if they exist. But without
  6765. the initial pass, we assume nothing exists.
  6766.  
  6767. 3. When loading reflog entries, we do a similar
  6768. lookup_object() check, and complain that the reflog is
  6769. broken if the object doesn't exist in our hash.
  6770.  
  6771. So in short, --connectivity-only is broken pretty badly, and
  6772. will claim that your repository is fine when it's not.
  6773. Presumably nobody noticed for a few reasons.
  6774.  
  6775. One is that the embedded test does not actually test the
  6776. recursive nature of the reachability check. All of the
  6777. missing objects are still in the index, and we directly
  6778. check items from the index. This patch modifies the test to
  6779. delete the index, which shows off breakage (1).
  6780.  
  6781. Another is that --connectivity-only just skips the initial
  6782. pass for loose objects. So on a real repository, the packed
  6783. objects were still checked correctly. But on the flipside,
  6784. it means that "git fsck --connectivity-only" still checks
  6785. the sha1 of all of the packed objects, nullifying its
  6786. original purpose of being a faster git-fsck.
  6787.  
  6788. And of course the final problem is that the bug only shows
  6789. up when there _is_ corruption, which is rare. So anybody
  6790. running "git fsck --connectivity-only" proactively would
  6791. assume it was being thorough, when it was not.
  6792.  
  6793. One possibility for fixing this is to find all of the spots
  6794. that rely on HAS_OBJ and tweak them for the connectivity-only
  6795. case. But besides the risk that we might miss a spot (and I
  6796. found three already, corresponding to the three bugs above),
  6797. there are other parts of fsck that _can't_ work without a
  6798. full list of objects. E.g., the list of dangling objects.
  6799.  
  6800. Instead, let's make the connectivity-only case look more
  6801. like the normal case. Rather than skip the initial pass
  6802. completely, we'll do an abbreviated one that sets up the
  6803. HAS_OBJ flag for each object, without actually loading the
  6804. object data.
  6805.  
  6806. That's simple and fast, and we don't have to care about the
  6807. connectivity_only flag in the rest of the code at all.
  6808. While we're at it, let's make sure we treat loose and packed
  6809. objects the same (i.e., setting up dummy objects for both
  6810. and skipping the actual sha1 check). That makes the
  6811. connectivity-only check actually fast on a real repo (40
  6812. seconds versus 180 seconds on my copy of linux.git).
  6813.  
  6814. Signed-off-by: Jeff King <peff@peff.net>
  6815. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6816.  
  6817. sequencer (rebase -i): write out the final message
  6818.  
  6819. The shell script version of the interactive rebase has a very specific
  6820. final message. Teach the sequencer to print the same.
  6821.  
  6822. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6823. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6824.  
  6825. sequencer (rebase -i): write the progress into files
  6826.  
  6827. For the benefit of e.g. the shell prompt, the interactive rebase not
  6828. only displays the progress for the user to see, but also writes it into
  6829. the msgnum/end files in the state directory.
  6830.  
  6831. Teach the sequencer this new trick.
  6832.  
  6833. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6834. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6835.  
  6836. sequencer (rebase -i): show the progress
  6837.  
  6838. The interactive rebase keeps the user informed about its progress.
  6839. If the sequencer wants to do the grunt work of the interactive
  6840. rebase, it also needs to show that progress.
  6841.  
  6842. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6843. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6844.  
  6845. sequencer (rebase -i): suggest --edit-todo upon unknown command
  6846.  
  6847. This is the same behavior as known from `git rebase -i`.
  6848.  
  6849. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6850. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6851.  
  6852. sequencer (rebase -i): show only failed cherry-picks' output
  6853.  
  6854. This is the behavior of the shell script version of the interactive
  6855. rebase, by using the `output` function defined in `git-rebase.sh`.
  6856.  
  6857. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6858. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6859.  
  6860. sequencer (rebase -i): show only failed `git commit`'s output
  6861.  
  6862. This is the behavior of the shell script version of the interactive
  6863. rebase, by using the `output` function defined in `git-rebase.sh`.
  6864.  
  6865. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6866. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6867.  
  6868. sequencer: use run_command() directly
  6869.  
  6870. Instead of using the convenience function run_command_v_opt_cd_env(), we
  6871. now use the run_command() function. The former function is simply a
  6872. wrapper of the latter, trying to make it more convenient to use.
  6873.  
  6874. However, we already have to construct the argv and the env parameters,
  6875. and we will need even finer control e.g. over the output of the command,
  6876. so let's just stop using the convenience function.
  6877.  
  6878. Based on patches and suggestions by Johannes Sixt and Jeff King.
  6879.  
  6880. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6881. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6882.  
  6883. sequencer: update reading author-script
  6884.  
  6885. Rather than abusing a strbuf to come up with an environment block,
  6886. let's just use the argv_array structure which serves the same
  6887. purpose much better.
  6888.  
  6889. While at it, rename the function to reflect the fact that it does
  6890. not really care exactly what environment variables are defined in
  6891. said file.
  6892.  
  6893. Suggested-by: Jeff King <peff@peff.net>
  6894. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6895. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6896.  
  6897. difftool: add a skeleton for the upcoming builtin
  6898.  
  6899. This adds a builtin difftool that still falls back to the legacy Perl
  6900. version, which has been renamed to `legacy-difftool`.
  6901.  
  6902. The idea is that the new, experimental, builtin difftool immediately hands
  6903. off to the legacy difftool for now, unless the config variable
  6904. difftool.useBuiltin is set to true.
  6905.  
  6906. This feature flag will be used in the upcoming Git for Windows v2.11.0
  6907. release, to allow early testers to opt-in to use the builtin difftool and
  6908. flesh out any bugs.
  6909.  
  6910. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  6911. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6912.  
  6913. fsck: report trees as dangling
  6914.  
  6915. After checking connectivity, fsck looks through the list of
  6916. any objects we've seen mentioned, and reports unreachable
  6917. and un-"used" ones as dangling. However, it skips any object
  6918. which is not marked as "parsed", as that is an object that
  6919. we _don't_ have (but that somebody mentioned).
  6920.  
  6921. Since 6e454b9a3 (clear parsed flag when we free tree
  6922. buffers, 2013-06-05), that flag can't be relied on, and the
  6923. correct method is to check the HAS_OBJ flag. The cleanup in
  6924. that commit missed this callsite, though. As a result, we
  6925. would generally fail to report dangling trees.
  6926.  
  6927. We never noticed because there were no tests in this area
  6928. (for trees or otherwise). Let's add some.
  6929.  
  6930. Signed-off-by: Jeff King <peff@peff.net>
  6931. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6932.  
  6933. t1450: clean up sub-objects in duplicate-entry test
  6934.  
  6935. This test creates a multi-level set of trees, but its
  6936. cleanup routine only removes the top-level tree. After the
  6937. test finishes, the inner tree and the blob it points to
  6938. remain, making the inner tree dangling.
  6939.  
  6940. A later test ("cleaned up") verifies that we've removed any
  6941. cruft and "git fsck" output is clean. This passes only
  6942. because of a bug in git-fsck which fails to notice dangling
  6943. trees.
  6944.  
  6945. In preparation for fixing the bug, let's teach this earlier
  6946. test to clean up after itself correctly. We have to remove
  6947. the inner tree (and therefore the blob, too, which becomes
  6948. dangling after removing that tree).
  6949.  
  6950. Since the setup code happens inside a subshell, we can't
  6951. just set a variable for each object. However, we can stuff
  6952. all of the sha1s into the $T output variable, which is not
  6953. used for anything except cleanup.
  6954.  
  6955. Signed-off-by: Jeff King <peff@peff.net>
  6956. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6957.  
  6958. diff: document the format of the -O (diff.orderFile) file
  6959.  
  6960. Signed-off-by: Richard Hansen <hansenr@google.com>
  6961. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6962.  
  6963. diff: document behavior of relative diff.orderFile
  6964.  
  6965. Document that a relative pathname for diff.orderFile is interpreted as
  6966. relative to the top-level work directory.
  6967.  
  6968. Signed-off-by: Richard Hansen <hansenr@google.com>
  6969. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6970.  
  6971. request-pull: drop old USAGE stuff
  6972.  
  6973. request-pull uses OPTIONS_SPEC, so no need for (meanwhile incomplete)
  6974. USAGE and LONG_USAGE anymore.
  6975.  
  6976. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
  6977. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6978.  
  6979. xdiff -W: relax end-of-file function detection
  6980.  
  6981. When adding a new function to the end of a file, it's enough to know
  6982. that 1) the addition is at the end of the file; and 2) there is a
  6983. function _somewhere_ in there.
  6984.  
  6985. If we had simply been changing the end of an existing function, then we
  6986. would also be deleting something from the old version.
  6987.  
  6988. This fixes the case where we add e.g.
  6989.  
  6990. // Begin of dummy
  6991. static int dummy(void)
  6992. {
  6993. }
  6994.  
  6995. to the end of the file.
  6996.  
  6997. Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
  6998. Acked-by: René Scharfe <l.s.r@web.de>
  6999. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7000.  
  7001. fsck: detect trailing garbage in all object types
  7002.  
  7003. When a loose tree or commit is read by fsck (or any git
  7004. program), unpack_sha1_rest() checks whether there is extra
  7005. cruft at the end of the object file, after the zlib data.
  7006. Blobs that are streamed, however, do not have this check.
  7007.  
  7008. For normal git operations, it's not a big deal. We know the
  7009. sha1 and size checked out, so we have the object bytes we
  7010. wanted. The trailing garbage doesn't affect what we're
  7011. trying to do.
  7012.  
  7013. But since the point of fsck is to find corruption or other
  7014. problems, it should be more thorough. This patch teaches its
  7015. loose-sha1 reader to detect extra bytes after the zlib
  7016. stream and complain.
  7017.  
  7018. Signed-off-by: Jeff King <peff@peff.net>
  7019. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7020.  
  7021. fsck: parse loose object paths directly
  7022.  
  7023. When we iterate over the list of loose objects to check, we
  7024. get the actual path of each object. But we then throw it
  7025. away and pass just the sha1 to fsck_sha1(), which will do a
  7026. fresh lookup. Usually it would find the same object, but it
  7027. may not if an object exists both as a loose and a packed
  7028. object. We may end up checking the packed object twice, and
  7029. never look at the loose one.
  7030.  
  7031. In practice this isn't too terrible, because if fsck doesn't
  7032. complain, it means you have at least one good copy. But
  7033. since the point of fsck is to look for corruption, we should
  7034. be thorough.
  7035.  
  7036. The new read_loose_object() interface can help us get the
  7037. data from disk, and then we replace parse_object() with
  7038. parse_object_buffer(). As a bonus, our error messages now
  7039. mention the path to a corrupted object, which should make it
  7040. easier to track down errors when they do happen.
  7041.  
  7042. Signed-off-by: Jeff King <peff@peff.net>
  7043. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7044.  
  7045. sha1_file: add read_loose_object() function
  7046.  
  7047. It's surprisingly hard to ask the sha1_file code to open a
  7048. _specific_ incarnation of a loose object. Most of the
  7049. functions take a sha1, and loop over the various object
  7050. types (packed versus loose) and locations (local versus
  7051. alternates) at a low level.
  7052.  
  7053. However, some tools like fsck need to look at a specific
  7054. file. This patch gives them a function they can use to open
  7055. the loose object at a given path.
  7056.  
  7057. The implementation unfortunately ends up repeating bits of
  7058. related functions, but there's not a good way around it
  7059. without some major refactoring of the whole sha1_file stack.
  7060. We need to mmap the specific file, then partially read the
  7061. zlib stream to know whether we're streaming or not, and then
  7062. finally either stream it or copy the data to a buffer.
  7063.  
  7064. We can do that by assembling some of the more arcane
  7065. internal sha1_file functions, but we end up having to
  7066. essentially reimplement unpack_sha1_file(), along with the
  7067. streaming bits of check_sha1_signature().
  7068.  
  7069. Still, most of the ugliness is contained in the new
  7070. function, and the interface is clean enough that it may be
  7071. reusable (though it seems unlikely anything but git-fsck
  7072. would care about opening a specific file).
  7073.  
  7074. Signed-off-by: Jeff King <peff@peff.net>
  7075. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7076.  
  7077. t1450: test fsck of packed objects
  7078.  
  7079. The code paths in fsck for packed and loose objects are
  7080. quite different, and it is not immediately obvious that the
  7081. packed case behaves well. In particular:
  7082.  
  7083. 1. The fsck_loose() function always returns "0" to tell the
  7084. iterator to keep checking more objects. Whereas
  7085. fsck_obj_buffer() (which handles packed objects)
  7086. returns -1. This is OK, because the callback machinery
  7087. for verify_pack() does not stop when it sees a non-zero
  7088. return.
  7089.  
  7090. 2. The fsck_loose() function sets the ERROR_OBJECT bit
  7091. when fsck_obj() fails, whereas fsck_obj_buffer() sets it
  7092. only when it sees a corrupt object. This turns out not
  7093. to matter. We don't actually do anything with this bit
  7094. except exit the program with a non-zero code, and that
  7095. is handled already by the non-zero return from the
  7096. function.
  7097.  
  7098. So there are no bugs here, but it was certainly confusing to
  7099. me. And we do not test either of the properties in t1450
  7100. (neither that a non-corruption error will caused a non-zero
  7101. exit for a packed object, nor that we keep going after
  7102. seeing the first error). Let's test both of those
  7103. conditions, so that we'll notice if any of those assumptions
  7104. becomes invalid.
  7105.  
  7106. Signed-off-by: Jeff King <peff@peff.net>
  7107. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7108.  
  7109. sha1_file: fix error message for alternate objects
  7110.  
  7111. When we fail to open a corrupt loose object, we report an
  7112. error and mention the filename via sha1_file_name().
  7113. However, that function will always give us a path in the
  7114. local repository, whereas the corrupt object may have come
  7115. from an alternate. The result is a very misleading error
  7116. message.
  7117.  
  7118. Teach the open_sha1_file() and stat_sha1_file() helpers to
  7119. pass back the path they found, so that we can report it
  7120. correctly.
  7121.  
  7122. Note that the pointers we return go to static storage (e.g.,
  7123. from sha1_file_name()), which is slightly dangerous.
  7124. However, these helpers are static local helpers, and the
  7125. names are used for immediately generating error messages.
  7126. The simplicity is an acceptable tradeoff for the danger.
  7127.  
  7128. Signed-off-by: Jeff King <peff@peff.net>
  7129. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7130.  
  7131. t1450: refactor loose-object removal
  7132.  
  7133. Commit 90cf590f5 (fsck: optionally show more helpful info
  7134. for broken links, 2016-07-17) added a remove_loose_object()
  7135. helper, but we already had a remove_object() helper that did
  7136. the same thing. Let's combine these into one.
  7137.  
  7138. The implementations had a few subtle differences, so I've
  7139. tried to take the best of both:
  7140.  
  7141. - the original used "sed", but the newer version avoids
  7142. spawning an extra process
  7143.  
  7144. - the original processed "$*", which was nonsense, as it
  7145. assumed only a single sha1. Use "$1" to make that more
  7146. clear.
  7147.  
  7148. - the newer version ran an extra rev-parse, but it was not
  7149. necessary; it's sole caller already converted the
  7150. argument into a raw sha1
  7151.  
  7152. - the original used "rm -f", whereas the new one uses
  7153. "rm". The latter is better because it may notice a bug
  7154. or other unexpected failure in the test. (The original
  7155. does check that the object exists before we remove it,
  7156. which is good, but that's a subset of the possible
  7157. unexpected conditions).
  7158.  
  7159. Signed-off-by: Jeff King <peff@peff.net>
  7160. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7161.  
  7162. doc: git-gui browser does not default to HEAD
  7163.  
  7164. 37cd4f7 ("Document git-gui, git-citool as mainporcelain manual pages",
  7165. 2007-06-21) documented the default, but was shortly followed by c52c945
  7166. ("git-gui: Allow blame/browser subcommands on bare repositories",
  7167. 2007-07-17) which, it would appear, as a side effect, removed that default.
  7168.  
  7169. Finally document that change.
  7170.  
  7171. Signed-off-by: Philip Oakley <philipoakley@iee.org>
  7172. Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  7173. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7174.  
  7175. doc: gitk: add the upstream repo location
  7176.  
  7177. Match the 'git gui' information regarding the graphical browser
  7178. and its upstream location.
  7179.  
  7180. Signed-off-by: Philip Oakley <philipoakley@iee.org>
  7181. Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  7182. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7183.  
  7184. doc: gitk: remove gitview reference
  7185.  
  7186. contrib/gitview has been removed. Remove the reference.
  7187.  
  7188. Signed-off-by: Philip Oakley <philipoakley@iee.org>
  7189. Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  7190. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7191.  
  7192. lib-submodule-update.sh: reduce use of subshell by using "git -C"
  7193.  
  7194. We write
  7195.  
  7196. (cd <dir> && git <cmd>)
  7197.  
  7198. to avoid
  7199.  
  7200. cd <dir> && git <cmd> && cd ..
  7201.  
  7202. that allows a breakage in one part of the test script to leave the
  7203. entire test process in an unexpected place. Modern version of Git
  7204. allows us to do this more concisely with "git -C <dir> <cmd>".
  7205.  
  7206. Signed-off-by: Stefan Beller <sbeller@google.com>
  7207. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7208.  
  7209. builtin/commit.c: remove the PATH_MAX limitation via dynamic allocation
  7210.  
  7211. Remove the PATH_MAX limitation from the environment setting that
  7212. points to a filename by switching to dynamic allocation.
  7213.  
  7214. As a side effect of this change, we also reduce the snprintf()
  7215. calls, that may silently truncate results if the programmer is not
  7216. careful.
  7217.  
  7218. Helped-by: Junio C Hamano <gitster@pobox.com>
  7219. Helped-by: Jeff King <peff@peff.net>
  7220. Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
  7221. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7222.  
  7223. Documentation/bisect: improve on (bad|new) and (good|bad)
  7224.  
  7225. The following part of the description:
  7226.  
  7227. git bisect (bad|new) [<rev>]
  7228. git bisect (good|old) [<rev>...]
  7229.  
  7230. may be a bit confusing, as a reader may wonder if instead it should be:
  7231.  
  7232. git bisect (bad|good) [<rev>]
  7233. git bisect (old|new) [<rev>...]
  7234.  
  7235. Of course the difference between "[<rev>]" and "[<rev>...]" should hint
  7236. that there is a good reason for the way it is.
  7237.  
  7238. But we can further clarify and complete the description by adding
  7239. "<term-new>" and "<term-old>" to the "bad|new" and "good|old"
  7240. alternatives.
  7241.  
  7242. Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
  7243. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7244.  
  7245. asciidoctor: fix user-manual to be built by `asciidoctor`
  7246.  
  7247. The `user-manual.txt` is designed as a `book` but the `Makefile` wants
  7248. to build it as an `article`. This seems to be a problem when building
  7249. the documentation with `asciidoctor`. Furthermore the parts *Git
  7250. Glossary* and *Appendix B* had no subsections which is not allowed when
  7251. building with `asciidoctor`. So lets add a *dummy* section.
  7252.  
  7253. Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
  7254. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  7255. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7256.  
  7257. submodule update --init: display correct path from submodule
  7258.  
  7259. In the submodule helper we did not correctly handled the display path
  7260. for initializing submodules when both the submodule is inside a
  7261. subdirectory as well as the command being invoked from a subdirectory
  7262. (as viewed from the superproject).
  7263.  
  7264. This was broken in 3604242f080, which was written at a time where
  7265. there was no super-prefix available, so we abused the --prefix option
  7266. for the same purpose and could get only one case right (the call from
  7267. within a subdirectory, not the submodule being in a subdirectory).
  7268.  
  7269. Test-provided-by: David Turner <novalis@novalis.org>
  7270. Signed-off-by: Stefan Beller <sbeller@google.com>
  7271. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7272.  
  7273. submodule update documentation: don't repeat ourselves
  7274.  
  7275. The documentation for the `git submodule update` command, repeats itself
  7276. for each update option, "This is done when <option> is given, or no
  7277. option is given and `submodule.<name>.update` is set to <string>.
  7278.  
  7279. Avoid these repetitive clauses by stating the command line options take
  7280. precedence over configured options.
  7281.  
  7282. Also add 'none' to the list of options instead of mentioning it in the
  7283. following running text and split the list into two parts, one that is
  7284. accessible via the command line and one that is only reachable via the
  7285. configuration variables.
  7286.  
  7287. Signed-off-by: Stefan Beller <sbeller@google.com>
  7288. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7289.  
  7290. submodule documentation: add options to the subcommand
  7291.  
  7292. When reading up on a subcommand of `git submodule <subcommand>`,
  7293. it is convenient to have its options nearby and not just at the
  7294. top of the man page. Add the options to each subcommand.
  7295.  
  7296. While at it, also document the `--checkout` option for `update`.
  7297.  
  7298. Signed-off-by: Stefan Beller <sbeller@google.com>
  7299. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7300.  
  7301. t7411: test lookup of uninitialized submodules
  7302.  
  7303. Sometimes we need to lookup information of uninitialized submodules. Make
  7304. sure that works.
  7305.  
  7306. Signed-off-by: Stefan Beller <sbeller@google.com>
  7307. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7308.  
  7309. t7411: quote URLs
  7310.  
  7311. The variables may contain white spaces, so we need to quote them.
  7312. By not quoting the variables we'd end up passing multiple arguments to
  7313. git config, which doesn't fail for two arguments as value.
  7314.  
  7315. Signed-off-by: Stefan Beller <sbeller@google.com>
  7316. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7317.  
  7318. submodule absorbgitdirs: mention in docstring help
  7319.  
  7320. This part was missing in f6f85861 (submodule: add absorb-git-dir function,
  7321. 2016-12-12).
  7322.  
  7323. Noticed-by: Jonathan Nieder <jrnieder@gmail.com>
  7324. Signed-off-by: Stefan Beller <sbeller@google.com>
  7325. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7326.  
  7327. diff: add interhunk context config option
  7328.  
  7329. The --inter-hunk-context= option was added in commit 6d0e674a5754
  7330. ("diff: add option to show context between close hunks"). This patch
  7331. allows configuring a default for this option.
  7332.  
  7333. Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
  7334. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7335.  
  7336. versioncmp: generalize version sort suffix reordering
  7337.  
  7338. The 'versionsort.prereleaseSuffix' configuration variable, as its name
  7339. suggests, is supposed to only deal with tagnames with prerelease
  7340. suffixes, and allows sorting those prerelease tags in a user-defined
  7341. order before the suffixless main release tag, instead of sorting them
  7342. simply lexicographically.
  7343.  
  7344. However, the previous changes in this series resulted in an
  7345. interesting and useful property of version sort:
  7346.  
  7347. - The empty string as a configured suffix matches all tagnames,
  7348. including tagnames without any suffix, but
  7349.  
  7350. - tagnames containing a "real" configured suffix are still ordered
  7351. according to that real suffix, because any longer suffix takes
  7352. precedence over the empty string.
  7353.  
  7354. Exploiting this property we can easily generalize suffix reordering
  7355. and specify the order of tags with given suffixes not only before but
  7356. even after a main release tag by using the empty suffix to denote the
  7357. position of the main release tag, without any algorithm changes:
  7358.  
  7359. $ git -c versionsort.prereleaseSuffix=-alpha \
  7360. -c versionsort.prereleaseSuffix=-beta \
  7361. -c versionsort.prereleaseSuffix="" \
  7362. -c versionsort.prereleaseSuffix=-gamma \
  7363. -c versionsort.prereleaseSuffix=-delta \
  7364. tag -l --sort=version:refname 'v3.0*'
  7365. v3.0-alpha1
  7366. v3.0-beta1
  7367. v3.0
  7368. v3.0-gamma1
  7369. v3.0-delta1
  7370.  
  7371. Since 'versionsort.prereleaseSuffix' is not a fitting name for a
  7372. configuration variable to control this more general suffix reordering,
  7373. introduce the new variable 'versionsort.suffix'. Still keep the old
  7374. configuration variable name as a deprecated alias, though, to avoid
  7375. suddenly breaking setups already using it. Ignore the old variable if
  7376. both old and new configuration variables are set, but emit a warning
  7377. so users will be aware of it and can fix their configuration. Extend
  7378. the documentation to describe and add a test to check this more
  7379. general behavior.
  7380.  
  7381. Note: since the empty suffix matches all tagnames, tagnames with
  7382. suffixes not included in the configuration are listed together with
  7383. the suffixless main release tag, ordered lexicographically right after
  7384. that, i.e. before tags with suffixes listed in the configuration
  7385. following the empty suffix.
  7386.  
  7387. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  7388. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7389.  
  7390. versioncmp: factor out helper for suffix matching
  7391.  
  7392. As the number of identical steps to be done for both tagnames grows,
  7393. extract them into a helper function, with the additional benefit that
  7394. the conditionals near the end of swap_prereleases() will use more
  7395. meaningful variable names.
  7396.  
  7397. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  7398. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7399.  
  7400. vreport: sanitize ASCII control chars
  7401.  
  7402. Our error() and die() calls may report messages with
  7403. arbitrary data (e.g., filenames or even data from a remote
  7404. server). Let's make it harder to cause confusion with
  7405. mischievous filenames. E.g., try:
  7406.  
  7407. git rev-parse "$(printf "\rfatal: this argument is too sneaky")" --
  7408.  
  7409. or
  7410.  
  7411. git rev-parse "$(printf "\x1b[5mblinky\x1b[0m")" --
  7412.  
  7413. Let's block all ASCII control characters, with the exception
  7414. of TAB and LF. We use both in our own messages (and we are
  7415. necessarily sanitizing the complete output of snprintf here,
  7416. as we do not have access to the individual varargs). And TAB
  7417. and LF are unlikely to cause confusion (you could put
  7418. "\nfatal: sneaky\n" in your filename, but it would at least
  7419. not _cover up_ the message leading to it, unlike "\r").
  7420.  
  7421. We'll replace the characters with a "?", which is similar to
  7422. how "ls" behaves. It might be nice to do something less
  7423. lossy, like converting them to "\x" hex codes. But replacing
  7424. with a single character makes it easy to do in-place and
  7425. without worrying about length limitations. This feature
  7426. should kick in rarely enough that the "?" marks are almost
  7427. never seen.
  7428.  
  7429. We'll leave high-bit characters as-is, as they are likely to
  7430. be UTF-8 (though there may be some Unicode mischief you
  7431. could cause, which may require further patches).
  7432.  
  7433. Signed-off-by: Jeff King <peff@peff.net>
  7434. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7435.  
  7436. Revert "vreportf: avoid intermediate buffer"
  7437.  
  7438. This reverts commit f4c3edc0b156362a92bf9de4f0ec794e90a757fc.
  7439.  
  7440. The purpose of that commit was to let us write errors of
  7441. arbitrary length to stderr by skipping the intermediate
  7442. buffer and sending our varargs straight to fprintf. That
  7443. works, but it comes with a downside: we do not get access to
  7444. the varargs before they are sent to stderr.
  7445.  
  7446. On balance, it's not a good tradeoff. Error messages larger
  7447. than our 4K buffer are quite uncommon, and we've lost the
  7448. ability to make any modifications to the output (e.g., to
  7449. remove non-printable characters).
  7450.  
  7451. The only way to have both would be one of:
  7452.  
  7453. 1. Write into a dynamic buffer. But this is a bad idea for
  7454. a low-level function that may be called when malloc()
  7455. has failed.
  7456.  
  7457. 2. Do our own printf-format varargs parsing. This is too
  7458. complex to be worth the trouble.
  7459.  
  7460. Let's just revert that change and go back to a fixed buffer.
  7461.  
  7462. Signed-off-by: Jeff King <peff@peff.net>
  7463. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7464.  
  7465. index: improve constness for reading blob data
  7466.  
  7467. Improve constness of the index_state parameter to the
  7468. 'read_blob_data_from_index' function.
  7469.  
  7470. Signed-off-by: Brandon Williams <bmwill@google.com>
  7471. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7472.  
  7473. t1001: modernize style
  7474.  
  7475. The preferred style in tests is:
  7476.  
  7477. test_expect_success 'short description then sq to open the body' '
  7478. here comes the test &&
  7479. and chains over many lines &&
  7480. with closing sq on its own line
  7481. '
  7482.  
  7483. Signed-off-by: Stefan Beller <sbeller@google.com>
  7484. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7485.  
  7486. t1000: modernize style
  7487.  
  7488. The preferred style in tests is:
  7489.  
  7490. test_expect_success 'short description then sq to open the body' '
  7491. here comes the test &&
  7492. and chains over many lines &&
  7493. with closing sq on its own line
  7494. '
  7495.  
  7496. Signed-off-by: Stefan Beller <sbeller@google.com>
  7497. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7498.  
  7499. read-tree: use OPT_BOOL instead of OPT_SET_INT
  7500.  
  7501. All occurrences of OPT_SET_INT were setting the value to 1;
  7502. internally OPT_BOOL is just that.
  7503.  
  7504. Signed-off-by: Stefan Beller <sbeller@google.com>
  7505. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7506.  
  7507. t7810: avoid assumption about invalid regex syntax
  7508.  
  7509. A few of the tests want to check that "git grep -P -E" will
  7510. override -P with -E, and vice versa. To do so, we use a
  7511. regex with "\x{..}", which is valid in PCRE but not defined
  7512. by POSIX (for basic or extended regular expressions).
  7513.  
  7514. However, POSIX declares quite a lot of syntax, including
  7515. "\x", as "undefined". That leaves implementations free to
  7516. extend the standard if they choose. At least one, musl libc,
  7517. implements "\x" in the same way as PCRE. Our tests check
  7518. that "-E" complains about "\x", which fails with musl.
  7519.  
  7520. We can fix this by finding some construct which behaves
  7521. reliably on both PCRE and POSIX, but differently in each
  7522. system.
  7523.  
  7524. One such construct is the use of backslash inside brackets.
  7525. In PCRE, "[\d]" interprets "\d" as it would outside the
  7526. brackets, matching a digit. Whereas in POSIX, the backslash
  7527. must be treated literally, and we match either it or a
  7528. literal "d". Moreover, implementations are not free to
  7529. change this according to POSIX, so we should be able to rely
  7530. on it.
  7531.  
  7532. Signed-off-by: Jeff King <peff@peff.net>
  7533. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7534.  
  7535. Fifth batch 2.12
  7536.  
  7537. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7538.  
  7539. Merge branch 'sb/submodule-embed-gitdir'
  7540.  
  7541. A new submodule helper "git submodule embedgitdirs" to make it
  7542. easier to move embedded .git/ directory for submodules in a
  7543. superproject to .git/modules/ (and point the latter with the former
  7544. that is turned into a "gitdir:" file) has been added.
  7545.  
  7546. * sb/submodule-embed-gitdir:
  7547. worktree: initialize return value for submodule_uses_worktrees
  7548. submodule: add absorb-git-dir function
  7549. move connect_work_tree_and_git_dir to dir.h
  7550. worktree: check if a submodule uses worktrees
  7551. test-lib-functions.sh: teach test_commit -C <dir>
  7552. submodule helper: support super prefix
  7553. submodule: use absolute path for computing relative path connecting
  7554.  
  7555. Merge branch 'jc/retire-compaction-heuristics'
  7556.  
  7557. "git diff" and its family had two experimental heuristics to shift
  7558. the contents of a hunk to make the patch easier to read. One of
  7559. them turns out to be better than the other, so leave only the
  7560. "--indent-heuristic" option and remove the other one.
  7561.  
  7562. * jc/retire-compaction-heuristics:
  7563. diff: retire "compaction" heuristics
  7564.  
  7565. Merge branch 'nd/config-misc-fixes'
  7566.  
  7567. Leakage of lockfiles in the config subsystem has been fixed.
  7568.  
  7569. * nd/config-misc-fixes:
  7570. config.c: handle lock file in error case in git_config_rename_...
  7571. config.c: rename label unlock_and_out
  7572. config.c: handle error case for fstat() calls
  7573.  
  7574. Merge branch 'jc/abbrev-autoscale-config'
  7575.  
  7576. Recent update to the default abbreviation length that auto-scales
  7577. lacked documentation update, which has been corrected.
  7578.  
  7579. * jc/abbrev-autoscale-config:
  7580. config.abbrev: document the new default that auto-scales
  7581.  
  7582. Merge branch 'mh/fast-import-notes-fix-new'
  7583.  
  7584. "git fast-import" sometimes mishandled while rebalancing notes
  7585. tree, which has been fixed.
  7586.  
  7587. * mh/fast-import-notes-fix-new:
  7588. fast-import: properly fanout notes when tree is imported
  7589.  
  7590. Merge branch 'jc/git-open-cloexec'
  7591.  
  7592. The codeflow of setting NOATIME and CLOEXEC on file descriptors Git
  7593. opens has been simplified.
  7594. We may want to drop the tip one, but we'll see.
  7595.  
  7596. * jc/git-open-cloexec:
  7597. sha1_file: stop opening files with O_NOATIME
  7598. git_open_cloexec(): use fcntl(2) w/ FD_CLOEXEC fallback
  7599. git_open(): untangle possible NOATIME and CLOEXEC interactions
  7600.  
  7601. Merge branch 'jc/compression-config'
  7602.  
  7603. Compression setting for producing packfiles were spread across
  7604. three codepaths, one of which did not honor any configuration.
  7605. Unify these so that all of them honor core.compression and
  7606. pack.compression variables the same way.
  7607.  
  7608. * jc/compression-config:
  7609. compression: unify pack.compression configuration parsing
  7610.  
  7611. Merge branch 'dt/smart-http-detect-server-going-away'
  7612.  
  7613. When the http server gives an incomplete response to a smart-http
  7614. rpc call, it could lead to client waiting for a full response that
  7615. will never come. Teach the client side to notice this condition
  7616. and abort the transfer.
  7617.  
  7618. An improvement counterproposal has failed.
  7619. cf. <20161114194049.mktpsvgdhex2f4zv@sigill.intra.peff.net>
  7620.  
  7621. * dt/smart-http-detect-server-going-away:
  7622. upload-pack: optionally allow fetching any sha1
  7623. remote-curl: don't hang when a server dies before any output
  7624.  
  7625. Merge branch 'mm/gc-safety-doc'
  7626.  
  7627. Doc update.
  7628.  
  7629. * mm/gc-safety-doc:
  7630. git-gc.txt: expand discussion of races with other processes
  7631.  
  7632. Merge branch 'mm/push-social-engineering-attack-doc'
  7633.  
  7634. Doc update on fetching and pushing.
  7635.  
  7636. * mm/push-social-engineering-attack-doc:
  7637. doc: mention transfer data leaks in more places
  7638.  
  7639. Merge branch 'jt/fetch-no-redundant-tag-fetch-map'
  7640.  
  7641. Code cleanup to avoid using redundant refspecs while fetching with
  7642. the --tags option.
  7643.  
  7644. * jt/fetch-no-redundant-tag-fetch-map:
  7645. fetch: do not redundantly calculate tag refmap
  7646.  
  7647. Merge branch 'jc/latin-1'
  7648.  
  7649. Some platforms no longer understand "latin-1" that is still seen in
  7650. the wild in e-mail headers; replace them with "iso-8859-1" that is
  7651. more widely known when conversion fails from/to it.
  7652.  
  7653. * jc/latin-1:
  7654. utf8: accept "latin-1" as ISO-8859-1
  7655. utf8: refactor code to decide fallback encoding
  7656.  
  7657. mergetool: fix running in subdir when rerere enabled
  7658.  
  7659. "git mergetool" (without any pathspec on the command line) that is
  7660. not run from the top-level of the working tree no longer works in
  7661. Git v2.11, failing to get the list of unmerged paths from the output
  7662. of "git rerere remaining". This regression was introduced by
  7663. 57937f70a0 ("mergetool: honor diff.orderFile", 2016-10-07).
  7664.  
  7665. This is because the pathnames output by the 'git rerere remaining'
  7666. command are relative to the top-level directory but the 'git diff
  7667. --name-only' command expects its pathname arguments to be relative
  7668. to the current working directory. To make everything consistent,
  7669. cd_to_toplevel before running 'git diff --name-only' and adjust any
  7670. relative pathnames.
  7671.  
  7672. Signed-off-by: Richard Hansen <hansenr@google.com>
  7673. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7674.  
  7675. mergetool: take the "-O" out of $orderfile
  7676.  
  7677. This will make it easier for a future commit to convert a relative
  7678. orderfile pathname to either absolute or relative to the top-level
  7679. directory. It also improves code readability.
  7680.  
  7681. Signed-off-by: Richard Hansen <hansenr@google.com>
  7682. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7683.  
  7684. t7610: add test case for rerere+mergetool+subdir bug
  7685.  
  7686. If rerere is enabled and mergetool is run from a subdirectory,
  7687. mergetool always prints "No files need merging". Add an expected
  7688. failure test case for this situation.
  7689.  
  7690. Signed-off-by: Richard Hansen <hansenr@google.com>
  7691. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7692.  
  7693. t7610: spell 'git reset --hard' consistently
  7694.  
  7695. Signed-off-by: Richard Hansen <hansenr@google.com>
  7696. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7697.  
  7698. t7610: don't assume the checked-out commit
  7699.  
  7700. Always check out the required commit at the beginning of the test so
  7701. that a failure in a previous test does not cause the test to work off
  7702. of the wrong commit.
  7703.  
  7704. This is a step toward making the tests more independent so that if one
  7705. test fails it doesn't cause subsequent tests to fail.
  7706.  
  7707. Signed-off-by: Richard Hansen <hansenr@google.com>
  7708. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7709.  
  7710. t7610: always work on a test-specific branch
  7711.  
  7712. Create and use a test-specific branch when the test might create a
  7713. commit. This is not always necessary for correctness, but it improves
  7714. debuggability by ensuring a commit created by test #N shows up on the
  7715. testN branch, not the branch for test #N-1.
  7716.  
  7717. Signed-off-by: Richard Hansen <hansenr@google.com>
  7718. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7719.  
  7720. t7610: delete some now-unnecessary 'git reset --hard' lines
  7721.  
  7722. Tests now always run 'git reset --hard' at the end (even if they
  7723. fail), so it's no longer necessary to run 'git reset --hard' at the
  7724. beginning of a test.
  7725.  
  7726. Signed-off-by: Richard Hansen <hansenr@google.com>
  7727. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7728.  
  7729. t7610: run 'git reset --hard' after each test to clean up
  7730.  
  7731. Use test_when_finished to run 'git reset --hard' after each test so
  7732. that the repository is left in a saner state for the next test.
  7733.  
  7734. This is a step toward making the tests more independent so that if one
  7735. test fails it doesn't cause subsequent tests to fail.
  7736.  
  7737. Signed-off-by: Richard Hansen <hansenr@google.com>
  7738. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7739.  
  7740. t7610: don't rely on state from previous test
  7741.  
  7742. If the repository must be in a particular state (beyond what is
  7743. already done by the 'setup' test case) before the test can run, make
  7744. the necessary repository changes in the test script even if it means
  7745. duplicating some lines of code from the previous test case.
  7746.  
  7747. This is a step toward making the tests more independent so that if one
  7748. test fails it doesn't cause subsequent tests to fail.
  7749.  
  7750. Signed-off-by: Richard Hansen <hansenr@google.com>
  7751. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7752.  
  7753. t7610: use test_when_finished for cleanup tasks
  7754.  
  7755. This is a step toward making the tests more independent so that if one
  7756. test fails it doesn't cause subsequent tests to fail.
  7757.  
  7758. Signed-off-by: Richard Hansen <hansenr@google.com>
  7759. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7760.  
  7761. t7610: move setup code to the 'setup' test case
  7762.  
  7763. Multiple test cases depend on these hunks, so move them to the 'setup'
  7764. test case. This is a step toward making the tests more independent so
  7765. that if one test fails it doesn't cause subsequent tests to fail.
  7766.  
  7767. Signed-off-by: Richard Hansen <hansenr@google.com>
  7768. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7769.  
  7770. t7610: update branch names to match test number
  7771.  
  7772. Rename the testNN branches so that NN matches the test number. This
  7773. should make it easier to troubleshoot test issues. Use $test_count to
  7774. keep this future-proof.
  7775.  
  7776. Signed-off-by: Richard Hansen <hansenr@google.com>
  7777. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7778.  
  7779. rev-parse doc: pass "--" to rev-parse in the --prefix example
  7780.  
  7781. The "--" argument avoids "ambiguous argument: unknown revision or
  7782. path not in the working tree" errors when a pathname argument refers
  7783. to a non-existent file.
  7784.  
  7785. The "--" passed explicitly to set was removed because rev-parse
  7786. outputs the "--" argument that it is given.
  7787.  
  7788. Signed-off-by: Richard Hansen <hansenr@google.com>
  7789. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7790.  
  7791. ref-filter: Do not abruptly die when using the 'lstrip=<N>' option
  7792.  
  7793. Currently when we use the 'lstrip=<N>' option, if 'N' is greater than
  7794. the number of components available in the refname, we abruptly end
  7795. program execution by calling die().
  7796.  
  7797. This behavior is undesired since a single refname with few components
  7798. could end program execution. To avoid this, return an empty string
  7799. whenever the value 'N' is greater than the number of components
  7800. available, instead of calling die().
  7801.  
  7802. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  7803. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7804.  
  7805. ref-filter: rename the 'strip' option to 'lstrip'
  7806.  
  7807. In preparation for the upcoming patch, where we introduce the 'rstrip'
  7808. option. Rename the 'strip' option to 'lstrip' to remove ambiguity.
  7809.  
  7810. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  7811. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7812.  
  7813. ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()
  7814.  
  7815. Use the recently introduced refname_atom_parser_internal() within
  7816. remote_ref_atom_parser(), this provides a common base for all the ref
  7817. printing atoms, allowing %(upstream) and %(push) to also use the
  7818. ':strip' option.
  7819.  
  7820. The atoms '%(push)' and '%(upstream)' will retain the ':track' and
  7821. ':trackshort' atom modifiers to themselves as they have no meaning in
  7822. context to the '%(refname)' and '%(symref)' atoms.
  7823.  
  7824. Update the documentation and tests to reflect the same.
  7825.  
  7826. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  7827. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7828.  
  7829. ref-filter: introduce refname_atom_parser()
  7830.  
  7831. Using refname_atom_parser_internal(), introduce refname_atom_parser()
  7832. which will parse the %(symref) and %(refname) atoms. Store the parsed
  7833. information into the 'used_atom' structure based on the modifiers used
  7834. along with the atoms.
  7835.  
  7836. Now the '%(symref)' atom supports the ':strip' atom modifier. Update the
  7837. Documentation and tests to reflect this.
  7838.  
  7839. Helped-by: Jeff King <peff@peff.net>
  7840. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  7841. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7842.  
  7843. ref-filter: introduce refname_atom_parser_internal()
  7844.  
  7845. Since there are multiple atoms which print refs ('%(refname)',
  7846. '%(symref)', '%(push)', '%(upstream)'), it makes sense to have a common
  7847. ground for parsing them. This would allow us to share implementations of
  7848. the atom modifiers between these atoms.
  7849.  
  7850. Introduce refname_atom_parser_internal() to act as a common parsing
  7851. function for ref printing atoms. This would eventually be used to
  7852. introduce refname_atom_parser() and symref_atom_parser() and also be
  7853. internally used in remote_ref_atom_parser().
  7854.  
  7855. Helped-by: Jeff King <peff@peff.net>
  7856. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  7857. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7858.  
  7859. ref-filter: make "%(symref)" atom work with the ':short' modifier
  7860.  
  7861. The "%(symref)" atom doesn't work when used with the ':short' modifier
  7862. because we strictly match only 'symref' for setting the 'need_symref'
  7863. indicator. Fix this by comparing with the valid_atom rather than the
  7864. used_atom.
  7865.  
  7866. Add tests for %(symref) and %(symref:short) while we're here.
  7867.  
  7868. Helped-by: Junio C Hamano <gitster@pobox.com>
  7869. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  7870. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7871.  
  7872. ref-filter: add support for %(upstream:track,nobracket)
  7873.  
  7874. Add support for %(upstream:track,nobracket) which will print the
  7875. tracking information without the brackets (i.e. "ahead N, behind M").
  7876. This is needed when we port branch.c to use ref-filter's printing APIs.
  7877.  
  7878. Add test and documentation for the same.
  7879.  
  7880. Mentored-by: Christian Couder <christian.couder@gmail.com>
  7881. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  7882. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  7883. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7884.  
  7885. ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams
  7886.  
  7887. Borrowing from branch.c's implementation print "[gone]" whenever an
  7888. unknown upstream ref is encountered instead of just ignoring it.
  7889.  
  7890. This makes sure that when branch.c is ported over to using ref-filter
  7891. APIs for printing, this feature is not lost.
  7892.  
  7893. Make changes to t/t6300-for-each-ref.sh and
  7894. Documentation/git-for-each-ref.txt to reflect this change.
  7895.  
  7896. Mentored-by: Christian Couder <christian.couder@gmail.com>
  7897. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  7898. Helped-by : Jacob Keller <jacob.keller@gmail.com>
  7899. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  7900. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7901.  
  7902. ref-filter: introduce format_ref_array_item()
  7903.  
  7904. To allow column display, we will need to first render the output in a
  7905. string list to allow print_columns() to compute the proper size of
  7906. each column before starting the actual output. Introduce the function
  7907. format_ref_array_item() that does the formatting of a ref_array_item
  7908. to an strbuf.
  7909.  
  7910. show_ref_array_item() is kept as a convenience wrapper around it which
  7911. obtains the strbuf and prints it the standard output.
  7912.  
  7913. Mentored-by: Christian Couder <christian.couder@gmail.com>
  7914. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  7915. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  7916. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7917.  
  7918. ref-filter: move get_head_description() from branch.c
  7919.  
  7920. Move the implementation of get_head_description() from branch.c to
  7921. ref-filter. This gives a description of the HEAD ref if called. This
  7922. is used as the refname for the HEAD ref whenever the
  7923. FILTER_REFS_DETACHED_HEAD option is used. Make it public because we
  7924. need it to calculate the length of the HEAD refs description in
  7925. branch.c:calc_maxwidth() when we port branch.c to use ref-filter
  7926. APIs.
  7927.  
  7928. Mentored-by: Christian Couder <christian.couder@gmail.com>
  7929. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  7930. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  7931. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7932.  
  7933. ref-filter: modify "%(objectname:short)" to take length
  7934.  
  7935. Add support for %(objectname:short=<length>) which would print the
  7936. abbreviated unique objectname of given length. When no length is
  7937. specified, the length is 'DEFAULT_ABBREV'. The minimum length is
  7938. 'MINIMUM_ABBREV'. The length may be exceeded to ensure that the
  7939. provided object name is unique.
  7940.  
  7941. Add tests and documentation for the same.
  7942.  
  7943. Mentored-by: Christian Couder <christian.couder@gmail.com>
  7944. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  7945. Helped-by: Jacob Keller <jacob.keller@gmail.com>
  7946. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  7947. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7948.  
  7949. ref-filter: implement %(if:equals=<string>) and %(if:notequals=<string>)
  7950.  
  7951. Implement %(if:equals=<string>) wherein the if condition is only
  7952. satisfied if the value obtained between the %(if:...) and %(then) atom
  7953. is the same as the given '<string>'.
  7954.  
  7955. Similarly, implement (if:notequals=<string>) wherein the if condition
  7956. is only satisfied if the value obtained between the %(if:...) and
  7957. %(then) atom is different from the given '<string>'.
  7958.  
  7959. This is done by introducing 'if_atom_parser()' which parses the given
  7960. %(if) atom and then stores the data in used_atom which is later passed
  7961. on to the used_atom of the %(then) atom, so that it can do the required
  7962. comparisons.
  7963.  
  7964. Add tests and documentation for the same.
  7965.  
  7966. Mentored-by: Christian Couder <christian.couder@gmail.com>
  7967. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  7968. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  7969. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7970.  
  7971. ref-filter: include reference to 'used_atom' within 'atom_value'
  7972.  
  7973. Ensure that each 'atom_value' has a reference to its corresponding
  7974. 'used_atom'. This lets us use values within 'used_atom' in the
  7975. 'handler' function.
  7976.  
  7977. Hence we can get the %(align) atom's parameters directly from the
  7978. 'used_atom' therefore removing the necessity of passing %(align) atom's
  7979. parameters to 'atom_value'.
  7980.  
  7981. This also acts as a preparatory patch for the upcoming patch where we
  7982. introduce %(if:equals=) and %(if:notequals=).
  7983.  
  7984. Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
  7985. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7986.  
  7987. ref-filter: implement %(if), %(then), and %(else) atoms
  7988.  
  7989. Implement %(if), %(then) and %(else) atoms. Used as
  7990. %(if)...%(then)...%(end) or %(if)...%(then)...%(else)...%(end). If the
  7991. format string between %(if) and %(then) expands to an empty string, or
  7992. to only whitespaces, then the whole %(if)...%(end) expands to the string
  7993. following %(then). Otherwise, it expands to the string following
  7994. %(else), if any. Nesting of this construct is possible.
  7995.  
  7996. This is in preparation for porting over `git branch -l` to use
  7997. ref-filter APIs for printing.
  7998.  
  7999. Add documentation and tests regarding the same.
  8000.  
  8001. Mentored-by: Christian Couder <christian.couder@gmail.com>
  8002. Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
  8003. Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
  8004. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8005.  
  8006. unpack-trees: factor progress setup out of check_updates
  8007.  
  8008. This makes check_updates shorter and easier to understand.
  8009.  
  8010. Signed-off-by: Stefan Beller <sbeller@google.com>
  8011. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8012.  
  8013. unpack-trees: remove unneeded continue
  8014.  
  8015. The continue is the last statement in the loop, so not needed.
  8016. This situation arose in 700e66d66 (2010-07-30, unpack-trees: let
  8017. read-tree -u remove index entries outside sparse area) when statements
  8018. after the continue were removed.
  8019.  
  8020. Signed-off-by: Stefan Beller <sbeller@google.com>
  8021. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8022.  
  8023. unpack-trees: move checkout state into check_updates
  8024.  
  8025. The checkout state was introduced via 16da134b1f9
  8026. (read-trees: refactor the unpack_trees() part, 2006-07-30). An attempt to
  8027. refactor the checkout state was done in b56aa5b268e (unpack-trees: pass
  8028. checkout state explicitly to check_updates(), 2016-09-13), but we can
  8029. go even further.
  8030.  
  8031. The `struct checkout state` is not used in unpack_trees apart from
  8032. initializing it, so move it into the function that makes use of it,
  8033. which is `check_updates`.
  8034.  
  8035. Signed-off-by: Stefan Beller <sbeller@google.com>
  8036. Reviewed-by: René Scharfe <l.s.r@web.de>
  8037. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8038.  
  8039. .mailmap: record canonical email for Richard Hansen
  8040.  
  8041. When I changed employers my work address changed from rhansen@bbn.com
  8042. to hansenr@google.com. Rather than map my old work address to my new,
  8043. map them both to my permanent personal email address. (I will still
  8044. use my work address in commits I submit so that my employer gets some
  8045. credit.)
  8046.  
  8047. Signed-off-by: Richard Hansen <hansenr@google.com>
  8048. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8049.  
  8050. pathspec: give better message for submodule related pathspec error
  8051.  
  8052. Every once in a while someone complains to the mailing list to have
  8053. run into this weird assertion[1]. The usual response from the mailing
  8054. list is link to old discussions[2], and acknowledging the problem
  8055. stating it is known.
  8056.  
  8057. This patch accomplishes two things:
  8058.  
  8059. 1. Switch assert() to die("BUG") to give a more readable message.
  8060.  
  8061. 2. Take one of the cases where we hit a BUG and turn it into a normal
  8062. "there was something wrong with the input" message.
  8063.  
  8064. This assertion triggered for cases where there wasn't a programming
  8065. bug, but just bogus input. In particular, if the user asks for a
  8066. pathspec that is inside a submodule, we shouldn't assert() or
  8067. die("BUG"); we should tell the user their request is bogus.
  8068.  
  8069. The only reason we did not check for it, is the expensive nature
  8070. of such a check, so callers avoid setting the flag
  8071. PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE. However when we die due
  8072. to bogus input, the expense of CPU cycles spent outweighs the user
  8073. wondering what went wrong, so run that check unconditionally before
  8074. dying with a more generic error message.
  8075.  
  8076. Note: There is a case (e.g. "git -C submodule add .") in which we call
  8077. strip_submodule_slash_expensive, as git-add requests it via the flag
  8078. PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE, but the assert used to
  8079. trigger nevertheless, because the flag PATHSPEC_LITERAL was not set,
  8080. such that we executed
  8081.  
  8082. if (item->nowildcard_len < prefixlen)
  8083. item->nowildcard_len = prefixlen;
  8084.  
  8085. and prefixlen was not adapted (e.g. it was computed from "submodule/")
  8086. So in the die_inside_submodule_path function we also need handle paths,
  8087. that were stripped before, i.e. are the exact submodule path. This
  8088. is why the conditions in die_inside_submodule_path are slightly
  8089. different than in strip_submodule_slash_expensive.
  8090.  
  8091. [1] https://www.google.com/search?q=item-%3Enowildcard_len
  8092. [2] http://git.661346.n2.nabble.com/assert-failed-in-submodule-edge-case-td7628687.html
  8093. https://www.spinics.net/lists/git/msg249473.html
  8094.  
  8095. Helped-by: Jeff King <peff@peff.net>
  8096. Helped-by: Junio C Hamano <gitster@pobox.com>
  8097. Signed-off-by: Stefan Beller <sbeller@google.com>
  8098. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8099.  
  8100. sequencer (rebase -i): differentiate between comments and 'noop'
  8101.  
  8102. In the upcoming patch, we will support rebase -i's progress
  8103. reporting. The progress skips comments but counts 'noop's.
  8104.  
  8105. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8106. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8107.  
  8108. sequencer (rebase -i): implement the 'drop' command
  8109.  
  8110. The parsing part of a 'drop' command is almost identical to parsing a
  8111. 'pick', while the operation is the same as that of a 'noop'.
  8112.  
  8113. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8114. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8115.  
  8116. sequencer (rebase -i): allow rescheduling commands
  8117.  
  8118. The interactive rebase has the very special magic that a cherry-pick
  8119. that exits with a status different from 0 and 1 signifies a failure to
  8120. even record that a cherry-pick was started.
  8121.  
  8122. This can happen e.g. when a fast-forward fails because it would
  8123. overwrite untracked files.
  8124.  
  8125. In that case, we must reschedule the command that we thought we already
  8126. had at least started successfully.
  8127.  
  8128. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8129. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8130.  
  8131. sequencer (rebase -i): respect strategy/strategy_opts settings
  8132.  
  8133. The sequencer already has an idea about using different merge
  8134. strategies. We just piggy-back on top of that, using rebase -i's
  8135. own settings, when running the sequencer in interactive rebase mode.
  8136.  
  8137. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8138. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8139.  
  8140. sequencer (rebase -i): respect the rebase.autostash setting
  8141.  
  8142. Git's `rebase` command inspects the `rebase.autostash` config setting
  8143. to determine whether it should stash any uncommitted changes before
  8144. rebasing and re-apply them afterwards.
  8145.  
  8146. As we introduce more bits and pieces to let the sequencer act as
  8147. interactive rebase's backend, here is the part that adds support for
  8148. the autostash feature.
  8149.  
  8150. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8151. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8152.  
  8153. sequencer (rebase -i): run the post-rewrite hook, if needed
  8154.  
  8155. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8156. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8157.  
  8158. sequencer (rebase -i): record interrupted commits in rewritten, too
  8159.  
  8160. When continuing after a `pick` command failed, we want that commit
  8161. to show up in the rewritten-list (and its notes to be rewritten), too.
  8162.  
  8163. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8164. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8165.  
  8166. sequencer (rebase -i): copy commit notes at end
  8167.  
  8168. When rebasing commits that have commit notes attached, the interactive
  8169. rebase rewrites those notes faithfully at the end. The sequencer must
  8170. do this, too, if it wishes to do interactive rebase's job.
  8171.  
  8172. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8173. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8174.  
  8175. sequencer (rebase -i): set the reflog message consistently
  8176.  
  8177. We already used the same reflog message as the scripted version of rebase
  8178. -i when finishing. With this commit, we do that also for all the commands
  8179. before that.
  8180.  
  8181. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8182. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8183.  
  8184. sequencer (rebase -i): refactor setting the reflog message
  8185.  
  8186. This makes the code DRYer, with the obvious benefit that we can enhance
  8187. the code further in a single place.
  8188.  
  8189. We can also reuse the functionality elsewhere by calling this new
  8190. function.
  8191.  
  8192. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8193. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8194.  
  8195. sequencer (rebase -i): allow fast-forwarding for edit/reword
  8196.  
  8197. The sequencer already knew how to fast-forward instead of
  8198. cherry-picking, if possible.
  8199.  
  8200. We want to continue to do this, of course, but in case of the 'reword'
  8201. command, we will need to call `git commit` after fast-forwarding.
  8202.  
  8203. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8204. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8205.  
  8206. sequencer (rebase -i): implement the 'reword' command
  8207.  
  8208. This is now trivial, as all the building blocks are in place: all we need
  8209. to do is to flip the "edit" switch when committing.
  8210.  
  8211. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8212. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8213.  
  8214. sequencer (rebase -i): leave a patch upon error
  8215.  
  8216. When doing an interactive rebase, we want to leave a 'patch' file for
  8217. further inspection by the user (even if we never tried to actually apply
  8218. that patch, since we're cherry-picking instead).
  8219.  
  8220. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8221. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8222.  
  8223. sequencer (rebase -i): update refs after a successful rebase
  8224.  
  8225. An interactive rebase operates on a detached HEAD (to keep the reflog
  8226. of the original branch relatively clean), and updates the branch only
  8227. at the end.
  8228.  
  8229. Now that the sequencer learns to perform interactive rebases, it also
  8230. needs to learn the trick to update the branch before removing the
  8231. directory containing the state of the interactive rebase.
  8232.  
  8233. We introduce a new head_ref variable in a wider scope than necessary at
  8234. the moment, to allow for a later patch that prints out "Successfully
  8235. rebased and updated <ref>".
  8236.  
  8237. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8238. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8239.  
  8240. sequencer (rebase -i): the todo can be empty when continuing
  8241.  
  8242. When the last command of an interactive rebase fails, the user needs to
  8243. resolve the problem and then continue the interactive rebase. Naturally,
  8244. the todo script is empty by then. So let's not complain about that!
  8245.  
  8246. To that end, let's move that test out of the function that parses the
  8247. todo script, and into the more high-level function read_populate_todo().
  8248. This is also necessary by now because the lower-level parse_insn_buffer()
  8249. has no idea whether we are performing an interactive rebase or not.
  8250.  
  8251. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8252. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8253.  
  8254. sequencer (rebase -i): skip some revert/cherry-pick specific code path
  8255.  
  8256. When a cherry-pick continues without a "todo script", the intention is
  8257. simply to pick a single commit.
  8258.  
  8259. However, when an interactive rebase is continued without a "todo
  8260. script", it means that the last command has been completed and that we
  8261. now need to clean up.
  8262.  
  8263. This commit guards the revert/cherry-pick specific steps so that they
  8264. are not executed in rebase -i mode.
  8265.  
  8266. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8267. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8268.  
  8269. sequencer (rebase -i): remove CHERRY_PICK_HEAD when no longer needed
  8270.  
  8271. The scripted version of the interactive rebase already does that.
  8272.  
  8273. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8274. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8275.  
  8276. sequencer (rebase -i): allow continuing with staged changes
  8277.  
  8278. When an interactive rebase is interrupted, the user may stage changes
  8279. before continuing, and we need to commit those changes in that case.
  8280.  
  8281. Please note that the nested "if" added to the sequencer_continue() is
  8282. not combined into a single "if" because it will be extended with an
  8283. "else" clause in a later patch in this patch series.
  8284.  
  8285. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8286. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8287.  
  8288. sequencer (rebase -i): write an author-script file
  8289.  
  8290. When the interactive rebase aborts, it writes out an author-script file
  8291. to record the author information for the current commit. As we are about
  8292. to teach the sequencer how to perform the actions behind an interactive
  8293. rebase, it needs to write those author-script files, too.
  8294.  
  8295. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8296. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8297.  
  8298. sequencer (rebase -i): implement the short commands
  8299.  
  8300. For users' convenience, most rebase commands can be abbreviated, e.g.
  8301. 'p' instead of 'pick' and 'x' instead of 'exec'. Let's teach the
  8302. sequencer to handle those abbreviated commands just fine.
  8303.  
  8304. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8305. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8306.  
  8307. sequencer (rebase -i): add support for the 'fixup' and 'squash' commands
  8308.  
  8309. This is a huge patch, and at the same time a huge step forward to
  8310. execute the performance-critical parts of the interactive rebase in a
  8311. builtin command.
  8312.  
  8313. Since 'fixup' and 'squash' are not only similar, but also need to know
  8314. about each other (we want to reduce a series of fixups/squashes into a
  8315. single, final commit message edit, from the user's point of view), we
  8316. really have to implement them both at the same time.
  8317.  
  8318. Most of the actual work is done by the existing code path that already
  8319. handles the "pick" and the "edit" commands; We added support for other
  8320. features (e.g. to amend the commit message) in the patches leading up to
  8321. this one, yet there are still quite a few bits in this patch that simply
  8322. would not make sense as individual patches (such as: determining whether
  8323. there was anything to "fix up" in the "todo" script, etc).
  8324.  
  8325. In theory, it would be possible to reuse the fast-forward code path also
  8326. for the fixup and the squash code paths, but in practice this would make
  8327. the code less readable. The end result cannot be fast-forwarded anyway,
  8328. therefore let's just extend the cherry-picking code path for now.
  8329.  
  8330. Since the sequencer parses the entire `git-rebase-todo` script in one go,
  8331. fixup or squash commands without a preceding pick can be reported early
  8332. (in git-rebase--interactive, we could only report such errors just before
  8333. executing the fixup/squash).
  8334.  
  8335. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8336. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8337.  
  8338. sequencer (rebase -i): write the 'done' file
  8339.  
  8340. In the interactive rebase, commands that were successfully processed are
  8341. not simply discarded, but appended to the 'done' file instead. This is
  8342. used e.g. to display the current state to the user in the output of
  8343. `git status` or the progress.
  8344.  
  8345. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8346. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8347.  
  8348. sequencer (rebase -i): learn about the 'verbose' mode
  8349.  
  8350. When calling `git rebase -i -v`, the user wants to see some statistics
  8351. after the commits were rebased. Let's show some.
  8352.  
  8353. The strbuf we use to perform that task will be used for other things
  8354. in subsequent commits, hence it is declared and initialized in a wider
  8355. scope than strictly needed here.
  8356.  
  8357. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8358. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8359.  
  8360. sequencer (rebase -i): implement the 'exec' command
  8361.  
  8362. The 'exec' command is a little special among rebase -i's commands, as it
  8363. does *not* have a SHA-1 as first parameter. Instead, everything after the
  8364. `exec` command is treated as command-line to execute.
  8365.  
  8366. Let's reuse the arg/arg_len fields of the todo_item structure (which hold
  8367. the oneline for pick/edit commands) to point to the command-line.
  8368.  
  8369. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8370. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8371.  
  8372. sequencer (rebase -i): implement the 'edit' command
  8373.  
  8374. This patch is a straight-forward reimplementation of the `edit`
  8375. operation of the interactive rebase command.
  8376.  
  8377. Well, not *quite* straight-forward: when stopping, the `edit`
  8378. command wants to write the `patch` file (which is not only the
  8379. patch, but includes the commit message and author information). To
  8380. that end, this patch requires the earlier work that taught the
  8381. log-tree machinery to respect the `file` setting of
  8382. rev_info->diffopt to write to a file stream different than stdout.
  8383.  
  8384. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8385. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8386.  
  8387. sequencer (rebase -i): implement the 'noop' command
  8388.  
  8389. The 'noop' command is probably the most boring of all rebase -i commands
  8390. to support in the sequencer.
  8391.  
  8392. Which makes it an excellent candidate for this first stab to add support
  8393. for rebase -i's commands to the sequencer.
  8394.  
  8395. For the moment, let's also treat empty lines and commented-out lines as
  8396. 'noop'; We will refine that handling later in this patch series.
  8397.  
  8398. To make it easier to identify "classes" of todo_commands (such as:
  8399. determine whether a command is pick-like, i.e. handles a single commit),
  8400. let's enforce a certain order of said commands.
  8401.  
  8402. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8403. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8404.  
  8405. sequencer: support a new action: 'interactive rebase'
  8406.  
  8407. This patch introduces a new action for the sequencer. It really does not
  8408. do a whole lot of its own right now, but lays the ground work for
  8409. patches to come. The intention, of course, is to finally make the
  8410. sequencer the work horse of the interactive rebase (the original idea
  8411. behind the "sequencer" concept).
  8412.  
  8413. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8414. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8415.  
  8416. sequencer: use a helper to find the commit message
  8417.  
  8418. It is actually not safe to look for a commit message by looking for the
  8419. first empty line and skipping it.
  8420.  
  8421. The find_commit_subject() function looks more carefully, so let's use
  8422. it. Since we are interested in the entire commit message, we re-compute
  8423. the string length after verifying that the commit subject is not empty
  8424. (in which case the entire commit message would be empty, something that
  8425. should not happen but that we want to handle gracefully).
  8426.  
  8427. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8428. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8429.  
  8430. sequencer: move "else" keyword onto the same line as preceding brace
  8431.  
  8432. It is the current coding style of the Git project to write
  8433.  
  8434. if (...) {
  8435. ...
  8436. } else {
  8437. ...
  8438. }
  8439.  
  8440. instead of putting the closing brace and the "else" keyword on separate
  8441. lines.
  8442.  
  8443. Pointed out by Junio Hamano.
  8444.  
  8445. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8446. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8447.  
  8448. sequencer: avoid unnecessary curly braces
  8449.  
  8450. This was noticed while addressing Junio Hamano's concern that some
  8451. "else" operators were on separate lines than the preceding closing
  8452. brace.
  8453.  
  8454. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8455. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8456.  
  8457. execv_dashed_external: wait for child on signal death
  8458.  
  8459. When you hit ^C to interrupt a git command going to a pager,
  8460. this usually leaves the pager running. But when a dashed
  8461. external is in use, the pager ends up in a funny state and
  8462. quits (but only after eating one more character from the
  8463. terminal!). This fixes it.
  8464.  
  8465. Explaining the reason will require a little background.
  8466.  
  8467. When git runs a pager, it's important for the git process to
  8468. hang around and wait for the pager to finish, even though it
  8469. has no more data to feed it. This is because git spawns the
  8470. pager as a child, and thus the git process is the session
  8471. leader on the terminal. After it dies, the pager will finish
  8472. its current read from the terminal (eating the one
  8473. character), and then get EIO trying to read again.
  8474.  
  8475. When you hit ^C, that sends SIGINT to git and to the pager,
  8476. and it's a similar situation. The pager ignores it, but the
  8477. git process needs to hang around until the pager is done. We
  8478. addressed that long ago in a3da882120 (pager: do
  8479. wait_for_pager on signal death, 2009-01-22).
  8480.  
  8481. But when you have a dashed external (or an alias pointing to
  8482. a builtin, which will re-exec git for the builtin), there's
  8483. an extra process in the mix. For instance, running:
  8484.  
  8485. $ git -c alias.l=log l
  8486.  
  8487. will end up with a process tree like:
  8488.  
  8489. git (parent)
  8490. \
  8491. git-log (child)
  8492. \
  8493. less (pager)
  8494.  
  8495. If you hit ^C, SIGINT goes to all of them. The pager ignores
  8496. it, and the child git process will end up in wait_for_pager().
  8497. But the parent git process will die, and the usual EIO
  8498. trouble happens.
  8499.  
  8500. So we really want the parent git process to wait_for_pager(),
  8501. but of course it doesn't know anything about the pager at
  8502. all, since it was started by the child. However, we can
  8503. have it wait on the git-log child, which in turn is waiting
  8504. on the pager. And that's what this patch does.
  8505.  
  8506. There are a few design decisions here worth explaining:
  8507.  
  8508. 1. The new feature is attached to run-command's
  8509. clean_on_exit feature. Partly this is convenience,
  8510. since that feature already has a signal handler that
  8511. deals with child cleanup.
  8512.  
  8513. But it's also a meaningful connection. The main reason
  8514. that dashed externals use clean_on_exit is to bind the
  8515. two processes together. If somebody kills the parent
  8516. with a signal, we propagate that to the child (in this
  8517. instance with SIGINT, we do propagate but it doesn't
  8518. matter because the original signal went to the whole
  8519. process group). Likewise, we do not want the parent
  8520. to go away until the child has done so.
  8521.  
  8522. In a traditional Unix world, we'd probably accomplish
  8523. this binding by just having the parent execve() the
  8524. child directly. But since that doesn't work on Windows,
  8525. everything goes through run_command's more spawn-like
  8526. interface.
  8527.  
  8528. 2. We do _not_ automatically waitpid() on any
  8529. clean_on_exit children. For dashed externals this makes
  8530. sense; we know that the parent is doing nothing but
  8531. waiting for the child to exit anyway. But with other
  8532. children, it's possible that the child, after getting
  8533. the signal, could be waiting on the parent to do
  8534. something (like closing a descriptor). If we were to
  8535. wait on such a child, we'd end up in a deadlock. So
  8536. this errs on the side of caution, and lets callers
  8537. enable the feature explicitly.
  8538.  
  8539. 3. When we send children the cleanup signal, we send all
  8540. the signals first, before waiting on any children. This
  8541. is to avoid the case where one child might be waiting
  8542. on another one to exit, causing a deadlock. We inform
  8543. all of them that it's time to die before reaping any.
  8544.  
  8545. In practice, there is only ever one dashed external run
  8546. from a given process, so this doesn't matter much now.
  8547. But it future-proofs us if other callers start using
  8548. the wait_after_clean mechanism.
  8549.  
  8550. There's no automated test here, because it would end up racy
  8551. and unportable. But it's easy to reproduce the situation by
  8552. running the log command given above and hitting ^C.
  8553.  
  8554. Signed-off-by: Jeff King <peff@peff.net>
  8555. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8556.  
  8557. execv_dashed_external: stop exiting with negative code
  8558.  
  8559. When we try to exec a git sub-command, we pass along the
  8560. status code from run_command(). But that may return -1 if we
  8561. ran into an error with pipe() or execve(). This tends to
  8562. work (and end up as 255 due to twos-complement wraparound
  8563. and truncation), but in general it's probably a good idea to
  8564. avoid negative exit codes for portability.
  8565.  
  8566. We can easily translate to the normal generic "128" code we
  8567. get when syscalls cause us to die.
  8568.  
  8569. Signed-off-by: Jeff King <peff@peff.net>
  8570. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8571.  
  8572. execv_dashed_external: use child_process struct
  8573.  
  8574. When we run a dashed external, we use the one-liner
  8575. run_command_v_opt() to do so. Let's switch to using a
  8576. child_process struct, which has two advantages:
  8577.  
  8578. 1. We can drop all of the allocation and cleanup code for
  8579. building our custom argv array, and just rely on the
  8580. builtin argv_array (at the minor cost of doing a few
  8581. extra mallocs).
  8582.  
  8583. 2. We have access to the complete range of child_process
  8584. options, not just the ones that the "_opt()" form can
  8585. forward.
  8586.  
  8587. Signed-off-by: Jeff King <peff@peff.net>
  8588. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8589.  
  8590. real_path: set errno when max number of symlinks is exceeded
  8591.  
  8592. Set errno to ELOOP when the maximum number of symlinks is exceeded, as
  8593. would be done by other symlink-resolving functions.
  8594.  
  8595. Signed-off-by: Brandon Williams <bmwill@google.com>
  8596. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8597.  
  8598. real_path: prevent redefinition of MAXSYMLINKS
  8599.  
  8600. The macro 'MAXSYMLINKS' is already defined on macOS and Linux in
  8601. <sys/param.h>. If 'MAXSYMLINKS' has already been defined, use the value
  8602. defined by the OS otherwise default to a value of 32 which is more
  8603. inline with what is allowed by many systems.
  8604.  
  8605. Signed-off-by: Brandon Williams <bmwill@google.com>
  8606. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8607.  
  8608. Makefile: put LIBS after LDFLAGS for imap-send
  8609.  
  8610. This matches up with the targets git-%, git-http-fetch, git-http-push
  8611. and git-remote-testsvn. It must be done this way in Cygwin else lcrypto
  8612. cannot find lgdi32 and lws2_32.
  8613.  
  8614. Signed-off-by: Steven Penny <svnpenn@gmail.com>
  8615. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8616. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8617.  
  8618. Makefile: POSIX windres
  8619.  
  8620. When environment variable POSIXLY_CORRECT is set, the
  8621. "input -o output" syntax is not supported.
  8622.  
  8623. http://cygwin.com/ml/cygwin/2017-01/msg00036.html
  8624.  
  8625. Use "-i input -o output" syntax instead.
  8626.  
  8627. Signed-off-by: Steven Penny <svnpenn@gmail.com>
  8628. Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8629. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8630.  
  8631. t9813: avoid using pipes
  8632.  
  8633. The exit code of the upstream in a pipe is ignored thus we should avoid
  8634. using it. By writing out the output of the git command to a file, we can
  8635. test the exit codes of both the commands.
  8636.  
  8637. Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
  8638. Acked-by: Luke Diamand <luke@diamand.org>
  8639. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8640.  
  8641. git_exec_path: do not return the result of getenv()
  8642.  
  8643. The result of getenv() is not guaranteed by POSIX to last
  8644. beyond another call to getenv(), or setenv(), etc. We
  8645. should duplicate the string before returning to the caller
  8646. to avoid any surprises.
  8647.  
  8648. We already keep a cached pointer to avoid repeatedly leaking
  8649. the result of system_path(). We can use the same pointer
  8650. here to avoid allocating and leaking for each call.
  8651.  
  8652. Signed-off-by: Jeff King <peff@peff.net>
  8653. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8654.  
  8655. pathspec: rename prefix_pathspec to init_pathspec_item
  8656.  
  8657. Give a more relevant name to the prefix_pathspec function as it does
  8658. more than just prefix a pathspec element.
  8659.  
  8660. Signed-off-by: Brandon Williams <bmwill@google.com>
  8661. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8662. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8663.  
  8664. pathspec: small readability changes
  8665.  
  8666. A few small changes to improve readability. This is done by grouping related
  8667. assignments, adding blank lines, ensuring lines are <80 characters, and
  8668. adding additional comments.
  8669.  
  8670. Signed-off-by: Brandon Williams <bmwill@google.com>
  8671. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8672. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8673.  
  8674. pathspec: create strip submodule slash helpers
  8675.  
  8676. Factor out the logic responsible for stripping the trailing slash on
  8677. pathspecs referencing submodules into its own function.
  8678.  
  8679. Signed-off-by: Brandon Williams <bmwill@google.com>
  8680. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8681. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8682.  
  8683. pathspec: create parse_element_magic helper
  8684.  
  8685. Factor out the logic responsible for the magic in a pathspec element
  8686. into its own function.
  8687.  
  8688. Also avoid calling into the parsing functions when
  8689. `PATHSPEC_LITERAL_PATH` is specified since it causes magic to be
  8690. ignored and all paths to be treated as literals.
  8691.  
  8692. Signed-off-by: Brandon Williams <bmwill@google.com>
  8693. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8694. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8695.  
  8696. pathspec: create parse_long_magic function
  8697.  
  8698. Factor out the logic responsible for parsing long magic into its own
  8699. function. As well as hoist the prefix check logic outside of the inner
  8700. loop as there isn't anything that needs to be done after matching
  8701. "prefix:".
  8702.  
  8703. Signed-off-by: Brandon Williams <bmwill@google.com>
  8704. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8705. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8706.  
  8707. pathspec: create parse_short_magic function
  8708.  
  8709. Factor out the logic responsible for parsing short magic into its own
  8710. function.
  8711.  
  8712. Signed-off-by: Brandon Williams <bmwill@google.com>
  8713. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8714. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8715.  
  8716. pathspec: factor global magic into its own function
  8717.  
  8718. Create helper functions to read the global magic environment variables
  8719. in additon to factoring out the global magic gathering logic into its
  8720. own function.
  8721.  
  8722. Signed-off-by: Brandon Williams <bmwill@google.com>
  8723. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8724. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8725.  
  8726. pathspec: simpler logic to prefix original pathspec elements
  8727.  
  8728. The logic used to prefix an original pathspec element with 'prefix'
  8729. magic is more general purpose and can be used for more than just short
  8730. magic. Remove the extra code paths and rename 'prefix_short_magic' to
  8731. 'prefix_magic' to better indicate that it can be used in more general
  8732. situations.
  8733.  
  8734. Also, slightly change the logic which decides when to prefix the
  8735. original element in order to prevent a pathspec of "." from getting
  8736. converted to "" (empty string).
  8737.  
  8738. Signed-off-by: Brandon Williams <bmwill@google.com>
  8739. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8740. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8741.  
  8742. pathspec: always show mnemonic and name in unsupported_magic
  8743.  
  8744. For better clarity, always show the mnemonic and name of the unsupported
  8745. magic being used. This lets users have a more clear understanding of
  8746. what magic feature isn't supported. And if they supplied a mnemonic,
  8747. the user will be told what its corresponding name is which will allow
  8748. them to more easily search the man pages for that magic type.
  8749.  
  8750. This also avoids passing an extra parameter around the pathspec
  8751. initialization code.
  8752.  
  8753. Signed-off-by: Brandon Williams <bmwill@google.com>
  8754. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8755. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8756.  
  8757. pathspec: remove unused variable from unsupported_magic
  8758.  
  8759. Removed unused variable 'n' from the 'unsupported_magic()' function.
  8760.  
  8761. Signed-off-by: Brandon Williams <bmwill@google.com>
  8762. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8763. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8764.  
  8765. pathspec: copy and free owned memory
  8766.  
  8767. The 'original' string entry in a pathspec_item is only duplicated some
  8768. of the time, instead always make a copy of the original and take
  8769. ownership of the memory.
  8770.  
  8771. Since both 'match' and 'original' string entries in a pathspec_item are
  8772. owned by the pathspec struct, they need to be freed when clearing the
  8773. pathspec struct (in 'clear_pathspec()') and duplicated when copying the
  8774. pathspec struct (in 'copy_pathspec()').
  8775.  
  8776. Also change the type of 'match' and 'original' to 'char *' in order to
  8777. more explicitly show the ownership of the memory.
  8778.  
  8779. Signed-off-by: Brandon Williams <bmwill@google.com>
  8780. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8781. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8782.  
  8783. pathspec: remove the deprecated get_pathspec function
  8784.  
  8785. Now that all callers of the old 'get_pathspec' interface have been
  8786. migrated to use the new pathspec struct interface it can be removed
  8787. from the codebase.
  8788.  
  8789. Since there are no more users of the '_raw' field in the pathspec struct
  8790. it can also be removed. This patch also removes the old functionality
  8791. of modifying the const char **argv array that was passed into
  8792. parse_pathspec. Instead the constructed 'match' string (which is a
  8793. pathspec element with the prefix prepended) is only stored in its
  8794. corresponding pathspec_item entry.
  8795.  
  8796. Signed-off-by: Brandon Williams <bmwill@google.com>
  8797. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8798. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8799.  
  8800. ls-tree: convert show_recursive to use the pathspec struct interface
  8801.  
  8802. Convert 'show_recursive()' to use the pathspec struct interface from
  8803. using the '_raw' entry in the pathspec struct.
  8804.  
  8805. Signed-off-by: Brandon Williams <bmwill@google.com>
  8806. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8807. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8808.  
  8809. dir: convert fill_directory to use the pathspec struct interface
  8810.  
  8811. Convert 'fill_directory()' to use the pathspec struct interface from
  8812. using the '_raw' entry in the pathspec struct.
  8813.  
  8814. Signed-off-by: Brandon Williams <bmwill@google.com>
  8815. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8816. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8817.  
  8818. dir: remove struct path_simplify
  8819.  
  8820. Teach simplify_away() and exclude_matches_pathspec() to handle struct
  8821. pathspec directly, eliminating the need for the struct path_simplify.
  8822.  
  8823. Also renamed the len parameter to pathlen in exclude_matches_pathspec()
  8824. to match the parameter names used in simplify_away().
  8825.  
  8826. Signed-off-by: Brandon Williams <bmwill@google.com>
  8827. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8828. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8829.  
  8830. mv: remove use of deprecated 'get_pathspec()'
  8831.  
  8832. Convert the 'internal_copy_pathspec()' function to 'prefix_path()'
  8833. instead of using the deprecated 'get_pathspec()' interface. Also,
  8834. rename 'internal_copy_pathspec()' to 'internal_prefix_pathspec()' to be
  8835. more descriptive of what the funciton is actually doing.
  8836.  
  8837. In addition to this, fix a memory leak caused by only duplicating some
  8838. of the pathspec elements. Instead always duplicate all of the the
  8839. pathspec elements as an intermediate step (with modificationed based on
  8840. the passed in flags). This way the intermediate strings can then be
  8841. freed after getting the result from 'prefix_path()'.
  8842.  
  8843. Signed-off-by: Brandon Williams <bmwill@google.com>
  8844. Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  8845. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8846.  
  8847. git_exec_path: avoid Coverity warning about unfree()d result
  8848.  
  8849. Technically, it is correct that git_exec_path() returns a possibly
  8850. malloc()ed string returned from system_path(), and it is sometimes
  8851. not allocated. Cache the result in a static variable and make sure
  8852. that we call system_path() only once, which plugs a potential leak.
  8853.  
  8854. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  8855. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8856.  
  8857. blame: output porcelain "previous" header for each file
  8858.  
  8859. It's possible for content currently found in one file to
  8860. have originated in two separate files, each of which may
  8861. have been modified in some single older commit. The
  8862. --porcelain output generates an incorrect "previous" header
  8863. in this case, whereas --line-porcelain gets it right. The
  8864. problem is that the porcelain output tries to omit repeated
  8865. details of commits, and treats "previous" as a property of
  8866. the commit, when it is really a property of the blamed block
  8867. of lines.
  8868.  
  8869. Let's look at an example. In a case like this, you might see
  8870. this output from --line-porcelain:
  8871.  
  8872. SOME_SHA1 1 1 1
  8873. author ...
  8874. committer ...
  8875. previous SOME_SHA1^ file_one
  8876. filename file_one
  8877. ...some line content...
  8878. SOME_SHA1 2 1 1
  8879. author ...
  8880. committer ...
  8881. previous SOME_SHA1^ file_two
  8882. filename file_two
  8883. ...some different content....
  8884.  
  8885. The "filename" fields tell us that the two lines are from
  8886. two different files. But notice that the filename also
  8887. appears in the "previous" field, which tells us where to
  8888. start a re-blame. The second content line never appeared in
  8889. file_one at all, so we would obviously need to re-blame from
  8890. file_two (or possibly even some other file, if had just been
  8891. renamed to file_two in SOME_SHA1).
  8892.  
  8893. So far so good. Now here's what --porcelain looks like:
  8894.  
  8895. SOME_SHA1 1 1 1
  8896. author ...
  8897. committer ...
  8898. previous SOME_SHA1^ file_one
  8899. filename file_one
  8900. ...some line content...
  8901. SOME_SHA1 2 1 1
  8902. filename file_two
  8903. ...some different content....
  8904.  
  8905. We've dropped the author and committer fields from the
  8906. second line, as they would just be repeats. But we can't
  8907. omit "filename", because it depends on the actual block of
  8908. blamed lines, not just the commit. This is handled by
  8909. emit_porcelain_details(), which will show the filename
  8910. either if it is the first mention of the commit _or_ if the
  8911. commit has multiple paths in it.
  8912.  
  8913. But we don't give "previous" the same handling. It's written
  8914. inside emit_one_suspect_detail(), which bails early if we've
  8915. already seen that commit. And so the output above is wrong;
  8916. a reader would assume that the correct place to re-blame
  8917. line two is from file_one, but that's obviously nonsense.
  8918.  
  8919. Let's treat "previous" the same as "filename", and show it
  8920. fresh whenever we know we are in a confusing case like this.
  8921.  
  8922. Signed-off-by: Jeff King <peff@peff.net>
  8923. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8924.  
  8925. blame: handle --no-abbrev
  8926.  
  8927. You can already ask blame for full sha1s with "-l" or with
  8928. "--abbrev=40". But for consistency with other parts of Git,
  8929. we should support "--no-abbrev".
  8930.  
  8931. Worse, blame already accepts --no-abbrev, but it's totally
  8932. broken. When we see --no-abbrev, the abbrev variable is set
  8933. to 0, which is then used as a printf precision. For regular
  8934. sha1s, that means we print nothing at all (which is very
  8935. wrong). For boundary commits we decrement it to "-1", which
  8936. printf interprets as "no limit" (which is almost correct,
  8937. except it misses the 39-length magic explained in the
  8938. previous commit).
  8939.  
  8940. Let's detect --no-abbrev and behave as if --abbrev=40 was
  8941. given.
  8942.  
  8943. Signed-off-by: Jeff King <peff@peff.net>
  8944. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8945.  
  8946. blame: fix alignment with --abbrev=40
  8947.  
  8948. The blame command internally adds 1 to any requested sha1
  8949. abbreviation length, and then subtracts it when outputting a
  8950. boundary commit. This lets regular and boundary sha1s line
  8951. up visually, but it misses one corner case.
  8952.  
  8953. When the requested length is 40, we bump the value to 41.
  8954. But since we only have 40 characters, that's all we can show
  8955. (fortunately the truncation is done by a printf precision
  8956. field, so it never tries to read past the end of the
  8957. buffer). So a normal sha1 shows 40 hex characters, and a
  8958. boundary sha1 shows "^" plus 40 hex characters. The result
  8959. is misaligned.
  8960.  
  8961. The "-l" option to show long sha1s gets around this by
  8962. skipping the "abbrev" variable entirely and just always
  8963. using GIT_SHA1_HEXSZ. This avoids the "+1" issue, but it
  8964. does mean that boundary commits only have 39 characters
  8965. printed. This is somewhat odd, but it does look good
  8966. visually: the results are aligned and left-justified. The
  8967. alternative would be to allocate an extra column that would
  8968. contain either an extra space or the "^" boundary marker.
  8969.  
  8970. As this is by definition the human-readable view, it's
  8971. probably not that big a deal either way (and of course
  8972. --porcelain, etc, correctly produce correct 40-hex sha1s).
  8973. But for consistency, this patch teaches --abbrev=40 to
  8974. produce the same output as "-l" (always left-aligned, with
  8975. 40-hex for normal sha1s, and "^" plus 39-hex for
  8976. boundaries).
  8977.  
  8978. Signed-off-by: Jeff King <peff@peff.net>
  8979. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  8980.  
  8981. files_transaction_commit(): clean up empty directories
  8982.  
  8983. When deleting/pruning references, remove any directories that are made
  8984. empty by the deletion of loose references or of reflogs. Otherwise such
  8985. empty directories can survive forever and accumulate over time. (Even
  8986. 'pack-refs', which is smart enough to remove the parent directories of
  8987. loose references that it prunes, leaves directories that were already
  8988. empty.)
  8989.  
  8990. And now that files_transaction_commit() takes care of deleting the
  8991. parent directories of loose references that it prunes, we don't have to
  8992. do that in prune_ref() anymore.
  8993.  
  8994. This change would be unwise if the *creation* of these directories could
  8995. race with our deletion of them. But the earlier changes in this patch
  8996. series made the creation paths robust against races, so now it is safe
  8997. to tidy them up more aggressively.
  8998.  
  8999. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9000. Reviewed-by: Jeff King <peff@peff.net>
  9001. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9002.  
  9003. try_remove_empty_parents(): teach to remove parents of reflogs, too
  9004.  
  9005. Add a new "flags" parameter that tells the function whether to remove
  9006. empty parent directories of the loose reference file, of the reflog
  9007. file, or both. The new functionality is not yet used.
  9008.  
  9009. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9010. Reviewed-by: Jeff King <peff@peff.net>
  9011. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9012.  
  9013. try_remove_empty_parents(): don't trash argument contents
  9014.  
  9015. It's bad manners and surprising and therefore error-prone.
  9016.  
  9017. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9018. Reviewed-by: Jeff King <peff@peff.net>
  9019. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9020.  
  9021. try_remove_empty_parents(): rename parameter "name" -> "refname"
  9022.  
  9023. This is the standard nomenclature.
  9024.  
  9025. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9026. Reviewed-by: Jeff King <peff@peff.net>
  9027. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9028.  
  9029. delete_ref_loose(): inline function
  9030.  
  9031. It was hardly doing anything anymore, and had only one caller.
  9032.  
  9033. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9034. Reviewed-by: Jeff King <peff@peff.net>
  9035. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9036.  
  9037. delete_ref_loose(): derive loose reference path from lock
  9038.  
  9039. It is simpler to derive the path to the file that must be deleted from
  9040. "lock->ref_name" than from the lock_file object.
  9041.  
  9042. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9043. Reviewed-by: Jeff King <peff@peff.net>
  9044. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9045.  
  9046. log_ref_write_1(): inline function
  9047.  
  9048. Now files_log_ref_write() doesn't do anything beyond call
  9049. log_ref_write_1(), so inline the latter into the former.
  9050.  
  9051. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9052. Reviewed-by: Jeff King <peff@peff.net>
  9053. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9054.  
  9055. log_ref_setup(): manage the name of the reflog file internally
  9056.  
  9057. Instead of writing the name of the reflog file into a strbuf that is
  9058. supplied by the caller but not needed there, write it into a local
  9059. temporary buffer and remove the strbuf parameter entirely.
  9060.  
  9061. And while we're adjusting the function signature, reorder the arguments
  9062. to move the input parameters before the output parameters.
  9063.  
  9064. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9065. Reviewed-by: Jeff King <peff@peff.net>
  9066. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9067.  
  9068. log_ref_write_1(): don't depend on logfile argument
  9069.  
  9070. It's unnecessary to pass a strbuf holding the reflog path up and down
  9071. the call stack now that it is hardly needed by the callers. Remove the
  9072. places where log_ref_write_1() uses it, in preparation for making it
  9073. internal to log_ref_setup().
  9074.  
  9075. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9076. Reviewed-by: Jeff King <peff@peff.net>
  9077. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9078.  
  9079. log_ref_setup(): pass the open file descriptor back to the caller
  9080.  
  9081. This function will most often be called by log_ref_write_1(), which
  9082. wants to append to the reflog file. In that case, it is silly to close
  9083. the file only for the caller to reopen it immediately. So, in the case
  9084. that the file was opened, pass the open file descriptor back to the
  9085. caller.
  9086.  
  9087. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9088. Reviewed-by: Jeff King <peff@peff.net>
  9089. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9090.  
  9091. log_ref_setup(): improve robustness against races
  9092.  
  9093. Change log_ref_setup() to use raceproof_create_file() to create the new
  9094. logfile. This makes it more robust against a race against another
  9095. process that might be trying to clean up empty directories while we are
  9096. trying to create a new logfile.
  9097.  
  9098. This also means that it will only call create_leading_directories() if
  9099. open() fails, which should be a net win. Even in the cases where we are
  9100. willing to create a new logfile, it will usually be the case that the
  9101. logfile already exists, or if not then that the directory containing the
  9102. logfile already exists. In such cases, we will save some work that was
  9103. previously done unconditionally.
  9104.  
  9105. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9106. Reviewed-by: Jeff King <peff@peff.net>
  9107. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9108.  
  9109. log_ref_setup(): separate code for create vs non-create
  9110.  
  9111. The behavior of this function (especially how it handles errors) is
  9112. quite different depending on whether we are willing to create the reflog
  9113. vs. whether we are only trying to open an existing reflog. So separate
  9114. the code paths.
  9115.  
  9116. This also simplifies the next steps.
  9117.  
  9118. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9119. Reviewed-by: Jeff King <peff@peff.net>
  9120. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9121.  
  9122. log_ref_write(): inline function
  9123.  
  9124. This function doesn't do anything beyond call files_log_ref_write(), so
  9125. replace it with the latter at its call sites.
  9126.  
  9127. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9128. Reviewed-by: Jeff King <peff@peff.net>
  9129. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9130.  
  9131. rename_tmp_log(): improve error reporting
  9132.  
  9133. * Don't capitalize error strings
  9134. * Report true paths of affected files
  9135.  
  9136. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9137. Reviewed-by: Jeff King <peff@peff.net>
  9138. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9139.  
  9140. rename_tmp_log(): use raceproof_create_file()
  9141.  
  9142. Besides shortening the code, this saves an unnecessary call to
  9143. safe_create_leading_directories_const() in almost all cases.
  9144.  
  9145. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9146. Reviewed-by: Jeff King <peff@peff.net>
  9147. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9148.  
  9149. lock_ref_sha1_basic(): use raceproof_create_file()
  9150.  
  9151. Instead of coding the retry loop inline, use raceproof_create_file() to
  9152. make lock acquisition safe against directory creation/deletion races.
  9153.  
  9154. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9155. Reviewed-by: Jeff King <peff@peff.net>
  9156. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9157.  
  9158. lock_ref_sha1_basic(): inline constant
  9159.  
  9160. `lflags` is set a single time then never changed, so just inline it.
  9161.  
  9162. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9163. Reviewed-by: Jeff King <peff@peff.net>
  9164. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9165.  
  9166. raceproof_create_file(): new function
  9167.  
  9168. Add a function that tries to create a file and any containing
  9169. directories in a way that is robust against races with other processes
  9170. that might be cleaning up empty directories at the same time.
  9171.  
  9172. The actual file creation is done by a callback function, which, if it
  9173. fails, should set errno to EISDIR or ENOENT according to the convention
  9174. of open(). raceproof_create_file() detects such failures, and
  9175. respectively either tries to delete empty directories that might be in
  9176. the way of the file or tries to create the containing directories. Then
  9177. it retries the callback function.
  9178.  
  9179. This function is not yet used.
  9180.  
  9181. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9182. Reviewed-by: Jeff King <peff@peff.net>
  9183. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9184.  
  9185. safe_create_leading_directories(): set errno on SCLD_EXISTS
  9186.  
  9187. The exit path for SCLD_EXISTS wasn't setting errno, which some callers
  9188. use to generate error messages for the user. Fix the problem and
  9189. document that the function sets errno correctly to help avoid similar
  9190. regressions in the future.
  9191.  
  9192. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9193. Reviewed-by: Jeff King <peff@peff.net>
  9194. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9195.  
  9196. safe_create_leading_directories_const(): preserve errno
  9197.  
  9198. Some implementations of free() change errno (even thought they
  9199. shouldn't):
  9200.  
  9201. https://sourceware.org/bugzilla/show_bug.cgi?id=17924
  9202.  
  9203. So preserve the errno from safe_create_leading_directories() across the
  9204. call to free().
  9205.  
  9206. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9207. Reviewed-by: Jeff King <peff@peff.net>
  9208. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9209.  
  9210. t5505: use "for-each-ref" to test for the non-existence of references
  9211.  
  9212. Instead of looking on the filesystem inside ".git/refs/remotes/origin",
  9213. use "git for-each-ref" to check for leftover references under the
  9214. remote's old name.
  9215.  
  9216. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9217. Reviewed-by: Jeff King <peff@peff.net>
  9218. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9219.  
  9220. refname_is_safe(): correct docstring
  9221.  
  9222. The behavior of refname_is_safe() was changed in
  9223.  
  9224. e40f355 "refname_is_safe(): insist that the refname already be normalized", 2016-04-27
  9225.  
  9226. without a corresponding update to its docstring. The function is in fact
  9227. stricter than documented, because it now insists that the result of
  9228. normalizing the part of a refname following "refs/" is identical to that
  9229. part of the original refname. Fix the docstring.
  9230.  
  9231. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9232. Reviewed-by: Jeff King <peff@peff.net>
  9233. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9234.  
  9235. files_rename_ref(): tidy up whitespace
  9236.  
  9237. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
  9238. Reviewed-by: Jeff King <peff@peff.net>
  9239. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9240.  
  9241. rebase--interactive: count squash commits above 10 correctly
  9242.  
  9243. We generate the squash commit message incrementally running
  9244. a sed script once for each commit. It parses "This is
  9245. a combination of <N> commits" from the first line of the
  9246. existing message, adds one to <N>, and uses the result as
  9247. the number of our current message.
  9248.  
  9249. Since f2d17068fd (i18n: rebase-interactive: mark comments of
  9250. squash for translation, 2016-06-17), the first line may be
  9251. localized, and sed uses a pretty liberal regex, looking for:
  9252.  
  9253. /^#.*([0-9][0-9]*)/
  9254.  
  9255. The "[0-9][0-9]*" tries to match double digits, but it
  9256. doesn't quite work. The first ".*" is greedy, so if you
  9257. have:
  9258.  
  9259. This is a combination of 10 commits.
  9260.  
  9261. it will eat up "This is a combination of 1", leaving "0" to
  9262. match the first "[0-9]" digit, and then skipping the
  9263. optional match of "[0-9]*".
  9264.  
  9265. As a result, the count resets every 10 commits, and a
  9266. 15-commit squash would end up as:
  9267.  
  9268. # This is a combination of 5 commits.
  9269. # This is the 1st commit message:
  9270. ...
  9271. # This is the commit message #2:
  9272. ... and so on ..
  9273. # This is the commit message #10:
  9274. ...
  9275. # This is the commit message #1:
  9276. ...
  9277. # This is the commit message #2:
  9278. ... etc, up to 5 ...
  9279.  
  9280. We can fix this by making the ".*" less greedy. Instead of
  9281. depending on ".*?" working portably, we can just limit the
  9282. match to non-digit characters, which accomplishes the same
  9283. thing.
  9284.  
  9285. Reported-by: Brandon Tolsch <btolsch@gmail.com>
  9286. Signed-off-by: Jeff King <peff@peff.net>
  9287. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9288.  
  9289. branch_get_push: do not segfault when HEAD is detached
  9290.  
  9291. Move the detached HEAD check from branch_get_push_1() to
  9292. branch_get_push() to avoid setting branch->push_tracking_ref when
  9293. branch is NULL.
  9294.  
  9295. Signed-off-by: Kyle Meyer <kyle@kyleam.com>
  9296. Reviewed-by: Jeff King <peff@peff.net>
  9297. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9298.  
  9299. archive-zip: load userdiff config
  9300.  
  9301. Since 4aff646d17 (archive-zip: mark text files in archives,
  9302. 2015-03-05), the zip archiver will look at the userdiff
  9303. driver to decide whether a file is text or binary. This
  9304. usually doesn't need to look any further than the attributes
  9305. themselves (e.g., "-diff", etc). But if the user defines a
  9306. custom driver like "diff=foo", we need to look at
  9307. "diff.foo.binary" in the config. Prior to this patch, we
  9308. didn't actually load it.
  9309.  
  9310. Signed-off-by: Jeff King <peff@peff.net>
  9311. Acked-by: René Scharfe <l.s.r@web.de>
  9312. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9313.  
  9314. giteveryday: unbreak rendering with AsciiDoctor
  9315.  
  9316. The "giteveryday" document has a callout list that contains a code
  9317. block. This is not a problem for AsciiDoc, but AsciiDoctor sadly was
  9318. explicitly designed *not* to render this correctly [*1*]. The symptom is
  9319. an unhelpful
  9320.  
  9321. line 322: callout list item index: expected 1 got 12
  9322. line 325: no callouts refer to list item 1
  9323. line 325: callout list item index: expected 2 got 13
  9324. line 327: no callouts refer to list item 2
  9325.  
  9326. In Git for Windows, we rely on the speed improvement of AsciiDoctor (on
  9327. this developer's machine, `make -j15 html` takes roughly 30 seconds with
  9328. AsciiDoctor, 70 seconds with AsciiDoc), therefore we need a way to
  9329. render this correctly.
  9330.  
  9331. The easiest way out is to simplify the callout list, as suggested by
  9332. AsciiDoctor's author, even while one may very well disagree with him
  9333. that a code block hath no place in a callout list.
  9334.  
  9335. *1*: https://github.com/asciidoctor/asciidoctor/issues/1478
  9336.  
  9337. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  9338. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9339.  
  9340. mingw: add a regression test for pushing to UNC paths
  9341.  
  9342. On Windows, there are "UNC paths" to access network (AKA shared)
  9343. folders, of the form \\server\sharename\directory. This provides a
  9344. convenient way for Windows developers to share their Git repositories
  9345. without having to have a dedicated server.
  9346.  
  9347. Git for Windows v2.11.0 introduced a regression where pushing to said
  9348. UNC paths no longer works, although fetching and cloning still does, as
  9349. reported here: https://github.com/git-for-windows/git/issues/979
  9350.  
  9351. This regression was fixed in 7814fbe3f1 (normalize_path_copy(): fix
  9352. pushing to //server/share/dir on Windows, 2016-12-14).
  9353.  
  9354. Let's make sure that it does not regress again, by introducing a test
  9355. that uses so-called "administrative shares": disk volumes are
  9356. automatically shared under certain circumstances, e.g. the C: drive is
  9357. shared as \\localhost\c$. The test needs to be skipped if the current
  9358. directory is inaccessible via said administrative share, of course.
  9359.  
  9360. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  9361. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9362.  
  9363. contrib: remove gitview
  9364.  
  9365. gitview did not have meaningful contributions since 2007, which gives the
  9366. impression it is either a mature or dead project.
  9367.  
  9368. In both cases we should not carry it in git.git as the README for contrib
  9369. states we only want to carry experimental things to give early exposure.
  9370.  
  9371. Recently a security vulnerability was reported by Javantea, so the decision
  9372. to either fix the issue or remove the code in question becomes a bit
  9373. more urgent.
  9374.  
  9375. Reported-by: Javantea <jvoss@altsci.com>
  9376. Signed-off-by: Stefan Beller <sbeller@google.com>
  9377. Acked-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
  9378. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9379.  
  9380. don't use test_must_fail with grep
  9381.  
  9382. test_must_fail should only be used for testing git commands. To test the
  9383. failure of other commands use `!`.
  9384.  
  9385. Reported-by: Stefan Beller <sbeller@google.com>
  9386. Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
  9387. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9388.  
  9389. submodule.c: use GIT_DIR_ENVIRONMENT consistently
  9390.  
  9391. In C code we have the luxury of having constants for all the important
  9392. things that are hard coded. This is the only place in C that hard codes
  9393. the git directory environment variable, so fix it.
  9394.  
  9395. Signed-off-by: Stefan Beller <sbeller@google.com>
  9396. Reviewed-by: Jeff King <peff@peff.net>
  9397. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9398.  
  9399. l10n: fixes to Catalan translation
  9400.  
  9401. Signed-off-by: Jordi Mas <jmas@softcatala.org>
  9402.  
  9403. l10n: zh_CN: review for git v2.11.0 l10n
  9404.  
  9405. Signed-off-by: Ray Chen <oldsharp@gmail.com>
  9406. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
  9407.  
  9408. Merge branch 'master' of https://github.com/Softcatala/git-po
  9409.  
  9410. * 'master' of https://github.com/Softcatala/git-po:
  9411. l10n: New Catalan translation maintainer
  9412.  
  9413. gitk: ru.po: Update Russian translation
  9414.  
  9415. Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
  9416. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  9417.  
  9418. git-p4: do not pass '-r 0' to p4 commands
  9419.  
  9420. git-p4 crashes when used with a very old p4 client version
  9421. that does not support the '-r <number>' option in its commands.
  9422.  
  9423. Allow making git-p4 work with old p4 clients by setting git-p4.retries to 0.
  9424.  
  9425. Alternatively git-p4.retries could be made opt-in.
  9426. But since only very old, barely maintained p4 versions don't support
  9427. the '-r' option, the setting-retries-to-0 workaround would do.
  9428.  
  9429. The "-r retries" option is present in Perforce 2012.2 Command Reference,
  9430. but absent from Perforce 2012.1 Command Reference.
  9431.  
  9432. Signed-off-by: Igor Kushnir <igorkuo@gmail.com>
  9433. Acked-by: Lars Schneider <larsxschneider@gmail.com>
  9434. Reviewed-by: Luke Diamand <luke@diamand.org>
  9435. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9436.  
  9437. repack: die on incremental + write-bitmap-index
  9438.  
  9439. The bitmap index only works for single packs, so requesting an
  9440. incremental repack with bitmap indexes makes no sense.
  9441.  
  9442. Signed-off-by: David Turner <dturner@twosigma.com>
  9443. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9444.  
  9445. auto gc: don't write bitmaps for incremental repacks
  9446.  
  9447. When git gc --auto does an incremental repack of loose objects, we do
  9448. not expect to be able to write a bitmap; it is very likely that
  9449. objects in the new pack will have references to objects outside of the
  9450. pack. So we shouldn't try to write a bitmap, because doing so will
  9451. likely issue a warning.
  9452.  
  9453. This warning was making its way into gc.log. When the gc.log was
  9454. present, future auto gc runs would refuse to run.
  9455.  
  9456. Patch by Jeff King.
  9457. Bug report, test, and commit message by David Turner.
  9458.  
  9459. Signed-off-by: David Turner <dturner@twosigma.com>
  9460. Signed-off-by: Jeff King <peff@peff.net>
  9461. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9462.  
  9463. rm: absorb a submodules git dir before deletion
  9464.  
  9465. When deleting a submodule, we need to keep the actual git directory around,
  9466. such that we do not lose local changes in there and at a later checkout
  9467. of the submodule we don't need to clone it again.
  9468.  
  9469. Now that the functionality is available to absorb the git directory of a
  9470. submodule, rewrite the checking in git-rm to not complain, but rather
  9471. relocate the git directories inside the superproject.
  9472.  
  9473. An alternative solution was discussed to have a function
  9474. `depopulate_submodule`. That would couple the check for its git directory
  9475. and possible relocation before the the removal, such that it is less
  9476. likely to miss the check in the future. But the indirection with such
  9477. a function added seemed also complex. The reason for that was that this
  9478. possible move of the git directory was also implemented in
  9479. `ok_to_remove_submodule`, such that this function could truthfully
  9480. answer whether it is ok to remove the submodule.
  9481.  
  9482. The solution proposed here defers all these checks to the caller.
  9483.  
  9484. Signed-off-by: Stefan Beller <sbeller@google.com>
  9485. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9486.  
  9487. submodule: rename and add flags to ok_to_remove_submodule
  9488.  
  9489. In different contexts the question "Is it ok to delete a submodule?"
  9490. may be answered differently.
  9491.  
  9492. In 293ab15eea (submodule: teach rm to remove submodules unless they
  9493. contain a git directory, 2012-09-26) a case was made that we can safely
  9494. ignore ignored untracked files for removal as we explicitely ask for the
  9495. removal of the submodule.
  9496.  
  9497. In a later patch we want to remove submodules even when the user doesn't
  9498. explicitly ask for it (e.g. checking out a tree-ish in which the submodule
  9499. doesn't exist). In that case we want to be more careful when it comes
  9500. to deletion of untracked files. As of this patch it is unclear how this
  9501. will be implemented exactly, so we'll offer flags in which the caller
  9502. can specify how the different untracked files ought to be handled.
  9503.  
  9504. As the flags allow the function to not die on an error when spawning
  9505. a child process, we need to find an appropriate return code for the
  9506. case when the child process could not be started. As in that case we
  9507. cannot tell if the submodule is ok to remove, we'd want to return 'false'.
  9508.  
  9509. As only 0 is understood as false, rename the function to invert the
  9510. meaning, i.e. the return code of 0 signals the removal of the submodule
  9511. is fine, and other values can be used to return a more precise answer
  9512. what went wrong.
  9513.  
  9514. Signed-off-by: Stefan Beller <sbeller@google.com>
  9515. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9516.  
  9517. submodule: modernize ok_to_remove_submodule to use argv_array
  9518.  
  9519. Instead of constructing the NULL terminated array ourselves, we
  9520. should make use of the argv_array infrastructure.
  9521.  
  9522. While at it, adapt the error messages to reflect the actual invocation.
  9523.  
  9524. Signed-off-by: Stefan Beller <sbeller@google.com>
  9525. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9526.  
  9527. submodule.h: add extern keyword to functions
  9528.  
  9529. As the upcoming series will add a lot of functions to the submodule
  9530. header, let's first make the header consistent to the rest of the project
  9531. by adding the extern keyword to functions.
  9532.  
  9533. As per the CodingGuidelines we try to stay below 80 characters per line,
  9534. so adapt all those functions to stay below 80 characters that are already
  9535. using more than one line. Those function using just one line are better
  9536. kept in one line than breaking them up into multiple lines just for the
  9537. goal of staying below the character limit as it makes grepping
  9538. for functions easier if they are one liners.
  9539.  
  9540. Signed-off-by: Stefan Beller <sbeller@google.com>
  9541. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9542.  
  9543. worktree: initialize return value for submodule_uses_worktrees
  9544.  
  9545. When the worktrees directory is empty, the `ret` will be returned
  9546. uninitialized. Fix it by initializing the value.
  9547.  
  9548. Signed-off-by: Stefan Beller <sbeller@google.com>
  9549. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9550.  
  9551. Fourth batch for 2.12
  9552.  
  9553. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9554.  
  9555. Merge branch 'jc/lock-report-on-error'
  9556.  
  9557. * jc/lock-report-on-error:
  9558. lockfile: move REPORT_ON_ERROR bit elsewhere
  9559.  
  9560. lockfile: move REPORT_ON_ERROR bit elsewhere
  9561.  
  9562. There was LOCK_NO_DEREF defined as 2 = 1<<1 with the same value,
  9563. which was missed due to a huge comment block. Deconflict by moving
  9564. the new one to 4 = 1<<2 for now.
  9565.  
  9566. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9567.  
  9568. Merge branch 'js/mingw-isatty'
  9569.  
  9570. Update the isatty() emulation for Windows by updating the previous
  9571. hack that depended on internals of (older) MSVC runtime.
  9572.  
  9573. * js/mingw-isatty:
  9574. mingw: replace isatty() hack
  9575. mingw: fix colourization on Cygwin pseudo terminals
  9576. mingw: adjust is_console() to work with stdin
  9577.  
  9578. Merge branch 'ls/p4-lfs'
  9579.  
  9580. Update GitLFS integration with "git p4".
  9581.  
  9582. * ls/p4-lfs:
  9583. git-p4: add diff/merge properties to .gitattributes for GitLFS files
  9584.  
  9585. Merge branch 'va/i18n-even-more'
  9586.  
  9587. * va/i18n-even-more:
  9588. i18n: fix misconversion in shell scripts
  9589.  
  9590. Merge branch 'lt/shortlog-by-committer'
  9591.  
  9592. "git shortlog" learned "--committer" option to group commits by
  9593. committer, instead of author.
  9594.  
  9595. * lt/shortlog-by-committer:
  9596. t4201: make tests work with and without the MINGW prerequiste
  9597. shortlog: test and document --committer option
  9598. shortlog: group by committer information
  9599.  
  9600. Merge branch 'mk/mingw-winansi-ttyname-termination-fix'
  9601.  
  9602. A potential but unlikely buffer overflow in Windows port has been
  9603. fixed.
  9604.  
  9605. * mk/mingw-winansi-ttyname-termination-fix:
  9606. mingw: consider that UNICODE_STRING::Length counts bytes
  9607.  
  9608. Merge branch 'gv/p4-multi-path-commit-fix'
  9609.  
  9610. "git p4" that tracks multile p4 paths imported a single changelist
  9611. that touches files in these multiple paths as one commit, followed
  9612. by many empty commits. This has been fixed.
  9613.  
  9614. * gv/p4-multi-path-commit-fix:
  9615. git-p4: fix multi-path changelist empty commits
  9616.  
  9617. Merge branch 'jk/difftool-in-subdir'
  9618.  
  9619. Even though an fix was attempted in Git 2.9.3 days, but running
  9620. "git difftool --dir-diff" from a subdirectory never worked. This
  9621. has been fixed.
  9622.  
  9623. * jk/difftool-in-subdir:
  9624. difftool: rename variables for consistency
  9625. difftool: chdir as early as possible
  9626. difftool: sanitize $workdir as early as possible
  9627. difftool: fix dir-diff index creation when in a subdirectory
  9628.  
  9629. Merge branch 'ld/p4-compare-dir-vs-symlink'
  9630.  
  9631. "git p4" misbehaved when swapping a directory and a symbolic link.
  9632.  
  9633. * ld/p4-compare-dir-vs-symlink:
  9634. git-p4: avoid crash adding symlinked directory
  9635.  
  9636. Merge branch 'ls/filter-process'
  9637.  
  9638. Doc update.
  9639.  
  9640. * ls/filter-process:
  9641. t0021: fix flaky test
  9642. docs: warn about possible '=' in clean/smudge filter process values
  9643.  
  9644. Merge branch 'bw/transport-protocol-policy'
  9645.  
  9646. Finer-grained control of what protocols are allowed for transports
  9647. during clone/fetch/push have been enabled via a new configuration
  9648. mechanism.
  9649.  
  9650. * bw/transport-protocol-policy:
  9651. http: respect protocol.*.allow=user for http-alternates
  9652. transport: add from_user parameter to is_transport_allowed
  9653. http: create function to get curl allowed protocols
  9654. transport: add protocol policy config option
  9655. http: always warn if libcurl version is too old
  9656. lib-proto-disable: variable name fix
  9657.  
  9658. Merge branch 'cp/merge-continue'
  9659.  
  9660. "git merge --continue" has been added as a synonym to "git commit"
  9661. to conclude a merge that has stopped due to conflicts.
  9662.  
  9663. * cp/merge-continue:
  9664. merge: mark usage error strings for translation
  9665. merge: ensure '--abort' option takes no arguments
  9666. completion: add --continue option for merge
  9667. merge: add '--continue' option as a synonym for 'git commit'
  9668.  
  9669. Merge branch 'va/i18n-perl-scripts'
  9670.  
  9671. Porcelain scripts written in Perl are getting internationalized.
  9672.  
  9673. * va/i18n-perl-scripts:
  9674. i18n: difftool: mark warnings for translation
  9675. i18n: send-email: mark composing message for translation
  9676. i18n: send-email: mark string with interpolation for translation
  9677. i18n: send-email: mark warnings and errors for translation
  9678. i18n: send-email: mark strings for translation
  9679. i18n: add--interactive: mark status words for translation
  9680. i18n: add--interactive: remove %patch_modes entries
  9681. i18n: add--interactive: mark edit_hunk_manually message for translation
  9682. i18n: add--interactive: i18n of help_patch_cmd
  9683. i18n: add--interactive: mark patch prompt for translation
  9684. i18n: add--interactive: mark plural strings
  9685. i18n: clean.c: match string with git-add--interactive.perl
  9686. i18n: add--interactive: mark strings with interpolation for translation
  9687. i18n: add--interactive: mark simple here-documents for translation
  9688. i18n: add--interactive: mark strings for translation
  9689. Git.pm: add subroutines for commenting lines
  9690.  
  9691. Merge branch 'sb/submodule-config-cleanup'
  9692.  
  9693. Minor code clean-up.
  9694.  
  9695. * sb/submodule-config-cleanup:
  9696. submodule-config: clarify parsing of null_sha1 element
  9697. submodule-config: rename commit_sha1 to treeish_name
  9698. submodule config: inline config_from_{name, path}
  9699.  
  9700. Merge branch 'jc/push-default-explicit'
  9701.  
  9702. A lazy "git push" without refspec did not internally use a fully
  9703. specified refspec to perform 'current', 'simple', or 'upstream'
  9704. push, causing unnecessary "ambiguous ref" errors.
  9705.  
  9706. * jc/push-default-explicit:
  9707. push: test pushing ambiguously named branches
  9708. push: do not use potentially ambiguous default refspec
  9709.  
  9710. l10n: New Catalan translation maintainer
  9711.  
  9712. Signed-off-by: Jordi Mas <jmas@softcatala.org>
  9713.  
  9714. diff: retire "compaction" heuristics
  9715.  
  9716. When a patch inserts a block of lines, whose last lines are the
  9717. same as the existing lines that appear before the inserted block,
  9718. "git diff" can choose any place between these existing lines as the
  9719. boundary between the pre-context and the added lines (adjusting the
  9720. end of the inserted block as appropriate) to come up with variants
  9721. of the same patch, and some variants are easier to read than others.
  9722.  
  9723. We have been trying to improve the choice of this boundary, and Git
  9724. 2.11 shipped with an experimental "compaction-heuristic". Since
  9725. then another attempt to improve the logic further resulted in a new
  9726. "indent-heuristic" logic. It is agreed that the latter gives better
  9727. result overall, and the former outlived its usefulness.
  9728.  
  9729. Retire "compaction", and keep "indent" as an experimental feature.
  9730. The latter hopefully will be turned on by default in a future
  9731. release, but that should be done as a separate step.
  9732.  
  9733. Suggested-by: Jeff King <peff@peff.net>
  9734. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9735.  
  9736. git-svn: escape backslashes in refnames
  9737.  
  9738. This brings git-svn refname escaping up-to-date with
  9739. commit a4c2e69936df8dd0b071b85664c6cc6a4870dd84
  9740. ("Disallow '\' in ref names") from May 2009.
  9741.  
  9742. Reported-by: Michael Fladischer <michael@fladi.at>
  9743. Message-ID: <cb8cd9b1-9882-64d2-435d-40d0b2b82d59@fladi.at>
  9744. Signed-off-by: Eric Wong <e@80x24.org>
  9745.  
  9746. config.abbrev: document the new default that auto-scales
  9747.  
  9748. We somehow forgot to update the "default is 7" in the
  9749. documentation. Also give a way to explicitly ask the auto-scaling
  9750. by setting config.abbrev to "auto".
  9751.  
  9752. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9753.  
  9754. config.c: handle lock file in error case in git_config_rename_...
  9755.  
  9756. We could rely on atexit() to clean up everything, but let's be
  9757. explicit when we can. And it's good anyway because the function is
  9758. called the second time in the same process, we're in trouble.
  9759.  
  9760. This function should not affect the successful case because after
  9761. commit_lock_file() is called, rollback_lock_file() becomes no-op,
  9762. as long as it is initialized.
  9763.  
  9764. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  9765. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9766.  
  9767. grep: search history of moved submodules
  9768.  
  9769. If a submodule was renamed at any point since it's inception then if you
  9770. were to try and grep on a commit prior to the submodule being moved, you
  9771. wouldn't be able to find a working directory for the submodule since the
  9772. path in the past is different from the current path.
  9773.  
  9774. This patch teaches grep to find the .git directory for a submodule in
  9775. the parents .git/modules/ directory in the event the path to the
  9776. submodule in the commit that is being searched differs from the state of
  9777. the currently checked out commit. If found, the child process that is
  9778. spawned to grep the submodule will chdir into its gitdir instead of a
  9779. working directory.
  9780.  
  9781. In order to override the explicit setting of submodule child process's
  9782. gitdir environment variable (which was introduced in '10f5c526')
  9783. `GIT_DIR_ENVIORMENT` needs to be pushed onto child process's env_array.
  9784. This allows the searching of history from a submodule's gitdir, rather
  9785. than from a working directory.
  9786.  
  9787. Signed-off-by: Brandon Williams <bmwill@google.com>
  9788. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9789.  
  9790. grep: enable recurse-submodules to work on <tree> objects
  9791.  
  9792. Teach grep to recursively search in submodules when provided with a
  9793. <tree> object. This allows grep to search a submodule based on the state
  9794. of the submodule that is present in a commit of the super project.
  9795.  
  9796. When grep is provided with a <tree> object, the name of the object is
  9797. prefixed to all output. In order to provide uniformity of output
  9798. between the parent and child processes the option `--parent-basename`
  9799. has been added so that the child can preface all of it's output with the
  9800. name of the parent's object instead of the name of the commit SHA1 of
  9801. the submodule. This changes output from the command
  9802. `git grep -e. -l --recurse-submodules HEAD` from:
  9803.  
  9804. HEAD:file
  9805. <commit sha1 of submodule>:sub/file
  9806.  
  9807. to:
  9808.  
  9809. HEAD:file
  9810. HEAD:sub/file
  9811.  
  9812. Signed-off-by: Brandon Williams <bmwill@google.com>
  9813. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9814.  
  9815. grep: optionally recurse into submodules
  9816.  
  9817. Allow grep to recognize submodules and recursively search for patterns in
  9818. each submodule. This is done by forking off a process to recursively
  9819. call grep on each submodule. The top level --super-prefix option is
  9820. used to pass a path to the submodule which can in turn be used to
  9821. prepend to output or in pathspec matching logic.
  9822.  
  9823. Recursion only occurs for submodules which have been initialized and
  9824. checked out by the parent project. If a submodule hasn't been
  9825. initialized and checked out it is simply skipped.
  9826.  
  9827. In order to support the existing multi-threading infrastructure in grep,
  9828. output from each child process is captured in a strbuf so that it can be
  9829. later printed to the console in an ordered fashion.
  9830.  
  9831. To limit the number of theads that are created, each child process has
  9832. half the number of threads as its parents (minimum of 1), otherwise we
  9833. potentailly have a fork-bomb.
  9834.  
  9835. Signed-off-by: Brandon Williams <bmwill@google.com>
  9836. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9837.  
  9838. grep: add submodules as a grep source type
  9839.  
  9840. Add `GREP_SOURCE_SUBMODULE` as a grep_source type and cases for this new
  9841. type in the various switch statements in grep.c.
  9842.  
  9843. When initializing a grep_source with type `GREP_SOURCE_SUBMODULE` the
  9844. identifier can either be NULL (to indicate that the working tree will be
  9845. used) or a SHA1 (the REV of the submodule to be grep'd). If the
  9846. identifier is a SHA1 then we want to fall through to the
  9847. `GREP_SOURCE_SHA1` case to handle the copying of the SHA1.
  9848.  
  9849. Signed-off-by: Brandon Williams <bmwill@google.com>
  9850. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9851.  
  9852. submodules: load gitmodules file from commit sha1
  9853.  
  9854. teach submodules to load a '.gitmodules' file from a commit sha1. This
  9855. enables the population of the submodule_cache to be based on the state
  9856. of the '.gitmodules' file from a particular commit.
  9857.  
  9858. Signed-off-by: Brandon Williams <bmwill@google.com>
  9859. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9860.  
  9861. submodules: add helper to determine if a submodule is initialized
  9862.  
  9863. Add the `is_submodule_initialized()` helper function to submodules.c.
  9864. `is_submodule_initialized()` performs a check to determine if the
  9865. submodule at the given path has been initialized.
  9866.  
  9867. Signed-off-by: Brandon Williams <bmwill@google.com>
  9868. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9869.  
  9870. submodules: add helper to determine if a submodule is populated
  9871.  
  9872. Add the `is_submodule_populated()` helper function to submodules.c.
  9873. `is_submodule_populated()` performes a check to see if a submodule has
  9874. been checkout out (and has a valid .git directory/file) at the given path.
  9875.  
  9876. Signed-off-by: Brandon Williams <bmwill@google.com>
  9877. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9878.  
  9879. real_path: canonicalize directory separators in root parts
  9880.  
  9881. When an absolute path is resolved, resolution begins at the first path
  9882. component after the root part. The root part is just copied verbatim,
  9883. because it must not be inspected for symbolic links. For POSIX paths,
  9884. this is just the initial slash, but on Windows, the root part has the
  9885. forms c:\ or \\server\share. We do want to canonicalize the back-slashes
  9886. in the root part because these parts are compared to the result of
  9887. getcwd(), which does return a fully canonicalized path.
  9888.  
  9889. Factor out a helper that splits off the root part, and have it
  9890. canonicalize the copied part.
  9891.  
  9892. This change was prompted because t1504-ceiling-dirs.sh caught a breakage
  9893. in GIT_CEILING_DIRECTORIES handling on Windows.
  9894.  
  9895. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
  9896. Acked-by: Brandon Williams <bmwill@google.com>
  9897. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9898.  
  9899. mingw: replace isatty() hack
  9900.  
  9901. Git for Windows has carried a patch that depended on internals
  9902. of MSVC runtime, but it does not work correctly with recent MSVC
  9903. runtime. A replacement was written originally for compiling
  9904. with VC++. The patch in this message is a backport of that
  9905. replacement, and it also fixes the previous attempt to make
  9906. isatty() tell that /dev/null is *not* an interactive terminal.
  9907.  
  9908. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  9909. Tested-by: Beat Bolli <dev+git@drbeat.li>
  9910. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  9911. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9912.  
  9913. mingw: fix colourization on Cygwin pseudo terminals
  9914.  
  9915. Git only colours the output and uses pagination if isatty() returns 1.
  9916. MSYS2 and Cygwin emulate pseudo terminals via named pipes, meaning that
  9917. isatty() returns 0.
  9918.  
  9919. f7f90e0f4f (mingw: make isatty() recognize MSYS2's pseudo terminals
  9920. (/dev/pty*), 2016-04-27) fixed this for MSYS2 terminals, but not for
  9921. Cygwin.
  9922.  
  9923. The named pipes that Cygwin and MSYS2 use are very similar. MSYS2 PTY pipes
  9924. are called 'msys-*-pty*' and Cygwin uses 'cygwin-*-pty*'. This commit
  9925. modifies the existing check to allow both MSYS2 and Cygwin PTY pipes to be
  9926. identified as TTYs.
  9927.  
  9928. Note that pagination is still broken when running Git for Windows from
  9929. within Cygwin, as MSYS2's less.exe is spawned (and does not like to
  9930. interact with Cygwin's PTY).
  9931.  
  9932. This partially fixes https://github.com/git-for-windows/git/issues/267
  9933.  
  9934. Signed-off-by: Alan Davies <alan.n.davies@gmail.com>
  9935. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  9936. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9937.  
  9938. mingw: adjust is_console() to work with stdin
  9939.  
  9940. When determining whether a handle corresponds to a *real* Win32 Console
  9941. (as opposed to, say, a character device such as /dev/null), we use the
  9942. GetConsoleOutputBufferInfo() function as a tell-tale.
  9943.  
  9944. However, that does not work for *input* handles associated with a
  9945. console. Let's just use the GetConsoleMode() function for input handles,
  9946. and since it does not work on output handles fall back to the previous
  9947. method for those.
  9948.  
  9949. This patch prepares for using is_console() instead of my previous
  9950. misguided attempt in cbb3f3c9b1 (mingw: intercept isatty() to handle
  9951. /dev/null as Git expects it, 2016-12-11) that broke everything on
  9952. Windows.
  9953.  
  9954. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  9955. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9956.  
  9957. Third batch for 2.12
  9958.  
  9959. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  9960.  
  9961. Merge branch 'jt/mailinfo-fold-in-body-headers'
  9962.  
  9963. Fix for NDEBUG builds.
  9964.  
  9965. * jt/mailinfo-fold-in-body-headers:
  9966. mailinfo.c: move side-effects outside of assert
  9967.  
  9968. Merge branch 'jk/index-pack-wo-repo-from-stdin'
  9969.  
  9970. "git index-pack --stdin" needs an access to an existing repository,
  9971. but "git index-pack file.pack" to generate an .idx file that
  9972. corresponds to a packfile does not.
  9973.  
  9974. * jk/index-pack-wo-repo-from-stdin:
  9975. index-pack: skip collision check when not in repository
  9976. t: use nongit() function where applicable
  9977. index-pack: complain when --stdin is used outside of a repo
  9978. t5000: extract nongit function to test-lib-functions.sh
  9979.  
  9980. Merge branch 'jk/parseopt-usage-msg-opt'
  9981.  
  9982. The function usage_msg_opt() has been updated to say "fatal:"
  9983. before the custom message programs give, when they want to die
  9984. with a message about wrong command line options followed by the
  9985. standard usage string.
  9986.  
  9987. * jk/parseopt-usage-msg-opt:
  9988. parse-options: print "fatal:" before usage_msg_opt()
  9989.  
  9990. Merge branch 'jk/quote-env-path-list-component'
  9991.  
  9992. A recent update to receive-pack to make it easier to drop garbage
  9993. objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot
  9994. have a pathname with a colon in it (no surprise!), and this in turn
  9995. made it impossible to push into a repository at such a path. This
  9996. has been fixed by introducing a quoting mechanism used when
  9997. appending such a path to the colon-separated list.
  9998.  
  9999. * jk/quote-env-path-list-component:
  10000. t5615-alternate-env: double-quotes in file names do not work on Windows
  10001. t5547-push-quarantine: run the path separator test on Windows, too
  10002. tmp-objdir: quote paths we add to alternates
  10003. alternates: accept double-quoted paths
  10004.  
  10005. Merge branch 'vs/submodule-clone-nested-submodules-alternates'
  10006.  
  10007. "git clone --reference $there --recurse-submodules $super" has been
  10008. taught to guess repositories usable as references for submodules of
  10009. $super that are embedded in $there while making a clone of the
  10010. superproject borrow objects from $there; extend the mechanism to
  10011. also allow submodules of these submodules to borrow repositories
  10012. embedded in these clones of the submodules embedded in the clone of
  10013. the superproject.
  10014.  
  10015. * vs/submodule-clone-nested-submodules-alternates:
  10016. submodule--helper: set alternateLocation for cloned submodules
  10017.  
  10018. Merge branch 'nd/shallow-fixup'
  10019.  
  10020. Code cleanup in shallow boundary computation.
  10021.  
  10022. * nd/shallow-fixup:
  10023. shallow.c: remove useless code
  10024. shallow.c: bit manipulation tweaks
  10025. shallow.c: avoid theoretical pointer wrap-around
  10026. shallow.c: make paint_alloc slightly more robust
  10027. shallow.c: stop abusing COMMIT_SLAB_SIZE for paint_info's memory pools
  10028. shallow.c: rename fields in paint_info to better express their purposes
  10029.  
  10030. Merge branch 'sb/sequencer-abort-safety'
  10031.  
  10032. Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
  10033. to where cherry-pick started while picking multiple changes, when
  10034. the cherry-pick stopped to ask for help from the user, and the user
  10035. did "git reset --hard" to a different commit in order to re-attempt
  10036. the operation.
  10037.  
  10038. * sb/sequencer-abort-safety:
  10039. Revert "sequencer: remove useless get_dir() function"
  10040. sequencer: remove useless get_dir() function
  10041. sequencer: make sequencer abort safer
  10042. t3510: test that cherry-pick --abort does not unsafely change HEAD
  10043. am: change safe_to_abort()'s not rewinding error into a warning
  10044. am: fix filename in safe_to_abort() error message
  10045.  
  10046. t5615-alternate-env: double-quotes in file names do not work on Windows
  10047.  
  10048. Protect a recently added test case with !MINGW.
  10049.  
  10050. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
  10051. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10052.  
  10053. fast-import: properly fanout notes when tree is imported
  10054.  
  10055. In typical uses of fast-import, trees are inherited from a parent
  10056. commit. In that case, the tree_entry for the branch looks like:
  10057.  
  10058. .versions[1].sha1 = $some_sha1
  10059. .tree = <tree structure loaded from $some_sha1>
  10060.  
  10061. However, when trees are imported, rather than inherited, that is not the
  10062. case. One can import a tree with a filemodify command, replacing the
  10063. root tree object.
  10064.  
  10065. e.g.
  10066. "M 040000 $some_sha1 \n"
  10067.  
  10068. In this case, the tree_entry for the branch looks like:
  10069.  
  10070. .versions[1].sha1 = $some_sha1
  10071. .tree = NULL
  10072.  
  10073. When adding new notes with the notemodify command, do_change_note_fanout
  10074. is called to get a notes count, and to do so, it loops over the
  10075. tree_entry->tree, but doesn't do anything when the tree is NULL.
  10076.  
  10077. In the latter case above, it means do_change_note_fanout thinks the tree
  10078. contains no notes, and new notes are added with no fanout.
  10079.  
  10080. Interestingly, do_change_note_fanout does check whether subdirectories
  10081. have a NULL .tree, in which case it uses load_tree(). Which means the
  10082. right behaviour happens when using the filemodify command to import
  10083. subdirectories.
  10084.  
  10085. This change makes do_change_note_fanount call load_tree() whenever the
  10086. tree_entry it is given has no tree loaded, making all cases handled
  10087. equally.
  10088.  
  10089. Signed-off-by: Mike Hommey <mh@glandium.org>
  10090. Reviewed-by: Johan Herland <johan@herland.net>
  10091. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10092.  
  10093. t4201: make tests work with and without the MINGW prerequiste
  10094.  
  10095. Make sure the tests do not depend on the result of the previous
  10096. tests. With MINGW prerequisite satisfied, a "reset to original and
  10097. rebuild" in an earlier test was skipped, resulting in different
  10098. history being tested with this and the next tests.
  10099.  
  10100. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10101.  
  10102. push: add option to push only submodules
  10103.  
  10104. Teach push the --recurse-submodules=only option. This enables push
  10105. to recursively push all unpushed submodules while leaving the
  10106. superproject unpushed.
  10107.  
  10108. This is a desirable feature in a scenario where updates to the
  10109. superproject are handled automatically by some other means, perhaps
  10110. a tool like Gerrit code review. In this scenario, a developer could
  10111. make a change which spans multiple submodules and then push their
  10112. commits for code review. Upon completion of the code review, their
  10113. commits can be accepted and applied to their respective submodules
  10114. while the code review tool can then automatically update the
  10115. superproject to the most recent SHA1 of each submodule. This would
  10116. reduce the merge conflicts in the superproject that could occur if
  10117. multiple people are contributing to the same submodule.
  10118.  
  10119. Signed-off-by: Brandon Williams <bmwill@google.com>
  10120. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10121.  
  10122. submodules: add RECURSE_SUBMODULES_ONLY value
  10123.  
  10124. Add the `RECURSE_SUBMODULES_ONLY` enum value to submodule.h. This enum
  10125. value will be used in a later patch to push to indicate that only
  10126. submodules should be pushed, while the superproject should remain
  10127. unpushed.
  10128.  
  10129. Signed-off-by: Brandon Williams <bmwill@google.com>
  10130. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10131.  
  10132. transport: reformat flag #defines to be more readable
  10133.  
  10134. All of the #defines for the TRANSPORT_* flags are hardcoded to be
  10135. powers of two. This can be error prone when adding a new flag and
  10136. is difficult to read. Update these defines to instead use a shift
  10137. operation to generate the flags and reformat them.
  10138.  
  10139. Signed-off-by: Brandon Williams <bmwill@google.com>
  10140. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10141.  
  10142. config.c: rename label unlock_and_out
  10143.  
  10144. There are two ways to unlock a file: commit, or revert. Rename it to
  10145. commit_and_out to avoid confusion.
  10146.  
  10147. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  10148. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10149.  
  10150. config.c: handle error case for fstat() calls
  10151.  
  10152. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  10153. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10154.  
  10155. git-p4: add diff/merge properties to .gitattributes for GitLFS files
  10156.  
  10157. The `git lfs track` command generates a .gitattributes file with diff
  10158. and merge properties [1]. Set the same .gitattributes format for files
  10159. tracked with GitLFS in git-p4.
  10160.  
  10161. [1] https://github.com/git-lfs/git-lfs/blob/v1.5.3/commands/command_track.go#L121
  10162.  
  10163. Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
  10164. Reviewed-by: Luke Diamand <luke@diamand.org>
  10165. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10166.  
  10167. i18n: fix misconversion in shell scripts
  10168.  
  10169. An earlier series that was merged at 2703572b3a ("Merge branch
  10170. 'va/i18n-even-more'", 2016-07-13) failed to use $(eval_gettext
  10171. "string with \$variable interpolation") and instead used gettext in
  10172. a few places, and ended up showing the variable names in the
  10173. message, e.g.
  10174.  
  10175. $ git submodule
  10176. fatal: $program_name cannot be used without a working tree.
  10177.  
  10178. Catch these mistakes with
  10179.  
  10180. $ git grep -n '[^_]gettext .*\\\$'
  10181.  
  10182. and fix them all to use eval_gettext instead.
  10183.  
  10184. Reported-by: Josh Bleecher Snyder
  10185. Acked-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10186. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10187.  
  10188. mailinfo.c: move side-effects outside of assert
  10189.  
  10190. Since 6b4b013f18 (mailinfo: handle in-body header continuations,
  10191. 2016-09-20, v2.11.0) mailinfo.c has contained new code with an
  10192. assert of the form:
  10193.  
  10194. assert(call_a_function(...))
  10195.  
  10196. The function in question, check_header, has side effects. This
  10197. means that when NDEBUG is defined during a release build the
  10198. function call is omitted entirely, the side effects do not
  10199. take place and tests (fortunately) start failing.
  10200.  
  10201. Since the only time that mi->inbody_header_accum is appended to is
  10202. in check_inbody_header, and appending onto a blank
  10203. mi->inbody_header_accum always happens when is_inbody_header is
  10204. true, this guarantees a prefix that causes check_header to always
  10205. return true.
  10206.  
  10207. Therefore replace the assert with an if !check_header + DIE
  10208. combination to reflect this.
  10209.  
  10210. Helped-by: Jonathan Tan <jonathantanmy@google.com>
  10211. Helped-by: Jeff King <peff@peff.net>
  10212. Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
  10213. Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
  10214. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10215.  
  10216. mingw: consider that UNICODE_STRING::Length counts bytes
  10217.  
  10218. UNICODE_STRING::Length field means size of buffer in bytes[1],
  10219. despite of buffer itself being array of wchar_t. Because of that
  10220. terminating zero is placed twice as far. Fix it.
  10221.  
  10222. [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa380518.aspx
  10223.  
  10224. Signed-off-by: Max Kirillov <max@max630.net>
  10225. Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  10226. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10227.  
  10228. Second batch for 2.12
  10229.  
  10230. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10231.  
  10232. Merge branch 'kh/tutorial-grammofix'
  10233.  
  10234. * kh/tutorial-grammofix:
  10235. doc: omit needless "for"
  10236. doc: make the intent of sentence clearer
  10237. doc: add verb in front of command to run
  10238. doc: add articles (grammar)
  10239.  
  10240. Merge branch 'da/mergetool-xxdiff-hotkey'
  10241.  
  10242. The way to specify hotkeys to "xxdiff" that is used by "git
  10243. mergetool" has been modernized to match recent versions of xxdiff.
  10244.  
  10245. * da/mergetool-xxdiff-hotkey:
  10246. mergetools: fix xxdiff hotkeys
  10247.  
  10248. Merge branch 'lr/doc-fix-cet'
  10249.  
  10250. * lr/doc-fix-cet:
  10251. date-formats.txt: Typo fix
  10252.  
  10253. Merge branch 'sb/t3600-cleanup'
  10254.  
  10255. Code cleanup.
  10256.  
  10257. * sb/t3600-cleanup:
  10258. t3600: slightly modernize style
  10259. t3600: remove useless redirect
  10260.  
  10261. Merge branch 'jc/pull-rebase-ff'
  10262.  
  10263. "git pull --rebase", when there is no new commits on our side since
  10264. we forked from the upstream, should be able to fast-forward without
  10265. invoking "git rebase", but it didn't.
  10266.  
  10267. * jc/pull-rebase-ff:
  10268. pull: fast-forward "pull --rebase=true"
  10269.  
  10270. Merge branch 'ld/p4-worktree'
  10271.  
  10272. "git p4" didn't interact with the internal of .git directory
  10273. correctly in the modern "git-worktree"-enabled world.
  10274.  
  10275. * ld/p4-worktree:
  10276. git-p4: support git worktrees
  10277.  
  10278. Merge branch 'jk/make-tags-find-sources-tweak'
  10279.  
  10280. Update the procedure to generate "tags" for developer support.
  10281.  
  10282. * jk/make-tags-find-sources-tweak:
  10283. Makefile: exclude contrib from FIND_SOURCE_FILES
  10284. Makefile: match shell scripts in FIND_SOURCE_FILES
  10285. Makefile: exclude test cruft from FIND_SOURCE_FILES
  10286. Makefile: reformat FIND_SOURCE_FILES
  10287.  
  10288. Merge branch 'js/normalize-path-copy-ceil'
  10289.  
  10290. A pathname that begins with "//" or "\\" on Windows is special but
  10291. path normalization logic was unaware of it.
  10292.  
  10293. * js/normalize-path-copy-ceil:
  10294. normalize_path_copy(): fix pushing to //server/share/dir on Windows
  10295.  
  10296. Merge branch 'bb/unicode-9.0'
  10297.  
  10298. The character width table has been updated to match Unicode 9.0
  10299.  
  10300. * bb/unicode-9.0:
  10301. unicode_width.h: update the width tables to Unicode 9.0
  10302. update_unicode.sh: remove the plane filter
  10303. update_unicode.sh: automatically download newer definition files
  10304. update_unicode.sh: pin the uniset repo to a known good commit
  10305. update_unicode.sh: remove an unnecessary subshell level
  10306. update_unicode.sh: move it into contrib/update-unicode
  10307.  
  10308. Merge branch 'jk/readme-gmane-is-no-more'
  10309.  
  10310. * jk/readme-gmane-is-no-more:
  10311. README: replace gmane link with public-inbox
  10312.  
  10313. Merge branch 'jc/lock-report-on-error'
  10314.  
  10315. Git 2.11 had a minor regression in "merge --ff-only" that competed
  10316. with another process that simultanously attempted to update the
  10317. index. We used to explain what went wrong with an error message,
  10318. but the new code silently failed. The error message has been
  10319. resurrected.
  10320.  
  10321. * jc/lock-report-on-error:
  10322. lockfile: LOCK_REPORT_ON_ERROR
  10323. hold_locked_index(): align error handling with hold_lockfile_for_update()
  10324. wt-status: implement opportunisitc index update correctly
  10325.  
  10326. Merge branch 'jk/xdiff-drop-xdl-fast-hash'
  10327.  
  10328. Retire the "fast hash" that had disastrous performance issues in
  10329. some corner cases.
  10330.  
  10331. * jk/xdiff-drop-xdl-fast-hash:
  10332. xdiff: drop XDL_FAST_HASH
  10333.  
  10334. Merge branch 'nd/rebase-forget'
  10335.  
  10336. "git rebase" learned "--quit" option, which allows a user to
  10337. remove the metadata left by an earlier "git rebase" that was
  10338. manually aborted without using "git rebase --abort".
  10339.  
  10340. * nd/rebase-forget:
  10341. rebase: add --quit to cleanup rebase, leave everything else untouched
  10342.  
  10343. Merge branch 'jk/trailers-placeholder-in-pretty'
  10344.  
  10345. In addition to %(subject), %(body), "log --pretty=format:..."
  10346. learned a new placeholder %(trailers).
  10347.  
  10348. * jk/trailers-placeholder-in-pretty:
  10349. ref-filter: add support to display trailers as part of contents
  10350. pretty: add %(trailers) format for displaying trailers of a commit message
  10351.  
  10352. Merge branch 'ak/commit-only-allow-empty'
  10353.  
  10354. "git commit --allow-empty --only" (no pathspec) with dirty index
  10355. ought to be an acceptable way to create a new commit that does not
  10356. change any paths, but it was forbidden, perhaps because nobody
  10357. needed it so far.
  10358.  
  10359. * ak/commit-only-allow-empty:
  10360. commit: remove 'Clever' message for --only --amend
  10361. commit: make --only --allow-empty work without paths
  10362.  
  10363. Merge branch 'da/difftool-dir-diff-fix'
  10364.  
  10365. "git difftool --dir-diff" had a minor regression when started from
  10366. a subdirectory, which has been fixed.
  10367.  
  10368. * da/difftool-dir-diff-fix:
  10369. difftool: fix dir-diff index creation when in a subdirectory
  10370.  
  10371. Merge branch 'jb/diff-no-index-no-abbrev'
  10372.  
  10373. "git diff --no-index" did not take "--no-abbrev" option.
  10374.  
  10375. * jb/diff-no-index-no-abbrev:
  10376. diff: handle --no-abbrev in no-index case
  10377.  
  10378. Merge branch 'rj/git-version-gen-do-not-force-abbrev'
  10379.  
  10380. A minor build update.
  10381.  
  10382. * rj/git-version-gen-do-not-force-abbrev:
  10383. GIT-VERSION-GEN: do not force abbreviation length used by 'describe'
  10384.  
  10385. Merge branch 'jk/stash-disable-renames-internally'
  10386.  
  10387. When diff.renames configuration is on (and with Git 2.9 and later,
  10388. it is enabled by default, which made it worse), "git stash"
  10389. misbehaved if a file is removed and another file with a very
  10390. similar content is added.
  10391.  
  10392. * jk/stash-disable-renames-internally:
  10393. stash: prefer plumbing over git-diff
  10394.  
  10395. Merge branch 'jk/http-walker-limit-redirect'
  10396.  
  10397. Update the error messages from the dumb-http client when it fails
  10398. to obtain loose objects; we used to give sensible error message
  10399. only upon 404 but we now forbid unexpected redirects that needs to
  10400. be reported with something sensible.
  10401.  
  10402. * jk/http-walker-limit-redirect:
  10403. http-walker: complain about non-404 loose object errors
  10404.  
  10405. Merge branch 'jk/http-walker-limit-redirect-2.9'
  10406.  
  10407. Transport with dumb http can be fooled into following foreign URLs
  10408. that the end user does not intend to, especially with the server
  10409. side redirects and http-alternates mechanism, which can lead to
  10410. security issues. Tighten the redirection and make it more obvious
  10411. to the end user when it happens.
  10412.  
  10413. * jk/http-walker-limit-redirect-2.9:
  10414. http: treat http-alternates like redirects
  10415. http: make redirects more obvious
  10416. remote-curl: rename shadowed options variable
  10417. http: always update the base URL for redirects
  10418. http: simplify update_url_from_redirect
  10419.  
  10420. Merge branch 'nd/for-each-ref-ignore-case'
  10421.  
  10422. "git branch --list" and friends learned "--ignore-case" option to
  10423. optionally sort branches and tags case insensitively.
  10424.  
  10425. * nd/for-each-ref-ignore-case:
  10426. tag, branch, for-each-ref: add --ignore-case for sorting and filtering
  10427.  
  10428. Merge branch 'sb/unpack-trees-grammofix'
  10429.  
  10430. * sb/unpack-trees-grammofix:
  10431. unpack-trees: fix grammar for untracked files in directories
  10432.  
  10433. Merge branch 'ls/travis-update-p4-and-lfs'
  10434.  
  10435. The default Travis-CI configuration specifies newer P4 and GitLFS.
  10436.  
  10437. * ls/travis-update-p4-and-lfs:
  10438. travis-ci: update P4 to 16.2 and GitLFS to 1.5.2 in Linux build
  10439.  
  10440. Merge branch 'ls/t0021-fixup'
  10441.  
  10442. * ls/t0021-fixup:
  10443. t0021: minor filter process test cleanup
  10444.  
  10445. Merge branch 'ah/grammos'
  10446.  
  10447. A few messages have been fixed for their grammatical errors.
  10448.  
  10449. * ah/grammos:
  10450. clone,fetch: explain the shallow-clone option a little more clearly
  10451. receive-pack: improve English grammar of denyCurrentBranch message
  10452. bisect: improve English grammar of not-ancestors message
  10453.  
  10454. Merge branch 'jc/renormalize-merge-kill-safer-crlf'
  10455.  
  10456. Fix a corner case in merge-recursive regression that crept in
  10457. during 2.10 development cycle.
  10458.  
  10459. * jc/renormalize-merge-kill-safer-crlf:
  10460. convert: git cherry-pick -Xrenormalize did not work
  10461. merge-recursive: handle NULL in add_cacheinfo() correctly
  10462. cherry-pick: demonstrate a segmentation fault
  10463.  
  10464. Merge branch 'jt/use-trailer-api-in-commands'
  10465.  
  10466. Commands that operate on a log message and add lines to the trailer
  10467. blocks, such as "format-patch -s", "cherry-pick (-x|-s)", and
  10468. "commit -s", have been taught to use the logic of and share the
  10469. code with "git interpret-trailer".
  10470.  
  10471. * jt/use-trailer-api-in-commands:
  10472. sequencer: use trailer's trailer layout
  10473. trailer: have function to describe trailer layout
  10474. trailer: avoid unnecessary splitting on lines
  10475. commit: make ignore_non_trailer take buf/len
  10476. trailer: be stricter in parsing separators
  10477.  
  10478. git-p4: fix multi-path changelist empty commits
  10479.  
  10480. When importing from multiple perforce paths - we may attempt to
  10481. import a changelist that contains files from two (or more) of these
  10482. depot paths. Currently, this results in multiple git commits - one
  10483. containing the changes, and the other(s) as empty commit(s). This
  10484. behavior was introduced in commit 1f90a64891 ("git-p4: reduce number
  10485. of server queries for fetches", 2015-12-19).
  10486.  
  10487. Reproduction Steps:
  10488.  
  10489. 1. Have a git repo cloned from a perforce repo using multiple
  10490. depot paths (e.g. //depot/foo and //depot/bar).
  10491.  
  10492. 2. Submit a single change to the perforce repo that makes changes
  10493. in both //depot/foo and //depot/bar.
  10494.  
  10495. 3. Run "git p4 sync" to sync the change from #2.
  10496.  
  10497. Change is synced as multiple commits, one for each depot path that
  10498. was affected.
  10499.  
  10500. Using a set, instead of a list inside p4ChangesForPaths() ensures
  10501. that each changelist is unique to the returned list, and therefore
  10502. only a single commit is generated for each changelist.
  10503.  
  10504. Reported-by: James Farwell <jfarwell@vmware.com>
  10505. Signed-off-by: George Vanburgh <gvanburgh@bloomberg.net>
  10506. Reviewed-by: Luke Diamand <luke@diamand.org>
  10507. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10508.  
  10509. git-p4: avoid crash adding symlinked directory
  10510.  
  10511. When submitting to P4, if git-p4 came across a symlinked
  10512. directory, then during the generation of the submit diff, it would
  10513. try to open it as a normal file and fail.
  10514.  
  10515. Spot symlinks (of any type) and output a description of the symlink
  10516. instead.
  10517.  
  10518. Add a test case.
  10519.  
  10520. Signed-off-by: Luke Diamand <luke@diamand.org>
  10521. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10522.  
  10523. t0021: fix flaky test
  10524.  
  10525. t0021.15 creates files, adds them to the index, and commits them. All
  10526. this usually happens in a test run within the same second and Git cannot
  10527. know if the files have been changed between `add` and `commit`. Thus,
  10528. Git has to run the clean filter in both operations. Sometimes these
  10529. invocations spread over two different seconds and Git can infer that the
  10530. files were not changed between `add` and `commit` based on their
  10531. modification timestamp. The test would fail as it expects the filter
  10532. invocation. Remove this expectation to make the test stable.
  10533.  
  10534. Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
  10535. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10536.  
  10537. First batch for 2.12
  10538.  
  10539. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10540.  
  10541. Merge branch 'ls/p4-retry-thrice'
  10542.  
  10543. * ls/p4-retry-thrice:
  10544. git-p4: add config to retry p4 commands; retry 3 times by default
  10545.  
  10546. Merge branch 'ls/p4-empty-file-on-lfs'
  10547.  
  10548. "git p4" LFS support was broken when LFS stores an empty blob.
  10549.  
  10550. * ls/p4-empty-file-on-lfs:
  10551. git-p4: fix empty file processing for large file system backend GitLFS
  10552.  
  10553. Merge branch 'ld/p4-update-shelve'
  10554.  
  10555. * ld/p4-update-shelve:
  10556. git-p4: support updating an existing shelved changelist
  10557.  
  10558. Merge branch 'vk/p4-submit-shelve'
  10559.  
  10560. * vk/p4-submit-shelve:
  10561. git-p4: allow submit to create shelved changelists.
  10562.  
  10563. Merge branch 'da/mergetool-trust-exit-code'
  10564.  
  10565. mergetool.<tool>.trustExitCode configuration variable did not apply
  10566. to built-in tools, but now it does.
  10567.  
  10568. * da/mergetool-trust-exit-code:
  10569. mergetools/vimdiff: trust Vim's exit code
  10570. mergetool: honor mergetool.$tool.trustExitCode for built-in tools
  10571.  
  10572. Merge branch 'ak/lazy-prereq-mktemp'
  10573.  
  10574. Test code clean-up.
  10575.  
  10576. * ak/lazy-prereq-mktemp:
  10577. t7610: clean up foo.XXXXXX tmpdir
  10578.  
  10579. Merge branch 'nd/worktree-list-fixup'
  10580.  
  10581. The output from "git worktree list" was made in readdir() order,
  10582. and was unstable.
  10583.  
  10584. * nd/worktree-list-fixup:
  10585. worktree list: keep the list sorted
  10586. worktree.c: get_worktrees() takes a new flag argument
  10587. get_worktrees() must return main worktree as first item even on error
  10588. worktree: reorder an if statement
  10589. worktree.c: zero new 'struct worktree' on allocation
  10590.  
  10591. Merge branch 'nd/qsort-in-merge-recursive'
  10592.  
  10593. Code simplification.
  10594.  
  10595. * nd/qsort-in-merge-recursive:
  10596. merge-recursive.c: use string_list_sort instead of qsort
  10597.  
  10598. Merge branch 'bw/push-dry-run'
  10599.  
  10600. "git push --dry-run --recurse-submodule=on-demand" wasn't
  10601. "--dry-run" in the submodules.
  10602.  
  10603. * bw/push-dry-run:
  10604. push: fix --dry-run to not push submodules
  10605. push: --dry-run updates submodules when --recurse-submodules=on-demand
  10606.  
  10607. Merge branch 'hv/submodule-not-yet-pushed-fix'
  10608.  
  10609. The code in "git push" to compute if any commit being pushed in the
  10610. superproject binds a commit in a submodule that hasn't been pushed
  10611. out was overly inefficient, making it unusable even for a small
  10612. project that does not have any submodule but have a reasonable
  10613. number of refs.
  10614.  
  10615. * hv/submodule-not-yet-pushed-fix:
  10616. submodule_needs_pushing(): explain the behaviour when we cannot answer
  10617. batch check whether submodule needs pushing into one call
  10618. serialize collection of refs that contain submodule changes
  10619. serialize collection of changed submodules
  10620.  
  10621. Merge branch 'dt/empty-submodule-in-merge'
  10622.  
  10623. An empty directory in a working tree that can simply be nuked used
  10624. to interfere while merging or cherry-picking a change to create a
  10625. submodule directory there, which has been fixed..
  10626.  
  10627. * dt/empty-submodule-in-merge:
  10628. submodules: allow empty working-tree dirs in merge/cherry-pick
  10629.  
  10630. Merge branch 'jk/rev-parse-symbolic-parents-fix'
  10631.  
  10632. "git rev-parse --symbolic" failed with a more recent notation like
  10633. "HEAD^-1" and "HEAD^!".
  10634.  
  10635. * jk/rev-parse-symbolic-parents-fix:
  10636. rev-parse: fix parent shorthands with --symbolic
  10637.  
  10638. index-pack: skip collision check when not in repository
  10639.  
  10640. You can run "git index-pack path/to/foo.pack" outside of a
  10641. repository to generate an index file, or just to verify the
  10642. contents. There's no point in doing a collision check, since
  10643. we obviously do not have any objects to collide with.
  10644.  
  10645. The current code will blindly look in .git/objects based on
  10646. the result of setup_git_env(). That effectively gives us the
  10647. right answer (since we won't find any objects), but it's a
  10648. waste of time, and it conflicts with our desire to
  10649. eventually get rid of the "fallback to .git" behavior of
  10650. setup_git_env().
  10651.  
  10652. Signed-off-by: Jeff King <peff@peff.net>
  10653. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10654.  
  10655. normalize_path_copy(): fix pushing to //server/share/dir on Windows
  10656.  
  10657. normalize_path_copy() is not prepared to keep the double-slash of a
  10658. //server/share/dir kind of path, but treats it like a regular POSIX
  10659. style path and transforms it to /server/share/dir.
  10660.  
  10661. The bug manifests when 'git push //server/share/dir master' is run,
  10662. because tmp_objdir_add_as_alternate() uses the path in normalized
  10663. form when it registers the quarantine object database via
  10664. link_alt_odb_entries(). Needless to say that the directory cannot be
  10665. accessed using the wrongly normalized path.
  10666.  
  10667. Fix it by skipping all of the root part, not just a potential drive
  10668. prefix. offset_1st_component takes care of this, see the
  10669. implementation in compat/mingw.c::mingw_offset_1st_component().
  10670.  
  10671. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
  10672. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10673.  
  10674. shortlog: test and document --committer option
  10675.  
  10676. This puts the final touches on the feature added by
  10677. fbfda15fb8 (shortlog: group by committer information,
  10678. 2016-10-11).
  10679.  
  10680. Signed-off-by: Jeff King <peff@peff.net>
  10681. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10682.  
  10683. t: use nongit() function where applicable
  10684.  
  10685. Many tests want to run a command outside of any git repo;
  10686. with the nongit() function this is now a one-liner. It saves
  10687. a few lines, but more importantly, it's immediately obvious
  10688. what the code is trying to accomplish.
  10689.  
  10690. This doesn't convert every such case in the test suite; it
  10691. just covers those that want to do a one-off command. Other
  10692. cases, such as the ones in t4035, are part of a larger
  10693. scheme of outside-repo files, and it's less confusing for
  10694. them to stay consistent with the surrounding tests.
  10695.  
  10696. Signed-off-by: Jeff King <peff@peff.net>
  10697. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10698.  
  10699. index-pack: complain when --stdin is used outside of a repo
  10700.  
  10701. The index-pack builtin is marked as RUN_SETUP_GENTLY,
  10702. because it's perfectly fine to index a pack in the
  10703. filesystem outside of any repository. However, --stdin mode
  10704. will write the result to the object database, which does not
  10705. make sense outside of a repository. Doing so creates a bogus
  10706. ".git" directory with nothing in it except the newly-created
  10707. pack and its index.
  10708.  
  10709. Instead, let's flag this as an error and abort.
  10710.  
  10711. Signed-off-by: Jeff King <peff@peff.net>
  10712. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10713.  
  10714. t5000: extract nongit function to test-lib-functions.sh
  10715.  
  10716. This function abstracts the idea of running a command
  10717. outside of any repository (which is slightly awkward to do
  10718. because even if you make a non-repo directory, git may keep
  10719. walking up outside of the trash directory). There are
  10720. several scripts that use the same technique, so let's make
  10721. the function available for everyone.
  10722.  
  10723. Signed-off-by: Jeff King <peff@peff.net>
  10724. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10725.  
  10726. shortlog: group by committer information
  10727.  
  10728. In some situations you may want to group the commits not by author,
  10729. but by committer instead.
  10730.  
  10731. For example, when I just wanted to look up what I'm still missing from
  10732. linux-next in the current merge window, I don't care so much about who
  10733. wrote a patch, as what git tree it came from, which generally boils
  10734. down to "who committed it".
  10735.  
  10736. So make git shortlog take a "-c" or "--committer" option to switch
  10737. grouping to that.
  10738.  
  10739. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  10740. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10741.  
  10742. merge: mark usage error strings for translation
  10743.  
  10744. The nearby error messages are already marked for
  10745. translation, but these new ones aren't.
  10746.  
  10747. Signed-off-by: Jeff King <peff@peff.net>
  10748. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10749.  
  10750. README: replace gmane link with public-inbox
  10751.  
  10752. The general status and future of gmane is unclear at this
  10753. point, but certainly it does not seem to be carrying
  10754. gmane.comp.version-control.git at all anymore. Let's point
  10755. to public-inbox.org, which seems to be the favored archive
  10756. on the list these days (and which uses message-ids in its
  10757. URLs, making the links somewhat future-proof).
  10758.  
  10759. Reported-by: Chiel ten Brinke <ctenbrinke@gmail.com>
  10760. Signed-off-by: Jeff King <peff@peff.net>
  10761. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10762.  
  10763. http: respect protocol.*.allow=user for http-alternates
  10764.  
  10765. The http-walker may fetch the http-alternates (or
  10766. alternates) file from a remote in order to find more
  10767. objects. This should count as a "not from the user" use of
  10768. the protocol. But because we implement the redirection
  10769. ourselves and feed the new URL to curl, it will use the
  10770. CURLOPT_PROTOCOLS rules, not the more restrictive
  10771. CURLOPT_REDIR_PROTOCOLS.
  10772.  
  10773. The ideal solution would be for each curl request we make to
  10774. know whether or not is directly from the user or part of an
  10775. alternates redirect, and then set CURLOPT_PROTOCOLS as
  10776. appropriate. However, that would require plumbing that
  10777. information through all of the various layers of the http
  10778. code.
  10779.  
  10780. Instead, let's check the protocol at the source: when we are
  10781. parsing the remote http-alternates file. The only downside
  10782. is that if there's any mismatch between what protocol we
  10783. think it is versus what curl thinks it is, it could violate
  10784. the policy.
  10785.  
  10786. To address this, we'll make the parsing err on the picky
  10787. side, and only allow protocols that it can parse
  10788. definitively. So for example, you can't elude the "http"
  10789. policy by asking for "HTTP://", even though curl might
  10790. handle it; we would reject it as unknown. The only unsafe
  10791. case would be if you have a URL that starts with "http://"
  10792. but curl interprets as another protocol. That seems like an
  10793. unlikely failure mode (and we are still protected by our
  10794. base CURLOPT_PROTOCOL setting, so the worst you could do is
  10795. trigger one of https, ftp, or ftps).
  10796.  
  10797. Signed-off-by: Jeff King <peff@peff.net>
  10798. Signed-off-by: Brandon Williams <bmwill@google.com>
  10799. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10800.  
  10801. transport: add from_user parameter to is_transport_allowed
  10802.  
  10803. Add a from_user parameter to is_transport_allowed() to allow http to be
  10804. able to distinguish between protocol restrictions for redirects versus
  10805. initial requests. CURLOPT_REDIR_PROTOCOLS can now be set differently
  10806. from CURLOPT_PROTOCOLS to disallow use of protocols with the "user"
  10807. policy in redirects.
  10808.  
  10809. This change allows callers to query if a transport protocol is allowed,
  10810. given that the caller knows that the protocol is coming from the user
  10811. (1) or not from the user (0) such as redirects in libcurl. If unknown a
  10812. -1 should be provided which falls back to reading
  10813. `GIT_PROTOCOL_FROM_USER` to determine if the protocol came from the
  10814. user.
  10815.  
  10816. Signed-off-by: Brandon Williams <bmwill@google.com>
  10817. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10818.  
  10819. http: create function to get curl allowed protocols
  10820.  
  10821. Move the creation of an allowed protocols whitelist to a helper
  10822. function. This will be useful when we need to compute the set of
  10823. allowed protocols differently for normal and redirect cases.
  10824.  
  10825. Signed-off-by: Brandon Williams <bmwill@google.com>
  10826. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10827.  
  10828. transport: add protocol policy config option
  10829.  
  10830. Previously the `GIT_ALLOW_PROTOCOL` environment variable was used to
  10831. specify a whitelist of protocols to be used in clone/fetch/push
  10832. commands. This patch introduces new configuration options for more
  10833. fine-grained control for allowing/disallowing protocols. This also has
  10834. the added benefit of allowing easier construction of a protocol
  10835. whitelist on systems where setting an environment variable is
  10836. non-trivial.
  10837.  
  10838. Now users can specify a policy to be used for each type of protocol via
  10839. the 'protocol.<name>.allow' config option. A default policy for all
  10840. unconfigured protocols can be set with the 'protocol.allow' config
  10841. option. If no user configured default is made git will allow known-safe
  10842. protocols (http, https, git, ssh, file), disallow known-dangerous
  10843. protocols (ext), and have a default policy of `user` for all other
  10844. protocols.
  10845.  
  10846. The supported policies are `always`, `never`, and `user`. The `user`
  10847. policy can be used to configure a protocol to be usable when explicitly
  10848. used by a user, while disallowing it for commands which run
  10849. clone/fetch/push commands without direct user intervention (e.g.
  10850. recursive initialization of submodules). Commands which can potentially
  10851. clone/fetch/push from untrusted repositories without user intervention
  10852. can export `GIT_PROTOCOL_FROM_USER` with a value of '0' to prevent
  10853. protocols configured to the `user` policy from being used.
  10854.  
  10855. Fix remote-ext tests to use the new config to allow the ext
  10856. protocol to be tested.
  10857.  
  10858. Based on a patch by Jeff King <peff@peff.net>
  10859.  
  10860. Signed-off-by: Brandon Williams <bmwill@google.com>
  10861. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10862.  
  10863. http: always warn if libcurl version is too old
  10864.  
  10865. Always warn if libcurl version is too old because:
  10866.  
  10867. 1. Even without a protocol whitelist, newer versions of curl have all
  10868. non-standard protocols disabled by default.
  10869. 2. A future patch will introduce default "known-good" and "known-bad"
  10870. protocols which are allowed/disallowed by 'is_transport_allowed'
  10871. which older version of libcurl can't respect.
  10872.  
  10873. Signed-off-by: Brandon Williams <bmwill@google.com>
  10874. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10875.  
  10876. lib-proto-disable: variable name fix
  10877.  
  10878. The test_proto function assigns the positional parameters to named
  10879. variables, but then still refers to "$desc" as "$1". Using $desc is
  10880. more readable and less error-prone.
  10881.  
  10882. Signed-off-by: Brandon Williams <bmwill@google.com>
  10883. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10884.  
  10885. Revert "sequencer: remove useless get_dir() function"
  10886.  
  10887. This reverts commit 39784cd3620cc47415c9010ec58a9616f040125c.
  10888.  
  10889. The function had only one caller when the "remove useless" was
  10890. written, but another topic will soon make heavy use of it and more
  10891. importantly the function will return different paths depending on
  10892. the value in opts.
  10893.  
  10894. i18n: difftool: mark warnings for translation
  10895.  
  10896. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10897. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10898.  
  10899. i18n: send-email: mark composing message for translation
  10900.  
  10901. When composing an e-mail, there is a message for the user whose lines
  10902. begin in "GIT:" that can be marked for translation.
  10903.  
  10904. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10905. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10906.  
  10907. i18n: send-email: mark string with interpolation for translation
  10908.  
  10909. Mark warnings, errors and other messages that are interpolated for
  10910. translation.
  10911.  
  10912. We call sprintf() before calling die() and in few other circumstances in
  10913. order to replace the values on the placeholders.
  10914.  
  10915. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10916. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10917.  
  10918. i18n: send-email: mark warnings and errors for translation
  10919.  
  10920. Mark warnings, errors and other messages for translation.
  10921.  
  10922. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10923. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10924.  
  10925. i18n: send-email: mark strings for translation
  10926.  
  10927. Mark strings often displayed to the user for translation.
  10928.  
  10929. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10930. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10931.  
  10932. i18n: add--interactive: mark status words for translation
  10933.  
  10934. Mark words 'nothing', 'unchanged' and 'binary' used to display what has
  10935. been staged or not, in "git add -i" status command.
  10936.  
  10937. Alternatively one could mark N__('nothing') no-op in order to
  10938. xgettext(1) extract the string and then trigger the translation at run
  10939. time only with __($print->{FILE}), but that has the side effect of triggering
  10940. retrieval of translations for the changes indicator too (e.g. +2/-1)
  10941. which may or may not be a problem.
  10942.  
  10943. To avoid that potential problem, mark only where there is certain to
  10944. trigger translation only of those words but in this case we must also
  10945. retrieve the translation for the eq tests, since the value assigned was
  10946. of the translation, not the English source.
  10947.  
  10948. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10949. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10950.  
  10951. i18n: add--interactive: remove %patch_modes entries
  10952.  
  10953. Remove unnecessary entries from %patch_modes. After the i18n conversion,
  10954. these entries are not used anymore.
  10955.  
  10956. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10957. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10958.  
  10959. i18n: add--interactive: mark edit_hunk_manually message for translation
  10960.  
  10961. Mark message of edit_hunk_manually displayed in the editing file when
  10962. user chooses 'e' option. The message had to be unfolded to allow
  10963. translation of the $participle verb.
  10964.  
  10965. Some messages end up being exactly the same for some use cases, but
  10966. left it for easier change in the future, e.g., wanting to change wording
  10967. of one particular use case.
  10968.  
  10969. The comment character is now used according to the git configuration
  10970. core.commentchar.
  10971.  
  10972. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10973. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10974.  
  10975. i18n: add--interactive: i18n of help_patch_cmd
  10976.  
  10977. Mark help message of help_patch_cmd for translation. The message must
  10978. be unfolded to be free of variables so we can have high quality
  10979. translations.
  10980.  
  10981. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  10982. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  10983.  
  10984. i18n: add--interactive: mark patch prompt for translation
  10985.  
  10986. Mark prompt message assembled in place for translation, unfolding each
  10987. use case for each entry in the %patch_modes hash table.
  10988.  
  10989. Previously, this script relied on whether $patch_mode was set to run the
  10990. command patch_update_cmd() or show status and loop the main loop. Now,
  10991. it uses $cmd to indicate we must run patch_update_cmd() and $patch_mode
  10992. is used to tell which flavor of the %patch_modes are we on. This is
  10993. introduced in order to be able to mark and unfold the message prompt
  10994. knowing in which context we are.
  10995.  
  10996. The tracking of context was done previously by point %patch_mode_flavour
  10997. hash table to the correct entry of %patch_modes, focusing only on value
  10998. of %patch_modes. Now, we are also interested in the key ('staged',
  10999. 'stash', 'checkout_head', ...).
  11000.  
  11001. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11002. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11003.  
  11004. i18n: add--interactive: mark plural strings
  11005.  
  11006. Mark plural strings for translation. Unfold each action case in one
  11007. entire sentence.
  11008.  
  11009. Pass new keyword for xgettext to extract.
  11010.  
  11011. Update test to include new subroutine __n() for plural strings handling.
  11012.  
  11013. Update documentation to include a description of the new __n()
  11014. subroutine.
  11015.  
  11016. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11017. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11018.  
  11019. i18n: clean.c: match string with git-add--interactive.perl
  11020.  
  11021. Change strings for help to match the ones in git-add--interactive.perl.
  11022. The strings now represent one entry to translate each rather then two
  11023. entries each different only by an ending newline character.
  11024.  
  11025. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11026. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11027.  
  11028. i18n: add--interactive: mark strings with interpolation for translation
  11029.  
  11030. Since at this point Git::I18N.perl lacks support for Perl i18n
  11031. placeholder substitution, use of sprintf following die or error_msg is
  11032. necessary for placeholder substitution take place.
  11033.  
  11034. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11035. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11036.  
  11037. i18n: add--interactive: mark simple here-documents for translation
  11038.  
  11039. Mark messages in here-documents without interpolation for translation.
  11040.  
  11041. The here-document delimiter \EOF, which is the same as 'EOF', indicates
  11042. that the text is to be treated literally without interpolation of its
  11043. content. Unfortunately xgettext is not able to extract here-documents
  11044. delimited with \EOF but it is with delimiter enclosed in single quotes.
  11045. So change \EOF to 'EOF', although in this case does not make
  11046. difference what variation of here-document to use since there is nothing
  11047. to interpolate.
  11048.  
  11049. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11050. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11051.  
  11052. i18n: add--interactive: mark strings for translation
  11053.  
  11054. Mark simple strings (without interpolation) for translation.
  11055.  
  11056. Brackets around first parameter of ternary operator is necessary because
  11057. otherwise xgettext fails to extract strings marked for translation from
  11058. the rest of the file.
  11059.  
  11060. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11061. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11062.  
  11063. Git.pm: add subroutines for commenting lines
  11064.  
  11065. Add subroutines prefix_lines and comment_lines.
  11066.  
  11067. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11068. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11069.  
  11070. merge: ensure '--abort' option takes no arguments
  11071.  
  11072. Like '--continue', the '--abort' option doesn't make any sense with
  11073. other options or arguments to 'git merge' so ensure that none are
  11074. present.
  11075.  
  11076. Signed-off-by: Chris Packham <judge.packham@gmail.com>
  11077. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11078.  
  11079. completion: add --continue option for merge
  11080.  
  11081. Add 'git merge --continue' option when completing.
  11082.  
  11083. Signed-off-by: Chris Packham <judge.packham@gmail.com>
  11084. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11085.  
  11086. merge: add '--continue' option as a synonym for 'git commit'
  11087.  
  11088. Teach 'git merge' the --continue option which allows 'continuing' a
  11089. merge by completing it. The traditional way of completing a merge after
  11090. resolving conflicts is to use 'git commit'. Now with commands like 'git
  11091. rebase' and 'git cherry-pick' having a '--continue' option adding such
  11092. an option to 'git merge' presents a consistent UI.
  11093.  
  11094. Signed-off-by: Chris Packham <judge.packham@gmail.com>
  11095. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11096.  
  11097. parse-options: print "fatal:" before usage_msg_opt()
  11098.  
  11099. Programs may use usage_msg_opt() to print a brief message
  11100. followed by the program usage, and then exit. The message
  11101. isn't prefixed at all, though, so it doesn't match our usual
  11102. error output and is easy to overlook:
  11103.  
  11104. $ git clone 1 2 3
  11105. Too many arguments.
  11106.  
  11107. usage: git clone [<options>] [--] <repo> [<dir>]
  11108.  
  11109. -v, --verbose be more verbose
  11110. -q, --quiet be more quiet
  11111. --progress force progress reporting
  11112. -n, --no-checkout don't create a checkout
  11113. --bare create a bare repository
  11114. [...and so on for another 31 lines...]
  11115.  
  11116. It looks especially bad when the message starts with an
  11117. option, like:
  11118.  
  11119. $ git replace -e
  11120. -e needs exactly one argument
  11121.  
  11122. usage: git replace [-f] <object> <replacement>
  11123. or: git replace [-f] --edit <object>
  11124. [...etc...]
  11125.  
  11126. Let's put our usual "fatal:" prefix in front of it.
  11127.  
  11128. Signed-off-by: Jeff King <peff@peff.net>
  11129. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11130.  
  11131. Makefile: exclude contrib from FIND_SOURCE_FILES
  11132.  
  11133. When you're working on the git project, you're unlikely to
  11134. care about random bits in contrib/ (e.g., you would not want
  11135. to jump to the copy of xmalloc in the wincred credential
  11136. helper). Nobody has really complained because there are
  11137. relatively few C files in contrib.
  11138.  
  11139. Now that we're matching shell scripts, too, we get quite a
  11140. few more hits, especially in the obsolete contrib/examples
  11141. directory. Looking for usage() should turn up the one in
  11142. git-sh-setup, not in some long-dead version of git-clone.
  11143.  
  11144. Let's just exclude all of contrib. Any specific projects
  11145. there which are big enough to want tags can generate them
  11146. separately.
  11147.  
  11148. Signed-off-by: Jeff King <peff@peff.net>
  11149. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11150.  
  11151. Makefile: match shell scripts in FIND_SOURCE_FILES
  11152.  
  11153. We feed FIND_SOURCE_FILES to ctags to help developers
  11154. navigate to particular functions, but we only feed C source
  11155. code. The same feature can be helpful when working with
  11156. shell scripts (especially the test suite). Modern versions
  11157. of ctags know how to parse shell scripts; we just need to
  11158. feed the filenames to it.
  11159.  
  11160. This patch specifically avoids including the individual test
  11161. scripts themselves. Those are unlikely to be of interest,
  11162. and there are a lot of them to process. It does pick up
  11163. test-lib.sh and test-lib-functions.sh.
  11164.  
  11165. Note that our negative pathspec already excludes the
  11166. individual scripts for the ls-files case, but we need to
  11167. loosen the `find` rule to match it.
  11168.  
  11169. Signed-off-by: Jeff King <peff@peff.net>
  11170. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11171.  
  11172. Makefile: exclude test cruft from FIND_SOURCE_FILES
  11173.  
  11174. The test directory may contain three types of files that
  11175. match our patterns:
  11176.  
  11177. 1. Helper programs in t/helper.
  11178.  
  11179. 2. Sample data files (e.g., t/t4051/hello.c).
  11180.  
  11181. 3. Untracked cruft in trash directories and t/perf/build.
  11182.  
  11183. We want to match (1), but not the other two, as they just
  11184. clutter up the list.
  11185.  
  11186. For the ls-files method, we can drop (2) with a negative
  11187. pathspec. We do not have to care about (3), since ls-files
  11188. will not list untracked files.
  11189.  
  11190. For `find`, we can match both cases with `-prune` patterns.
  11191.  
  11192. Signed-off-by: Jeff King <peff@peff.net>
  11193. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11194.  
  11195. Makefile: reformat FIND_SOURCE_FILES
  11196.  
  11197. As we add to this in future commits, the formatting is going
  11198. to make it harder and harder to read. Let's write it more as
  11199. we would in a shell script, putting each logical block on
  11200. its own line.
  11201.  
  11202. Signed-off-by: Jeff King <peff@peff.net>
  11203. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11204.  
  11205. unicode_width.h: update the width tables to Unicode 9.0
  11206.  
  11207. Rerunning update-unicode.sh that we fixed in the previous commits
  11208. produces these new tables.
  11209.  
  11210. Signed-off-by: Beat Bolli <dev+git@drbeat.li>
  11211. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11212.  
  11213. update_unicode.sh: remove the plane filter
  11214.  
  11215. The uniset upstream has accepted my patches that eliminate the Unicode
  11216. plane offsets from the output in '--32' mode.
  11217.  
  11218. Remove the corresponding filter in update_unicode.sh.
  11219.  
  11220. This also fixes the issue that the plane offsets were not removed from
  11221. the second uniset call.
  11222.  
  11223. Signed-off-by: Beat Bolli <dev+git@drbeat.li>
  11224. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11225.  
  11226. update_unicode.sh: automatically download newer definition files
  11227.  
  11228. Checking just for the unicode data files' existence is not sufficient;
  11229. we should also download them if a newer version exists on the Unicode
  11230. consortium's servers. Option -N of wget does this nicely for us.
  11231.  
  11232. Reviewed-by: Torsten Bögershausen <tboegi@web.de>
  11233. Signed-off-by: Beat Bolli <dev+git@drbeat.li>
  11234. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11235.  
  11236. update_unicode.sh: pin the uniset repo to a known good commit
  11237.  
  11238. The uniset upstream has added more commits that for example change the
  11239. hexadecimal output in '--32' mode to decimal. Let's pin the repo to a
  11240. commit that still outputs the width tables in the format we want.
  11241.  
  11242. Signed-off-by: Beat Bolli <dev+git@drbeat.li>
  11243. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11244.  
  11245. update_unicode.sh: remove an unnecessary subshell level
  11246.  
  11247. After the move into contrib/update-unicode, we no longer create the
  11248. unicode directory to have a clean working folder. Instead, the directory
  11249. of the script is used. This means that the subshell can be removed.
  11250.  
  11251. Signed-off-by: Beat Bolli <dev+git@drbeat.li>
  11252. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11253.  
  11254. update_unicode.sh: move it into contrib/update-unicode
  11255.  
  11256. As it's used only by a tiny minority of the Git developer population,
  11257. this script does not belong into the main Git source directory.
  11258.  
  11259. Move it into contrib/ and adjust the paths to account for the new
  11260. location.
  11261.  
  11262. Signed-off-by: Beat Bolli <dev+git@drbeat.li>
  11263. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11264.  
  11265. git-p4: support git worktrees
  11266.  
  11267. git-p4 would attempt to find the git directory using
  11268. its own specific code, which did not know about git
  11269. worktrees.
  11270.  
  11271. Rework it to use "git rev-parse --git-dir" instead.
  11272.  
  11273. Add test cases for worktree usage and specifying
  11274. git directory via --git-dir and $GIT_DIR.
  11275.  
  11276. Signed-off-by: Luke Diamand <luke@diamand.org>
  11277. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11278.  
  11279. Early fixes for 2.11.x series
  11280.  
  11281. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11282.  
  11283. Merge branch 'ew/svn-fixes'
  11284.  
  11285. * ew/svn-fixes:
  11286. git-svn: document useLogAuthor and addAuthorFrom config keys
  11287. git-svn: allow "0" in SVN path components
  11288.  
  11289. Merge branch 'js/mingw-isatty'
  11290.  
  11291. We often decide if a session is interactive by checking if the
  11292. standard I/O streams are connected to a TTY, but isatty() emulation
  11293. on Windows incorrectly returned true if it is used on NUL (i.e. an
  11294. equivalent to /dev/null). This has been fixed.
  11295.  
  11296. * js/mingw-isatty:
  11297. mingw: intercept isatty() to handle /dev/null as Git expects it
  11298.  
  11299. t5547-push-quarantine: run the path separator test on Windows, too
  11300.  
  11301. To perform the test case on Windows in a way that corresponds to the
  11302. POSIX version, inject the semicolon in a directory name.
  11303.  
  11304. Typically, an absolute POSIX style path, such as the one in $PWD, is
  11305. translated into a Windows style path by bash when it invokes git.exe.
  11306. However, the presence of the semicolon suppresses this translation;
  11307. but the untranslated POSIX style path is useless for git.exe.
  11308. Therefore, instead of $PWD pass the Windows style path that $(pwd)
  11309. produces.
  11310.  
  11311. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
  11312. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11313.  
  11314. t3600: slightly modernize style
  11315.  
  11316. Remove the space between redirection and file name.
  11317. Also remove unnecessary invocations of subshells, such as
  11318.  
  11319. (cd submod &&
  11320. echo X >untracked
  11321. ) &&
  11322.  
  11323. as there is no point of having the shell for functional purposes.
  11324. In case of a single Git command use the `-C` option to let Git cd into
  11325. the directory.
  11326.  
  11327. Signed-off-by: Stefan Beller <sbeller@google.com>
  11328. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11329.  
  11330. real_path: have callers use real_pathdup and strbuf_realpath
  11331.  
  11332. Migrate callers of real_path() who duplicate the retern value to use
  11333. real_pathdup or strbuf_realpath.
  11334.  
  11335. Signed-off-by: Brandon Williams <bmwill@google.com>
  11336. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11337.  
  11338. real_path: create real_pathdup
  11339.  
  11340. Create real_pathdup which returns a caller owned string of the resolved
  11341. realpath based on the provide path.
  11342.  
  11343. Signed-off-by: Brandon Williams <bmwill@google.com>
  11344. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11345.  
  11346. real_path: convert real_path_internal to strbuf_realpath
  11347.  
  11348. Change the name of real_path_internal to strbuf_realpath. In addition
  11349. push the static strbuf up to its callers and instead take as a
  11350. parameter a pointer to a strbuf to use for the final result.
  11351.  
  11352. This change makes strbuf_realpath reentrant.
  11353.  
  11354. Signed-off-by: Brandon Williams <bmwill@google.com>
  11355. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11356.  
  11357. real_path: resolve symlinks by hand
  11358.  
  11359. The current implementation of real_path uses chdir() in order to resolve
  11360. symlinks. Unfortunately this isn't thread-safe as chdir() affects a
  11361. process as a whole and not just an individual thread. Instead perform
  11362. the symlink resolution by hand so that the calls to chdir() can be
  11363. removed, making real_path one step closer to being reentrant.
  11364.  
  11365. Signed-off-by: Brandon Williams <bmwill@google.com>
  11366. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11367.  
  11368. submodule: add absorb-git-dir function
  11369.  
  11370. When a submodule has its git dir inside the working dir, the submodule
  11371. support for checkout that we plan to add in a later patch will fail.
  11372.  
  11373. Add functionality to migrate the git directory to be absorbed
  11374. into the superprojects git directory.
  11375.  
  11376. The newly added code in this patch is structured such that other areas of
  11377. Git can also make use of it. The code in the submodule--helper is a mere
  11378. wrapper and option parser for the function
  11379. `absorb_git_dir_into_superproject`, that takes care of embedding the
  11380. submodules git directory into the superprojects git dir. That function
  11381. makes use of the more abstract function for this use case
  11382. `relocate_gitdir`, which can be used by e.g. the worktree code eventually
  11383. to move around a git directory.
  11384.  
  11385. Signed-off-by: Stefan Beller <sbeller@google.com>
  11386. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11387.  
  11388. move connect_work_tree_and_git_dir to dir.h
  11389.  
  11390. That function was primarily used by submodule code, but the function
  11391. itself is not inherently about submodules. In the next patch we'll
  11392. introduce relocate_git_dir, which can be used by worktrees as well,
  11393. so find a neutral middle ground in dir.h.
  11394.  
  11395. Signed-off-by: Stefan Beller <sbeller@google.com>
  11396. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11397.  
  11398. worktree: check if a submodule uses worktrees
  11399.  
  11400. In a later patch we want to move around the the git directory of
  11401. a submodule. Both submodules as well as worktrees are involved in
  11402. placing git directories at unusual places, so their functionality
  11403. may collide. To react appropriately to situations where worktrees
  11404. in submodules are in use, offer a new function to query the
  11405. a submodule if it uses the worktree feature.
  11406.  
  11407. An earlier approach:
  11408. "Implement submodule_get_worktrees and just count them", however:
  11409. This can be done cheaply (both in new code to write as well as run time)
  11410. by obtaining the list of worktrees based off that submodules git
  11411. directory. However as we have loaded the variables for the current
  11412. repository, the values in the submodule worktree
  11413. can be wrong, e.g.
  11414. * core.ignorecase may differ between these two repositories
  11415. * the ref resolution is broken (refs/heads/branch in the submodule
  11416. resolves to the sha1 value of the `branch` in the current repository
  11417. that may not exist or have another sha1)
  11418.  
  11419. The implementation here is just checking for any files in
  11420. $GIT_COMMON_DIR/worktrees for the submodule, which ought to be sufficient
  11421. if the submodule is using the current repository format, which we also
  11422. check.
  11423.  
  11424. Signed-off-by: Stefan Beller <sbeller@google.com>
  11425. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11426.  
  11427. tmp-objdir: quote paths we add to alternates
  11428.  
  11429. Commit 722ff7f87 (receive-pack: quarantine objects until
  11430. pre-receive accepts, 2016-10-03) regressed pushes to
  11431. repositories with colon (or semi-colon in Windows in them)
  11432. because it adds the repository's main object directory to
  11433. GIT_ALTERNATE_OBJECT_DIRECTORIES. The receiver interprets
  11434. the colon as a delimiter, not as part of the path, and
  11435. index-pack is unable to find objects which it needs to
  11436. resolve deltas.
  11437.  
  11438. The previous commit introduced a quoting mechanism for the
  11439. alternates list; let's use it here to cover this case. We'll
  11440. avoid quoting when we can, though. This alternate setup is
  11441. also used when calling hooks, so it's possible that the user
  11442. may call older git implementations which don't understand
  11443. the quoting mechanism. By quoting only when necessary, this
  11444. setup will continue to work unless the user _also_ has a
  11445. repository whose path contains the delimiter.
  11446.  
  11447. Signed-off-by: Jeff King <peff@peff.net>
  11448. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11449.  
  11450. alternates: accept double-quoted paths
  11451.  
  11452. We read lists of alternates from objects/info/alternates
  11453. files (delimited by newline), as well as from the
  11454. GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable
  11455. (delimited by colon or semi-colon, depending on the
  11456. platform).
  11457.  
  11458. There's no mechanism for quoting the delimiters, so it's
  11459. impossible to specify an alternate path that contains a
  11460. colon in the environment, or one that contains a newline in
  11461. a file. We've lived with that restriction for ages because
  11462. both alternates and filenames with colons are relatively
  11463. rare, and it's only a problem when the two meet. But since
  11464. 722ff7f87 (receive-pack: quarantine objects until
  11465. pre-receive accepts, 2016-10-03), which builds on the
  11466. alternates system, every push causes the receiver to set
  11467. GIT_ALTERNATE_OBJECT_DIRECTORIES internally.
  11468.  
  11469. It would be convenient to have some way to quote the
  11470. delimiter so that we can represent arbitrary paths.
  11471.  
  11472. The simplest thing would be an escape character before a
  11473. quoted delimiter (e.g., "\:" as a literal colon). But that
  11474. creates a backwards compatibility problem: any path which
  11475. uses that escape character is now broken, and we've just
  11476. shifted the problem. We could choose an unlikely escape
  11477. character (e.g., something from the non-printable ASCII
  11478. range), but that's awkward to use.
  11479.  
  11480. Instead, let's treat names as unquoted unless they begin
  11481. with a double-quote, in which case they are interpreted via
  11482. our usual C-stylke quoting rules. This also breaks
  11483. backwards-compatibility, but in a smaller way: it only
  11484. matters if your file has a double-quote as the very _first_
  11485. character in the path (whereas an escape character is a
  11486. problem anywhere in the path). It's also consistent with
  11487. many other parts of git, which accept either a bare pathname
  11488. or a double-quoted one, and the sender can choose to quote
  11489. or not as required.
  11490.  
  11491. Signed-off-by: Jeff King <peff@peff.net>
  11492. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11493.  
  11494. Merge branch 'jk/alt-odb-cleanup' into jk/quote-env-path-list-component
  11495.  
  11496. * jk/alt-odb-cleanup:
  11497. alternates: re-allow relative paths from environment
  11498.  
  11499. date-formats.txt: Typo fix
  11500.  
  11501. Last time I checked, I was living in the UTC+01:00 time zone. UTC+02:00
  11502. would be Central European _Summer_ Time.
  11503.  
  11504. Signed-off-by: Luis Ressel <aranea@aixah.de>
  11505. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11506.  
  11507. git-svn: document useLogAuthor and addAuthorFrom config keys
  11508.  
  11509. We've always supported these config keys in git-svn,
  11510. so document them so users won't have to respecify them
  11511. on every invocation.
  11512.  
  11513. Reported-by: Juergen Kosel <juergen.kosel@gmx.de>
  11514. Signed-off-by: Eric Wong <e@80x24.org>
  11515.  
  11516. git-svn: allow "0" in SVN path components
  11517.  
  11518. Blindly checking a path component for falsiness is unwise, as
  11519. "0" is false to Perl, but a valid pathname component for SVN
  11520. (or any filesystem).
  11521.  
  11522. Found via random code reading.
  11523.  
  11524. Signed-off-by: Eric Wong <e@80x24.org>
  11525.  
  11526. submodule--helper: set alternateLocation for cloned submodules
  11527.  
  11528. In 31224cbdc7 (clone: recursive and reference option triggers
  11529. submodule alternates, 2016-08-17) a mechanism was added to
  11530. have submodules referenced. It did not address _nested_
  11531. submodules, however.
  11532.  
  11533. This patch makes all not just the root repository, but also
  11534. all submodules (recursively) have submodule.alternateLocation
  11535. and submodule.alternateErrorStrategy configured, making Git
  11536. search for possible alternates for nested submodules as well.
  11537.  
  11538. As submodule's alternate target does not end in .git/objects
  11539. (rather .git/modules/qqqqqq/objects), this alternate target
  11540. path restriction for in add_possible_reference_from_superproject
  11541. relates from "*.git/objects" to just */objects".
  11542.  
  11543. New tests have been added to t7408-submodule-reference.
  11544.  
  11545. Signed-off-by: Vitaly _Vi Shukela <vi0oss@gmail.com>
  11546. Reviewed-by: Stefan Beller <sbeller@google.com>
  11547. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11548.  
  11549. gitk: Update copyright notice to 2016
  11550.  
  11551. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11552.  
  11553. gitk: Clear array 'commitinfo' on reload
  11554.  
  11555. After a reload we might have an entirely different set of commits,
  11556. so keeping all of them leaks memory. Remove them all because
  11557. re-creating them is not more expensive than testing wether they're
  11558. still valid. Lazy (re-)creation is already well established, so
  11559. a missing entry can't cause harm.
  11560.  
  11561. Signed-off-by: Markus Hitter <mah@jump-ing.de>
  11562. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11563.  
  11564. gitk: Remove closed file descriptors from $blobdifffd
  11565.  
  11566. One shouldn't have descriptors of already closed files around.
  11567.  
  11568. The first idea to deal with this (previously) ever growing array
  11569. was to remove it entirely, but it's needed to detect start of a
  11570. new diff with ths old diff not yet done. This happens when a user
  11571. clicks on the same commit in the commit list repeatedly without
  11572. delay.
  11573.  
  11574. Signed-off-by: Markus Hitter <mah@jump-ing.de>
  11575. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11576.  
  11577. gitk: Turn off undo manager in the text widget
  11578.  
  11579. The diff text widget is read-only, so there's zero point in
  11580. building an undo stack. This change reduces memory consumption of
  11581. this widget by about 95%.
  11582.  
  11583. Memory usage of the whole program for viewing a reference commit
  11584. before; 579'692'744 bytes, after: 32'724'446 bytes.
  11585.  
  11586. Test procedure:
  11587.  
  11588. - Choose a largish commit and check it out. In this case one with
  11589. 90'802 lines, 5'006'902 bytes.
  11590.  
  11591. - Have a Tcl version with memory debugging enabled. This is,
  11592. build one with --enable-symbols=mem passed to configure.
  11593.  
  11594. - Instrument Gitk to regularly show a memory dump. E.g. by adding
  11595. these code lines at the very bottom:
  11596.  
  11597. proc memDump {} {
  11598. catch {
  11599. set output [memory info]
  11600. puts $output
  11601. }
  11602.  
  11603. after 3000 memDump
  11604. }
  11605.  
  11606. memDump
  11607.  
  11608. - Start Gitk, it'll load this largish commit into the diff text
  11609. field automatically (because it's the current commit).
  11610.  
  11611. - Wait until memory consumption levels out and note the numbers.
  11612.  
  11613. Note that the numbers reported by [memory info] are much smaller
  11614. than the ones reported in 'top' (1.75 GB vs. 105 MB in this case),
  11615. likely due to all the instrumentation coming with the debug
  11616. version of Tcl.
  11617.  
  11618. Signed-off-by: Markus Hitter <mah@jump-ing.de>
  11619. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11620.  
  11621. gitk: Fix Japanese translation for "marked commit"
  11622.  
  11623. Signed-off-by: Satoshi Yasushima <s.yasushima@gmail.com>
  11624. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11625.  
  11626. gitk: Fix missing commits when using -S or -G
  11627.  
  11628. When -S or -G is used as a filter option, the resulting commit list
  11629. rarely contains all matching commits. Only a certain number of commits
  11630. are displayed and the rest are missing.
  11631.  
  11632. "git log --boundary -S" does not return as many boundary commits as you
  11633. might expect. gitk makes up for this in closevarcs() by adding missing
  11634. parent (boundary) commits. However, it does not change $numcommits,
  11635. which limits how many commits are shown. In the end, some commits at the
  11636. end of the commit list are simply not shown.
  11637.  
  11638. Change $numcommits whenever a missing parent is added to the current
  11639. view.
  11640.  
  11641. Signed-off-by: Stefan Dotterweich <stefandotterweich@gmx.de>
  11642. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11643.  
  11644. gitk: Use explicit RGB green instead of "lime"
  11645.  
  11646. Some systems don't recognize "lime" as a color, leading to errors when
  11647. gitk is run. What we want is a bright green, so use "#00ff00" instead.
  11648.  
  11649. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11650.  
  11651. gitk: Add Portuguese translation
  11652.  
  11653. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11654. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11655.  
  11656. mergetools: fix xxdiff hotkeys
  11657.  
  11658. xxdiff was using a mix of "Ctrl-<key>" and "Ctrl+<key>" hotkeys.
  11659. The dashed "-" form is not accepted by newer xxdiff versions.
  11660. Use the plus "+" form only.
  11661.  
  11662. Signed-off-by: David Aguilar <davvid@gmail.com>
  11663. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11664.  
  11665. difftool: rename variables for consistency
  11666.  
  11667. Always call the list of files @files.
  11668. Always call the worktree $worktree.
  11669.  
  11670. Signed-off-by: David Aguilar <davvid@gmail.com>
  11671. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11672.  
  11673. difftool: chdir as early as possible
  11674.  
  11675. Make difftool chdir to the top-level of the repository as soon as it can
  11676. so that we can simplify how paths are handled. Replace construction of
  11677. absolute paths via string concatenation with relative paths wherever
  11678. possible. The bulk of the code no longer needs to use absolute paths.
  11679.  
  11680. Signed-off-by: David Aguilar <davvid@gmail.com>
  11681. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11682.  
  11683. difftool: sanitize $workdir as early as possible
  11684.  
  11685. The double-slash fixup on the $workdir variable was being
  11686. performed just-in-time to avoid double-slashes in symlink
  11687. targets, but the rest of the code was silently using paths with
  11688. embedded "//" in them.
  11689.  
  11690. A recent user-reported error message contained double-slashes.
  11691. Eliminate the issue by sanitizing inputs as soon as they arrive.
  11692.  
  11693. Signed-off-by: David Aguilar <davvid@gmail.com>
  11694. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11695.  
  11696. difftool: fix dir-diff index creation when in a subdirectory
  11697.  
  11698. 9ec26e7977 (difftool: fix argument handling in subdirs, 2016-07-18)
  11699. corrected how path arguments are handled in a subdirectory, but
  11700. it introduced a regression in how entries outside of the
  11701. subdirectory are handled by dir-diff.
  11702.  
  11703. When preparing the right-side of the diff we only include the
  11704. changed paths in the temporary area.
  11705.  
  11706. The left side of the diff is constructed from a temporary
  11707. index that is built from the same set of changed files, but it
  11708. was being constructed from within the subdirectory. This is a
  11709. problem because the indexed paths are toplevel-relative, and
  11710. thus they were not getting added to the index.
  11711.  
  11712. Teach difftool to chdir to the toplevel of the repository before
  11713. preparing its temporary indexes. This ensures that all of the
  11714. toplevel-relative paths are valid.
  11715.  
  11716. Add test cases to more thoroughly exercise this scenario.
  11717.  
  11718. Reported-by: Frank Becker <fb@mooflu.com>
  11719. Signed-off-by: David Aguilar <davvid@gmail.com>
  11720. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11721.  
  11722. mingw: intercept isatty() to handle /dev/null as Git expects it
  11723.  
  11724. When Git's source code calls isatty(), it really asks whether the
  11725. respective file descriptor is connected to an interactive terminal.
  11726.  
  11727. Windows' _isatty() function, however, determines whether the file
  11728. descriptor is associated with a character device. And NUL, Windows'
  11729. equivalent of /dev/null, is a character device.
  11730.  
  11731. Which means that for years, Git mistakenly detected an associated
  11732. interactive terminal when being run through the test suite, which
  11733. almost always redirects stdin, stdout and stderr to /dev/null.
  11734.  
  11735. This bug only became obvious, and painfully so, when the new
  11736. bisect--helper entered the `pu` branch and made the automatic build & test
  11737. time out because t6030 was waiting for an answer.
  11738.  
  11739. For details, see
  11740.  
  11741. https://msdn.microsoft.com/en-us/library/f4s0ddew.aspx
  11742.  
  11743. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  11744. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11745.  
  11746. gitk: Makefile: create install bin directory
  11747.  
  11748. Force creation of destination bin directory. Without this, gitk
  11749. would fail to install if this directory didn't already exist.
  11750.  
  11751. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
  11752. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11753.  
  11754. gitk: Include commit title in branch dialog
  11755.  
  11756. Hi,
  11757.  
  11758. I made another branch dialog related change, included in this message.
  11759. It applies on top of my other two patches.
  11760.  
  11761. Rogier.
  11762.  
  11763. ------- 8< ------------------- 8< --------------
  11764.  
  11765. Only the SHA1 was included. It's convenient to have the title
  11766. mentioned as well.
  11767.  
  11768. Signed-off-by: Rogier Goossens <goossens.rogier@gmail.com>
  11769. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11770.  
  11771. gitk: Allow checking out a remote branch
  11772.  
  11773. Git allows checking out remote branches, creating a local tracking
  11774. branch in the process. Allow gitk to do this as well, provided a
  11775. local branch of the same name does not yet exist.
  11776.  
  11777. Signed-off-by: Rogier Goossens <goossens.rogier@gmail.com>
  11778. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11779.  
  11780. gitk: Add a 'rename' option to the branch context menu
  11781.  
  11782. Signed-off-by: Rogier Goossens <goossens.rogier@gmail.com>
  11783. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  11784.  
  11785. ref-filter: add support to display trailers as part of contents
  11786.  
  11787. Add %(trailers) and %(contents:trailers) to display the trailers as
  11788. interpreted by trailer_info_get. Update documentation and add a test for
  11789. the new feature.
  11790.  
  11791. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  11792. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11793.  
  11794. pretty: add %(trailers) format for displaying trailers of a commit message
  11795.  
  11796. Recent patches have expanded on the trailers.c code and we have the
  11797. builtin commant git-interpret-trailers which can be used to add or
  11798. modify trailer lines. However, there is no easy way to simply display
  11799. the trailers of a commit message.
  11800.  
  11801. Add support for %(trailers) format modifier which will use the
  11802. trailer_info_get() calls to read trailers in an identical way as git
  11803. interpret-trailers does. Use a long format option instead of a short
  11804. name so that future work can more easily unify ref-filter and pretty
  11805. formats.
  11806.  
  11807. Add documentation and tests for the same.
  11808.  
  11809. Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
  11810. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11811.  
  11812. rebase: add --quit to cleanup rebase, leave everything else untouched
  11813.  
  11814. There are occasions when you decide to abort an in-progress rebase and
  11815. move on to do something else but you forget to do "git rebase --abort"
  11816. first. Or the rebase has been in progress for so long you forgot about
  11817. it. By the time you realize that (e.g. by starting another rebase)
  11818. it's already too late to retrace your steps. The solution is normally
  11819.  
  11820. rm -r .git/<some rebase dir>
  11821.  
  11822. and continue with your life. But there could be two different
  11823. directories for <some rebase dir> (and it obviously requires some
  11824. knowledge of how rebase works), and the ".git" part could be much
  11825. longer if you are not at top-dir, or in a linked worktree. And
  11826. "rm -r" is very dangerous to do in .git, a mistake in there could
  11827. destroy object database or other important data.
  11828.  
  11829. Provide "git rebase --quit" for this use case, mimicking a precedent
  11830. that is "git cherry-pick --quit".
  11831.  
  11832. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  11833. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11834.  
  11835. doc: omit needless "for"
  11836.  
  11837. What was intended was perhaps "... plumbing does for you" ("you" added), but
  11838. simply omitting the word "for" is more terse and gets the intended point across
  11839. just as well, if not more so.
  11840.  
  11841. I originally went with the approach of writing "for you", but Junio C
  11842. Hamano suggested this approach instead.
  11843.  
  11844. Signed-off-by: Kristoffer Haugsbakk <kristoffer.haugsbakk@gmail.com>
  11845. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11846.  
  11847. doc: make the intent of sentence clearer
  11848.  
  11849. By adding the word "just", which might have been accidentally omitted.
  11850.  
  11851. Adding the word "just" makes it clear that the point is to *not* do an
  11852. octopus merge simply because you *can* do it. In other words, you
  11853. should have a reason for doing it beyond simply having two (seemingly)
  11854. independent commits that you need to merge into another branch, since
  11855. it's not always the best approach.
  11856.  
  11857. The previous sentence made it look more like it was trying to say that
  11858. you shouldn't do an octopus merge *because* you can do an octopus merge.
  11859. Although this interpretation doesn't make sense and the rest of the
  11860. paragraph makes the intended meaning clear, this adjustment should make
  11861. the intent of the sentence more immediately clear to the reader.
  11862.  
  11863. Signed-off-by: Kristoffer Haugsbakk <kristoffer.haugsbakk@gmail.com>
  11864. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11865.  
  11866. doc: add verb in front of command to run
  11867.  
  11868. Instead of using the command 'git clone' as a verb, use "run" as the
  11869. verb indicating the action of executing the command 'git clone'.
  11870.  
  11871. Signed-off-by: Kristoffer Haugsbakk <kristoffer.haugsbakk@gmail.com>
  11872. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11873.  
  11874. doc: add articles (grammar)
  11875.  
  11876. Add definite and indefinite articles in three places where they were
  11877. missing.
  11878.  
  11879. - Use "the" in front of a directory name
  11880. - Use "the" in front of "style of cooperation"
  11881. - Use an indefinite article in front of "CVS background"
  11882.  
  11883. Signed-off-by: Kristoffer Haugsbakk <kristoffer.haugsbakk@gmail.com>
  11884. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11885.  
  11886. test-lib-functions.sh: teach test_commit -C <dir>
  11887.  
  11888. Specifically when setting up submodule tests, it comes in handy if
  11889. we can create commits in repositories that are not at the root of
  11890. the tested trash dir. Add "-C <dir>" similar to gits -C parameter
  11891. that will perform the operation in the given directory.
  11892.  
  11893. Signed-off-by: Stefan Beller <sbeller@google.com>
  11894. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11895.  
  11896. submodule helper: support super prefix
  11897.  
  11898. Just like main commands in Git, the submodule helper needs
  11899. access to the superproject prefix. Enable this in the git.c
  11900. but have its own fuse in the helper code by having a flag to
  11901. turn on the super prefix.
  11902.  
  11903. Signed-off-by: Stefan Beller <sbeller@google.com>
  11904. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11905.  
  11906. submodule: use absolute path for computing relative path connecting
  11907.  
  11908. The current caller of connect_work_tree_and_git_dir passes
  11909. an absolute path for the `git_dir` parameter. In the future patch
  11910. we will also pass in relative path for `git_dir`. Extend the functionality
  11911. of connect_work_tree_and_git_dir to take relative paths for parameters.
  11912.  
  11913. We could work around this in the future patch by computing the absolute
  11914. path for the git_dir in the calling site, however accepting relative
  11915. paths for either parameter makes the API for this function much harder
  11916. to misuse.
  11917.  
  11918. Signed-off-by: Stefan Beller <sbeller@google.com>
  11919. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11920.  
  11921. sequencer: remove useless get_dir() function
  11922.  
  11923. This function is used only once, for the removal of the
  11924. directory. It is not used for the creation of the directory nor
  11925. anywhere else.
  11926.  
  11927. Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
  11928. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11929.  
  11930. sequencer: make sequencer abort safer
  11931.  
  11932. In contrast to "git am --abort", a sequencer abort did not check
  11933. whether the current HEAD is the one that is expected. This can lead
  11934. to loss of work (when not spotted and resolved using reflog before
  11935. the garbage collector chimes in).
  11936.  
  11937. This behavior is now changed by mimicking "git am --abort". The
  11938. abortion is done but HEAD is not changed when the current HEAD is
  11939. not the expected HEAD.
  11940.  
  11941. A new file "sequencer/abort-safety" is added to save the expected
  11942. HEAD.
  11943.  
  11944. The new behavior is only active when --abort is invoked on multiple
  11945. picks. The problem does not occur for the single-pick case because
  11946. it is handled differently.
  11947.  
  11948. Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
  11949. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11950.  
  11951. t3510: test that cherry-pick --abort does not unsafely change HEAD
  11952.  
  11953. Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
  11954. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11955.  
  11956. commit: remove 'Clever' message for --only --amend
  11957.  
  11958. The behavior is now documented; more importantly, rewarding the user
  11959. with a "Wow, you are clever" praise afterwards is not an effective
  11960. way to advertise the feature--at that point the user already knows.
  11961.  
  11962. Signed-off-by: Andreas Krey <a.krey@gmx.de>
  11963. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11964.  
  11965. diff: handle --no-abbrev in no-index case
  11966.  
  11967. There are two different places where the --no-abbrev option is parsed,
  11968. and two different places where SHA-1s are abbreviated. We normally parse
  11969. --no-abbrev with setup_revisions(), but in the no-index case, "git diff"
  11970. calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
  11971. --no-abbrev until now. (It did handle --abbrev, however.) We normally
  11972. abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666 ("diff:
  11973. handle sha1 abbreviations outside of repository, 2016-10-20) recently
  11974. introduced a special case when you run "git diff" outside of a
  11975. repository.
  11976.  
  11977. setup_revisions() does also call diff_opt_parse(), but not for --abbrev
  11978. or --no-abbrev, which it handles itself. setup_revisions() sets
  11979. rev_info->abbrev, and later copies that to diff_options->abbrev. It
  11980. handles --no-abbrev by setting abbrev to zero. (This change doesn't
  11981. touch that.)
  11982.  
  11983. Setting abbrev to zero was broken in the outside-of-a-repository special
  11984. case, which until now resulted in a truly zero-length SHA-1, rather than
  11985. taking zero to mean do not abbreviate. The only way to trigger this bug,
  11986. however, was by running "git diff --raw" without either the --abbrev or
  11987. --no-abbrev options, because 1) without --raw it doesn't respect abbrev
  11988. (which is bizarre, but has been that way forever), 2) we silently clamp
  11989. --abbrev=0 to MINIMUM_ABBREV, and 3) --no-abbrev wasn't handled until
  11990. now.
  11991.  
  11992. The outside-of-a-repository case is one of three no-index cases. The
  11993. other two are when one of the files you're comparing is outside of the
  11994. repository you're in, and the --no-index option.
  11995.  
  11996. Signed-off-by: Jack Bates <jack@nottheoilrig.com>
  11997. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  11998.  
  11999. versioncmp: use earliest-longest contained suffix to determine sorting order
  12000.  
  12001. When comparing tagnames, it is possible that a tagname contains more
  12002. than one of the configured prerelease suffixes around the first
  12003. different character. After fixing a bug in the previous commit such a
  12004. tagname is sorted according to the contained suffix which comes first
  12005. in the configuration. This is, however, not quite the right thing to
  12006. do in the following corner cases:
  12007.  
  12008. 1. $ git -c versionsort.suffix=-bar
  12009. -c versionsort.suffix=-foo-baz
  12010. -c versionsort.suffix=-foo-bar
  12011. tag -l --sort=version:refname 'v1*'
  12012. v1.0-foo-bar
  12013. v1.0-foo-baz
  12014.  
  12015. The suffix of the tagname 'v1.0-foo-bar' is clearly '-foo-bar',
  12016. so it should be listed last. However, as it also contains '-bar'
  12017. around the first different character, it is listed first instead,
  12018. because that '-bar' suffix comes first the configuration.
  12019.  
  12020. 2. One of the configured suffixes starts with the other:
  12021.  
  12022. $ git -c versionsort.prereleasesuffix=-pre \
  12023. -c versionsort.prereleasesuffix=-prerelease \
  12024. tag -l --sort=version:refname 'v2*'
  12025. v2.0-prerelease1
  12026. v2.0-pre1
  12027. v2.0-pre2
  12028.  
  12029. Here the tagname 'v2.0-prerelease1' should be the last. When
  12030. comparing 'v2.0-pre1' and 'v2.0-prerelease1' the first different
  12031. characters are '1' and 'r', respectively. Since this first
  12032. different character must be part of the configured suffix, the
  12033. '-pre' suffix is not recognized in the first tagname. OTOH, the
  12034. '-prerelease' suffix is properly recognized in
  12035. 'v2.0-prerelease1', thus it is listed first.
  12036.  
  12037. Improve version sort in these corner cases, and
  12038.  
  12039. - look for a configured prerelease suffix containing the first
  12040. different character or ending right before it, so the '-pre'
  12041. suffixes are recognized in case (2). This also means that
  12042. when comparing tagnames 'v2.0-pre1' and 'v2.0-pre2',
  12043. swap_prereleases() would find the '-pre' suffix in both, but then
  12044. it will return "undecided" and the caller will do the right thing
  12045. by sorting based in '1' and '2'.
  12046.  
  12047. - If the tagname contains more than one suffix, then give precedence
  12048. to the contained suffix that starts at the earliest offset in the
  12049. tagname to address (1).
  12050.  
  12051. - If there are more than one suffixes starting at that earliest
  12052. position, then give precedence to the longest of those suffixes,
  12053. thus ensuring that in (2) the tagname 'v2.0-prerelease1' won't be
  12054. sorted based on the '-pre' suffix.
  12055.  
  12056. Add tests for these corner cases and adjust the documentation
  12057. accordingly.
  12058.  
  12059. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  12060. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12061.  
  12062. versioncmp: cope with common part overlapping with prerelease suffix
  12063.  
  12064. Version sort with prerelease reordering sometimes puts tagnames in the
  12065. wrong order, when the common part of two compared tagnames overlaps
  12066. with the leading character(s) of one or more configured prerelease
  12067. suffixes. Note the position of "v2.1.0-beta-1":
  12068.  
  12069. $ git -c versionsort.prereleaseSuffix=-beta \
  12070. tag -l --sort=version:refname v2.1.*
  12071. v2.1.0-beta-2
  12072. v2.1.0-beta-3
  12073. v2.1.0
  12074. v2.1.0-RC1
  12075. v2.1.0-RC2
  12076. v2.1.0-beta-1
  12077. v2.1.1
  12078. v2.1.2
  12079.  
  12080. The reason is that when comparing a pair of tagnames, first
  12081. versioncmp() looks for the first different character in a pair of
  12082. tagnames, and then the swap_prereleases() helper function looks for a
  12083. configured prerelease suffix _starting at_ that character. Thus, when
  12084. in the above example the sorting algorithm happens to compare the
  12085. tagnames "v2.1.0-beta-1" and "v2.1.0-RC2", swap_prereleases() tries to
  12086. match the suffix "-beta" against "beta-1" to no avail, and the two
  12087. tagnames erroneously end up being ordered lexicographically.
  12088.  
  12089. To fix this issue change swap_prereleases() to look for configured
  12090. prerelease suffixes _containing_ the position of that first different
  12091. character.
  12092.  
  12093. Care must be taken, when a configured suffix is longer than the
  12094. tagnames' common part up to the first different character, to avoid
  12095. reading memory before the beginning of the tagnames. Add a test that
  12096. uses an exceptionally long prerelease suffix to check for this, in the
  12097. hope that in case of a regression the illegal memory access causes a
  12098. segfault in 'git tag' on one of the commonly used platforms (the test
  12099. happens to pass successfully on my Linux system with the safety check
  12100. removed), or at least makes valgrind complain.
  12101.  
  12102. Under some circumstances it's possible that more than one prerelease
  12103. suffixes can be found in the same tagname around that first different
  12104. character. With this simple bugfix patch such a tagname is sorted
  12105. according to the contained suffix that comes first in the
  12106. configuration for now. This is less than ideal in some cases, and the
  12107. following patch will take care of those.
  12108.  
  12109. Reported-by: Leho Kraav <leho@conversionready.com>
  12110. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  12111. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12112.  
  12113. versioncmp: pass full tagnames to swap_prereleases()
  12114.  
  12115. The swap_prereleases() helper function is responsible for finding
  12116. configured prerelease suffixes in a pair of tagnames to be compared,
  12117. but this function currently gets to see only the parts of those two
  12118. tagnames starting at the first different character. To fix some
  12119. issues related to the common part of two tagnames overlapping with
  12120. leading part of a prerelease suffix, this helper function must see
  12121. both full tagnames.
  12122.  
  12123. In preparation for the fix in the following patch, refactor
  12124. swap_prereleases() and its caller to pass two full tagnames and an
  12125. additional offset indicating the position of the first different
  12126. character.
  12127.  
  12128. While updating the comment describing that function, remove the
  12129. sentence about not dealing with both tagnames having the same suffix.
  12130. Currently it doesn't add much value (we know that there is a different
  12131. character, so it's obvious that it can't possibly be the same suffix
  12132. in both), and at the end of this patch series it won't even be true
  12133. anymore.
  12134.  
  12135. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  12136. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12137.  
  12138. t7004-tag: add version sort tests to show prerelease reordering issues
  12139.  
  12140. Version sort with prerelease reordering sometimes puts tagnames in the
  12141. wrong order, when the common part of two compared tagnames ends with
  12142. the leading character(s) of one or more configured prerelease
  12143. suffixes. Add tests that demonstrate these issues.
  12144.  
  12145. The unrelated '--format should list tags as per format given' test
  12146. later uses tags matching the same prefix as the version sort tests,
  12147. thus was affected by the new tags added for the new tests in this
  12148. patch. Change that test to perform its checks on a different set of
  12149. tags.
  12150.  
  12151. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  12152. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12153.  
  12154. t7004-tag: use test_config helper
  12155.  
  12156. ... instead of setting and then manually unsetting configuration
  12157. variables, on one occasion even outside the test_expect_success block.
  12158.  
  12159. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  12160. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12161.  
  12162. t7004-tag: delete unnecessary tags with test_when_finished
  12163.  
  12164. The '--force is moot with a non-existing tag name' test creates two
  12165. new tags, which are then deleted right after the test is finished,
  12166. outside the test_expect_success block, allowing 'git tag -d's output to
  12167. pollute the test output.
  12168.  
  12169. Use test_when_finished to delete those tags.
  12170.  
  12171. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  12172. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12173.  
  12174. difftool: fix dir-diff index creation when in a subdirectory
  12175.  
  12176. 9ec26e7977 (difftool: fix argument handling in subdirs, 2016-07-18)
  12177. corrected how path arguments are handled in a subdirectory, but
  12178. it introduced a regression in how entries outside of the
  12179. subdirectory are handled by dir-diff.
  12180.  
  12181. When preparing the right-side of the diff we only include the
  12182. changed paths in the temporary area.
  12183.  
  12184. The left side of the diff is constructed from a temporary
  12185. index that is built from the same set of changed files, but it
  12186. was being constructed from within the subdirectory. This is a
  12187. problem because the indexed paths are toplevel-relative, and
  12188. thus they were not getting added to the index.
  12189.  
  12190. Teach difftool to chdir to the toplevel of the repository before
  12191. preparing its temporary indexes. This ensures that all of the
  12192. toplevel-relative paths are valid.
  12193.  
  12194. Add test cases to more thoroughly exercise this scenario.
  12195.  
  12196. Reported-by: Frank Becker <fb@mooflu.com>
  12197. Signed-off-by: David Aguilar <davvid@gmail.com>
  12198. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12199.  
  12200. am: change safe_to_abort()'s not rewinding error into a warning
  12201.  
  12202. The error message tells the user that something went terribly wrong
  12203. and the --abort could not be performed. But the --abort is performed,
  12204. only without rewinding. By simply changing the error into a warning,
  12205. we indicate the user that she must not try something like
  12206. "git am --abort --force", instead she just has to check the HEAD.
  12207.  
  12208. Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
  12209. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12210.  
  12211. am: fix filename in safe_to_abort() error message
  12212.  
  12213. Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
  12214. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12215.  
  12216. shallow.c: remove useless code
  12217.  
  12218. Some context before we talk about the removed code.
  12219.  
  12220. This paint_down() is part of step 6 of 58babff (shallow.c: the 8 steps
  12221. to select new commits for .git/shallow - 2013-12-05). When we fetch from
  12222. a shallow repository, we need to know if one of the new/updated refs
  12223. needs new "shallow commits" in .git/shallow (because we don't have
  12224. enough history of those refs) and which one.
  12225.  
  12226. The question at step 6 is, what (new) shallow commits are required in
  12227. other to maintain reachability throughout the repository _without_
  12228. cutting our history short? To answer, we mark all commits reachable from
  12229. existing refs with UNINTERESTING ("rev-list --not --all"), mark shallow
  12230. commits with BOTTOM, then for each new/updated refs, walk through the
  12231. commit graph until we either hit UNINTERESTING or BOTTOM, marking the
  12232. ref on the commit as we walk.
  12233.  
  12234. After all the walking is done, we check the new shallow commits. If we
  12235. have not seen any new ref marked on a new shallow commit, we know all
  12236. new/updated refs are reachable using just our history and .git/shallow.
  12237. The shallow commit in question is not needed and can be thrown away.
  12238.  
  12239. So, the code.
  12240.  
  12241. The loop here (to walk through commits) is basically
  12242.  
  12243. 1. get one commit from the queue
  12244. 2. ignore if it's SEEN or UNINTERESTING
  12245. 3. mark it
  12246. 4. go through all the parents and..
  12247. 5a. mark it if it's never marked before
  12248. 5b. put it back in the queue
  12249.  
  12250. What we do in this patch is drop step 5a because it is not
  12251. necessary. The commit being marked at 5a is put back on the queue, and
  12252. will be marked at step 3 at the next iteration. The only case it will
  12253. not be marked is when the commit is already marked UNINTERESTING (5a
  12254. does not check this), which will be ignored at step 2.
  12255.  
  12256. But we don't care about refs marking on UNINTERESTING. We care about the
  12257. marking on _shallow commits_ that are not reachable from our current
  12258. history (and having UNINTERESTING on it means it's reachable). So it's
  12259. ok for an UNINTERESTING not to be ref-marked.
  12260.  
  12261. Reported-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
  12262. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  12263. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12264.  
  12265. shallow.c: bit manipulation tweaks
  12266.  
  12267. First of all, 1 << 31 is technically undefined behaviour, so let's just
  12268. use an unsigned literal.
  12269.  
  12270. If i is 'signed int' and gcc doesn't know that i is positive, gcc
  12271. generates code to compute the C99-mandated values of "i / 32" and "i %
  12272. 32", which is a lot more complicated than simple a simple shifts/mask.
  12273.  
  12274. The only caller of paint_down actually passes an "unsigned int" value,
  12275. but the prototype of paint_down causes (completely well-defined)
  12276. conversion to signed int, and gcc has no way of knowing that the
  12277. converted value is non-negative. Just make the id parameter unsigned.
  12278.  
  12279. In update_refstatus, the change in generated code is much smaller,
  12280. presumably because gcc is smart enough to see that i starts as 0 and is
  12281. only incremented, so it is allowed (per the UD of signed overflow) to
  12282. assume that i is always non-negative. But let's just help less smart
  12283. compilers generate good code anyway.
  12284.  
  12285. Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
  12286. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  12287. Reviewed-by: Jeff King <peff@peff.net>
  12288. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12289.  
  12290. shallow.c: avoid theoretical pointer wrap-around
  12291.  
  12292. The expression info->free+size is technically undefined behaviour in
  12293. exactly the case we want to test for. Moreover, the compiler is likely
  12294. to translate the expression to
  12295.  
  12296. (unsigned long)info->free + size > (unsigned long)info->end
  12297.  
  12298. where there's at least a theoretical chance that the LHS could wrap
  12299. around 0, giving a false negative.
  12300.  
  12301. This might as well be written using pointer subtraction avoiding these
  12302. issues.
  12303.  
  12304. Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
  12305. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  12306. Reviewed-by: Jeff King <peff@peff.net>
  12307. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12308.  
  12309. shallow.c: make paint_alloc slightly more robust
  12310.  
  12311. paint_alloc() allocates a big block of memory and splits it into
  12312. smaller, fixed size, chunks of memory whenever it's called. Each chunk
  12313. contains enough bits to present all "new refs" [1] in a fetch from a
  12314. shallow repository.
  12315.  
  12316. We do not check if the new "big block" is smaller than the requested
  12317. memory chunk though. If it happens, we'll happily pass back a memory
  12318. region smaller than expected. Which will lead to problems eventually.
  12319.  
  12320. A normal fetch may add/update a dozen new refs. Let's stay on the
  12321. "reasonably extreme" side and say we need 16k refs (or bits from
  12322. paint_alloc's perspective). Each chunk of memory would be 2k, much
  12323. smaller than the memory pool (512k).
  12324.  
  12325. So, normally, the under-allocation situation should never happen. A bad
  12326. guy, however, could make a fetch that adds more than 4m new/updated refs
  12327. to this code which results in a memory chunk larger than pool size.
  12328. Check this case and abort.
  12329.  
  12330. Noticed-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
  12331. Reviewed-by: Jeff King <peff@peff.net>
  12332.  
  12333. [1] Details are in commit message of 58babff (shallow.c: the 8 steps to
  12334. select new commits for .git/shallow - 2013-12-05), step 6.
  12335.  
  12336. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  12337. Reviewed-by: Jeff King <peff@peff.net>
  12338. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12339.  
  12340. shallow.c: stop abusing COMMIT_SLAB_SIZE for paint_info's memory pools
  12341.  
  12342. We need to allocate a "big" block of memory in paint_alloc(). The exact
  12343. size does not really matter. But the pool size has no relation with
  12344. commit-slab. Stop using that macro here.
  12345.  
  12346. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  12347. Reviewed-by: Jeff King <peff@peff.net>
  12348. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12349.  
  12350. shallow.c: rename fields in paint_info to better express their purposes
  12351.  
  12352. paint_alloc() is basically malloc(), tuned for allocating a fixed number
  12353. of bits on every call without worrying about freeing any individual
  12354. allocation since all will be freed at the end. It does it by allocating
  12355. a big block of memory every time it runs out of "free memory". "slab" is
  12356. a poor choice of name, at least poorer than "pool".
  12357.  
  12358. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
  12359. Reviewed-by: Jeff King <peff@peff.net>
  12360. Signed-off-by: Junio C Hamano <gitster@pobox.com>
  12361.  
  12362. lockfile: LOCK_REPORT_ON_ERROR
  12363.  
  12364. The "libify sequencer" topic stopped passing the die_on_error option
  12365. to hold_locked_index(), and this lost an error message from "git
  12366. merge --ff-only $commit" when there are competing updates in
  12367. progress.
  12368.  
  12369. The command still exits with a non-zero status, but that is not of
  12370. much help for an interactive user. The last thing the command says
  12371. is "Updating $from..$to". We used to follow it with a big error
  12372. message that makes it clear that "merge --ff-only" did not succeed.
  12373.  
  12374. What is sad is that we should have noticed this regression while
  12375. reviewing the change. It was clear that the update to the
  12376. checkout_fast_forward() function made a failing hold_locked_index()
  12377. silent, but the only caller of the checkout_fast_forward() function
  12378. had this comment:
  12379.  
  12380. if (checkout_fast_forward(from, to, 1))
  12381. - exit(128); /* the callee should have complained already */
  12382. + return -1; /* the callee should have complained already */
  12383.  
  12384. which clearly contradicted the assumption X-<.
  12385.  
  12386. Add a new option LOCK_REPORT_ON_ERROR that can be passed instead of
  12387. LOCK_DIE_ON_ERROR to the hold_lock*() family of functions and teach
  12388. checkout_fast_forward() to use it to fix this regression.
  12389.  
  12390. After going thourgh all calls to hold_lock*() family of functions
  12391. that used to pass LOCK_DIE_ON_ERROR but were modified to pass 0 in
  12392. the "libify sequencer" topic "git show --first-parent 2a4062a4a8",
  12393. it appears that this is the only one that has become silent. Many
  12394. others used to give detailed report that talked about "there may be
  12395. competing Git process running" but with the series merged they now
  12396. only give a single liner "Unable to lock ...", some of which may
  12397. have to be tweaked further, but at least they say something, unlike
  12398. the one this patch fixes.
  12399.  
  12400. Reported-by: Robbie Iannucci <iannucci@google.com>
  12401. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement