git/git.git
3 years agoThe second batch for 2.18
Junio C Hamano [Tue, 10 Apr 2018 07:32:45 +0000 (16:32 +0900)]
The second batch for 2.18

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ys/bisect-object-id-missing-conversion-fix'
Junio C Hamano [Tue, 10 Apr 2018 07:28:24 +0000 (16:28 +0900)]
Merge branch 'ys/bisect-object-id-missing-conversion-fix'

Code clean-up.

* ys/bisect-object-id-missing-conversion-fix:
  bisect: use oid_to_hex() for converting object_id hashes to hex strings

3 years agoMerge branch 'yk/filter-branch-non-committish-refs'
Junio C Hamano [Tue, 10 Apr 2018 07:28:23 +0000 (16:28 +0900)]
Merge branch 'yk/filter-branch-non-committish-refs'

when refs that do not point at committish are given, "git
filter-branch" gave a misleading error messages.  This has been
corrected.

* yk/filter-branch-non-committish-refs:
  filter-branch: fix errors caused by refs that point at non-committish

3 years agoMerge branch 'nd/trace-with-env'
Junio C Hamano [Tue, 10 Apr 2018 07:28:22 +0000 (16:28 +0900)]
Merge branch 'nd/trace-with-env'

Code cleanup.

* nd/trace-with-env:
  run-command: use strbuf_addstr() for adding a string to a strbuf

3 years agoMerge branch 'nd/parseopt-completion-more'
Junio C Hamano [Tue, 10 Apr 2018 07:28:22 +0000 (16:28 +0900)]
Merge branch 'nd/parseopt-completion-more'

The mechanism to use parse-options API to automate the command line
completion continues to get extended and polished.

* nd/parseopt-completion-more:
  completion: use __gitcomp_builtin in _git_cherry
  completion: use __gitcomp_builtin in _git_ls_tree
  completion: delete option-only completion commands
  completion: add --option completion for most builtin commands
  completion: factor out _git_xxx calling code
  completion: mention the oldest version we need to support
  git.c: add hidden option --list-parseopt-builtins
  git.c: move cmd_struct declaration up

3 years agoMerge branch 'ds/bsearch-hash'
Junio C Hamano [Tue, 10 Apr 2018 07:28:22 +0000 (16:28 +0900)]
Merge branch 'ds/bsearch-hash'

Code to find the length to uniquely abbreviate object names based
on packfile content, which is a relatively recent addtion, has been
optimized to use the same fan-out table.

* ds/bsearch-hash:
  sha1_name: use bsearch_pack() in unique_in_pack()
  sha1_name: use bsearch_pack() for abbreviations
  packfile: define and use bsearch_pack()
  sha1_name: convert struct min_abbrev_data to object_id

3 years agoMerge branch 'ws/rebase-p'
Junio C Hamano [Tue, 10 Apr 2018 07:28:21 +0000 (16:28 +0900)]
Merge branch 'ws/rebase-p'

Code clean-up.

* ws/rebase-p:
  rebase: remove merges_option and a blank line
  rebase: remove unused code paths from git_rebase__interactive__preserve_merges
  rebase: remove unused code paths from git_rebase__interactive
  rebase: add and use git_rebase__interactive__preserve_merges
  rebase: extract functions out of git_rebase__interactive
  rebase: reindent function git_rebase__interactive
  rebase: update invocation of rebase dot-sourced scripts
  rebase-interactive: simplify pick_on_preserving_merges

3 years agoMerge branch 'jk/diff-highlight-graph-fix'
Junio C Hamano [Tue, 10 Apr 2018 07:28:21 +0000 (16:28 +0900)]
Merge branch 'jk/diff-highlight-graph-fix'

"diff-highlight" filter (in contrib/) learned to undertand "git log
--graph" output better.

* jk/diff-highlight-graph-fix:
  diff-highlight: detect --graph by indent
  diff-highlight: use flush() helper consistently
  diff-highlight: test graphs with --color
  diff-highlight: test interleaved parallel lines of history
  diff-highlight: prefer "echo" to "cat" in tests
  diff-highlight: use test_tick in graph test
  diff-highlight: correct test graph diagram

3 years agoMerge branch 'nd/remove-ignore-env-field'
Junio C Hamano [Tue, 10 Apr 2018 07:28:20 +0000 (16:28 +0900)]
Merge branch 'nd/remove-ignore-env-field'

Code clean-up for the "repository" abstraction.

* nd/remove-ignore-env-field:
  repository.h: add comment and clarify repo_set_gitdir
  repository: delete ignore_env member
  sha1_file.c: move delayed getenv(altdb) back to setup_git_env()
  repository.c: delete dead functions
  repository.c: move env-related setup code back to environment.c
  repository: initialize the_repository in main()

3 years agoMerge branch 'ps/contains-id-error-message'
Junio C Hamano [Tue, 10 Apr 2018 07:28:20 +0000 (16:28 +0900)]
Merge branch 'ps/contains-id-error-message'

"git tag --contains no-such-commit" gave a full list of options
after giving an error message.

* ps/contains-id-error-message:
  parse-options: do not show usage upon invalid option value

3 years agoThe first batch for 2.18 cycle
Junio C Hamano [Mon, 9 Apr 2018 23:31:10 +0000 (08:31 +0900)]
The first batch for 2.18 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'tg/stash-untracked-with-pathspec-fix'
Junio C Hamano [Mon, 9 Apr 2018 23:25:45 +0000 (08:25 +0900)]
Merge branch 'tg/stash-untracked-with-pathspec-fix'

"git stash push -u -- <pathspec>" gave an unnecessary and confusing
error message when there was no tracked files that match the
<pathspec>, which has been fixed.

