· 9 years ago · Mar 10, 2017, 11:08 AM
1git svn: fix authentication with 'branch'
2
3Authentication fails with svn branch while svn rebase and
4svn dcommit work fine without authentication failures.
5
6$ git svn branch v7_3
7Copying https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx at r27519
8to https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/v7_3...
9Can't create session: Unable to connect to a repository at URL
10'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': No more
11credentials or we tried too many times.
12Authentication failed at
13C:\Program Files\Git\mingw64/libexec/git-core\git-svn line 1200.
14
15We add auth configuration to SVN::Client->new() to fix the issue.
16
17Signed-off-by: Hiroshi Shirosaki <h.shirosaki@gmail.com>
18Signed-off-by: Eric Wong <e@80x24.org>
19
20First batch after 2.12
21
22Signed-off-by: Junio C Hamano <gitster@pobox.com>
23
24Merge branch 'rl/remote-allow-missing-branch-name-merge'
25
26"git remote rm X", when a branch has remote X configured as the
27value of its branch.*.remote, tried to remove branch.*.remote and
28branch.*.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
33Merge branch 'km/delete-ref-reflog-message'
34
35"git update-ref -d" and other operations to delete references did
36not leave any entry in HEAD's reflog when the reference being
37deleted was the current branch. This is not a problem in practice
38because you do not want to delete the branch you are currently on,
39but caused renaming of the current branch to something else not to
40be 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
48Merge branch 'jk/tempfile-ferror-fclose-confusion'
49
50A caller of tempfile API that uses stdio interface to write to
51files may ignore errors while writing, which is detected when
52tempfile is closed (with a call to ferror()). By that time, the
53original errno that may have told us what went wrong is likely to
54be long gone and was overwritten by an irrelevant value.
55close_tempfile() now resets errno to EIO to make errno at least
56predictable.
57
58* jk/tempfile-ferror-fclose-confusion:
59 tempfile: set errno to a known value before calling ferror()
60
61Merge branch 'vn/xdiff-func-context'
62
63"git diff -W" has been taught to handle the case where a new
64function 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
69Merge branch 'js/git-path-in-subdir'
70
71The "--git-path", "--git-common-dir", and "--shared-index-path"
72options of "git rev-parse" did not produce usable output. They are
73now updated to show the path to the correct file, relative to where
74the 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
80Merge branch 'mm/two-more-xstrfmt'
81
82Code 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
88Merge branch 'nd/clean-preserve-errno-in-warning'
89
90Some warning() messages from "git clean" were updated to show the
91errno from failed system calls.
92
93* nd/clean-preserve-errno-in-warning:
94 clean: use warning_errno() when appropriate
95
96Merge branch 'jk/show-branch-lift-name-len-limit'
97
98"git show-branch" expected there were only very short branch names
99in the repository and used a fixed-length buffer to hold them
100without 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
107Merge branch 'jn/remote-helpers-with-git-dir'
108
109"git ls-remote" and "git archive --remote" are designed to work
110without being in a directory under Git's control. However, recent
111updates revealed that we randomly look into a directory called
112.git/ without actually doing necessary set-up when working in a
113repository. 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
119Merge branch 'jk/grep-no-index-fix'
120
121The code to parse the command line "git grep <patterns>... <rev>
122[[--] <pathspec>...]" has been cleaned up, and a handful of bugs
123have 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
134Merge branch 'dt/gc-ignore-old-gc-logs'
135
136A "gc.log" file left by a backgrounded "gc --auto" disables further
137automatic gc; it has been taught to run at least once a day (by
138default) 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
143Merge branch 'jh/preload-index-skip-skip'
144
145The preload-index code has been taught not to bother with the index
146entries 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
151Merge branch 'mh/submodule-hash'
152
153Code 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
166Merge branch 'sf/putty-w-args'
167
168The command line options for ssh invocation needs to be tweaked for
169some implementations of SSH (e.g. PuTTY plink wants "-P <port>"
170while OpenSSH wants "-p <port>" to specify port to connect to), and
171the variant was guessed when GIT_SSH environment variable is used
172to specify it. The logic to guess now applies to the command
173specified by the newer GIT_SSH_COMMAND and also core.sshcommand
174configuration variable, and comes with an escape hatch for users to
175deal 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
184Merge 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
192Merge branch 'bw/attr'
193
194The gitattributes machinery is being taught to work better in a
195multi-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
220Merge branch 'sg/completion'
221
222Clean-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
247Merge branch 'lt/pathspec-negative'
248
249The "negative" pathspec feature was somewhat more cumbersome to use
250than necessary in that its short-hand used "!" which needed to be
251escaped 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
257Merge branch 'cw/tag-reflog-message'
258
259"git tag" did not leave useful message when adding a new entry to
260reflog; this was left unnoticed for a long time because refs/tags/*
261doesn't keep reflog by default.
262
263* cw/tag-reflog-message:
264 tag: generate useful reflog message
265
266Merge branch 'jk/alternate-ref-optim'
267
268Optimizes resource usage while enumerating refs from alternate
269object store, to help receiving end of "push" that hosts a
270repository 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
285Merge branch 'kn/ref-filter-branch-list'
286
287The code to list branches in "git branch" has been consolidated
288with 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
313Merge branch 'ps/urlmatch-wildcard'
314
315The <url> part in "http.<url>.<variable>" configuration variable
316can now be spelled with '*' that serves as wildcard.
317E.g. "http.https://*.example.com.proxy" can be used to specify the
318proxy used for https://a.example.com, https://b.example.com, etc.,
319i.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
328Merge branch 'mm/merge-rename-delete-message'
329
330When "git merge" detects a path that is renamed in one history
331while the other history deleted (or modified) it, it now reports
332both paths to help the user understand what is going on in the two
333histories being merged.
334
335* mm/merge-rename-delete-message:
336 merge-recursive: make "CONFLICT (rename/delete)" message show both paths
337
338Merge branch 'mh/ref-remove-empty-directory'
339
340Deletion of a branch "foo/bar" could remove .git/refs/heads/foo
341once 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
367Merge branch 'jk/delta-chain-limit'
368
369"git repack --depth=<n>" for a long time busted the specified depth
370when 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
376Merge branch 'jk/describe-omit-some-refs'
377
378"git describe" and "git name-rev" have been taught to take more
379than one refname patterns to restrict the set of refs to base their
380naming output on, and also learned to take negative patterns to
381name 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
390Git 2.12
391
392Signed-off-by: Junio C Hamano <gitster@pobox.com>
393
394Merge branch 'ps/doc-gc-aggressive-depth-update'
395
396Doc update.
397
398* ps/doc-gc-aggressive-depth-update:
399 docs/git-gc: fix default value for `--aggressiveDepth`
400
401Merge branch 'bc/worktree-doc-fix-detached'
402
403Doc update.
404
405* bc/worktree-doc-fix-detached:
406 Documentation: correctly spell git worktree --detach
407
408Merge branch 'dr/doc-check-ref-format-normalize'
409
410Doc update.
411
412* dr/doc-check-ref-format-normalize:
413 git-check-ref-format: clarify documentation for --normalize
414
415Merge branch 'gp/document-dotfiles-in-templates-are-not-copied'
416
417Doc update.
418
419* gp/document-dotfiles-in-templates-are-not-copied:
420 init: document dotfiles exclusion on template copy
421
422Merge branch 'rt/align-add-i-help-text'
423
424Doc update.
425
426* rt/align-add-i-help-text:
427 git add -i: replace \t with blanks in the help message
428
429Merge branch 'bc/blame-doc-fix'
430
431Doc update.
432
433* bc/blame-doc-fix:
434 Documentation: use brackets for optional arguments
435
436docs/git-gc: fix default value for `--aggressiveDepth`
437
438In commit 07e7dbf0d (gc: default aggressive depth to 50, 2016-08-11),
439the default aggressive depth of git-gc has been changed to 50. While
440git-config(1) has been updated to represent the new default value,
441git-gc(1) still mentions the old value. This patch fixes it.
442
443Signed-off-by: Patrick Steinhardt <ps@pks.im>
444Reviewed-by: Jeff King <peff@peff.net>
445Signed-off-by: Junio C Hamano <gitster@pobox.com>
446
447Merge tag 'l10n-2.12.0-rnd2' of git://github.com/git-l10n/git-po
448
449l10n-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
474l10n: zh_CN: for git v2.12.0 l10n round 2
475
476Translate 241 messages (3139t0f0u) for git v2.12.0-rc1.
477
478Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
479
480l10n: Update Catalan translation
481
482Signed-off-by: Jordi Mas <jmas@softcatala.org>
483
484l10n: pt_PT: update Portuguese tranlation
485
486Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
487
488git add -i: replace \t with blanks in the help message
489
490Within the help message of 'git add -i', the 'diff' command uses one
491tab character and blanks to create the space between the name and the
492description while the others use blanks only. So if the tab size is
493not at 4 characters, this description will not be in range.
494Replace the tab character with blanks.
495
496Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
497Signed-off-by: Junio C Hamano <gitster@pobox.com>
498
499Documentation: use brackets for optional arguments
500
501The documentation for git blame used vertical bars for optional
502arguments to -M and -C, which is unusual and potentially confusing.
503Since most man pages use brackets for optional items, and that's
504consistent with how we document the same options for git diff and
505friends, use brackets here, too.
506
507Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
508Signed-off-by: Junio C Hamano <gitster@pobox.com>
509
510Documentation: correctly spell git worktree --detach
511
512The option is “--detachâ€, but we accidentally spelled it “--detached†at
513one point in the man page.
514
515Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
516Reported-by: Casey Rodarmor <casey@rodarmor.com>
517Signed-off-by: Junio C Hamano <gitster@pobox.com>
518
519remote: ignore failure to remove missing branch.<name>.merge
520
521It is not all too unusual for a branch to use "branch.<name>.remote"
522without "branch.<name>.merge". You may be using the 'push.default'
523configuration set to 'current', for example, and do
524
525 $ git checkout -b side colleague/side
526 $ git config branch.side.remote colleague
527
528However, "git remote rm" to remove the remote used in such a manner
529fails with
530
531 "fatal: could not unset 'branch.<name>.merge'"
532
533because it assumes that a branch that has .remote defined must also
534have .merge defined. Detect the "cannot unset because it is not set
535to begin with" case and ignore it.
536
537Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
538Signed-off-by: Junio C Hamano <gitster@pobox.com>
539
540git-check-ref-format: clarify documentation for --normalize
541
542Use of 'iff' may be confusing to people not familiar with this term.
543
544Improving the --normalize option's documentation to remove the use of
545'iff', and clearly describe what happens when the condition is not met.
546
547Signed-off-by: Damien Regad <dregad@mantisbt.org>
548Signed-off-by: Junio C Hamano <gitster@pobox.com>
549
550Merge 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
555branch: record creation of renamed branch in HEAD's log
556
557Renaming the current branch adds an event to the current branch's log
558and to HEAD's log. However, the logged entries differ. The entry in
559the branch's log represents the entire renaming operation (the old and
560new hash are identical), whereas the entry in HEAD's log represents
561the deletion only (the new sha1 is null).
562
563Extend replace_each_worktree_head_symref(), whose only caller is
564branch_rename(), to take a reflog message argument. This allows the
565creation of the new ref to be recorded in HEAD's log. As a result,
566the renaming event is represented by two entries (a deletion and a
567creation entry) in HEAD's log.
568
569It's a bit unfortunate that the branch's log and HEAD's log now
570represent the renaming event in different ways. Given that the
571renaming operation is not atomic, the two-entry form is a more
572accurate representation of the operation and is more useful for
573debugging purposes if a failure occurs between the deletion and
574creation events. It would make sense to move the branch's log to the
575two-entry form, but this would involve changes to how the rename is
576carried out and to how the update flags and reflogs are processed for
577deletions, so it may not be worth the effort.
578
579Based-on-patch-by: Jeff King <peff@peff.net>
580Signed-off-by: Kyle Meyer <kyle@kyleam.com>
581Signed-off-by: Junio C Hamano <gitster@pobox.com>
582
583rename_ref: replace empty message in HEAD's log
584
585When the current branch is renamed, the deletion of the old ref is
586recorded in HEAD's log with an empty message. Now that delete_ref()
587accepts a reflog message, provide a more descriptive message by
588passing along the log message that is given to rename_ref().
589
590The next step will be to extend HEAD's log to also include the second
591part of the rename, the creation of the new branch.
592
593Helped-by: Jeff King <peff@peff.net>
594Signed-off-by: Kyle Meyer <kyle@kyleam.com>
595Signed-off-by: Junio C Hamano <gitster@pobox.com>
596
597update-ref: pass reflog message to delete_ref()
598
599Now that delete_ref() accepts a reflog message, pass the user-provided
600message to delete_ref() rather than silently dropping it.
601
602Signed-off-by: Kyle Meyer <kyle@kyleam.com>
603Signed-off-by: Junio C Hamano <gitster@pobox.com>
604
605delete_ref: accept a reflog message argument
606
607When the current branch is renamed with 'git branch -m/-M' or deleted
608with 'git update-ref -m<msg> -d', the event is recorded in HEAD's log
609with an empty message. In preparation for adding a more meaningful
610message to HEAD's log in these cases, update delete_ref() to take a
611message argument and pass it along to ref_transaction_delete().
612Modify all callers to pass NULL for the new message argument; no
613change in behavior is intended.
614
615Note that this is relevant for HEAD's log but not for the deleted
616ref's log, which is currently deleted along with the ref. Even if it
617were not, an entry for the deletion wouldn't be present in the deleted
618ref's log. files_transaction_commit() writes to the log if
619REF_NEEDS_COMMIT or REF_LOG_ONLY are set, but lock_ref_for_update()
620doesn't set REF_NEEDS_COMMIT for the deleted ref because REF_DELETING
621is set. In contrast, the update for HEAD has REF_LOG_ONLY set by
622split_head_update(), resulting in the deletion being logged.
623
624Signed-off-by: Kyle Meyer <kyle@kyleam.com>
625Signed-off-by: Junio C Hamano <gitster@pobox.com>
626
627Merge 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
632l10n: sv.po: Update Swedish translation (3139t0f0u)
633
634Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
635
636l10n: de.po: translate 241 messages
637
638Translate 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
642Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
643Acked-by: Phillip Sz <phillip.szelat@gmail.com>
644
645Merge 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
650Merge 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
655l10n: ko.po: Update Korean translation
656
657Signed-off-by: Changwoo Ryu <cwryu@debian.org>
658
659l10n: vi.po (3139t): Updated 2 new messages for rc1
660
661Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
662
663init: document dotfiles exclusion on template copy
664
665Not just . and .., but any path that begins with dot is not copied
666when copying the template directory to a new repository. You can
667customize the template directory, copying some dotfiles might make
668sense, but it's actually a good thing not to, because you would not
669want to have your git directory copied in every git directory that
670is created should you decide to put your template directory under
671version control, for example. Plus, it might be used as a feature
672by people who would want to exclude some files.
673
674Signed-off-by: Grégoire Paris <postmaster@greg0ire.fr>
675Signed-off-by: Junio C Hamano <gitster@pobox.com>
676
677l10n: fr.po: v2.12.0 round 2 3139t
678
679Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
680
681tempfile: set errno to a known value before calling ferror()
682
683In close_tempfile(), we return an error if ferror()
684indicated a previous failure, or if fclose() failed. In the
685latter case, errno is set and it is useful for callers to
686report it.
687
688However, if _only_ ferror() triggers, then the value of
689errno is based on whatever syscall happened to last fail,
690which may not be related to our filehandle at all. A caller
691cannot tell the difference between the two cases, and may
692use "die_errno()" or similar to report a nonsense errno value.
693
694One solution would be to actually pass back separate return
695values for the two cases, so a caller can write a more
696appropriate message for each case. But that makes the
697interface clunky.
698
699Instead, let's just set errno to the generic EIO in this case.
700That's not as descriptive as we'd like, but at least it's
701predictable. So it's better than the status quo in all cases
702but one: when the last syscall really did involve a failure
703on our filehandle, we'll be wiping that out. But that's a
704fragile thing for us to rely on.
705
706In any case, we'll let the errno result from fclose() take
707precedence over our value, as we know that's recent and
708accurate (and many I/O errors will persist through the
709fclose anyway).
710
711Signed-off-by: Jeff King <peff@peff.net>
712Signed-off-by: Junio C Hamano <gitster@pobox.com>
713
714Git 2.12-rc2
715
716Signed-off-by: Junio C Hamano <gitster@pobox.com>
717
718rev-parse: fix several options when running in a subdirectory
719
720In addition to making git_path() aware of certain file names that need
721to be handled differently e.g. when running in worktrees, the commit
722557bd833bb (git_path(): be aware of file relocation in $GIT_DIR,
7232014-11-30) also snuck in a new option for `git rev-parse`:
724`--git-path`.
725
726On the face of it, there is no obvious bug in that commit's diff: it
727faithfully calls git_path() on the argument and prints it out, i.e. `git
728rev-parse --git-path <filename>` has the same precise behavior as
729calling `git_path("<filename>")` in C.
730
731The problem lies deeper, much deeper. In hindsight (which is always
732unfair), implementing the .git/ directory discovery in
733`setup_git_directory()` by changing the working directory may have
734allowed us to avoid passing around a struct that contains information
735about the current repository, but it bought us many, many problems.
736
737In this case, when being called in a subdirectory, `git rev-parse`
738changes the working directory to the top-level directory before calling
739`git_path()`. In the new working directory, the result is correct. But
740in the working directory of the calling script, it is incorrect.
741
742Example: when calling `git rev-parse --git-path HEAD` in, say, the
743Documentation/ subdirectory of Git's own source code, the string
744`.git/HEAD` is printed.
745
746Side note: that bug is hidden when running in a subdirectory of a
747worktree that was added by the `git worktree` command: in that case, the
748(correct) absolute path of the `HEAD` file is printed.
749
750In the interest of time, this patch does not go the "correct" route to
751introduce a struct with repository information (and removing global
752state in the process), instead this patch chooses to detect when the
753command was called in a subdirectory and forces the result to be an
754absolute path.
755
756While at it, we are also fixing the output of --git-common-dir and
757--shared-index-path.
758
759Lastly, please note that we reuse the same strbuf for all of the
760relative_path() calls; this avoids frequent allocation (and duplicated
761code), and it does not risk memory leaks, for two reasons: 1) the
762cmd_rev_parse() function does not return anywhere between the use of
763the new strbuf instance and its final release, and 2) git-rev-parse is
764one of these "one-shot" programs in Git, i.e. it exits after running
765for a very short time, meaning that all allocated memory is released
766with the exit() call anyway.
767
768Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
769Signed-off-by: Junio C Hamano <gitster@pobox.com>
770
771rev-parse tests: add tests executed from a subdirectory
772
773t2027-worktree-list has an incorrect expectation for --git-common-dir
774which has been adjusted and marked to expect failure.
775
776Some of the tests added have been marked to expect failure. These
777demonstrate a problem with the way that some options to git rev-parse
778behave when executed from a subdirectory of the main worktree.
779
780[jes: fixed incorrect assumption that objects/ lives in the
781worktree-specific git-dir (it lives in the common dir instead). Also
782adjusted t1700 so that the test case does not *need* to be the last
783one in that script.]
784
785Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
786Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
787Signed-off-by: Junio C Hamano <gitster@pobox.com>
788
789l10n: git.pot: v2.12.0 round 2 (2 new)
790
791Generate po/git.pot from v2.12.0-rc1 for git v2.12.0 l10n round 2.
792
793Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
794
795Merge 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
812Merge 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
817Merge 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
822l10n: vi.po: Updated Vietnamese translation (3137t)
823
824Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
825
826Hopefully the final batch of mini-topics before the final
827
828Signed-off-by: Junio C Hamano <gitster@pobox.com>
829
830Merge branch 'jk/tempfile-ferror-fclose-confusion'
831
832Code clean-up.
833
834* jk/tempfile-ferror-fclose-confusion:
835 tempfile: avoid "ferror | fclose" trick
836
837Merge branch 'dp/submodule-doc-markup-fix'
838
839Doc fix.
840
841* dp/submodule-doc-markup-fix:
842 config.txt: fix formatting of submodule.alternateErrorStrategy section
843
844Merge branch 'jk/reset-to-break-a-commit-doc-updated'
845
846Doc 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
851Merge branch 'jk/reset-to-break-a-commit-doc'
852
853Doc 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
858Merge branch 'js/mingw-isatty'
859
860A hotfix for a topic already in 'master'.
861
862* js/mingw-isatty:
863 mingw: make stderr unbuffered again
864
865Merge branch 'rs/strbuf-cleanup-in-rmdir-recursively'
866
867Code clean-up.
868
869* rs/strbuf-cleanup-in-rmdir-recursively:
870 rm: reuse strbuf for all remove_dir_recursively() calls, again
871
872Merge branch 'rs/ls-files-partial-optim'
873
874"ls-files" run with pathspec has been micro-optimized to avoid
875having 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
881Merge branch 'rs/cocci-check-free-only-null'
882
883A new coccinelle rule that catches a check of !pointer before the
884pointer 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
889Merge branch 'ls/p4-path-encoding'
890
891When "git p4" imports changelist that removes paths, it failed to
892convert pathnames when the p4 used encoding different from the one
893used 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
898tempfile: avoid "ferror | fclose" trick
899
900The current code wants to record an error condition from
901either ferror() or fclose(), but makes sure that we always
902call both functions. So it can't use logical-OR "||", which
903would short-circuit when ferror() is true. Instead, it uses
904bitwise-OR "|" to evaluate both functions and set one or
905more bits in the "err" flag if they reported a failure.
906
907Unlike logical-OR, though, bitwise-OR does not introduce a
908sequence point, and the order of evaluation for its operands
909is unspecified. So a compiler would be free to generate code
910which calls fclose() first, and then ferror() on the
911now-freed filehandle.
912
913There's no indication that this has happened in practice,
914but let's write it out in a way that follows the standard.
915
916Noticed-by: Andreas Schwab <schwab@linux-m68k.org>
917Signed-off-by: Jeff King <peff@peff.net>
918Signed-off-by: Junio C Hamano <gitster@pobox.com>
919
920config.txt: fix formatting of submodule.alternateErrorStrategy section
921
922Add missing `::` after the title.
923
924Signed-off-by: David Pursehouse <dpursehouse@collab.net>
925Acked-by: Stefan Beller <sbeller@google.com>
926Signed-off-by: Junio C Hamano <gitster@pobox.com>
927
928clean: use warning_errno() when appropriate
929
930All these warning() calls are preceded by a system call. Report the
931actual error to help the user understand why we fail to remove
932something.
933
934Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
935Signed-off-by: Junio C Hamano <gitster@pobox.com>
936
937reset: add an example of how to split a commit into two
938
939It is often useful to break a commit into multiple parts that are more
940logical separations. This can be tricky to learn how to do without the
941brute-force method if re-writing code or commit messages from scratch.
942
943Add a section to the git-reset documentation which shows an example
944process for how to use git add -p and git commit -c HEAD@{1} to
945interactively break a commit apart and re-use the original commit
946message as a starting point when making the new commit message.
947
948Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
949Signed-off-by: Junio C Hamano <gitster@pobox.com>
950
951Revert "reset: add an example of how to split a commit into two"
952
953This reverts commit 7326451bedaa67d29afe02184b166e28d9393c91; a
954better rewrite will be queued separately.
955
956bisect_next_all: convert xsnprintf to xstrfmt
957
958Git can't run bisect between 2048+ commits if use russian
959translation, because the translated string is too long for the fixed
960buffer it uses (this can be reproduced "LANG=ru_RU.UTF8 git bisect
961start v4.9 v4.8" on linux sources).
962
963Use xstrfmt() to format the message string to sufficiently sized
964buffer instead to fix this.
965
966Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
967Signed-off-by: Junio C Hamano <gitster@pobox.com>
968
969stop_progress_msg: convert xsnprintf to xstrfmt
970
971Simplify code by replacing buffer allocation with a call to xstrfmt().
972
973Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
974Signed-off-by: Junio C Hamano <gitster@pobox.com>
975
976l10n: update Catalan translation
977
978Signed-off-by: Jordi Mas <jmas@softcatala.org>
979
980A bit more for -rc2
981
982Merge branch 'tg/stash-doc-cleanup'
983
984The documentation explained what "git stash" does to the working
985tree (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
991Merge branch 'jk/doc-submodule-markup-fix'
992
993Doc markup fix.
994
995* jk/doc-submodule-markup-fix:
996 docs/git-submodule: fix unbalanced quote
997
998Merge branch 'jk/doc-remote-helpers-markup-fix'
999
1000Doc markup fix.
1001
1002* jk/doc-remote-helpers-markup-fix:
1003 docs/gitremote-helpers: fix unbalanced quotes
1004
1005show-branch: use skip_prefix to drop magic numbers
1006
1007We make several starts_with() calls, only to advance
1008pointers. This is exactly what skip_prefix() is for, which
1009lets us avoid manually-counted magic numbers.
1010
1011Helped-by: Pranit Bauva <pranit.bauva@gmail.com>
1012Signed-off-by: Jeff King <peff@peff.net>
1013Signed-off-by: Junio C Hamano <gitster@pobox.com>
1014
1015Merge branch 'sb/doc-unify-bottom'
1016
1017Doc clean-up.
1018
1019* sb/doc-unify-bottom:
1020 Documentation: unify bottom "part of git suite" lines
1021
1022Merge branch 'sb/push-options-via-transport'
1023
1024The push-options given via the "--push-options" option were not
1025passed through to external remote helpers such as "smart HTTP" that
1026are invoked via the transport helper.
1027
1028* sb/push-options-via-transport:
1029 push options: pass push options to the transport helper
1030
1031Merge branch 'cw/completion'
1032
1033More 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
1044Merge branch 'rs/swap'
1045
1046Code 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
1055Merge branch 'sb/submodule-doc'
1056
1057Doc updates.
1058
1059* sb/submodule-doc:
1060 submodule update documentation: don't repeat ourselves
1061 submodule documentation: add options to the subcommand
1062
1063grep: treat revs the same for --untracked as for --no-index
1064
1065git-grep has always disallowed grepping in a tree (as
1066opposed to the working directory) with both --untracked
1067and --no-index. But we traditionally did so by first
1068collecting the revs, and then complaining when any were
1069provided.
1070
1071The --no-index option recently learned to detect revs
1072much 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
1082The rationale for doing this with --no-index is that it is
1083meant to be used outside a repository, and so parsing revs
1084at all does not make sense.
1085
1086This patch gives --untracked the same treatment. While it
1087_is_ meant to be used in a repository, it is explicitly
1088about grepping the non-repository contents. Telling the user
1089"we found a rev, but you are not allowed to use revs" is
1090not really helpful compared to "we treated your argument as
1091a path, and could not find it".
1092
1093Signed-off-by: Jeff King <peff@peff.net>
1094Signed-off-by: Junio C Hamano <gitster@pobox.com>
1095
1096remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR
1097
1098To push from or fetch to the current repository, remote helpers need
1099to know what repository that is. Accordingly, Git sets the GIT_DIR
1100environment variable to the path to the current repository when
1101invoking remote helpers.
1102
1103There is a special case it does not handle: "git ls-remote" and "git
1104archive --remote" can be run to inspect a remote repository without
1105being run from any local repository. GIT_DIR is not useful in this
1106scenario:
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
1120So leave GIT_DIR unset in this case. This makes GIT_DIR easier to
1121understand for remote helper authors and makes transport code less of
1122a special case for repository discovery.
1123
1124Noticed 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
1131Helped-by: Jeff King <peff@peff.net>
1132Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
1133Signed-off-by: Jeff King <peff@peff.net>
1134Signed-off-by: Junio C Hamano <gitster@pobox.com>
1135
1136remote: avoid reading $GIT_DIR config in non-repo
1137
1138The "git ls-remote" command can be run outside of a
1139repository, but needs to look up configured remotes. The
1140config code is smart enough to handle this case itself, but
1141we also check the historical "branches" and "remotes" paths
1142in $GIT_DIR. The git_path() function causes us to blindly
1143look at ".git/remotes", even if we know we aren't in a git
1144repository.
1145
1146For now, this is just an unlikely bug (you probably don't
1147have such a file if you're not in a repository), but it will
1148become more obvious once we merge b1ef400ee (setup_git_env:
1149avoid 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
1159We can fix this by skipping these sources entirely when
1160we're outside of a repository.
1161
1162The test is a little more complex than the demonstration
1163above. Rather than detect the correct behavior by parsing
1164the error message, we can actually set up a case where the
1165remote name we give is a valid repository, but b1ef400ee
1166would cause us to die in the configuration step.
1167
1168This test doesn't fail now, but it future-proofs us for the
1169b1ef400ee change.
1170
1171Signed-off-by: Jeff King <peff@peff.net>
1172Signed-off-by: Junio C Hamano <gitster@pobox.com>
1173
1174show-branch: store resolved head in heap buffer
1175
1176We resolve HEAD and copy the result to a fixed-size buffer
1177with memcpy, never checking that it actually fits. This bug
1178dates back to 8098a178b (Add git-symbolic-ref, 2005-09-30).
1179Before that we used readlink(), which took a maximum buffer
1180size.
1181
1182We can fix this by using resolve_refdup(), which duplicates
1183the buffer on the heap. That also lets us just check
1184for a NULL pointer to see if we have resolved HEAD, and
1185drop the extra head_p variable.
1186
1187Signed-off-by: Jeff King <peff@peff.net>
1188Signed-off-by: Junio C Hamano <gitster@pobox.com>
1189
1190show-branch: drop head_len variable
1191
1192We copy the result of resolving HEAD into a buffer and keep
1193track of its length. But we never actually use the length
1194for anything besides the copy. Let's stop passing it around.
1195
1196Signed-off-by: Jeff King <peff@peff.net>
1197Signed-off-by: Junio C Hamano <gitster@pobox.com>
1198
1199grep: do not diagnose misspelt revs with --no-index
1200
1201If we are using --no-index, then our arguments cannot be
1202revs in the first place. Not only is it pointless to
1203diagnose them, but if we are not in a repository, we should
1204not be trying to resolve any names.
1205
1206Signed-off-by: Jeff King <peff@peff.net>
1207Signed-off-by: Junio C Hamano <gitster@pobox.com>
1208
1209grep: avoid resolving revision names in --no-index case
1210
1211We disallow the use of revisions with --no-index, but we
1212don't actually check and complain until well after we've
1213parsed the revisions.
1214
1215This 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
1236This patch skips the get_sha1() call entirely in the
1237no-index case, and behaves as if it failed (with the
1238exception of giving a better error message).
1239
1240Signed-off-by: Jeff King <peff@peff.net>
1241Signed-off-by: Junio C Hamano <gitster@pobox.com>
1242
1243grep: fix "--" rev/pathspec disambiguation
1244
1245If we see "git grep pattern rev -- file" then we apply the
1246usual rev/pathspec disambiguation rules: any "rev" before
1247the "--" must be a revision, and we do not need to apply the
1248verify_non_filename() check.
1249
1250But 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
1273This patch fixes both bugs, and tries to comment the parsing
1274flow a bit better.
1275
1276It adds tests that cover the two bugs, but also some related
1277situations (which already worked, but this confirms that our
1278fixes did not break anything).
1279
1280Signed-off-by: Jeff King <peff@peff.net>
1281Signed-off-by: Junio C Hamano <gitster@pobox.com>
1282
1283grep: re-order rev-parsing loop
1284
1285We loop over the arguments, but every branch of the loop
1286hits either a "continue" or a "break". Surely we can make
1287this simpler.
1288
1289The final conditional is:
1290
1291 if (arg is a rev) {
1292 ... handle rev ...
1293 continue;
1294 }
1295 break;
1296
1297We can rewrite this as:
1298
1299 if (arg is not a rev)
1300 break;
1301
1302 ... handle rev ...
1303
1304That makes the flow a little bit simpler, and will make
1305things much easier to follow when we add more logic in
1306future patches.
1307
1308Signed-off-by: Jeff King <peff@peff.net>
1309Signed-off-by: Junio C Hamano <gitster@pobox.com>
1310
1311grep: do not unnecessarily query repo for "--"
1312
1313When running a command of the form
1314
1315 git grep --no-index pattern -- path
1316
1317in the absence of a Git repository, an error message will be printed:
1318
1319 fatal: BUG: setup_git_env called without repository
1320
1321This is because "git grep" tries to interpret "--" as a rev. "git grep"
1322has always tried to first interpret "--" as a rev for at least a few
1323years, but this issue was upgraded from a pessimization to a bug in
1324commit 59332d1 ("Resurrect "git grep --no-index"", 2010-02-06), which
1325calls get_sha1 regardless of whether --no-index was specified. This bug
1326appeared to be benign until commit b1ef400 ("setup_git_env: avoid blind
1327fall-back to ".git"", 2016-10-20) when Git was taught to die in this
1328situation. (This "git grep" bug appears to be one of the bugs that
1329commit b1ef400 is meant to flush out.)
1330
1331Therefore, always interpret "--" as signaling the end of options,
1332instead of trying to interpret it as a rev first.
1333
1334Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
1335Signed-off-by: Jeff King <peff@peff.net>
1336Signed-off-by: Junio C Hamano <gitster@pobox.com>
1337
1338grep: move thread initialization a little lower
1339
1340Originally, we set up the threads for grep before parsing
1341the non-option arguments. In 53b8d931b (grep: disable
1342threading in non-worktree case, 2011-12-12), the thread code
1343got bumped lower in the function because it now needed to
1344know whether we got any revision arguments.
1345
1346That put a big block of code in between the parsing of revs
1347and the parsing of pathspecs, both of which share some loop
1348variables. That makes it harder to read the code than the
1349original, where the shared loops were right next to each
1350other.
1351
1352Let's bump the thread initialization until after all of the
1353parsing is done.
1354
1355Signed-off-by: Jeff King <peff@peff.net>
1356Signed-off-by: Junio C Hamano <gitster@pobox.com>
1357
1358mingw: make stderr unbuffered again
1359
1360When removing the hack for isatty(), we actually removed more than just
1361an isatty() hack: we removed the hack where internal data structures of
1362the MSVC runtime are modified in order to redirect stdout/stderr.
1363
1364Instead of using that hack (that does not work with newer versions of
1365the runtime, anyway), we replaced it by reopening the respective file
1366descriptors.
1367
1368What we forgot was to mark stderr as unbuffered again.
1369
1370Reported by Hannes Sixt. Fixed with Jeff Hostetler's assistance.
1371
1372Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1373Tested-by: Johannes Sixt <j6t@kdbg.org>
1374Signed-off-by: Junio C Hamano <gitster@pobox.com>
1375
1376gc: ignore old gc.log files
1377
1378A server can end up in a state where there are lots of unreferenced
1379loose objects (say, because many users are doing a bunch of rebasing
1380and pushing their rebased branches). Running "git gc --auto" in
1381this state would cause a gc.log file to be created, preventing
1382future auto gcs, causing pack files to pile up. Since many git
1383operations are O(n) in the number of pack files, this would lead to
1384poor performance.
1385
1386Git should never get itself into a state where it refuses to do any
1387maintenance, just because at some point some piece of the maintenance
1388didn't make progress.
1389
1390Teach Git to ignore gc.log files which are older than (by default)
1391one day old, which can be tweaked via the gc.logExpiry configuration
1392variable. That way, these pack files will get cleaned up, if
1393necessary, at least once per day. And operators who find a need for
1394more-frequent gcs can adjust gc.logExpiry to meet their needs.
1395
1396There is also some cleanup: a successful manual gc, or a
1397warning-free auto gc with an old log file, will remove any old
1398gc.log files.
1399
1400It might still happen that manual intervention is required
1401(e.g. because the repo is corrupt), but at the very least it won't
1402be because Git is too dumb to try again.
1403
1404Signed-off-by: David Turner <dturner@twosigma.com>
1405Helped-by: Jeff King <peff@peff.net>
1406Signed-off-by: Junio C Hamano <gitster@pobox.com>
1407
1408read_loose_refs(): read refs using resolve_ref_recursively()
1409
1410There is no need to call read_ref_full() or resolve_gitlink_ref() from
1411read_loose_refs(), because we already have a ref_store object in hand.
1412So we can call resolve_ref_recursively() ourselves. Happily, this
1413unifies the code for the submodule vs. non-submodule cases.
1414
1415This requires resolve_ref_recursively() to be exposed to the refs
1416subsystem, though not to non-refs code.
1417
1418Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1419Reviewed-by: Jeff King <peff@peff.net>
1420Signed-off-by: Junio C Hamano <gitster@pobox.com>
1421
1422rm: reuse strbuf for all remove_dir_recursively() calls, again
1423
1424Don't throw the memory allocated for remove_dir_recursively() away after
1425a single call, use it for the other entries as well instead.
1426
1427This change was done before in deb8e15a (rm: reuse strbuf for all
1428remove_dir_recursively() calls), but was reverted as a side-effect of
142955856a35 (rm: absorb a submodules git dir before deletion). Reinstate
1430the optimization.
1431
1432Signed-off-by: Rene Scharfe <l.s.r@web.de>
1433Signed-off-by: Junio C Hamano <gitster@pobox.com>
1434
1435Documentation/stash: remove mention of git reset --hard
1436
1437Don't mention git reset --hard in the documentation for git stash save.
1438It's an implementation detail that doesn't matter to the end user and
1439thus shouldn't be exposed to them. In addition it's not quite true for
1440git stash -p, and will not be true when a filename argument to limit the
1441stash to a few files is introduced.
1442
1443Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
1444Signed-off-by: Junio C Hamano <gitster@pobox.com>
1445
1446docs/git-submodule: fix unbalanced quote
1447
1448The documentation gives an example of the submodule foreach
1449command that uses both backticks and single-quotes. We stick
1450the whole thing inside "+" markers to make it monospace, but
1451the inside punctuation still needs escaping. We handle the
1452backticks with "{backtick}", and use backslash-escaping for
1453the single-quotes.
1454
1455But we missed the escaping on the second quote. Fortunately,
1456asciidoc renders this unbalanced quote as we want (showing
1457the quote), but asciidoctor does not. We could fix it by
1458adding the missing backslash.
1459
1460However, let's take a step back. Even when rendered
1461correctly, it's hard to read a long command stuck into the
1462middle of a paragraph, and the important punctuation is hard
1463to notice. Let's instead bump it into its own single-line
1464code block. That makes both the source and the rendered
1465result more readable, and as a bonus we don't have to worry
1466about quoting at all.
1467
1468Signed-off-by: Jeff King <peff@peff.net>
1469Signed-off-by: Junio C Hamano <gitster@pobox.com>
1470
1471docs/gitremote-helpers: fix unbalanced quotes
1472
1473Each of these options is missing the closing single-quote on
1474the option name. This understandably confuses asciidoc,
1475which ends up rendering a stray quote, like:
1476
1477 option cloning {'true|false}
1478
1479Signed-off-by: Jeff King <peff@peff.net>
1480Signed-off-by: Junio C Hamano <gitster@pobox.com>
1481
1482completion: restore removed line continuating backslash
1483
1484Recent commit 1cd23e9e0 (completion: don't use __gitdir() for git
1485commands, 2017-02-03) rewrapped a couple of long lines, and while
1486doing so it inadvertently removed a '\' from the end of a line, thus
1487breaking completion for 'git config remote.name.push <TAB>'.
1488
1489Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
1490Signed-off-by: Junio C Hamano <gitster@pobox.com>
1491
1492ls-files: move only kept cache entries in prune_cache()
1493
1494prune_cache() first identifies those entries at the start of the sorted
1495array that can be discarded. Then it moves the rest of the entries up.
1496Last it identifies the unwanted trailing entries among the moved ones
1497and cuts them off.
1498
1499Change the order: Identify both start *and* end of the range to keep
1500first and then move only those entries to the top. The resulting code
1501is slightly shorter and a bit more efficient.
1502
1503Signed-off-by: Rene Scharfe <l.s.r@web.de>
1504Reviewed-by: Brandon Williams <bmwill@google.com>
1505Signed-off-by: Junio C Hamano <gitster@pobox.com>
1506
1507ls-files: pass prefix length explicitly to prune_cache()
1508
1509The function prune_cache() relies on the fact that it is only called on
1510max_prefix and sneakily uses the matching global variable max_prefix_len
1511directly. Tighten its interface by passing both the string and its
1512length as parameters. While at it move the NULL check into the function
1513to collect all cache-pruning related logic in one place.
1514
1515Signed-off-by: Rene Scharfe <l.s.r@web.de>
1516Reviewed-by: Brandon Williams <bmwill@google.com>
1517Signed-off-by: Junio C Hamano <gitster@pobox.com>
1518
1519Merge 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
1524Merge 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
1532cocci: detect useless free(3) calls
1533
1534Add a semantic patch for removing checks that cause free(3) to only be
1535called with a NULL pointer, as that must be a programming mistake.
1536
1537Signed-off-by: Rene Scharfe <l.s.r@web.de>
1538Signed-off-by: Junio C Hamano <gitster@pobox.com>
1539
1540l10n: sv.po: Update Swedish translation (3137t0f0u)
1541
1542Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
1543
1544l10n: fr.po: v2.11-rc0 first round
1545
1546Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
1547
1548l10n: ko.po: Update Korean translation
1549
1550Signed-off-by: Changwoo Ryu <cwryu@debian.org>
1551
1552preload-index: avoid lstat for skip-worktree items
1553
1554Teach preload-index to avoid lstat() calls for index-entries
1555with skip-worktree bit set. This is a performance optimization.
1556
1557During a sparse-checkout, the skip-worktree bit is set on items
1558that were not populated and therefore are not present in the
1559worktree. The per-thread preload-index loop performs a series
1560of tests on each index-entry as it attempts to compare the
1561worktree version with the index and mark them up-to-date.
1562This patch short-cuts that work.
1563
1564On a Windows 10 system with a very large repo (450MB index)
1565and various levels of sparseness, performance was improved
1566in the {preloadindex=true, fscache=false} case by 80% and
1567in the {preloadindex=true, fscache=true} case by 20% for various
1568commands.
1569
1570Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
1571Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1572Signed-off-by: Junio C Hamano <gitster@pobox.com>
1573
1574git-p4: fix git-p4.pathEncoding for removed files
1575
1576In a9e38359e3 we taught git-p4 a way to re-encode path names from what
1577was used in Perforce to UTF-8. This path re-encoding worked properly for
1578"added" paths. "Removed" paths were not re-encoded and therefore
1579different from the "added" paths. Consequently, these files were not
1580removed in a git-p4 cloned Git repository because the path names did not
1581match.
1582
1583Fix this by moving the re-encoding to a place that affects "added" and
1584"removed" paths. Add a test to demonstrate the issue.
1585
1586Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
1587Reviewed-by: Luke Diamand <luke@diamand.org>
1588Signed-off-by: Junio C Hamano <gitster@pobox.com>
1589
1590connect.c: stop conflating ssh command names and overrides
1591
1592dd33e07766 ("connect: Add the envvar GIT_SSH_VARIANT and ssh.variant
1593config", 2017-02-01) attempted to add support for configuration and
1594environment variable to override the different handling of
1595port_option and needs_batch settings suitable for variants of the
1596ssh implementation that was autodetected by looking at the ssh
1597command name. Because it piggybacked on the code that turns command
1598name to specific override (e.g. "plink.exe" and "plink" means
1599port_option needs to be set to 'P' instead of the default 'p'), yet
1600it defined a separate namespace for these overrides (e.g. "putty"
1601can be usable to signal that port_option needs to be 'P'), however,
1602it 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
1604the same override).
1605
1606Separate the code that interprets the override that was read from
1607the configuration & environment from the original code that handles
1608the command names, as they are in separate namespaces, to fix this
1609confusion.
1610
1611This incidentally also makes it easier for future enhancement of the
1612override syntax (e.g. "port_option=p,needs_batch=1" may want to be
1613accepted as a more explicit syntax) without affecting the code for
1614auto-detection based on the command name.
1615
1616While at it, update the return type of the handle_ssh_variant()
1617helper function to void; the caller does not use it, and the
1618function does not return any meaningful value.
1619
1620Signed-off-by: Junio C Hamano <gitster@pobox.com>
1621
1622pathspec: don't error out on all-exclusionary pathspec patterns
1623
1624Instead of erroring out and telling the user that they should add a
1625positive pattern that covers everything else, just _do_ that.
1626
1627For commands where we honor the current cwd by default (ie grep, ls-files
1628etc), we make that default positive pathspec be the current working
1629directory. And for commands that default to the whole project (ie diff,
1630log, etc), the default positive pathspec is the whole project.
1631
1632Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1633Signed-off-by: Junio C Hamano <gitster@pobox.com>
1634
1635pathspec magic: add '^' as alias for '!'
1636
1637The choice of '!' for a negative pathspec ends up not only not matching
1638what we do for revisions, it's also a horrible character for shell
1639expansion since it needs quoting.
1640
1641So add '^' as an alternative alias for an excluding pathspec entry.
1642
1643Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1644Signed-off-by: Junio C Hamano <gitster@pobox.com>
1645
1646Git 2.12-rc1
1647
1648Signed-off-by: Junio C Hamano <gitster@pobox.com>
1649
1650Merge branch 'nd/rev-list-all-includes-HEAD-doc'
1651
1652Doc update.
1653
1654* nd/rev-list-all-includes-HEAD-doc:
1655 rev-list-options.txt: update --all about HEAD
1656
1657Merge branch 'rs/fill-directory-optim'
1658
1659Code clean-up.
1660
1661* rs/fill-directory-optim:
1662 dir: avoid allocation in fill_directory()
1663
1664Merge branch 'jk/log-graph-name-only'
1665
1666"git log --graph" did not work well with "--name-only", even though
1667other forms of "diff" output were handled correctly.
1668
1669* jk/log-graph-name-only:
1670 diff: print line prefix for --name-only output
1671
1672Merge branch 'da/t7800-cleanup'
1673
1674Test updates.
1675
1676* da/t7800-cleanup:
1677 t7800: replace "wc -l" with test_line_count
1678
1679Merge branch 'dl/difftool-doc-no-gui-option'
1680
1681Doc update.
1682
1683* dl/difftool-doc-no-gui-option:
1684 Document the --no-gui option in difftool
1685
1686Merge branch 'js/difftool-builtin'
1687
1688A 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
1694Merge branch 'rs/p5302-create-repositories-before-tests'
1695
1696Adjust a perf test to new world order where commands that do
1697require 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
1702Merge branch 'ps/worktree-prune-help-fix'
1703
1704Incorrect 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
1709Merge branch 'ew/complete-svn-authorship-options'
1710
1711Correct command line completion (in contrib/) on "git svn"
1712
1713* ew/complete-svn-authorship-options:
1714 completion: fix git svn authorship switches
1715
1716Merge branch 'jk/reset-to-break-a-commit-doc'
1717
1718A 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
1723Merge branch 'bw/push-submodule-only'
1724
1725Add 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
1731files_ref_store::submodule: use NULL for the main repository
1732
1733The old practice of storing the empty string in this member for the main
1734repository 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
1736stored in a flex array at the end of `struct files_ref_store`. Storing
1737NULL for this case is more idiomatic and a tiny bit less code.
1738
1739Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1740Reviewed-by: Jeff King <peff@peff.net>
1741Signed-off-by: Junio C Hamano <gitster@pobox.com>
1742
1743base_ref_store_init(): remove submodule argument
1744
1745This is another step towards weakening the 1:1 relationship between
1746ref_stores and submodules.
1747
1748Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1749Reviewed-by: Jeff King <peff@peff.net>
1750Signed-off-by: Junio C Hamano <gitster@pobox.com>
1751
1752refs: push the submodule attribute down
1753
1754Push the submodule attribute down from ref_store to files_ref_store.
1755This is another step towards loosening the 1:1 connection between
1756ref_stores and submodules.
1757
1758Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1759Reviewed-by: Jeff King <peff@peff.net>
1760Signed-off-by: Junio C Hamano <gitster@pobox.com>
1761
1762refs: store submodule ref stores in a hashmap
1763
1764Aside from scaling better, this means that the submodule name needn't be
1765stored in the ref_store instance anymore (which will be changed in a
1766moment). This, in turn, will help loosen the strict 1:1 relationship
1767between ref_stores and submodules.
1768
1769Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1770Reviewed-by: Jeff King <peff@peff.net>
1771Signed-off-by: Junio C Hamano <gitster@pobox.com>
1772
1773register_ref_store(): new function
1774
1775Move the responsibility for registering the ref_store for a submodule
1776from base_ref_store_init() to a new function, register_ref_store(). Call
1777the latter from ref_store_init().
1778
1779Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1780Reviewed-by: Jeff King <peff@peff.net>
1781Signed-off-by: Junio C Hamano <gitster@pobox.com>
1782
1783refs: remove some unnecessary handling of submodule == ""
1784
1785The only external entry point to the ref_store lookup functions is
1786get_ref_store(), which ensures that submodule == "" is passed along as
1787NULL. So ref_store_init() and lookup_ref_store() don't have to handle
1788submodule being specified as the empty string.
1789
1790Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1791Reviewed-by: Jeff King <peff@peff.net>
1792Signed-off-by: Junio C Hamano <gitster@pobox.com>
1793
1794refs: make some ref_store lookup functions private
1795
1796The following functions currently don't need to be exposed:
1797
1798* ref_store_init()
1799* lookup_ref_store()
1800
1801That might change in the future, but for now make them private.
1802
1803Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1804Reviewed-by: Jeff King <peff@peff.net>
1805Signed-off-by: Junio C Hamano <gitster@pobox.com>
1806
1807refs: reorder some function definitions
1808
1809This avoids the need to add forward declarations in the next step.
1810
1811Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
1812Reviewed-by: Jeff King <peff@peff.net>
1813Signed-off-by: Junio C Hamano <gitster@pobox.com>
1814
1815Documentation: unify bottom "part of git suite" lines
1816
1817We currently have 168 man pages that mention they are part of Git, you
1818can check yourself easily via:
1819 $ git grep "Part of the linkgit:git\[1\] suite" |wc -l
1820 168
1821However some have a trailing period, i.e.
1822 $ git grep "Part of the linkgit:git\[1\] suite." |wc -l
1823 8
1824
1825Unify the bottom line in all man pages to not end with a period.
1826
1827Signed-off-by: Stefan Beller <sbeller@google.com>
1828Signed-off-by: Junio C Hamano <gitster@pobox.com>
1829
1830rebase -i: use the rebase--helper builtin
1831
1832Now that the sequencer learned to process a "normal" interactive rebase,
1833we use it. The original shell script is still used for "non-normal"
1834interactive rebases, i.e. when --root or --preserve-merges was passed.
1835
1836Please note that the --root option (via the $squash_onto variable) needs
1837special handling only for the very first command, hence it is still okay
1838to use the helper upon continue/skip.
1839
1840Also please note that the --no-ff setting is volatile, i.e. when the
1841interactive rebase is interrupted at any stage, there is no record of
1842it. Therefore, we have to pass it from the shell script to the
1843rebase--helper.
1844
1845Note: the test t3404 had to be adjusted because the the error messages
1846produced by the sequencer comply with our current convention to start with
1847a lower-case letter.
1848
1849Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1850Signed-off-by: Junio C Hamano <gitster@pobox.com>
1851
1852rebase--helper: add a builtin helper for interactive rebases
1853
1854Git's interactive rebase is still implemented as a shell script, despite
1855its complexity. This implies that it suffers from the portability point
1856of view, from lack of expressibility, and of course also from
1857performance. The latter issue is particularly serious on Windows, where
1858we pay a hefty price for relying so much on POSIX.
1859
1860Unfortunately, being such a huge shell script also means that we missed
1861the train when it would have been relatively easy to port it to C, and
1862instead piled feature upon feature onto that poor script that originally
1863never intended to be more than a slightly pimped cherry-pick in a loop.
1864
1865To open the road toward better performance (in addition to all the other
1866benefits of C over shell scripts), let's just start *somewhere*.
1867
1868The approach taken here is to add a builtin helper that at first intends
1869to take care of the parts of the interactive rebase that are most
1870affected by the performance penalties mentioned above.
1871
1872In particular, after we spent all those efforts on preparing the sequencer
1873to process rebase -i's git-rebase-todo scripts, we implement the `git
1874rebase -i --continue` functionality as a new builtin, git-rebase--helper.
1875
1876Once that is in place, we can work gradually on tackling the rest of the
1877technical debt.
1878
1879Note that the rebase--helper needs to learn about the transient
1880--ff/--no-ff options of git-rebase, as the corresponding flag is not
1881persisted to, and re-read from, the state directory.
1882
1883Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1884Signed-off-by: Junio C Hamano <gitster@pobox.com>
1885
1886push options: pass push options to the transport helper
1887
1888When using non-builtin protocols relying on a transport helper
1889(such as http), push options are not propagated to the helper.
1890
1891The user could ask for push options and a push would seemingly succeed,
1892but the push options would never be transported to the server,
1893misleading the users expectation.
1894
1895Fix this by propagating the push options to the transport helper.
1896
1897This 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
1901Once we fix (2), the http transport helper can make use of push options
1902as well, but that happens as a follow up. (1) is a bug fix, whereas (2)
1903is a feature, which is why we only do (1) here.
1904
1905Signed-off-by: Stefan Beller <sbeller@google.com>
1906Signed-off-by: Junio C Hamano <gitster@pobox.com>
1907
1908tag: generate useful reflog message
1909
1910When tags are created with `--create-reflog` or with the option
1911`core.logAllRefUpdates` set to 'always', a reflog is created for them.
1912So far, the description of reflog entries for tags was empty, making the
1913reflog hard to understand. For example:
19146e3a7b3 refs/tags/test@{0}:
1915
1916Now, a reflog message is generated when creating a tag, following the
1917pattern "tag: tagging <short-sha1> (<description>)". If
1918GIT_REFLOG_ACTION is set, the message becomes "$GIT_REFLOG_ACTION
1919(<description>)" instead. If the tag references a commit object, the
1920description is set to the subject line of the commit, followed by its
1921commit date. For example:
19226e3a7b3 refs/tags/test@{0}: tag: tagging 6e3a7b3398 (Git 2.12-rc0, 2017-02-03)
1923
1924If the tag points to a tree/blob/tag objects, the following static
1925strings are taken as description:
1926
1927 - "tree object"
1928 - "blob object"
1929 - "other tag object"
1930
1931Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
1932Signed-off-by: Junio C Hamano <gitster@pobox.com>
1933
1934receive-pack: avoid duplicates between our refs and alternates
1935
1936We de-duplicate ".have" refs among themselves, but never
1937check if they are duplicates of our local refs. It's not
1938unreasonable that they would be if we are a "--shared" or
1939"--reference" clone of a similar repository; we'd have all
1940the same tags.
1941
1942We can handle this by inserting our local refs into the
1943oidset, but obviously not suppressing duplicates (since the
1944refnames are important).
1945
1946Note that this also switches the order in which we advertise
1947refs, processing ours first and then any alternates. The
1948order shouldn't matter (and arguably showing our refs first
1949makes more sense).
1950
1951Signed-off-by: Jeff King <peff@peff.net>
1952Signed-off-by: Junio C Hamano <gitster@pobox.com>
1953
1954receive-pack: treat namespace .have lines like alternates
1955
1956Namely, de-duplicate them. We use the same set as the
1957alternates, since we call them both ".have" (i.e., there is
1958no value in showing one versus the other).
1959
1960Signed-off-by: Jeff King <peff@peff.net>
1961Signed-off-by: Junio C Hamano <gitster@pobox.com>
1962
1963receive-pack: fix misleading namespace/.have comment
1964
1965The comment claims that we handle alternate ".have" lines
1966through this function, but that hasn't been the case since
196785f251045 (write_head_info(): handle "extra refs" locally,
19682012-01-06).
1969
1970Signed-off-by: Jeff King <peff@peff.net>
1971Signed-off-by: Junio C Hamano <gitster@pobox.com>
1972
1973receive-pack: use oidset to de-duplicate .have lines
1974
1975If you have an alternate object store with a very large
1976number of refs, the peak memory usage of the sha1_array can
1977grow high, even if most of them are duplicates that end up
1978not being printed at all.
1979
1980The similar for_each_alternate_ref() code-paths in
1981fetch-pack solve this by using flags in "struct object" to
1982de-duplicate (and so are relying on obj_hash at the core).
1983
1984But we don't have a "struct object" at all in this case. We
1985could call lookup_unknown_object() to get one, but if our
1986goal 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
1996So let's use an oidset. Note that unlike a sha1-array it
1997doesn't sort the output as a side effect. However, our
1998output is at least stable, because for_each_alternate_ref()
1999will give us the sha1s in ref-sorted order.
2000
2001In one particularly pathological case with an alternate that
2002has 60,000 unique refs out of 80 million total, this reduced
2003the peak heap usage of "git receive-pack . </dev/null" from
200413GB to 14MB.
2005
2006Signed-off-by: Jeff King <peff@peff.net>
2007Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008
2009add oidset API
2010
2011This is similar to many of our uses of sha1-array, but it
2012overcomes one limitation of a sha1-array: when you are
2013de-duplicating a large input with relatively few unique
2014entries, sha1-array uses 20 bytes per non-unique entry.
2015Whereas this set will use memory linear in the number of
2016unique entries (albeit a few more than 20 bytes due to
2017hashmap overhead).
2018
2019Signed-off-by: Jeff King <peff@peff.net>
2020Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021
2022fetch-pack: cache results of for_each_alternate_ref
2023
2024We may run for_each_alternate_ref() twice, once in
2025find_common() and once in everything_local(). This operation
2026can be expensive, because it involves running a sub-process
2027which must freshly load all of the alternate's refs from
2028disk.
2029
2030Let's cache and reuse the results between the two calls. We
2031can make some optimizations based on the particular use
2032pattern in fetch-pack to keep our memory usage down.
2033
2034The first is that we only care about the sha1s, not the refs
2035themselves. So it's OK to store only the sha1s, and to
2036suppress duplicates. The natural fit would therefore be a
2037sha1_array.
2038
2039However, sha1_array's de-duplication happens only after it
2040has read and sorted all entries. It still stores each
2041duplicate. For an alternate with a large number of refs
2042pointing to the same commits, this is a needless expense.
2043
2044Instead, we'd prefer to eliminate duplicates before putting
2045them in the cache, which implies using a hash. We can
2046further note that fetch-pack will call parse_object() on
2047each alternate sha1. We can therefore keep our cache as a
2048set of pointers to "struct object". That gives us a place to
2049put our "already seen" bit with an optimized hash lookup.
2050And as a bonus, the object stores the sha1 for us, so
2051pointer-to-object is all we need.
2052
2053There 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
2076Signed-off-by: Jeff King <peff@peff.net>
2077Signed-off-by: Junio C Hamano <gitster@pobox.com>
2078
2079for_each_alternate_ref: replace transport code with for-each-ref
2080
2081The current method for getting the refs from an alternate is
2082to run upload-pack in the alternate and parse its output
2083using the normal transport code. This works and is
2084reasonably short, but it has a very bad memory footprint
2085when there are a lot of refs in the alternate. There are two
2086problems:
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
2102On a particularly pathological case, where the alternate had
2103over 80 million refs pointing to only around 60,000 unique
2104objects, the peak heap usage of "git clone --reference" grew
2105to over 25GB.
2106
2107This patch instead calls git-for-each-ref in the alternate
2108repository, and passes each line to the callback as we read
2109it. That drops the peak heap of the same command to 50MB.
2110
2111I considered and rejected a few alternatives.
2112
2113We could read all of the refs in the alternate using our own
2114ref code, just as we do with submodules. However, as memory
2115footprint is one of the concerns here, we want to avoid
2116loading those refs into our own memory as a whole.
2117
2118It's possible that this will be a better technique in the
2119future when the ref code can more easily iterate without
2120loading all of packed-refs into memory.
2121
2122Another option is to keep calling upload-pack, and just
2123parse its output ourselves in a streaming fashion. Besides
2124for-each-ref being simpler (we get to define the format
2125ourselves, and don't have to deal with speaking the git
2126protocol), it's more flexible for possible future changes.
2127
2128For instance, it might be useful for the caller to be able
2129to limit the set of "interesting" alternate refs. The
2130motivating example is one where many "forks" of a particular
2131repository share object storage, and the shared storage has
2132refs for each fork (which is why so many of the refs are
2133duplicates; each fork has the same tags). A plausible
2134future optimization would be to ask for the alternate refs
2135for just _one_ fork (if you had some out-of-band way of
2136knowing which was the most interesting or important for the
2137current operation).
2138
2139Similarly, no callbacks actually care about the symref value
2140of alternate refs, and as before, this patch ignores them
2141entirely. However, if we wanted to add them, for-each-ref's
2142"%(symref)" is going to be more flexible than upload-pack,
2143because the latter only handles the HEAD symref due to
2144historical constraints.
2145
2146There is one potential downside, though: unlike upload-pack,
2147our for-each-ref command doesn't report the peeled value of
2148refs. The existing code calls the alternate_ref_fn callback
2149twice for tags: once for the tag, and once for the peeled
2150value with the refname set to "ref^{}".
2151
2152For the callers in fetch-pack, this doesn't matter at all.
2153We immediately peel each tag down to a commit either way (so
2154there's a slight improvement, as do not bother passing the
2155redundant data over the pipe). For the caller in
2156receive-pack, it means we will not advertise the peeled
2157values of tags in our alternate. However, we also don't
2158advertise peeled values for our _own_ tags, so this is
2159actually making things more consistent.
2160
2161It's unclear whether receive-pack advertising peeled values
2162is a win or not. On one hand, giving more information to the
2163other side may let it omit some objects from the push. On
2164the other hand, for tags which both sides have, they simply
2165bloat the advertisement. The upload-pack advertisement of
2166git.git is about 30% larger than the receive-pack
2167advertisement due to its peeled information.
2168
2169This patch omits the peeled information from
2170for_each_alternate_ref entirely, and leaves it up to the
2171caller whether they want to dig up the information.
2172
2173Signed-off-by: Jeff King <peff@peff.net>
2174Signed-off-by: Junio C Hamano <gitster@pobox.com>
2175
2176for_each_alternate_ref: pass name/oid instead of ref struct
2177
2178Breaking down the fields in the interface makes it easier to
2179change the backend of for_each_alternate_ref to something
2180that doesn't use "struct ref" internally.
2181
2182The only field that callers actually look at is the oid,
2183anyway. The refname is kept in the interface as a plausible
2184thing for future code to want.
2185
2186Signed-off-by: Jeff King <peff@peff.net>
2187Signed-off-by: Junio C Hamano <gitster@pobox.com>
2188
2189for_each_alternate_ref: use strbuf for path allocation
2190
2191We have a string with ".../objects" pointing to the
2192alternate object store, and overwrite bits of it to look at
2193other paths in the (potential) git repository holding it.
2194This works because the only path we care about is "refs",
2195which is shorter than "objects".
2196
2197Using a strbuf to hold the path lets us get rid of some
2198magic numbers, and makes it more obvious that the memory
2199operations are safe.
2200
2201Signed-off-by: Jeff King <peff@peff.net>
2202Signed-off-by: Junio C Hamano <gitster@pobox.com>
2203
2204for_each_alternate_ref: stop trimming trailing slashes
2205
2206The real_pathdup() function will have removed extra slashes
2207for us already (on top of the normalize_path() done when we
2208created the alternate_object_database struct in the first
2209place).
2210
2211Incidentally, this also fixes the case where the path is
2212just "/", which would read off the start of the array.
2213That doesn't seem possible to trigger in practice, though,
2214as link_alt_odb_entry() blindly eats trailing slashes,
2215including a bare "/".
2216
2217Signed-off-by: Jeff King <peff@peff.net>
2218Signed-off-by: Junio C Hamano <gitster@pobox.com>
2219
2220for_each_alternate_ref: handle failure from real_pathdup()
2221
2222In older versions of git, if real_path() failed to resolve
2223the alternate object store path, we would die() with an
2224error. However, since 4ac9006f8 (real_path: have callers use
2225real_pathdup and strbuf_realpath, 2016-12-12) we use the
2226real_pathdup() function, which may return NULL. Since we
2227don't check the return value, we can segfault.
2228
2229This is hard to trigger in practice, since we check that the
2230path is accessible before creating the alternate_object_database
2231struct. But it could be removed racily, or we could see a
2232transient filesystem error.
2233
2234We could restore the original behavior by switching back to
2235xstrdup(real_path()). However, dying is probably not the
2236best option here. This whole function is best-effort
2237already; there might not even be a repository around the
2238shared objects at all. And if the alternate store has gone
2239away, there are no objects to show.
2240
2241So let's just quietly return, as we would if we failed to
2242open "refs/", or if upload-pack failed to start, etc.
2243
2244Signed-off-by: Jeff King <peff@peff.net>
2245Signed-off-by: Junio C Hamano <gitster@pobox.com>
2246
2247diff: print line prefix for --name-only output
2248
2249If you run "git log --graph --name-only", the pathnames are
2250not indented to go along with their matching commits (unlike
2251all of the other diff formats). We need to output the line
2252prefix for each item before writing it.
2253
2254The tests cover both --name-status and --name-only. The
2255former actually gets this right already, because it builds
2256on the --raw format functions. It's only --name-only which
2257uses its own code (and this fix mirrors the code in
2258diff_flush_raw()).
2259
2260Note that the tests don't follow our usual style of setting
2261up the "expect" output inside the test block. This matches
2262the surrounding style, but more importantly it is easier to
2263read: we don't have to worry about embedded single-quotes,
2264and the leading indentation is more obvious.
2265
2266Signed-off-by: Jeff King <peff@peff.net>
2267Signed-off-by: Junio C Hamano <gitster@pobox.com>
2268
2269dir: avoid allocation in fill_directory()
2270
2271Pass the match member of the first pathspec item directly to
2272read_directory() instead of using common_prefix() to duplicate it first,
2273thus avoiding memory duplication, strlen(3) and free(3).
2274
2275Signed-off-by: Rene Scharfe <l.s.r@web.de>
2276Signed-off-by: Junio C Hamano <gitster@pobox.com>
2277
2278rev-list-options.txt: update --all about HEAD
2279
2280This is the document patch for f0298cf1c6 (revision walker: include a
2281detached HEAD in --all - 2009-01-16).
2282
2283Even though that commit is about detached HEAD, as Jeff pointed out,
2284always adding HEAD in that case may have subtle differences with
2285--source or --exclude. So the document mentions nothing about the
2286detached-ness.
2287
2288Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
2289Signed-off-by: Junio C Hamano <gitster@pobox.com>
2290
2291t7800: replace "wc -l" with test_line_count
2292
2293Make t7800 easier to debug by capturing output into temporary files and
2294using test_line_count to make assertions on those files.
2295
2296Signed-off-by: David Aguilar <davvid@gmail.com>
2297Signed-off-by: Junio C Hamano <gitster@pobox.com>
2298
2299Merge 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
2304t7800: simplify basic usage test
2305
2306Use "test_line_count" instead of "wc -l", use "git -C" instead of a
2307subshell, and use test_expect_code when calling difftool. Ease
2308debugging by capturing output into temporary files.
2309
2310Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2311Signed-off-by: David Aguilar <davvid@gmail.com>
2312Signed-off-by: Junio C Hamano <gitster@pobox.com>
2313
2314Document the --no-gui option in difftool
2315
2316Prior to this, the `--no-gui` option was not documented in the manpage.
2317This commit introduces this into the manpage
2318
2319Signed-off-by: Denton Liu <liu.denton@gmail.com>
2320Signed-off-by: Junio C Hamano <gitster@pobox.com>
2321
2322ref-filter: resurrect "strip" as a synonym to "lstrip"
2323
2324We forgot that "strip" was introduced at 0571979bd6 ("tag: do not
2325show ambiguous tag names as "tags/foo"", 2016-01-25) as part of Git
23262.8 (and 2.7.1) when we started calling this "lstrip" to make it
2327easier to explain the new "rstrip" operation.
2328
2329We shouldn't have renamed the existing one; "lstrip" should have
2330been a new synonym that means the same thing as "strip". Scripts
2331in the wild are surely using the original form already.
2332
2333Signed-off-by: Junio C Hamano <gitster@pobox.com>
2334
2335worktree: fix option descriptions for `prune`
2336
2337The `verbose` and `expire` options of the `git worktree prune`
2338subcommand have wrong descriptions in that they pretend to relate to
2339objects. But as the git-worktree(1) correctly states, these options have
2340nothing to do with objects but only with worktrees. Fix the description
2341accordingly.
2342
2343Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
2344Signed-off-by: Junio C Hamano <gitster@pobox.com>
2345
2346p5302: create repositories for index-pack results explicitly
2347
2348Before 7176a314 (index-pack: complain when --stdin is used outside of a
2349repo) index-pack silently created a non-existing target directory; now
2350the command refuses to work unless it's used against a valid repository.
2351That causes p5302 to fail, which relies on the former behavior. Fix it
2352by setting up the destinations for its performance tests using git init.
2353
2354Signed-off-by: Rene Scharfe <l.s.r@web.de>
2355Acked-by: Jeff King <peff@peff.net>
2356Signed-off-by: Junio C Hamano <gitster@pobox.com>
2357
2358completion: fix git svn authorship switches
2359
2360--add-author-from and --use-log-author are for "git svn dcommit",
2361not "git svn (init|clone)"
2362
2363Signed-off-by: Eric Wong <e@80x24.org>
2364Signed-off-by: Junio C Hamano <gitster@pobox.com>
2365
2366difftool: fix bug when printing usage
2367
2368"git difftool -h" reports an error:
2369
2370 fatal: BUG: setup_git_env called without repository
2371
2372Defer repository setup so that the help option processing happens before
2373the repository is initialized.
2374
2375Add tests to ensure that the basic usage works inside and outside of a
2376repository.
2377
2378Signed-off-by: David Aguilar <davvid@gmail.com>
2379Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2380Signed-off-by: Junio C Hamano <gitster@pobox.com>
2381
2382l10n: fr.po: Fix a typo in the French translation
2383
2384Signed-off-by: Anthony Ramine <n.oxyde@gmail.com>
2385
2386l10n: fr.po: Remove gender specific adjectives
2387
2388Signed-off-by: Joachim Jablon <ewjoachim@gmail.com>
2389Reviewed-by: Jean-Noel Avila <jn.avila@free.fr>
2390
2391l10n: fr.po: Fix typos
2392
2393Reviewed-by: Jean-Noel Avila <jn.avila@free.fr>
2394Signed-off-by: Joachim Jablon <ewjoachim@gmail.com>
2395
2396reset: add an example of how to split a commit into two
2397
2398It is often useful to break a commit into multiple parts that are more
2399logical separations. This can be tricky to learn how to do without the
2400brute-force method if re-writing code or commit messages from scratch.
2401
2402Add a section to the git-reset documentation which shows an example
2403process for how to use git add -p and git commit -c HEAD@{1} to
2404interactively break a commit apart and re-use the original commit
2405message as a starting point when making the new commit message.
2406
2407Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
2408Signed-off-by: Junio C Hamano <gitster@pobox.com>
2409
2410completion: recognize more long-options
2411
2412Command completion only recognizes a subset of the available options for
2413the various git commands. The set of recognized options needs to balance
2414between having all useful options and to not clutter the terminal.
2415
2416This commit adds all long-options that are mentioned in the man-page
2417synopsis of the respective git command. Possibly dangerous options are
2418not included in this set, to avoid accidental data loss. The added
2419options 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
2437Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
2438Helped-by: Johannes Sixt <j6t@kdbg.org>
2439Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
2440Signed-off-by: Junio C Hamano <gitster@pobox.com>
2441
2442completion: teach remote subcommands to complete options
2443
2444Git-remote needs to complete remote names, its subcommands, and options
2445thereof. In addition to the existing subcommand and remote name
2446completion, 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
2453Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
2454Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
2455Signed-off-by: Junio C Hamano <gitster@pobox.com>
2456
2457completion: teach replace to complete options
2458
2459Git-replace needs to complete references and its own options. In
2460addition to the existing references completions, do also complete the
2461options --edit --graft --format= --list --delete.
2462
2463Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
2464Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
2465Signed-off-by: Junio C Hamano <gitster@pobox.com>
2466
2467completion: teach ls-remote to complete options
2468
2469ls-remote needs to complete remote names and its own options. In
2470addition to the existing remote name completions, do also complete
2471the options --heads, --tags, --refs, --get-url, and --symref.
2472
2473Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
2474Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
2475Signed-off-by: Junio C Hamano <gitster@pobox.com>
2476
2477completion: improve bash completion for git-add
2478
2479Command completion for git-add did not recognize some long-options.
2480This commits adds completion for all long-options that are mentioned in
2481the man-page synopsis. In addition, if the user specified `--update` or
2482`-u`, path completion will only suggest modified tracked files.
2483
2484Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
2485Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
2486Signed-off-by: Junio C Hamano <gitster@pobox.com>
2487
2488completion: add subcommand completion for rerere
2489
2490Managing recorded resolutions requires command-line usage of git-rerere.
2491Added subcommand completion for rerere and path completion for its
2492subcommand forget.
2493
2494Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
2495Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
2496Signed-off-by: Junio C Hamano <gitster@pobox.com>
2497
2498completion: teach submodule subcommands to complete options
2499
2500Each submodule subcommand has specific long-options. Therefore, teach
2501bash completion to support option completion based on the current
2502subcommand. All long-options that are mentioned in the man-page synopsis
2503are added.
2504
2505Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
2506Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com>
2507Signed-off-by: Junio C Hamano <gitster@pobox.com>
2508
2509completion: cache the path to the repository
2510
2511After the previous changes in this series there are only a handful of
2512$(__gitdir) command substitutions left in the completion script, but
2513there 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
2525Both of these points can be addressed by using the
2526__git_find_repo_path() helper function introduced in the previous
2527commit:
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
2546So call __git_find_repo_path() and use $__git_repo_path instead of the
2547$(__gitdir) command substitution to access paths in the .git
2548directory. Turn tests checking __gitdir()'s repository discovery into
2549tests of __git_find_repo_path() such that only the tested function
2550changes but the expected results don't, ensuring that repo discovery
2551keeps working as it did before.
2552
2553As __gitdir() is not used anymore in the completion script, mark it as
2554deprecated and direct users' attention to __git_find_repo_path() and
2555$__git_repo_path. Yet keep four __gitdir() tests to ensure that it
2556handles success and failure of __git_find_repo_path() and that it
2557still handles its optional remote argument, because users' custom
2558completion scriptlets might depend on it.
2559
2560Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2561Signed-off-by: Junio C Hamano <gitster@pobox.com>
2562
2563completion: extract repository discovery from __gitdir()
2564
2565To prepare for caching the path to the repository in the following
2566commit, extract the repository discovering part of __gitdir() into the
2567__git_find_repo_path() helper function, which stores the found path in
2568the $__git_repo_path variable instead of printing it. Make __gitdir()
2569a wrapper around this new function. Declare $__git_repo_path local in
2570the toplevel completion functions __git_main() and __gitk_main() to
2571ensure that it never leaks into the environment and influences
2572subsequent completions (though this isn't necessary right now, as
2573__gitdir() is still only executed in subshells, but will matter for
2574the following commit).
2575
2576Adjust tests checking __gitdir() or any other completion function
2577calling __gitdir() to perform those checks in a subshell to prevent
2578$__git_repo_path from leaking into the test environment. Otherwise
2579leave the tests unchanged to demonstrate that this change doesn't
2580alter __gitdir()'s behavior.
2581
2582Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2583Signed-off-by: Junio C Hamano <gitster@pobox.com>
2584
2585completion: don't guard git executions with __gitdir()
2586
2587Three completion functions, namely __git_index_files(), __git_heads()
2588and __git_tags(), first run __gitdir() and check that the path it
2589outputs exists, i.e. that there is a git repository, and run a git
2590command only if there is one.
2591
2592After the previous changes in this series there are no further uses of
2593__gitdir()'s output in these functions besides those checks. And
2594those checks are unnecessary, because we can just execute those git
2595commands outside of a repository and let them error out. We don't
2596perform such a check in other places either.
2597
2598Remove this check and the __gitdir() call from these functions,
2599sparing the fork()+exec() overhead of the command substitution and the
2600potential 'git rev-parse' execution.
2601
2602Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2603Signed-off-by: Junio C Hamano <gitster@pobox.com>
2604
2605completion: consolidate silencing errors from git commands
2606
2607Outputting error messages during completion is bad: they disrupt the
2608command line, can't be deleted, and the user is forced to Ctrl-C and
2609start over most of the time. We already silence stderr of many git
2610commands in our Bash completion script, but there are still some in
2611there that can spew error messages when something goes wrong.
2612
2613We could add the missing stderr redirections to all the remaining
2614places, but instead let's leverage that git commands are now executed
2615through the previously introduced __git() wrapper function, and
2616redirect standard error to /dev/null only in that function. This way
2617we need only one redirection to take care of errors from almost all
2618git commands. Redirecting standard error of the __git() wrapper
2619function thus became redundant, remove them.
2620
2621The exceptions, i.e. the repo-independent git executions and those in
2622the __gitdir() function that don't go through __git() already have
2623their standard error silenced.
2624
2625Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2626Signed-off-by: Junio C Hamano <gitster@pobox.com>
2627
2628completion: don't use __gitdir() for git commands
2629
2630Several completion functions contain the following pattern to run git
2631commands respecting the path to the repository specified on the
2632command line:
2633
2634 git --git-dir="$(__gitdir)" <cmd> <options>
2635
2636This imposes the overhead of fork()ing a subshell for the command
2637substitution and potentially fork()+exec()ing 'git rev-parse' inside
2638__gitdir().
2639
2640Now, if neither '--gitdir=<path>' nor '-C <path>' options are
2641specified on the command line, then those git commands are perfectly
2642capable to discover the repository on their own. If either one or
2643both of those options are specified on the command line, then, again,
2644the git commands could discover the repository, if we pass them all of
2645those options from the command line.
2646
2647This means we don't have to run __gitdir() at all for git commands and
2648can spare its fork()+exec() overhead.
2649
2650Use Bash parameter expansions to check the $__git_dir variable and
2651$__git_C_args array and to assemble the appropriate '--git-dir=<path>'
2652and '-C <path>' options if either one or both are present on the
2653command line. These parameter expansions are, however, rather long,
2654so instead of changing all git executions and make already long lines
2655even longer, encapsulate running git with '--git-dir=<path> -C <path>'
2656options into the new __git() wrapper function. Furthermore, this
2657wrapper function will also enable us to silence error messages from
2658git commands uniformly in one place in a later commit.
2659
2660There's one tricky case, though: in __git_refs() local refs are listed
2661with 'git for-each-ref', where "local" is not necessarily the
2662repository we are currently in, but it might mean a remote repository
2663in the filesystem (e.g. listing refs for 'git fetch /some/other/repo
2664<TAB>'). Use one-shot variable assignment to override $__git_dir with
2665the path of the repository where the refs should come from. Although
2666one-shot variable assignments in front of shell functions are to be
2667avoided in our scripts in general, in the Bash completion script we
2668can do that safely.
2669
2670Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2671Signed-off-by: Junio C Hamano <gitster@pobox.com>
2672
2673completion: respect 'git -C <path>'
2674
2675'git -C <path>' option(s) on the command line should be taken into
2676account 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
2686However, unlike '--git-dir=<path>', the '-C <path>' option can be
2687specified multiple times and their effect is cumulative, so we can't
2688just store a single '<path>' in a variable. Nor can we simply
2689concatenate a path from '-C <path1> -C <path2> ...', because e.g. (in
2690an arguably pathological corner case) a relative path might be
2691followed by an absolute path.
2692
2693Instead, store all '-C <path>' options word by word in the
2694$__git_C_args array in the main git completion function, and pass this
2695array, if present, to 'git rev-parse --absolute-git-dir' when
2696discovering the repository in __gitdir(), and let it take care of
2697multiple options, relative paths, absolute paths and everything.
2698
2699Also pass all '-C <path> options via the $__git_C_args array to those
2700git executions which require a worktree and for which it matters from
2701which directory they are executed from. There are only three such
2702cases:
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
2709The other git commands executed in the completion script don't need
2710these '-C <path>' options, because __gitdir() already took those
2711options into account. It would not hurt them, either, but let's not
2712induce unnecessary code churn.
2713
2714Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2715Signed-off-by: Junio C Hamano <gitster@pobox.com>
2716
2717rev-parse: add '--absolute-git-dir' option
2718
2719The output of 'git rev-parse --git-dir' can be either a relative or an
2720absolute path, depending on whether the current working directory is
2721at the top of the worktree or the .git directory or not, or how the
2722path to the repository is specified via the '--git-dir=<path>' option
2723or the $GIT_DIR environment variable. And if that output is a
2724relative path, then it is relative to the directory where any 'git
2725-C <path>' options might have led us.
2726
2727This doesn't matter at all for regular scripts, because the git
2728wrapper automatically takes care of changing directories according to
2729the '-C <path>' options, and the scripts can then simply follow any
2730path returned by 'git rev-parse --git-dir', even if it's a relative
2731path.
2732
2733Our Bash completion script, however, is unique in that it must run
2734directly in the user's interactive shell environment. This means that
2735it's not executed through the git wrapper and would have to take care
2736of any '-C <path> options on its own, and it can't just change
2737directories as it pleases. Consequently, adding support for taking
2738any '-C <path>' options on the command line into account during
2739completion turned out to be considerably more difficult, error prone
2740and required more subshells and git processes when it had to cope with
2741a relative path to the .git directory.
2742
2743Help this rather special use case and teach 'git rev-parse' a new
2744'--absolute-git-dir' option which always outputs a canonicalized
2745absolute path to the .git directory, regardless of whether the path is
2746discovered automatically or is specified via $GIT_DIR or 'git
2747--git-dir=<path>'.
2748
2749Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2750Signed-off-by: Junio C Hamano <gitster@pobox.com>
2751
2752completion: fix completion after 'git -C <path>'
2753
2754The main completion function finds the name of the git command by
2755iterating through all the words on the command line in search for the
2756first non-option-looking word. As it is not aware of 'git -C's
2757mandatory path argument, if the '-C <path>' option is present, 'path'
2758will be the first such word and it will be mistaken for a git command.
2759This 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
2777Fix this by skipping 'git -C's mandatory path argument while iterating
2778over the words on the command line. Extend the relevant test with
2779this case and, while at it, with cases that needed similar treatment
2780in the past ('--git-dir', '-c', '--work-tree' and '--namespace').
2781
2782Additionally, silence the standard error of the 'declare' builtins
2783looking for the completion function associated with the git command
2784and of the 'git config' query for the aliased command. So if git ever
2785learns a new option with a mandatory argument in the future, then,
2786though the completion script will again misbehave, at least the
2787command line will not be utterly disrupted by those error messages.
2788
2789Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2790Signed-off-by: Junio C Hamano <gitster@pobox.com>
2791
2792completion: don't offer commands when 'git --opt' needs an argument
2793
2794The main git options '--git-dir', '-c', '-C', '--worktree' and
2795'--namespace' require an argument, but attempting completion right
2796after them lists git commands.
2797
2798Don't offer anything right after these options, thus let Bash fall
2799back 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
2808Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2809Signed-off-by: Junio C Hamano <gitster@pobox.com>
2810
2811completion: list short refs from a remote given as a URL
2812
2813e832f5c09680 (completion: avoid ls-remote in certain scenarios,
28142013-05-28) turned a 'git ls-remote <remote>' query into a 'git
2815for-each-ref refs/remotes/<remote>/' to improve responsiveness of
2816remote refs completion by avoiding potential network communication.
2817However, it inadvertently made impossible to complete short refs from
2818a 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
2822Since the previous commit we tell apart configured remotes, i.e. those
2823that can have a hierarchy under 'refs/remotes/', from others that
2824don't, including remotes given as URL, so we know when we can't use
2825the faster 'git for-each-ref'-based approach.
2826
2827Resurrect the old, pre-e832f5c09680 'git ls-remote'-based code for the
2828latter case to support listing short refs from remotes given as a URL.
2829The 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
2836When the remote given to __git_refs() doesn't exist, then it will be
2837handled by this resurrected 'git ls-remote' query. This code path
2838doesn't list 'HEAD' unconditionally, which has the nice side effect of
2839fixing two more expected test failures.
2840
2841Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2842Signed-off-by: Junio C Hamano <gitster@pobox.com>
2843
2844completion: don't list 'HEAD' when trying refs completion outside of a repo
2845
2846When refs completion is attempted while not in a git repository, the
2847completion script offers 'HEAD' erroneously.
2848
2849Check early in __git_refs() that there is either a repository or a
2850remote to work on, and return early if neither is given.
2851
2852Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2853Signed-off-by: Junio C Hamano <gitster@pobox.com>
2854
2855completion: list refs from remote when remote's name matches a directory
2856
2857If the remote given to __git_refs() happens to match both the name of
2858a configured remote and the name of a directory in the current working
2859directory, then that directory is assumed to be a git repository, and
2860listing refs from that directory will be attempted. This is wrong,
2861because in such a situation git commands (e.g. 'git fetch|pull|push
2862<remote>' whom these refs will eventually be passed to) give
2863precedence to the configured remote. Therefore, __git_refs() should
2864list refs from the configured remote as well.
2865
2866Add the helper function __git_is_configured_remote() that checks
2867whether its argument matches the name of a configured remote. Use
2868this helper to decide how to handle the remote passed to __git_refs().
2869
2870Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2871Signed-off-by: Junio C Hamano <gitster@pobox.com>
2872
2873completion: respect 'git --git-dir=<path>' when listing remote refs
2874
2875In __git_refs() the git commands listing refs, both short and full,
2876from a given remote repository are run without giving them the path to
2877the git repository which might have been specified on the command line
2878via 'git --git-dir=<path>'. This is bad, those git commands should
2879access the 'refs/remotes/<remote>/' hierarchy or the remote and
2880credentials configuration in that specified repository.
2881
2882Use the __gitdir() helper only to find the path to the .git directory
2883and pass the resulting path to the 'git ls-remote' and 'for-each-ref'
2884executions that list remote refs. While modifying that 'for-each-ref'
2885line, remove the superfluous disambiguating doubledash.
2886
2887Don't use __gitdir() to check that the given remote is on the file
2888system: basically it performs only a single if statement for us at the
2889considerable cost of fork()ing a subshell for a command substitution.
2890We are better off to perform all the necessary checks of the remote in
2891__git_refs().
2892
2893Though __git_refs() was the last remaining callsite that passed a
2894remote to __gitdir(), don't delete __gitdir()'s remote-handling part
2895yet, just in case some users' custom completion scriptlets depend on
2896it.
2897
2898Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2899Signed-off-by: Junio C Hamano <gitster@pobox.com>
2900
2901completion: fix most spots not respecting 'git --git-dir=<path>'
2902
2903The completion script already respects the path to the repository
2904specified on the command line most of the time, here we add the
2905necessary '--git-dir=$(__gitdir)' options to most of the places where
2906git was executed without it. The exceptions where said option is not
2907added 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
2918Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2919Signed-off-by: Junio C Hamano <gitster@pobox.com>
2920
2921completion: ensure that the repository path given on the command line exists
2922
2923The __gitdir() helper function prints the path to the git repository
2924to its stdout or stays silent and returns with error when it can't
2925find a repository or when the repository given via $GIT_DIR doesn't
2926exist.
2927
2928This is not the case, however, when the path in $__git_dir, i.e. the
2929path to the repository specified on the command line via 'git
2930--git-dir=<path>', doesn't exist: __gitdir() still outputs it as if it
2931were a real existing repository, making some completion functions
2932believe that they operate on an existing repository.
2933
2934Check that the path in $__git_dir exists and return with error without
2935printing anything to stdout if it doesn't.
2936
2937Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2938Signed-off-by: Junio C Hamano <gitster@pobox.com>
2939
2940completion tests: add tests for the __git_refs() helper function
2941
2942Check 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
2953Seven of these tests expect failure, mostly demonstrating bugs related
2954to 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
2963Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2964Signed-off-by: Junio C Hamano <gitster@pobox.com>
2965
2966completion tests: check __gitdir()'s output in the error cases
2967
2968The __gitdir() helper function shouldn't output anything if not in a
2969git repository. The relevant tests only checked its error code, so
2970extend them to ensure that there's no output.
2971
2972Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2973Signed-off-by: Junio C Hamano <gitster@pobox.com>
2974
2975completion tests: consolidate getting path of current working directory
2976
2977Some tests of the __gitdir() helper function use the $TRASH_DIRECTORY
2978variable in direct path comparisons. In general this should be
2979avoided, because it might contain symbolic links. There happens to be
2980no issues with this here, however, because those tests use
2981$TRASH_DIRECTORY both for specifying the expected result and for
2982specifying input which in turn is just 'echo'ed verbatim.
2983
2984Other __gitdir() tests ask for the path of the trash directory by
2985running $(pwd -P) in each test, sometimes even twice in a single test.
2986
2987Run $(pwd) only once at the beginning of the test script to store the
2988path of the trash directory in a variable, and use that variable in
2989all __gitdir() tests.
2990
2991Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
2992Signed-off-by: Junio C Hamano <gitster@pobox.com>
2993
2994completion tests: make the $cur variable local to the test helper functions
2995
2996The test helper functions test_gitcomp() and test_gitcomp_nl() leak
2997the $cur variable into the test environment. Since this variable has
2998a special role in the Bash completion script (it holds the word
2999currently being completed) it influences the behavior of most
3000completion functions and thus this leakage could interfere with
3001subsequent tests. Although there are no such issues in the current
3002tests, early versions of the new tests that will be added later in
3003this series suffered because of this.
3004
3005It's better to play safe and declare $cur local in those test helper
3006functions. 'local' is bashism, of course, but the tests of the Bash
3007completion script are run under Bash anyway, and there are already
3008other variables declared local in this test script.
3009
3010Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
3011Signed-off-by: Junio C Hamano <gitster@pobox.com>
3012
3013completion tests: don't add test cruft to the test repository
3014
3015While preparing commits, three tests added newly created files to the
3016index using 'git add .', which added not only the files in question
3017but leftover test cruft from previous tests like the files 'expected'
3018and 'actual' as well. Luckily, this had no effect on the tests'
3019correctness.
3020
3021Add only the files we are actually interested in.
3022
3023Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
3024Signed-off-by: Junio C Hamano <gitster@pobox.com>
3025
3026completion: improve __git_refs()'s in-code documentation
3027
3028That "first argument is passed to __gitdir()" statement in particular
3029is not really helpful, and after this series it won't be the case
3030anyway.
3031
3032Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
3033Signed-off-by: Junio C Hamano <gitster@pobox.com>
3034
3035l10n: git.pot: v2.12.0 round 1 (239 new, 15 removed)
3036
3037Generate po/git.pot from v2.12.0-rc0 for git v2.12.0 l10n round 1.
3038
3039Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
3040
3041Merge 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
3049Git 2.12-rc0
3050
3051Signed-off-by: Junio C Hamano <gitster@pobox.com>
3052
3053Merge branch 'cw/log-updates-for-all-refs-really'
3054
3055The "core.logAllRefUpdates" that used to be boolean has been
3056enhanced to take 'always' as well, to record ref updates to refs
3057other than the ones that are expected to be updated (i.e. branches,
3058remote-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
3066Merge branch 'pl/complete-diff-submodule-diff'
3067
3068The 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
3074Merge 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
3083Merge branch 'js/re-running-failed-tests'
3084
3085"make -C t failed" will now run only the tests that failed in the
3086previous run. This is usable only when prove is not use, and gives
3087a useless error message when run after "make clean", but otherwise
3088is serviceable.
3089
3090* js/re-running-failed-tests:
3091 t/Makefile: add a rule to re-run previously-failed tests
3092
3093Merge branch 'sb/submodule-update-initial-runs-custom-script'
3094
3095The user can specify a custom update method that is run when
3096"submodule update" updates an already checked out submodule. This
3097was ignored when checking the submodule out for the first time and
3098we instead always just checked out the commit that is bound to the
3099path 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
3104Merge branch 'sb/submodule-recursive-absorb'
3105
3106When a submodule "A", which has another submodule "B" nested within
3107it, is "absorbed" into the top-level superproject, the inner
3108submodule "B" used to be left in a strange state. The logic to
3109adjust 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
3116Merge branch 'sb/unpack-trees-super-prefix'
3117
3118"git read-tree" and its underlying unpack_trees() machinery learned
3119to 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
3127Sync with v2.11.1
3128
3129* maint:
3130 Git 2.11.1
3131
3132Ninth batch for 2.12; almost ready for -rc0
3133
3134Signed-off-by: Junio C Hamano <gitster@pobox.com>
3135
3136Merge branch 'nd/log-graph-configurable-colors'
3137
3138Some people feel the default set of colors used by "git log --graph"
3139rather limiting. A mechanism to customize the set of colors has
3140been 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
3149Merge branch 'ep/commit-static-buf-cleanup'
3150
3151Code 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
3157Merge branch 'bc/use-asciidoctor-opt'
3158
3159Asciidoctor, an alternative reimplementation of AsciiDoc, still
3160needs some changes to work with documents meant to be formatted
3161with AsciiDoc. "make USE_ASCIIDOCTOR=YesPlease" to use it out of
3162the 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
3174Merge branch 'sg/mailmap-self'
3175
3176* sg/mailmap-self:
3177 .mailmap: update Gábor Szeder's email address
3178
3179Merge branch 'js/mingw-hooks-with-exe-suffix'
3180
3181Names of the various hook scripts must be spelled exactly, but on
3182Windows, 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
3188Merge branch 'rs/receive-pack-cleanup'
3189
3190Code clean-up.
3191
3192* rs/receive-pack-cleanup:
3193 receive-pack: call string_list_clear() unconditionally
3194
3195Merge branch 'mm/reset-facl-before-umask-test'
3196
3197Test tweaks for those who have default ACL in their git source tree
3198that 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
3203Merge branch 'hv/mingw-help-is-executable'
3204
3205"git help" enumerates executable files in $PATH; the implementation
3206of "is this file executable?" on Windows has been optimized.
3207
3208* hv/mingw-help-is-executable:
3209 help: improve is_executable() on Windows
3210
3211Merge branch 'gv/mingw-p4-mapuser'
3212
3213"git p4" did not work well with multiple git-p4.mapUser entries on
3214Windows.
3215
3216* gv/mingw-p4-mapuser:
3217 git-p4: fix git-p4.mapUser on Windows
3218
3219Merge branch 'rs/absolute-pathdup'
3220
3221Code cleanup.
3222
3223* rs/absolute-pathdup:
3224 use absolute_pathdup()
3225 abspath: add absolute_pathdup()
3226
3227Merge branch 'js/unzip-in-usr-bin-workaround'
3228
3229Test tweak for FreeBSD where /usr/bin/unzip is unsuitable to run
3230our 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
3235Merge branch 'cw/doc-sign-off'
3236
3237Doc update.
3238
3239* cw/doc-sign-off:
3240 doc: clarify distinction between sign-off and pgp-signing
3241
3242Merge branch 'js/status-pre-rebase-i'
3243
3244After starting "git rebase -i", which first opens the user's editor
3245to edit the series of patches to apply, but before saving the
3246contents of that file, "git status" failed to show the current
3247state (i.e. you are in an interactive rebase session, but you have
3248applied no steps yet) correctly.
3249
3250* js/status-pre-rebase-i:
3251 status: be prepared for not-yet-started interactive rebase
3252
3253Merge branch 'js/retire-relink'
3254
3255Cruft removal.
3256
3257* js/retire-relink:
3258 relink: really remove the command
3259 relink: retire the command
3260
3261Merge branch 'sb/submodule-add-force'
3262
3263"git submodule add" used to be confused and refused to add a
3264locally created repository; users can now use "--force" option
3265to add them.
3266
3267* sb/submodule-add-force:
3268 submodule add: extend force flag to add existing repos
3269
3270Git 2.11.1
3271
3272Signed-off-by: Junio C Hamano <gitster@pobox.com>
3273
3274Merge branch 'ws/request-pull-code-cleanup' into maint
3275
3276Code clean-up.
3277
3278* ws/request-pull-code-cleanup:
3279 request-pull: drop old USAGE stuff
3280
3281Merge branch 'jk/execv-dashed-external' into maint
3282
3283Typing ^C to pager, which usually does not kill it, killed Git and
3284took the pager down as a collateral damage in certain process-tree
3285structure. 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
3292document behavior of empty color name
3293
3294Commit 55cccf4bb (color_parse_mem: allow empty color spec,
32952017-02-01) clearly defined the behavior of an empty color
3296config variable. Let's document that, and give a hint about
3297why it might be useful.
3298
3299It's important not to say that it makes the item uncolored,
3300because it doesn't. It just sets no attributes, which means
3301that any previous attributes continue to take effect.
3302
3303Signed-off-by: Jeff King <peff@peff.net>
3304Signed-off-by: Junio C Hamano <gitster@pobox.com>
3305
3306doc: add note about ignoring '--no-create-reflog'
3307
3308The commands git-branch and git-tag accept the '--create-reflog'
3309option, and create reflog even when core.logallrefupdates
3310configuration is explicitly set not to.
3311
3312On the other hand, the negated form '--no-create-reflog' is accepted
3313as a valid option but has no effect (other than overriding an
3314earlier '--create-reflog' on the command line). This silent noop may
3315puzzle users. To communicate that this is a known limitation, add a
3316short note in the manuals for git-branch and git-tag.
3317
3318Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
3319Helped-by: Jeff King <peff@peff.net>
3320Signed-off-by: Junio C Hamano <gitster@pobox.com>
3321
3322completion: add completion for --recurse-submodules=only
3323
3324Command completion for 'git-push --recurse-submodules' already knows to
3325complete some modes. However, the recently added mode 'only' is missing.
3326
3327Adding 'only' to the recognized modes completes the list of non-trivial
3328modes.
3329
3330Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
3331Signed-off-by: Junio C Hamano <gitster@pobox.com>
3332
3333doc: add doc for git-push --recurse-submodules=only
3334
3335Add documentation for the `--recurse-submodules=only` option of
3336git-push. The feature was added in commit 225e8bf (add option to
3337push only submodules).
3338
3339Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
3340Signed-off-by: Junio C Hamano <gitster@pobox.com>
3341
3342attr: reformat git_attr_set_direction() function
3343
3344Move the 'git_attr_set_direction()' up to be closer to the variables
3345that it modifies as well as a small formatting by renaming the variable
3346'new' to 'new_direction' so that it is more descriptive.
3347
3348Update the comment about how 'direction' is used to read the state of
3349the world. It should be noted that callers of
3350'git_attr_set_direction()' should ensure that other threads are not
3351making calls into the attribute system until after the call to
3352'git_attr_set_direction()' completes. This function essentially acts as
3353reset button for the attribute system and should be handled with care.
3354
3355Signed-off-by: Brandon Williams <bmwill@google.com>
3356Signed-off-by: Junio C Hamano <gitster@pobox.com>
3357
3358attr: push the bare repo check into read_attr()
3359
3360Push the bare repository check into the 'read_attr()' function. This
3361avoids needing to have extra logic which creates an empty stack frame
3362when inside a bare repo as a similar bit of logic already exists in the
3363'read_attr()' function.
3364
3365Signed-off-by: Brandon Williams <bmwill@google.com>
3366Signed-off-by: Junio C Hamano <gitster@pobox.com>
3367
3368attr: store attribute stack in attr_check structure
3369
3370The last big hurdle towards a thread-safe API for the attribute system
3371is the reliance on a global attribute stack that is modified during each
3372call into the attribute system.
3373
3374This patch removes this global stack and instead a stack is stored
3375locally in each attr_check instance. This opens up the opportunity for
3376future optimizations to customize the attribute stack for the attributes
3377that a particular attr_check struct is interested in.
3378
3379One caveat with pushing the attribute stack into the attr_check
3380structure is that the attribute system now needs to keep track of all
3381active attr_check instances. Due to the direction mechanism the stack
3382needs to be dropped when the direction is switched. In order to ensure
3383correctness when the direction is changed the attribute system needs to
3384iterate through all active attr_check instances and drop each of their
3385stacks.
3386
3387Signed-off-by: Brandon Williams <bmwill@google.com>
3388Signed-off-by: Junio C Hamano <gitster@pobox.com>
3389
3390attr: tighten const correctness with git_attr and match_attr
3391
3392Signed-off-by: Brandon Williams <bmwill@google.com>
3393Signed-off-by: Junio C Hamano <gitster@pobox.com>
3394
3395attr: remove maybe-real, maybe-macro from git_attr
3396
3397Whether or not a git attribute is real or a macro isn't a property of
3398the attribute but rather it depends on the attribute stack (which
3399.gitattribute files were read).
3400
3401This patch removes the 'maybe_real' and 'maybe_macro' fields in a
3402git_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
3404for the given attribute stack. It's populated, through a quick scan of
3405the attribute stack, with the match_attr that corresponds to the macro's
3406definition. This way the attribute stack only needs to be scanned a
3407single time prior to attribute collection instead of each time a macro
3408needs to be expanded.
3409
3410Signed-off-by: Brandon Williams <bmwill@google.com>
3411Signed-off-by: Junio C Hamano <gitster@pobox.com>
3412
3413attr: eliminate global check_all_attr array
3414
3415Currently there is a reliance on 'check_all_attr' which is a global
3416array of 'attr_check_item' items which is used to store the value of
3417each attribute during the collection process.
3418
3419This patch eliminates this global and instead creates an array per
3420'attr_check' instance which is then used in the attribute collection
3421process. This brings the attribute system one step closer to being
3422thread-safe.
3423
3424Signed-off-by: Brandon Williams <bmwill@google.com>
3425Signed-off-by: Junio C Hamano <gitster@pobox.com>
3426
3427attr: use hashmap for attribute dictionary
3428
3429The current implementation of the attribute dictionary uses a custom
3430hashtable. This modernizes the dictionary by converting it to the builtin
3431'hashmap' structure.
3432
3433Also, in order to enable a threaded API in the future add an
3434accompanying mutex which must be acquired prior to accessing the
3435dictionary of interned attributes.
3436
3437Signed-off-by: Brandon Williams <bmwill@google.com>
3438Signed-off-by: Junio C Hamano <gitster@pobox.com>
3439
3440attr: change validity check for attribute names to use positive logic
3441
3442Convert 'invalid_attr_name()' to 'attr_name_valid()' and use positive
3443logic for the return value. In addition create a helper function that
3444prints out an error message when an invalid attribute name is used.
3445
3446We could later update the message to exactly spell out what the
3447rules for a good attribute name are, etc.
3448
3449Signed-off-by: Junio C Hamano <gitster@pobox.com>
3450Signed-off-by: Stefan Beller <sbeller@google.com>
3451Signed-off-by: Brandon Williams <bmwill@google.com>
3452Signed-off-by: Junio C Hamano <gitster@pobox.com>
3453
3454attr: pass struct attr_check to collect_some_attrs
3455
3456The old callchain used to take an array of attr_check_item items.
3457Instead pass the 'attr_check' container object to 'collect_some_attrs()'
3458and access the fields in the data structure directly.
3459
3460Signed-off-by: Brandon Williams <bmwill@google.com>
3461Signed-off-by: Junio C Hamano <gitster@pobox.com>
3462
3463attr: retire git_check_attrs() API
3464
3465Since nobody uses the old API, make it file-scope static, and update
3466the documentation to describe the new API.
3467
3468Signed-off-by: Junio C Hamano <gitster@pobox.com>
3469Signed-off-by: Stefan Beller <sbeller@google.com>
3470Signed-off-by: Brandon Williams <bmwill@google.com>
3471Signed-off-by: Junio C Hamano <gitster@pobox.com>
3472
3473attr: convert git_check_attrs() callers to use the new API
3474
3475The remaining callers are all simple "I have N attributes I am
3476interested in. I'll ask about them with various paths one by one".
3477
3478After this step, no caller to git_check_attrs() remains. After
3479removing it, we can extend "struct attr_check" struct with data
3480that can be used in optimizing the query for the specific N
3481attributes it contains.
3482
3483Signed-off-by: Junio C Hamano <gitster@pobox.com>
3484Signed-off-by: Stefan Beller <sbeller@google.com>
3485Signed-off-by: Brandon Williams <bmwill@google.com>
3486Signed-off-by: Junio C Hamano <gitster@pobox.com>
3487
3488attr: convert git_all_attrs() to use "struct attr_check"
3489
3490This updates the other two ways the attribute check is done via an
3491array of "struct attr_check_item" elements. These two niches
3492appear 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
3501Such a caller can call attr_check_alloc() to allocate an empty
3502attr_check, and then call attr_check_append() to add attribute names
3503one by one.
3504
3505Signed-off-by: Junio C Hamano <gitster@pobox.com>
3506Signed-off-by: Stefan Beller <sbeller@google.com>
3507Signed-off-by: Brandon Williams <bmwill@google.com>
3508Signed-off-by: Junio C Hamano <gitster@pobox.com>
3509
3510attr: (re)introduce git_check_attr() and struct attr_check
3511
3512A 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
3518A look-up for these N attributes for a single path P scans the
3519entire attr_stack, starting from the .git/info/attributes file and
3520then .gitattributes file in the directory the path P is in, going
3521upwards to find .gitattributes file found in parent directories.
3522
3523An earlier commit 06a604e6 (attr: avoid heavy work when we know the
3524specified attr is not defined, 2014-12-28) tried to optimize out
3525this scanning for one trivial special case: when the attribute being
3526sought is known not to exist, we do not have to scan for it. While
3527this may be a cheap and effective heuristic, it would not work well
3528when N is (much) more than 1.
3529
3530What we would want is a more customized way to skip irrelevant
3531entries in the attribute stack, and the definition of irrelevance
3532is tied to the set of attributes passed to git_check_attrs() call,
3533i.e. the set of attributes being sought. The data necessary for
3534this optimization needs to live alongside the set of attributes, but
3535a simple array of git_attr_check_elem simply does not have any place
3536for that.
3537
3538Introduce "struct attr_check" that contains N, the number of
3539attributes being sought, and A, the array that holds N
3540attr_check_item items, and a function git_check_attr() that
3541takes a path P and this structure as its parameters. This structure
3542can later be extended to hold extra data necessary for optimization.
3543
3544Also, to make it easier to write the first two steps in common
3545cases, introduce git_attr_check_initl() helper function, which takes
3546a NULL-terminated list of attribute names and initialize this
3547structure.
3548
3549Signed-off-by: Junio C Hamano <gitster@pobox.com>
3550Signed-off-by: Stefan Beller <sbeller@google.com>
3551Signed-off-by: Brandon Williams <bmwill@google.com>
3552Signed-off-by: Junio C Hamano <gitster@pobox.com>
3553
3554attr: rename function and struct related to checking attributes
3555
3556The traditional API to check attributes is to prepare an N-element
3557array of "struct git_attr_check" and pass N and the array to the
3558function "git_check_attr()" as arguments.
3559
3560In preparation to revamp the API to pass a single structure, in
3561which these N elements are held, rename the type used for these
3562individual array elements to "struct attr_check_item" and rename
3563the function to "git_check_attrs()".
3564
3565Signed-off-by: Junio C Hamano <gitster@pobox.com>
3566Signed-off-by: Stefan Beller <sbeller@google.com>
3567Signed-off-by: Brandon Williams <bmwill@google.com>
3568Signed-off-by: Junio C Hamano <gitster@pobox.com>
3569
3570attr.c: outline the future plans by heavily commenting
3571
3572Signed-off-by: Junio C Hamano <gitster@pobox.com>
3573Signed-off-by: Stefan Beller <sbeller@google.com>
3574Signed-off-by: Brandon Williams <bmwill@google.com>
3575Signed-off-by: Junio C Hamano <gitster@pobox.com>
3576
3577Documentation: fix a typo
3578
3579Signed-off-by: Stefan Beller <sbeller@google.com>
3580Signed-off-by: Brandon Williams <bmwill@google.com>
3581Signed-off-by: Junio C Hamano <gitster@pobox.com>
3582
3583attr.c: add push_stack() helper
3584
3585There are too many repetitious "I have this new attr_stack element;
3586push it at the top of the stack" sequence. The new helper function
3587push_stack() gives us a way to express what is going on at these
3588places, and as a side effect, halves the number of times we mention
3589the attr_stack global variable.
3590
3591Signed-off-by: Junio C Hamano <gitster@pobox.com>
3592Signed-off-by: Stefan Beller <sbeller@google.com>
3593Signed-off-by: Brandon Williams <bmwill@google.com>
3594Signed-off-by: Junio C Hamano <gitster@pobox.com>
3595
3596attr: support quoting pathname patterns in C style
3597
3598Full pattern must be quoted. So 'pat"t"ern attr' will give exactly
3599'pat"t"ern', not 'pattern'. Also clarify that leading whitespaces are
3600not part of the pattern and document comment syntax.
3601
3602Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
3603Signed-off-by: Junio C Hamano <gitster@pobox.com>
3604Signed-off-by: Stefan Beller <sbeller@google.com>
3605Signed-off-by: Brandon Williams <bmwill@google.com>
3606Signed-off-by: Junio C Hamano <gitster@pobox.com>
3607
3608attr.c: plug small leak in parse_attr_line()
3609
3610If any error is noticed after the match_attr structure is allocated,
3611we shouldn't just return NULL from this function.
3612
3613Add a fail_return label that frees the allocated structure and
3614returns NULL, and consistently jump there when we want to return
3615NULL after cleaning up.
3616
3617Signed-off-by: Junio C Hamano <gitster@pobox.com>
3618Signed-off-by: Stefan Beller <sbeller@google.com>
3619Signed-off-by: Brandon Williams <bmwill@google.com>
3620Signed-off-by: Junio C Hamano <gitster@pobox.com>
3621
3622attr.c: tighten constness around "git_attr" structure
3623
3624It holds an interned string, and git_attr_name() is a way to peek
3625into it. Make sure the involved pointer types are pointer-to-const.
3626
3627Signed-off-by: Junio C Hamano <gitster@pobox.com>
3628Signed-off-by: Stefan Beller <sbeller@google.com>
3629Signed-off-by: Brandon Williams <bmwill@google.com>
3630Signed-off-by: Junio C Hamano <gitster@pobox.com>
3631
3632attr.c: simplify macroexpand_one()
3633
3634The double-loop wants to do an early return immediately when one
3635matching macro is found. Eliminate the extra variable 'a' used for
3636that purpose and rewrite the "assign the found item to 'a' to make
3637it non-NULL and force the loop(s) to terminate" with a direct return
3638from there.
3639
3640Signed-off-by: Junio C Hamano <gitster@pobox.com>
3641Signed-off-by: Stefan Beller <sbeller@google.com>
3642Signed-off-by: Brandon Williams <bmwill@google.com>
3643Signed-off-by: Junio C Hamano <gitster@pobox.com>
3644
3645attr.c: mark where #if DEBUG ends more clearly
3646
3647Signed-off-by: Junio C Hamano <gitster@pobox.com>
3648Signed-off-by: Stefan Beller <sbeller@google.com>
3649Signed-off-by: Brandon Williams <bmwill@google.com>
3650Signed-off-by: Junio C Hamano <gitster@pobox.com>
3651
3652attr.c: complete a sentence in a comment
3653
3654Signed-off-by: Junio C Hamano <gitster@pobox.com>
3655Signed-off-by: Stefan Beller <sbeller@google.com>
3656Signed-off-by: Brandon Williams <bmwill@google.com>
3657Signed-off-by: Junio C Hamano <gitster@pobox.com>
3658
3659attr.c: explain the lack of attr-name syntax check in parse_attr()
3660
3661Signed-off-by: Junio C Hamano <gitster@pobox.com>
3662Signed-off-by: Stefan Beller <sbeller@google.com>
3663Signed-off-by: Brandon Williams <bmwill@google.com>
3664Signed-off-by: Junio C Hamano <gitster@pobox.com>
3665
3666attr.c: update a stale comment on "struct match_attr"
3667
3668When 82dce998 (attr: more matching optimizations from .gitignore,
36692012-10-15) changed a pointer to a string "*pattern" into an
3670embedded "struct pattern" in struct match_attr, it forgot to update
3671the comment that describes the structure.
3672
3673Signed-off-by: Junio C Hamano <gitster@pobox.com>
3674Signed-off-by: Stefan Beller <sbeller@google.com>
3675Signed-off-by: Brandon Williams <bmwill@google.com>
3676Signed-off-by: Junio C Hamano <gitster@pobox.com>
3677
3678attr.c: use strchrnul() to scan for one line
3679
3680Signed-off-by: Junio C Hamano <gitster@pobox.com>
3681Signed-off-by: Stefan Beller <sbeller@google.com>
3682Signed-off-by: Brandon Williams <bmwill@google.com>
3683Signed-off-by: Junio C Hamano <gitster@pobox.com>
3684
3685commit.c: use strchrnul() to scan for one line
3686
3687Signed-off-by: Junio C Hamano <gitster@pobox.com>
3688Signed-off-by: Stefan Beller <sbeller@google.com>
3689Signed-off-by: Brandon Williams <bmwill@google.com>
3690Signed-off-by: Junio C Hamano <gitster@pobox.com>
3691
3692urlmatch: allow globbing for the URL host part
3693
3694The URL matching function computes for two URLs whether they match not.
3695The match is performed by splitting up the URL into different parts and
3696then doing an exact comparison with the to-be-matched URL.
3697
3698The main user of `urlmatch` is the configuration subsystem. It allows to
3699set certain configurations based on the URL which is being connected to
3700via keys like `http.<url>.*`. A common use case for this is to set
3701proxies for only some remotes which match the given URL. Unfortunately,
3702having exact matches for all parts of the URL can become quite tedious
3703in some setups. Imagine for example a corporate network where there are
3704dozens or even hundreds of subdomains, which would have to be configured
3705individually.
3706
3707Allow 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
3710subdomains of "https://example.com", e.g. "https://foo.example.com", but
3711not "https://foo.bar.example.com".
3712
3713Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
3714Helped-by: Junio C Hamano <gitster@pobox.com>
3715Signed-off-by: Junio C Hamano <gitster@pobox.com>
3716
3717urlmatch: include host in urlmatch ranking
3718
3719In order to be able to rank positive matches by `urlmatch`, we inspect
3720the path length and user part to decide whether a match is better than
3721another match. As all other parts are matched exactly between both URLs,
3722this is the correct thing to do right now.
3723
3724In the future, though, we want to introduce wild cards for the domain
3725part. When doing this, it does not make sense anymore to only compare
3726the path lengths. Instead, we also want to compare the domain lengths to
3727determine which of both URLs matches the host part more closely.
3728
3729Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
3730Signed-off-by: Junio C Hamano <gitster@pobox.com>
3731
3732connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config
3733
3734This environment variable and configuration value allow to
3735override the autodetection of plink/tortoiseplink in case that
3736Git gets it wrong.
3737
3738[jes: wrapped overly-long lines, factored out and changed
3739get_ssh_variant() to handle_ssh_variant() to accomodate the
3740change from the putty/tortoiseplink variables to
3741port_option/needs_batch, adjusted the documentation, free()d
3742value obtained from the config.]
3743
3744Signed-off-by: Segev Finer <segev208@gmail.com>
3745Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3746Signed-off-by: Junio C Hamano <gitster@pobox.com>
3747
3748git_connect(): factor out SSH variant handling
3749
3750We handle plink and tortoiseplink as OpenSSH replacements, by passing
3751the correct command-line options when detecting that they are used.
3752
3753To let users override that auto-detection (in case Git gets it wrong),
3754we need to introduce new code to that end.
3755
3756In preparation for this code, let's factor out the SSH variant handling
3757into its own function, handle_ssh_variant().
3758
3759Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3760Signed-off-by: Junio C Hamano <gitster@pobox.com>
3761
3762color_parse_mem: allow empty color spec
3763
3764Prior to c2f41bf52 (color.c: fix color_parse_mem() with
3765value_len == 0, 2017-01-19), the empty string was
3766interpreted as a color "reset". This was an accidental
3767outcome, and that commit turned it into an error.
3768
3769However, scripts may pass the empty string as a default
3770value to "git config --get-color" to disable color when the
3771value is not defined. The git-add--interactive script does
3772this. As a result, the script is unusable since c2f41bf52
3773unless you have color.diff.plain defined (if it is defined,
3774then we don't parse the empty default at all).
3775
3776Our test scripts didn't notice the recent breakage because
3777they run without a terminal, and thus without color. They
3778never hit this code path at all. And nobody noticed the
3779original buggy "reset" behavior, because it was effectively
3780a noop.
3781
3782Let's fix the code to have an empty color name produce an
3783empty 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
3813Signed-off-by: Jeff King <peff@peff.net>
3814Signed-off-by: Junio C Hamano <gitster@pobox.com>
3815
3816.mailmap: update Gábor Szeder's email address
3817
3818Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
3819Signed-off-by: Junio C Hamano <gitster@pobox.com>
3820
3821Sync with maint
3822
3823* maint:
3824 Ready for 2.11.1
3825
3826Ready for 2.11.1
3827
3828Signed-off-by: Junio C Hamano <gitster@pobox.com>
3829
3830Merge branch 'sb/in-core-index-doc' into maint
3831
3832Documentation 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
3840Merge branch 'js/mingw-isatty' into maint
3841
3842An update to a topic that is already in 'master'.
3843
3844* js/mingw-isatty:
3845 mingw: follow-up to "replace isatty() hack"
3846
3847Merge branch 'jk/coding-guidelines-update' into maint
3848
3849Developer doc update.
3850
3851* jk/coding-guidelines-update:
3852 CodingGuidelines: clarify multi-line brace style
3853
3854Merge branch 'js/exec-path-coverity-workaround' into maint
3855
3856Code 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
3862Merge branch 'ad/bisect-terms' into maint
3863
3864Documentation fix.
3865
3866* ad/bisect-terms:
3867 Documentation/bisect: improve on (bad|new) and (good|bad)
3868
3869Merge branch 'jk/grep-e-could-be-extended-beyond-posix' into maint
3870
3871Tighten a test to avoid mistaking an extended ERE regexp engine as
3872a PRE regexp engine.
3873
3874* jk/grep-e-could-be-extended-beyond-posix:
3875 t7810: avoid assumption about invalid regex syntax
3876
3877Merge branch 'km/branch-get-push-while-detached' into maint
3878
3879"git <cmd> @{push}" on a detached HEAD used to segfault; it has
3880been 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
3885Merge branch 'jk/rebase-i-squash-count-fix' into maint
3886
3887"git rebase -i" with a recent update started showing an incorrect
3888count when squashing more than 10 commits.
3889
3890* jk/rebase-i-squash-count-fix:
3891 rebase--interactive: count squash commits above 10 correctly
3892
3893Merge branch 'jk/blame-fixes' into maint
3894
3895"git blame --porcelain" misidentified the "previous" <commit, path>
3896pair (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
3903Merge branch 'jk/archive-zip-userdiff-config' into maint
3904
3905"git archive" did not read the standard configuration files, and
3906failed to notice a file that is marked as binary via the userdiff
3907driver configuration.
3908
3909* jk/archive-zip-userdiff-config:
3910 archive-zip: load userdiff config
3911
3912Merge branch 'dt/disable-bitmap-in-auto-gc' into maint
3913
3914It is natural that "git gc --auto" may not attempt to pack
3915everything into a single pack, and there is no point in warning
3916when the user has configured the system to use the pack bitmap,
3917leading 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
3923Merge branch 'nd/config-misc-fixes' into maint
3924
3925Leakage 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
3932Merge branch 'jc/abbrev-autoscale-config' into maint
3933
3934Recent update to the default abbreviation length that auto-scales
3935lacked documentation update, which has been corrected.
3936
3937* jc/abbrev-autoscale-config:
3938 config.abbrev: document the new default that auto-scales
3939
3940Merge branch 'mh/fast-import-notes-fix-new' into maint
3941
3942"git fast-import" sometimes mishandled while rebalancing notes
3943tree, which has been fixed.
3944
3945* mh/fast-import-notes-fix-new:
3946 fast-import: properly fanout notes when tree is imported
3947
3948Merge branch 'jc/compression-config' into maint
3949
3950Compression setting for producing packfiles were spread across
3951three codepaths, one of which did not honor any configuration.
3952Unify these so that all of them honor core.compression and
3953pack.compression variables the same way.
3954
3955* jc/compression-config:
3956 compression: unify pack.compression configuration parsing
3957
3958Merge branch 'ew/svn-fixes' into maint
3959
3960Meant 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
3966Merge branch 'ls/travis-p4-on-macos' into maint
3967
3968Update the definition of the MacOSX test environment used by
3969TravisCI.
3970
3971* ls/travis-p4-on-macos:
3972 travis-ci: fix Perforce install on macOS
3973
3974Merge branch 'jk/make-tags-find-sources-tweak' into maint
3975
3976Update 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
3984Merge branch 'jc/latin-1' into maint
3985
3986Some platforms no longer understand "latin-1" that is still seen in
3987the wild in e-mail headers; replace them with "iso-8859-1" that is
3988more 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
3994Eighth batch for 2.12
3995
3996Signed-off-by: Junio C Hamano <gitster@pobox.com>
3997
3998Merge 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
4013Merge branch 'js/difftool-builtin'
4014
4015Rewrite 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
4023Merge branch 'rs/qsort-s'
4024
4025A few codepaths had to rely on a global variable when sorting
4026elements of an array because sort(3) API does not allow extra data
4027to be passed to the comparison function. Use qsort_s() when
4028natively available, and a fallback implementation of it when not,
4029to eliminate the need, which is a prerequisite for making the
4030codepath 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
4039Merge branch 'ls/travis-p4-on-macos'
4040
4041Update the definition of the MacOSX test environment used by
4042TravisCI.
4043
4044* ls/travis-p4-on-macos:
4045 travis-ci: fix Perforce install on macOS
4046
4047Merge branch 'vp/show-ref-verify-head'
4048
4049"git show-ref HEAD" used with "--verify" because the user is not
4050interested in seeing refs/remotes/origin/HEAD, and used with
4051"--head" because the user does not want HEAD to be filtered out,
4052i.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
4062Merge branch 'sb/retire-convert-objects-from-contrib'
4063
4064Remove an ancient tool left in contrib/.
4065
4066* sb/retire-convert-objects-from-contrib:
4067 contrib: remove git-convert-objects
4068
4069Merge branch 'sb/in-core-index-doc'
4070
4071Documentation 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
4079Merge branch 'js/remote-rename-with-half-configured-remote'
4080
4081With anticipatory tweaking for remotes defined in ~/.gitconfig
4082(e.g. "remote.origin.prune" set to true, even though there may or
4083may not actually be "origin" remote defined in a particular Git
4084repository), "git remote rename" and other commands misinterpreted
4085and 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
4091Merge branch 'jk/clear-delta-base-cache-fix'
4092
4093A crashing bug introduced in v2.11 timeframe has been found (it is
4094triggerable 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
4099Merge branch 'st/verify-tag'
4100
4101"git tag" and "git verify-tag" learned to put GPG verification
4102status 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
4112Merge branch 'js/mingw-isatty'
4113
4114An update to a topic that is already in 'master'.
4115
4116* js/mingw-isatty:
4117 mingw: follow-up to "replace isatty() hack"
4118
4119Merge branch 'js/sequencer-i-countdown-3'
4120
4121The sequencer machinery has been further enhanced so that a later
4122set 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
4147Merge branch 'jk/coding-guidelines-update'
4148
4149Developer doc update.
4150
4151* jk/coding-guidelines-update:
4152 CodingGuidelines: clarify multi-line brace style
4153
4154Merge 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
4166Merge branch 'js/exec-path-coverity-workaround'
4167
4168Code 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
4174Merge branch 'bw/push-submodule-only'
4175
4176"git submodule push" learned "--recurse-submodules=only option to
4177push 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
4184Merge branch 'jk/vreport-sanitize'
4185
4186An error message with an ASCII control character like '\r' in it
4187can alter the message to hide its early part, which is problematic
4188when a remote side gives such an error message that the local side
4189will relay with a "remote: " prefix.
4190
4191* jk/vreport-sanitize:
4192 vreport: sanitize ASCII control chars
4193 Revert "vreportf: avoid intermediate buffer"
4194
4195branch: implement '--format' option
4196
4197Implement the '--format' option provided by 'ref-filter'. This lets the
4198user list branches as per desired format similar to the implementation
4199in 'git for-each-ref'.
4200
4201Add tests and documentation for the same.
4202
4203Mentored-by: Christian Couder <christian.couder@gmail.com>
4204Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
4205Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
4206Signed-off-by: Junio C Hamano <gitster@pobox.com>
4207
4208branch: use ref-filter printing APIs
4209
4210Port branch.c to use ref-filter APIs for printing. This clears out
4211most of the code used in branch.c for printing and replaces them with
4212calls made to the ref-filter library.
4213
4214Introduce build_format() which gets the format required for printing
4215of refs. Make amendments to print_ref_list() to reflect these changes.
4216
4217The strings included in build_format() may not be safely quoted for
4218inclusion (i.e. it might contain '%' which needs to be escaped with an
4219additional '%'). Introduce quote_literal_for_format() as a helper
4220function which takes a string and returns a version of the string that
4221is safely quoted to be used in the for-each-ref format which is built
4222in build_format().
4223
4224Change calc_maxwidth() to also account for the length of HEAD ref, by
4225calling ref-filter:get_head_discription().
4226
4227Also change the test in t6040 to reflect the changes.
4228
4229Before this patch, all cross-prefix symrefs weren't shortened. Since
4230we're using ref-filter APIs, we shorten all symrefs by default. We also
4231allow the user to change the format if needed with the introduction of
4232the '--format' option in the next patch.
4233
4234Mentored-by: Christian Couder <christian.couder@gmail.com>
4235Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
4236Helped-by: Junio C Hamano <gitster@pobox.com>
4237Helped-by: Jeff King <peff@peff.net>
4238Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
4239Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
4240Signed-off-by: Junio C Hamano <gitster@pobox.com>
4241
4242branch, tag: use porcelain output
4243
4244Call ref-filter's setup_ref_filter_porcelain_msg() to enable
4245translated messages for the %(upstream:tack) atom. Although branch.c
4246doesn't currently use ref-filter's printing API's, this will ensure
4247that when it does in the future patches, we do not need to worry about
4248translation.
4249
4250Written-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
4251Mentored-by: Christian Couder <christian.couder@gmail.com>
4252Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
4253Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
4254Signed-off-by: Junio C Hamano <gitster@pobox.com>
4255
4256ref-filter: allow porcelain to translate messages in the output
4257
4258Introduce setup_ref_filter_porcelain_msg() so that the messages used in
4259the atom %(upstream:track) can be translated if needed. By default, keep
4260the messages untranslated, which is the right behavior for plumbing
4261commands. This is needed as we port branch.c to use ref-filter's
4262printing API's.
4263
4264Written-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
4265Mentored-by: Christian Couder <christian.couder@gmail.com>
4266Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
4267Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
4268Signed-off-by: Junio C Hamano <gitster@pobox.com>
4269
4270ref-filter: add an 'rstrip=<N>' option to atoms which deal with refnames
4271
4272Complimenting the existing 'lstrip=<N>' option, add an 'rstrip=<N>'
4273option which strips `<N>` slash-separated path components from the end
4274of the refname (e.g., `%(refname:rstrip=2)` turns `refs/tags/foo` into
4275`refs`).
4276
4277Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
4278Signed-off-by: Junio C Hamano <gitster@pobox.com>
4279
4280ref-filter: modify the 'lstrip=<N>' option to work with negative '<N>'
4281
4282Currently the 'lstrip=<N>' option only takes a positive value '<N>'
4283and strips '<N>' slash-separated path components from the left. Modify
4284the 'lstrip' option to also take a negative number '<N>' which would
4285strip from the left as necessary and _leave_ behind only 'N'
4286slash-separated path components from the right-most end.
4287
4288For e.g. %(refname:lstrip=-1) would make 'foo/goo/abc' into 'abc'.
4289
4290Add documentation and tests for the same.
4291
4292Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
4293Signed-off-by: Junio C Hamano <gitster@pobox.com>
4294
4295Documentation: implement linkgit macro for Asciidoctor
4296
4297AsciiDoc uses a configuration file to implement macros like linkgit,
4298while Asciidoctor uses Ruby extensions. Implement a Ruby extension that
4299implements the linkgit macro for Asciidoctor in the same way that
4300asciidoc.conf does for AsciiDoc. Adjust the Makefile to use it by
4301default.
4302
4303Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
4304Signed-off-by: Junio C Hamano <gitster@pobox.com>
4305
4306builtin/commit.c: switch to strbuf, instead of snprintf()
4307
4308Switch to dynamic allocation with strbuf, so we can avoid dealing
4309with magic numbers in the code and reduce the cognitive burden from
4310the programmers. The original code is correct, but programmers no
4311longer have to count bytes needed for static allocation to know that.
4312
4313As a side effect of this change, we also reduce the snprintf()
4314calls, that may silently truncate results if the programmer is not
4315careful.
4316
4317Helped-by: René Scharfe <l.s.r@web.de>
4318Helped-by: Junio C Hamano <gitster@pobox.com>
4319Helped-by: Jeff King <peff@peff.net>
4320Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
4321Signed-off-by: Junio C Hamano <gitster@pobox.com>
4322
4323urlmatch: split host and port fields in `struct url_info`
4324
4325The `url_info` structure contains information about a normalized URL
4326with the URL's components being represented by different fields. The
4327host and port part though are to be accessed by the same `host` field,
4328so that getting the host and/or port separately becomes more involved
4329than really necessary.
4330
4331To make the port more readily accessible, split up the host and port
4332fields. Namely, the `host_len` will not include the port length anymore
4333and a new `port_off` field has been added which includes the offset to
4334the port, if available.
4335
4336The only user of these fields is `url_normalize_1`. This change makes it
4337easier later on to treat host and port differently when introducing
4338globs for domains.
4339
4340Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
4341Signed-off-by: Junio C Hamano <gitster@pobox.com>
4342
4343urlmatch: enable normalization of URLs with globs
4344
4345The `url_normalize` function is used to validate and normalize URLs. As
4346such, it does not allow for some special characters to be part of the
4347URLs that are to be normalized. As we want to allow using globs in some
4348configuration keys making use of URLs, namely `http.<url>.<key>`, but
4349still normalize them, we need to somehow enable some additional allowed
4350characters.
4351
4352To do this without having to change all callers of `url_normalize`,
4353where most do not actually want globbing at all, we split off another
4354function `url_normalize_1`. This function accepts an additional
4355parameter `allow_globs`, which is subsequently called by `url_normalize`
4356with `allow_globs=0`.
4357
4358As of now, this function is not used with globbing enabled. A caller
4359will be added in the following commit.
4360
4361Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
4362Signed-off-by: Junio C Hamano <gitster@pobox.com>
4363
4364mailmap: add Patrick Steinhardt's work address
4365
4366Signed-off-by: Patrick Steinhardt <patrick.steinhardt@elego.de>
4367Signed-off-by: Junio C Hamano <gitster@pobox.com>
4368
4369update-ref: add test cases for bare repository
4370
4371The default behavior of update-ref to create reflogs differs in
4372repositories with worktree and bare ones. The existing tests cover only
4373the behavior of repositories with worktree.
4374
4375This commit adds tests that assert the correct behavior in bare
4376repositories 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
4381Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
4382Signed-off-by: Junio C Hamano <gitster@pobox.com>
4383
4384refs: add option core.logAllRefUpdates = always
4385
4386When core.logallrefupdates is true, we only create a new reflog for refs
4387that are under certain well-known hierarchies. The reason is that we
4388know that some hierarchies (like refs/tags) are not meant to change, and
4389that unknown hierarchies might not want reflogs at all (e.g., a
4390hypothetical refs/foo might be meant to change often and drop old
4391history immediately).
4392
4393However, sometimes it is useful to override this decision and simply log
4394for all refs, because the safety and audit trail is more important than
4395the performance implications of keeping the log around.
4396
4397This patch introduces a new "always" mode for the core.logallrefupdates
4398option which will log updates to everything under refs/, regardless
4399where in the hierarchy it is (we still will not log things like
4400ORIG_HEAD and FETCH_HEAD, which are known to be transient).
4401
4402Based-on-patch-by: Jeff King <peff@peff.net>
4403Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
4404Reviewed-by: Jeff King <peff@peff.net>
4405Signed-off-by: Junio C Hamano <gitster@pobox.com>
4406
4407l10n: bg: Updated Bulgarian translation (2913t+0f+0u)
4408
4409Signed-off-by: Alexander Shopov <ash@kambanaria.org>
4410
4411receive-pack: call string_list_clear() unconditionally
4412
4413string_list_clear() handles empty lists just fine, so remove the
4414redundant check.
4415
4416Signed-off-by: Rene Scharfe <l.s.r@web.de>
4417Signed-off-by: Junio C Hamano <gitster@pobox.com>
4418
4419Completion: Add support for --submodule=diff
4420
4421Teach git-completion.bash about the 'diff' option to 'git diff
4422--submodule=', which was added in Git 2.11.
4423
4424Signed-off-by: Peter Law <PeterJCLaw@gmail.com>
4425Signed-off-by: Junio C Hamano <gitster@pobox.com>
4426
4427checkout: convert post_checkout_hook() to struct object_id
4428
4429Signed-off-by: Rene Scharfe <l.s.r@web.de>
4430Signed-off-by: Junio C Hamano <gitster@pobox.com>
4431
4432use oidcpy() for copying hashes between instances of struct object_id
4433
4434Patch generated by Coccinelle and contrib/coccinelle/object_id.cocci.
4435
4436Signed-off-by: Rene Scharfe <l.s.r@web.de>
4437Signed-off-by: Junio C Hamano <gitster@pobox.com>
4438
4439use oid_to_hex_r() for converting struct object_id hashes to hex strings
4440
4441Patch generated by Coccinelle and contrib/coccinelle/object_id.cocci.
4442
4443Signed-off-by: Rene Scharfe <l.s.r@web.de>
4444Signed-off-by: Junio C Hamano <gitster@pobox.com>
4445
4446graph: use SWAP macro
4447
4448Exchange the values of graph->columns and graph->new_columns using the
4449macro SWAP instead of hand-rolled code. The result is shorter and
4450easier to read.
4451
4452This transformation was not done by the semantic patch swap.cocci
4453because there's an unrelated statement between the second and the last
4454step of the exchange, so it didn't match the expected pattern.
4455
4456Signed-off-by: Rene Scharfe <l.s.r@web.de>
4457Signed-off-by: Junio C Hamano <gitster@pobox.com>
4458
4459diff: use SWAP macro
4460
4461Use the macro SWAP to exchange the value of pairs of variables instead
4462of swapping them manually with the help of a temporary variable. The
4463resulting code is shorter and easier to read.
4464
4465The two cases were not transformed by the semantic patch swap.cocci
4466because it's extra careful and handles only cases where the types of all
4467variables are the same -- and here we swap two ints and use an unsigned
4468temporary variable for that. Nevertheless the conversion is safe, as
4469the value range is preserved with and without the patch.
4470
4471Signed-off-by: Rene Scharfe <l.s.r@web.de>
4472Signed-off-by: Junio C Hamano <gitster@pobox.com>
4473
4474use SWAP macro
4475
4476Apply the semantic patch swap.cocci to convert hand-rolled swaps to use
4477the macro SWAP. The resulting code is shorter and easier to read, the
4478object code is effectively unchanged.
4479
4480The patch for object.c had to be hand-edited in order to preserve the
4481comment before the change; Coccinelle tried to eat it for some reason.
4482
4483Signed-off-by: Rene Scharfe <l.s.r@web.de>
4484Signed-off-by: Junio C Hamano <gitster@pobox.com>
4485
4486apply: use SWAP macro
4487
4488Use the exported macro SWAP instead of the file-scoped macro swap and
4489remove the latter's definition.
4490
4491Signed-off-by: Rene Scharfe <l.s.r@web.de>
4492Signed-off-by: Junio C Hamano <gitster@pobox.com>
4493
4494add SWAP macro
4495
4496Add a macro for exchanging the values of variables. It allows users
4497to avoid repetition and takes care of the temporary variable for them.
4498It also makes sure that the storage sizes of its two parameters are the
4499same. Its memcpy(1) calls are optimized away by current compilers.
4500
4501Also add a conservative semantic patch for transforming only swaps of
4502variables of the same type.
4503
4504Signed-off-by: Rene Scharfe <l.s.r@web.de>
4505Signed-off-by: Junio C Hamano <gitster@pobox.com>
4506
4507merge-recursive: make "CONFLICT (rename/delete)" message show both paths
4508
4509The current message printed by "git merge-recursive" for a rename/delete
4510conflict is like this:
4511
4512CONFLICT (rename/delete): new-path deleted in HEAD and renamed in
4513other-branch. Version other-branch of new-path left in tree.
4514
4515To be more helpful, the message should show both paths of the rename and
4516state that the deletion occurred at the old path, not the new path. So
4517change the message to the following format:
4518
4519CONFLICT (rename/delete): old-path deleted in HEAD and renamed to
4520new-path in other-branch. Version other-branch of new-path left in tree.
4521
4522Since this doubles the number of cases in handle_change_delete (modify vs.
4523rename), refactor the code to halve the number of cases again by merging the
4524cases where o->branch1 has the change and o->branch2 has the delete with the
4525cases that are the other way around.
4526
4527Also add a simple test of the new conflict message.
4528
4529Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
4530Signed-off-by: Junio C Hamano <gitster@pobox.com>
4531
4532t0001: don't let a default ACL interfere with the umask test
4533
4534The "init creates a new deep directory (umask vs. shared)" test expects
4535the permissions of newly created files to be based on the umask, which
4536fails if a default ACL is inherited from the working tree for git. So
4537attempt to remove a default ACL if there is one. Same idea as
45388ed0a740dd42bd0724aebed6e3b07c4ea2a2d5e8. (I guess I'm the only one who
4539ever runs the test suite with a default ACL set.)
4540
4541Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
4542Signed-off-by: Junio C Hamano <gitster@pobox.com>
4543
4544config: add markup to core.logAllRefUpdates doc
4545
4546Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
4547Signed-off-by: Junio C Hamano <gitster@pobox.com>
4548
4549git-p4: fix git-p4.mapUser on Windows
4550
4551When running git-p4 on Windows, with multiple git-p4.mapUser entries in
4552git config - no user mappings are applied to the generated repository.
4553
4554Reproduction Steps:
4555
45561. Add multiple git-p4.mapUser entries to git config on a Windows
4557 machine
45582. Attempt to clone a p4 repository
4559
4560None of the user mappings will be applied.
4561
4562This issue is actually caused by gitConfigList, using split(os.linesep)
4563to convert the output of git config --get-all into a list. On Windows,
4564os.linesep is equal to '\r\n' - however git.exe returns configuration
4565with a line seperator of '\n'.
4566
4567This leads to the list returned by gitConfigList containing only one
4568element - which contains the full output of git config --get-all in
4569string form, which causes problems for the code introduced to
4570getUserMapFromPerforceServer in 10d08a149d ("git-p4: map a P4 user to
4571Git author name and email address", 2016-03-01)
4572
4573This issue should be caught by the test introduced in 10d08a1, however
4574would require running on Windows to reproduce.
4575
4576Using splitlines solves this issue, by splitting config on all
4577typical delimiters ('\n', '\r\n' etc.)
4578
4579Signed-off-by: George Vanburgh <gvanburgh@bloomberg.net>
4580Reviewed-by: Luke Diamand <luke@diamand.org>
4581Signed-off-by: Junio C Hamano <gitster@pobox.com>
4582
4583help: improve is_executable() on Windows
4584
4585On Windows, executables need to have the file extension `.exe`, or they
4586are not executables. Hence, to support scripts, Git for Windows also
4587looks for a she-bang line by opening the file in question, and executing
4588it via the specified script interpreter.
4589
4590To figure out whether files in the `PATH` are executable, `git help` has
4591code that imitates this behavior. With one exception: it *always* opens
4592the 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
4596Opening this many files leads to performance problems that are even more
4597serious when a virus scanner is running. Therefore, let's change the
4598code to look for the file extension `.exe` early, and avoid opening the
4599file altogether if we already know that it is executable.
4600
4601See the following measurements (in seconds) as an example, where we
4602execute a simple program that simply lists the directory contents and
4603calls open() on every listed file:
4604
4605With virus scanner running (coldcache):
4606
4607$ ./a.exe /libexec/git-core/
4608before open (git-add.exe): 0.000000
4609after open (git-add.exe): 0.412873
4610before open (git-annotate.exe): 0.000175
4611after open (git-annotate.exe): 0.397925
4612before open (git-apply.exe): 0.000243
4613after open (git-apply.exe): 0.399996
4614before open (git-archive.exe): 0.000147
4615after open (git-archive.exe): 0.397783
4616before open (git-bisect--helper.exe): 0.000160
4617after open (git-bisect--helper.exe): 0.397700
4618before open (git-blame.exe): 0.000160
4619after open (git-blame.exe): 0.399136
4620...
4621
4622With virus scanner running (hotcache):
4623
4624$ ./a.exe /libexec/git-core/
4625before open (git-add.exe): 0.000000
4626after open (git-add.exe): 0.000325
4627before open (git-annotate.exe): 0.000229
4628after open (git-annotate.exe): 0.000177
4629before open (git-apply.exe): 0.000167
4630after open (git-apply.exe): 0.000150
4631before open (git-archive.exe): 0.000154
4632after open (git-archive.exe): 0.000156
4633before open (git-bisect--helper.exe): 0.000132
4634after open (git-bisect--helper.exe): 0.000180
4635before open (git-blame.exe): 0.000718
4636after open (git-blame.exe): 0.000724
4637...
4638
4639With this patch I get:
4640
4641$ time git help git
4642Launching default browser to display HTML ...
4643
4644real 0m8.723s
4645user 0m0.000s
4646sys 0m0.000s
4647
4648and without
4649
4650$ time git help git
4651Launching default browser to display HTML ...
4652
4653real 1m37.734s
4654user 0m0.000s
4655sys 0m0.031s
4656
4657both tests with cold cache and giving the machine some time to settle
4658down after restart.
4659
4660[jes: adjusted the commit message]
4661
4662Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de>
4663Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4664Signed-off-by: Junio C Hamano <gitster@pobox.com>
4665
4666mingw: allow hooks to be .exe files
4667
4668Executable files in Windows need to have the extension '.exe', otherwise
4669they do not work. Extend the hooks to not just look at the hard coded
4670names, but also at the names extended by the custom STRIP_EXTENSION,
4671which is defined as '.exe' in Windows.
4672
4673Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4674Signed-off-by: Junio C Hamano <gitster@pobox.com>
4675
4676pack-objects: convert recursion to iteration in break_delta_chain()
4677
4678The break_delta_chain() function is recursive over the depth
4679of a given delta chain, which can lead to possibly running
4680out of stack space. Normally delta depth is quite small, but
4681if there _is_ a pathological case, this is where we would
4682find and fix it, so we should be more careful.
4683
4684We can do it without recursion at all, but there's a little
4685bit of cleverness needed to do so. It's easiest to explain
4686by covering the less-clever strategies first.
4687
4688The obvious thing to try is just keeping our own stack on
4689the heap. Whenever we would recurse, push the new entry onto
4690the stack and loop instead. But this gets tricky; when we
4691see 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
4693which case we dealt with its bases, and no we need to clear
4694the ACTIVE flag and compute its depth).
4695
4696You can hack around that in various ways, like keeping a
4697"just pushed" flag, but the logic gets muddled. However, we
4698can observe that we do all of our pushes first, and then all
4699of our pops afterwards. In other words, we can do this in
4700two passes. First dig down to the base, stopping when we see
4701a cycle, and pushing each item onto our stack. Then pop the
4702stack elements, clearing the ACTIVE flag and computing the
4703depth for each.
4704
4705This works, and is reasonably elegant. However, why do we
4706need the stack for the second pass? We can just walk the
4707delta pointers again. There's one complication. Popping the
4708stack went over our list in reverse, so we could compute the
4709depth of each entry by incrementing the depth of its base,
4710which we will have just computed. To go forward in the
4711second pass, we have to compute the total depth on the way
4712down, and then assign it as we go.
4713
4714This patch implements this final strategy, because it not
4715only keeps the memory off the stack, but it eliminates it
4716entirely. Credit for the cleverness in that approach goes to
4717Michael Haggerty; bugs are mine.
4718
4719Signed-off-by: Jeff King <peff@peff.net>
4720Signed-off-by: Junio C Hamano <gitster@pobox.com>
4721
4722pack-objects: enforce --depth limit in reused deltas
4723
4724Since 898b14c (pack-objects: rework check_delta_limit usage,
47252007-04-16), we check the delta depth limit only when
4726figuring out whether we should make a new delta. We don't
4727consider it at all when reusing deltas, which means that
4728packing once with --depth=250, and then again with
4729--depth=50, the second pack may still contain chains larger
4730than 50.
4731
4732This is generally considered a feature, as the results of
4733earlier high-depth repacks are carried forward, used for
4734serving fetches, etc. However, since we started using
4735cross-pack deltas in c9af708b1 (pack-objects: use mru list
4736when iterating over packs, 2016-08-11), we are no longer
4737bounded by the length of an existing delta chain in a single
4738pack.
4739
4740Here's one particular pathological case: a sequence of N
4741packs, each with 2 objects, the base of which is stored as a
4742delta in a previous pack. If we chain all the deltas
4743together, we have a cycle of length N. We break the cycle,
4744but the tip delta is still at depth N-1.
4745
4746This is less unlikely than it might sound. See the included
4747test for a reconstruction based on real-world actions. I
4748ran into such a case in the wild, where a client was rapidly
4749sending packs, and we had accumulated 10,000 before doing a
4750server-side repack. The pack that "git repack" tried to
4751generate had a very deep chain, which caused pack-objects to
4752run out of stack space in the recursive write_one().
4753
4754This patch bounds the length of delta chains in the output
4755pack based on --depth, regardless of whether they are caused
4756by cross-pack deltas or existed in the input packs. This
4757fixes 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
4773The implementation uses the existing search for delta
4774cycles. That lets us compute the depth of any node based on
4775the depth of its base, because we know the base is DFS_DONE
4776by the time we look at it (modulo any cycles in the graph,
4777but we know there cannot be any because we break them as we
4778see them).
4779
4780There is some subtlety worth mentioning, though. We record
4781the depth of each object as we compute it. It might seem
4782like we could save the per-object storage space by just
4783keeping track of the depth of our traversal (i.e., have
4784break_delta_chains() report how deep it went). But we may
4785visit an object through multiple delta paths, and on
4786subsequent paths we want to know its depth immediately,
4787without having to walk back down to its final base (doing so
4788would make our graph walk quadratic rather than linear).
4789
4790Likewise, one could try to record the depth not from the
4791base, but from our starting point (i.e., start
4792recursion_depth at 0, and pass "recursion_depth + 1" to each
4793invocation of break_delta_chains()). And then when
4794recursion_depth gets too big, we know that we must cut the
4795delta chain. But that technique is wrong if we do not visit
4796the nodes in topological order. In a chain A->B->C, it
4797if we visit "C", then "B", then "A", we will never recurse
4798deeper than 1 link (because we see at each node that we have
4799already visited it).
4800
4801Signed-off-by: Jeff King <peff@peff.net>
4802Signed-off-by: Junio C Hamano <gitster@pobox.com>
4803
4804doc: clarify distinction between sign-off and pgp-signing
4805
4806The documentation for submission discourages pgp-signing, but demands
4807a proper sign-off by contributors. However, when skimming the headings,
4808the wording of the section for sign-off could mistakenly be understood
4809as concerning pgp-signing. Thus, new contributors could oversee the
4810necessary sign-off.
4811
4812This commit improves the wording such that the section about sign-off
4813cannot be misunderstood as pgp-signing. In addition, the paragraph about
4814pgp-signing is changed such that it avoids the impression that
4815pgp-signing could be relevant at later stages of the submission.
4816
4817Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
4818Helped-by: Philip Oakley <philipoakley@iee.org>
4819Helped-by: Stefan Beller <sbeller@google.com>
4820Signed-off-by: Junio C Hamano <gitster@pobox.com>
4821
4822test-lib: on FreeBSD, look for unzip(1) in /usr/local/bin/
4823
4824Eric Wong reported that while FreeBSD has a /usr/bin/unzip, it uses
4825different semantics from those that are needed by Git's tests: When
4826passing 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
4828attribute.
4829
4830The common work-around is to install Info-Zip on FreeBSD, into
4831/usr/local/bin/.
4832
4833Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4834Tested-by: Eric Wong <e@80x24.org>
4835Signed-off-by: Junio C Hamano <gitster@pobox.com>
4836
4837t/Makefile: add a rule to re-run previously-failed tests
4838
4839This patch automates the process of determining which tests failed
4840previously and re-running them.
4841
4842While developing patch series, it is a good practice to run the test
4843suite from time to time, just to make sure that obvious bugs are caught
4844early. With complex patch series, it is common to run `make -j15 -k
4845test`, i.e. run the tests in parallel and *not* stop at the first
4846failing test but continue. This has the advantage of identifying
4847possibly multiple problems in one big test run.
4848
4849It is particularly important to reduce the turn-around time thusly on
4850Windows, where the test suite spends 45 minutes on the computer on which
4851this patch was developed.
4852
4853It is the most convenient way to determine which tests failed after
4854running the entire test suite, in parallel, to look for left-over "trash
4855directory.t*" subdirectories in the t/ subdirectory. However, those
4856directories might live outside t/ when overridden using the
4857--root=<directory> option, to which the Makefile has no access. The next
4858best method is to grep explicitly for failed tests in the test-results/
4859directory, which the Makefile *can* access.
4860
4861Please note that the often-recommended `prove` tool requires Perl, and
4862that opens a whole new can of worms on Windows. As no native Windows Perl
4863comes with Subversion bindings, we have to use a Perl in Git for Windows
4864that uses the POSIX emulation layer named MSYS2 (which is a portable
4865version of Cygwin). When using this emulation layer under stress, e.g.
4866when running massively-parallel tests, unexplicable crashes occur quite
4867frequently, and instead of having a solution to the original problem, the
4868developer now has an additional, quite huge problem. For that reason, this
4869developer rejected `prove` as a solution and went with this patch instead.
4870
4871Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4872Reviewed-by: Jeff King <peff@peff.net>
4873Signed-off-by: Junio C Hamano <gitster@pobox.com>
4874
4875use absolute_pathdup()
4876
4877Apply the semantic patch for converting callers that duplicate the
4878result of absolute_path() to call absolute_pathdup() instead, which
4879avoids an extra string copy to a static buffer.
4880
4881Signed-off-by: Rene Scharfe <l.s.r@web.de>
4882Signed-off-by: Junio C Hamano <gitster@pobox.com>
4883
4884abspath: add absolute_pathdup()
4885
4886Add a function that returns a buffer containing the absolute path of its
4887argument and a semantic patch for its intended use. It avoids an extra
4888string copy to a static buffer.
4889
4890Signed-off-by: Rene Scharfe <l.s.r@web.de>
4891Signed-off-by: Junio C Hamano <gitster@pobox.com>
4892
4893status: be prepared for not-yet-started interactive rebase
4894
4895Some developers might want to call `git status` in a working
4896directory where they just started an interactive rebase, but the
4897edit script is still opened in the editor.
4898
4899Let's show a meaningful message in such cases.
4900
4901Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4902Signed-off-by: Junio C Hamano <gitster@pobox.com>
4903
4904connect: rename tortoiseplink and putty variables
4905
4906One of these two may have originally been named after "what exact
4907SSH implementation do we have?" so that we can tweak the command
4908line options for that exact implementation. But "putty=1" no longer
4909means "We are using the plink SSH implementation that comes with
4910PuTTY" these days. It is set when we guess that either PuTTY plink
4911or Tortoiseplink is in use.
4912
4913Rename them after what effect is desired. The current 'putty'
4914option is about using "-P <port>" when OpenSSH would use "-p <port>",
4915so rename it to 'port_option' whose value is either 'p' or 'P". The
4916other one is about passing an extra command line option "-batch",
4917so rename it to 'needs_batch'.
4918
4919[jes: wrapped overly-long line]
4920
4921Signed-off-by: Junio C Hamano <gitster@pobox.com>
4922Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4923Signed-off-by: Junio C Hamano <gitster@pobox.com>
4924
4925submodule update: run custom update script for initial populating as well
4926
4927In 1b4735d9f3 (submodule: no [--merge|--rebase] when newly cloned,
49282011-02-17), all actions were defaulted to checkout for populating
4929a submodule initially, because merging or rebasing makes no sense
4930in that situation.
4931
4932Other commands however do make sense, such as the custom command
4933that was added later (6cb5728c43, submodule update: allow custom
4934command to update submodule working tree, 2013-07-03).
4935
4936I am unsure about the "none" command, as I can see an initial
4937checkout there as a useful thing. On the other hand going strictly
4938by our own documentation, we should do nothing in case of "none"
4939as well, because the user asked for it.
4940
4941Reported-by: Han-Wen Nienhuys <hanwen@google.com>
4942Signed-off-by: Stefan Beller <sbeller@google.com>
4943Signed-off-by: Junio C Hamano <gitster@pobox.com>
4944
4945submodule absorbing: fix worktree/gitdir pointers recursively for non-moves
4946
4947Consider having a submodule 'sub' and a nested submodule at 'sub/nested'.
4948When nested is already absorbed into sub, but sub is not absorbed into
4949its superproject, then we need to fixup the gitfile and core.worktree
4950setting for 'nested' when absorbing 'sub', but we do not need to move
4951its git dir around.
4952
4953Previously 'nested's gitfile contained "gitdir: ../.git/modules/nested";
4954it has to be corrected to "gitdir: ../../.git/modules/sub1/modules/nested".
4955
4956An alternative I considered to do this work lazily, i.e. when resolving
4957"../.git/modules/nested", we would notice the ".git" being a gitfile
4958linking to another path. That seemed to be robuster by design, but harder
4959to get the implementation right. Maybe we have to do that anyway once we
4960try to have submodules and worktrees working nicely together, but for now
4961just produce 'correct' (i.e. direct) pointers.
4962
4963Signed-off-by: Stefan Beller <sbeller@google.com>
4964Signed-off-by: Junio C Hamano <gitster@pobox.com>
4965
4966cache.h: expose the dying procedure for reading gitlinks
4967
4968In a later patch we want to react to only a subset of errors, defaulting
4969the rest to die as usual. Separate the block that takes care of dying
4970into its own function so we have easy access to it.
4971
4972Signed-off-by: Stefan Beller <sbeller@google.com>
4973Signed-off-by: Junio C Hamano <gitster@pobox.com>
4974
4975setup: add gentle version of resolve_git_dir
4976
4977This follows a93bedada (setup: add gentle version of read_gitfile,
49782015-06-09), and assumes the same reasoning. resolve_git_dir is unsuited
4979for speculative calls, so we want to use the gentle version to find out
4980about potential errors.
4981
4982Signed-off-by: Stefan Beller <sbeller@google.com>
4983Signed-off-by: Junio C Hamano <gitster@pobox.com>
4984
4985fsck: lazily load types under --connectivity-only
4986
4987The recent fixes to "fsck --connectivity-only" load all of
4988the objects with their correct types. This keeps the
4989connectivity-only code path close to the regular one, but it
4990also introduces some unnecessary inefficiency. While getting
4991the type of an object is cheap compared to actually opening
4992and parsing the object (as the non-connectivity-only case
4993would do), it's still not free.
4994
4995For reachable non-blob objects, we end up having to parse
4996them later anyway (to see what they point to), making our
4997type lookup here redundant.
4998
4999For unreachable objects, we might never hit them at all in
5000the reachability traversal, making the lookup completely
5001wasted. And in some cases, we might have quite a few
5002unreachable objects (e.g., when alternates are used for
5003shared object storage between repositories, it's normal for
5004there to be objects reachable from other repositories but
5005not the one running fsck).
5006
5007The comment in mark_object_for_connectivity() claims two
5008benefits 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
5044Here are before and after timings for an extreme case with
5045~5M reachable objects and another ~12M unreachable (it's the
5046torvalds/linux repository on GitHub, connected to shared
5047storage 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
5061Signed-off-by: Jeff King <peff@peff.net>
5062Signed-off-by: Junio C Hamano <gitster@pobox.com>
5063
5064fsck: move typename() printing to its own function
5065
5066When an object has a problem, we mention its type. But we do
5067so by feeding the result of typename() directly to
5068fprintf(). This is potentially dangerous because typename()
5069can return NULL for some type values (like OBJ_NONE).
5070
5071It's doubtful that this can be triggered in practice with
5072the current code, so this is probably not fixing a bug. But
5073it future-proofs us against modifications that make things
5074like OBJ_NONE more likely (and gives future patches a
5075central point to handle them).
5076
5077Signed-off-by: Jeff King <peff@peff.net>
5078Signed-off-by: Junio C Hamano <gitster@pobox.com>
5079
5080relink: really remove the command
5081
5082The files in contrib/examples are meant to illustrate "you could
5083combine plumbing commands to implement something like these"; this
5084is an opposite and is an example of what not to do, e.g. accessing
5085the object store directly bypassing Git.
5086
5087Remove it.
5088
5089Suggested-by: Jeff King <peff@peff.net>
5090Signed-off-by: Junio C Hamano <gitster@pobox.com>
5091
5092relink: retire the command
5093
5094Back in the olden days, when all objects were loose and rubber boots were
5095made out of wood, it made sense to try to share (immutable) objects
5096between repositories.
5097
5098Ever since the arrival of pack files, it is but an anachronism.
5099
5100Let's move the script to the contrib/examples/ directory and no longer
5101offer it.
5102
5103Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
5104Signed-off-by: Junio C Hamano <gitster@pobox.com>
5105
5106connect: handle putty/plink also in GIT_SSH_COMMAND
5107
5108Git for Windows has special support for the popular SSH client PuTTY:
5109when using PuTTY's non-interactive version ("plink.exe"), we use the -P
5110option to specify the port rather than OpenSSH's -p option. TortoiseGit
5111ships with its own, forked version of plink.exe, that adds support for
5112the -batch option, and for good measure we special-case that, too.
5113
5114However, this special-casing of PuTTY only covers the case where the
5115user overrides the SSH command via the environment variable GIT_SSH
5116(which allows specifying the name of the executable), not
5117GIT_SSH_COMMAND (which allows specifying a full command, including
5118additional command-line options).
5119
5120When users want to pass any additional arguments to (Tortoise-)Plink,
5121such as setting a private key, they are required to either use a shell
5122script named plink or tortoiseplink or duplicate the logic that is
5123already in Git for passing the correct style of command line arguments,
5124which can be difficult, error prone and annoying to get right.
5125
5126This patch simply reuses the existing logic and expands it to cover
5127GIT_SSH_COMMAND, too.
5128
5129Note: it may look a little heavy-handed to duplicate the entire
5130command-line and then split it, only to extract the name of the
5131executable. However, this is not a performance-critical code path, and
5132the code is much more readable this way.
5133
5134Signed-off-by: Segev Finer <segev208@gmail.com>
5135Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
5136Signed-off-by: Junio C Hamano <gitster@pobox.com>
5137
5138difftool: hack around -Wzero-length-format warning
5139
5140Building with "gcc -Wall" will complain that the format in:
5141
5142 warning("")
5143
5144is empty. Which is true, but the warning is over-eager. We
5145are calling the function for its side effect of printing
5146"warning:", even with an empty string.
5147
5148Our DEVELOPER Makefile knob disables the warning, but not
5149everybody uses it. Let's silence the warning in the code so
5150that nobody reports it or tries to "fix" it.
5151
5152Signed-off-by: Jeff King <peff@peff.net>
5153Signed-off-by: Junio C Hamano <gitster@pobox.com>
5154
5155unpack-trees: support super-prefix option
5156
5157In the future we want to support working tree operations within submodules,
5158e.g. "git checkout --recurse-submodules", which will update the submodule
5159to the commit as recorded in its superproject. In the submodule the
5160unpack-tree operation is carried out as usual, but the reporting to the
5161user needs to prefix any path with the superproject. The mechanism for
5162this is the super-prefix. (see 74866d757, git: make super-prefix option)
5163
5164Add support for the super-prefix option for commands that unpack trees
5165by wrapping any path output in unpacking trees in the newly introduced
5166super_prefixed function. This new function prefixes any path with the
5167super-prefix if there is one. Assuming the submodule case doesn't happen
5168in the majority of the cases, we'd want to have a fast behavior for no
5169super prefix, i.e. no reallocation/copying, but just returning path.
5170
5171Another aspect of introducing the `super_prefixed` function is to consider
5172who owns the memory and if this is the right place where the path gets
5173modified. As the super prefix ought to change the output behavior only and
5174not the actual unpack tree part, it is fine to be that late in the line.
5175As we get passed in 'const char *path', we cannot change the path itself,
5176which means in case of a super prefix we have to copy over the path.
5177We need two static buffers in that function as the error messages
5178contain at most two paths.
5179
5180For testing purposes enable it in read-tree, which has no output
5181of paths other than an unpack-trees.c. These are all converted in
5182this patch.
5183
5184Signed-off-by: Stefan Beller <sbeller@google.com>
5185Signed-off-by: Junio C Hamano <gitster@pobox.com>
5186
5187t1450: use "mv -f" within loose object directory
5188
5189The loose objects are created with mode 0444. That doesn't
5190prevent them being overwritten by rename(), but some
5191versions of "mv" will be extra careful and prompt the user,
5192even without "-i".
5193
5194Reportedly macOS does this, at least in the Travis builds.
5195The prompt reads from /dev/null, defaulting to "no", and the
5196object isn't moved. Then to make matters even more
5197interesting, it still returns "0" and the rest of the test
5198proceeds, but with a broken setup.
5199
5200We can work around it by using "mv -f" to override the
5201prompt. This should work as it's already used in t5504 for
5202the same purpose.
5203
5204Signed-off-by: Jeff King <peff@peff.net>
5205Signed-off-by: Junio C Hamano <gitster@pobox.com>
5206
5207Merge 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
5212show-ref: remove a stale comment
5213
5214When cf0adba788 ("Store peeled refs in packed-refs file.",
52152006-11-19) made the command to die with a message on error even
5216when --quiet is passed, it left the comment to say it changed the
5217semantics. But that kind of information belongs to the log message,
5218not in-code comment. Besides, the behaviour after the change has
5219been the established one for the past 10 years ;-)
5220
5221Signed-off-by: Junio C Hamano <gitster@pobox.com>
5222
5223describe: teach describe negative pattern matches
5224
5225Teach git-describe the `--exclude` option which will allow specifying
5226a glob pattern of tags to ignore. This can be combined with the
5227`--match` patterns to enable more flexibility in determining which tags
5228to consider.
5229
5230For example, suppose you wish to find the first official release tag
5231that contains a certain commit. If we assume that official release tags
5232are of the form "v*" and pre-release candidates include "*rc*" in their
5233name, we can now find the first release tag that introduces the commit
5234abcdef:
5235
5236 git describe --contains --match="v*" --exclude="*rc*" abcdef
5237
5238Add documentation, tests, and completion for this change.
5239
5240Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
5241Signed-off-by: Junio C Hamano <gitster@pobox.com>
5242
5243describe: teach --match to accept multiple patterns
5244
5245Teach `--match` to be accepted multiple times, accumulating a list of
5246patterns to match into a string list. Each pattern is inclusive, such
5247that a tag need only match one of the provided patterns to be
5248considered for matching.
5249
5250This extension is useful as it enables more flexibility in what tags
5251match, and may avoid the need to run the describe command multiple
5252times to get the same result.
5253
5254Add tests and update the documentation for this change.
5255
5256Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
5257Signed-off-by: Junio C Hamano <gitster@pobox.com>
5258
5259name-rev: add support to exclude refs by pattern match
5260
5261Extend git-name-rev to support excluding refs which match shell patterns
5262using --exclude. These patterns can be used to limit the scope of refs
5263by excluding any ref that matches one of the --exclude patterns. A ref
5264will only be used for naming when it matches at least one --refs pattern
5265but does not match any of the --exclude patterns. Thus, --exclude
5266patterns are given precedence over --refs patterns.
5267
5268For example, suppose you wish to name a series of commits based on an
5269official release tag of the form "v*" but excluding any pre-release tags
5270which match "*rc*". You can use the following to do so:
5271
5272 git name-rev --refs="v*" --exclude="*rc*" --all
5273
5274Add tests and update Documentation for this change.
5275
5276Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
5277Signed-off-by: Junio C Hamano <gitster@pobox.com>
5278
5279name-rev: extend --refs to accept multiple patterns
5280
5281Teach git name-rev to take multiple --refs stored as a string list of
5282patterns. The list of patterns will be matched inclusively, and each ref
5283only needs to match one pattern to be included. A ref will only be
5284excluded if it does not match any of the given patterns. Additionally,
5285if any of the patterns would allow abbreviation, then we will abbreviate
5286the ref, even if another pattern is more strict and would not have
5287allowed abbreviation on its own.
5288
5289Add tests and documentation for this change. The tests expected output
5290is dynamically generated. This is in order to avoid hard-coding
5291a commit object name in the test results (as the expected output is to
5292simply leave the commit object unnamed).
5293
5294Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
5295Signed-off-by: Junio C Hamano <gitster@pobox.com>
5296
5297log --graph: customize the graph lines with config log.graphColors
5298
5299If you have a 256 colors terminal (or one with true color support), then
5300the predefined 12 colors seem limited. On the other hand, you don't want
5301to draw graph lines with every single color in this mode because the two
5302colors could look extremely similar. This option allows you to hand pick
5303the colors you want.
5304
5305Even with standard terminal, if your background color is neither black
5306or white, then the graph line may match your background and become
5307hidden. You can exclude your background color (or simply the colors you
5308hate) with this.
5309
5310Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
5311Signed-off-by: Junio C Hamano <gitster@pobox.com>
5312
5313Seventh batch for 2.12
5314
5315Signed-off-by: Junio C Hamano <gitster@pobox.com>
5316
5317Merge branch 'ws/request-pull-code-cleanup'
5318
5319Code clean-up.
5320
5321* ws/request-pull-code-cleanup:
5322 request-pull: drop old USAGE stuff
5323
5324Merge branch 'rh/diff-orderfile-doc'
5325
5326Documentation 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
5332Merge branch 'sb/cd-then-git-can-be-written-as-git-c'
5333
5334Test 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
5339Merge branch 'ad/bisect-terms'
5340
5341Documentation fix.
5342
5343* ad/bisect-terms:
5344 Documentation/bisect: improve on (bad|new) and (good|bad)
5345
5346Merge branch 'sg/fix-versioncmp-with-common-suffix'
5347
5348The prereleaseSuffix feature of version comparison that is used in
5349"git tag -l" did not correctly when two or more prereleases for the
5350same release were present (e.g. when 2.0, 2.0-beta1, and 2.0-beta2
5351are 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
5363Merge branch 'vn/diff-ihc-config'
5364
5365"git diff" learned diff.interHunkContext configuration variable
5366that gives the default value for its --inter-hunk-context option.
5367
5368* vn/diff-ihc-config:
5369 diff: add interhunk context config option
5370
5371Merge branch 'sb/submodule-init'
5372
5373Error message fix.
5374
5375* sb/submodule-init:
5376 submodule update --init: display correct path from submodule
5377
5378Merge branch 'sb/submodule-embed-gitdir'
5379
5380Help-text fix.
5381
5382* sb/submodule-embed-gitdir:
5383 submodule absorbgitdirs: mention in docstring help
5384
5385Merge branch 'sb/submodule-config-tests'
5386
5387Test updates.
5388
5389* sb/submodule-config-tests:
5390 t7411: test lookup of uninitialized submodules
5391 t7411: quote URLs
5392
5393Merge branch 'jk/grep-e-could-be-extended-beyond-posix'
5394
5395Tighten a test to avoid mistaking an extended ERE regexp engine as
5396a PRE regexp engine.
5397
5398* jk/grep-e-could-be-extended-beyond-posix:
5399 t7810: avoid assumption about invalid regex syntax
5400
5401Merge branch 'bw/read-blob-data-does-not-modify-index-state'
5402
5403Code clean-up.
5404
5405* bw/read-blob-data-does-not-modify-index-state:
5406 index: improve constness for reading blob data
5407
5408show-ref: remove dead `if (verify)' check
5409
5410As show_ref() is only ever called on the path where --verify is not
5411specified, `verify' can never possibly be true here.
5412
5413Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
5414Signed-off-by: Junio C Hamano <gitster@pobox.com>
5415
5416show-ref: detect dangling refs under --verify as well
5417
5418Move detection of dangling refs into show_one(), so that they are
5419detected when --verify is present as well as when it is absent.
5420
5421Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
5422Signed-off-by: Junio C Hamano <gitster@pobox.com>
5423
5424show-ref: move --quiet handling into show_one()
5425
5426Do the same with --quiet as was done with -d, to remove the need to
5427perform this check at show_one()'s call site from the --verify branch.
5428
5429Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
5430Signed-off-by: Junio C Hamano <gitster@pobox.com>
5431
5432show-ref: allow -d to work with --verify
5433
5434Move 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
5436the user wishes to avoid the costly iteration of refs.
5437
5438Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
5439Signed-off-by: Junio C Hamano <gitster@pobox.com>
5440
5441show-ref: accept HEAD with --verify
5442
5443Previously, when --verify was specified, show-ref would use a separate
5444code path which did not handle HEAD and treated it as an invalid
5445ref. Thus, "git show-ref --verify HEAD" (where "--verify" is used
5446because the user is not interested in seeing refs/remotes/origin/HEAD)
5447did not work as expected.
5448
5449Instead of insisting that the input begins with "refs/", allow "HEAD"
5450as well in the codepath that handles "--verify", so that all valid
5451full refnames including HEAD are passed to the same output machinery.
5452
5453Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
5454Signed-off-by: Junio C Hamano <gitster@pobox.com>
5455
5456ref-filter: use QSORT_S in ref_array_sort()
5457
5458Pass the array of sort keys to compare_refs() via the context parameter
5459of qsort_s() instead of using a global variable; that's cleaner and
5460simpler. If ref_array_sort() is to be called from multiple parallel
5461threads then care still needs to be taken that the global variable
5462used_atom is not modified concurrently.
5463
5464Signed-off-by: Rene Scharfe <l.s.r@web.de>
5465Signed-off-by: Junio C Hamano <gitster@pobox.com>
5466
5467string-list: use QSORT_S in string_list_sort()
5468
5469Pass the comparison function to cmp_items() via the context parameter of
5470qsort_s() instead of using a global variable. That allows calling
5471string_list_sort() from multiple parallel threads.
5472
5473Our qsort_s() in compat/ is slightly slower than qsort(1) from glibc
54742.24 for sorting lots of lines:
5475
5476Test HEAD^ HEAD
5477---------------------------------------------------------------------
54780071.2: sort(1) 0.10(0.22+0.01) 0.09(0.21+0.00) -10.0%
54790071.3: string_list_sort() 0.16(0.15+0.01) 0.17(0.15+0.00) +6.3%
5480
5481GNU sort(1) version 8.26 is significantly faster because it uses
5482multiple parallel threads; with the unportable option --parallel=1 it
5483becomes slower:
5484
5485Test HEAD^ HEAD
5486--------------------------------------------------------------------
54870071.2: sort(1) 0.21(0.18+0.01) 0.20(0.18+0.01) -4.8%
54880071.3: string_list_sort() 0.16(0.13+0.02) 0.17(0.15+0.01) +6.3%
5489
5490There is some instability -- the numbers for the sort(1) check shouldn't
5491be affected by this patch. Anyway, the performance of our qsort_s()
5492implementation is apparently good enough, at least for this test.
5493
5494Signed-off-by: Rene Scharfe <l.s.r@web.de>
5495Signed-off-by: Junio C Hamano <gitster@pobox.com>
5496
5497perf: add basic sort performance test
5498
5499Add a sort command to test-string-list that reads lines from stdin,
5500stores them in a string_list and then sorts it. Use it in a simple
5501perf test script to measure the performance of string_list_sort().
5502
5503Signed-off-by: Rene Scharfe <l.s.r@web.de>
5504Signed-off-by: Junio C Hamano <gitster@pobox.com>
5505
5506add QSORT_S
5507
5508Add the macro QSORT_S, a convenient wrapper for qsort_s() that infers
5509the size of the array elements and dies on error.
5510
5511Basically all possible errors are programming mistakes (passing NULL as
5512base of a non-empty array, passing NULL as comparison function,
5513out-of-bounds accesses), so terminating the program should be acceptable
5514for most callers.
5515
5516Signed-off-by: Rene Scharfe <l.s.r@web.de>
5517Signed-off-by: Junio C Hamano <gitster@pobox.com>
5518
5519compat: add qsort_s()
5520
5521The function qsort_s() was introduced with C11 Annex K; it provides the
5522ability to pass a context pointer to the comparison function, supports
5523the convention of using a NULL pointer for an empty array and performs a
5524few safety checks.
5525
5526Add an implementation based on compat/qsort.c for platforms that lack a
5527native standards-compliant qsort_s() (i.e. basically everyone). It
5528doesn't perform the full range of possible checks: It uses size_t
5529instead of rsize_t and doesn't check nmemb and size against RSIZE_MAX
5530because we probably don't have the restricted size type defined. For
5531the same reason it returns int instead of errno_t.
5532
5533Signed-off-by: Rene Scharfe <l.s.r@web.de>
5534Signed-off-by: Junio C Hamano <gitster@pobox.com>
5535
5536Makefile: add a knob to enable the use of Asciidoctor
5537
5538While Git has traditionally built its documentation using AsciiDoc, some
5539people wish to use Asciidoctor for speed or other reasons. Add a
5540Makefile knob, USE_ASCIIDOCTOR, that sets various options in order to
5541produce acceptable output. For HTML output, XHTML5 was chosen, since
5542the AsciiDoc options also produce XHTML, albeit XHTML 1.1.
5543
5544Asciidoctor does not have built-in support for the linkgit macro, but it
5545is available using the Asciidoctor Extensions Lab. Add a macro to
5546enable the use of this extension if it is available. Without it, the
5547linkgit macros are emitted into the output.
5548
5549Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
5550Signed-off-by: Junio C Hamano <gitster@pobox.com>
5551
5552Documentation: move dblatex arguments into variable
5553
5554Our dblatex invocation uses several style components from the AsciiDoc
5555distribution, but those components are not available when building with
5556Asciidoctor. Move the command line arguments into a variable so it can
5557be overridden by the user or makefile configuration options.
5558
5559Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
5560Signed-off-by: Junio C Hamano <gitster@pobox.com>
5561
5562Documentation: add XSLT to fix DocBook for Texinfo
5563
5564There are two ways to create a section in a reference document (i.e.,
5565manpage) in DocBook 4: refsection elements and refsect, refsect2, and
5566refsect3 elements. Either form is acceptable as of DocBook 4.2, but
5567they cannot be mixed. Prior to DocBook 4.2, only the numbered forms
5568were acceptable.
5569
5570docbook2texi only accepts the numbered forms, and this has not generally
5571been a problem, since AsciiDoc produces the numbered forms.
5572Asciidoctor, on the other hand, uses a shared backend for DocBook 4 and
55735, and uses the unnumbered refsection elements instead.
5574
5575If we don't convert the unnumbered form to the numbered form,
5576docbook2texi omits section headings, which is undesirable. Add an XSLT
5577stylesheet to transform the unnumbered forms to the numbered forms
5578automatically, and preprocess the DocBook XML as part of the
5579transformation to Texinfo format.
5580
5581Note that this transformation is only necessary for Texinfo, since
5582docbook2texi provides its own stylesheets. The DocBook stylesheets,
5583which we use for other formats, provide the full range of DocBook 4 and
55845 compatibility, and don't have this issue.
5585
5586Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
5587Signed-off-by: Junio C Hamano <gitster@pobox.com>
5588
5589Documentation: sort sources for gitman.texi
5590
5591Sorting the sources makes it easier to compare the output using diff.
5592In addition, it aids groups creating reproducible builds, as the order
5593of the files is no longer dependent on the file system or other
5594irrelevant factors.
5595
5596Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
5597Signed-off-by: Junio C Hamano <gitster@pobox.com>
5598
5599Documentation: remove unneeded argument in cat-texi.perl
5600
5601The newly-added use of the warnings pragma exposes that the $menu[0]
5602argument to printf has long been silently ignored, since there is no
5603format specifier for it. It doesn't appear that the argument is
5604actually needed, either: there is no reason to insert the name of one
5605particular documentation page anywhere in the header that's being
5606generated.
5607
5608Remove the unused argument, and since the format specification
5609functionality is no longer needed, convert the printf to a simple print.
5610
5611Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
5612Signed-off-by: Junio C Hamano <gitster@pobox.com>
5613
5614Documentation: modernize cat-texi.perl
5615
5616Good style for Perl includes using the strict and warnings pragmas, and
5617preferring lexical file handles over bareword file handles. Using
5618lexical file handles necessitates being explicit when $_ is printed, so
5619that Perl does not get confused and instead print the glob ref.
5620
5621The benefit of this modernization is that a formerly obscured bug is now
5622visible, which will be fixed in a followup patch.
5623
5624Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
5625Signed-off-by: Junio C Hamano <gitster@pobox.com>
5626
5627Documentation: fix warning in cat-texi.perl
5628
5629Newer versions of Perl produce the warning "Unescaped left brace in
5630regex is deprecated, passed through in regex" when an unescaped left
5631brace occurs in a regex. Escape the brace to avoid this warning.
5632
5633Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
5634Signed-off-by: Junio C Hamano <gitster@pobox.com>
5635
5636travis-ci: fix Perforce install on macOS
5637
5638The `perforce` and `perforce-server` package were moved from brew [1][2]
5639to cask [3]. Teach TravisCI the new location.
5640
5641Perforce updates their binaries without version bumps. That made the
5642brew install (legitimately!) fail due to checksum mismatches. The
5643workaround is not necessary anymore as Cask [4] allows to disable the
5644checksum 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
5651Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
5652Signed-off-by: Junio C Hamano <gitster@pobox.com>
5653
5654contrib: remove git-convert-objects
5655
5656git-convert-objects, originally named git-convert-cache was used in
5657early 2005 to convert ancient repositories where objects are named
5658after the hash of their compressed contents to the current object
5659naming sheme where they are named after the hash of their pre-compression
5660contents.
5661
5662By now the need for conversion of the very early repositories is
5663less relevant, we no longer need to keep it in contrib; remove it.
5664
5665Signed-off-by: Stefan Beller <sbeller@google.com>
5666Signed-off-by: Junio C Hamano <gitster@pobox.com>
5667
5668remote rename: more carefully determine whether a remote is configured
5669
5670One of the really nice features of the ~/.gitconfig file is that users
5671can override defaults by their own preferred settings for all of their
5672repositories.
5673
5674One 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
5679and from now on all "origin" remotes would be pruned automatically when
5680fetching into the local repository.
5681
5682There is just one catch: now Git thinks that the "origin" remote is
5683configured, even if the repository config has no [remote "origin"]
5684section at all, as it does not realize that the "prune" setting was
5685configured globally and that there really is no "origin" remote
5686configured in this repository.
5687
5688That is a problem e.g. when renaming a remote to a new name, when Git
5689may be fooled into thinking that there is already a remote of that new
5690name.
5691
5692Let's fix this by paying more attention to *where* the remote settings
5693came from: if they are configured in the local repository config, we
5694must not overwrite them. If they were configured elsewhere, we cannot
5695overwrite them to begin with, as we only write the repository config.
5696
5697There is only one caller of remote_is_configured() (in `git fetch`) that
5698may want to take remotes into account even if they were configured
5699outside the repository config; all other callers essentially try to
5700prevent the Git command from overwriting settings in the repository
5701config.
5702
5703To accommodate that fact, the remote_is_configured() function now
5704requires a parameter that states whether the caller is interested in all
5705remotes, or only in those that were configured in the repository config.
5706
5707Many thanks to Jeff King whose tireless review helped with settling for
5708nothing less than the current strategy.
5709
5710This fixes https://github.com/git-for-windows/git/issues/888
5711
5712Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
5713Signed-off-by: Junio C Hamano <gitster@pobox.com>
5714
5715remote rename: demonstrate a bogus "remote exists" bug
5716
5717Some users like to set `remote.origin.prune = true` in their ~/.gitconfig
5718so that all of their repositories use that default.
5719
5720However, our code is ill-prepared for this, mistaking that single entry to
5721mean that there is already a remote of the name "origin", even if there is
5722not.
5723
5724This patch adds a test case demonstrating this issue.
5725
5726Reported by Andrew Arnott.
5727
5728Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
5729Signed-off-by: Junio C Hamano <gitster@pobox.com>
5730
5731difftool: retire the scripted version
5732
5733It served its purpose, but now we have a builtin difftool. Time for the
5734Perl script to enjoy Florida.
5735
5736Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
5737Signed-off-by: Junio C Hamano <gitster@pobox.com>
5738
5739difftool: implement the functionality in the builtin
5740
5741This patch gives life to the skeleton added in the previous patch.
5742
5743The motivation for converting the difftool is that Perl scripts are not at
5744all native on Windows, and that `git difftool` therefore is pretty slow on
5745that platform, when there is no good reason for it to be slow.
5746
5747In addition, Perl does not really have access to Git's internals. That
5748means that any script will always have to jump through unnecessary
5749hoops, and it will often need to perform unnecessary work (e.g. when
5750reading the entire config every time `git config` is called to query a
5751single config value).
5752
5753The current version of the builtin difftool does not, however, make full
5754use of the internals but instead chooses to spawn a couple of Git
5755processes, still, to make for an easier conversion. There remains a lot
5756of room for improvement, left later.
5757
5758Note: to play it safe, the original difftool is still called unless the
5759config setting difftool.useBuiltin is set to true.
5760
5761The reason: this new, experimental, builtin difftool was shipped as part
5762of Git for Windows v2.11.0, to allow for easier large-scale testing, but
5763of course as an opt-in feature.
5764
5765The speedup is actually more noticable on Linux than on Windows: a quick
5766test 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
5768Windows, it is (36.064s/2.730s/7.194s), down from (47.637s/2.407s/6.863s).
5769The culprit is most likely the overhead incurred from *still* having to
5770shell out to mergetool-lib.sh and difftool--helper.sh.
5771
5772Still, it is an improvement.
5773
5774Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
5775Signed-off-by: Junio C Hamano <gitster@pobox.com>
5776
5777doc: add documentation for OPT_STRING_LIST
5778
5779Commit c8ba16391655 ("parse-options: add OPT_STRING_LIST helper",
57802011-06-09) added the OPT_STRING_LIST as a way to accumulate a repeated
5781list of strings. However, this was not documented in the
5782api-parse-options documentation. Add documentation now so that future
5783developers may learn of its existence.
5784
5785Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
5786Signed-off-by: Junio C Hamano <gitster@pobox.com>
5787
5788documentation: retire unfinished documentation
5789
5790When looking for documentation for a specific function, you may be tempted
5791to run
5792
5793 git -C Documentation grep index_name_pos
5794
5795only to find the file technical/api-in-core-index.txt, which doesn't
5796help for understanding the given function. It would be better to not find
5797these functions in the documentation, such that people directly dive into
5798the code instead.
5799
5800In the previous patches we have documented
5801* index_name_pos()
5802* remove_index_entry_at()
5803* add_[file_]to_index()
5804in cache.h
5805
5806We already have documentation for:
5807* add_index_entry()
5808* read_index()
5809
5810Which 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
5820Signed-off-by: Stefan Beller <sbeller@google.com>
5821Signed-off-by: Junio C Hamano <gitster@pobox.com>
5822
5823cache.h: document add_[file_]to_index
5824
5825Helped-by: Junio C Hamano <gitster@pobox.com>
5826Signed-off-by: Stefan Beller <sbeller@google.com>
5827Signed-off-by: Junio C Hamano <gitster@pobox.com>
5828
5829cache.h: document remove_index_entry_at
5830
5831Do this by moving the existing documentation from
5832read-cache.c to cache.h.
5833
5834Signed-off-by: Stefan Beller <sbeller@google.com>
5835Signed-off-by: Junio C Hamano <gitster@pobox.com>
5836
5837cache.h: document index_name_pos
5838
5839Signed-off-by: Stefan Beller <sbeller@google.com>
5840Signed-off-by: Junio C Hamano <gitster@pobox.com>
5841
5842color.c: trim leading spaces in color_parse_mem()
5843
5844Normally color_parse_mem() is called from config parser which trims the
5845leading spaces already. The new caller in the next patch won't. Let's be
5846tidy and trim leading spaces too (we already trim trailing spaces
5847after a word).
5848
5849Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
5850Signed-off-by: Junio C Hamano <gitster@pobox.com>
5851
5852color.c: fix color_parse_mem() with value_len == 0
5853
5854In this code we want to match the word "reset". If len is zero,
5855strncasecmp() will return zero and we incorrectly assume it's "reset" as
5856a result.
5857
5858Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
5859Signed-off-by: Junio C Hamano <gitster@pobox.com>
5860
5861clear_delta_base_cache(): don't modify hashmap while iterating
5862
5863On 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
5873Thanks. Here it is rolled up with a commit message.
5874
5875-- >8 --
5876Subject: clear_delta_base_cache(): don't modify hashmap while iterating
5877
5878Removing entries while iterating causes fast-import to
5879access an already-freed `struct packed_git`, leading to
5880various confusing errors.
5881
5882What happens is that clear_delta_base_cache() drops the
5883whole contents of the cache by iterating over the hashmap,
5884calling release_delta_base_cache() on each entry. That
5885function removes the item from the hashmap. The hashmap code
5886may then shrink the table, but the hashmap_iter struct
5887retains an offset from the old table.
5888
5889As a result, the next call to hashmap_iter_next() may claim
5890that the iteration is done, even though some items haven't
5891been visited.
5892
5893The only caller of clear_delta_base_cache() is fast-import,
5894which wants to clear the cache because it is discarding the
5895packed_git struct for its temporary pack. So by failing to
5896remove all of the entries, we still have references to the
5897freed packed_git.
5898
5899To make things even more confusing, this doesn't seem to
5900trigger with the test suite, because it depends on
5901complexities like the size of the hash table, which entries
5902got cleared, whether we try to access them before they're
5903evicted from the cache, etc.
5904
5905So I've been able to identify the problem with large
5906imports like freebsd's svn import, or a fast-export of
5907linux.git. But nothing that would be reasonable to run as
5908part of the normal test suite.
5909
5910We can fix this easily by iterating over the lru linked list
5911instead of the hashmap. They both contain the same entries,
5912and we can use the "safe" variant of the list iterator,
5913which exists for exactly this case.
5914
5915Let's also add a warning to the hashmap API documentation to
5916reduce the chances of getting bit by this again.
5917
5918Reported-by: Ulrich Spörlein <uqs@freebsd.org>
5919Signed-off-by: Jeff King <peff@peff.net>
5920Signed-off-by: Junio C Hamano <gitster@pobox.com>
5921
5922Sixth batch for 2.12
5923
5924Merge branch 'sb/remove-gitview'
5925
5926Retire 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
5934Merge branch 'js/asciidoctor-tweaks'
5935
5936Adjust documentation to help AsciiDoctor render better while not
5937breaking 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
5943Merge branch 'sb/unpack-trees-cleanup'
5944
5945Code 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
5952Merge branch 'rh/mergetool-regression-fix'
5953
5954"git mergetool" without any pathspec on the command line that is
5955run from a subdirectory became no-op in Git v2.11 by mistake, which
5956has 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
5974Merge branch 'bw/realpath-wo-chdir'
5975
5976The implementation of "real_path()" was to go there with chdir(2)
5977and call getcwd(3), but this obviously wouldn't be usable in a
5978threaded environment. Rewrite it to manually resolve relative
5979paths 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
5985Merge branch 'jk/execv-dashed-external'
5986
5987Typing ^C to pager, which usually does not kill it, killed Git and
5988took the pager down as a collateral damage in certain process-tree
5989structure. 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
5996Merge branch 'sp/cygwin-build-fixes'
5997
5998Build updates for Cygwin.
5999
6000* sp/cygwin-build-fixes:
6001 Makefile: put LIBS after LDFLAGS for imap-send
6002 Makefile: POSIX windres
6003
6004Merge branch 'sb/pathspec-errors'
6005
6006Running "git add a/b" when "a" is a submodule correctly errored
6007out, but without a meaningful error message.
6008
6009* sb/pathspec-errors:
6010 pathspec: give better message for submodule related pathspec error
6011
6012Merge branch 'pb/test-must-fail-is-for-git'
6013
6014Test 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
6020Merge branch 'bw/pathspec-cleanup'
6021
6022Code 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
6042Merge branch 'js/mingw-test-push-unc-path'
6043
6044"git push \\server\share\dir" has recently regressed and then
6045fixed. 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
6050Merge branch 'sb/submodule-cleanup-export-git-dir-env'
6051
6052Code cleanup.
6053
6054* sb/submodule-cleanup-export-git-dir-env:
6055 submodule.c: use GIT_DIR_ENVIRONMENT consistently
6056
6057Merge branch 'km/branch-get-push-while-detached'
6058
6059"git <cmd> @{push}" on a detached HEAD used to segfault; it has
6060been 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
6065Merge branch 'jk/rebase-i-squash-count-fix'
6066
6067"git rebase -i" with a recent update started showing an incorrect
6068count when squashing more than 10 commits.
6069
6070* jk/rebase-i-squash-count-fix:
6071 rebase--interactive: count squash commits above 10 correctly
6072
6073Merge branch 'jk/blame-fixes'
6074
6075"git blame --porcelain" misidentified the "previous" <commit, path>
6076pair (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
6083Merge branch 'jk/archive-zip-userdiff-config'
6084
6085"git archive" did not read the standard configuration files, and
6086failed to notice a file that is marked as binary via the userdiff
6087driver configuration.
6088
6089* jk/archive-zip-userdiff-config:
6090 archive-zip: load userdiff config
6091
6092Merge branch 'dt/disable-bitmap-in-auto-gc'
6093
6094It is natural that "git gc --auto" may not attempt to pack
6095everything into a single pack, and there is no point in warning
6096when the user has configured the system to use the pack bitmap,
6097leading 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
6103Merge branch 'ls/p4-retry-thrice'
6104
6105A recent updates to "git p4" was not usable for older p4 but it
6106could 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
6111Merge branch 'sb/submodule-rm-absorb'
6112
6113"git rm" used to refuse to remove a submodule when it has its own
6114git repository embedded in its working tree. It learned to move
6115the repository away to $GIT_DIR/modules/ of the superproject
6116instead, and allow the submodule to be deleted (as long as there
6117will 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
6125Merge 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
6143mingw: follow-up to "replace isatty() hack"
6144
6145The version of the "replace isatty() hack" that got merged a few
6146weeks ago did not actually reflect the latest iteration of the patch
6147series: v3 was sent out with these changes, as requested by the
6148reviewer 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
6158Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6159Reviewed-by: Johannes Sixt <j6t@kdbg.org>
6160Signed-off-by: Junio C Hamano <gitster@pobox.com>
6161
6162t/t7004-tag: Add --format specifier tests
6163
6164tag -v now supports --format specifiers to inspect the contents of a tag
6165upon verification. Add two tests to ensure this behavior is respected in
6166future changes.
6167
6168Signed-off-by: Santiago Torres <santiago@nyu.edu>
6169Signed-off-by: Junio C Hamano <gitster@pobox.com>
6170
6171t/t7030-verify-tag: Add --format specifier tests
6172
6173Verify-tag now provides --format specifiers to inspect and ensure the
6174contents of the tag are proper. We add two tests to ensure this
6175functionality works as expected: the return value should indicate if
6176verification passed, and the format specifiers must be respected.
6177
6178Signed-off-by: Santiago Torres <santiago@nyu.edu>
6179Signed-off-by: Junio C Hamano <gitster@pobox.com>
6180
6181builtin/tag: add --format argument for tag -v
6182
6183Adding --format to git tag -v mutes the default output of the GPG
6184verification and instead prints the formatted tag object.
6185This allows callers to cross-check the tagname from refs/tags with
6186the tagname from the tag object header upon GPG verification.
6187
6188The callback function for for_each_tag_name() didn't allow callers to
6189pass custom data to their callback functions. Add a new opaque pointer
6190to each_tag_name_fn's parameter to allow this.
6191
6192Signed-off-by: Lukas Puehringer <luk.puehringer@gmail.com>
6193Signed-off-by: Junio C Hamano <gitster@pobox.com>
6194
6195Merge 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
6213gitk: Remove translated message from comments
6214
6215"make update-po" fails because a previously untranslated string
6216has 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
6222Remove the duplicate message definition.
6223
6224Reported-by: Junio C Hamano <gitster@pobox.com>
6225Signed-off-by: David Aguilar <davvid@gmail.com>
6226Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
6227
6228builtin/verify-tag: add --format to verify-tag
6229
6230Callers of verify-tag may want to cross-check the tagname from refs/tags
6231with the tagname from the tag object header upon GPG verification. This
6232is to avoid tag refs that point to an incorrect object.
6233
6234Add a --format parameter to git verify-tag to print the formatted tag
6235object header in addition to or instead of the --verbose or --raw GPG
6236verification output.
6237
6238Signed-off-by: Santiago Torres <santiago@nyu.edu>
6239Signed-off-by: Junio C Hamano <gitster@pobox.com>
6240
6241ref-filter: add function to print single ref_array_item
6242
6243ref-filter functions are useful for printing git object information
6244using a format specifier. However, some other modules may not want to use
6245this functionality on a ref-array but only print a single item.
6246
6247Expose a pretty_print_ref function to create, pretty print and free
6248individual ref-items.
6249
6250Signed-off-by: Lukas Puehringer <luk.puehringer@gmail.com>
6251Signed-off-by: Junio C Hamano <gitster@pobox.com>
6252
6253gpg-interface, tag: add GPG_VERIFY_OMIT_STATUS flag
6254
6255Functions that print git object information may require that the
6256gpg-interface functions be silent. Add GPG_VERIFY_OMIT_STATUS flag and
6257prevent print_signature_buffer from being called if flag is set.
6258
6259Signed-off-by: Lukas Puehringer <luk.puehringer@gmail.com>
6260Signed-off-by: Junio C Hamano <gitster@pobox.com>
6261
6262RelNotes: drop merge-later comments for maint
6263
6264Signed-off-by: Junio C Hamano <gitster@pobox.com>
6265
6266Merge branch 'maint'
6267
6268Almost ready for 2.11.1
6269
6270Signed-off-by: Junio C Hamano <gitster@pobox.com>
6271
6272Merge branch 'mm/gc-safety-doc' into maint
6273
6274Doc update.
6275
6276* mm/gc-safety-doc:
6277 git-gc.txt: expand discussion of races with other processes
6278
6279Merge branch 'mm/push-social-engineering-attack-doc' into maint
6280
6281Doc update on fetching and pushing.
6282
6283* mm/push-social-engineering-attack-doc:
6284 doc: mention transfer data leaks in more places
6285
6286Merge branch 'jt/fetch-no-redundant-tag-fetch-map' into maint
6287
6288Code cleanup to avoid using redundant refspecs while fetching with
6289the --tags option.
6290
6291* jt/fetch-no-redundant-tag-fetch-map:
6292 fetch: do not redundantly calculate tag refmap
6293
6294Merge branch 'ls/filter-process' into maint
6295
6296Doc update.
6297
6298* ls/filter-process:
6299 t0021: fix flaky test
6300 docs: warn about possible '=' in clean/smudge filter process values
6301
6302Merge 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
6310Merge branch 'lr/doc-fix-cet' into maint
6311
6312* lr/doc-fix-cet:
6313 date-formats.txt: Typo fix
6314
6315Merge branch 'sb/t3600-cleanup' into maint
6316
6317Code cleanup.
6318
6319* sb/t3600-cleanup:
6320 t3600: slightly modernize style
6321 t3600: remove useless redirect
6322
6323Merge 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
6328Merge branch 'sb/unpack-trees-grammofix' into maint
6329
6330* sb/unpack-trees-grammofix:
6331 unpack-trees: fix grammar for untracked files in directories
6332
6333Merge branch 'ls/t0021-fixup' into maint
6334
6335* ls/t0021-fixup:
6336 t0021: minor filter process test cleanup
6337
6338Merge branch 'ak/lazy-prereq-mktemp' into maint
6339
6340Test code clean-up.
6341
6342* ak/lazy-prereq-mktemp:
6343 t7610: clean up foo.XXXXXX tmpdir
6344
6345Merge branch 'nd/qsort-in-merge-recursive' into maint
6346
6347Code simplification.
6348
6349* nd/qsort-in-merge-recursive:
6350 merge-recursive.c: use string_list_sort instead of qsort
6351
6352Merge branch 'dt/smart-http-detect-server-going-away' into maint
6353
6354When the http server gives an incomplete response to a smart-http
6355rpc call, it could lead to client waiting for a full response that
6356will never come. Teach the client side to notice this condition
6357and abort the transfer.
6358
6359An improvement counterproposal has failed.
6360cf. <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
6366Merge branch 'mk/mingw-winansi-ttyname-termination-fix' into maint
6367
6368A potential but unlikely buffer overflow in Windows port has been
6369fixed.
6370
6371* mk/mingw-winansi-ttyname-termination-fix:
6372 mingw: consider that UNICODE_STRING::Length counts bytes
6373
6374Merge branch 'gv/p4-multi-path-commit-fix' into maint
6375
6376"git p4" that tracks multile p4 paths imported a single changelist
6377that touches files in these multiple paths as one commit, followed
6378by 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
6383Merge branch 'jk/difftool-in-subdir' into maint
6384
6385Even though an fix was attempted in Git 2.9.3 days, but running
6386"git difftool --dir-diff" from a subdirectory never worked. This
6387has 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
6395Merge 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
6402Merge branch 'jc/push-default-explicit' into maint
6403
6404A lazy "git push" without refspec did not internally use a fully
6405specified refspec to perform 'current', 'simple', or 'upstream'
6406push, 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
6412Merge branch 'jt/mailinfo-fold-in-body-headers' into maint
6413
6414Fix for NDEBUG builds.
6415
6416* jt/mailinfo-fold-in-body-headers:
6417 mailinfo.c: move side-effects outside of assert
6418
6419Merge branch 'jk/index-pack-wo-repo-from-stdin' into maint
6420
6421"git index-pack --stdin" needs an access to an existing repository,
6422but "git index-pack file.pack" to generate an .idx file that
6423corresponds 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
6431Merge branch 'jk/parseopt-usage-msg-opt' into maint
6432
6433The function usage_msg_opt() has been updated to say "fatal:"
6434before the custom message programs give, when they want to die
6435with a message about wrong command line options followed by the
6436standard usage string.
6437
6438* jk/parseopt-usage-msg-opt:
6439 parse-options: print "fatal:" before usage_msg_opt()
6440
6441Merge branch 'jk/quote-env-path-list-component' into maint
6442
6443A recent update to receive-pack to make it easier to drop garbage
6444objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot
6445have a pathname with a colon in it (no surprise!), and this in turn
6446made it impossible to push into a repository at such a path. This
6447has been fixed by introducing a quoting mechanism used when
6448appending 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
6456Merge branch 'nd/shallow-fixup' into maint
6457
6458Code 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
6468Merge branch 'sb/sequencer-abort-safety' into maint
6469
6470Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
6471to where cherry-pick started while picking multiple changes, when
6472the cherry-pick stopped to ask for help from the user, and the user
6473did "git reset --hard" to a different commit in order to re-attempt
6474the 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
6484Merge branch 'da/mergetool-xxdiff-hotkey' into maint
6485
6486The way to specify hotkeys to "xxdiff" that is used by "git
6487mergetool" has been modernized to match recent versions of xxdiff.
6488
6489* da/mergetool-xxdiff-hotkey:
6490 mergetools: fix xxdiff hotkeys
6491
6492Merge branch 'jc/pull-rebase-ff' into maint
6493
6494"git pull --rebase", when there is no new commits on our side since
6495we forked from the upstream, should be able to fast-forward without
6496invoking "git rebase", but it didn't.
6497
6498* jc/pull-rebase-ff:
6499 pull: fast-forward "pull --rebase=true"
6500
6501Merge branch 'js/normalize-path-copy-ceil' into maint
6502
6503A pathname that begins with "//" or "\\" on Windows is special but
6504path 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
6509Merge branch 'ak/commit-only-allow-empty' into maint
6510
6511"git commit --allow-empty --only" (no pathspec) with dirty index
6512ought to be an acceptable way to create a new commit that does not
6513change any paths, but it was forbidden, perhaps because nobody
6514needed 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
6520Merge branch 'da/difftool-dir-diff-fix' into maint
6521
6522"git difftool --dir-diff" had a minor regression when started from
6523a subdirectory, which has been fixed.
6524
6525* da/difftool-dir-diff-fix:
6526 difftool: fix dir-diff index creation when in a subdirectory
6527
6528Merge 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
6535Merge branch 'jk/stash-disable-renames-internally' into maint
6536
6537When diff.renames configuration is on (and with Git 2.9 and later,
6538it is enabled by default, which made it worse), "git stash"
6539misbehaved if a file is removed and another file with a very
6540similar content is added.
6541
6542* jk/stash-disable-renames-internally:
6543 stash: prefer plumbing over git-diff
6544
6545Merge branch 'jk/http-walker-limit-redirect' into maint
6546
6547Update the error messages from the dumb-http client when it fails
6548to obtain loose objects; we used to give sensible error message
6549only upon 404 but we now forbid unexpected redirects that needs to
6550be 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
6560Merge branch 'jc/renormalize-merge-kill-safer-crlf' into maint
6561
6562Fix a corner case in merge-recursive regression that crept in
6563during 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
6570Merge 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
6577Merge branch 'da/mergetool-trust-exit-code' into maint
6578
6579mergetool.<tool>.trustExitCode configuration variable did not apply
6580to 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
6586Merge branch 'nd/worktree-list-fixup' into maint
6587
6588The output from "git worktree list" was made in readdir() order,
6589and 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
6598Merge 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
6607Merge branch 'hv/submodule-not-yet-pushed-fix' into maint
6608
6609The code in "git push" to compute if any commit being pushed in the
6610superproject binds a commit in a submodule that hasn't been pushed
6611out was overly inefficient, making it unusable even for a small
6612project that does not have any submodule but have a reasonable
6613number 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
6621Merge branch 'dt/empty-submodule-in-merge' into maint
6622
6623An empty directory in a working tree that can simply be nuked used
6624to interfere while merging or cherry-picking a change to create a
6625submodule 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
6630Merge 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
6638Merge branch 'js/mingw-isatty' into maint
6639
6640Update the isatty() emulation for Windows by updating the previous
6641hack 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
6649Merge branch 'bb/unicode-9.0' into maint
6650
6651The 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
6661Merge branch 'ls/travis-update-p4-and-lfs' into maint
6662
6663The 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
6668CodingGuidelines: clarify multi-line brace style
6669
6670There are some "gray areas" around when to omit braces from
6671a conditional or loop body. Since that seems to have
6672resulted in some arguments, let's be a little more clear
6673about our preferred style.
6674
6675Signed-off-by: Jeff King <peff@peff.net>
6676Signed-off-by: Junio C Hamano <gitster@pobox.com>
6677
6678fsck: check HAS_OBJ more consistently
6679
6680There are two spots that call lookup_object() and assume
6681that 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
6688This generally follows fsck's mental model that we will have
6689looked at and loaded a "struct object" for each object in
6690the repository. But it misses one case: if another object
6691_mentioned_ an object, but we didn't actually parse it or
6692verify that it exists, it will still have a struct.
6693
6694It's not clear if this is a triggerable bug or not.
6695Certainly the later parts of the reachability check need to
6696be careful of this, and do so by checking the HAS_OBJ flag.
6697But both of these steps happen before we start traversing,
6698so probably we won't have followed any links yet. Still,
6699it's easy enough to be defensive here.
6700
6701Signed-off-by: Jeff King <peff@peff.net>
6702Signed-off-by: Junio C Hamano <gitster@pobox.com>
6703
6704fsck: do not fallback "git fsck <bogus>" to "git fsck"
6705
6706Since fsck tries to continue as much as it can after seeing
6707an error, we still do the reachability check even if some
6708heads we were given on the command-line are bogus. But if
6709_none_ of the heads is is valid, we fallback to checking all
6710refs and the index, which is not what the user asked for at
6711all.
6712
6713Instead of checking "heads", the number of successful heads
6714we got, check "argc" (which we know only has non-options in
6715it, because parse_options removed the others).
6716
6717Signed-off-by: Jeff King <peff@peff.net>
6718Signed-off-by: Junio C Hamano <gitster@pobox.com>
6719
6720fsck: tighten error-checks of "git fsck <head>"
6721
6722Instead of checking reachability from the refs, you can ask
6723fsck to check from a particular set of heads. However, the
6724error 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
6734This patch fixes both of these cases.
6735
6736Signed-off-by: Jeff King <peff@peff.net>
6737Signed-off-by: Junio C Hamano <gitster@pobox.com>
6738
6739fsck: prepare dummy objects for --connectivity-check
6740
6741Normally fsck makes a pass over all objects to check their
6742integrity, and then follows up with a reachability check to
6743make sure we have all of the referenced objects (and to know
6744which ones are dangling). The latter checks for the HAS_OBJ
6745flag in obj->flags to see if we found the object in the
6746first pass.
6747
6748Commit 02976bf85 (fsck: introduce `git fsck --connectivity-only`,
67492015-06-22) taught fsck to skip the initial pass, and to
6750fallback to has_sha1_file() instead of the HAS_OBJ check.
6751
6752However, it converted only one HAS_OBJ check to use
6753has_sha1_file(). But there are many other places in
6754builtin/fsck.c that assume that the flag is set (or that
6755lookup_object() will return an object at all). This leads to
6756several 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
6771So in short, --connectivity-only is broken pretty badly, and
6772will claim that your repository is fine when it's not.
6773Presumably nobody noticed for a few reasons.
6774
6775One is that the embedded test does not actually test the
6776recursive nature of the reachability check. All of the
6777missing objects are still in the index, and we directly
6778check items from the index. This patch modifies the test to
6779delete the index, which shows off breakage (1).
6780
6781Another is that --connectivity-only just skips the initial
6782pass for loose objects. So on a real repository, the packed
6783objects were still checked correctly. But on the flipside,
6784it means that "git fsck --connectivity-only" still checks
6785the sha1 of all of the packed objects, nullifying its
6786original purpose of being a faster git-fsck.
6787
6788And of course the final problem is that the bug only shows
6789up when there _is_ corruption, which is rare. So anybody
6790running "git fsck --connectivity-only" proactively would
6791assume it was being thorough, when it was not.
6792
6793One possibility for fixing this is to find all of the spots
6794that rely on HAS_OBJ and tweak them for the connectivity-only
6795case. But besides the risk that we might miss a spot (and I
6796found three already, corresponding to the three bugs above),
6797there are other parts of fsck that _can't_ work without a
6798full list of objects. E.g., the list of dangling objects.
6799
6800Instead, let's make the connectivity-only case look more
6801like the normal case. Rather than skip the initial pass
6802completely, we'll do an abbreviated one that sets up the
6803HAS_OBJ flag for each object, without actually loading the
6804object data.
6805
6806That's simple and fast, and we don't have to care about the
6807connectivity_only flag in the rest of the code at all.
6808While we're at it, let's make sure we treat loose and packed
6809objects the same (i.e., setting up dummy objects for both
6810and skipping the actual sha1 check). That makes the
6811connectivity-only check actually fast on a real repo (40
6812seconds versus 180 seconds on my copy of linux.git).
6813
6814Signed-off-by: Jeff King <peff@peff.net>
6815Signed-off-by: Junio C Hamano <gitster@pobox.com>
6816
6817sequencer (rebase -i): write out the final message
6818
6819The shell script version of the interactive rebase has a very specific
6820final message. Teach the sequencer to print the same.
6821
6822Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6823Signed-off-by: Junio C Hamano <gitster@pobox.com>
6824
6825sequencer (rebase -i): write the progress into files
6826
6827For the benefit of e.g. the shell prompt, the interactive rebase not
6828only displays the progress for the user to see, but also writes it into
6829the msgnum/end files in the state directory.
6830
6831Teach the sequencer this new trick.
6832
6833Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6834Signed-off-by: Junio C Hamano <gitster@pobox.com>
6835
6836sequencer (rebase -i): show the progress
6837
6838The interactive rebase keeps the user informed about its progress.
6839If the sequencer wants to do the grunt work of the interactive
6840rebase, it also needs to show that progress.
6841
6842Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6843Signed-off-by: Junio C Hamano <gitster@pobox.com>
6844
6845sequencer (rebase -i): suggest --edit-todo upon unknown command
6846
6847This is the same behavior as known from `git rebase -i`.
6848
6849Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6850Signed-off-by: Junio C Hamano <gitster@pobox.com>
6851
6852sequencer (rebase -i): show only failed cherry-picks' output
6853
6854This is the behavior of the shell script version of the interactive
6855rebase, by using the `output` function defined in `git-rebase.sh`.
6856
6857Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6858Signed-off-by: Junio C Hamano <gitster@pobox.com>
6859
6860sequencer (rebase -i): show only failed `git commit`'s output
6861
6862This is the behavior of the shell script version of the interactive
6863rebase, by using the `output` function defined in `git-rebase.sh`.
6864
6865Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6866Signed-off-by: Junio C Hamano <gitster@pobox.com>
6867
6868sequencer: use run_command() directly
6869
6870Instead of using the convenience function run_command_v_opt_cd_env(), we
6871now use the run_command() function. The former function is simply a
6872wrapper of the latter, trying to make it more convenient to use.
6873
6874However, we already have to construct the argv and the env parameters,
6875and we will need even finer control e.g. over the output of the command,
6876so let's just stop using the convenience function.
6877
6878Based on patches and suggestions by Johannes Sixt and Jeff King.
6879
6880Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6881Signed-off-by: Junio C Hamano <gitster@pobox.com>
6882
6883sequencer: update reading author-script
6884
6885Rather than abusing a strbuf to come up with an environment block,
6886let's just use the argv_array structure which serves the same
6887purpose much better.
6888
6889While at it, rename the function to reflect the fact that it does
6890not really care exactly what environment variables are defined in
6891said file.
6892
6893Suggested-by: Jeff King <peff@peff.net>
6894Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6895Signed-off-by: Junio C Hamano <gitster@pobox.com>
6896
6897difftool: add a skeleton for the upcoming builtin
6898
6899This adds a builtin difftool that still falls back to the legacy Perl
6900version, which has been renamed to `legacy-difftool`.
6901
6902The idea is that the new, experimental, builtin difftool immediately hands
6903off to the legacy difftool for now, unless the config variable
6904difftool.useBuiltin is set to true.
6905
6906This feature flag will be used in the upcoming Git for Windows v2.11.0
6907release, to allow early testers to opt-in to use the builtin difftool and
6908flesh out any bugs.
6909
6910Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
6911Signed-off-by: Junio C Hamano <gitster@pobox.com>
6912
6913fsck: report trees as dangling
6914
6915After checking connectivity, fsck looks through the list of
6916any objects we've seen mentioned, and reports unreachable
6917and un-"used" ones as dangling. However, it skips any object
6918which is not marked as "parsed", as that is an object that
6919we _don't_ have (but that somebody mentioned).
6920
6921Since 6e454b9a3 (clear parsed flag when we free tree
6922buffers, 2013-06-05), that flag can't be relied on, and the
6923correct method is to check the HAS_OBJ flag. The cleanup in
6924that commit missed this callsite, though. As a result, we
6925would generally fail to report dangling trees.
6926
6927We never noticed because there were no tests in this area
6928(for trees or otherwise). Let's add some.
6929
6930Signed-off-by: Jeff King <peff@peff.net>
6931Signed-off-by: Junio C Hamano <gitster@pobox.com>
6932
6933t1450: clean up sub-objects in duplicate-entry test
6934
6935This test creates a multi-level set of trees, but its
6936cleanup routine only removes the top-level tree. After the
6937test finishes, the inner tree and the blob it points to
6938remain, making the inner tree dangling.
6939
6940A later test ("cleaned up") verifies that we've removed any
6941cruft and "git fsck" output is clean. This passes only
6942because of a bug in git-fsck which fails to notice dangling
6943trees.
6944
6945In preparation for fixing the bug, let's teach this earlier
6946test to clean up after itself correctly. We have to remove
6947the inner tree (and therefore the blob, too, which becomes
6948dangling after removing that tree).
6949
6950Since the setup code happens inside a subshell, we can't
6951just set a variable for each object. However, we can stuff
6952all of the sha1s into the $T output variable, which is not
6953used for anything except cleanup.
6954
6955Signed-off-by: Jeff King <peff@peff.net>
6956Signed-off-by: Junio C Hamano <gitster@pobox.com>
6957
6958diff: document the format of the -O (diff.orderFile) file
6959
6960Signed-off-by: Richard Hansen <hansenr@google.com>
6961Signed-off-by: Junio C Hamano <gitster@pobox.com>
6962
6963diff: document behavior of relative diff.orderFile
6964
6965Document that a relative pathname for diff.orderFile is interpreted as
6966relative to the top-level work directory.
6967
6968Signed-off-by: Richard Hansen <hansenr@google.com>
6969Signed-off-by: Junio C Hamano <gitster@pobox.com>
6970
6971request-pull: drop old USAGE stuff
6972
6973request-pull uses OPTIONS_SPEC, so no need for (meanwhile incomplete)
6974USAGE and LONG_USAGE anymore.
6975
6976Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
6977Signed-off-by: Junio C Hamano <gitster@pobox.com>
6978
6979xdiff -W: relax end-of-file function detection
6980
6981When adding a new function to the end of a file, it's enough to know
6982that 1) the addition is at the end of the file; and 2) there is a
6983function _somewhere_ in there.
6984
6985If we had simply been changing the end of an existing function, then we
6986would also be deleting something from the old version.
6987
6988This fixes the case where we add e.g.
6989
6990 // Begin of dummy
6991 static int dummy(void)
6992 {
6993 }
6994
6995to the end of the file.
6996
6997Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
6998Acked-by: René Scharfe <l.s.r@web.de>
6999Signed-off-by: Junio C Hamano <gitster@pobox.com>
7000
7001fsck: detect trailing garbage in all object types
7002
7003When a loose tree or commit is read by fsck (or any git
7004program), unpack_sha1_rest() checks whether there is extra
7005cruft at the end of the object file, after the zlib data.
7006Blobs that are streamed, however, do not have this check.
7007
7008For normal git operations, it's not a big deal. We know the
7009sha1 and size checked out, so we have the object bytes we
7010wanted. The trailing garbage doesn't affect what we're
7011trying to do.
7012
7013But since the point of fsck is to find corruption or other
7014problems, it should be more thorough. This patch teaches its
7015loose-sha1 reader to detect extra bytes after the zlib
7016stream and complain.
7017
7018Signed-off-by: Jeff King <peff@peff.net>
7019Signed-off-by: Junio C Hamano <gitster@pobox.com>
7020
7021fsck: parse loose object paths directly
7022
7023When we iterate over the list of loose objects to check, we
7024get the actual path of each object. But we then throw it
7025away and pass just the sha1 to fsck_sha1(), which will do a
7026fresh lookup. Usually it would find the same object, but it
7027may not if an object exists both as a loose and a packed
7028object. We may end up checking the packed object twice, and
7029never look at the loose one.
7030
7031In practice this isn't too terrible, because if fsck doesn't
7032complain, it means you have at least one good copy. But
7033since the point of fsck is to look for corruption, we should
7034be thorough.
7035
7036The new read_loose_object() interface can help us get the
7037data from disk, and then we replace parse_object() with
7038parse_object_buffer(). As a bonus, our error messages now
7039mention the path to a corrupted object, which should make it
7040easier to track down errors when they do happen.
7041
7042Signed-off-by: Jeff King <peff@peff.net>
7043Signed-off-by: Junio C Hamano <gitster@pobox.com>
7044
7045sha1_file: add read_loose_object() function
7046
7047It's surprisingly hard to ask the sha1_file code to open a
7048_specific_ incarnation of a loose object. Most of the
7049functions take a sha1, and loop over the various object
7050types (packed versus loose) and locations (local versus
7051alternates) at a low level.
7052
7053However, some tools like fsck need to look at a specific
7054file. This patch gives them a function they can use to open
7055the loose object at a given path.
7056
7057The implementation unfortunately ends up repeating bits of
7058related functions, but there's not a good way around it
7059without some major refactoring of the whole sha1_file stack.
7060We need to mmap the specific file, then partially read the
7061zlib stream to know whether we're streaming or not, and then
7062finally either stream it or copy the data to a buffer.
7063
7064We can do that by assembling some of the more arcane
7065internal sha1_file functions, but we end up having to
7066essentially reimplement unpack_sha1_file(), along with the
7067streaming bits of check_sha1_signature().
7068
7069Still, most of the ugliness is contained in the new
7070function, and the interface is clean enough that it may be
7071reusable (though it seems unlikely anything but git-fsck
7072would care about opening a specific file).
7073
7074Signed-off-by: Jeff King <peff@peff.net>
7075Signed-off-by: Junio C Hamano <gitster@pobox.com>
7076
7077t1450: test fsck of packed objects
7078
7079The code paths in fsck for packed and loose objects are
7080quite different, and it is not immediately obvious that the
7081packed 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
7098So there are no bugs here, but it was certainly confusing to
7099me. And we do not test either of the properties in t1450
7100(neither that a non-corruption error will caused a non-zero
7101exit for a packed object, nor that we keep going after
7102seeing the first error). Let's test both of those
7103conditions, so that we'll notice if any of those assumptions
7104becomes invalid.
7105
7106Signed-off-by: Jeff King <peff@peff.net>
7107Signed-off-by: Junio C Hamano <gitster@pobox.com>
7108
7109sha1_file: fix error message for alternate objects
7110
7111When we fail to open a corrupt loose object, we report an
7112error and mention the filename via sha1_file_name().
7113However, that function will always give us a path in the
7114local repository, whereas the corrupt object may have come
7115from an alternate. The result is a very misleading error
7116message.
7117
7118Teach the open_sha1_file() and stat_sha1_file() helpers to
7119pass back the path they found, so that we can report it
7120correctly.
7121
7122Note that the pointers we return go to static storage (e.g.,
7123from sha1_file_name()), which is slightly dangerous.
7124However, these helpers are static local helpers, and the
7125names are used for immediately generating error messages.
7126The simplicity is an acceptable tradeoff for the danger.
7127
7128Signed-off-by: Jeff King <peff@peff.net>
7129Signed-off-by: Junio C Hamano <gitster@pobox.com>
7130
7131t1450: refactor loose-object removal
7132
7133Commit 90cf590f5 (fsck: optionally show more helpful info
7134for broken links, 2016-07-17) added a remove_loose_object()
7135helper, but we already had a remove_object() helper that did
7136the same thing. Let's combine these into one.
7137
7138The implementations had a few subtle differences, so I've
7139tried 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
7159Signed-off-by: Jeff King <peff@peff.net>
7160Signed-off-by: Junio C Hamano <gitster@pobox.com>
7161
7162doc: git-gui browser does not default to HEAD
7163
716437cd4f7 ("Document git-gui, git-citool as mainporcelain manual pages",
71652007-06-21) documented the default, but was shortly followed by c52c945
7166("git-gui: Allow blame/browser subcommands on bare repositories",
71672007-07-17) which, it would appear, as a side effect, removed that default.
7168
7169Finally document that change.
7170
7171Signed-off-by: Philip Oakley <philipoakley@iee.org>
7172Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
7173Signed-off-by: Junio C Hamano <gitster@pobox.com>
7174
7175doc: gitk: add the upstream repo location
7176
7177Match the 'git gui' information regarding the graphical browser
7178and its upstream location.
7179
7180Signed-off-by: Philip Oakley <philipoakley@iee.org>
7181Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
7182Signed-off-by: Junio C Hamano <gitster@pobox.com>
7183
7184doc: gitk: remove gitview reference
7185
7186contrib/gitview has been removed. Remove the reference.
7187
7188Signed-off-by: Philip Oakley <philipoakley@iee.org>
7189Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
7190Signed-off-by: Junio C Hamano <gitster@pobox.com>
7191
7192lib-submodule-update.sh: reduce use of subshell by using "git -C"
7193
7194We write
7195
7196 (cd <dir> && git <cmd>)
7197
7198to avoid
7199
7200 cd <dir> && git <cmd> && cd ..
7201
7202that allows a breakage in one part of the test script to leave the
7203entire test process in an unexpected place. Modern version of Git
7204allows us to do this more concisely with "git -C <dir> <cmd>".
7205
7206Signed-off-by: Stefan Beller <sbeller@google.com>
7207Signed-off-by: Junio C Hamano <gitster@pobox.com>
7208
7209builtin/commit.c: remove the PATH_MAX limitation via dynamic allocation
7210
7211Remove the PATH_MAX limitation from the environment setting that
7212points to a filename by switching to dynamic allocation.
7213
7214As a side effect of this change, we also reduce the snprintf()
7215calls, that may silently truncate results if the programmer is not
7216careful.
7217
7218Helped-by: Junio C Hamano <gitster@pobox.com>
7219Helped-by: Jeff King <peff@peff.net>
7220Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
7221Signed-off-by: Junio C Hamano <gitster@pobox.com>
7222
7223Documentation/bisect: improve on (bad|new) and (good|bad)
7224
7225The following part of the description:
7226
7227git bisect (bad|new) [<rev>]
7228git bisect (good|old) [<rev>...]
7229
7230may be a bit confusing, as a reader may wonder if instead it should be:
7231
7232git bisect (bad|good) [<rev>]
7233git bisect (old|new) [<rev>...]
7234
7235Of course the difference between "[<rev>]" and "[<rev>...]" should hint
7236that there is a good reason for the way it is.
7237
7238But we can further clarify and complete the description by adding
7239"<term-new>" and "<term-old>" to the "bad|new" and "good|old"
7240alternatives.
7241
7242Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
7243Signed-off-by: Junio C Hamano <gitster@pobox.com>
7244
7245asciidoctor: fix user-manual to be built by `asciidoctor`
7246
7247The `user-manual.txt` is designed as a `book` but the `Makefile` wants
7248to build it as an `article`. This seems to be a problem when building
7249the documentation with `asciidoctor`. Furthermore the parts *Git
7250Glossary* and *Appendix B* had no subsections which is not allowed when
7251building with `asciidoctor`. So lets add a *dummy* section.
7252
7253Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
7254Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
7255Signed-off-by: Junio C Hamano <gitster@pobox.com>
7256
7257submodule update --init: display correct path from submodule
7258
7259In the submodule helper we did not correctly handled the display path
7260for initializing submodules when both the submodule is inside a
7261subdirectory as well as the command being invoked from a subdirectory
7262(as viewed from the superproject).
7263
7264This was broken in 3604242f080, which was written at a time where
7265there was no super-prefix available, so we abused the --prefix option
7266for the same purpose and could get only one case right (the call from
7267within a subdirectory, not the submodule being in a subdirectory).
7268
7269Test-provided-by: David Turner <novalis@novalis.org>
7270Signed-off-by: Stefan Beller <sbeller@google.com>
7271Signed-off-by: Junio C Hamano <gitster@pobox.com>
7272
7273submodule update documentation: don't repeat ourselves
7274
7275The documentation for the `git submodule update` command, repeats itself
7276for each update option, "This is done when <option> is given, or no
7277option is given and `submodule.<name>.update` is set to <string>.
7278
7279Avoid these repetitive clauses by stating the command line options take
7280precedence over configured options.
7281
7282Also add 'none' to the list of options instead of mentioning it in the
7283following running text and split the list into two parts, one that is
7284accessible via the command line and one that is only reachable via the
7285configuration variables.
7286
7287Signed-off-by: Stefan Beller <sbeller@google.com>
7288Signed-off-by: Junio C Hamano <gitster@pobox.com>
7289
7290submodule documentation: add options to the subcommand
7291
7292When reading up on a subcommand of `git submodule <subcommand>`,
7293it is convenient to have its options nearby and not just at the
7294top of the man page. Add the options to each subcommand.
7295
7296While at it, also document the `--checkout` option for `update`.
7297
7298Signed-off-by: Stefan Beller <sbeller@google.com>
7299Signed-off-by: Junio C Hamano <gitster@pobox.com>
7300
7301t7411: test lookup of uninitialized submodules
7302
7303Sometimes we need to lookup information of uninitialized submodules. Make
7304sure that works.
7305
7306Signed-off-by: Stefan Beller <sbeller@google.com>
7307Signed-off-by: Junio C Hamano <gitster@pobox.com>
7308
7309t7411: quote URLs
7310
7311The variables may contain white spaces, so we need to quote them.
7312By not quoting the variables we'd end up passing multiple arguments to
7313git config, which doesn't fail for two arguments as value.
7314
7315Signed-off-by: Stefan Beller <sbeller@google.com>
7316Signed-off-by: Junio C Hamano <gitster@pobox.com>
7317
7318submodule absorbgitdirs: mention in docstring help
7319
7320This part was missing in f6f85861 (submodule: add absorb-git-dir function,
73212016-12-12).
7322
7323Noticed-by: Jonathan Nieder <jrnieder@gmail.com>
7324Signed-off-by: Stefan Beller <sbeller@google.com>
7325Signed-off-by: Junio C Hamano <gitster@pobox.com>
7326
7327diff: add interhunk context config option
7328
7329The --inter-hunk-context= option was added in commit 6d0e674a5754
7330("diff: add option to show context between close hunks"). This patch
7331allows configuring a default for this option.
7332
7333Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
7334Signed-off-by: Junio C Hamano <gitster@pobox.com>
7335
7336versioncmp: generalize version sort suffix reordering
7337
7338The 'versionsort.prereleaseSuffix' configuration variable, as its name
7339suggests, is supposed to only deal with tagnames with prerelease
7340suffixes, and allows sorting those prerelease tags in a user-defined
7341order before the suffixless main release tag, instead of sorting them
7342simply lexicographically.
7343
7344However, the previous changes in this series resulted in an
7345interesting 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
7354Exploiting this property we can easily generalize suffix reordering
7355and specify the order of tags with given suffixes not only before but
7356even after a main release tag by using the empty suffix to denote the
7357position 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
7371Since 'versionsort.prereleaseSuffix' is not a fitting name for a
7372configuration variable to control this more general suffix reordering,
7373introduce the new variable 'versionsort.suffix'. Still keep the old
7374configuration variable name as a deprecated alias, though, to avoid
7375suddenly breaking setups already using it. Ignore the old variable if
7376both old and new configuration variables are set, but emit a warning
7377so users will be aware of it and can fix their configuration. Extend
7378the documentation to describe and add a test to check this more
7379general behavior.
7380
7381Note: since the empty suffix matches all tagnames, tagnames with
7382suffixes not included in the configuration are listed together with
7383the suffixless main release tag, ordered lexicographically right after
7384that, i.e. before tags with suffixes listed in the configuration
7385following the empty suffix.
7386
7387Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
7388Signed-off-by: Junio C Hamano <gitster@pobox.com>
7389
7390versioncmp: factor out helper for suffix matching
7391
7392As the number of identical steps to be done for both tagnames grows,
7393extract them into a helper function, with the additional benefit that
7394the conditionals near the end of swap_prereleases() will use more
7395meaningful variable names.
7396
7397Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
7398Signed-off-by: Junio C Hamano <gitster@pobox.com>
7399
7400vreport: sanitize ASCII control chars
7401
7402Our error() and die() calls may report messages with
7403arbitrary data (e.g., filenames or even data from a remote
7404server). Let's make it harder to cause confusion with
7405mischievous filenames. E.g., try:
7406
7407 git rev-parse "$(printf "\rfatal: this argument is too sneaky")" --
7408
7409or
7410
7411 git rev-parse "$(printf "\x1b[5mblinky\x1b[0m")" --
7412
7413Let's block all ASCII control characters, with the exception
7414of TAB and LF. We use both in our own messages (and we are
7415necessarily sanitizing the complete output of snprintf here,
7416as we do not have access to the individual varargs). And TAB
7417and LF are unlikely to cause confusion (you could put
7418"\nfatal: sneaky\n" in your filename, but it would at least
7419not _cover up_ the message leading to it, unlike "\r").
7420
7421We'll replace the characters with a "?", which is similar to
7422how "ls" behaves. It might be nice to do something less
7423lossy, like converting them to "\x" hex codes. But replacing
7424with a single character makes it easy to do in-place and
7425without worrying about length limitations. This feature
7426should kick in rarely enough that the "?" marks are almost
7427never seen.
7428
7429We'll leave high-bit characters as-is, as they are likely to
7430be UTF-8 (though there may be some Unicode mischief you
7431could cause, which may require further patches).
7432
7433Signed-off-by: Jeff King <peff@peff.net>
7434Signed-off-by: Junio C Hamano <gitster@pobox.com>
7435
7436Revert "vreportf: avoid intermediate buffer"
7437
7438This reverts commit f4c3edc0b156362a92bf9de4f0ec794e90a757fc.
7439
7440The purpose of that commit was to let us write errors of
7441arbitrary length to stderr by skipping the intermediate
7442buffer and sending our varargs straight to fprintf. That
7443works, but it comes with a downside: we do not get access to
7444the varargs before they are sent to stderr.
7445
7446On balance, it's not a good tradeoff. Error messages larger
7447than our 4K buffer are quite uncommon, and we've lost the
7448ability to make any modifications to the output (e.g., to
7449remove non-printable characters).
7450
7451The 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
7460Let's just revert that change and go back to a fixed buffer.
7461
7462Signed-off-by: Jeff King <peff@peff.net>
7463Signed-off-by: Junio C Hamano <gitster@pobox.com>
7464
7465index: improve constness for reading blob data
7466
7467Improve constness of the index_state parameter to the
7468'read_blob_data_from_index' function.
7469
7470Signed-off-by: Brandon Williams <bmwill@google.com>
7471Signed-off-by: Junio C Hamano <gitster@pobox.com>
7472
7473t1001: modernize style
7474
7475The 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
7483Signed-off-by: Stefan Beller <sbeller@google.com>
7484Signed-off-by: Junio C Hamano <gitster@pobox.com>
7485
7486t1000: modernize style
7487
7488The 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
7496Signed-off-by: Stefan Beller <sbeller@google.com>
7497Signed-off-by: Junio C Hamano <gitster@pobox.com>
7498
7499read-tree: use OPT_BOOL instead of OPT_SET_INT
7500
7501All occurrences of OPT_SET_INT were setting the value to 1;
7502internally OPT_BOOL is just that.
7503
7504Signed-off-by: Stefan Beller <sbeller@google.com>
7505Signed-off-by: Junio C Hamano <gitster@pobox.com>
7506
7507t7810: avoid assumption about invalid regex syntax
7508
7509A few of the tests want to check that "git grep -P -E" will
7510override -P with -E, and vice versa. To do so, we use a
7511regex with "\x{..}", which is valid in PCRE but not defined
7512by POSIX (for basic or extended regular expressions).
7513
7514However, POSIX declares quite a lot of syntax, including
7515"\x", as "undefined". That leaves implementations free to
7516extend the standard if they choose. At least one, musl libc,
7517implements "\x" in the same way as PCRE. Our tests check
7518that "-E" complains about "\x", which fails with musl.
7519
7520We can fix this by finding some construct which behaves
7521reliably on both PCRE and POSIX, but differently in each
7522system.
7523
7524One such construct is the use of backslash inside brackets.
7525In PCRE, "[\d]" interprets "\d" as it would outside the
7526brackets, matching a digit. Whereas in POSIX, the backslash
7527must be treated literally, and we match either it or a
7528literal "d". Moreover, implementations are not free to
7529change this according to POSIX, so we should be able to rely
7530on it.
7531
7532Signed-off-by: Jeff King <peff@peff.net>
7533Signed-off-by: Junio C Hamano <gitster@pobox.com>
7534
7535Fifth batch 2.12
7536
7537Signed-off-by: Junio C Hamano <gitster@pobox.com>
7538
7539Merge branch 'sb/submodule-embed-gitdir'
7540
7541A new submodule helper "git submodule embedgitdirs" to make it
7542easier to move embedded .git/ directory for submodules in a
7543superproject to .git/modules/ (and point the latter with the former
7544that 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
7555Merge branch 'jc/retire-compaction-heuristics'
7556
7557"git diff" and its family had two experimental heuristics to shift
7558the contents of a hunk to make the patch easier to read. One of
7559them 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
7565Merge branch 'nd/config-misc-fixes'
7566
7567Leakage 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
7574Merge branch 'jc/abbrev-autoscale-config'
7575
7576Recent update to the default abbreviation length that auto-scales
7577lacked documentation update, which has been corrected.
7578
7579* jc/abbrev-autoscale-config:
7580 config.abbrev: document the new default that auto-scales
7581
7582Merge branch 'mh/fast-import-notes-fix-new'
7583
7584"git fast-import" sometimes mishandled while rebalancing notes
7585tree, which has been fixed.
7586
7587* mh/fast-import-notes-fix-new:
7588 fast-import: properly fanout notes when tree is imported
7589
7590Merge branch 'jc/git-open-cloexec'
7591
7592The codeflow of setting NOATIME and CLOEXEC on file descriptors Git
7593opens has been simplified.
7594We 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
7601Merge branch 'jc/compression-config'
7602
7603Compression setting for producing packfiles were spread across
7604three codepaths, one of which did not honor any configuration.
7605Unify these so that all of them honor core.compression and
7606pack.compression variables the same way.
7607
7608* jc/compression-config:
7609 compression: unify pack.compression configuration parsing
7610
7611Merge branch 'dt/smart-http-detect-server-going-away'
7612
7613When the http server gives an incomplete response to a smart-http
7614rpc call, it could lead to client waiting for a full response that
7615will never come. Teach the client side to notice this condition
7616and abort the transfer.
7617
7618An improvement counterproposal has failed.
7619cf. <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
7625Merge branch 'mm/gc-safety-doc'
7626
7627Doc update.
7628
7629* mm/gc-safety-doc:
7630 git-gc.txt: expand discussion of races with other processes
7631
7632Merge branch 'mm/push-social-engineering-attack-doc'
7633
7634Doc update on fetching and pushing.
7635
7636* mm/push-social-engineering-attack-doc:
7637 doc: mention transfer data leaks in more places
7638
7639Merge branch 'jt/fetch-no-redundant-tag-fetch-map'
7640
7641Code cleanup to avoid using redundant refspecs while fetching with
7642the --tags option.
7643
7644* jt/fetch-no-redundant-tag-fetch-map:
7645 fetch: do not redundantly calculate tag refmap
7646
7647Merge branch 'jc/latin-1'
7648
7649Some platforms no longer understand "latin-1" that is still seen in
7650the wild in e-mail headers; replace them with "iso-8859-1" that is
7651more 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
7657mergetool: fix running in subdir when rerere enabled
7658
7659"git mergetool" (without any pathspec on the command line) that is
7660not run from the top-level of the working tree no longer works in
7661Git v2.11, failing to get the list of unmerged paths from the output
7662of "git rerere remaining". This regression was introduced by
766357937f70a0 ("mergetool: honor diff.orderFile", 2016-10-07).
7664
7665This is because the pathnames output by the 'git rerere remaining'
7666command are relative to the top-level directory but the 'git diff
7667--name-only' command expects its pathname arguments to be relative
7668to the current working directory. To make everything consistent,
7669cd_to_toplevel before running 'git diff --name-only' and adjust any
7670relative pathnames.
7671
7672Signed-off-by: Richard Hansen <hansenr@google.com>
7673Signed-off-by: Junio C Hamano <gitster@pobox.com>
7674
7675mergetool: take the "-O" out of $orderfile
7676
7677This will make it easier for a future commit to convert a relative
7678orderfile pathname to either absolute or relative to the top-level
7679directory. It also improves code readability.
7680
7681Signed-off-by: Richard Hansen <hansenr@google.com>
7682Signed-off-by: Junio C Hamano <gitster@pobox.com>
7683
7684t7610: add test case for rerere+mergetool+subdir bug
7685
7686If rerere is enabled and mergetool is run from a subdirectory,
7687mergetool always prints "No files need merging". Add an expected
7688failure test case for this situation.
7689
7690Signed-off-by: Richard Hansen <hansenr@google.com>
7691Signed-off-by: Junio C Hamano <gitster@pobox.com>
7692
7693t7610: spell 'git reset --hard' consistently
7694
7695Signed-off-by: Richard Hansen <hansenr@google.com>
7696Signed-off-by: Junio C Hamano <gitster@pobox.com>
7697
7698t7610: don't assume the checked-out commit
7699
7700Always check out the required commit at the beginning of the test so
7701that a failure in a previous test does not cause the test to work off
7702of the wrong commit.
7703
7704This is a step toward making the tests more independent so that if one
7705test fails it doesn't cause subsequent tests to fail.
7706
7707Signed-off-by: Richard Hansen <hansenr@google.com>
7708Signed-off-by: Junio C Hamano <gitster@pobox.com>
7709
7710t7610: always work on a test-specific branch
7711
7712Create and use a test-specific branch when the test might create a
7713commit. This is not always necessary for correctness, but it improves
7714debuggability by ensuring a commit created by test #N shows up on the
7715testN branch, not the branch for test #N-1.
7716
7717Signed-off-by: Richard Hansen <hansenr@google.com>
7718Signed-off-by: Junio C Hamano <gitster@pobox.com>
7719
7720t7610: delete some now-unnecessary 'git reset --hard' lines
7721
7722Tests now always run 'git reset --hard' at the end (even if they
7723fail), so it's no longer necessary to run 'git reset --hard' at the
7724beginning of a test.
7725
7726Signed-off-by: Richard Hansen <hansenr@google.com>
7727Signed-off-by: Junio C Hamano <gitster@pobox.com>
7728
7729t7610: run 'git reset --hard' after each test to clean up
7730
7731Use test_when_finished to run 'git reset --hard' after each test so
7732that the repository is left in a saner state for the next test.
7733
7734This is a step toward making the tests more independent so that if one
7735test fails it doesn't cause subsequent tests to fail.
7736
7737Signed-off-by: Richard Hansen <hansenr@google.com>
7738Signed-off-by: Junio C Hamano <gitster@pobox.com>
7739
7740t7610: don't rely on state from previous test
7741
7742If the repository must be in a particular state (beyond what is
7743already done by the 'setup' test case) before the test can run, make
7744the necessary repository changes in the test script even if it means
7745duplicating some lines of code from the previous test case.
7746
7747This is a step toward making the tests more independent so that if one
7748test fails it doesn't cause subsequent tests to fail.
7749
7750Signed-off-by: Richard Hansen <hansenr@google.com>
7751Signed-off-by: Junio C Hamano <gitster@pobox.com>
7752
7753t7610: use test_when_finished for cleanup tasks
7754
7755This is a step toward making the tests more independent so that if one
7756test fails it doesn't cause subsequent tests to fail.
7757
7758Signed-off-by: Richard Hansen <hansenr@google.com>
7759Signed-off-by: Junio C Hamano <gitster@pobox.com>
7760
7761t7610: move setup code to the 'setup' test case
7762
7763Multiple test cases depend on these hunks, so move them to the 'setup'
7764test case. This is a step toward making the tests more independent so
7765that if one test fails it doesn't cause subsequent tests to fail.
7766
7767Signed-off-by: Richard Hansen <hansenr@google.com>
7768Signed-off-by: Junio C Hamano <gitster@pobox.com>
7769
7770t7610: update branch names to match test number
7771
7772Rename the testNN branches so that NN matches the test number. This
7773should make it easier to troubleshoot test issues. Use $test_count to
7774keep this future-proof.
7775
7776Signed-off-by: Richard Hansen <hansenr@google.com>
7777Signed-off-by: Junio C Hamano <gitster@pobox.com>
7778
7779rev-parse doc: pass "--" to rev-parse in the --prefix example
7780
7781The "--" argument avoids "ambiguous argument: unknown revision or
7782path not in the working tree" errors when a pathname argument refers
7783to a non-existent file.
7784
7785The "--" passed explicitly to set was removed because rev-parse
7786outputs the "--" argument that it is given.
7787
7788Signed-off-by: Richard Hansen <hansenr@google.com>
7789Signed-off-by: Junio C Hamano <gitster@pobox.com>
7790
7791ref-filter: Do not abruptly die when using the 'lstrip=<N>' option
7792
7793Currently when we use the 'lstrip=<N>' option, if 'N' is greater than
7794the number of components available in the refname, we abruptly end
7795program execution by calling die().
7796
7797This behavior is undesired since a single refname with few components
7798could end program execution. To avoid this, return an empty string
7799whenever the value 'N' is greater than the number of components
7800available, instead of calling die().
7801
7802Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
7803Signed-off-by: Junio C Hamano <gitster@pobox.com>
7804
7805ref-filter: rename the 'strip' option to 'lstrip'
7806
7807In preparation for the upcoming patch, where we introduce the 'rstrip'
7808option. Rename the 'strip' option to 'lstrip' to remove ambiguity.
7809
7810Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
7811Signed-off-by: Junio C Hamano <gitster@pobox.com>
7812
7813ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()
7814
7815Use the recently introduced refname_atom_parser_internal() within
7816remote_ref_atom_parser(), this provides a common base for all the ref
7817printing atoms, allowing %(upstream) and %(push) to also use the
7818':strip' option.
7819
7820The atoms '%(push)' and '%(upstream)' will retain the ':track' and
7821':trackshort' atom modifiers to themselves as they have no meaning in
7822context to the '%(refname)' and '%(symref)' atoms.
7823
7824Update the documentation and tests to reflect the same.
7825
7826Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
7827Signed-off-by: Junio C Hamano <gitster@pobox.com>
7828
7829ref-filter: introduce refname_atom_parser()
7830
7831Using refname_atom_parser_internal(), introduce refname_atom_parser()
7832which will parse the %(symref) and %(refname) atoms. Store the parsed
7833information into the 'used_atom' structure based on the modifiers used
7834along with the atoms.
7835
7836Now the '%(symref)' atom supports the ':strip' atom modifier. Update the
7837Documentation and tests to reflect this.
7838
7839Helped-by: Jeff King <peff@peff.net>
7840Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
7841Signed-off-by: Junio C Hamano <gitster@pobox.com>
7842
7843ref-filter: introduce refname_atom_parser_internal()
7844
7845Since there are multiple atoms which print refs ('%(refname)',
7846'%(symref)', '%(push)', '%(upstream)'), it makes sense to have a common
7847ground for parsing them. This would allow us to share implementations of
7848the atom modifiers between these atoms.
7849
7850Introduce refname_atom_parser_internal() to act as a common parsing
7851function for ref printing atoms. This would eventually be used to
7852introduce refname_atom_parser() and symref_atom_parser() and also be
7853internally used in remote_ref_atom_parser().
7854
7855Helped-by: Jeff King <peff@peff.net>
7856Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
7857Signed-off-by: Junio C Hamano <gitster@pobox.com>
7858
7859ref-filter: make "%(symref)" atom work with the ':short' modifier
7860
7861The "%(symref)" atom doesn't work when used with the ':short' modifier
7862because we strictly match only 'symref' for setting the 'need_symref'
7863indicator. Fix this by comparing with the valid_atom rather than the
7864used_atom.
7865
7866Add tests for %(symref) and %(symref:short) while we're here.
7867
7868Helped-by: Junio C Hamano <gitster@pobox.com>
7869Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
7870Signed-off-by: Junio C Hamano <gitster@pobox.com>
7871
7872ref-filter: add support for %(upstream:track,nobracket)
7873
7874Add support for %(upstream:track,nobracket) which will print the
7875tracking information without the brackets (i.e. "ahead N, behind M").
7876This is needed when we port branch.c to use ref-filter's printing APIs.
7877
7878Add test and documentation for the same.
7879
7880Mentored-by: Christian Couder <christian.couder@gmail.com>
7881Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
7882Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
7883Signed-off-by: Junio C Hamano <gitster@pobox.com>
7884
7885ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams
7886
7887Borrowing from branch.c's implementation print "[gone]" whenever an
7888unknown upstream ref is encountered instead of just ignoring it.
7889
7890This makes sure that when branch.c is ported over to using ref-filter
7891APIs for printing, this feature is not lost.
7892
7893Make changes to t/t6300-for-each-ref.sh and
7894Documentation/git-for-each-ref.txt to reflect this change.
7895
7896Mentored-by: Christian Couder <christian.couder@gmail.com>
7897Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
7898Helped-by : Jacob Keller <jacob.keller@gmail.com>
7899Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
7900Signed-off-by: Junio C Hamano <gitster@pobox.com>
7901
7902ref-filter: introduce format_ref_array_item()
7903
7904To allow column display, we will need to first render the output in a
7905string list to allow print_columns() to compute the proper size of
7906each column before starting the actual output. Introduce the function
7907format_ref_array_item() that does the formatting of a ref_array_item
7908to an strbuf.
7909
7910show_ref_array_item() is kept as a convenience wrapper around it which
7911obtains the strbuf and prints it the standard output.
7912
7913Mentored-by: Christian Couder <christian.couder@gmail.com>
7914Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
7915Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
7916Signed-off-by: Junio C Hamano <gitster@pobox.com>
7917
7918ref-filter: move get_head_description() from branch.c
7919
7920Move the implementation of get_head_description() from branch.c to
7921ref-filter. This gives a description of the HEAD ref if called. This
7922is used as the refname for the HEAD ref whenever the
7923FILTER_REFS_DETACHED_HEAD option is used. Make it public because we
7924need it to calculate the length of the HEAD refs description in
7925branch.c:calc_maxwidth() when we port branch.c to use ref-filter
7926APIs.
7927
7928Mentored-by: Christian Couder <christian.couder@gmail.com>
7929Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
7930Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
7931Signed-off-by: Junio C Hamano <gitster@pobox.com>
7932
7933ref-filter: modify "%(objectname:short)" to take length
7934
7935Add support for %(objectname:short=<length>) which would print the
7936abbreviated unique objectname of given length. When no length is
7937specified, the length is 'DEFAULT_ABBREV'. The minimum length is
7938'MINIMUM_ABBREV'. The length may be exceeded to ensure that the
7939provided object name is unique.
7940
7941Add tests and documentation for the same.
7942
7943Mentored-by: Christian Couder <christian.couder@gmail.com>
7944Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
7945Helped-by: Jacob Keller <jacob.keller@gmail.com>
7946Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
7947Signed-off-by: Junio C Hamano <gitster@pobox.com>
7948
7949ref-filter: implement %(if:equals=<string>) and %(if:notequals=<string>)
7950
7951Implement %(if:equals=<string>) wherein the if condition is only
7952satisfied if the value obtained between the %(if:...) and %(then) atom
7953is the same as the given '<string>'.
7954
7955Similarly, implement (if:notequals=<string>) wherein the if condition
7956is only satisfied if the value obtained between the %(if:...) and
7957%(then) atom is different from the given '<string>'.
7958
7959This 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
7961on to the used_atom of the %(then) atom, so that it can do the required
7962comparisons.
7963
7964Add tests and documentation for the same.
7965
7966Mentored-by: Christian Couder <christian.couder@gmail.com>
7967Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
7968Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
7969Signed-off-by: Junio C Hamano <gitster@pobox.com>
7970
7971ref-filter: include reference to 'used_atom' within 'atom_value'
7972
7973Ensure 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
7977Hence we can get the %(align) atom's parameters directly from the
7978'used_atom' therefore removing the necessity of passing %(align) atom's
7979parameters to 'atom_value'.
7980
7981This also acts as a preparatory patch for the upcoming patch where we
7982introduce %(if:equals=) and %(if:notequals=).
7983
7984Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
7985Signed-off-by: Junio C Hamano <gitster@pobox.com>
7986
7987ref-filter: implement %(if), %(then), and %(else) atoms
7988
7989Implement %(if), %(then) and %(else) atoms. Used as
7990%(if)...%(then)...%(end) or %(if)...%(then)...%(else)...%(end). If the
7991format string between %(if) and %(then) expands to an empty string, or
7992to only whitespaces, then the whole %(if)...%(end) expands to the string
7993following %(then). Otherwise, it expands to the string following
7994%(else), if any. Nesting of this construct is possible.
7995
7996This is in preparation for porting over `git branch -l` to use
7997ref-filter APIs for printing.
7998
7999Add documentation and tests regarding the same.
8000
8001Mentored-by: Christian Couder <christian.couder@gmail.com>
8002Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
8003Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
8004Signed-off-by: Junio C Hamano <gitster@pobox.com>
8005
8006unpack-trees: factor progress setup out of check_updates
8007
8008This makes check_updates shorter and easier to understand.
8009
8010Signed-off-by: Stefan Beller <sbeller@google.com>
8011Signed-off-by: Junio C Hamano <gitster@pobox.com>
8012
8013unpack-trees: remove unneeded continue
8014
8015The continue is the last statement in the loop, so not needed.
8016This situation arose in 700e66d66 (2010-07-30, unpack-trees: let
8017read-tree -u remove index entries outside sparse area) when statements
8018after the continue were removed.
8019
8020Signed-off-by: Stefan Beller <sbeller@google.com>
8021Signed-off-by: Junio C Hamano <gitster@pobox.com>
8022
8023unpack-trees: move checkout state into check_updates
8024
8025The checkout state was introduced via 16da134b1f9
8026(read-trees: refactor the unpack_trees() part, 2006-07-30). An attempt to
8027refactor the checkout state was done in b56aa5b268e (unpack-trees: pass
8028checkout state explicitly to check_updates(), 2016-09-13), but we can
8029go even further.
8030
8031The `struct checkout state` is not used in unpack_trees apart from
8032initializing it, so move it into the function that makes use of it,
8033which is `check_updates`.
8034
8035Signed-off-by: Stefan Beller <sbeller@google.com>
8036Reviewed-by: René Scharfe <l.s.r@web.de>
8037Signed-off-by: Junio C Hamano <gitster@pobox.com>
8038
8039.mailmap: record canonical email for Richard Hansen
8040
8041When I changed employers my work address changed from rhansen@bbn.com
8042to hansenr@google.com. Rather than map my old work address to my new,
8043map them both to my permanent personal email address. (I will still
8044use my work address in commits I submit so that my employer gets some
8045credit.)
8046
8047Signed-off-by: Richard Hansen <hansenr@google.com>
8048Signed-off-by: Junio C Hamano <gitster@pobox.com>
8049
8050pathspec: give better message for submodule related pathspec error
8051
8052Every once in a while someone complains to the mailing list to have
8053run into this weird assertion[1]. The usual response from the mailing
8054list is link to old discussions[2], and acknowledging the problem
8055stating it is known.
8056
8057This 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
8076Note: There is a case (e.g. "git -C submodule add .") in which we call
8077strip_submodule_slash_expensive, as git-add requests it via the flag
8078PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE, but the assert used to
8079trigger nevertheless, because the flag PATHSPEC_LITERAL was not set,
8080such that we executed
8081
8082 if (item->nowildcard_len < prefixlen)
8083 item->nowildcard_len = prefixlen;
8084
8085and prefixlen was not adapted (e.g. it was computed from "submodule/")
8086So in the die_inside_submodule_path function we also need handle paths,
8087that were stripped before, i.e. are the exact submodule path. This
8088is why the conditions in die_inside_submodule_path are slightly
8089different 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
8095Helped-by: Jeff King <peff@peff.net>
8096Helped-by: Junio C Hamano <gitster@pobox.com>
8097Signed-off-by: Stefan Beller <sbeller@google.com>
8098Signed-off-by: Junio C Hamano <gitster@pobox.com>
8099
8100sequencer (rebase -i): differentiate between comments and 'noop'
8101
8102In the upcoming patch, we will support rebase -i's progress
8103reporting. The progress skips comments but counts 'noop's.
8104
8105Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8106Signed-off-by: Junio C Hamano <gitster@pobox.com>
8107
8108sequencer (rebase -i): implement the 'drop' command
8109
8110The 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
8113Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8114Signed-off-by: Junio C Hamano <gitster@pobox.com>
8115
8116sequencer (rebase -i): allow rescheduling commands
8117
8118The interactive rebase has the very special magic that a cherry-pick
8119that exits with a status different from 0 and 1 signifies a failure to
8120even record that a cherry-pick was started.
8121
8122This can happen e.g. when a fast-forward fails because it would
8123overwrite untracked files.
8124
8125In that case, we must reschedule the command that we thought we already
8126had at least started successfully.
8127
8128Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8129Signed-off-by: Junio C Hamano <gitster@pobox.com>
8130
8131sequencer (rebase -i): respect strategy/strategy_opts settings
8132
8133The sequencer already has an idea about using different merge
8134strategies. We just piggy-back on top of that, using rebase -i's
8135own settings, when running the sequencer in interactive rebase mode.
8136
8137Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8138Signed-off-by: Junio C Hamano <gitster@pobox.com>
8139
8140sequencer (rebase -i): respect the rebase.autostash setting
8141
8142Git's `rebase` command inspects the `rebase.autostash` config setting
8143to determine whether it should stash any uncommitted changes before
8144rebasing and re-apply them afterwards.
8145
8146As we introduce more bits and pieces to let the sequencer act as
8147interactive rebase's backend, here is the part that adds support for
8148the autostash feature.
8149
8150Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8151Signed-off-by: Junio C Hamano <gitster@pobox.com>
8152
8153sequencer (rebase -i): run the post-rewrite hook, if needed
8154
8155Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8156Signed-off-by: Junio C Hamano <gitster@pobox.com>
8157
8158sequencer (rebase -i): record interrupted commits in rewritten, too
8159
8160When continuing after a `pick` command failed, we want that commit
8161to show up in the rewritten-list (and its notes to be rewritten), too.
8162
8163Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8164Signed-off-by: Junio C Hamano <gitster@pobox.com>
8165
8166sequencer (rebase -i): copy commit notes at end
8167
8168When rebasing commits that have commit notes attached, the interactive
8169rebase rewrites those notes faithfully at the end. The sequencer must
8170do this, too, if it wishes to do interactive rebase's job.
8171
8172Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8173Signed-off-by: Junio C Hamano <gitster@pobox.com>
8174
8175sequencer (rebase -i): set the reflog message consistently
8176
8177We 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
8179before that.
8180
8181Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8182Signed-off-by: Junio C Hamano <gitster@pobox.com>
8183
8184sequencer (rebase -i): refactor setting the reflog message
8185
8186This makes the code DRYer, with the obvious benefit that we can enhance
8187the code further in a single place.
8188
8189We can also reuse the functionality elsewhere by calling this new
8190function.
8191
8192Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8193Signed-off-by: Junio C Hamano <gitster@pobox.com>
8194
8195sequencer (rebase -i): allow fast-forwarding for edit/reword
8196
8197The sequencer already knew how to fast-forward instead of
8198cherry-picking, if possible.
8199
8200We want to continue to do this, of course, but in case of the 'reword'
8201command, we will need to call `git commit` after fast-forwarding.
8202
8203Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8204Signed-off-by: Junio C Hamano <gitster@pobox.com>
8205
8206sequencer (rebase -i): implement the 'reword' command
8207
8208This is now trivial, as all the building blocks are in place: all we need
8209to do is to flip the "edit" switch when committing.
8210
8211Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8212Signed-off-by: Junio C Hamano <gitster@pobox.com>
8213
8214sequencer (rebase -i): leave a patch upon error
8215
8216When doing an interactive rebase, we want to leave a 'patch' file for
8217further inspection by the user (even if we never tried to actually apply
8218that patch, since we're cherry-picking instead).
8219
8220Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8221Signed-off-by: Junio C Hamano <gitster@pobox.com>
8222
8223sequencer (rebase -i): update refs after a successful rebase
8224
8225An interactive rebase operates on a detached HEAD (to keep the reflog
8226of the original branch relatively clean), and updates the branch only
8227at the end.
8228
8229Now that the sequencer learns to perform interactive rebases, it also
8230needs to learn the trick to update the branch before removing the
8231directory containing the state of the interactive rebase.
8232
8233We introduce a new head_ref variable in a wider scope than necessary at
8234the moment, to allow for a later patch that prints out "Successfully
8235rebased and updated <ref>".
8236
8237Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8238Signed-off-by: Junio C Hamano <gitster@pobox.com>
8239
8240sequencer (rebase -i): the todo can be empty when continuing
8241
8242When the last command of an interactive rebase fails, the user needs to
8243resolve the problem and then continue the interactive rebase. Naturally,
8244the todo script is empty by then. So let's not complain about that!
8245
8246To that end, let's move that test out of the function that parses the
8247todo script, and into the more high-level function read_populate_todo().
8248This is also necessary by now because the lower-level parse_insn_buffer()
8249has no idea whether we are performing an interactive rebase or not.
8250
8251Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8252Signed-off-by: Junio C Hamano <gitster@pobox.com>
8253
8254sequencer (rebase -i): skip some revert/cherry-pick specific code path
8255
8256When a cherry-pick continues without a "todo script", the intention is
8257simply to pick a single commit.
8258
8259However, when an interactive rebase is continued without a "todo
8260script", it means that the last command has been completed and that we
8261now need to clean up.
8262
8263This commit guards the revert/cherry-pick specific steps so that they
8264are not executed in rebase -i mode.
8265
8266Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8267Signed-off-by: Junio C Hamano <gitster@pobox.com>
8268
8269sequencer (rebase -i): remove CHERRY_PICK_HEAD when no longer needed
8270
8271The scripted version of the interactive rebase already does that.
8272
8273Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8274Signed-off-by: Junio C Hamano <gitster@pobox.com>
8275
8276sequencer (rebase -i): allow continuing with staged changes
8277
8278When an interactive rebase is interrupted, the user may stage changes
8279before continuing, and we need to commit those changes in that case.
8280
8281Please note that the nested "if" added to the sequencer_continue() is
8282not combined into a single "if" because it will be extended with an
8283"else" clause in a later patch in this patch series.
8284
8285Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8286Signed-off-by: Junio C Hamano <gitster@pobox.com>
8287
8288sequencer (rebase -i): write an author-script file
8289
8290When the interactive rebase aborts, it writes out an author-script file
8291to record the author information for the current commit. As we are about
8292to teach the sequencer how to perform the actions behind an interactive
8293rebase, it needs to write those author-script files, too.
8294
8295Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8296Signed-off-by: Junio C Hamano <gitster@pobox.com>
8297
8298sequencer (rebase -i): implement the short commands
8299
8300For users' convenience, most rebase commands can be abbreviated, e.g.
8301'p' instead of 'pick' and 'x' instead of 'exec'. Let's teach the
8302sequencer to handle those abbreviated commands just fine.
8303
8304Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8305Signed-off-by: Junio C Hamano <gitster@pobox.com>
8306
8307sequencer (rebase -i): add support for the 'fixup' and 'squash' commands
8308
8309This is a huge patch, and at the same time a huge step forward to
8310execute the performance-critical parts of the interactive rebase in a
8311builtin command.
8312
8313Since 'fixup' and 'squash' are not only similar, but also need to know
8314about each other (we want to reduce a series of fixups/squashes into a
8315single, final commit message edit, from the user's point of view), we
8316really have to implement them both at the same time.
8317
8318Most of the actual work is done by the existing code path that already
8319handles the "pick" and the "edit" commands; We added support for other
8320features (e.g. to amend the commit message) in the patches leading up to
8321this one, yet there are still quite a few bits in this patch that simply
8322would not make sense as individual patches (such as: determining whether
8323there was anything to "fix up" in the "todo" script, etc).
8324
8325In theory, it would be possible to reuse the fast-forward code path also
8326for the fixup and the squash code paths, but in practice this would make
8327the code less readable. The end result cannot be fast-forwarded anyway,
8328therefore let's just extend the cherry-picking code path for now.
8329
8330Since the sequencer parses the entire `git-rebase-todo` script in one go,
8331fixup or squash commands without a preceding pick can be reported early
8332(in git-rebase--interactive, we could only report such errors just before
8333executing the fixup/squash).
8334
8335Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8336Signed-off-by: Junio C Hamano <gitster@pobox.com>
8337
8338sequencer (rebase -i): write the 'done' file
8339
8340In the interactive rebase, commands that were successfully processed are
8341not simply discarded, but appended to the 'done' file instead. This is
8342used e.g. to display the current state to the user in the output of
8343`git status` or the progress.
8344
8345Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8346Signed-off-by: Junio C Hamano <gitster@pobox.com>
8347
8348sequencer (rebase -i): learn about the 'verbose' mode
8349
8350When calling `git rebase -i -v`, the user wants to see some statistics
8351after the commits were rebased. Let's show some.
8352
8353The strbuf we use to perform that task will be used for other things
8354in subsequent commits, hence it is declared and initialized in a wider
8355scope than strictly needed here.
8356
8357Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8358Signed-off-by: Junio C Hamano <gitster@pobox.com>
8359
8360sequencer (rebase -i): implement the 'exec' command
8361
8362The 'exec' command is a little special among rebase -i's commands, as it
8363does *not* have a SHA-1 as first parameter. Instead, everything after the
8364`exec` command is treated as command-line to execute.
8365
8366Let's reuse the arg/arg_len fields of the todo_item structure (which hold
8367the oneline for pick/edit commands) to point to the command-line.
8368
8369Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8370Signed-off-by: Junio C Hamano <gitster@pobox.com>
8371
8372sequencer (rebase -i): implement the 'edit' command
8373
8374This patch is a straight-forward reimplementation of the `edit`
8375operation of the interactive rebase command.
8376
8377Well, not *quite* straight-forward: when stopping, the `edit`
8378command wants to write the `patch` file (which is not only the
8379patch, but includes the commit message and author information). To
8380that end, this patch requires the earlier work that taught the
8381log-tree machinery to respect the `file` setting of
8382rev_info->diffopt to write to a file stream different than stdout.
8383
8384Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8385Signed-off-by: Junio C Hamano <gitster@pobox.com>
8386
8387sequencer (rebase -i): implement the 'noop' command
8388
8389The 'noop' command is probably the most boring of all rebase -i commands
8390to support in the sequencer.
8391
8392Which makes it an excellent candidate for this first stab to add support
8393for rebase -i's commands to the sequencer.
8394
8395For 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
8398To make it easier to identify "classes" of todo_commands (such as:
8399determine whether a command is pick-like, i.e. handles a single commit),
8400let's enforce a certain order of said commands.
8401
8402Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8403Signed-off-by: Junio C Hamano <gitster@pobox.com>
8404
8405sequencer: support a new action: 'interactive rebase'
8406
8407This patch introduces a new action for the sequencer. It really does not
8408do a whole lot of its own right now, but lays the ground work for
8409patches to come. The intention, of course, is to finally make the
8410sequencer the work horse of the interactive rebase (the original idea
8411behind the "sequencer" concept).
8412
8413Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8414Signed-off-by: Junio C Hamano <gitster@pobox.com>
8415
8416sequencer: use a helper to find the commit message
8417
8418It is actually not safe to look for a commit message by looking for the
8419first empty line and skipping it.
8420
8421The find_commit_subject() function looks more carefully, so let's use
8422it. Since we are interested in the entire commit message, we re-compute
8423the string length after verifying that the commit subject is not empty
8424(in which case the entire commit message would be empty, something that
8425should not happen but that we want to handle gracefully).
8426
8427Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8428Signed-off-by: Junio C Hamano <gitster@pobox.com>
8429
8430sequencer: move "else" keyword onto the same line as preceding brace
8431
8432It is the current coding style of the Git project to write
8433
8434 if (...) {
8435 ...
8436 } else {
8437 ...
8438 }
8439
8440instead of putting the closing brace and the "else" keyword on separate
8441lines.
8442
8443Pointed out by Junio Hamano.
8444
8445Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8446Signed-off-by: Junio C Hamano <gitster@pobox.com>
8447
8448sequencer: avoid unnecessary curly braces
8449
8450This was noticed while addressing Junio Hamano's concern that some
8451"else" operators were on separate lines than the preceding closing
8452brace.
8453
8454Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8455Signed-off-by: Junio C Hamano <gitster@pobox.com>
8456
8457execv_dashed_external: wait for child on signal death
8458
8459When you hit ^C to interrupt a git command going to a pager,
8460this usually leaves the pager running. But when a dashed
8461external is in use, the pager ends up in a funny state and
8462quits (but only after eating one more character from the
8463terminal!). This fixes it.
8464
8465Explaining the reason will require a little background.
8466
8467When git runs a pager, it's important for the git process to
8468hang around and wait for the pager to finish, even though it
8469has no more data to feed it. This is because git spawns the
8470pager as a child, and thus the git process is the session
8471leader on the terminal. After it dies, the pager will finish
8472its current read from the terminal (eating the one
8473character), and then get EIO trying to read again.
8474
8475When you hit ^C, that sends SIGINT to git and to the pager,
8476and it's a similar situation. The pager ignores it, but the
8477git process needs to hang around until the pager is done. We
8478addressed that long ago in a3da882120 (pager: do
8479wait_for_pager on signal death, 2009-01-22).
8480
8481But when you have a dashed external (or an alias pointing to
8482a builtin, which will re-exec git for the builtin), there's
8483an extra process in the mix. For instance, running:
8484
8485 $ git -c alias.l=log l
8486
8487will end up with a process tree like:
8488
8489 git (parent)
8490 \
8491 git-log (child)
8492 \
8493 less (pager)
8494
8495If you hit ^C, SIGINT goes to all of them. The pager ignores
8496it, and the child git process will end up in wait_for_pager().
8497But the parent git process will die, and the usual EIO
8498trouble happens.
8499
8500So we really want the parent git process to wait_for_pager(),
8501but of course it doesn't know anything about the pager at
8502all, since it was started by the child. However, we can
8503have it wait on the git-log child, which in turn is waiting
8504on the pager. And that's what this patch does.
8505
8506There 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
8550There's no automated test here, because it would end up racy
8551and unportable. But it's easy to reproduce the situation by
8552running the log command given above and hitting ^C.
8553
8554Signed-off-by: Jeff King <peff@peff.net>
8555Signed-off-by: Junio C Hamano <gitster@pobox.com>
8556
8557execv_dashed_external: stop exiting with negative code
8558
8559When we try to exec a git sub-command, we pass along the
8560status code from run_command(). But that may return -1 if we
8561ran into an error with pipe() or execve(). This tends to
8562work (and end up as 255 due to twos-complement wraparound
8563and truncation), but in general it's probably a good idea to
8564avoid negative exit codes for portability.
8565
8566We can easily translate to the normal generic "128" code we
8567get when syscalls cause us to die.
8568
8569Signed-off-by: Jeff King <peff@peff.net>
8570Signed-off-by: Junio C Hamano <gitster@pobox.com>
8571
8572execv_dashed_external: use child_process struct
8573
8574When we run a dashed external, we use the one-liner
8575run_command_v_opt() to do so. Let's switch to using a
8576child_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
8587Signed-off-by: Jeff King <peff@peff.net>
8588Signed-off-by: Junio C Hamano <gitster@pobox.com>
8589
8590real_path: set errno when max number of symlinks is exceeded
8591
8592Set errno to ELOOP when the maximum number of symlinks is exceeded, as
8593would be done by other symlink-resolving functions.
8594
8595Signed-off-by: Brandon Williams <bmwill@google.com>
8596Signed-off-by: Junio C Hamano <gitster@pobox.com>
8597
8598real_path: prevent redefinition of MAXSYMLINKS
8599
8600The macro 'MAXSYMLINKS' is already defined on macOS and Linux in
8601<sys/param.h>. If 'MAXSYMLINKS' has already been defined, use the value
8602defined by the OS otherwise default to a value of 32 which is more
8603inline with what is allowed by many systems.
8604
8605Signed-off-by: Brandon Williams <bmwill@google.com>
8606Signed-off-by: Junio C Hamano <gitster@pobox.com>
8607
8608Makefile: put LIBS after LDFLAGS for imap-send
8609
8610This matches up with the targets git-%, git-http-fetch, git-http-push
8611and git-remote-testsvn. It must be done this way in Cygwin else lcrypto
8612cannot find lgdi32 and lws2_32.
8613
8614Signed-off-by: Steven Penny <svnpenn@gmail.com>
8615Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8616Signed-off-by: Junio C Hamano <gitster@pobox.com>
8617
8618Makefile: POSIX windres
8619
8620When 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
8625Use "-i input -o output" syntax instead.
8626
8627Signed-off-by: Steven Penny <svnpenn@gmail.com>
8628Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8629Signed-off-by: Junio C Hamano <gitster@pobox.com>
8630
8631t9813: avoid using pipes
8632
8633The exit code of the upstream in a pipe is ignored thus we should avoid
8634using it. By writing out the output of the git command to a file, we can
8635test the exit codes of both the commands.
8636
8637Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
8638Acked-by: Luke Diamand <luke@diamand.org>
8639Signed-off-by: Junio C Hamano <gitster@pobox.com>
8640
8641git_exec_path: do not return the result of getenv()
8642
8643The result of getenv() is not guaranteed by POSIX to last
8644beyond another call to getenv(), or setenv(), etc. We
8645should duplicate the string before returning to the caller
8646to avoid any surprises.
8647
8648We already keep a cached pointer to avoid repeatedly leaking
8649the result of system_path(). We can use the same pointer
8650here to avoid allocating and leaking for each call.
8651
8652Signed-off-by: Jeff King <peff@peff.net>
8653Signed-off-by: Junio C Hamano <gitster@pobox.com>
8654
8655pathspec: rename prefix_pathspec to init_pathspec_item
8656
8657Give a more relevant name to the prefix_pathspec function as it does
8658more than just prefix a pathspec element.
8659
8660Signed-off-by: Brandon Williams <bmwill@google.com>
8661Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8662Signed-off-by: Junio C Hamano <gitster@pobox.com>
8663
8664pathspec: small readability changes
8665
8666A few small changes to improve readability. This is done by grouping related
8667assignments, adding blank lines, ensuring lines are <80 characters, and
8668adding additional comments.
8669
8670Signed-off-by: Brandon Williams <bmwill@google.com>
8671Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8672Signed-off-by: Junio C Hamano <gitster@pobox.com>
8673
8674pathspec: create strip submodule slash helpers
8675
8676Factor out the logic responsible for stripping the trailing slash on
8677pathspecs referencing submodules into its own function.
8678
8679Signed-off-by: Brandon Williams <bmwill@google.com>
8680Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8681Signed-off-by: Junio C Hamano <gitster@pobox.com>
8682
8683pathspec: create parse_element_magic helper
8684
8685Factor out the logic responsible for the magic in a pathspec element
8686into its own function.
8687
8688Also avoid calling into the parsing functions when
8689`PATHSPEC_LITERAL_PATH` is specified since it causes magic to be
8690ignored and all paths to be treated as literals.
8691
8692Signed-off-by: Brandon Williams <bmwill@google.com>
8693Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8694Signed-off-by: Junio C Hamano <gitster@pobox.com>
8695
8696pathspec: create parse_long_magic function
8697
8698Factor out the logic responsible for parsing long magic into its own
8699function. As well as hoist the prefix check logic outside of the inner
8700loop as there isn't anything that needs to be done after matching
8701"prefix:".
8702
8703Signed-off-by: Brandon Williams <bmwill@google.com>
8704Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8705Signed-off-by: Junio C Hamano <gitster@pobox.com>
8706
8707pathspec: create parse_short_magic function
8708
8709Factor out the logic responsible for parsing short magic into its own
8710function.
8711
8712Signed-off-by: Brandon Williams <bmwill@google.com>
8713Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8714Signed-off-by: Junio C Hamano <gitster@pobox.com>
8715
8716pathspec: factor global magic into its own function
8717
8718Create helper functions to read the global magic environment variables
8719in additon to factoring out the global magic gathering logic into its
8720own function.
8721
8722Signed-off-by: Brandon Williams <bmwill@google.com>
8723Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8724Signed-off-by: Junio C Hamano <gitster@pobox.com>
8725
8726pathspec: simpler logic to prefix original pathspec elements
8727
8728The logic used to prefix an original pathspec element with 'prefix'
8729magic is more general purpose and can be used for more than just short
8730magic. 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
8732situations.
8733
8734Also, slightly change the logic which decides when to prefix the
8735original element in order to prevent a pathspec of "." from getting
8736converted to "" (empty string).
8737
8738Signed-off-by: Brandon Williams <bmwill@google.com>
8739Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8740Signed-off-by: Junio C Hamano <gitster@pobox.com>
8741
8742pathspec: always show mnemonic and name in unsupported_magic
8743
8744For better clarity, always show the mnemonic and name of the unsupported
8745magic being used. This lets users have a more clear understanding of
8746what magic feature isn't supported. And if they supplied a mnemonic,
8747the user will be told what its corresponding name is which will allow
8748them to more easily search the man pages for that magic type.
8749
8750This also avoids passing an extra parameter around the pathspec
8751initialization code.
8752
8753Signed-off-by: Brandon Williams <bmwill@google.com>
8754Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8755Signed-off-by: Junio C Hamano <gitster@pobox.com>
8756
8757pathspec: remove unused variable from unsupported_magic
8758
8759Removed unused variable 'n' from the 'unsupported_magic()' function.
8760
8761Signed-off-by: Brandon Williams <bmwill@google.com>
8762Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8763Signed-off-by: Junio C Hamano <gitster@pobox.com>
8764
8765pathspec: copy and free owned memory
8766
8767The 'original' string entry in a pathspec_item is only duplicated some
8768of the time, instead always make a copy of the original and take
8769ownership of the memory.
8770
8771Since both 'match' and 'original' string entries in a pathspec_item are
8772owned by the pathspec struct, they need to be freed when clearing the
8773pathspec struct (in 'clear_pathspec()') and duplicated when copying the
8774pathspec struct (in 'copy_pathspec()').
8775
8776Also change the type of 'match' and 'original' to 'char *' in order to
8777more explicitly show the ownership of the memory.
8778
8779Signed-off-by: Brandon Williams <bmwill@google.com>
8780Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8781Signed-off-by: Junio C Hamano <gitster@pobox.com>
8782
8783pathspec: remove the deprecated get_pathspec function
8784
8785Now that all callers of the old 'get_pathspec' interface have been
8786migrated to use the new pathspec struct interface it can be removed
8787from the codebase.
8788
8789Since there are no more users of the '_raw' field in the pathspec struct
8790it can also be removed. This patch also removes the old functionality
8791of modifying the const char **argv array that was passed into
8792parse_pathspec. Instead the constructed 'match' string (which is a
8793pathspec element with the prefix prepended) is only stored in its
8794corresponding pathspec_item entry.
8795
8796Signed-off-by: Brandon Williams <bmwill@google.com>
8797Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8798Signed-off-by: Junio C Hamano <gitster@pobox.com>
8799
8800ls-tree: convert show_recursive to use the pathspec struct interface
8801
8802Convert 'show_recursive()' to use the pathspec struct interface from
8803using the '_raw' entry in the pathspec struct.
8804
8805Signed-off-by: Brandon Williams <bmwill@google.com>
8806Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8807Signed-off-by: Junio C Hamano <gitster@pobox.com>
8808
8809dir: convert fill_directory to use the pathspec struct interface
8810
8811Convert 'fill_directory()' to use the pathspec struct interface from
8812using the '_raw' entry in the pathspec struct.
8813
8814Signed-off-by: Brandon Williams <bmwill@google.com>
8815Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8816Signed-off-by: Junio C Hamano <gitster@pobox.com>
8817
8818dir: remove struct path_simplify
8819
8820Teach simplify_away() and exclude_matches_pathspec() to handle struct
8821pathspec directly, eliminating the need for the struct path_simplify.
8822
8823Also renamed the len parameter to pathlen in exclude_matches_pathspec()
8824to match the parameter names used in simplify_away().
8825
8826Signed-off-by: Brandon Williams <bmwill@google.com>
8827Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8828Signed-off-by: Junio C Hamano <gitster@pobox.com>
8829
8830mv: remove use of deprecated 'get_pathspec()'
8831
8832Convert the 'internal_copy_pathspec()' function to 'prefix_path()'
8833instead of using the deprecated 'get_pathspec()' interface. Also,
8834rename 'internal_copy_pathspec()' to 'internal_prefix_pathspec()' to be
8835more descriptive of what the funciton is actually doing.
8836
8837In addition to this, fix a memory leak caused by only duplicating some
8838of the pathspec elements. Instead always duplicate all of the the
8839pathspec elements as an intermediate step (with modificationed based on
8840the passed in flags). This way the intermediate strings can then be
8841freed after getting the result from 'prefix_path()'.
8842
8843Signed-off-by: Brandon Williams <bmwill@google.com>
8844Reviewed-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
8845Signed-off-by: Junio C Hamano <gitster@pobox.com>
8846
8847git_exec_path: avoid Coverity warning about unfree()d result
8848
8849Technically, it is correct that git_exec_path() returns a possibly
8850malloc()ed string returned from system_path(), and it is sometimes
8851not allocated. Cache the result in a static variable and make sure
8852that we call system_path() only once, which plugs a potential leak.
8853
8854Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
8855Signed-off-by: Junio C Hamano <gitster@pobox.com>
8856
8857blame: output porcelain "previous" header for each file
8858
8859It's possible for content currently found in one file to
8860have originated in two separate files, each of which may
8861have been modified in some single older commit. The
8862--porcelain output generates an incorrect "previous" header
8863in this case, whereas --line-porcelain gets it right. The
8864problem is that the porcelain output tries to omit repeated
8865details of commits, and treats "previous" as a property of
8866the commit, when it is really a property of the blamed block
8867of lines.
8868
8869Let's look at an example. In a case like this, you might see
8870this 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
8885The "filename" fields tell us that the two lines are from
8886two different files. But notice that the filename also
8887appears in the "previous" field, which tells us where to
8888start a re-blame. The second content line never appeared in
8889file_one at all, so we would obviously need to re-blame from
8890file_two (or possibly even some other file, if had just been
8891renamed to file_two in SOME_SHA1).
8892
8893So 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
8905We've dropped the author and committer fields from the
8906second line, as they would just be repeats. But we can't
8907omit "filename", because it depends on the actual block of
8908blamed lines, not just the commit. This is handled by
8909emit_porcelain_details(), which will show the filename
8910either if it is the first mention of the commit _or_ if the
8911commit has multiple paths in it.
8912
8913But we don't give "previous" the same handling. It's written
8914inside emit_one_suspect_detail(), which bails early if we've
8915already seen that commit. And so the output above is wrong;
8916a reader would assume that the correct place to re-blame
8917line two is from file_one, but that's obviously nonsense.
8918
8919Let's treat "previous" the same as "filename", and show it
8920fresh whenever we know we are in a confusing case like this.
8921
8922Signed-off-by: Jeff King <peff@peff.net>
8923Signed-off-by: Junio C Hamano <gitster@pobox.com>
8924
8925blame: handle --no-abbrev
8926
8927You can already ask blame for full sha1s with "-l" or with
8928"--abbrev=40". But for consistency with other parts of Git,
8929we should support "--no-abbrev".
8930
8931Worse, blame already accepts --no-abbrev, but it's totally
8932broken. When we see --no-abbrev, the abbrev variable is set
8933to 0, which is then used as a printf precision. For regular
8934sha1s, that means we print nothing at all (which is very
8935wrong). For boundary commits we decrement it to "-1", which
8936printf interprets as "no limit" (which is almost correct,
8937except it misses the 39-length magic explained in the
8938previous commit).
8939
8940Let's detect --no-abbrev and behave as if --abbrev=40 was
8941given.
8942
8943Signed-off-by: Jeff King <peff@peff.net>
8944Signed-off-by: Junio C Hamano <gitster@pobox.com>
8945
8946blame: fix alignment with --abbrev=40
8947
8948The blame command internally adds 1 to any requested sha1
8949abbreviation length, and then subtracts it when outputting a
8950boundary commit. This lets regular and boundary sha1s line
8951up visually, but it misses one corner case.
8952
8953When the requested length is 40, we bump the value to 41.
8954But since we only have 40 characters, that's all we can show
8955(fortunately the truncation is done by a printf precision
8956field, so it never tries to read past the end of the
8957buffer). So a normal sha1 shows 40 hex characters, and a
8958boundary sha1 shows "^" plus 40 hex characters. The result
8959is misaligned.
8960
8961The "-l" option to show long sha1s gets around this by
8962skipping the "abbrev" variable entirely and just always
8963using GIT_SHA1_HEXSZ. This avoids the "+1" issue, but it
8964does mean that boundary commits only have 39 characters
8965printed. This is somewhat odd, but it does look good
8966visually: the results are aligned and left-justified. The
8967alternative would be to allocate an extra column that would
8968contain either an extra space or the "^" boundary marker.
8969
8970As this is by definition the human-readable view, it's
8971probably not that big a deal either way (and of course
8972--porcelain, etc, correctly produce correct 40-hex sha1s).
8973But for consistency, this patch teaches --abbrev=40 to
8974produce the same output as "-l" (always left-aligned, with
897540-hex for normal sha1s, and "^" plus 39-hex for
8976boundaries).
8977
8978Signed-off-by: Jeff King <peff@peff.net>
8979Signed-off-by: Junio C Hamano <gitster@pobox.com>
8980
8981files_transaction_commit(): clean up empty directories
8982
8983When deleting/pruning references, remove any directories that are made
8984empty by the deletion of loose references or of reflogs. Otherwise such
8985empty directories can survive forever and accumulate over time. (Even
8986'pack-refs', which is smart enough to remove the parent directories of
8987loose references that it prunes, leaves directories that were already
8988empty.)
8989
8990And now that files_transaction_commit() takes care of deleting the
8991parent directories of loose references that it prunes, we don't have to
8992do that in prune_ref() anymore.
8993
8994This change would be unwise if the *creation* of these directories could
8995race with our deletion of them. But the earlier changes in this patch
8996series made the creation paths robust against races, so now it is safe
8997to tidy them up more aggressively.
8998
8999Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9000Reviewed-by: Jeff King <peff@peff.net>
9001Signed-off-by: Junio C Hamano <gitster@pobox.com>
9002
9003try_remove_empty_parents(): teach to remove parents of reflogs, too
9004
9005Add a new "flags" parameter that tells the function whether to remove
9006empty parent directories of the loose reference file, of the reflog
9007file, or both. The new functionality is not yet used.
9008
9009Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9010Reviewed-by: Jeff King <peff@peff.net>
9011Signed-off-by: Junio C Hamano <gitster@pobox.com>
9012
9013try_remove_empty_parents(): don't trash argument contents
9014
9015It's bad manners and surprising and therefore error-prone.
9016
9017Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9018Reviewed-by: Jeff King <peff@peff.net>
9019Signed-off-by: Junio C Hamano <gitster@pobox.com>
9020
9021try_remove_empty_parents(): rename parameter "name" -> "refname"
9022
9023This is the standard nomenclature.
9024
9025Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9026Reviewed-by: Jeff King <peff@peff.net>
9027Signed-off-by: Junio C Hamano <gitster@pobox.com>
9028
9029delete_ref_loose(): inline function
9030
9031It was hardly doing anything anymore, and had only one caller.
9032
9033Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9034Reviewed-by: Jeff King <peff@peff.net>
9035Signed-off-by: Junio C Hamano <gitster@pobox.com>
9036
9037delete_ref_loose(): derive loose reference path from lock
9038
9039It 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
9042Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9043Reviewed-by: Jeff King <peff@peff.net>
9044Signed-off-by: Junio C Hamano <gitster@pobox.com>
9045
9046log_ref_write_1(): inline function
9047
9048Now files_log_ref_write() doesn't do anything beyond call
9049log_ref_write_1(), so inline the latter into the former.
9050
9051Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9052Reviewed-by: Jeff King <peff@peff.net>
9053Signed-off-by: Junio C Hamano <gitster@pobox.com>
9054
9055log_ref_setup(): manage the name of the reflog file internally
9056
9057Instead of writing the name of the reflog file into a strbuf that is
9058supplied by the caller but not needed there, write it into a local
9059temporary buffer and remove the strbuf parameter entirely.
9060
9061And while we're adjusting the function signature, reorder the arguments
9062to move the input parameters before the output parameters.
9063
9064Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9065Reviewed-by: Jeff King <peff@peff.net>
9066Signed-off-by: Junio C Hamano <gitster@pobox.com>
9067
9068log_ref_write_1(): don't depend on logfile argument
9069
9070It's unnecessary to pass a strbuf holding the reflog path up and down
9071the call stack now that it is hardly needed by the callers. Remove the
9072places where log_ref_write_1() uses it, in preparation for making it
9073internal to log_ref_setup().
9074
9075Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9076Reviewed-by: Jeff King <peff@peff.net>
9077Signed-off-by: Junio C Hamano <gitster@pobox.com>
9078
9079log_ref_setup(): pass the open file descriptor back to the caller
9080
9081This function will most often be called by log_ref_write_1(), which
9082wants to append to the reflog file. In that case, it is silly to close
9083the file only for the caller to reopen it immediately. So, in the case
9084that the file was opened, pass the open file descriptor back to the
9085caller.
9086
9087Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9088Reviewed-by: Jeff King <peff@peff.net>
9089Signed-off-by: Junio C Hamano <gitster@pobox.com>
9090
9091log_ref_setup(): improve robustness against races
9092
9093Change log_ref_setup() to use raceproof_create_file() to create the new
9094logfile. This makes it more robust against a race against another
9095process that might be trying to clean up empty directories while we are
9096trying to create a new logfile.
9097
9098This also means that it will only call create_leading_directories() if
9099open() fails, which should be a net win. Even in the cases where we are
9100willing to create a new logfile, it will usually be the case that the
9101logfile already exists, or if not then that the directory containing the
9102logfile already exists. In such cases, we will save some work that was
9103previously done unconditionally.
9104
9105Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9106Reviewed-by: Jeff King <peff@peff.net>
9107Signed-off-by: Junio C Hamano <gitster@pobox.com>
9108
9109log_ref_setup(): separate code for create vs non-create
9110
9111The behavior of this function (especially how it handles errors) is
9112quite different depending on whether we are willing to create the reflog
9113vs. whether we are only trying to open an existing reflog. So separate
9114the code paths.
9115
9116This also simplifies the next steps.
9117
9118Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9119Reviewed-by: Jeff King <peff@peff.net>
9120Signed-off-by: Junio C Hamano <gitster@pobox.com>
9121
9122log_ref_write(): inline function
9123
9124This function doesn't do anything beyond call files_log_ref_write(), so
9125replace it with the latter at its call sites.
9126
9127Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9128Reviewed-by: Jeff King <peff@peff.net>
9129Signed-off-by: Junio C Hamano <gitster@pobox.com>
9130
9131rename_tmp_log(): improve error reporting
9132
9133* Don't capitalize error strings
9134* Report true paths of affected files
9135
9136Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9137Reviewed-by: Jeff King <peff@peff.net>
9138Signed-off-by: Junio C Hamano <gitster@pobox.com>
9139
9140rename_tmp_log(): use raceproof_create_file()
9141
9142Besides shortening the code, this saves an unnecessary call to
9143safe_create_leading_directories_const() in almost all cases.
9144
9145Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9146Reviewed-by: Jeff King <peff@peff.net>
9147Signed-off-by: Junio C Hamano <gitster@pobox.com>
9148
9149lock_ref_sha1_basic(): use raceproof_create_file()
9150
9151Instead of coding the retry loop inline, use raceproof_create_file() to
9152make lock acquisition safe against directory creation/deletion races.
9153
9154Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9155Reviewed-by: Jeff King <peff@peff.net>
9156Signed-off-by: Junio C Hamano <gitster@pobox.com>
9157
9158lock_ref_sha1_basic(): inline constant
9159
9160`lflags` is set a single time then never changed, so just inline it.
9161
9162Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9163Reviewed-by: Jeff King <peff@peff.net>
9164Signed-off-by: Junio C Hamano <gitster@pobox.com>
9165
9166raceproof_create_file(): new function
9167
9168Add a function that tries to create a file and any containing
9169directories in a way that is robust against races with other processes
9170that might be cleaning up empty directories at the same time.
9171
9172The actual file creation is done by a callback function, which, if it
9173fails, should set errno to EISDIR or ENOENT according to the convention
9174of open(). raceproof_create_file() detects such failures, and
9175respectively either tries to delete empty directories that might be in
9176the way of the file or tries to create the containing directories. Then
9177it retries the callback function.
9178
9179This function is not yet used.
9180
9181Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9182Reviewed-by: Jeff King <peff@peff.net>
9183Signed-off-by: Junio C Hamano <gitster@pobox.com>
9184
9185safe_create_leading_directories(): set errno on SCLD_EXISTS
9186
9187The exit path for SCLD_EXISTS wasn't setting errno, which some callers
9188use to generate error messages for the user. Fix the problem and
9189document that the function sets errno correctly to help avoid similar
9190regressions in the future.
9191
9192Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9193Reviewed-by: Jeff King <peff@peff.net>
9194Signed-off-by: Junio C Hamano <gitster@pobox.com>
9195
9196safe_create_leading_directories_const(): preserve errno
9197
9198Some implementations of free() change errno (even thought they
9199shouldn't):
9200
9201 https://sourceware.org/bugzilla/show_bug.cgi?id=17924
9202
9203So preserve the errno from safe_create_leading_directories() across the
9204call to free().
9205
9206Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9207Reviewed-by: Jeff King <peff@peff.net>
9208Signed-off-by: Junio C Hamano <gitster@pobox.com>
9209
9210t5505: use "for-each-ref" to test for the non-existence of references
9211
9212Instead of looking on the filesystem inside ".git/refs/remotes/origin",
9213use "git for-each-ref" to check for leftover references under the
9214remote's old name.
9215
9216Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9217Reviewed-by: Jeff King <peff@peff.net>
9218Signed-off-by: Junio C Hamano <gitster@pobox.com>
9219
9220refname_is_safe(): correct docstring
9221
9222The 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
9226without a corresponding update to its docstring. The function is in fact
9227stricter than documented, because it now insists that the result of
9228normalizing the part of a refname following "refs/" is identical to that
9229part of the original refname. Fix the docstring.
9230
9231Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9232Reviewed-by: Jeff King <peff@peff.net>
9233Signed-off-by: Junio C Hamano <gitster@pobox.com>
9234
9235files_rename_ref(): tidy up whitespace
9236
9237Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
9238Reviewed-by: Jeff King <peff@peff.net>
9239Signed-off-by: Junio C Hamano <gitster@pobox.com>
9240
9241rebase--interactive: count squash commits above 10 correctly
9242
9243We generate the squash commit message incrementally running
9244a sed script once for each commit. It parses "This is
9245a combination of <N> commits" from the first line of the
9246existing message, adds one to <N>, and uses the result as
9247the number of our current message.
9248
9249Since f2d17068fd (i18n: rebase-interactive: mark comments of
9250squash for translation, 2016-06-17), the first line may be
9251localized, and sed uses a pretty liberal regex, looking for:
9252
9253 /^#.*([0-9][0-9]*)/
9254
9255The "[0-9][0-9]*" tries to match double digits, but it
9256doesn't quite work. The first ".*" is greedy, so if you
9257have:
9258
9259 This is a combination of 10 commits.
9260
9261it will eat up "This is a combination of 1", leaving "0" to
9262match the first "[0-9]" digit, and then skipping the
9263optional match of "[0-9]*".
9264
9265As a result, the count resets every 10 commits, and a
926615-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
9280We can fix this by making the ".*" less greedy. Instead of
9281depending on ".*?" working portably, we can just limit the
9282match to non-digit characters, which accomplishes the same
9283thing.
9284
9285Reported-by: Brandon Tolsch <btolsch@gmail.com>
9286Signed-off-by: Jeff King <peff@peff.net>
9287Signed-off-by: Junio C Hamano <gitster@pobox.com>
9288
9289branch_get_push: do not segfault when HEAD is detached
9290
9291Move the detached HEAD check from branch_get_push_1() to
9292branch_get_push() to avoid setting branch->push_tracking_ref when
9293branch is NULL.
9294
9295Signed-off-by: Kyle Meyer <kyle@kyleam.com>
9296Reviewed-by: Jeff King <peff@peff.net>
9297Signed-off-by: Junio C Hamano <gitster@pobox.com>
9298
9299archive-zip: load userdiff config
9300
9301Since 4aff646d17 (archive-zip: mark text files in archives,
93022015-03-05), the zip archiver will look at the userdiff
9303driver to decide whether a file is text or binary. This
9304usually doesn't need to look any further than the attributes
9305themselves (e.g., "-diff", etc). But if the user defines a
9306custom driver like "diff=foo", we need to look at
9307"diff.foo.binary" in the config. Prior to this patch, we
9308didn't actually load it.
9309
9310Signed-off-by: Jeff King <peff@peff.net>
9311Acked-by: René Scharfe <l.s.r@web.de>
9312Signed-off-by: Junio C Hamano <gitster@pobox.com>
9313
9314giteveryday: unbreak rendering with AsciiDoctor
9315
9316The "giteveryday" document has a callout list that contains a code
9317block. This is not a problem for AsciiDoc, but AsciiDoctor sadly was
9318explicitly designed *not* to render this correctly [*1*]. The symptom is
9319an 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
9326In Git for Windows, we rely on the speed improvement of AsciiDoctor (on
9327this developer's machine, `make -j15 html` takes roughly 30 seconds with
9328AsciiDoctor, 70 seconds with AsciiDoc), therefore we need a way to
9329render this correctly.
9330
9331The easiest way out is to simplify the callout list, as suggested by
9332AsciiDoctor's author, even while one may very well disagree with him
9333that a code block hath no place in a callout list.
9334
9335*1*: https://github.com/asciidoctor/asciidoctor/issues/1478
9336
9337Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
9338Signed-off-by: Junio C Hamano <gitster@pobox.com>
9339
9340mingw: add a regression test for pushing to UNC paths
9341
9342On Windows, there are "UNC paths" to access network (AKA shared)
9343folders, of the form \\server\sharename\directory. This provides a
9344convenient way for Windows developers to share their Git repositories
9345without having to have a dedicated server.
9346
9347Git for Windows v2.11.0 introduced a regression where pushing to said
9348UNC paths no longer works, although fetching and cloning still does, as
9349reported here: https://github.com/git-for-windows/git/issues/979
9350
9351This regression was fixed in 7814fbe3f1 (normalize_path_copy(): fix
9352pushing to //server/share/dir on Windows, 2016-12-14).
9353
9354Let's make sure that it does not regress again, by introducing a test
9355that uses so-called "administrative shares": disk volumes are
9356automatically shared under certain circumstances, e.g. the C: drive is
9357shared as \\localhost\c$. The test needs to be skipped if the current
9358directory is inaccessible via said administrative share, of course.
9359
9360Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
9361Signed-off-by: Junio C Hamano <gitster@pobox.com>
9362
9363contrib: remove gitview
9364
9365gitview did not have meaningful contributions since 2007, which gives the
9366impression it is either a mature or dead project.
9367
9368In both cases we should not carry it in git.git as the README for contrib
9369states we only want to carry experimental things to give early exposure.
9370
9371Recently a security vulnerability was reported by Javantea, so the decision
9372to either fix the issue or remove the code in question becomes a bit
9373more urgent.
9374
9375Reported-by: Javantea <jvoss@altsci.com>
9376Signed-off-by: Stefan Beller <sbeller@google.com>
9377Acked-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
9378Signed-off-by: Junio C Hamano <gitster@pobox.com>
9379
9380don't use test_must_fail with grep
9381
9382test_must_fail should only be used for testing git commands. To test the
9383failure of other commands use `!`.
9384
9385Reported-by: Stefan Beller <sbeller@google.com>
9386Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
9387Signed-off-by: Junio C Hamano <gitster@pobox.com>
9388
9389submodule.c: use GIT_DIR_ENVIRONMENT consistently
9390
9391In C code we have the luxury of having constants for all the important
9392things that are hard coded. This is the only place in C that hard codes
9393the git directory environment variable, so fix it.
9394
9395Signed-off-by: Stefan Beller <sbeller@google.com>
9396Reviewed-by: Jeff King <peff@peff.net>
9397Signed-off-by: Junio C Hamano <gitster@pobox.com>
9398
9399l10n: fixes to Catalan translation
9400
9401Signed-off-by: Jordi Mas <jmas@softcatala.org>
9402
9403l10n: zh_CN: review for git v2.11.0 l10n
9404
9405Signed-off-by: Ray Chen <oldsharp@gmail.com>
9406Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
9407
9408Merge 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
9413gitk: ru.po: Update Russian translation
9414
9415Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
9416Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
9417
9418git-p4: do not pass '-r 0' to p4 commands
9419
9420git-p4 crashes when used with a very old p4 client version
9421that does not support the '-r <number>' option in its commands.
9422
9423Allow making git-p4 work with old p4 clients by setting git-p4.retries to 0.
9424
9425Alternatively git-p4.retries could be made opt-in.
9426But since only very old, barely maintained p4 versions don't support
9427the '-r' option, the setting-retries-to-0 workaround would do.
9428
9429The "-r retries" option is present in Perforce 2012.2 Command Reference,
9430but absent from Perforce 2012.1 Command Reference.
9431
9432Signed-off-by: Igor Kushnir <igorkuo@gmail.com>
9433Acked-by: Lars Schneider <larsxschneider@gmail.com>
9434Reviewed-by: Luke Diamand <luke@diamand.org>
9435Signed-off-by: Junio C Hamano <gitster@pobox.com>
9436
9437repack: die on incremental + write-bitmap-index
9438
9439The bitmap index only works for single packs, so requesting an
9440incremental repack with bitmap indexes makes no sense.
9441
9442Signed-off-by: David Turner <dturner@twosigma.com>
9443Signed-off-by: Junio C Hamano <gitster@pobox.com>
9444
9445auto gc: don't write bitmaps for incremental repacks
9446
9447When git gc --auto does an incremental repack of loose objects, we do
9448not expect to be able to write a bitmap; it is very likely that
9449objects in the new pack will have references to objects outside of the
9450pack. So we shouldn't try to write a bitmap, because doing so will
9451likely issue a warning.
9452
9453This warning was making its way into gc.log. When the gc.log was
9454present, future auto gc runs would refuse to run.
9455
9456Patch by Jeff King.
9457Bug report, test, and commit message by David Turner.
9458
9459Signed-off-by: David Turner <dturner@twosigma.com>
9460Signed-off-by: Jeff King <peff@peff.net>
9461Signed-off-by: Junio C Hamano <gitster@pobox.com>
9462
9463rm: absorb a submodules git dir before deletion
9464
9465When deleting a submodule, we need to keep the actual git directory around,
9466such that we do not lose local changes in there and at a later checkout
9467of the submodule we don't need to clone it again.
9468
9469Now that the functionality is available to absorb the git directory of a
9470submodule, rewrite the checking in git-rm to not complain, but rather
9471relocate the git directories inside the superproject.
9472
9473An alternative solution was discussed to have a function
9474`depopulate_submodule`. That would couple the check for its git directory
9475and possible relocation before the the removal, such that it is less
9476likely to miss the check in the future. But the indirection with such
9477a function added seemed also complex. The reason for that was that this
9478possible move of the git directory was also implemented in
9479`ok_to_remove_submodule`, such that this function could truthfully
9480answer whether it is ok to remove the submodule.
9481
9482The solution proposed here defers all these checks to the caller.
9483
9484Signed-off-by: Stefan Beller <sbeller@google.com>
9485Signed-off-by: Junio C Hamano <gitster@pobox.com>
9486
9487submodule: rename and add flags to ok_to_remove_submodule
9488
9489In different contexts the question "Is it ok to delete a submodule?"
9490may be answered differently.
9491
9492In 293ab15eea (submodule: teach rm to remove submodules unless they
9493contain a git directory, 2012-09-26) a case was made that we can safely
9494ignore ignored untracked files for removal as we explicitely ask for the
9495removal of the submodule.
9496
9497In a later patch we want to remove submodules even when the user doesn't
9498explicitly ask for it (e.g. checking out a tree-ish in which the submodule
9499doesn't exist). In that case we want to be more careful when it comes
9500to deletion of untracked files. As of this patch it is unclear how this
9501will be implemented exactly, so we'll offer flags in which the caller
9502can specify how the different untracked files ought to be handled.
9503
9504As the flags allow the function to not die on an error when spawning
9505a child process, we need to find an appropriate return code for the
9506case when the child process could not be started. As in that case we
9507cannot tell if the submodule is ok to remove, we'd want to return 'false'.
9508
9509As only 0 is understood as false, rename the function to invert the
9510meaning, i.e. the return code of 0 signals the removal of the submodule
9511is fine, and other values can be used to return a more precise answer
9512what went wrong.
9513
9514Signed-off-by: Stefan Beller <sbeller@google.com>
9515Signed-off-by: Junio C Hamano <gitster@pobox.com>
9516
9517submodule: modernize ok_to_remove_submodule to use argv_array
9518
9519Instead of constructing the NULL terminated array ourselves, we
9520should make use of the argv_array infrastructure.
9521
9522While at it, adapt the error messages to reflect the actual invocation.
9523
9524Signed-off-by: Stefan Beller <sbeller@google.com>
9525Signed-off-by: Junio C Hamano <gitster@pobox.com>
9526
9527submodule.h: add extern keyword to functions
9528
9529As the upcoming series will add a lot of functions to the submodule
9530header, let's first make the header consistent to the rest of the project
9531by adding the extern keyword to functions.
9532
9533As per the CodingGuidelines we try to stay below 80 characters per line,
9534so adapt all those functions to stay below 80 characters that are already
9535using more than one line. Those function using just one line are better
9536kept in one line than breaking them up into multiple lines just for the
9537goal of staying below the character limit as it makes grepping
9538for functions easier if they are one liners.
9539
9540Signed-off-by: Stefan Beller <sbeller@google.com>
9541Signed-off-by: Junio C Hamano <gitster@pobox.com>
9542
9543worktree: initialize return value for submodule_uses_worktrees
9544
9545When the worktrees directory is empty, the `ret` will be returned
9546uninitialized. Fix it by initializing the value.
9547
9548Signed-off-by: Stefan Beller <sbeller@google.com>
9549Signed-off-by: Junio C Hamano <gitster@pobox.com>
9550
9551Fourth batch for 2.12
9552
9553Signed-off-by: Junio C Hamano <gitster@pobox.com>
9554
9555Merge branch 'jc/lock-report-on-error'
9556
9557* jc/lock-report-on-error:
9558 lockfile: move REPORT_ON_ERROR bit elsewhere
9559
9560lockfile: move REPORT_ON_ERROR bit elsewhere
9561
9562There was LOCK_NO_DEREF defined as 2 = 1<<1 with the same value,
9563which was missed due to a huge comment block. Deconflict by moving
9564the new one to 4 = 1<<2 for now.
9565
9566Signed-off-by: Junio C Hamano <gitster@pobox.com>
9567
9568Merge branch 'js/mingw-isatty'
9569
9570Update the isatty() emulation for Windows by updating the previous
9571hack 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
9578Merge branch 'ls/p4-lfs'
9579
9580Update GitLFS integration with "git p4".
9581
9582* ls/p4-lfs:
9583 git-p4: add diff/merge properties to .gitattributes for GitLFS files
9584
9585Merge branch 'va/i18n-even-more'
9586
9587* va/i18n-even-more:
9588 i18n: fix misconversion in shell scripts
9589
9590Merge branch 'lt/shortlog-by-committer'
9591
9592"git shortlog" learned "--committer" option to group commits by
9593committer, 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
9600Merge branch 'mk/mingw-winansi-ttyname-termination-fix'
9601
9602A potential but unlikely buffer overflow in Windows port has been
9603fixed.
9604
9605* mk/mingw-winansi-ttyname-termination-fix:
9606 mingw: consider that UNICODE_STRING::Length counts bytes
9607
9608Merge branch 'gv/p4-multi-path-commit-fix'
9609
9610"git p4" that tracks multile p4 paths imported a single changelist
9611that touches files in these multiple paths as one commit, followed
9612by 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
9617Merge branch 'jk/difftool-in-subdir'
9618
9619Even though an fix was attempted in Git 2.9.3 days, but running
9620"git difftool --dir-diff" from a subdirectory never worked. This
9621has 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
9629Merge 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
9636Merge branch 'ls/filter-process'
9637
9638Doc update.
9639
9640* ls/filter-process:
9641 t0021: fix flaky test
9642 docs: warn about possible '=' in clean/smudge filter process values
9643
9644Merge branch 'bw/transport-protocol-policy'
9645
9646Finer-grained control of what protocols are allowed for transports
9647during clone/fetch/push have been enabled via a new configuration
9648mechanism.
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
9658Merge branch 'cp/merge-continue'
9659
9660"git merge --continue" has been added as a synonym to "git commit"
9661to 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
9669Merge branch 'va/i18n-perl-scripts'
9670
9671Porcelain 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
9691Merge branch 'sb/submodule-config-cleanup'
9692
9693Minor 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
9700Merge branch 'jc/push-default-explicit'
9701
9702A lazy "git push" without refspec did not internally use a fully
9703specified refspec to perform 'current', 'simple', or 'upstream'
9704push, 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
9710l10n: New Catalan translation maintainer
9711
9712Signed-off-by: Jordi Mas <jmas@softcatala.org>
9713
9714diff: retire "compaction" heuristics
9715
9716When a patch inserts a block of lines, whose last lines are the
9717same as the existing lines that appear before the inserted block,
9718"git diff" can choose any place between these existing lines as the
9719boundary between the pre-context and the added lines (adjusting the
9720end of the inserted block as appropriate) to come up with variants
9721of the same patch, and some variants are easier to read than others.
9722
9723We have been trying to improve the choice of this boundary, and Git
97242.11 shipped with an experimental "compaction-heuristic". Since
9725then another attempt to improve the logic further resulted in a new
9726"indent-heuristic" logic. It is agreed that the latter gives better
9727result overall, and the former outlived its usefulness.
9728
9729Retire "compaction", and keep "indent" as an experimental feature.
9730The latter hopefully will be turned on by default in a future
9731release, but that should be done as a separate step.
9732
9733Suggested-by: Jeff King <peff@peff.net>
9734Signed-off-by: Junio C Hamano <gitster@pobox.com>
9735
9736git-svn: escape backslashes in refnames
9737
9738This brings git-svn refname escaping up-to-date with
9739commit a4c2e69936df8dd0b071b85664c6cc6a4870dd84
9740("Disallow '\' in ref names") from May 2009.
9741
9742Reported-by: Michael Fladischer <michael@fladi.at>
9743Message-ID: <cb8cd9b1-9882-64d2-435d-40d0b2b82d59@fladi.at>
9744Signed-off-by: Eric Wong <e@80x24.org>
9745
9746config.abbrev: document the new default that auto-scales
9747
9748We somehow forgot to update the "default is 7" in the
9749documentation. Also give a way to explicitly ask the auto-scaling
9750by setting config.abbrev to "auto".
9751
9752Signed-off-by: Junio C Hamano <gitster@pobox.com>
9753
9754config.c: handle lock file in error case in git_config_rename_...
9755
9756We could rely on atexit() to clean up everything, but let's be
9757explicit when we can. And it's good anyway because the function is
9758called the second time in the same process, we're in trouble.
9759
9760This function should not affect the successful case because after
9761commit_lock_file() is called, rollback_lock_file() becomes no-op,
9762as long as it is initialized.
9763
9764Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
9765Signed-off-by: Junio C Hamano <gitster@pobox.com>
9766
9767grep: search history of moved submodules
9768
9769If a submodule was renamed at any point since it's inception then if you
9770were to try and grep on a commit prior to the submodule being moved, you
9771wouldn't be able to find a working directory for the submodule since the
9772path in the past is different from the current path.
9773
9774This patch teaches grep to find the .git directory for a submodule in
9775the parents .git/modules/ directory in the event the path to the
9776submodule in the commit that is being searched differs from the state of
9777the currently checked out commit. If found, the child process that is
9778spawned to grep the submodule will chdir into its gitdir instead of a
9779working directory.
9780
9781In order to override the explicit setting of submodule child process's
9782gitdir environment variable (which was introduced in '10f5c526')
9783`GIT_DIR_ENVIORMENT` needs to be pushed onto child process's env_array.
9784This allows the searching of history from a submodule's gitdir, rather
9785than from a working directory.
9786
9787Signed-off-by: Brandon Williams <bmwill@google.com>
9788Signed-off-by: Junio C Hamano <gitster@pobox.com>
9789
9790grep: enable recurse-submodules to work on <tree> objects
9791
9792Teach grep to recursively search in submodules when provided with a
9793<tree> object. This allows grep to search a submodule based on the state
9794of the submodule that is present in a commit of the super project.
9795
9796When grep is provided with a <tree> object, the name of the object is
9797prefixed to all output. In order to provide uniformity of output
9798between the parent and child processes the option `--parent-basename`
9799has been added so that the child can preface all of it's output with the
9800name of the parent's object instead of the name of the commit SHA1 of
9801the 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
9807to:
9808
9809 HEAD:file
9810 HEAD:sub/file
9811
9812Signed-off-by: Brandon Williams <bmwill@google.com>
9813Signed-off-by: Junio C Hamano <gitster@pobox.com>
9814
9815grep: optionally recurse into submodules
9816
9817Allow grep to recognize submodules and recursively search for patterns in
9818each submodule. This is done by forking off a process to recursively
9819call grep on each submodule. The top level --super-prefix option is
9820used to pass a path to the submodule which can in turn be used to
9821prepend to output or in pathspec matching logic.
9822
9823Recursion only occurs for submodules which have been initialized and
9824checked out by the parent project. If a submodule hasn't been
9825initialized and checked out it is simply skipped.
9826
9827In order to support the existing multi-threading infrastructure in grep,
9828output from each child process is captured in a strbuf so that it can be
9829later printed to the console in an ordered fashion.
9830
9831To limit the number of theads that are created, each child process has
9832half the number of threads as its parents (minimum of 1), otherwise we
9833potentailly have a fork-bomb.
9834
9835Signed-off-by: Brandon Williams <bmwill@google.com>
9836Signed-off-by: Junio C Hamano <gitster@pobox.com>
9837
9838grep: add submodules as a grep source type
9839
9840Add `GREP_SOURCE_SUBMODULE` as a grep_source type and cases for this new
9841type in the various switch statements in grep.c.
9842
9843When initializing a grep_source with type `GREP_SOURCE_SUBMODULE` the
9844identifier can either be NULL (to indicate that the working tree will be
9845used) or a SHA1 (the REV of the submodule to be grep'd). If the
9846identifier is a SHA1 then we want to fall through to the
9847`GREP_SOURCE_SHA1` case to handle the copying of the SHA1.
9848
9849Signed-off-by: Brandon Williams <bmwill@google.com>
9850Signed-off-by: Junio C Hamano <gitster@pobox.com>
9851
9852submodules: load gitmodules file from commit sha1
9853
9854teach submodules to load a '.gitmodules' file from a commit sha1. This
9855enables the population of the submodule_cache to be based on the state
9856of the '.gitmodules' file from a particular commit.
9857
9858Signed-off-by: Brandon Williams <bmwill@google.com>
9859Signed-off-by: Junio C Hamano <gitster@pobox.com>
9860
9861submodules: add helper to determine if a submodule is initialized
9862
9863Add the `is_submodule_initialized()` helper function to submodules.c.
9864`is_submodule_initialized()` performs a check to determine if the
9865submodule at the given path has been initialized.
9866
9867Signed-off-by: Brandon Williams <bmwill@google.com>
9868Signed-off-by: Junio C Hamano <gitster@pobox.com>
9869
9870submodules: add helper to determine if a submodule is populated
9871
9872Add the `is_submodule_populated()` helper function to submodules.c.
9873`is_submodule_populated()` performes a check to see if a submodule has
9874been checkout out (and has a valid .git directory/file) at the given path.
9875
9876Signed-off-by: Brandon Williams <bmwill@google.com>
9877Signed-off-by: Junio C Hamano <gitster@pobox.com>
9878
9879real_path: canonicalize directory separators in root parts
9880
9881When an absolute path is resolved, resolution begins at the first path
9882component after the root part. The root part is just copied verbatim,
9883because it must not be inspected for symbolic links. For POSIX paths,
9884this is just the initial slash, but on Windows, the root part has the
9885forms c:\ or \\server\share. We do want to canonicalize the back-slashes
9886in the root part because these parts are compared to the result of
9887getcwd(), which does return a fully canonicalized path.
9888
9889Factor out a helper that splits off the root part, and have it
9890canonicalize the copied part.
9891
9892This change was prompted because t1504-ceiling-dirs.sh caught a breakage
9893in GIT_CEILING_DIRECTORIES handling on Windows.
9894
9895Signed-off-by: Johannes Sixt <j6t@kdbg.org>
9896Acked-by: Brandon Williams <bmwill@google.com>
9897Signed-off-by: Junio C Hamano <gitster@pobox.com>
9898
9899mingw: replace isatty() hack
9900
9901Git for Windows has carried a patch that depended on internals
9902of MSVC runtime, but it does not work correctly with recent MSVC
9903runtime. A replacement was written originally for compiling
9904with VC++. The patch in this message is a backport of that
9905replacement, and it also fixes the previous attempt to make
9906isatty() tell that /dev/null is *not* an interactive terminal.
9907
9908Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
9909Tested-by: Beat Bolli <dev+git@drbeat.li>
9910Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
9911Signed-off-by: Junio C Hamano <gitster@pobox.com>
9912
9913mingw: fix colourization on Cygwin pseudo terminals
9914
9915Git only colours the output and uses pagination if isatty() returns 1.
9916MSYS2 and Cygwin emulate pseudo terminals via named pipes, meaning that
9917isatty() returns 0.
9918
9919f7f90e0f4f (mingw: make isatty() recognize MSYS2's pseudo terminals
9920(/dev/pty*), 2016-04-27) fixed this for MSYS2 terminals, but not for
9921Cygwin.
9922
9923The named pipes that Cygwin and MSYS2 use are very similar. MSYS2 PTY pipes
9924are called 'msys-*-pty*' and Cygwin uses 'cygwin-*-pty*'. This commit
9925modifies the existing check to allow both MSYS2 and Cygwin PTY pipes to be
9926identified as TTYs.
9927
9928Note that pagination is still broken when running Git for Windows from
9929within Cygwin, as MSYS2's less.exe is spawned (and does not like to
9930interact with Cygwin's PTY).
9931
9932This partially fixes https://github.com/git-for-windows/git/issues/267
9933
9934Signed-off-by: Alan Davies <alan.n.davies@gmail.com>
9935Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
9936Signed-off-by: Junio C Hamano <gitster@pobox.com>
9937
9938mingw: adjust is_console() to work with stdin
9939
9940When 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
9942GetConsoleOutputBufferInfo() function as a tell-tale.
9943
9944However, that does not work for *input* handles associated with a
9945console. Let's just use the GetConsoleMode() function for input handles,
9946and since it does not work on output handles fall back to the previous
9947method for those.
9948
9949This patch prepares for using is_console() instead of my previous
9950misguided attempt in cbb3f3c9b1 (mingw: intercept isatty() to handle
9951/dev/null as Git expects it, 2016-12-11) that broke everything on
9952Windows.
9953
9954Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
9955Signed-off-by: Junio C Hamano <gitster@pobox.com>
9956
9957Third batch for 2.12
9958
9959Signed-off-by: Junio C Hamano <gitster@pobox.com>
9960
9961Merge branch 'jt/mailinfo-fold-in-body-headers'
9962
9963Fix for NDEBUG builds.
9964
9965* jt/mailinfo-fold-in-body-headers:
9966 mailinfo.c: move side-effects outside of assert
9967
9968Merge branch 'jk/index-pack-wo-repo-from-stdin'
9969
9970"git index-pack --stdin" needs an access to an existing repository,
9971but "git index-pack file.pack" to generate an .idx file that
9972corresponds 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
9980Merge branch 'jk/parseopt-usage-msg-opt'
9981
9982The function usage_msg_opt() has been updated to say "fatal:"
9983before the custom message programs give, when they want to die
9984with a message about wrong command line options followed by the
9985standard usage string.
9986
9987* jk/parseopt-usage-msg-opt:
9988 parse-options: print "fatal:" before usage_msg_opt()
9989
9990Merge branch 'jk/quote-env-path-list-component'
9991
9992A recent update to receive-pack to make it easier to drop garbage
9993objects made it clear that GIT_ALTERNATE_OBJECT_DIRECTORIES cannot
9994have a pathname with a colon in it (no surprise!), and this in turn
9995made it impossible to push into a repository at such a path. This
9996has been fixed by introducing a quoting mechanism used when
9997appending 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
10005Merge branch 'vs/submodule-clone-nested-submodules-alternates'
10006
10007"git clone --reference $there --recurse-submodules $super" has been
10008taught to guess repositories usable as references for submodules of
10009$super that are embedded in $there while making a clone of the
10010superproject borrow objects from $there; extend the mechanism to
10011also allow submodules of these submodules to borrow repositories
10012embedded in these clones of the submodules embedded in the clone of
10013the superproject.
10014
10015* vs/submodule-clone-nested-submodules-alternates:
10016 submodule--helper: set alternateLocation for cloned submodules
10017
10018Merge branch 'nd/shallow-fixup'
10019
10020Code 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
10030Merge branch 'sb/sequencer-abort-safety'
10031
10032Unlike "git am --abort", "git cherry-pick --abort" moved HEAD back
10033to where cherry-pick started while picking multiple changes, when
10034the cherry-pick stopped to ask for help from the user, and the user
10035did "git reset --hard" to a different commit in order to re-attempt
10036the 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
10046t5615-alternate-env: double-quotes in file names do not work on Windows
10047
10048Protect a recently added test case with !MINGW.
10049
10050Signed-off-by: Johannes Sixt <j6t@kdbg.org>
10051Signed-off-by: Junio C Hamano <gitster@pobox.com>
10052
10053fast-import: properly fanout notes when tree is imported
10054
10055In typical uses of fast-import, trees are inherited from a parent
10056commit. 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
10061However, when trees are imported, rather than inherited, that is not the
10062case. One can import a tree with a filemodify command, replacing the
10063root tree object.
10064
10065e.g.
10066 "M 040000 $some_sha1 \n"
10067
10068In this case, the tree_entry for the branch looks like:
10069
10070 .versions[1].sha1 = $some_sha1
10071 .tree = NULL
10072
10073When adding new notes with the notemodify command, do_change_note_fanout
10074is called to get a notes count, and to do so, it loops over the
10075tree_entry->tree, but doesn't do anything when the tree is NULL.
10076
10077In the latter case above, it means do_change_note_fanout thinks the tree
10078contains no notes, and new notes are added with no fanout.
10079
10080Interestingly, do_change_note_fanout does check whether subdirectories
10081have a NULL .tree, in which case it uses load_tree(). Which means the
10082right behaviour happens when using the filemodify command to import
10083subdirectories.
10084
10085This change makes do_change_note_fanount call load_tree() whenever the
10086tree_entry it is given has no tree loaded, making all cases handled
10087equally.
10088
10089Signed-off-by: Mike Hommey <mh@glandium.org>
10090Reviewed-by: Johan Herland <johan@herland.net>
10091Signed-off-by: Junio C Hamano <gitster@pobox.com>
10092
10093t4201: make tests work with and without the MINGW prerequiste
10094
10095Make sure the tests do not depend on the result of the previous
10096tests. With MINGW prerequisite satisfied, a "reset to original and
10097rebuild" in an earlier test was skipped, resulting in different
10098history being tested with this and the next tests.
10099
10100Signed-off-by: Junio C Hamano <gitster@pobox.com>
10101
10102push: add option to push only submodules
10103
10104Teach push the --recurse-submodules=only option. This enables push
10105to recursively push all unpushed submodules while leaving the
10106superproject unpushed.
10107
10108This is a desirable feature in a scenario where updates to the
10109superproject are handled automatically by some other means, perhaps
10110a tool like Gerrit code review. In this scenario, a developer could
10111make a change which spans multiple submodules and then push their
10112commits for code review. Upon completion of the code review, their
10113commits can be accepted and applied to their respective submodules
10114while the code review tool can then automatically update the
10115superproject to the most recent SHA1 of each submodule. This would
10116reduce the merge conflicts in the superproject that could occur if
10117multiple people are contributing to the same submodule.
10118
10119Signed-off-by: Brandon Williams <bmwill@google.com>
10120Signed-off-by: Junio C Hamano <gitster@pobox.com>
10121
10122submodules: add RECURSE_SUBMODULES_ONLY value
10123
10124Add the `RECURSE_SUBMODULES_ONLY` enum value to submodule.h. This enum
10125value will be used in a later patch to push to indicate that only
10126submodules should be pushed, while the superproject should remain
10127unpushed.
10128
10129Signed-off-by: Brandon Williams <bmwill@google.com>
10130Signed-off-by: Junio C Hamano <gitster@pobox.com>
10131
10132transport: reformat flag #defines to be more readable
10133
10134All of the #defines for the TRANSPORT_* flags are hardcoded to be
10135powers of two. This can be error prone when adding a new flag and
10136is difficult to read. Update these defines to instead use a shift
10137operation to generate the flags and reformat them.
10138
10139Signed-off-by: Brandon Williams <bmwill@google.com>
10140Signed-off-by: Junio C Hamano <gitster@pobox.com>
10141
10142config.c: rename label unlock_and_out
10143
10144There are two ways to unlock a file: commit, or revert. Rename it to
10145commit_and_out to avoid confusion.
10146
10147Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
10148Signed-off-by: Junio C Hamano <gitster@pobox.com>
10149
10150config.c: handle error case for fstat() calls
10151
10152Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
10153Signed-off-by: Junio C Hamano <gitster@pobox.com>
10154
10155git-p4: add diff/merge properties to .gitattributes for GitLFS files
10156
10157The `git lfs track` command generates a .gitattributes file with diff
10158and merge properties [1]. Set the same .gitattributes format for files
10159tracked 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
10163Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
10164Reviewed-by: Luke Diamand <luke@diamand.org>
10165Signed-off-by: Junio C Hamano <gitster@pobox.com>
10166
10167i18n: fix misconversion in shell scripts
10168
10169An 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
10172a few places, and ended up showing the variable names in the
10173message, e.g.
10174
10175 $ git submodule
10176 fatal: $program_name cannot be used without a working tree.
10177
10178Catch these mistakes with
10179
10180 $ git grep -n '[^_]gettext .*\\\$'
10181
10182and fix them all to use eval_gettext instead.
10183
10184Reported-by: Josh Bleecher Snyder
10185Acked-by: Vasco Almeida <vascomalmeida@sapo.pt>
10186Signed-off-by: Junio C Hamano <gitster@pobox.com>
10187
10188mailinfo.c: move side-effects outside of assert
10189
10190Since 6b4b013f18 (mailinfo: handle in-body header continuations,
101912016-09-20, v2.11.0) mailinfo.c has contained new code with an
10192assert of the form:
10193
10194 assert(call_a_function(...))
10195
10196The function in question, check_header, has side effects. This
10197means that when NDEBUG is defined during a release build the
10198function call is omitted entirely, the side effects do not
10199take place and tests (fortunately) start failing.
10200
10201Since the only time that mi->inbody_header_accum is appended to is
10202in check_inbody_header, and appending onto a blank
10203mi->inbody_header_accum always happens when is_inbody_header is
10204true, this guarantees a prefix that causes check_header to always
10205return true.
10206
10207Therefore replace the assert with an if !check_header + DIE
10208combination to reflect this.
10209
10210Helped-by: Jonathan Tan <jonathantanmy@google.com>
10211Helped-by: Jeff King <peff@peff.net>
10212Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
10213Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
10214Signed-off-by: Junio C Hamano <gitster@pobox.com>
10215
10216mingw: consider that UNICODE_STRING::Length counts bytes
10217
10218UNICODE_STRING::Length field means size of buffer in bytes[1],
10219despite of buffer itself being array of wchar_t. Because of that
10220terminating zero is placed twice as far. Fix it.
10221
10222[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa380518.aspx
10223
10224Signed-off-by: Max Kirillov <max@max630.net>
10225Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
10226Signed-off-by: Junio C Hamano <gitster@pobox.com>
10227
10228Second batch for 2.12
10229
10230Signed-off-by: Junio C Hamano <gitster@pobox.com>
10231
10232Merge 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
10240Merge branch 'da/mergetool-xxdiff-hotkey'
10241
10242The way to specify hotkeys to "xxdiff" that is used by "git
10243mergetool" has been modernized to match recent versions of xxdiff.
10244
10245* da/mergetool-xxdiff-hotkey:
10246 mergetools: fix xxdiff hotkeys
10247
10248Merge branch 'lr/doc-fix-cet'
10249
10250* lr/doc-fix-cet:
10251 date-formats.txt: Typo fix
10252
10253Merge branch 'sb/t3600-cleanup'
10254
10255Code cleanup.
10256
10257* sb/t3600-cleanup:
10258 t3600: slightly modernize style
10259 t3600: remove useless redirect
10260
10261Merge branch 'jc/pull-rebase-ff'
10262
10263"git pull --rebase", when there is no new commits on our side since
10264we forked from the upstream, should be able to fast-forward without
10265invoking "git rebase", but it didn't.
10266
10267* jc/pull-rebase-ff:
10268 pull: fast-forward "pull --rebase=true"
10269
10270Merge branch 'ld/p4-worktree'
10271
10272"git p4" didn't interact with the internal of .git directory
10273correctly in the modern "git-worktree"-enabled world.
10274
10275* ld/p4-worktree:
10276 git-p4: support git worktrees
10277
10278Merge branch 'jk/make-tags-find-sources-tweak'
10279
10280Update 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
10288Merge branch 'js/normalize-path-copy-ceil'
10289
10290A pathname that begins with "//" or "\\" on Windows is special but
10291path 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
10296Merge branch 'bb/unicode-9.0'
10297
10298The 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
10308Merge branch 'jk/readme-gmane-is-no-more'
10309
10310* jk/readme-gmane-is-no-more:
10311 README: replace gmane link with public-inbox
10312
10313Merge branch 'jc/lock-report-on-error'
10314
10315Git 2.11 had a minor regression in "merge --ff-only" that competed
10316with another process that simultanously attempted to update the
10317index. We used to explain what went wrong with an error message,
10318but the new code silently failed. The error message has been
10319resurrected.
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
10326Merge branch 'jk/xdiff-drop-xdl-fast-hash'
10327
10328Retire the "fast hash" that had disastrous performance issues in
10329some corner cases.
10330
10331* jk/xdiff-drop-xdl-fast-hash:
10332 xdiff: drop XDL_FAST_HASH
10333
10334Merge branch 'nd/rebase-forget'
10335
10336"git rebase" learned "--quit" option, which allows a user to
10337remove the metadata left by an earlier "git rebase" that was
10338manually aborted without using "git rebase --abort".
10339
10340* nd/rebase-forget:
10341 rebase: add --quit to cleanup rebase, leave everything else untouched
10342
10343Merge branch 'jk/trailers-placeholder-in-pretty'
10344
10345In addition to %(subject), %(body), "log --pretty=format:..."
10346learned 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
10352Merge branch 'ak/commit-only-allow-empty'
10353
10354"git commit --allow-empty --only" (no pathspec) with dirty index
10355ought to be an acceptable way to create a new commit that does not
10356change any paths, but it was forbidden, perhaps because nobody
10357needed 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
10363Merge branch 'da/difftool-dir-diff-fix'
10364
10365"git difftool --dir-diff" had a minor regression when started from
10366a subdirectory, which has been fixed.
10367
10368* da/difftool-dir-diff-fix:
10369 difftool: fix dir-diff index creation when in a subdirectory
10370
10371Merge 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
10378Merge branch 'rj/git-version-gen-do-not-force-abbrev'
10379
10380A 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
10385Merge branch 'jk/stash-disable-renames-internally'
10386
10387When diff.renames configuration is on (and with Git 2.9 and later,
10388it is enabled by default, which made it worse), "git stash"
10389misbehaved if a file is removed and another file with a very
10390similar content is added.
10391
10392* jk/stash-disable-renames-internally:
10393 stash: prefer plumbing over git-diff
10394
10395Merge branch 'jk/http-walker-limit-redirect'
10396
10397Update the error messages from the dumb-http client when it fails
10398to obtain loose objects; we used to give sensible error message
10399only upon 404 but we now forbid unexpected redirects that needs to
10400be reported with something sensible.
10401
10402* jk/http-walker-limit-redirect:
10403 http-walker: complain about non-404 loose object errors
10404
10405Merge branch 'jk/http-walker-limit-redirect-2.9'
10406
10407Transport with dumb http can be fooled into following foreign URLs
10408that the end user does not intend to, especially with the server
10409side redirects and http-alternates mechanism, which can lead to
10410security issues. Tighten the redirection and make it more obvious
10411to 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
10420Merge branch 'nd/for-each-ref-ignore-case'
10421
10422"git branch --list" and friends learned "--ignore-case" option to
10423optionally 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
10428Merge branch 'sb/unpack-trees-grammofix'
10429
10430* sb/unpack-trees-grammofix:
10431 unpack-trees: fix grammar for untracked files in directories
10432
10433Merge branch 'ls/travis-update-p4-and-lfs'
10434
10435The 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
10440Merge branch 'ls/t0021-fixup'
10441
10442* ls/t0021-fixup:
10443 t0021: minor filter process test cleanup
10444
10445Merge branch 'ah/grammos'
10446
10447A 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
10454Merge branch 'jc/renormalize-merge-kill-safer-crlf'
10455
10456Fix a corner case in merge-recursive regression that crept in
10457during 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
10464Merge branch 'jt/use-trailer-api-in-commands'
10465
10466Commands that operate on a log message and add lines to the trailer
10467blocks, such as "format-patch -s", "cherry-pick (-x|-s)", and
10468"commit -s", have been taught to use the logic of and share the
10469code 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
10478git-p4: fix multi-path changelist empty commits
10479
10480When importing from multiple perforce paths - we may attempt to
10481import a changelist that contains files from two (or more) of these
10482depot paths. Currently, this results in multiple git commits - one
10483containing the changes, and the other(s) as empty commit(s). This
10484behavior was introduced in commit 1f90a64891 ("git-p4: reduce number
10485of server queries for fetches", 2015-12-19).
10486
10487Reproduction 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
10497Change is synced as multiple commits, one for each depot path that
10498was affected.
10499
10500Using a set, instead of a list inside p4ChangesForPaths() ensures
10501that each changelist is unique to the returned list, and therefore
10502only a single commit is generated for each changelist.
10503
10504Reported-by: James Farwell <jfarwell@vmware.com>
10505Signed-off-by: George Vanburgh <gvanburgh@bloomberg.net>
10506Reviewed-by: Luke Diamand <luke@diamand.org>
10507Signed-off-by: Junio C Hamano <gitster@pobox.com>
10508
10509git-p4: avoid crash adding symlinked directory
10510
10511When submitting to P4, if git-p4 came across a symlinked
10512directory, then during the generation of the submit diff, it would
10513try to open it as a normal file and fail.
10514
10515Spot symlinks (of any type) and output a description of the symlink
10516instead.
10517
10518Add a test case.
10519
10520Signed-off-by: Luke Diamand <luke@diamand.org>
10521Signed-off-by: Junio C Hamano <gitster@pobox.com>
10522
10523t0021: fix flaky test
10524
10525t0021.15 creates files, adds them to the index, and commits them. All
10526this usually happens in a test run within the same second and Git cannot
10527know if the files have been changed between `add` and `commit`. Thus,
10528Git has to run the clean filter in both operations. Sometimes these
10529invocations spread over two different seconds and Git can infer that the
10530files were not changed between `add` and `commit` based on their
10531modification timestamp. The test would fail as it expects the filter
10532invocation. Remove this expectation to make the test stable.
10533
10534Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
10535Signed-off-by: Junio C Hamano <gitster@pobox.com>
10536
10537First batch for 2.12
10538
10539Signed-off-by: Junio C Hamano <gitster@pobox.com>
10540
10541Merge 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
10546Merge 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
10553Merge branch 'ld/p4-update-shelve'
10554
10555* ld/p4-update-shelve:
10556 git-p4: support updating an existing shelved changelist
10557
10558Merge branch 'vk/p4-submit-shelve'
10559
10560* vk/p4-submit-shelve:
10561 git-p4: allow submit to create shelved changelists.
10562
10563Merge branch 'da/mergetool-trust-exit-code'
10564
10565mergetool.<tool>.trustExitCode configuration variable did not apply
10566to 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
10572Merge branch 'ak/lazy-prereq-mktemp'
10573
10574Test code clean-up.
10575
10576* ak/lazy-prereq-mktemp:
10577 t7610: clean up foo.XXXXXX tmpdir
10578
10579Merge branch 'nd/worktree-list-fixup'
10580
10581The output from "git worktree list" was made in readdir() order,
10582and 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
10591Merge branch 'nd/qsort-in-merge-recursive'
10592
10593Code simplification.
10594
10595* nd/qsort-in-merge-recursive:
10596 merge-recursive.c: use string_list_sort instead of qsort
10597
10598Merge 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
10607Merge branch 'hv/submodule-not-yet-pushed-fix'
10608
10609The code in "git push" to compute if any commit being pushed in the
10610superproject binds a commit in a submodule that hasn't been pushed
10611out was overly inefficient, making it unusable even for a small
10612project that does not have any submodule but have a reasonable
10613number 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
10621Merge branch 'dt/empty-submodule-in-merge'
10622
10623An empty directory in a working tree that can simply be nuked used
10624to interfere while merging or cherry-picking a change to create a
10625submodule 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
10630Merge 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
10638index-pack: skip collision check when not in repository
10639
10640You can run "git index-pack path/to/foo.pack" outside of a
10641repository to generate an index file, or just to verify the
10642contents. There's no point in doing a collision check, since
10643we obviously do not have any objects to collide with.
10644
10645The current code will blindly look in .git/objects based on
10646the result of setup_git_env(). That effectively gives us the
10647right answer (since we won't find any objects), but it's a
10648waste of time, and it conflicts with our desire to
10649eventually get rid of the "fallback to .git" behavior of
10650setup_git_env().
10651
10652Signed-off-by: Jeff King <peff@peff.net>
10653Signed-off-by: Junio C Hamano <gitster@pobox.com>
10654
10655normalize_path_copy(): fix pushing to //server/share/dir on Windows
10656
10657normalize_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
10659style path and transforms it to /server/share/dir.
10660
10661The bug manifests when 'git push //server/share/dir master' is run,
10662because tmp_objdir_add_as_alternate() uses the path in normalized
10663form when it registers the quarantine object database via
10664link_alt_odb_entries(). Needless to say that the directory cannot be
10665accessed using the wrongly normalized path.
10666
10667Fix it by skipping all of the root part, not just a potential drive
10668prefix. offset_1st_component takes care of this, see the
10669implementation in compat/mingw.c::mingw_offset_1st_component().
10670
10671Signed-off-by: Johannes Sixt <j6t@kdbg.org>
10672Signed-off-by: Junio C Hamano <gitster@pobox.com>
10673
10674shortlog: test and document --committer option
10675
10676This puts the final touches on the feature added by
10677fbfda15fb8 (shortlog: group by committer information,
106782016-10-11).
10679
10680Signed-off-by: Jeff King <peff@peff.net>
10681Signed-off-by: Junio C Hamano <gitster@pobox.com>
10682
10683t: use nongit() function where applicable
10684
10685Many tests want to run a command outside of any git repo;
10686with the nongit() function this is now a one-liner. It saves
10687a few lines, but more importantly, it's immediately obvious
10688what the code is trying to accomplish.
10689
10690This doesn't convert every such case in the test suite; it
10691just covers those that want to do a one-off command. Other
10692cases, such as the ones in t4035, are part of a larger
10693scheme of outside-repo files, and it's less confusing for
10694them to stay consistent with the surrounding tests.
10695
10696Signed-off-by: Jeff King <peff@peff.net>
10697Signed-off-by: Junio C Hamano <gitster@pobox.com>
10698
10699index-pack: complain when --stdin is used outside of a repo
10700
10701The index-pack builtin is marked as RUN_SETUP_GENTLY,
10702because it's perfectly fine to index a pack in the
10703filesystem outside of any repository. However, --stdin mode
10704will write the result to the object database, which does not
10705make sense outside of a repository. Doing so creates a bogus
10706".git" directory with nothing in it except the newly-created
10707pack and its index.
10708
10709Instead, let's flag this as an error and abort.
10710
10711Signed-off-by: Jeff King <peff@peff.net>
10712Signed-off-by: Junio C Hamano <gitster@pobox.com>
10713
10714t5000: extract nongit function to test-lib-functions.sh
10715
10716This function abstracts the idea of running a command
10717outside of any repository (which is slightly awkward to do
10718because even if you make a non-repo directory, git may keep
10719walking up outside of the trash directory). There are
10720several scripts that use the same technique, so let's make
10721the function available for everyone.
10722
10723Signed-off-by: Jeff King <peff@peff.net>
10724Signed-off-by: Junio C Hamano <gitster@pobox.com>
10725
10726shortlog: group by committer information
10727
10728In some situations you may want to group the commits not by author,
10729but by committer instead.
10730
10731For example, when I just wanted to look up what I'm still missing from
10732linux-next in the current merge window, I don't care so much about who
10733wrote a patch, as what git tree it came from, which generally boils
10734down to "who committed it".
10735
10736So make git shortlog take a "-c" or "--committer" option to switch
10737grouping to that.
10738
10739Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
10740Signed-off-by: Junio C Hamano <gitster@pobox.com>
10741
10742merge: mark usage error strings for translation
10743
10744The nearby error messages are already marked for
10745translation, but these new ones aren't.
10746
10747Signed-off-by: Jeff King <peff@peff.net>
10748Signed-off-by: Junio C Hamano <gitster@pobox.com>
10749
10750README: replace gmane link with public-inbox
10751
10752The general status and future of gmane is unclear at this
10753point, but certainly it does not seem to be carrying
10754gmane.comp.version-control.git at all anymore. Let's point
10755to public-inbox.org, which seems to be the favored archive
10756on the list these days (and which uses message-ids in its
10757URLs, making the links somewhat future-proof).
10758
10759Reported-by: Chiel ten Brinke <ctenbrinke@gmail.com>
10760Signed-off-by: Jeff King <peff@peff.net>
10761Signed-off-by: Junio C Hamano <gitster@pobox.com>
10762
10763http: respect protocol.*.allow=user for http-alternates
10764
10765The http-walker may fetch the http-alternates (or
10766alternates) file from a remote in order to find more
10767objects. This should count as a "not from the user" use of
10768the protocol. But because we implement the redirection
10769ourselves and feed the new URL to curl, it will use the
10770CURLOPT_PROTOCOLS rules, not the more restrictive
10771CURLOPT_REDIR_PROTOCOLS.
10772
10773The ideal solution would be for each curl request we make to
10774know whether or not is directly from the user or part of an
10775alternates redirect, and then set CURLOPT_PROTOCOLS as
10776appropriate. However, that would require plumbing that
10777information through all of the various layers of the http
10778code.
10779
10780Instead, let's check the protocol at the source: when we are
10781parsing the remote http-alternates file. The only downside
10782is that if there's any mismatch between what protocol we
10783think it is versus what curl thinks it is, it could violate
10784the policy.
10785
10786To address this, we'll make the parsing err on the picky
10787side, and only allow protocols that it can parse
10788definitively. So for example, you can't elude the "http"
10789policy by asking for "HTTP://", even though curl might
10790handle it; we would reject it as unknown. The only unsafe
10791case would be if you have a URL that starts with "http://"
10792but curl interprets as another protocol. That seems like an
10793unlikely failure mode (and we are still protected by our
10794base CURLOPT_PROTOCOL setting, so the worst you could do is
10795trigger one of https, ftp, or ftps).
10796
10797Signed-off-by: Jeff King <peff@peff.net>
10798Signed-off-by: Brandon Williams <bmwill@google.com>
10799Signed-off-by: Junio C Hamano <gitster@pobox.com>
10800
10801transport: add from_user parameter to is_transport_allowed
10802
10803Add a from_user parameter to is_transport_allowed() to allow http to be
10804able to distinguish between protocol restrictions for redirects versus
10805initial requests. CURLOPT_REDIR_PROTOCOLS can now be set differently
10806from CURLOPT_PROTOCOLS to disallow use of protocols with the "user"
10807policy in redirects.
10808
10809This change allows callers to query if a transport protocol is allowed,
10810given 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
10814user.
10815
10816Signed-off-by: Brandon Williams <bmwill@google.com>
10817Signed-off-by: Junio C Hamano <gitster@pobox.com>
10818
10819http: create function to get curl allowed protocols
10820
10821Move the creation of an allowed protocols whitelist to a helper
10822function. This will be useful when we need to compute the set of
10823allowed protocols differently for normal and redirect cases.
10824
10825Signed-off-by: Brandon Williams <bmwill@google.com>
10826Signed-off-by: Junio C Hamano <gitster@pobox.com>
10827
10828transport: add protocol policy config option
10829
10830Previously the `GIT_ALLOW_PROTOCOL` environment variable was used to
10831specify a whitelist of protocols to be used in clone/fetch/push
10832commands. This patch introduces new configuration options for more
10833fine-grained control for allowing/disallowing protocols. This also has
10834the added benefit of allowing easier construction of a protocol
10835whitelist on systems where setting an environment variable is
10836non-trivial.
10837
10838Now users can specify a policy to be used for each type of protocol via
10839the 'protocol.<name>.allow' config option. A default policy for all
10840unconfigured protocols can be set with the 'protocol.allow' config
10841option. If no user configured default is made git will allow known-safe
10842protocols (http, https, git, ssh, file), disallow known-dangerous
10843protocols (ext), and have a default policy of `user` for all other
10844protocols.
10845
10846The supported policies are `always`, `never`, and `user`. The `user`
10847policy can be used to configure a protocol to be usable when explicitly
10848used by a user, while disallowing it for commands which run
10849clone/fetch/push commands without direct user intervention (e.g.
10850recursive initialization of submodules). Commands which can potentially
10851clone/fetch/push from untrusted repositories without user intervention
10852can export `GIT_PROTOCOL_FROM_USER` with a value of '0' to prevent
10853protocols configured to the `user` policy from being used.
10854
10855Fix remote-ext tests to use the new config to allow the ext
10856protocol to be tested.
10857
10858Based on a patch by Jeff King <peff@peff.net>
10859
10860Signed-off-by: Brandon Williams <bmwill@google.com>
10861Signed-off-by: Junio C Hamano <gitster@pobox.com>
10862
10863http: always warn if libcurl version is too old
10864
10865Always warn if libcurl version is too old because:
10866
108671. Even without a protocol whitelist, newer versions of curl have all
10868 non-standard protocols disabled by default.
108692. 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
10873Signed-off-by: Brandon Williams <bmwill@google.com>
10874Signed-off-by: Junio C Hamano <gitster@pobox.com>
10875
10876lib-proto-disable: variable name fix
10877
10878The test_proto function assigns the positional parameters to named
10879variables, but then still refers to "$desc" as "$1". Using $desc is
10880more readable and less error-prone.
10881
10882Signed-off-by: Brandon Williams <bmwill@google.com>
10883Signed-off-by: Junio C Hamano <gitster@pobox.com>
10884
10885Revert "sequencer: remove useless get_dir() function"
10886
10887This reverts commit 39784cd3620cc47415c9010ec58a9616f040125c.
10888
10889The function had only one caller when the "remove useless" was
10890written, but another topic will soon make heavy use of it and more
10891importantly the function will return different paths depending on
10892the value in opts.
10893
10894i18n: difftool: mark warnings for translation
10895
10896Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10897Signed-off-by: Junio C Hamano <gitster@pobox.com>
10898
10899i18n: send-email: mark composing message for translation
10900
10901When composing an e-mail, there is a message for the user whose lines
10902begin in "GIT:" that can be marked for translation.
10903
10904Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10905Signed-off-by: Junio C Hamano <gitster@pobox.com>
10906
10907i18n: send-email: mark string with interpolation for translation
10908
10909Mark warnings, errors and other messages that are interpolated for
10910translation.
10911
10912We call sprintf() before calling die() and in few other circumstances in
10913order to replace the values on the placeholders.
10914
10915Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10916Signed-off-by: Junio C Hamano <gitster@pobox.com>
10917
10918i18n: send-email: mark warnings and errors for translation
10919
10920Mark warnings, errors and other messages for translation.
10921
10922Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10923Signed-off-by: Junio C Hamano <gitster@pobox.com>
10924
10925i18n: send-email: mark strings for translation
10926
10927Mark strings often displayed to the user for translation.
10928
10929Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10930Signed-off-by: Junio C Hamano <gitster@pobox.com>
10931
10932i18n: add--interactive: mark status words for translation
10933
10934Mark words 'nothing', 'unchanged' and 'binary' used to display what has
10935been staged or not, in "git add -i" status command.
10936
10937Alternatively one could mark N__('nothing') no-op in order to
10938xgettext(1) extract the string and then trigger the translation at run
10939time only with __($print->{FILE}), but that has the side effect of triggering
10940retrieval of translations for the changes indicator too (e.g. +2/-1)
10941which may or may not be a problem.
10942
10943To avoid that potential problem, mark only where there is certain to
10944trigger translation only of those words but in this case we must also
10945retrieve the translation for the eq tests, since the value assigned was
10946of the translation, not the English source.
10947
10948Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10949Signed-off-by: Junio C Hamano <gitster@pobox.com>
10950
10951i18n: add--interactive: remove %patch_modes entries
10952
10953Remove unnecessary entries from %patch_modes. After the i18n conversion,
10954these entries are not used anymore.
10955
10956Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10957Signed-off-by: Junio C Hamano <gitster@pobox.com>
10958
10959i18n: add--interactive: mark edit_hunk_manually message for translation
10960
10961Mark message of edit_hunk_manually displayed in the editing file when
10962user chooses 'e' option. The message had to be unfolded to allow
10963translation of the $participle verb.
10964
10965Some messages end up being exactly the same for some use cases, but
10966left it for easier change in the future, e.g., wanting to change wording
10967of one particular use case.
10968
10969The comment character is now used according to the git configuration
10970core.commentchar.
10971
10972Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10973Signed-off-by: Junio C Hamano <gitster@pobox.com>
10974
10975i18n: add--interactive: i18n of help_patch_cmd
10976
10977Mark help message of help_patch_cmd for translation. The message must
10978be unfolded to be free of variables so we can have high quality
10979translations.
10980
10981Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
10982Signed-off-by: Junio C Hamano <gitster@pobox.com>
10983
10984i18n: add--interactive: mark patch prompt for translation
10985
10986Mark prompt message assembled in place for translation, unfolding each
10987use case for each entry in the %patch_modes hash table.
10988
10989Previously, this script relied on whether $patch_mode was set to run the
10990command patch_update_cmd() or show status and loop the main loop. Now,
10991it uses $cmd to indicate we must run patch_update_cmd() and $patch_mode
10992is used to tell which flavor of the %patch_modes are we on. This is
10993introduced in order to be able to mark and unfold the message prompt
10994knowing in which context we are.
10995
10996The tracking of context was done previously by point %patch_mode_flavour
10997hash table to the correct entry of %patch_modes, focusing only on value
10998of %patch_modes. Now, we are also interested in the key ('staged',
10999'stash', 'checkout_head', ...).
11000
11001Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11002Signed-off-by: Junio C Hamano <gitster@pobox.com>
11003
11004i18n: add--interactive: mark plural strings
11005
11006Mark plural strings for translation. Unfold each action case in one
11007entire sentence.
11008
11009Pass new keyword for xgettext to extract.
11010
11011Update test to include new subroutine __n() for plural strings handling.
11012
11013Update documentation to include a description of the new __n()
11014subroutine.
11015
11016Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11017Signed-off-by: Junio C Hamano <gitster@pobox.com>
11018
11019i18n: clean.c: match string with git-add--interactive.perl
11020
11021Change strings for help to match the ones in git-add--interactive.perl.
11022The strings now represent one entry to translate each rather then two
11023entries each different only by an ending newline character.
11024
11025Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11026Signed-off-by: Junio C Hamano <gitster@pobox.com>
11027
11028i18n: add--interactive: mark strings with interpolation for translation
11029
11030Since at this point Git::I18N.perl lacks support for Perl i18n
11031placeholder substitution, use of sprintf following die or error_msg is
11032necessary for placeholder substitution take place.
11033
11034Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11035Signed-off-by: Junio C Hamano <gitster@pobox.com>
11036
11037i18n: add--interactive: mark simple here-documents for translation
11038
11039Mark messages in here-documents without interpolation for translation.
11040
11041The here-document delimiter \EOF, which is the same as 'EOF', indicates
11042that the text is to be treated literally without interpolation of its
11043content. Unfortunately xgettext is not able to extract here-documents
11044delimited with \EOF but it is with delimiter enclosed in single quotes.
11045So change \EOF to 'EOF', although in this case does not make
11046difference what variation of here-document to use since there is nothing
11047to interpolate.
11048
11049Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11050Signed-off-by: Junio C Hamano <gitster@pobox.com>
11051
11052i18n: add--interactive: mark strings for translation
11053
11054Mark simple strings (without interpolation) for translation.
11055
11056Brackets around first parameter of ternary operator is necessary because
11057otherwise xgettext fails to extract strings marked for translation from
11058the rest of the file.
11059
11060Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11061Signed-off-by: Junio C Hamano <gitster@pobox.com>
11062
11063Git.pm: add subroutines for commenting lines
11064
11065Add subroutines prefix_lines and comment_lines.
11066
11067Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11068Signed-off-by: Junio C Hamano <gitster@pobox.com>
11069
11070merge: ensure '--abort' option takes no arguments
11071
11072Like '--continue', the '--abort' option doesn't make any sense with
11073other options or arguments to 'git merge' so ensure that none are
11074present.
11075
11076Signed-off-by: Chris Packham <judge.packham@gmail.com>
11077Signed-off-by: Junio C Hamano <gitster@pobox.com>
11078
11079completion: add --continue option for merge
11080
11081Add 'git merge --continue' option when completing.
11082
11083Signed-off-by: Chris Packham <judge.packham@gmail.com>
11084Signed-off-by: Junio C Hamano <gitster@pobox.com>
11085
11086merge: add '--continue' option as a synonym for 'git commit'
11087
11088Teach 'git merge' the --continue option which allows 'continuing' a
11089merge by completing it. The traditional way of completing a merge after
11090resolving conflicts is to use 'git commit'. Now with commands like 'git
11091rebase' and 'git cherry-pick' having a '--continue' option adding such
11092an option to 'git merge' presents a consistent UI.
11093
11094Signed-off-by: Chris Packham <judge.packham@gmail.com>
11095Signed-off-by: Junio C Hamano <gitster@pobox.com>
11096
11097parse-options: print "fatal:" before usage_msg_opt()
11098
11099Programs may use usage_msg_opt() to print a brief message
11100followed by the program usage, and then exit. The message
11101isn't prefixed at all, though, so it doesn't match our usual
11102error 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
11116It looks especially bad when the message starts with an
11117option, 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
11126Let's put our usual "fatal:" prefix in front of it.
11127
11128Signed-off-by: Jeff King <peff@peff.net>
11129Signed-off-by: Junio C Hamano <gitster@pobox.com>
11130
11131Makefile: exclude contrib from FIND_SOURCE_FILES
11132
11133When you're working on the git project, you're unlikely to
11134care about random bits in contrib/ (e.g., you would not want
11135to jump to the copy of xmalloc in the wincred credential
11136helper). Nobody has really complained because there are
11137relatively few C files in contrib.
11138
11139Now that we're matching shell scripts, too, we get quite a
11140few more hits, especially in the obsolete contrib/examples
11141directory. Looking for usage() should turn up the one in
11142git-sh-setup, not in some long-dead version of git-clone.
11143
11144Let's just exclude all of contrib. Any specific projects
11145there which are big enough to want tags can generate them
11146separately.
11147
11148Signed-off-by: Jeff King <peff@peff.net>
11149Signed-off-by: Junio C Hamano <gitster@pobox.com>
11150
11151Makefile: match shell scripts in FIND_SOURCE_FILES
11152
11153We feed FIND_SOURCE_FILES to ctags to help developers
11154navigate to particular functions, but we only feed C source
11155code. The same feature can be helpful when working with
11156shell scripts (especially the test suite). Modern versions
11157of ctags know how to parse shell scripts; we just need to
11158feed the filenames to it.
11159
11160This patch specifically avoids including the individual test
11161scripts themselves. Those are unlikely to be of interest,
11162and there are a lot of them to process. It does pick up
11163test-lib.sh and test-lib-functions.sh.
11164
11165Note that our negative pathspec already excludes the
11166individual scripts for the ls-files case, but we need to
11167loosen the `find` rule to match it.
11168
11169Signed-off-by: Jeff King <peff@peff.net>
11170Signed-off-by: Junio C Hamano <gitster@pobox.com>
11171
11172Makefile: exclude test cruft from FIND_SOURCE_FILES
11173
11174The test directory may contain three types of files that
11175match 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
11183We want to match (1), but not the other two, as they just
11184clutter up the list.
11185
11186For the ls-files method, we can drop (2) with a negative
11187pathspec. We do not have to care about (3), since ls-files
11188will not list untracked files.
11189
11190For `find`, we can match both cases with `-prune` patterns.
11191
11192Signed-off-by: Jeff King <peff@peff.net>
11193Signed-off-by: Junio C Hamano <gitster@pobox.com>
11194
11195Makefile: reformat FIND_SOURCE_FILES
11196
11197As we add to this in future commits, the formatting is going
11198to make it harder and harder to read. Let's write it more as
11199we would in a shell script, putting each logical block on
11200its own line.
11201
11202Signed-off-by: Jeff King <peff@peff.net>
11203Signed-off-by: Junio C Hamano <gitster@pobox.com>
11204
11205unicode_width.h: update the width tables to Unicode 9.0
11206
11207Rerunning update-unicode.sh that we fixed in the previous commits
11208produces these new tables.
11209
11210Signed-off-by: Beat Bolli <dev+git@drbeat.li>
11211Signed-off-by: Junio C Hamano <gitster@pobox.com>
11212
11213update_unicode.sh: remove the plane filter
11214
11215The uniset upstream has accepted my patches that eliminate the Unicode
11216plane offsets from the output in '--32' mode.
11217
11218Remove the corresponding filter in update_unicode.sh.
11219
11220This also fixes the issue that the plane offsets were not removed from
11221the second uniset call.
11222
11223Signed-off-by: Beat Bolli <dev+git@drbeat.li>
11224Signed-off-by: Junio C Hamano <gitster@pobox.com>
11225
11226update_unicode.sh: automatically download newer definition files
11227
11228Checking just for the unicode data files' existence is not sufficient;
11229we should also download them if a newer version exists on the Unicode
11230consortium's servers. Option -N of wget does this nicely for us.
11231
11232Reviewed-by: Torsten Bögershausen <tboegi@web.de>
11233Signed-off-by: Beat Bolli <dev+git@drbeat.li>
11234Signed-off-by: Junio C Hamano <gitster@pobox.com>
11235
11236update_unicode.sh: pin the uniset repo to a known good commit
11237
11238The uniset upstream has added more commits that for example change the
11239hexadecimal output in '--32' mode to decimal. Let's pin the repo to a
11240commit that still outputs the width tables in the format we want.
11241
11242Signed-off-by: Beat Bolli <dev+git@drbeat.li>
11243Signed-off-by: Junio C Hamano <gitster@pobox.com>
11244
11245update_unicode.sh: remove an unnecessary subshell level
11246
11247After the move into contrib/update-unicode, we no longer create the
11248unicode directory to have a clean working folder. Instead, the directory
11249of the script is used. This means that the subshell can be removed.
11250
11251Signed-off-by: Beat Bolli <dev+git@drbeat.li>
11252Signed-off-by: Junio C Hamano <gitster@pobox.com>
11253
11254update_unicode.sh: move it into contrib/update-unicode
11255
11256As it's used only by a tiny minority of the Git developer population,
11257this script does not belong into the main Git source directory.
11258
11259Move it into contrib/ and adjust the paths to account for the new
11260location.
11261
11262Signed-off-by: Beat Bolli <dev+git@drbeat.li>
11263Signed-off-by: Junio C Hamano <gitster@pobox.com>
11264
11265git-p4: support git worktrees
11266
11267git-p4 would attempt to find the git directory using
11268its own specific code, which did not know about git
11269worktrees.
11270
11271Rework it to use "git rev-parse --git-dir" instead.
11272
11273Add test cases for worktree usage and specifying
11274git directory via --git-dir and $GIT_DIR.
11275
11276Signed-off-by: Luke Diamand <luke@diamand.org>
11277Signed-off-by: Junio C Hamano <gitster@pobox.com>
11278
11279Early fixes for 2.11.x series
11280
11281Signed-off-by: Junio C Hamano <gitster@pobox.com>
11282
11283Merge 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
11289Merge branch 'js/mingw-isatty'
11290
11291We often decide if a session is interactive by checking if the
11292standard I/O streams are connected to a TTY, but isatty() emulation
11293on Windows incorrectly returned true if it is used on NUL (i.e. an
11294equivalent 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
11299t5547-push-quarantine: run the path separator test on Windows, too
11300
11301To perform the test case on Windows in a way that corresponds to the
11302POSIX version, inject the semicolon in a directory name.
11303
11304Typically, an absolute POSIX style path, such as the one in $PWD, is
11305translated into a Windows style path by bash when it invokes git.exe.
11306However, the presence of the semicolon suppresses this translation;
11307but the untranslated POSIX style path is useless for git.exe.
11308Therefore, instead of $PWD pass the Windows style path that $(pwd)
11309produces.
11310
11311Signed-off-by: Johannes Sixt <j6t@kdbg.org>
11312Signed-off-by: Junio C Hamano <gitster@pobox.com>
11313
11314t3600: slightly modernize style
11315
11316Remove the space between redirection and file name.
11317Also remove unnecessary invocations of subshells, such as
11318
11319 (cd submod &&
11320 echo X >untracked
11321 ) &&
11322
11323as there is no point of having the shell for functional purposes.
11324In case of a single Git command use the `-C` option to let Git cd into
11325the directory.
11326
11327Signed-off-by: Stefan Beller <sbeller@google.com>
11328Signed-off-by: Junio C Hamano <gitster@pobox.com>
11329
11330real_path: have callers use real_pathdup and strbuf_realpath
11331
11332Migrate callers of real_path() who duplicate the retern value to use
11333real_pathdup or strbuf_realpath.
11334
11335Signed-off-by: Brandon Williams <bmwill@google.com>
11336Signed-off-by: Junio C Hamano <gitster@pobox.com>
11337
11338real_path: create real_pathdup
11339
11340Create real_pathdup which returns a caller owned string of the resolved
11341realpath based on the provide path.
11342
11343Signed-off-by: Brandon Williams <bmwill@google.com>
11344Signed-off-by: Junio C Hamano <gitster@pobox.com>
11345
11346real_path: convert real_path_internal to strbuf_realpath
11347
11348Change the name of real_path_internal to strbuf_realpath. In addition
11349push the static strbuf up to its callers and instead take as a
11350parameter a pointer to a strbuf to use for the final result.
11351
11352This change makes strbuf_realpath reentrant.
11353
11354Signed-off-by: Brandon Williams <bmwill@google.com>
11355Signed-off-by: Junio C Hamano <gitster@pobox.com>
11356
11357real_path: resolve symlinks by hand
11358
11359The current implementation of real_path uses chdir() in order to resolve
11360symlinks. Unfortunately this isn't thread-safe as chdir() affects a
11361process as a whole and not just an individual thread. Instead perform
11362the symlink resolution by hand so that the calls to chdir() can be
11363removed, making real_path one step closer to being reentrant.
11364
11365Signed-off-by: Brandon Williams <bmwill@google.com>
11366Signed-off-by: Junio C Hamano <gitster@pobox.com>
11367
11368submodule: add absorb-git-dir function
11369
11370When a submodule has its git dir inside the working dir, the submodule
11371support for checkout that we plan to add in a later patch will fail.
11372
11373Add functionality to migrate the git directory to be absorbed
11374into the superprojects git directory.
11375
11376The newly added code in this patch is structured such that other areas of
11377Git can also make use of it. The code in the submodule--helper is a mere
11378wrapper and option parser for the function
11379`absorb_git_dir_into_superproject`, that takes care of embedding the
11380submodules git directory into the superprojects git dir. That function
11381makes use of the more abstract function for this use case
11382`relocate_gitdir`, which can be used by e.g. the worktree code eventually
11383to move around a git directory.
11384
11385Signed-off-by: Stefan Beller <sbeller@google.com>
11386Signed-off-by: Junio C Hamano <gitster@pobox.com>
11387
11388move connect_work_tree_and_git_dir to dir.h
11389
11390That function was primarily used by submodule code, but the function
11391itself is not inherently about submodules. In the next patch we'll
11392introduce relocate_git_dir, which can be used by worktrees as well,
11393so find a neutral middle ground in dir.h.
11394
11395Signed-off-by: Stefan Beller <sbeller@google.com>
11396Signed-off-by: Junio C Hamano <gitster@pobox.com>
11397
11398worktree: check if a submodule uses worktrees
11399
11400In a later patch we want to move around the the git directory of
11401a submodule. Both submodules as well as worktrees are involved in
11402placing git directories at unusual places, so their functionality
11403may collide. To react appropriately to situations where worktrees
11404in submodules are in use, offer a new function to query the
11405a submodule if it uses the worktree feature.
11406
11407An 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
11419The implementation here is just checking for any files in
11420$GIT_COMMON_DIR/worktrees for the submodule, which ought to be sufficient
11421if the submodule is using the current repository format, which we also
11422check.
11423
11424Signed-off-by: Stefan Beller <sbeller@google.com>
11425Signed-off-by: Junio C Hamano <gitster@pobox.com>
11426
11427tmp-objdir: quote paths we add to alternates
11428
11429Commit 722ff7f87 (receive-pack: quarantine objects until
11430pre-receive accepts, 2016-10-03) regressed pushes to
11431repositories with colon (or semi-colon in Windows in them)
11432because it adds the repository's main object directory to
11433GIT_ALTERNATE_OBJECT_DIRECTORIES. The receiver interprets
11434the colon as a delimiter, not as part of the path, and
11435index-pack is unable to find objects which it needs to
11436resolve deltas.
11437
11438The previous commit introduced a quoting mechanism for the
11439alternates list; let's use it here to cover this case. We'll
11440avoid quoting when we can, though. This alternate setup is
11441also used when calling hooks, so it's possible that the user
11442may call older git implementations which don't understand
11443the quoting mechanism. By quoting only when necessary, this
11444setup will continue to work unless the user _also_ has a
11445repository whose path contains the delimiter.
11446
11447Signed-off-by: Jeff King <peff@peff.net>
11448Signed-off-by: Junio C Hamano <gitster@pobox.com>
11449
11450alternates: accept double-quoted paths
11451
11452We read lists of alternates from objects/info/alternates
11453files (delimited by newline), as well as from the
11454GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable
11455(delimited by colon or semi-colon, depending on the
11456platform).
11457
11458There's no mechanism for quoting the delimiters, so it's
11459impossible to specify an alternate path that contains a
11460colon in the environment, or one that contains a newline in
11461a file. We've lived with that restriction for ages because
11462both alternates and filenames with colons are relatively
11463rare, and it's only a problem when the two meet. But since
11464722ff7f87 (receive-pack: quarantine objects until
11465pre-receive accepts, 2016-10-03), which builds on the
11466alternates system, every push causes the receiver to set
11467GIT_ALTERNATE_OBJECT_DIRECTORIES internally.
11468
11469It would be convenient to have some way to quote the
11470delimiter so that we can represent arbitrary paths.
11471
11472The simplest thing would be an escape character before a
11473quoted delimiter (e.g., "\:" as a literal colon). But that
11474creates a backwards compatibility problem: any path which
11475uses that escape character is now broken, and we've just
11476shifted the problem. We could choose an unlikely escape
11477character (e.g., something from the non-printable ASCII
11478range), but that's awkward to use.
11479
11480Instead, let's treat names as unquoted unless they begin
11481with a double-quote, in which case they are interpreted via
11482our usual C-stylke quoting rules. This also breaks
11483backwards-compatibility, but in a smaller way: it only
11484matters if your file has a double-quote as the very _first_
11485character in the path (whereas an escape character is a
11486problem anywhere in the path). It's also consistent with
11487many other parts of git, which accept either a bare pathname
11488or a double-quoted one, and the sender can choose to quote
11489or not as required.
11490
11491Signed-off-by: Jeff King <peff@peff.net>
11492Signed-off-by: Junio C Hamano <gitster@pobox.com>
11493
11494Merge 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
11499date-formats.txt: Typo fix
11500
11501Last time I checked, I was living in the UTC+01:00 time zone. UTC+02:00
11502would be Central European _Summer_ Time.
11503
11504Signed-off-by: Luis Ressel <aranea@aixah.de>
11505Signed-off-by: Junio C Hamano <gitster@pobox.com>
11506
11507git-svn: document useLogAuthor and addAuthorFrom config keys
11508
11509We've always supported these config keys in git-svn,
11510so document them so users won't have to respecify them
11511on every invocation.
11512
11513Reported-by: Juergen Kosel <juergen.kosel@gmx.de>
11514Signed-off-by: Eric Wong <e@80x24.org>
11515
11516git-svn: allow "0" in SVN path components
11517
11518Blindly 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
11522Found via random code reading.
11523
11524Signed-off-by: Eric Wong <e@80x24.org>
11525
11526submodule--helper: set alternateLocation for cloned submodules
11527
11528In 31224cbdc7 (clone: recursive and reference option triggers
11529submodule alternates, 2016-08-17) a mechanism was added to
11530have submodules referenced. It did not address _nested_
11531submodules, however.
11532
11533This patch makes all not just the root repository, but also
11534all submodules (recursively) have submodule.alternateLocation
11535and submodule.alternateErrorStrategy configured, making Git
11536search for possible alternates for nested submodules as well.
11537
11538As submodule's alternate target does not end in .git/objects
11539(rather .git/modules/qqqqqq/objects), this alternate target
11540path restriction for in add_possible_reference_from_superproject
11541relates from "*.git/objects" to just */objects".
11542
11543New tests have been added to t7408-submodule-reference.
11544
11545Signed-off-by: Vitaly _Vi Shukela <vi0oss@gmail.com>
11546Reviewed-by: Stefan Beller <sbeller@google.com>
11547Signed-off-by: Junio C Hamano <gitster@pobox.com>
11548
11549gitk: Update copyright notice to 2016
11550
11551Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11552
11553gitk: Clear array 'commitinfo' on reload
11554
11555After a reload we might have an entirely different set of commits,
11556so keeping all of them leaks memory. Remove them all because
11557re-creating them is not more expensive than testing wether they're
11558still valid. Lazy (re-)creation is already well established, so
11559a missing entry can't cause harm.
11560
11561Signed-off-by: Markus Hitter <mah@jump-ing.de>
11562Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11563
11564gitk: Remove closed file descriptors from $blobdifffd
11565
11566One shouldn't have descriptors of already closed files around.
11567
11568The first idea to deal with this (previously) ever growing array
11569was to remove it entirely, but it's needed to detect start of a
11570new diff with ths old diff not yet done. This happens when a user
11571clicks on the same commit in the commit list repeatedly without
11572delay.
11573
11574Signed-off-by: Markus Hitter <mah@jump-ing.de>
11575Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11576
11577gitk: Turn off undo manager in the text widget
11578
11579The diff text widget is read-only, so there's zero point in
11580building an undo stack. This change reduces memory consumption of
11581this widget by about 95%.
11582
11583Memory usage of the whole program for viewing a reference commit
11584before; 579'692'744 bytes, after: 32'724'446 bytes.
11585
11586Test 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
11613Note that the numbers reported by [memory info] are much smaller
11614than the ones reported in 'top' (1.75 GB vs. 105 MB in this case),
11615likely due to all the instrumentation coming with the debug
11616version of Tcl.
11617
11618Signed-off-by: Markus Hitter <mah@jump-ing.de>
11619Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11620
11621gitk: Fix Japanese translation for "marked commit"
11622
11623Signed-off-by: Satoshi Yasushima <s.yasushima@gmail.com>
11624Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11625
11626gitk: Fix missing commits when using -S or -G
11627
11628When -S or -G is used as a filter option, the resulting commit list
11629rarely contains all matching commits. Only a certain number of commits
11630are displayed and the rest are missing.
11631
11632"git log --boundary -S" does not return as many boundary commits as you
11633might expect. gitk makes up for this in closevarcs() by adding missing
11634parent (boundary) commits. However, it does not change $numcommits,
11635which limits how many commits are shown. In the end, some commits at the
11636end of the commit list are simply not shown.
11637
11638Change $numcommits whenever a missing parent is added to the current
11639view.
11640
11641Signed-off-by: Stefan Dotterweich <stefandotterweich@gmx.de>
11642Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11643
11644gitk: Use explicit RGB green instead of "lime"
11645
11646Some systems don't recognize "lime" as a color, leading to errors when
11647gitk is run. What we want is a bright green, so use "#00ff00" instead.
11648
11649Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11650
11651gitk: Add Portuguese translation
11652
11653Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11654Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11655
11656mergetools: fix xxdiff hotkeys
11657
11658xxdiff was using a mix of "Ctrl-<key>" and "Ctrl+<key>" hotkeys.
11659The dashed "-" form is not accepted by newer xxdiff versions.
11660Use the plus "+" form only.
11661
11662Signed-off-by: David Aguilar <davvid@gmail.com>
11663Signed-off-by: Junio C Hamano <gitster@pobox.com>
11664
11665difftool: rename variables for consistency
11666
11667Always call the list of files @files.
11668Always call the worktree $worktree.
11669
11670Signed-off-by: David Aguilar <davvid@gmail.com>
11671Signed-off-by: Junio C Hamano <gitster@pobox.com>
11672
11673difftool: chdir as early as possible
11674
11675Make difftool chdir to the top-level of the repository as soon as it can
11676so that we can simplify how paths are handled. Replace construction of
11677absolute paths via string concatenation with relative paths wherever
11678possible. The bulk of the code no longer needs to use absolute paths.
11679
11680Signed-off-by: David Aguilar <davvid@gmail.com>
11681Signed-off-by: Junio C Hamano <gitster@pobox.com>
11682
11683difftool: sanitize $workdir as early as possible
11684
11685The double-slash fixup on the $workdir variable was being
11686performed just-in-time to avoid double-slashes in symlink
11687targets, but the rest of the code was silently using paths with
11688embedded "//" in them.
11689
11690A recent user-reported error message contained double-slashes.
11691Eliminate the issue by sanitizing inputs as soon as they arrive.
11692
11693Signed-off-by: David Aguilar <davvid@gmail.com>
11694Signed-off-by: Junio C Hamano <gitster@pobox.com>
11695
11696difftool: fix dir-diff index creation when in a subdirectory
11697
116989ec26e7977 (difftool: fix argument handling in subdirs, 2016-07-18)
11699corrected how path arguments are handled in a subdirectory, but
11700it introduced a regression in how entries outside of the
11701subdirectory are handled by dir-diff.
11702
11703When preparing the right-side of the diff we only include the
11704changed paths in the temporary area.
11705
11706The left side of the diff is constructed from a temporary
11707index that is built from the same set of changed files, but it
11708was being constructed from within the subdirectory. This is a
11709problem because the indexed paths are toplevel-relative, and
11710thus they were not getting added to the index.
11711
11712Teach difftool to chdir to the toplevel of the repository before
11713preparing its temporary indexes. This ensures that all of the
11714toplevel-relative paths are valid.
11715
11716Add test cases to more thoroughly exercise this scenario.
11717
11718Reported-by: Frank Becker <fb@mooflu.com>
11719Signed-off-by: David Aguilar <davvid@gmail.com>
11720Signed-off-by: Junio C Hamano <gitster@pobox.com>
11721
11722mingw: intercept isatty() to handle /dev/null as Git expects it
11723
11724When Git's source code calls isatty(), it really asks whether the
11725respective file descriptor is connected to an interactive terminal.
11726
11727Windows' _isatty() function, however, determines whether the file
11728descriptor is associated with a character device. And NUL, Windows'
11729equivalent of /dev/null, is a character device.
11730
11731Which means that for years, Git mistakenly detected an associated
11732interactive terminal when being run through the test suite, which
11733almost always redirects stdin, stdout and stderr to /dev/null.
11734
11735This bug only became obvious, and painfully so, when the new
11736bisect--helper entered the `pu` branch and made the automatic build & test
11737time out because t6030 was waiting for an answer.
11738
11739For details, see
11740
11741 https://msdn.microsoft.com/en-us/library/f4s0ddew.aspx
11742
11743Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
11744Signed-off-by: Junio C Hamano <gitster@pobox.com>
11745
11746gitk: Makefile: create install bin directory
11747
11748Force creation of destination bin directory. Without this, gitk
11749would fail to install if this directory didn't already exist.
11750
11751Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
11752Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11753
11754gitk: Include commit title in branch dialog
11755
11756Hi,
11757
11758I made another branch dialog related change, included in this message.
11759It applies on top of my other two patches.
11760
11761Rogier.
11762
11763------- 8< ------------------- 8< --------------
11764
11765Only the SHA1 was included. It's convenient to have the title
11766mentioned as well.
11767
11768Signed-off-by: Rogier Goossens <goossens.rogier@gmail.com>
11769Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11770
11771gitk: Allow checking out a remote branch
11772
11773Git allows checking out remote branches, creating a local tracking
11774branch in the process. Allow gitk to do this as well, provided a
11775local branch of the same name does not yet exist.
11776
11777Signed-off-by: Rogier Goossens <goossens.rogier@gmail.com>
11778Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11779
11780gitk: Add a 'rename' option to the branch context menu
11781
11782Signed-off-by: Rogier Goossens <goossens.rogier@gmail.com>
11783Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
11784
11785ref-filter: add support to display trailers as part of contents
11786
11787Add %(trailers) and %(contents:trailers) to display the trailers as
11788interpreted by trailer_info_get. Update documentation and add a test for
11789the new feature.
11790
11791Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
11792Signed-off-by: Junio C Hamano <gitster@pobox.com>
11793
11794pretty: add %(trailers) format for displaying trailers of a commit message
11795
11796Recent patches have expanded on the trailers.c code and we have the
11797builtin commant git-interpret-trailers which can be used to add or
11798modify trailer lines. However, there is no easy way to simply display
11799the trailers of a commit message.
11800
11801Add support for %(trailers) format modifier which will use the
11802trailer_info_get() calls to read trailers in an identical way as git
11803interpret-trailers does. Use a long format option instead of a short
11804name so that future work can more easily unify ref-filter and pretty
11805formats.
11806
11807Add documentation and tests for the same.
11808
11809Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
11810Signed-off-by: Junio C Hamano <gitster@pobox.com>
11811
11812rebase: add --quit to cleanup rebase, leave everything else untouched
11813
11814There are occasions when you decide to abort an in-progress rebase and
11815move on to do something else but you forget to do "git rebase --abort"
11816first. Or the rebase has been in progress for so long you forgot about
11817it. By the time you realize that (e.g. by starting another rebase)
11818it's already too late to retrace your steps. The solution is normally
11819
11820 rm -r .git/<some rebase dir>
11821
11822and continue with your life. But there could be two different
11823directories for <some rebase dir> (and it obviously requires some
11824knowledge of how rebase works), and the ".git" part could be much
11825longer 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
11827destroy object database or other important data.
11828
11829Provide "git rebase --quit" for this use case, mimicking a precedent
11830that is "git cherry-pick --quit".
11831
11832Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
11833Signed-off-by: Junio C Hamano <gitster@pobox.com>
11834
11835doc: omit needless "for"
11836
11837What was intended was perhaps "... plumbing does for you" ("you" added), but
11838simply omitting the word "for" is more terse and gets the intended point across
11839just as well, if not more so.
11840
11841I originally went with the approach of writing "for you", but Junio C
11842Hamano suggested this approach instead.
11843
11844Signed-off-by: Kristoffer Haugsbakk <kristoffer.haugsbakk@gmail.com>
11845Signed-off-by: Junio C Hamano <gitster@pobox.com>
11846
11847doc: make the intent of sentence clearer
11848
11849By adding the word "just", which might have been accidentally omitted.
11850
11851Adding the word "just" makes it clear that the point is to *not* do an
11852octopus merge simply because you *can* do it. In other words, you
11853should have a reason for doing it beyond simply having two (seemingly)
11854independent commits that you need to merge into another branch, since
11855it's not always the best approach.
11856
11857The previous sentence made it look more like it was trying to say that
11858you shouldn't do an octopus merge *because* you can do an octopus merge.
11859Although this interpretation doesn't make sense and the rest of the
11860paragraph makes the intended meaning clear, this adjustment should make
11861the intent of the sentence more immediately clear to the reader.
11862
11863Signed-off-by: Kristoffer Haugsbakk <kristoffer.haugsbakk@gmail.com>
11864Signed-off-by: Junio C Hamano <gitster@pobox.com>
11865
11866doc: add verb in front of command to run
11867
11868Instead of using the command 'git clone' as a verb, use "run" as the
11869verb indicating the action of executing the command 'git clone'.
11870
11871Signed-off-by: Kristoffer Haugsbakk <kristoffer.haugsbakk@gmail.com>
11872Signed-off-by: Junio C Hamano <gitster@pobox.com>
11873
11874doc: add articles (grammar)
11875
11876Add definite and indefinite articles in three places where they were
11877missing.
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
11883Signed-off-by: Kristoffer Haugsbakk <kristoffer.haugsbakk@gmail.com>
11884Signed-off-by: Junio C Hamano <gitster@pobox.com>
11885
11886test-lib-functions.sh: teach test_commit -C <dir>
11887
11888Specifically when setting up submodule tests, it comes in handy if
11889we can create commits in repositories that are not at the root of
11890the tested trash dir. Add "-C <dir>" similar to gits -C parameter
11891that will perform the operation in the given directory.
11892
11893Signed-off-by: Stefan Beller <sbeller@google.com>
11894Signed-off-by: Junio C Hamano <gitster@pobox.com>
11895
11896submodule helper: support super prefix
11897
11898Just like main commands in Git, the submodule helper needs
11899access to the superproject prefix. Enable this in the git.c
11900but have its own fuse in the helper code by having a flag to
11901turn on the super prefix.
11902
11903Signed-off-by: Stefan Beller <sbeller@google.com>
11904Signed-off-by: Junio C Hamano <gitster@pobox.com>
11905
11906submodule: use absolute path for computing relative path connecting
11907
11908The current caller of connect_work_tree_and_git_dir passes
11909an absolute path for the `git_dir` parameter. In the future patch
11910we will also pass in relative path for `git_dir`. Extend the functionality
11911of connect_work_tree_and_git_dir to take relative paths for parameters.
11912
11913We could work around this in the future patch by computing the absolute
11914path for the git_dir in the calling site, however accepting relative
11915paths for either parameter makes the API for this function much harder
11916to misuse.
11917
11918Signed-off-by: Stefan Beller <sbeller@google.com>
11919Signed-off-by: Junio C Hamano <gitster@pobox.com>
11920
11921sequencer: remove useless get_dir() function
11922
11923This function is used only once, for the removal of the
11924directory. It is not used for the creation of the directory nor
11925anywhere else.
11926
11927Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
11928Signed-off-by: Junio C Hamano <gitster@pobox.com>
11929
11930sequencer: make sequencer abort safer
11931
11932In contrast to "git am --abort", a sequencer abort did not check
11933whether the current HEAD is the one that is expected. This can lead
11934to loss of work (when not spotted and resolved using reflog before
11935the garbage collector chimes in).
11936
11937This behavior is now changed by mimicking "git am --abort". The
11938abortion is done but HEAD is not changed when the current HEAD is
11939not the expected HEAD.
11940
11941A new file "sequencer/abort-safety" is added to save the expected
11942HEAD.
11943
11944The new behavior is only active when --abort is invoked on multiple
11945picks. The problem does not occur for the single-pick case because
11946it is handled differently.
11947
11948Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
11949Signed-off-by: Junio C Hamano <gitster@pobox.com>
11950
11951t3510: test that cherry-pick --abort does not unsafely change HEAD
11952
11953Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
11954Signed-off-by: Junio C Hamano <gitster@pobox.com>
11955
11956commit: remove 'Clever' message for --only --amend
11957
11958The behavior is now documented; more importantly, rewarding the user
11959with a "Wow, you are clever" praise afterwards is not an effective
11960way to advertise the feature--at that point the user already knows.
11961
11962Signed-off-by: Andreas Krey <a.krey@gmx.de>
11963Signed-off-by: Junio C Hamano <gitster@pobox.com>
11964
11965diff: handle --no-abbrev in no-index case
11966
11967There are two different places where the --no-abbrev option is parsed,
11968and 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"
11970calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
11971--no-abbrev until now. (It did handle --abbrev, however.) We normally
11972abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666 ("diff:
11973handle sha1 abbreviations outside of repository, 2016-10-20) recently
11974introduced a special case when you run "git diff" outside of a
11975repository.
11976
11977setup_revisions() does also call diff_opt_parse(), but not for --abbrev
11978or --no-abbrev, which it handles itself. setup_revisions() sets
11979rev_info->abbrev, and later copies that to diff_options->abbrev. It
11980handles --no-abbrev by setting abbrev to zero. (This change doesn't
11981touch that.)
11982
11983Setting abbrev to zero was broken in the outside-of-a-repository special
11984case, which until now resulted in a truly zero-length SHA-1, rather than
11985taking zero to mean do not abbreviate. The only way to trigger this bug,
11986however, 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
11990now.
11991
11992The outside-of-a-repository case is one of three no-index cases. The
11993other two are when one of the files you're comparing is outside of the
11994repository you're in, and the --no-index option.
11995
11996Signed-off-by: Jack Bates <jack@nottheoilrig.com>
11997Signed-off-by: Junio C Hamano <gitster@pobox.com>
11998
11999versioncmp: use earliest-longest contained suffix to determine sorting order
12000
12001When comparing tagnames, it is possible that a tagname contains more
12002than one of the configured prerelease suffixes around the first
12003different character. After fixing a bug in the previous commit such a
12004tagname is sorted according to the contained suffix which comes first
12005in the configuration. This is, however, not quite the right thing to
12006do 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
12037Improve 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
12056Add tests for these corner cases and adjust the documentation
12057accordingly.
12058
12059Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
12060Signed-off-by: Junio C Hamano <gitster@pobox.com>
12061
12062versioncmp: cope with common part overlapping with prerelease suffix
12063
12064Version sort with prerelease reordering sometimes puts tagnames in the
12065wrong order, when the common part of two compared tagnames overlaps
12066with the leading character(s) of one or more configured prerelease
12067suffixes. 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
12080The reason is that when comparing a pair of tagnames, first
12081versioncmp() looks for the first different character in a pair of
12082tagnames, and then the swap_prereleases() helper function looks for a
12083configured prerelease suffix _starting at_ that character. Thus, when
12084in the above example the sorting algorithm happens to compare the
12085tagnames "v2.1.0-beta-1" and "v2.1.0-RC2", swap_prereleases() tries to
12086match the suffix "-beta" against "beta-1" to no avail, and the two
12087tagnames erroneously end up being ordered lexicographically.
12088
12089To fix this issue change swap_prereleases() to look for configured
12090prerelease suffixes _containing_ the position of that first different
12091character.
12092
12093Care must be taken, when a configured suffix is longer than the
12094tagnames' common part up to the first different character, to avoid
12095reading memory before the beginning of the tagnames. Add a test that
12096uses an exceptionally long prerelease suffix to check for this, in the
12097hope that in case of a regression the illegal memory access causes a
12098segfault in 'git tag' on one of the commonly used platforms (the test
12099happens to pass successfully on my Linux system with the safety check
12100removed), or at least makes valgrind complain.
12101
12102Under some circumstances it's possible that more than one prerelease
12103suffixes can be found in the same tagname around that first different
12104character. With this simple bugfix patch such a tagname is sorted
12105according to the contained suffix that comes first in the
12106configuration for now. This is less than ideal in some cases, and the
12107following patch will take care of those.
12108
12109Reported-by: Leho Kraav <leho@conversionready.com>
12110Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
12111Signed-off-by: Junio C Hamano <gitster@pobox.com>
12112
12113versioncmp: pass full tagnames to swap_prereleases()
12114
12115The swap_prereleases() helper function is responsible for finding
12116configured prerelease suffixes in a pair of tagnames to be compared,
12117but this function currently gets to see only the parts of those two
12118tagnames starting at the first different character. To fix some
12119issues related to the common part of two tagnames overlapping with
12120leading part of a prerelease suffix, this helper function must see
12121both full tagnames.
12122
12123In preparation for the fix in the following patch, refactor
12124swap_prereleases() and its caller to pass two full tagnames and an
12125additional offset indicating the position of the first different
12126character.
12127
12128While updating the comment describing that function, remove the
12129sentence about not dealing with both tagnames having the same suffix.
12130Currently it doesn't add much value (we know that there is a different
12131character, so it's obvious that it can't possibly be the same suffix
12132in both), and at the end of this patch series it won't even be true
12133anymore.
12134
12135Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
12136Signed-off-by: Junio C Hamano <gitster@pobox.com>
12137
12138t7004-tag: add version sort tests to show prerelease reordering issues
12139
12140Version sort with prerelease reordering sometimes puts tagnames in the
12141wrong order, when the common part of two compared tagnames ends with
12142the leading character(s) of one or more configured prerelease
12143suffixes. Add tests that demonstrate these issues.
12144
12145The unrelated '--format should list tags as per format given' test
12146later uses tags matching the same prefix as the version sort tests,
12147thus was affected by the new tags added for the new tests in this
12148patch. Change that test to perform its checks on a different set of
12149tags.
12150
12151Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
12152Signed-off-by: Junio C Hamano <gitster@pobox.com>
12153
12154t7004-tag: use test_config helper
12155
12156... instead of setting and then manually unsetting configuration
12157variables, on one occasion even outside the test_expect_success block.
12158
12159Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
12160Signed-off-by: Junio C Hamano <gitster@pobox.com>
12161
12162t7004-tag: delete unnecessary tags with test_when_finished
12163
12164The '--force is moot with a non-existing tag name' test creates two
12165new tags, which are then deleted right after the test is finished,
12166outside the test_expect_success block, allowing 'git tag -d's output to
12167pollute the test output.
12168
12169Use test_when_finished to delete those tags.
12170
12171Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
12172Signed-off-by: Junio C Hamano <gitster@pobox.com>
12173
12174difftool: fix dir-diff index creation when in a subdirectory
12175
121769ec26e7977 (difftool: fix argument handling in subdirs, 2016-07-18)
12177corrected how path arguments are handled in a subdirectory, but
12178it introduced a regression in how entries outside of the
12179subdirectory are handled by dir-diff.
12180
12181When preparing the right-side of the diff we only include the
12182changed paths in the temporary area.
12183
12184The left side of the diff is constructed from a temporary
12185index that is built from the same set of changed files, but it
12186was being constructed from within the subdirectory. This is a
12187problem because the indexed paths are toplevel-relative, and
12188thus they were not getting added to the index.
12189
12190Teach difftool to chdir to the toplevel of the repository before
12191preparing its temporary indexes. This ensures that all of the
12192toplevel-relative paths are valid.
12193
12194Add test cases to more thoroughly exercise this scenario.
12195
12196Reported-by: Frank Becker <fb@mooflu.com>
12197Signed-off-by: David Aguilar <davvid@gmail.com>
12198Signed-off-by: Junio C Hamano <gitster@pobox.com>
12199
12200am: change safe_to_abort()'s not rewinding error into a warning
12201
12202The error message tells the user that something went terribly wrong
12203and the --abort could not be performed. But the --abort is performed,
12204only without rewinding. By simply changing the error into a warning,
12205we indicate the user that she must not try something like
12206"git am --abort --force", instead she just has to check the HEAD.
12207
12208Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
12209Signed-off-by: Junio C Hamano <gitster@pobox.com>
12210
12211am: fix filename in safe_to_abort() error message
12212
12213Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
12214Signed-off-by: Junio C Hamano <gitster@pobox.com>
12215
12216shallow.c: remove useless code
12217
12218Some context before we talk about the removed code.
12219
12220This paint_down() is part of step 6 of 58babff (shallow.c: the 8 steps
12221to select new commits for .git/shallow - 2013-12-05). When we fetch from
12222a shallow repository, we need to know if one of the new/updated refs
12223needs new "shallow commits" in .git/shallow (because we don't have
12224enough history of those refs) and which one.
12225
12226The question at step 6 is, what (new) shallow commits are required in
12227other to maintain reachability throughout the repository _without_
12228cutting our history short? To answer, we mark all commits reachable from
12229existing refs with UNINTERESTING ("rev-list --not --all"), mark shallow
12230commits with BOTTOM, then for each new/updated refs, walk through the
12231commit graph until we either hit UNINTERESTING or BOTTOM, marking the
12232ref on the commit as we walk.
12233
12234After all the walking is done, we check the new shallow commits. If we
12235have not seen any new ref marked on a new shallow commit, we know all
12236new/updated refs are reachable using just our history and .git/shallow.
12237The shallow commit in question is not needed and can be thrown away.
12238
12239So, the code.
12240
12241The loop here (to walk through commits) is basically
12242
122431. get one commit from the queue
122442. ignore if it's SEEN or UNINTERESTING
122453. mark it
122464. go through all the parents and..
122475a. mark it if it's never marked before
122485b. put it back in the queue
12249
12250What we do in this patch is drop step 5a because it is not
12251necessary. The commit being marked at 5a is put back on the queue, and
12252will be marked at step 3 at the next iteration. The only case it will
12253not be marked is when the commit is already marked UNINTERESTING (5a
12254does not check this), which will be ignored at step 2.
12255
12256But we don't care about refs marking on UNINTERESTING. We care about the
12257marking on _shallow commits_ that are not reachable from our current
12258history (and having UNINTERESTING on it means it's reachable). So it's
12259ok for an UNINTERESTING not to be ref-marked.
12260
12261Reported-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
12262Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
12263Signed-off-by: Junio C Hamano <gitster@pobox.com>
12264
12265shallow.c: bit manipulation tweaks
12266
12267First of all, 1 << 31 is technically undefined behaviour, so let's just
12268use an unsigned literal.
12269
12270If i is 'signed int' and gcc doesn't know that i is positive, gcc
12271generates code to compute the C99-mandated values of "i / 32" and "i %
1227232", which is a lot more complicated than simple a simple shifts/mask.
12273
12274The only caller of paint_down actually passes an "unsigned int" value,
12275but the prototype of paint_down causes (completely well-defined)
12276conversion to signed int, and gcc has no way of knowing that the
12277converted value is non-negative. Just make the id parameter unsigned.
12278
12279In update_refstatus, the change in generated code is much smaller,
12280presumably because gcc is smart enough to see that i starts as 0 and is
12281only incremented, so it is allowed (per the UD of signed overflow) to
12282assume that i is always non-negative. But let's just help less smart
12283compilers generate good code anyway.
12284
12285Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
12286Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
12287Reviewed-by: Jeff King <peff@peff.net>
12288Signed-off-by: Junio C Hamano <gitster@pobox.com>
12289
12290shallow.c: avoid theoretical pointer wrap-around
12291
12292The expression info->free+size is technically undefined behaviour in
12293exactly the case we want to test for. Moreover, the compiler is likely
12294to translate the expression to
12295
12296 (unsigned long)info->free + size > (unsigned long)info->end
12297
12298where there's at least a theoretical chance that the LHS could wrap
12299around 0, giving a false negative.
12300
12301This might as well be written using pointer subtraction avoiding these
12302issues.
12303
12304Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
12305Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
12306Reviewed-by: Jeff King <peff@peff.net>
12307Signed-off-by: Junio C Hamano <gitster@pobox.com>
12308
12309shallow.c: make paint_alloc slightly more robust
12310
12311paint_alloc() allocates a big block of memory and splits it into
12312smaller, fixed size, chunks of memory whenever it's called. Each chunk
12313contains enough bits to present all "new refs" [1] in a fetch from a
12314shallow repository.
12315
12316We do not check if the new "big block" is smaller than the requested
12317memory chunk though. If it happens, we'll happily pass back a memory
12318region smaller than expected. Which will lead to problems eventually.
12319
12320A 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
12322paint_alloc's perspective). Each chunk of memory would be 2k, much
12323smaller than the memory pool (512k).
12324
12325So, normally, the under-allocation situation should never happen. A bad
12326guy, however, could make a fetch that adds more than 4m new/updated refs
12327to this code which results in a memory chunk larger than pool size.
12328Check this case and abort.
12329
12330Noticed-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
12331Reviewed-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
12336Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
12337Reviewed-by: Jeff King <peff@peff.net>
12338Signed-off-by: Junio C Hamano <gitster@pobox.com>
12339
12340shallow.c: stop abusing COMMIT_SLAB_SIZE for paint_info's memory pools
12341
12342We need to allocate a "big" block of memory in paint_alloc(). The exact
12343size does not really matter. But the pool size has no relation with
12344commit-slab. Stop using that macro here.
12345
12346Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
12347Reviewed-by: Jeff King <peff@peff.net>
12348Signed-off-by: Junio C Hamano <gitster@pobox.com>
12349
12350shallow.c: rename fields in paint_info to better express their purposes
12351
12352paint_alloc() is basically malloc(), tuned for allocating a fixed number
12353of bits on every call without worrying about freeing any individual
12354allocation since all will be freed at the end. It does it by allocating
12355a big block of memory every time it runs out of "free memory". "slab" is
12356a poor choice of name, at least poorer than "pool".
12357
12358Signed-off-by: Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
12359Reviewed-by: Jeff King <peff@peff.net>
12360Signed-off-by: Junio C Hamano <gitster@pobox.com>
12361
12362lockfile: LOCK_REPORT_ON_ERROR
12363
12364The "libify sequencer" topic stopped passing the die_on_error option
12365to hold_locked_index(), and this lost an error message from "git
12366merge --ff-only $commit" when there are competing updates in
12367progress.
12368
12369The command still exits with a non-zero status, but that is not of
12370much help for an interactive user. The last thing the command says
12371is "Updating $from..$to". We used to follow it with a big error
12372message that makes it clear that "merge --ff-only" did not succeed.
12373
12374What is sad is that we should have noticed this regression while
12375reviewing the change. It was clear that the update to the
12376checkout_fast_forward() function made a failing hold_locked_index()
12377silent, but the only caller of the checkout_fast_forward() function
12378had 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
12384which clearly contradicted the assumption X-<.
12385
12386Add a new option LOCK_REPORT_ON_ERROR that can be passed instead of
12387LOCK_DIE_ON_ERROR to the hold_lock*() family of functions and teach
12388checkout_fast_forward() to use it to fix this regression.
12389
12390After going thourgh all calls to hold_lock*() family of functions
12391that used to pass LOCK_DIE_ON_ERROR but were modified to pass 0 in
12392the "libify sequencer" topic "git show --first-parent 2a4062a4a8",
12393it appears that this is the only one that has become silent. Many
12394others used to give detailed report that talked about "there may be
12395competing Git process running" but with the series merged they now
12396only give a single liner "Unable to lock ...", some of which may
12397have to be tweaked further, but at least they say something, unlike
12398the one this patch fixes.
12399
12400Reported-by: Robbie Iannucci <iannucci@google.com>
12401Signed-off-by: Junio C Hamano <gitster@pobox.com>