Junio C Hamano [Mon, 22 Apr 2019 02:14:45 +0000 (11:14 +0900)]
Merge branch 'tg/stash-in-c-show-default-to-p-fix'
A regression fix.
* tg/stash-in-c-show-default-to-p-fix:
stash: setup default diff output format if necessary
Junio C Hamano [Mon, 22 Apr 2019 02:14:44 +0000 (11:14 +0900)]
Merge branch 'js/stash-in-c-pathspec-fix'
Further fixes to "git stash" reimplemented in C.
* js/stash-in-c-pathspec-fix:
stash: pass pathspec as pointer
built-in stash: handle :(glob) pathspecs again
legacy stash: fix "rudimentary backport of -q"
Junio C Hamano [Mon, 22 Apr 2019 02:14:44 +0000 (11:14 +0900)]
Merge branch 'tb/stash-in-c-unused-param-fix'
Code clean-up.
* tb/stash-in-c-unused-param-fix:
stash: drop unused parameter
Junio C Hamano [Mon, 22 Apr 2019 02:14:43 +0000 (11:14 +0900)]
Merge branch 'ps/stash-in-c'
"git stash" rewritten in C.
* ps/stash-in-c: (28 commits)
tests: add a special setup where stash.useBuiltin is off
stash: optionally use the scripted version again
stash: add back the original, scripted `git stash`
stash: convert `stash--helper.c` into `stash.c`
stash: replace all `write-tree` child processes with API calls
stash: optimize `get_untracked_files()` and `check_changes()`
stash: convert save to builtin
stash: make push -q quiet
stash: convert push to builtin
stash: convert create to builtin
stash: convert store to builtin
stash: convert show to builtin
stash: convert list to builtin
stash: convert pop to builtin
stash: convert branch to builtin
stash: convert drop and clear to builtin
stash: convert apply to builtin
stash: mention options in `show` synopsis
stash: add tests for `git stash show` config
stash: rename test cases to be more descriptive
...
Josh Steadmon [Fri, 19 Apr 2019 21:00:13 +0000 (14:00 -0700)]
clone: do faster object check for partial clones
For partial clones, doing a full connectivity check is wasteful; we skip
promisor objects (which, for a partial clone, is all known objects), and
enumerating them all to exclude them from the connectivity check can
take a significant amount of time on large repos.
At most, we want to make sure that we get the objects referred to by any
wanted refs. For partial clones, just check that these objects were
transferred.
Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Tan [Fri, 19 Apr 2019 17:21:28 +0000 (10:21 -0700)]
worktree: update is_bare heuristics
When "git branch -D <name>" is run, Git usually first checks if that
branch is currently checked out. But this check is not performed if the
Git directory of that repository is not at "<repo>/.git", which is the
case if that repository is a submodule that has its Git directory stored
as "super/.git/modules/<repo>", for example. This results in the branch
being deleted even though it is checked out.
This is because get_main_worktree() in worktree.c sets is_bare on a
worktree only using the heuristic that a repo is bare if the worktree's
path does not end in "/.git", and not bare otherwise. This is_bare code
was introduced in
92718b7438 ("worktree: add details to the worktree
struct", 2015-10-08), following a pre-core.bare heuristic. This patch
does 2 things:
- Teach get_main_worktree() to use is_bare_repository() instead,
introduced in
7d1864ce67 ("Introduce is_bare_repository() and
core.bare configuration variable", 2007-01-07) and updated in
e90fdc39b6 ("Clean up work-tree handling", 2007-08-01). This solves
the "git branch -D <name>" problem described above. However...
- If a repository has core.bare=1 but the "git" command is being run
from one of its secondary worktrees, is_bare_repository() returns
false (which is fine, since there is a worktree available). However,
treating the main worktree as non-bare when it is bare causes issues:
for example, failure to delete a branch from a secondary worktree
that is referred to by a main worktree's HEAD, even if that main
worktree is bare.
In order to avoid that, also check core.bare when setting is_bare. If
core.bare=1, trust it, and otherwise, use is_bare_repository().
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:44 +0000 (15:30 +0100)]
rebase -i: run without forking rebase--interactive
When the builtin rebase starts an interactive rebase it parses the
options and then repackages them and forks
`rebase--interactive`. Separate the option parsing in
cmd_rebase__interactive() from the business logic to allow interactive
rebases can be run without forking `rebase__interactive` by calling
run_rebase_interactive() directly.
Starting interactive rebases without forking makes it easy to debug
the sequencer without worrying about attaching to child
processes. Ævar has also reported that some of the rebase perf tests
are 30% faster [1].
This patch also makes it easy to remove cmd_rebase__interactive() in
the future when git-legacy-rebase.sh and
git-rebase--preserve-merges.sh are retired.
[1] https://public-inbox.org/git/87y359cfjj.fsf@evledraar.gmail.com/
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:43 +0000 (15:30 +0100)]
rebase: use a common action enum
cmd_rebase() and cmd_rebase__interactive() used different enums to hold
the current action. Change to using a common enum so the values are the
same when we change `rebase -i` to avoid forking `rebase--interactive`.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:42 +0000 (15:30 +0100)]
rebase -i: use struct rebase_options in do_interactive_rebase()
All the parameters that are passed to do_interactive_rebase() apart from
`flags` are already in `struct rebase_options` so there is no need to
pass them separately.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:41 +0000 (15:30 +0100)]
rebase -i: use struct rebase_options to parse args
In order to run `rebase -i` without forking `rebase--interactive` it
will be convenient to use the same structure when parsing the options in
cmd_rebase() and cmd_rebase__interactive().
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:40 +0000 (15:30 +0100)]
rebase -i: use struct object_id for squash_onto
More preparation for using `struct rebase_options` in
cmd_rebase__interactive(). Using a string was a hangover from the
scripted version of rebase, update the functions that use `squash_onto`
to take a `sturct object_id`.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:39 +0000 (15:30 +0100)]
rebase -i: use struct commit when parsing options
This is in preparation for using `struct rebase_options` when parsing
options in cmd_rebase__interactive(). Using a string for onto,
restrict_revision and upstream, was a hangover from the scripted version
of rebase. The functions that use these variables are updated to take a
`struct commit`.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:38 +0000 (15:30 +0100)]
rebase -i: remove duplication
path_state_dir() and merge_dir() refer to the same path so remove one of
them.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:37 +0000 (15:30 +0100)]
rebase -i: combine rebase--interactive.c with rebase.c
In order to run `rebase -i` without forking `rebase--interactive` it
will be convenient to have all the code from rebase--interactive.c in
rebase.c. This is a straight forward copy of the code from
rebase--interactive.c, it will be simplified slightly in the next
commit.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:36 +0000 (15:30 +0100)]
rebase: use OPT_RERERE_AUTOUPDATE()
As we have a macro for this it makes sense to use it. Having
cmd_rebase() and cmd_rebase__interactive() use the same values for
this option will be helpful when we start running interactive rebases
without forking rebase--interactive.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:35 +0000 (15:30 +0100)]
rebase: rename write_basic_state()
This clashes with a function in sequencer.c
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 14:30:34 +0000 (15:30 +0100)]
rebase: don't translate trace strings
commit
b3a5d5a80c ("trace2:data: add subverb for rebase", 2019-02-22)
mistakenly marked the subverb names for translation and unnecessarily
NULL terminated the array.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Tue, 19 Mar 2019 19:03:07 +0000 (19:03 +0000)]
sequencer: always discard index after checkout
As the checkout runs in a separate process our index will be out of date
so it should be discarded. The existing callers are not doing this
consistently so do it here to avoid the callers having to worry about
it.
This fixes some test failures that happen if do_interactive_rebase() is
called without forking rebase--interactive which we will implement
shortly. Running
git rebase -i master topic
starting on master created empty todo lists because all the commits in
topic were marked as cherry-picks. After topic was checked out in
prepare_branch_to_be_rebased() the working tree contained the contents
from topic but the index contained master and the cache entries were
still valid. This meant that diff_populate_filespec() which loads the
blobs when calculating patch-id's ended up reading the contents for
master from the working tree which actually contained topic.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Thu, 21 Mar 2019 03:10:40 +0000 (12:10 +0900)]
Merge branch 'ag/sequencer-reduce-rewriting-todo' into pw/rebase-i-internal
* ag/sequencer-reduce-rewriting-todo:
rebase--interactive: move transform_todo_file()
sequencer: use edit_todo_list() in complete_action()
rebase-interactive: rewrite edit_todo_list() to handle the initial edit
rebase-interactive: append_todo_help() changes
rebase-interactive: use todo_list_write_to_file() in edit_todo_list()
sequencer: refactor skip_unnecessary_picks() to work on a todo_list
rebase--interactive: move rearrange_squash_in_todo_file()
rebase--interactive: move sequencer_add_exec_commands()
sequencer: change complete_action() to use the refactored functions
sequencer: make sequencer_make_script() write its script to a strbuf
sequencer: refactor rearrange_squash() to work on a todo_list
sequencer: refactor sequencer_add_exec_commands() to work on a todo_list
sequencer: refactor check_todo_list() to work on a todo_list
sequencer: introduce todo_list_write_to_file()
sequencer: refactor transform_todos() to work on a todo_list
sequencer: remove the 'arg' field from todo_item
sequencer: make the todo_list structure public
sequencer: changes in parse_insn_buffer()
Jeff King [Thu, 18 Apr 2019 21:18:35 +0000 (17:18 -0400)]
untracked-cache: simplify parsing by dropping "len"
The code which parses untracked-cache extensions from disk keeps a "len"
variable, which is the size of the string we are parsing. But since we
now have an "end of string" variable, we can just use that to get the
length when we need it. This eliminates the need to keep "len" up to
date (and removes the possibility of any errors where "len" and "eos"
get out of sync).
As a bonus, it means we are not storing a string length in an "int",
which is a potential source of overflows (though in this case it seems
fairly unlikely for that to cause any memory problems).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King [Thu, 18 Apr 2019 21:17:38 +0000 (17:17 -0400)]
untracked-cache: simplify parsing by dropping "next"
When we parse an on-disk untracked cache, we have two pointers, "data"
and "next". As we parse, we point "next" to the end of an element, and
then later update "data" to match.
But we actually don't need two pointers. Each parsing step can just
update "data" directly from other variables we hold (and we don't have
to worry about bailing in an intermediate state, since any parsing
failure causes us to immediately discard "data" and return).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King [Thu, 18 Apr 2019 21:17:02 +0000 (17:17 -0400)]
untracked-cache: be defensive about missing NULs in index
The on-disk format for the untracked-cache extension contains
NUL-terminated filenames. We parse these from the mmap'd file using
string functions like strlen(). This works fine in the normal case, but
if we see a malformed or corrupted index, we might read off the end of
our mmap.
Instead, let's use memchr() to find the trailing NUL within the bytes we
know are available, and return an error if it's missing.
Note that we can further simplify by folding another range check into
our conditional. After we find the end of the string, we set "next" to
the byte after the string and treat it as an error if there are no such
bytes left. That saves us from having to do a range check at the
beginning of each subsequent string (and works because there is always
data after each string). We can do both range checks together by
checking "!eos" (we didn't find a NUL) and "eos == end" (it was on the
last available byte, meaning there's nothing after). This replaces the
existing "next > end" checks.
Note also that the decode_varint() calls have a similar problem (we
don't even pass them "end"; they just keep parsing). These are probably
OK in practice since varints have a finite length (we stop parsing when
we'd overflow a uintmax_t), so the worst case is that we'd overflow into
reading the trailing bytes of the index.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King [Thu, 18 Apr 2019 20:08:27 +0000 (16:08 -0400)]
t5304: add a test for pruning with bitmaps
Commit
fde67d6896 (prune: use bitmaps for reachability traversal,
2019-02-13) uses bitmaps for pruning when they're available, but only
covers this functionality in the t/perf tests. This makes a kind of
sense, since the point is that the behaviour is indistinguishable before
and after the patch, just faster.
But since the bitmap code path is not exercised at all in the regular
test suite, it leaves us open to a regression where the behavior does in
fact change. The most thorough way to test that would be running the
whole suite with bitmaps enabled. But we don't yet have a way to do
that, and anyway it's expensive to do so. Let's at least add a basic
test that exercises this path and make sure we prune an object we should
(and not one that we shouldn't).
That would hopefully catch the most obvious breakages early.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin [Thu, 18 Apr 2019 13:16:51 +0000 (06:16 -0700)]
Turn `git serve` into a test helper
The `git serve` built-in was introduced in
ed10cb952d31 (serve:
introduce git-serve, 2018-03-15) as a backend to serve Git protocol v2,
probably originally intended to be spawned by `git upload-pack`.
However, in the version that the protocol v2 patches made it into core
Git, `git upload-pack` calls the `serve()` function directly instead of
spawning `git serve`; The only reason in life for `git serve` to survive
as a built-in command is to provide a way to test the protocol v2
functionality.
Meaning that it does not even have to be a built-in that is installed
with end-user facing Git installations, but it can be a test helper
instead.
Let's make it so.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin [Thu, 18 Apr 2019 13:16:49 +0000 (06:16 -0700)]
test-tool: handle the `-C <directory>` option just like `git`
In preparation for moving `git serve` into `test-tool` (because it
really is only used by the test suite), we teach the `test-tool` the
useful trick to change the working directory before running the test
command, which will avoid introducing subshells in the test code.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin [Thu, 18 Apr 2019 13:16:46 +0000 (06:16 -0700)]
check-docs: do not bother checking for legacy scripts' documentation
In the recent years, there has been a big push to convert more and more
of Git's commands that are implemented as scripts to built-ins written
in pure, portable C, for robustness, speed and portability.
One strategy that served us well is to convert those scripts
incrementally, starting by renaming the scripts to
`git-legacy-<command>`, then introducing a built-in that does nothing
else at first than checking the config setting `<command>.useBuiltin`
(which defaults to `false` at the outset) and handing off to the legacy
script if so asked.
Obviously, those `git-legacy-<command>` commands share the documentation
with the built-in `git-<command>`, and are not intended to be called
directly anyway. So let's not try to ensure that they are documented
separately from their built-in versions.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin [Thu, 18 Apr 2019 13:16:44 +0000 (06:16 -0700)]
docs: exclude documentation for commands that have been excluded
When building with certain build options, some commands are excluded
from the build. For example, `git-credential-cache` is skipped when
building with `NO_UNIX_SOCKETS`.
Let's not build or package documentation for those excluded commands.
This issue was pointed out rightfully when running `make check-docs` on
Windows, where we do not yet have Unix sockets, and therefore the
`credential-cache` command is excluded (yet its documentation was built
and shipped).
Note: building the documentation via `make -C Documentation` leaves the
build system with no way to determine which commands have been
excluded. If called thusly, we gracefully fail to exclude their
documentation. Only when building the documentation via the top-level
Makefile will it get excluded properly, or after building
`Documentation/GIT-EXCLUDED-PROGRAMS` manually.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin [Thu, 18 Apr 2019 13:16:42 +0000 (06:16 -0700)]
check-docs: allow command-list.txt to contain excluded commands
Among other things, the `check-docs` target ensures that
`command-list.txt` no longer contains commands that were dropped (or
that were never added in the first place).
To do so, it compares the list of commands from that file to the
commands listed in `$(ALL_COMMANDS)`.
However, some build options exclude commands from the latter. Fix the
target to handle this situation correctly by taking the just-introduced
`$(EXCLUDED_PROGRAMS)` into account.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin [Thu, 18 Apr 2019 13:16:40 +0000 (06:16 -0700)]
help -a: do not list commands that are excluded from the build
When built with NO_CURL or with NO_UNIX_SOCKETS, some commands are
skipped from the build. It does not make sense to list them in the
output of `git help -a`, so let's just not.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin [Thu, 18 Apr 2019 13:16:39 +0000 (06:16 -0700)]
Makefile: drop the NO_INSTALL variable
The last user was just removed; There is no longer any need to carry it
around. Should we ever run into a need for it again, it is easy enough
to revert this commit.
It is unlikely, though, that we need `NO_INSTALL` again: as we saw with
the just-removed item, `git-remote-testgit`, we have better locations
to put executables and scripts that we do not want to install, e.g.
a subdirectory in `t/`, or `contrib/`.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Vadim Kochan [Thu, 18 Apr 2019 05:04:19 +0000 (08:04 +0300)]
autoconf: #include <libintl.h> when checking for gettext()
Some libc implementations like uclibc or musl provides
gettext stubs via libintl library but this case is not checked
by AC_CHECK_LIB(c, gettext ...) because gcc has gettext as builtin
which passess the check.
So check it with included libintl.h where gettext may unfold into
libintl_gettext which will cause check to fail if libintl_gettext are
needed to be linked with -lintl.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:30 +0000 (11:23 +0100)]
cherry-pick/revert: add scissors line on merge conflict
Fix a bug where the scissors line is placed after the Conflicts:
section, in the case where a merge conflict occurs and
commit.cleanup = scissors.
Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Wed, 17 Apr 2019 10:23:29 +0000 (11:23 +0100)]
sequencer.c: save and restore cleanup mode
If the user specifies an explicit cleanup mode then save and restore it
so that it is preserved by 'git cherry-pick --continue'.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:28 +0000 (11:23 +0100)]
merge: add scissors line on merge conflict
This fixes a bug where the scissors line is placed after the Conflicts:
section, in the case where a merge conflict occurs and
commit.cleanup = scissors.
Next, if commit.cleanup = scissors is specified, don't produce a
scissors line in commit if one already exists in the MERGE_MSG file.
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:27 +0000 (11:23 +0100)]
merge: cleanup messages like commit
This change allows git-merge messages to be cleaned up with the
commit.cleanup configuration or --cleanup option, just like how
git-commit does it.
We also give git-pull the option of --cleanup so that it can also take
advantage of this change.
Finally, add testing to ensure that messages are properly cleaned up.
Note that some newlines that were added to the commit message were
removed so that if a file were read via -F, it would be copied
faithfully.
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:26 +0000 (11:23 +0100)]
parse-options.h: extract common --cleanup option
The --cleanup option is commonly used. Extract it so that its definition
is not repeated.
Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:25 +0000 (11:23 +0100)]
commit: extract cleanup_mode functions to sequencer
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:24 +0000 (11:23 +0100)]
t7502: clean up style
Refactor out Git commands that were upstream of a pipe. Remove spaces
after "> ". Indent here-docs appropriately. Convert echo chains to use
the test_write_lines function. Refactor 'sign off' test to use test_cmp
instead of comparing variables.
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:23 +0000 (11:23 +0100)]
t7604: clean up style
Before, we had some Git commands which were upstream of the pipe. This
meant that if it produced an error, it would've gone unnoticed. Refactor
to place Git commands on their own.
Also, while we're at it, remove spaces after redirection operators.
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:22 +0000 (11:23 +0100)]
t3507: clean up style
Remove space after redirection operators for style. Also, remove a git
command which was upstream of a pipe. Finally, let grep and sed open
their own input instead of letting the shell redirect the input.
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu [Wed, 17 Apr 2019 10:23:21 +0000 (11:23 +0100)]
t7600: clean up style
Clean up the 'merge --squash c3 with c7' test by removing some
unnecessary braces and removing a pipe.
Also, generally cleanup style by unindenting a here-doc, removing stray
spaces after a redirection operator and allowing sed to open its own
input instead of redirecting input from the shell.
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Fri, 29 Mar 2019 11:08:42 +0000 (11:08 +0000)]
sequencer: fix cleanup with --signoff and -x
Before commit
356ee4659b ("sequencer: try to commit without forking 'git
commit'", 2017-11-24) when --signoff or -x were given on the command
line the commit message was cleaned up with --cleanup=space or
commit.cleanup if it was set. Unfortunately this behavior was lost when
I implemented committing without forking. Fix this and add some tests to
catch future regressions.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Tan [Fri, 12 Apr 2019 19:51:22 +0000 (12:51 -0700)]
clone: send server options when using protocol v2
Commit
5e3548ef16 ("fetch: send server options when using protocol v2",
2018-04-24) taught "fetch" the ability to send server options when using
protocol v2, but not "clone". This ability is triggered by "-o" or
"--server-option".
Teach "clone" the same ability, except that because "clone" already
has "-o" for another parameter, teach "clone" only to receive
"--server-option".
Explain in the documentation, both for clone and for fetch, that server
handling of server options are server-specific. This is similar to
receive-pack's handling of push options - currently, they are just sent
to hooks to interpret as they see fit.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Tan [Fri, 12 Apr 2019 19:51:21 +0000 (12:51 -0700)]
transport: die if server options are unsupported
Server options were added in commit
5e3548ef16 ("fetch: send server
options when using protocol v2", 2018-04-24), supported only for
protocol version 2. But if the user specifies server options, and the
protocol version being used doesn't support them, the server options are
silently ignored.
Teach any transport users to die instead in this situation, just like
how "push" dies if push options are provided when the server doesn't
support them.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Damien Robert [Tue, 16 Apr 2019 12:16:46 +0000 (14:16 +0200)]
ref-filter: use correct branch for %(push:track)
In ref-filter.c, when processing the atom %(push:track), the
ahead/behind values are computed using `stat_tracking_info` which refers
to the upstream branch.
Fix that by introducing a new flag `for_push` in `stat_tracking_info`
in remote.c, which does the same thing but for the push branch.
Update the few callers of `stat_tracking_info` to handle this flag. This
ensure that whenever we use this function in the future, we are careful
to specify is this should apply to the upstream or the push branch.
This bug was not detected in t/t6300-for-each-ref.sh because in the test
for push:track, both the upstream and the push branches were behind by 1
from the local branch. Change the test so that the upstream branch is
behind by 1 while the push branch is ahead by 1. This allows us to test
that %(push:track) refers to the correct branch.
This changes the expected value of some following tests (by introducing
new references), so update them too.
Signed-off-by: Damien Robert <damien.olivier.robert+git@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Tue, 16 Apr 2019 10:18:42 +0000 (11:18 +0100)]
fix cherry-pick/revert status after commit
If the user commits a conflict resolution using `git commit` in the
middle of a sequence of cherry-picks/reverts then `git status` missed
the fact that a cherry-pick/revert is still in progress.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood [Tue, 16 Apr 2019 10:18:41 +0000 (11:18 +0100)]
commit/reset: try to clean up sequencer state
When cherry-picking or reverting a sequence of commits and if the final
pick/revert has conflicts and the user uses `git commit` to commit the
conflict resolution and does not run `git cherry-pick --continue` then
the sequencer state is left behind. This can cause problems later. In my
case I cherry-picked a sequence of commits the last one of which I
committed with `git commit` after resolving some conflicts, then a while
later, on a different branch I aborted a revert which rewound my HEAD to
the end of the cherry-pick sequence on the previous branch. Avoid this
potential problem by removing the sequencer state if we're committing or
resetting the final pick in a sequence.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Tue, 16 Apr 2019 10:33:35 +0000 (19:33 +0900)]
The fifth batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano [Tue, 16 Apr 2019 10:28:12 +0000 (19:28 +0900)]
Merge branch 'sg/t5318-cleanup'
Code cleanup.
* sg/t5318-cleanup:
t5318-commit-graph: remove unused variable
Junio C Hamano [Tue, 16 Apr 2019 10:28:12 +0000 (19:28 +0900)]
Merge branch 'jt/t5551-protocol-v2-does-not-have-half-auth'
Test update.
* jt/t5551-protocol-v2-does-not-have-half-auth:
t5551: mark half-auth no-op fetch test as v0-only
Junio C Hamano [Tue, 16 Apr 2019 10:28:11 +0000 (19:28 +0900)]
Merge branch 'jk/http-walker-status-fix'
dumb-http walker has been updated to share more error recovery
strategy with the normal codepath.
* jk/http-walker-status-fix:
http: use normalize_curl_result() instead of manual conversion
http: normalize curl results for dumb loose and alternates fetches
http: factor out curl result code normalization
Junio C Hamano [Tue, 16 Apr 2019 10:28:11 +0000 (19:28 +0900)]
Merge branch 'jh/midx-verify-too-many-packs'
"git multi-pack-index verify" did not scale well with the number of
packfiles, which is being improved.
* jh/midx-verify-too-many-packs:
midx: during verify group objects by packfile to speed verification
midx: add progress indicators in multi-pack-index verify
trace2:data: add trace2 data to midx
progress: add sparse mode to force 100% complete message
Junio C Hamano [Tue, 16 Apr 2019 10:28:11 +0000 (19:28 +0900)]
Merge branch 'bb/unicode-12'
Unicode update.
* bb/unicode-12:
unicode: update the width tables to Unicode 12
Junio C Hamano [Tue, 16 Apr 2019 10:28:11 +0000 (19:28 +0900)]
Merge branch 'jk/refs-double-abort'
A corner case bug in the refs API has been corrected.
* jk/refs-double-abort:
refs/files-backend: don't look at an aborted transaction
refs/files-backend: handle packed transaction prepare failure
Junio C Hamano [Tue, 16 Apr 2019 10:28:10 +0000 (19:28 +0900)]
Merge branch 'nd/checkout-m-doc-update'
Doc about the above.
* nd/checkout-m-doc-update:
checkout.txt: note about losing staged changes with --merge
Junio C Hamano [Tue, 16 Apr 2019 10:28:10 +0000 (19:28 +0900)]
Merge branch 'tb/trace2-va-list-fix'
Fix some code that passed a NULL when a va_list was expected.
* tb/trace2-va-list-fix:
trace2: NULL is not allowed for va_list
Junio C Hamano [Tue, 16 Apr 2019 10:28:09 +0000 (19:28 +0900)]
Merge branch 'tz/completion'
The completion helper code now pays attention to repository-local
configuration (when available), which allows --list-cmds to honour
a repository specific setting of completion.commands, for example.
* tz/completion:
completion: use __git when calling --list-cmds
completion: fix multiple command removals
t9902: test multiple removals via completion.commands
git: read local config in --list-cmds
Junio C Hamano [Tue, 16 Apr 2019 10:28:09 +0000 (19:28 +0900)]
Merge branch 'ma/doc-diff-doc-vs-doctor-comparison'
Dev support update to make it easier to compare two formatted
results from our documentation.
* ma/doc-diff-doc-vs-doctor-comparison:
doc-diff: add `--cut-header-footer`
doc-diff: support diffing from/to AsciiDoc(tor)
doc-diff: let `render_tree()` take an explicit directory name
Doc: auto-detect changed build flags
Junio C Hamano [Tue, 16 Apr 2019 10:28:09 +0000 (19:28 +0900)]
Merge branch 'tz/t4038-bash-redirect-target-workaround'
Work-around extra warning from bash in our tests.
* tz/t4038-bash-redirect-target-workaround:
t4038-diff-combined: quote paths with whitespace
Junio C Hamano [Tue, 16 Apr 2019 10:28:09 +0000 (19:28 +0900)]
Merge branch 'ab/drop-scripted-rebase'
Retire scripted "git rebase" implementation.
* ab/drop-scripted-rebase:
rebase: remove the rebase.useBuiltin setting
Junio C Hamano [Tue, 16 Apr 2019 10:28:08 +0000 (19:28 +0900)]
Merge branch 'jk/perf-lib-tee'
Code cleanup in the test framework.
* jk/perf-lib-tee:
perf-lib.sh: rely on test-lib.sh for --tee handling
Junio C Hamano [Tue, 16 Apr 2019 10:28:08 +0000 (19:28 +0900)]
Merge branch 'ab/doc-misc-typofixes'
Typofixes.
* ab/doc-misc-typofixes:
doc: fix typos in man pages
Junio C Hamano [Tue, 16 Apr 2019 10:28:08 +0000 (19:28 +0900)]
Merge branch 'mh/pack-protocol-doc-fix'
Docfix.
* mh/pack-protocol-doc-fix:
fix pack protocol example client/server communication
Junio C Hamano [Tue, 16 Apr 2019 10:28:07 +0000 (19:28 +0900)]
Merge branch 'tg/glossary-overlay'
Doc update.
* tg/glossary-overlay:
glossary: add definition for overlay
Junio C Hamano [Tue, 16 Apr 2019 10:28:07 +0000 (19:28 +0900)]
Merge branch 'nd/checkout-f-while-conflicted-fix'
"git checkout -f <branch>" while the index has an unmerged path
incorrectly left some paths in an unmerged state, which has been
corrected.
* nd/checkout-f-while-conflicted-fix:
unpack-trees: fix oneway_merge accidentally carry over stage index
Junio C Hamano [Tue, 16 Apr 2019 10:28:07 +0000 (19:28 +0900)]
Merge branch 'pw/rerere-autoupdate'
Doc updates.
* pw/rerere-autoupdate:
merge: tweak --rerere-autoupdate documentation
am/cherry-pick/rebase/revert: document --rerere-autoupdate
Junio C Hamano [Tue, 16 Apr 2019 10:28:06 +0000 (19:28 +0900)]
Merge branch 'jc/format-patch-error-check'
"git format-patch" used overwrite an existing patch/cover-letter
file. A new "--no-clobber" option stops it.
* jc/format-patch-error-check:
format-patch: notice failure to open cover letter for writing
builtin/log: downcase the beginning of error messages
Junio C Hamano [Tue, 16 Apr 2019 10:28:06 +0000 (19:28 +0900)]
Merge branch 'js/get-short-oid-drop-cache'
A corner-case object name ambiguity while the sequencer machinery
is working (e.g. "rebase -i -x") has been (half) fixed.
* js/get-short-oid-drop-cache:
get_oid(): when an object was not found, try harder
sequencer: move stale comment into correct location
sequencer: improve error message when an OID could not be parsed
rebase -i: demonstrate obscure loose object cache bug
Junio C Hamano [Tue, 16 Apr 2019 10:28:06 +0000 (19:28 +0900)]
Merge branch 'dl/subtree-limit-to-one-rev'
"git subtree" (in contrib/) update.
* dl/subtree-limit-to-one-rev:
contrib/subtree: ensure only one rev is provided
Junio C Hamano [Tue, 16 Apr 2019 10:28:05 +0000 (19:28 +0900)]
Merge branch 'js/init-db-update-for-mingw'
"git init" forgot to read platform-specific repository
configuration, which made Windows port to ignore settings of
core.hidedotfiles, for example.
* js/init-db-update-for-mingw:
mingw: respect core.hidedotfiles = false in git-init again
Junio C Hamano [Tue, 16 Apr 2019 10:28:05 +0000 (19:28 +0900)]
Merge branch 'js/remote-curl-i18n'
Error messages given from the http transport have been updated so
that they can be localized.
* js/remote-curl-i18n:
remote-curl: mark all error messages for translation
Junio C Hamano [Tue, 16 Apr 2019 10:28:04 +0000 (19:28 +0900)]
Merge branch 'js/anonymize-remote-curl-diag'
remote-http transport did not anonymize URLs reported in its error
messages at places.
* js/anonymize-remote-curl-diag:
curl: anonymize URLs in error messages and warnings
Junio C Hamano [Tue, 16 Apr 2019 10:28:04 +0000 (19:28 +0900)]
Merge branch 'ma/asciidoctor-fixes-more'
Documentation mark-up fixes.
* ma/asciidoctor-fixes-more:
Documentation: turn middle-of-line tabs into spaces
git-svn.txt: drop escaping '\' that ends up being rendered
git.txt: remove empty line before list continuation
config/fsck.txt: avoid starting line with dash
config/diff.txt: drop spurious backtick
Junio C Hamano [Tue, 16 Apr 2019 10:28:03 +0000 (19:28 +0900)]
Merge branch 'ma/asciidoctor-fixes'
Build fix around use of asciidoctor instead of asciidoc
* ma/asciidoctor-fixes:
asciidoctor-extensions: fix spurious space after linkgit
Documentation/Makefile: add missing dependency on asciidoctor-extensions
Documentation/Makefile: add missing xsl dependencies for manpages
Junio C Hamano [Tue, 16 Apr 2019 10:28:03 +0000 (19:28 +0900)]
Merge branch 'jt/test-protocol-version'
Help developers by making it easier to run most of the tests under
different versions of over-the-wire protocols.
* jt/test-protocol-version:
t5552: compensate for v2 filtering ref adv.
tests: fix protocol version for overspecifications
t5700: only run with protocol version 1
t5512: compensate for v0 only sending HEAD symrefs
t5503: fix overspecification of trace expectation
tests: always test fetch of unreachable with v0
t5601: check ssh command only with protocol v0
tests: define GIT_TEST_PROTOCOL_VERSION
Junio C Hamano [Tue, 16 Apr 2019 10:28:03 +0000 (19:28 +0900)]
Merge branch 'nd/diff-parseopt-3'
Third batch to teach the diff machinery to use the parse-options
API.
* nd/diff-parseopt-3:
diff-parseopt: convert --submodule
diff-parseopt: convert --ignore-submodules
diff-parseopt: convert --textconv
diff-parseopt: convert --ext-diff
diff-parseopt: convert --quiet
diff-parseopt: convert --exit-code
diff-parseopt: convert --color-words
diff-parseopt: convert --word-diff-regex
diff-parseopt: convert --word-diff
diff-parseopt: convert --[no-]color
diff-parseopt: convert --[no-]follow
diff-parseopt: convert -R
diff-parseopt: convert -a|--text
diff-parseopt: convert --full-index
diff-parseopt: convert --binary
diff-parseopt: convert --anchored
diff-parseopt: convert --diff-algorithm
diff-parseopt: convert --histogram
diff-parseopt: convert --patience
diff-parseopt: convert --[no-]indent-heuristic
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:41 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from get_oid_mb()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:40 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from other get_oid_*
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:39 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from maybe_die_on_misspelt_object_name
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:38 +0000 (16:33 +0700)]
submodule-config.c: use repo_get_oid for reading .gitmodules
Since
76e9bdc437 (submodule: support reading .gitmodules when it's not
in the working tree - 2018-10-25), every time you do
git grep --recurse-submodules
you are likely to see one warning line per submodule (unless all those
submodules also have submodules). On a superproject with plenty of
submodules (I've seen one with 67) this is really annoying.
The warning was there because we could not resolve extended SHA-1
syntax on a submodule. We can now. Make use of the new API and get rid
of the warning.
It would be even better if config_with_options() supports multiple
repositories too. But one step at a time.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:37 +0000 (16:33 +0700)]
sha1-name.c: add repo_get_oid()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:36 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from get_oid_with_context_1()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:35 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from resolve_relative_path()
"remove" is not entirely correct. But at least the function is aware
that if the given repo is not the_repository, then $CWD and
is_inside_work_tree() means nothing.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:34 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from diagnose_invalid_index_path()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:33 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from handle_one_ref()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:32 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from get_oid_1()
There is a cyclic dependency between one of these functions so they
cannot be converted one by one, so all related functions are converted
at once.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:31 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from get_oid_basic()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:30 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from get_describe_name()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:29 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from get_oid_oneline()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:28 +0000 (16:33 +0700)]
sha1-name.c: add repo_interpret_branch_name()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:27 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from interpret_branch_mark()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:26 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from interpret_nth_prior_checkout()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:25 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from get_short_oid()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:24 +0000 (16:33 +0700)]
sha1-name.c: add repo_for_each_abbrev()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:23 +0000 (16:33 +0700)]
sha1-name.c: store and use repo in struct disambiguate_state
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:22 +0000 (16:33 +0700)]
sha1-name.c: add repo_find_unique_abbrev_r()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:21 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from find_abbrev_len_packed()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:20 +0000 (16:33 +0700)]
sha1-name.c: remove the_repo from sort_ambiguous()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:19 +0000 (16:33 +0700)]
commit.c: add repo_get_commit_tree()
Remove the implicit dependency on the_repository in this function.
It will be used in sha1-name.c functions when they are updated to take
any 'struct repository'. get_commit_tree() remains as a compat wrapper,
to be slowly replaced later.
Any access to "maybe_tree" field directly will result in _broken_ code
after running through commit.cocci because we can't know what is the
right repository to use.
the_repository would be correct most of the time. But we're relying less
and less on the_repository and that assumption may no longer be
true. The transformation now is more of a poor man replacement for a C++
compiler catching access to private fields.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy [Tue, 16 Apr 2019 09:33:18 +0000 (16:33 +0700)]
commit.cocci: refactor code, avoid double rewrite
"maybe" pointer in 'struct commit' is tricky because it can be lazily
initialized to take advantage of commit-graph if available. This makes
it not safe to access directly.
This leads to a rule in commit.cocci to rewrite 'x->maybe_tree' to
'get_commit_tree(x)'. But that rule alone could lead to incorrectly
rewrite assignments, e.g. from
x->maybe_tree = yes
to
get_commit_tree(x) = yes
Because of this we have a second rule to revert this effect. Szeder
found out that we could do better by performing the assignment rewrite
rule first, then the remaining is read-only access and handled by the
current first rule.
For this to work, we need to transform "x->maybe_tree = y" to something
that does NOT contain "x->maybe_tree" to avoid the original first
rule. This is where set_commit_tree() comes in.
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>