* tg/stash-untracked-with-pathspec-fix:
  stash: drop superfluos pathspec parameter
  stash push -u: don't create empty stash
  stash push: avoid printing errors
  stash: fix nonsense pipeline

3 years agoMerge branch 'nd/worktree-prune'
Junio C Hamano [Mon, 9 Apr 2018 23:25:45 +0000 (08:25 +0900)]
Merge branch 'nd/worktree-prune'

The way "git worktree prune" worked internally has been simplified,
by assuming how "git worktree move" moves an existing worktree to a
different place.

* nd/worktree-prune:
  worktree prune: improve prune logic when worktree is moved
  worktree: delete dead code
  gc.txt: more details about what gc does

3 years agoMerge branch 'bc/object-id'
Junio C Hamano [Mon, 9 Apr 2018 23:25:45 +0000 (08:25 +0900)]
Merge branch 'bc/object-id'

Conversion from uchar[20] to struct object_id continues.

* bc/object-id: (36 commits)
  convert: convert to struct object_id
  sha1_file: introduce a constant for max header length
  Convert lookup_replace_object to struct object_id
  sha1_file: convert read_sha1_file to struct object_id
  sha1_file: convert read_object_with_reference to object_id
  tree-walk: convert tree entry functions to object_id
  streaming: convert istream internals to struct object_id
  tree-walk: convert get_tree_entry_follow_symlinks internals to object_id
  builtin/notes: convert static functions to object_id
  builtin/fmt-merge-msg: convert remaining code to object_id
  sha1_file: convert sha1_object_info* to object_id
  Convert remaining callers of sha1_object_info_extended to object_id
  packfile: convert unpack_entry to struct object_id
  sha1_file: convert retry_bad_packed_offset to struct object_id
  sha1_file: convert assert_sha1_type to object_id
  builtin/mktree: convert to struct object_id
  streaming: convert open_istream to use struct object_id
  sha1_file: convert check_sha1_signature to struct object_id
  sha1_file: convert read_loose_object to use struct object_id
  builtin/index-pack: convert struct ref_delta_entry to object_id
  ...

3 years agoMerge branch 'ma/shortlog-revparse'
Junio C Hamano [Mon, 9 Apr 2018 23:25:44 +0000 (08:25 +0900)]
Merge branch 'ma/shortlog-revparse'

"git shortlog cruft" aborted with a BUG message when run outside a
Git repository.  The command has been taught to complain about
extra and unwanted arguments on its command line instead in such a
case.

* ma/shortlog-revparse:
  shortlog: disallow left-over arguments outside repo
  shortlog: add usage-string for stdin-reading
  git-shortlog.txt: reorder usages

3 years agoMerge branch 'ab/install-symlinks'
Junio C Hamano [Mon, 9 Apr 2018 23:25:44 +0000 (08:25 +0900)]
Merge branch 'ab/install-symlinks'

The build procedure learned to optionally use symbolic links
(instead of hardlinks and copies) to install "git-foo" for built-in
commands, whose binaries are all identical.

* ab/install-symlinks:
  Makefile: optionally symlink libexec/git-core binaries to bin/git
  Makefile: add a gitexecdir_relative variable
  Makefile: fix broken bindir_relative variable

3 years agoMerge branch 'ml/filter-branch-no-op-error'
Junio C Hamano [Mon, 9 Apr 2018 23:25:44 +0000 (08:25 +0900)]
Merge branch 'ml/filter-branch-no-op-error'

"git filter-branch" learned to use a different exit code to allow
the callers to tell the case where there was no new commits to
rewrite from other error cases.

* ml/filter-branch-no-op-error:
  filter-branch: return 2 when nothing to rewrite

3 years agoMerge branch 'ab/pcre-v2'
Junio C Hamano [Mon, 9 Apr 2018 23:25:43 +0000 (08:25 +0900)]
Merge branch 'ab/pcre-v2'

Git can be built to use either v1 or v2 of the PCRE library, and so
far, the build-time configuration USE_LIBPCRE=YesPlease instructed
the build procedure to use v1, but now it means v2.  USE_LIBPCRE1
and USE_LIBPCRE2 can be used to explicitly choose which version to
use, as before.

* ab/pcre-v2:
  Makefile: make USE_LIBPCRE=YesPlease mean v2, not v1
  configure: detect redundant --with-libpcre & --with-libpcre1
  configure: fix a regression in PCRE v1 detection

3 years agoMerge branch 'ti/fetch-everything-local-optim'
Junio C Hamano [Mon, 9 Apr 2018 23:25:43 +0000 (08:25 +0900)]
Merge branch 'ti/fetch-everything-local-optim'

A "git fetch" from a repository with insane number of refs into a
repository that is already up-to-date still wasted too many cycles
making many lstat(2) calls to see if these objects at the tips
exist as loose objects locally.  These lstat(2) calls are optimized
away by enumerating all loose objects beforehand.

It is unknown if the new strategy negatively affects existing use
cases, fetching into a repository with many loose objects from a
repository with small number of refs.

* ti/fetch-everything-local-optim:
  fetch-pack.c: use oidset to check existence of loose object

3 years agoMerge branch 'en/rename-directory-detection'
Junio C Hamano [Mon, 9 Apr 2018 23:25:43 +0000 (08:25 +0900)]
Merge branch 'en/rename-directory-detection'

Rename detection logic in "diff" family that is used in "merge" has
learned to guess when all of x/a, x/b and x/c have moved to z/a,
z/b and z/c, it is likely that x/d added in the meantime would also
want to move to z/d by taking the hint that the entire directory
'x' moved to 'z'.  A bug causing dirty files involved in a rename
to be overwritten during merge has also been fixed as part of this
work.

