summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)AuthorFilesLines
2017-05-25blame: move progress updates to a scoreboard callbackLibravatar Jeff Smith1-10/+17
Allow the interface user to decide how to handle a progress update. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: make sanity_check use a callback in scoreboardLibravatar Jeff Smith1-8/+19
Allow the interface user to decide how to handle a failed sanity check, whether that be to output with the current state or to do nothing. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: move no_whole_file_rename flag to scoreboardLibravatar Jeff Smith1-1/+3
The no_whole_file_rename flag is used in parts of blame that are being moved to libgit, and should be accessible via the scoreboard structure. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: move xdl_opts flags to scoreboardLibravatar Jeff Smith1-3/+5
The xdl_opts flags are used in parts of blame that are being moved to libgit, and should be accessible via the scoreboard structure. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: move show_root flag to scoreboardLibravatar Jeff Smith1-1/+4
The show_root flag is used in parts of blame that are being moved to libgit, and should be accessible via the scoreboard structure. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: move reverse flag to scoreboardLibravatar Jeff Smith1-9/+14
The reverse flag is used in parts of blame that are being moved to libgit, and should be accessible via the scoreboard structure. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: move contents_from to scoreboardLibravatar Jeff Smith1-0/+4
The argument from --contents is used in parts of blame that are being moved to libgit, and should be accessible via the scoreboard structure. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: move copy/move thresholds to scoreboardLibravatar Jeff Smith1-18/+23
Copy and move score thresholds are used in parts of blame that are being moved to libgit, and should be accessible via the scoreboard structure. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: move stat counters to scoreboardLibravatar Jeff Smith1-17/+17
Statistic counters are used in parts of blame that are being moved to libgit, and should be accessible via the scoreboard structure. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: rename nth_line functionLibravatar Jeff Smith1-8/+8
Functions that will be publicly exposed should have names that better reflect what they are a part of. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: rename ent_score functionLibravatar Jeff Smith1-7/+7
Functions that will be publicly exposed should have names that better reflect what they are a part of. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: rename coalesce functionLibravatar Jeff Smith1-2/+2
Functions that will be publicly exposed should have names that better reflect what they are a part of. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: rename origin-related functionsLibravatar Jeff Smith1-29/+29
Functions related to blame_origin that will be publicly exposed should have names that better reflect what they are a part of. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: rename scoreboard structure to blame_scoreboardLibravatar Jeff Smith1-29/+29
The scoreboard structure is core to the blame interface. Since scoreboard will become more exposed, rename it to blame_scoreboard to clarify what it is a part of. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: rename origin structure to blame_originLibravatar Jeff Smith1-57/+57
The origin structure is core to the blame interface. Since origin will become more exposed, rename it to blame_origin to clarify what it is a part of. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: remove unused parametersLibravatar Jeff Smith1-15/+10
Clean up blame code before moving it into libgit Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: move textconv_object with related functionsLibravatar Jeff Smith2-28/+1
textconv_object is used in places other than blame.c and should be moved to a more appropriate location. Other textconv related functions are located in diff.c so that seems as good a place as any. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-24blame: remove unneeded dependency on blob.hLibravatar Jeff Smith1-1/+0
With commit 21666f1 ("convert object type handling from a string to a number", 2007-02-26), there was no longer a need for blame.c to include blob.h but it was not removed. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-16Merge branch 'js/larger-timestamps'Libravatar Junio C Hamano15-48/+48
Some platforms have ulong that is smaller than time_t, and our historical use of ulong for timestamp would mean they cannot represent some timestamp that the platform allows. Invent a separate and dedicated timestamp_t (so that we can distingiuish timestamps and a vanilla ulongs, which along is already a good move), and then declare uintmax_t is the type to be used as the timestamp_t. * js/larger-timestamps: archive-tar: fix a sparse 'constant too large' warning use uintmax_t for timestamps date.c: abort if the system time cannot handle one of our timestamps timestamp_t: a new data type for timestamps PRItime: introduce a new "printf format" for timestamps parse_timestamp(): specify explicitly where we parse timestamps t0006 & t5000: skip "far in the future" test when time_t is too limited t0006 & t5000: prepare for 64-bit timestamps ref-filter: avoid using `unsigned long` for catch-all data type
2017-05-16Merge branch 'jn/clone-add-empty-config-from-command-line'Libravatar Junio C Hamano1-1/+3
"git clone --config var=val" is a way to populate the per-repository configuration file of the new repository, but it did not work well when val is an empty string. This has been fixed. * jn/clone-add-empty-config-from-command-line: clone: handle empty config values in -c
2017-05-16Merge branch 'ab/clone-no-tags'Libravatar Junio C Hamano1-2/+11
"git clone" learned the "--no-tags" option not to fetch all tags initially, and also set up the tagopt not to follow any tags in subsequent fetches. * ab/clone-no-tags: tests: rename a test having to do with shallow submodules clone: add a --no-tags option to clone without tags tests: change "cd ... && git fetch" to "cd &&\n\tgit fetch"
2017-05-16Merge branch 'sk/status-short-branch-color-config'Libravatar Junio C Hamano1-0/+4
The colors in which "git status --short --branch" showed the names of the current branch and its remote-tracking branch are now configurable. * sk/status-short-branch-color-config: status: add color config slots for branch info in "--short --branch" status: fix missing newline when comment chars are disabled
2017-05-16Merge branch 'jk/am-leakfix'Libravatar Junio C Hamano1-20/+14
The codepath in "git am" that is used when running "git rebase" leaked memory held for the log message of the commits being rebased. * jk/am-leakfix: am: shorten ident_split variable name in get_commit_info() am: simplify allocations in get_commit_info() am: fix commit buffer leak in get_commit_info()
2017-05-04Merge branch 'ja/i18n-cleanup'Libravatar Junio C Hamano1-6/+6
* ja/i18n-cleanup: i18n: read-cache: typofix i18n: remove i18n from tag reflog message
2017-05-02clone: handle empty config values in -cLibravatar Jonathan Nieder1-1/+3
"git clone --config" uses the following incantation to add an item to a config file, instead of replacing an existing value: git_config_set_multivar_gently(key, value, "^$", 0) As long as no existing value matches the regex ^$, that works as intended and adds to the config. When a value is empty, though, it replaces the existing value. Noticed while trying to set credential.helper during a clone to use a specific helper without inheriting from ~/.gitconfig and /etc/gitconfig. That is, I ran git clone -c credential.helper= \ -c credential.helper=myhelper \ https://example.com/repo intending to produce the configuration [credential] helper = helper = myhelper Without this patch, the 'helper =' line is not included and the credential helper from /etc/gitconfig gets used. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-01Merge branch 'jk/submodule-init-segv-fix'Libravatar Junio C Hamano1-3/+3
Fix a segv in 'submodule init' when url is not given for a submodule. * jk/submodule-init-segv-fix: submodule_init: die cleanly on submodules without url defined
2017-05-01clone: add a --no-tags option to clone without tagsLibravatar Ævar Arnfjörð Bjarmason1-2/+11
Add a --no-tags option to clone without fetching any tags. Without this change there's no easy way to clone a repository without also fetching its tags. When supplying --single-branch the primary remote branch will be cloned, but in addition tags will be followed & retrieved. Now --no-tags can be added --single-branch to clone a repository without tags, and which only tracks a single upstream branch. This option works without --single-branch as well, and will do a normal clone but not fetch any tags. Many git commands pay some fixed overhead as a function of the number of references. E.g. creating ~40k tags in linux.git will cause a command like `git log -1 >/dev/null` to run in over a second instead of in a matter of milliseconds, in addition numerous other things will slow down, e.g. "git log <TAB>" with the bash completion will slowly show ~40k references instead of 1. The user might want to avoid all of that overhead to simply use a repository like that to browse the "master" branch, or something like a CI tool might want to keep that one branch up-to-date without caring about any other references. Without this change the only way of accomplishing this was either by manually tweaking the config in a fresh repository: git init git && cat >git/.git/config <<EOF && [remote "origin"] url = git@github.com:git/git.git tagOpt = --no-tags fetch = +refs/heads/master:refs/remotes/origin/master [branch "master"] remote = origin merge = refs/heads/master EOF cd git && git pull Which requires hardcoding the "master" name, which may not be the main --single-branch would have retrieved, or alternatively by setting tagOpt=--no-tags right after cloning & deleting any existing tags: git clone --single-branch git@github.com:git/git.git && cd git && git config remote.origin.tagOpt --no-tags && git tag -l | xargs git tag -d Which of course was also subtly buggy if --branch was pointed at a tag, leaving the user in a detached head: git clone --single-branch --branch v2.12.0 git@github.com:git/git.git && cd git && git config remote.origin.tagOpt --no-tags && git tag -l | xargs git tag -d Now all this complexity becomes the much simpler: git clone --single-branch --no-tags git@github.com:git/git.git Or in the case of cloning a single tag "branch": git clone --single-branch --branch v2.12.0 --no-tags git@github.com:git/git.git Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-05-01i18n: remove i18n from tag reflog messageLibravatar Jean-Noel Avila1-6/+6
The building of the reflog message is using strbuf, which is not friendly with internationalization frameworks. No other reflog messages are translated right now and switching all the messages to i18n would require a major rework of the way the messages are built. Signed-off-by: Jean-Noel Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-28status: add color config slots for branch info in "--short --branch"Libravatar Stephen Kent1-0/+4
Add color config slots to be used in the status short-format when displaying local and remote tracking branch information. [jc: rebased on top of Peff's fix to 'git status' and tweaked the test to check both local and remote-tracking branch output] Signed-off-by: Stephen Kent <smkent@smkent.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-27am: shorten ident_split variable name in get_commit_info()Libravatar Jeff King1-11/+9
The local ident_split variable is often mentioned three times per line when dealing with its begin/end pointer pairs. Let's use a shorter name which lets us get rid of some long lines. Since this is a short self-contained function, readability doesn't suffer. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-27am: simplify allocations in get_commit_info()Libravatar Jeff King1-15/+10
After we call split_ident_line(), we have several begin/end pairs for various parts of the ident. We then copy each into a strbuf to create a single string, and then detach that string. We can instead skip the strbuf entirely and just duplicate the strings directly. This is shorter, and it makes it more obvious that we are not leaking the strbuf (we were not before, because every code path either died or hit a strbuf_detach). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-27am: fix commit buffer leak in get_commit_info()Libravatar Jeff King1-0/+1
Calling logmsg_reencode() may allocate a buffer for the commit message (because we need to load it from disk, or because it needs re-encoded). We must "unuse" it afterwards to free it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-27timestamp_t: a new data type for timestampsLibravatar Johannes Schindelin13-36/+36
Git's source code assumes that unsigned long is at least as precise as time_t. Which is incorrect, and causes a lot of problems, in particular where unsigned long is only 32-bit (notably on Windows, even in 64-bit versions). So let's just use a more appropriate data type instead. In preparation for this, we introduce the new `timestamp_t` data type. By necessity, this is a very, very large patch, as it has to replace all timestamps' data type in one go. As we will use a data type that is not necessarily identical to `time_t`, we need to be very careful to use `time_t` whenever we interact with the system functions, and `timestamp_t` everywhere else. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-26Merge branch 'nd/worktree-add-lock'Libravatar Junio C Hamano1-4/+11
Allow to lock a worktree immediately after it's created. This helps prevent a race between "git worktree add; git worktree lock" and "git worktree prune". * nd/worktree-add-lock: worktree add: add --lock option
2017-04-26Merge branch 'jk/war-on-git-path'Libravatar Junio C Hamano6-20/+17
While handy, "git_path()" is a dangerous function to use as a callsite that uses it safely one day can be broken by changes to other code that calls it. Reduction of its use continues. * jk/war-on-git-path: am: drop "dir" parameter from am_state_init replace strbuf_addstr(git_path()) with git_path_buf() replace xstrdup(git_path(...)) with git_pathdup(...) use git_path_* helper functions branch: add edit_description() helper bisect: add git_path_bisect_terms helper
2017-04-26Merge branch 'nd/conditional-config-in-early-config'Libravatar Junio C Hamano1-9/+12
The recently introduced conditional inclusion of configuration did not work well when early-config mechanism was involved. * nd/conditional-config-in-early-config: config: correct file reading order in read_early_config() config: handle conditional include when $GIT_DIR is not set up config: prepare to pass more info in git_config_with_options()
2017-04-26Merge branch 'gb/rebase-signoff'Libravatar Junio C Hamano1-21/+18
"git rebase" learns "--signoff" option. * gb/rebase-signoff: rebase: pass --[no-]signoff option to git am builtin/am: fold am_signoff() into am_append_signoff() builtin/am: honor --signoff also when --rebasing
2017-04-24submodule_init: die cleanly on submodules without url definedLibravatar Jeff King1-3/+3
When we init a submodule, we try to die when it has no URL defined: url = xstrdup(sub->url); if (!url) die(...); But that's clearly nonsense. xstrdup() will never return NULL, and if sub->url is NULL, we'll segfault. These two bits of code need to be flipped, so we check sub->url before looking at it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-23Merge branch 'dt/xgethostname-nul-termination'Libravatar Junio C Hamano2-6/+10
gethostname(2) may not NUL terminate the buffer if hostname does not fit; unfortunately there is no easy way to see if our buffer was too small, but at least this will make sure we will not end up using garbage past the end of the buffer. * dt/xgethostname-nul-termination: xgethostname: handle long hostnames use HOST_NAME_MAX to size buffers for gethostname(2)
2017-04-23Merge branch 'jk/ls-files-recurse-submodules-fix'Libravatar Junio C Hamano1-1/+8
"ls-files --recurse-submodules" did not quite work well in a project with nested submodules. * jk/ls-files-recurse-submodules-fix: ls-files: fix path used when recursing into submodules ls-files: fix recurse-submodules with nested submodules
2017-04-23Merge branch 'rs/misc-cppcheck-fixes'Libravatar Junio C Hamano1-2/+6
Various small fixes. * rs/misc-cppcheck-fixes: server-info: avoid calling fclose(3) twice in update_info_file() files_for_each_reflog_ent_reverse(): close stream and free strbuf on error am: close stream on error, but not stdin
2017-04-23Merge branch 'jk/snprintf-cleanups'Libravatar Junio C Hamano1-0/+1
Hotfix for a topic that is already in 'master'. * jk/snprintf-cleanups: replace: plug a memory leak
2017-04-23Merge branch 'jk/quarantine-received-objects'Libravatar Junio C Hamano1-1/+0
Add finishing touches to a recent topic. * jk/quarantine-received-objects: refs: reject ref updates while GIT_QUARANTINE_PATH is set receive-pack: document user-visible quarantine effects receive-pack: drop tmp_objdir_env from run_update_hook
2017-04-23Merge branch 'jh/verify-index-checksum-only-in-fsck'Libravatar Junio C Hamano1-0/+1
The index file has a trailing SHA-1 checksum to detect file corruption, and historically we checked it every time the index file is used. Omit the validation during normal use, and instead verify only in "git fsck". * jh/verify-index-checksum-only-in-fsck: read-cache: force_verify_index_checksum
2017-04-23Merge branch 'nd/conditional-config-include'Libravatar Junio C Hamano2-2/+2
$GIT_DIR may in some cases be normalized with all symlinks resolved while "gitdir" path expansion in the pattern does not receive the same treatment, leading to incorrect mismatch. This has been fixed. * nd/conditional-config-include: config: resolve symlinks in conditional include's patterns path.c: and an option to call real_path() in expand_user_path()
2017-04-23PRItime: introduce a new "printf format" for timestampsLibravatar Johannes Schindelin6-9/+9
Currently, Git's source code treats all timestamps as if they were unsigned longs. Therefore, it is okay to write "%lu" when printing them. There is a substantial problem with that, though: at least on Windows, time_t is *larger* than unsigned long, and hence we will want to switch away from the ill-specified `unsigned long` data type. So let's introduce the pseudo format "PRItime" (currently simply being defined to "lu") to make it easier to change the data type used for timestamps. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-23parse_timestamp(): specify explicitly where we parse timestampsLibravatar Johannes Schindelin2-3/+3
Currently, Git's source code represents all timestamps as `unsigned long`. In preparation for using a more appropriate data type, let's introduce a symbol `parse_timestamp` (currently being defined to `strtoul`) where appropriate, so that we can later easily switch to, say, use `strtoull()` instead. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-20am: drop "dir" parameter from am_state_initLibravatar Jeff King1-6/+4
The only caller of this function passes in a static buffer returned from git_path(). This looks dangerous at first glance, but turns out to be OK because the first thing we do is xstrdup() the result. Let's turn this into a git_pathdup(). That's slightly more efficient (no extra copy), and makes it easier to audit for dangerous git_path() invocations. Since there's only a single caller, let's just set this default path inside the init function. That makes the memory ownership clear. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-20replace strbuf_addstr(git_path()) with git_path_buf()Libravatar Jeff King1-4/+2
Writing directly into the strbuf avoids a useless copy of the data, and dropping calls to git_path() makes it easier to audit for dangerous calls. Note that git_path() does an implicit strbuf_reset(), but in each of these cases we were either already doing that reset, or writing into a fresh strbuf anyway. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-20replace xstrdup(git_path(...)) with git_pathdup(...)Libravatar Jeff King1-2/+3
It's more efficient to use git_pathdup(), as it skips an extra copy of the path. And by removing some calls to git_path(), it makes it easier to audit for dangerous uses. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>