* en/rename-directory-detection: (29 commits)
  merge-recursive: ensure we write updates for directory-renamed file
  merge-recursive: avoid spurious rename/rename conflict from dir renames
  directory rename detection: new testcases showcasing a pair of bugs
  merge-recursive: fix remaining directory rename + dirty overwrite cases
  merge-recursive: fix overwriting dirty files involved in renames
  merge-recursive: avoid clobbering untracked files with directory renames
  merge-recursive: apply necessary modifications for directory renames
  merge-recursive: when comparing files, don't include trees
  merge-recursive: check for file level conflicts then get new name
  merge-recursive: add computation of collisions due to dir rename & merging
  merge-recursive: check for directory level conflicts
  merge-recursive: add get_directory_renames()
  merge-recursive: make a helper function for cleanup for handle_renames
  merge-recursive: split out code for determining diff_filepairs
  merge-recursive: make !o->detect_rename codepath more obvious
  merge-recursive: fix leaks of allocated renames and diff_filepairs
  merge-recursive: introduce new functions to handle rename logic
  merge-recursive: move the get_renames() function
  directory rename detection: tests for handling overwriting dirty files
  directory rename detection: tests for handling overwriting untracked files
  ...

3 years agoGit 2.17 v2.17.0
Junio C Hamano [Mon, 2 Apr 2018 17:13:35 +0000 (10:13 -0700)]
Git 2.17

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge tag 'l10n-2.17.0-rnd1' of git://github.com/git-l10n/git-po
Junio C Hamano [Mon, 2 Apr 2018 17:12:38 +0000 (10:12 -0700)]
Merge tag 'l10n-2.17.0-rnd1' of git://github.com/git-l10n/git-po

l10n for Git 2.17.0 round 1

* tag 'l10n-2.17.0-rnd1' of git://github.com/git-l10n/git-po:
  l10n: de.po: translate 132 new messages
  l10n: zh_CN: review for git v2.17.0 l10n round 1
  l10n: zh_CN: for git v2.17.0 l10n round 1
  l10n: ko.po: Update Korean translation
  l10n: fr.po: v2.17.0 no fuzzy
  l10n: sv.po: Update Swedish translation (3376t0f0u)
  l10n: Update Catalan translation
  l10n: fr.po v2.17.0 round 1
  l10n: vi.po(3376t): Updated Vietnamese translation for v2.17
  l10n: bg.po: Updated Bulgarian translation (3376t)
  l10n: es.po: Update Spanish translation 2.17.0
  l10n: git.pot: v2.17.0 round 1 (132 new, 44 removed)
  l10n: es.po: fixes to Spanish translation

3 years agoMerge branch 'pw/add-p-single'
Junio C Hamano [Mon, 2 Apr 2018 17:10:54 +0000 (10:10 -0700)]
Merge branch 'pw/add-p-single'

Hotfix.

* pw/add-p-single:
  add -p: fix 2.17.0-rc* regression due to moved code

3 years agoadd -p: fix 2.17.0-rc* regression due to moved code
Ævar Arnfjörð Bjarmason [Sat, 31 Mar 2018 12:50:58 +0000 (12:50 +0000)]
add -p: fix 2.17.0-rc* regression due to moved code

Fix a regression in 88f6ffc1c2 ("add -p: only bind search key if
there's more than one hunk", 2018-02-13) which is present in
2.17.0-rc*, but not 2.16.0.

In Perl, regex variables like $1 always refer to the last regex
match. When the aforementioned change added a new regex match between
the old match and the corresponding code that was expecting $1, the $1
variable would always be undef, since the newly inserted regex match
doesn't have any captures.

As a result the "/" feature to search for a string in a hunk by regex
completely broke, on git.git:

    $ perl -pi -e 's/Git/Tig/g' README.md
    $ ./git --exec-path=$PWD add -p
    [..]
    Stage this hunk [y,n,q,a,d,j,J,g,/,s,e,?]? s
    Split into 4 hunks.
    [...]
    Stage this hunk [y,n,q,a,d,j,J,g,/,s,e,?]? /Many
    Use of uninitialized value $1 in string eq at /home/avar/g/git/git-add--interactive line 1568, <STDIN> line 1.
    search for regex? Many

I.e. the initial "/regex" command wouldn't work, and would always emit
a warning and ask again for a regex, now it works as intended again.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agol10n: de.po: translate 132 new messages
Ralf Thielow [Fri, 16 Mar 2018 17:41:16 +0000 (18:41 +0100)]
l10n: de.po: translate 132 new messages

Translate 132 new messages came from git.pot update in abc8de64d (l10n:
git.pot: v2.17.0 round 1 (132 new, 44 removed)).

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
3 years agoMerge branch 'jh/partial-clone'
Junio C Hamano [Thu, 29 Mar 2018 22:39:59 +0000 (15:39 -0700)]
Merge branch 'jh/partial-clone'

Hotfix.

* jh/partial-clone:
  upload-pack: disable object filtering when disabled by config
  unpack-trees: release oid_array after use in check_updates()

3 years agoupload-pack: disable object filtering when disabled by config
Jonathan Nieder [Wed, 28 Mar 2018 20:33:03 +0000 (13:33 -0700)]
upload-pack: disable object filtering when disabled by config

When upload-pack gained partial clone support (v2.17.0-rc0~132^2~12,
2017-12-08), it was guarded by the uploadpack.allowFilter config item
to allow server operators to control when they start supporting it.

That config item didn't go far enough, though: it controls whether the
'filter' capability is advertised, but if a (custom) client ignores
the capability advertisement and passes a filter specification anyway,
the server would handle that despite allowFilter being false.

This is particularly significant if a security bug is discovered in
this new experimental partial clone code.  Installations without
uploadpack.allowFilter ought not to be affected since they don't
intend to support partial clone, but they would be swept up into being
vulnerable.

Simplify and limit the attack surface by making uploadpack.allowFilter
disable the feature, not just the advertisement of it.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agol10n: zh_CN: review for git v2.17.0 l10n round 1
Ray Chen [Thu, 29 Mar 2018 07:09:20 +0000 (15:09 +0800)]
l10n: zh_CN: review for git v2.17.0 l10n round 1

Signed-off-by: Ray Chen <oldsharp@gmail.com>
3 years agol10n: zh_CN: for git v2.17.0 l10n round 1
Jiang Xin [Thu, 22 Feb 2018 01:17:34 +0000 (09:17 +0800)]
l10n: zh_CN: for git v2.17.0 l10n round 1

Translate 132 new messages (3376t0f0u) for git 2.17.0-rc0.

Reviewed-by: 依云 <lilydjwg@gmail.com>
Reviewed-by: Fangyi Zhou <fangyi.zhou@yuriko.moe>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
3 years agoGit 2.17-rc2 v2.17.0-rc2
Junio C Hamano [Wed, 28 Mar 2018 18:05:14 +0000 (11:05 -0700)]
Git 2.17-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'tg/stash-doc-typofix'
Junio C Hamano [Wed, 28 Mar 2018 18:04:25 +0000 (11:04 -0700)]
Merge branch 'tg/stash-doc-typofix'

Hotfix.

* tg/stash-doc-typofix:
  git-stash.txt: remove extra square bracket

3 years agoMerge branch 'pc/submodule-helper'
Junio C Hamano [Wed, 28 Mar 2018 18:04:25 +0000 (11:04 -0700)]
Merge branch 'pc/submodule-helper'

Hotfix.

* pc/submodule-helper:
  submodule deinit: handle non existing pathspecs gracefully

3 years agoMerge branch 'nd/parseopt-completion'
Junio C Hamano [Wed, 28 Mar 2018 18:04:24 +0000 (11:04 -0700)]
Merge branch 'nd/parseopt-completion'

Hotfix for recently graduated topic that give help to completion
scripts from the Git subcommands that are being completed

* nd/parseopt-completion:
  t9902: disable test on the list of merge-strategies under GETTEXT_POISON
  completion: clear cached --options when sourcing the completion script

3 years agol10n: ko.po: Update Korean translation
Changwoo Ryu [Mon, 19 Mar 2018 04:59:50 +0000 (13:59 +0900)]
l10n: ko.po: Update Korean translation

Signed-off-by: Changwoo Ryu <cwryu@debian.org>
Signed-off-by: Sihyeon Jang <uneedsihyeon@gmail.com>
Signed-off-by: Gwan-gyeong Mun <elongbug@gmail.com>
Reviewed-by: Changwoo Ryu <cwryu@debian.org>
3 years agosubmodule deinit: handle non existing pathspecs gracefully
Stefan Beller [Tue, 27 Mar 2018 23:28:24 +0000 (16:28 -0700)]
submodule deinit: handle non existing pathspecs gracefully

This fixes a regression introduced in 2e612731b5 (submodule: port
submodule subcommand 'deinit' from shell to C, 2018-01-15), when
handling pathspecs that do not exist gracefully. This restores the
historic behavior of reporting the pathspec as unknown and returning
instead of reporting a bug.

Reported-by: Peter Oberndorfer <kumbayo84@arcor.de>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-stash.txt: remove extra square bracket
Thomas Gummerer [Mon, 26 Mar 2018 21:11:47 +0000 (22:11 +0100)]
git-stash.txt: remove extra square bracket

In 1ada5020b3 ("stash: use stash_push for no verb form", 2017-02-28),
when the pathspec argument was introduced in 'git stash', that was also
documented.  However I forgot to remove an extra square bracket after
the '--message' argument, even though the square bracket should have
been after the pathspec argument (where it was also added).

Remove the extra square bracket after the '--message' argument, to show
that the pathspec argument should be used with the 'push' verb.

While the pathspec argument can be used without the push verb, that's a
special case described later in the man page, and removing the first extra
square bracket instead of the second one makes the synopis easier to
understand.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agounpack-trees: release oid_array after use in check_updates()
René Scharfe [Sun, 25 Mar 2018 16:31:48 +0000 (18:31 +0200)]
unpack-trees: release oid_array after use in check_updates()

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofilter-branch: fix errors caused by refs that point at non-committish
Yuki Kokubun [Sun, 25 Mar 2018 16:54:58 +0000 (16:54 +0000)]
filter-branch: fix errors caused by refs that point at non-committish

"git filter-branch -- --all" prints error messages when processing refs that
point at objects that are not committish. Such refs can be created by
"git replace" with trees or blobs. And also "git tag" with trees or blobs can
create such refs.

Filter these problematic refs out early, before they are seen by the logic to
see which refs have been modified and which have been left intact (which is
where the unwanted error messages come from), and warn that these refs are left
unwritten while doing so.

Signed-off-by: Yuki Kokubun <orga.chem.job@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorun-command: use strbuf_addstr() for adding a string to a strbuf
René Scharfe [Sun, 25 Mar 2018 10:57:50 +0000 (12:57 +0200)]
run-command: use strbuf_addstr() for adding a string to a strbuf

Patch generated with Coccinelle and contrib/coccinelle/strbuf.cocci.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect: use oid_to_hex() for converting object_id hashes to hex strings
René Scharfe [Sun, 25 Mar 2018 10:57:36 +0000 (12:57 +0200)]
bisect: use oid_to_hex() for converting object_id hashes to hex strings

Patch generated with Coccinelle and contrib/coccinelle/object_id.cocci.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: use __gitcomp_builtin in _git_cherry
Nguyễn Thái Ngọc Duy [Sat, 24 Mar 2018 20:35:25 +0000 (21:35 +0100)]
completion: use __gitcomp_builtin in _git_cherry

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: use __gitcomp_builtin in _git_ls_tree
Nguyễn Thái Ngọc Duy [Sat, 24 Mar 2018 20:35:24 +0000 (21:35 +0100)]
completion: use __gitcomp_builtin in _git_ls_tree

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: delete option-only completion commands
Nguyễn Thái Ngọc Duy [Sat, 24 Mar 2018 20:35:23 +0000 (21:35 +0100)]
completion: delete option-only completion commands

The new function __git_complete_common can take over this job with
less code to maintain.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: add --option completion for most builtin commands
Nguyễn Thái Ngọc Duy [Sat, 24 Mar 2018 20:35:22 +0000 (21:35 +0100)]
completion: add --option completion for most builtin commands

Many builtin commands use parseopt which can expose the option list
via --git-completion-helper but do not have explicit support in
git-completion.bash. This patch detects those commands and uses
__gitcomp_builtin for option completion.

This does not pollute the command name completion though. "git <tab>"
will show you the same set as before. This only kicks in when you type
the correct command name.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: factor out _git_xxx calling code
Nguyễn Thái Ngọc Duy [Sat, 24 Mar 2018 20:35:21 +0000 (21:35 +0100)]
completion: factor out _git_xxx calling code

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: mention the oldest version we need to support
Nguyễn Thái Ngọc Duy [Sat, 24 Mar 2018 20:35:20 +0000 (21:35 +0100)]
completion: mention the oldest version we need to support

This is more of a note for git-completion.bash contributors, not
users. The bash version is from MacOS [1]. Most Linux distros should
be 4.x at this point.

[1] https://public-inbox.org/git/%3CCAPig+cQXT1ov4MjzSzqiLBzr4wN1XcP7aSxMP+_dhtWtYwhDAA@mail.gmail.com%3E/

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit.c: add hidden option --list-parseopt-builtins
Nguyễn Thái Ngọc Duy [Sat, 24 Mar 2018 20:35:19 +0000 (21:35 +0100)]
git.c: add hidden option --list-parseopt-builtins

This is another step to help automate git-completion.bash. This option
gives a list of all builtin commands that do use parse_options(),
which supports another hidden option --git-completion-helper. The
output is prepared for easy consumption by git-completion.bash and
separates items by spaces instead of \n

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit.c: move cmd_struct declaration up
Nguyễn Thái Ngọc Duy [Sat, 24 Mar 2018 20:35:18 +0000 (21:35 +0100)]
git.c: move cmd_struct declaration up

In a later patch we need access to one of these command option
constants near the top of this file. Move this block up so we will be
able to access the command options.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosha1_name: use bsearch_pack() in unique_in_pack()
René Scharfe [Sat, 24 Mar 2018 16:41:08 +0000 (17:41 +0100)]
sha1_name: use bsearch_pack() in unique_in_pack()

Replace the custom binary search in unique_in_pack() with a call to
bsearch_pack().  This reduces code duplication and makes use of the
fan-out table of packs.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'fr_v2.17.0' of git://github.com/jnavila/git
Jiang Xin [Sun, 25 Mar 2018 13:24:02 +0000 (21:24 +0800)]
Merge branch 'fr_v2.17.0' of git://github.com/jnavila/git

* 'fr_v2.17.0' of git://github.com/jnavila/git:
  l10n: fr.po: v2.17.0 no fuzzy

3 years agorebase: remove merges_option and a blank line
Wink Saville [Fri, 23 Mar 2018 21:25:29 +0000 (14:25 -0700)]
rebase: remove merges_option and a blank line

merges_option is unused in git_rebase__interactive and always empty in
git_rebase__interactive__preserve_merges so it can be removed.

Signed-off-by: Wink Saville <wink@saville.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase: remove unused code paths from git_rebase__interactive__preserve_merges
Wink Saville [Fri, 23 Mar 2018 21:25:28 +0000 (14:25 -0700)]
rebase: remove unused code paths from git_rebase__interactive__preserve_merges

Since git_rebase__interactive__preserve_merges is now always called with
$preserve_merges = t we can remove the unused code paths.

Signed-off-by: Wink Saville <wink@saville.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase: remove unused code paths from git_rebase__interactive
Wink Saville [Fri, 23 Mar 2018 21:25:27 +0000 (14:25 -0700)]
rebase: remove unused code paths from git_rebase__interactive

Since git_rebase__interactive is now never called with
$preserve_merges = t we can remove those code paths.

Signed-off-by: Wink Saville <wink@saville.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase: add and use git_rebase__interactive__preserve_merges
Wink Saville [Fri, 23 Mar 2018 21:25:26 +0000 (14:25 -0700)]
rebase: add and use git_rebase__interactive__preserve_merges

At the moment it's an exact copy of git_rebase__interactive except
the name has changed.

Signed-off-by: Wink Saville <wink@saville.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase: extract functions out of git_rebase__interactive
Wink Saville [Fri, 23 Mar 2018 21:25:25 +0000 (14:25 -0700)]
rebase: extract functions out of git_rebase__interactive

The extracted functions are:
  - initiate_action
  - setup_reflog_action
  - init_basic_state
  - init_revisions_and_shortrevisions
  - complete_action

Used by git_rebase__interactive

Signed-off-by: Wink Saville <wink@saville.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase: reindent function git_rebase__interactive
Wink Saville [Fri, 23 Mar 2018 21:25:24 +0000 (14:25 -0700)]
rebase: reindent function git_rebase__interactive

Signed-off-by: Wink Saville <wink@saville.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase: update invocation of rebase dot-sourced scripts
Wink Saville [Fri, 23 Mar 2018 21:25:23 +0000 (14:25 -0700)]
rebase: update invocation of rebase dot-sourced scripts

Due to historical reasons, the backend scriptlets for "git rebase"
are structured a bit unusually. As originally designed,
dot-sourcing them from "git rebase" was sufficient to invoke the
specific backend.

However, it was later discovered that some shell implementations
(e.g. FreeBSD 9.x) misbehaved by continuing to execute statements
following a top-level "return" rather than returning control to
the next statement in "git rebase" after dot-sourcing the
scriptlet. To work around this shortcoming, the whole body of
git-rebase--$backend.sh was made into a shell function
git_rebase__$backend, and then the very last line of the scriptlet
called that function.

A more normal architecture is for a dot-sourced scriptlet merely
to define functions (thus acting as a function library), and for
those functions to be called by the script doing the dot-sourcing.
Migrate to this arrangement by moving the git_rebase__$backend
call from the end of a scriptlet into "git rebase" itself.

While at it, remove the large comment block from each scriptlet
explaining this historic anomaly since it serves no purpose under
the new normalized architecture in which a scriptlet is merely a
function library.

Signed-off-by: Wink Saville <wink@saville.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agol10n: fr.po: v2.17.0 no fuzzy
Jean-Noël Avila [Fri, 23 Mar 2018 22:03:37 +0000 (23:03 +0100)]
l10n: fr.po: v2.17.0 no fuzzy

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
3 years agot9902: disable test on the list of merge-strategies under GETTEXT_POISON
Junio C Hamano [Fri, 23 Mar 2018 17:40:06 +0000 (10:40 -0700)]
t9902: disable test on the list of merge-strategies under GETTEXT_POISON

The code to learn the list of merge strategies from the output of
"git merge -s help" forces C locale, so that it can notice the
message shown to indicate where the list starts in the output.

However, GETTEXT_POISON build corrupts its output even when run in
the C locale, and we cannot expect this test to succeed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorepository.h: add comment and clarify repo_set_gitdir
Nguyễn Thái Ngọc Duy [Fri, 23 Mar 2018 15:55:23 +0000 (16:55 +0100)]
repository.h: add comment and clarify repo_set_gitdir

The argument name "optional" may mislead the reader to think this
option could be NULL. But it can't be. While at there, document a bit
more about struct set_gitdir_args.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorebase-interactive: simplify pick_on_preserving_merges
Wink Saville [Fri, 23 Mar 2018 04:39:52 +0000 (21:39 -0700)]
rebase-interactive: simplify pick_on_preserving_merges

Use compound if statement instead of nested if statements to
simplify pick_on_preserving_merges.

Signed-off-by: Wink Saville <wink@saville.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with Git 2.16.3
Junio C Hamano [Thu, 22 Mar 2018 21:36:51 +0000 (14:36 -0700)]
Sync with Git 2.16.3

3 years agoGit 2.16.3 v2.16.3
Junio C Hamano [Thu, 22 Mar 2018 21:24:45 +0000 (14:24 -0700)]
Git 2.16.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ms/non-ascii-ticks' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:25 +0000 (14:24 -0700)]
Merge branch 'ms/non-ascii-ticks' into maint

Doc markup fix.

* ms/non-ascii-ticks:
  Documentation/gitsubmodules.txt: avoid non-ASCII apostrophes

3 years agoMerge branch 'jk/cached-commit-buffer' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:25 +0000 (14:24 -0700)]
Merge branch 'jk/cached-commit-buffer' into maint

Code clean-up.

* jk/cached-commit-buffer:
  revision: drop --show-all option
  commit: drop uses of get_cached_commit_buffer()

3 years agoMerge branch 'sm/mv-dry-run-update' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:25 +0000 (14:24 -0700)]
Merge branch 'sm/mv-dry-run-update' into maint

Code clean-up.

* sm/mv-dry-run-update:
  mv: remove unneeded 'if (!show_only)'
  t7001: add test case for --dry-run

3 years agoMerge branch 'tg/worktree-create-tracking' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:24 +0000 (14:24 -0700)]
Merge branch 'tg/worktree-create-tracking' into maint

Hotfix for a recent topic.

* tg/worktree-create-tracking:
  git-worktree.txt: fix indentation of example and text of 'add' command
  git-worktree.txt: fix missing ")" typo

3 years agoMerge branch 'gs/test-unset-xdg-cache-home' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:24 +0000 (14:24 -0700)]
Merge branch 'gs/test-unset-xdg-cache-home' into maint

Test update.

* gs/test-unset-xdg-cache-home:
  test-lib.sh: unset XDG_CACHE_HOME

3 years agoMerge branch 'sb/status-doc-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:23 +0000 (14:24 -0700)]
Merge branch 'sb/status-doc-fix' into maint

Docfix.

* sb/status-doc-fix:
  Documentation/git-status: clarify status table for porcelain mode

3 years agoMerge branch 'rd/typofix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:22 +0000 (14:24 -0700)]
Merge branch 'rd/typofix' into maint

Typofix.

* rd/typofix:
  Correct mispellings of ".gitmodule" to ".gitmodules"
  t/: correct obvious typo "detahced"

3 years agoMerge branch 'bp/fsmonitor' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:21 +0000 (14:24 -0700)]
Merge branch 'bp/fsmonitor' into maint

Doc update for a recently added feature.

* bp/fsmonitor:
  fsmonitor: update documentation to remove reference to invalid config settings

3 years agoMerge branch 'bc/doc-interpret-trailers-grammofix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:21 +0000 (14:24 -0700)]
Merge branch 'bc/doc-interpret-trailers-grammofix' into maint

Docfix.

* bc/doc-interpret-trailers-grammofix:
  docs/interpret-trailers: fix agreement error

3 years agoMerge branch 'sg/doc-test-must-fail-args' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:19 +0000 (14:24 -0700)]
Merge branch 'sg/doc-test-must-fail-args' into maint

Devdoc update.

* sg/doc-test-must-fail-args:
  t: document 'test_must_fail ok=<signal-name>'

3 years agoMerge branch 'rj/sparse-updates' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:19 +0000 (14:24 -0700)]
Merge branch 'rj/sparse-updates' into maint

Devtool update.

* rj/sparse-updates:
  Makefile: suppress a sparse warning for pack-revindex.c
  config.mak.uname: remove SPARSE_FLAGS setting for cygwin

3 years agoMerge branch 'jk/gettext-poison' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:18 +0000 (14:24 -0700)]
Merge branch 'jk/gettext-poison' into maint

Test updates.

* jk/gettext-poison:
  git-sh-i18n: check GETTEXT_POISON before USE_GETTEXT_SCHEME
  t0205: drop redundant test

3 years agoMerge branch 'nd/ignore-glob-doc-update' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:18 +0000 (14:24 -0700)]
Merge branch 'nd/ignore-glob-doc-update' into maint

Doc update.

* nd/ignore-glob-doc-update:
  gitignore.txt: elaborate shell glob syntax

3 years agoMerge branch 'rs/cocci-strbuf-addf-to-addstr' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:17 +0000 (14:24 -0700)]
Merge branch 'rs/cocci-strbuf-addf-to-addstr' into maint

* rs/cocci-strbuf-addf-to-addstr:
  cocci: simplify check for trivial format strings

3 years agoMerge branch 'jc/worktree-add-short-help' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:17 +0000 (14:24 -0700)]
Merge branch 'jc/worktree-add-short-help' into maint

Error message fix.

* jc/worktree-add-short-help:
  worktree: say that "add" takes an arbitrary commit in short-help

3 years agoMerge branch 'tz/doc-show-defaults-to-head' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:17 +0000 (14:24 -0700)]
Merge branch 'tz/doc-show-defaults-to-head' into maint

Doc update.

* tz/doc-show-defaults-to-head:
  doc: mention 'git show' defaults to HEAD

3 years agoMerge branch 'nd/shared-index-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:16 +0000 (14:24 -0700)]
Merge branch 'nd/shared-index-fix' into maint

Code clean-up.

* nd/shared-index-fix:
  read-cache: don't write index twice if we can't write shared index
  read-cache.c: move tempfile creation/cleanup out of write_shared_index
  read-cache.c: change type of "temp" in write_shared_index()

3 years agoMerge branch 'jc/mailinfo-cleanup-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:16 +0000 (14:24 -0700)]
Merge branch 'jc/mailinfo-cleanup-fix' into maint

Corner case bugfix.

* jc/mailinfo-cleanup-fix:
  mailinfo: avoid segfault when can't open files

3 years agoMerge branch 'rb/hashmap-h-compilation-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:15 +0000 (14:24 -0700)]
Merge branch 'rb/hashmap-h-compilation-fix' into maint

Code clean-up.

* rb/hashmap-h-compilation-fix:
  hashmap.h: remove unused variable

3 years agoMerge branch 'rs/describe-unique-abbrev' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:14 +0000 (14:24 -0700)]
Merge branch 'rs/describe-unique-abbrev' into maint

Code clean-up.

* rs/describe-unique-abbrev:
  describe: use strbuf_add_unique_abbrev() for adding short hashes

3 years agoMerge branch 'ks/submodule-doc-updates' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:13 +0000 (14:24 -0700)]
Merge branch 'ks/submodule-doc-updates' into maint

Doc updates.

* ks/submodule-doc-updates:
  Doc/git-submodule: improve readability and grammar of a sentence
  Doc/gitsubmodules: make some changes to improve readability and syntax

3 years agoMerge branch 'cl/t9001-cleanup' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:13 +0000 (14:24 -0700)]
Merge branch 'cl/t9001-cleanup' into maint

Test clean-up.

* cl/t9001-cleanup:
  t9001: use existing helper in send-email test

3 years agoMerge branch 'bw/oidmap-autoinit' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:12 +0000 (14:24 -0700)]
Merge branch 'bw/oidmap-autoinit' into maint

Code clean-up.

* bw/oidmap-autoinit:
  oidmap: ensure map is initialized

3 years agoMerge branch 'sg/test-i18ngrep' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:12 +0000 (14:24 -0700)]
Merge branch 'sg/test-i18ngrep' into maint

Test fixes.

* sg/test-i18ngrep:
  t: make 'test_i18ngrep' more informative on failure
  t: validate 'test_i18ngrep's parameters
  t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'
  t5536: let 'test_i18ngrep' read the file without redirection
  t5510: consolidate 'grep' and 'test_i18ngrep' patterns
  t4001: don't run 'git status' upstream of a pipe
  t6022: don't run 'git merge' upstream of a pipe
  t5812: add 'test_i18ngrep's missing filename parameter
  t5541: add 'test_i18ngrep's missing filename parameter

3 years agoMerge branch 'jt/fsck-code-cleanup' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:12 +0000 (14:24 -0700)]
Merge branch 'jt/fsck-code-cleanup' into maint

Plug recently introduced leaks in fsck.

* jt/fsck-code-cleanup:
  fsck: fix leak when traversing trees

3 years agoMerge branch 'ew/svn-branch-segfault-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:11 +0000 (14:24 -0700)]
Merge branch 'ew/svn-branch-segfault-fix' into maint

Workaround for segfault with more recent versions of SVN.

* ew/svn-branch-segfault-fix:
  git-svn: control destruction order to avoid segfault

3 years agoMerge branch 'nd/list-merge-strategy' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:11 +0000 (14:24 -0700)]
Merge branch 'nd/list-merge-strategy' into maint

Completion of "git merge -s<strategy>" (in contrib/) did not work
well in non-C locale.

* nd/list-merge-strategy:
  completion: fix completing merge strategies on non-C locales

3 years agoMerge branch 'jk/daemon-fixes' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:10 +0000 (14:24 -0700)]
Merge branch 'jk/daemon-fixes' into maint

Assorted fixes to "git daemon".

* jk/daemon-fixes:
  daemon: fix length computation in newline stripping
  t/lib-git-daemon: add network-protocol helpers
  daemon: handle NULs in extended attribute string
  daemon: fix off-by-one in logging extended attributes
  t/lib-git-daemon: record daemon log
  t5570: use ls-remote instead of clone for interp tests

3 years agoMerge branch 'tg/split-index-fixes' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:10 +0000 (14:24 -0700)]
Merge branch 'tg/split-index-fixes' into maint

The split-index mode had a few corner case bugs fixed.

* tg/split-index-fixes:
  travis: run tests with GIT_TEST_SPLIT_INDEX
  split-index: don't write cache tree with null oid entries
  read-cache: fix reading the shared index for other repos

3 years agoMerge branch 'mr/packed-ref-store-fix' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:10 +0000 (14:24 -0700)]
Merge branch 'mr/packed-ref-store-fix' into maint

Crash fix for a corner case where an error codepath tried to unlock
what it did not acquire lock on.

* mr/packed-ref-store-fix:
  files_initial_transaction_commit(): only unlock if locked

3 years agoMerge branch 'jt/http-redact-cookies' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:09 +0000 (14:24 -0700)]
Merge branch 'jt/http-redact-cookies' into maint

The http tracing code, often used to debug connection issues,
learned to redact potentially sensitive information from its output
so that it can be more safely sharable.

* jt/http-redact-cookies:
  http: support omitting data from traces
  http: support cookie redaction when tracing

3 years agoMerge branch 'nd/diff-flush-before-warning' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:09 +0000 (14:24 -0700)]
Merge branch 'nd/diff-flush-before-warning' into maint

Avoid showing a warning message in the middle of a line of "git
diff" output.

* nd/diff-flush-before-warning:
  diff.c: flush stdout before printing rename warnings

3 years agoMerge branch 'sg/travis-build-during-script-phase' into maint
Junio C Hamano [Thu, 22 Mar 2018 21:24:08 +0000 (14:24 -0700)]
Merge branch 'sg/travis-build-during-script-phase' into maint

Build the executable in 'script' phase in Travis CI integration, to
follow the established practice, rather than during 'before_script'
phase.  This allows the CI categorize the failures better ('failed'
is project's fault, 'errored' is build environment's).

* sg/travis-build-during-script-phase:
  travis-ci: build Git during the 'script' phase

3 years agoparse-options: do not show usage upon invalid option value
Paul-Sebastian Ungureanu [Thu, 22 Mar 2018 18:43:51 +0000 (20:43 +0200)]
parse-options: do not show usage upon invalid option value

Usually, the usage should be shown only if the user does not know what
options are available. If the user specifies an invalid value, the user
is already aware of the available options. In this case, there is no
point in displaying the usage anymore.

This patch applies to "git tag --contains", "git branch --contains",
"git branch --points-at", "git for-each-ref --contains" and many more.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosha1_name: use bsearch_pack() for abbreviations
Derrick Stolee [Thu, 22 Mar 2018 17:40:10 +0000 (13:40 -0400)]
sha1_name: use bsearch_pack() for abbreviations

When computing abbreviation lengths for an object ID against a single
packfile, the method find_abbrev_len_for_pack() currently implements
binary search. This is one of several implementations. One issue with
this implementation is that it ignores the fanout table in the pack-
index.

Translate this binary search to use the existing bsearch_pack() method
that correctly uses a fanout table.

Due to the use of the fanout table, the abbreviation computation is
slightly faster than before. For a fully-repacked copy of the Linux
repo, the following 'git log' commands improved:

* git log --oneline --parents --raw
  Before: 59.2s
  After:  56.9s
  Rel %:  -3.8%

* git log --oneline --parents
  Before: 6.48s
  After:  5.91s
  Rel %: -8.9%

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopackfile: define and use bsearch_pack()
Derrick Stolee [Thu, 22 Mar 2018 17:40:09 +0000 (13:40 -0400)]
packfile: define and use bsearch_pack()

The method bsearch_hash() generalizes binary searches using a
fanout table. The only consumer is currently find_pack_entry_one().
It requires a bit of pointer arithmetic to align the fanout table
and the lookup table depending on the pack-index version.

Extract the pack-index pointer arithmetic to a new method,
bsearch_pack(), so this can be re-used in other code paths.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosha1_name: convert struct min_abbrev_data to object_id
brian m. carlson [Thu, 22 Mar 2018 17:40:08 +0000 (13:40 -0400)]
sha1_name: convert struct min_abbrev_data to object_id

This structure is only written to in one place, where we already have a
struct object_id.  Convert the struct to use a struct object_id instead.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>