summaryrefslogtreecommitdiff
path: root/builtin
AgeCommit message (Collapse)AuthorFilesLines
2015-04-20Merge branch 'ps/grep-help-all-callback-arg'Libravatar Junio C Hamano1-1/+1
Code clean-up. * ps/grep-help-all-callback-arg: grep: correctly initialize help-all option
2015-04-16Revert "merge: pass verbosity flag down to merge-recursive"Libravatar Junio C Hamano1-4/+0
This reverts commit 2bf15a3330a26183adc8563dbeeacc11294b8a01, whose intention was good, but the verbosity levels used in merge-recursive turns out to be rather uneven. For example, a merge of two branches with conflicting submodule updates used to report CONFLICT: output with --quiet but no longer (which *is* desired), while the final "Automatic merge failed; fix conflicts and then commit" message is still shown even with --quiet (which *is* inconsistent). Originally reported by Bryan Turner; it is too early to declare what the concensus is, but it seems that we would need to level the verbosity levels used in merge strategy backends before we can go forward. In the meantime, we'd revert to the old behaviour until that happens. cf. $gmane/267245
2015-04-14Merge branch 'jk/merge-quiet'Libravatar Junio C Hamano1-0/+4
"git merge --quiet" did not squelch messages from the underlying merge-recursive strategy. * jk/merge-quiet: merge: pass verbosity flag down to merge-recursive
2015-04-14Merge branch 'jc/update-instead-into-void'Libravatar Junio C Hamano1-1/+20
A push into an unborn branch, with "receive.denyCurrentBranch" set to "updateInstead", did not check out the working tree as expected. * jc/update-instead-into-void: push-to-deploy: allow pushing into an unborn branch and updating it
2015-04-12grep: correctly initialize help-all optionLibravatar Patrick Steinhardt1-1/+1
The "help-all" option is being initialized with a wrong value. While being semantically wrong this can also cause a segmentation fault in gcc on ARMv7 hardfloat platforms with a hardened toolchain. Fix this by initializing with a NULL value. Signed-off-by: Patrick Steinhardt <ps@pks.im> Reviewed-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-02merge: pass verbosity flag down to merge-recursiveLibravatar Jeff King1-0/+4
This makes "git merge --quiet" really quiet when we call into merge-recursive. Note that we can't just pass our flag down as-is; the two parts of the code use different scales. We center at "0" as normal for git-merge (with "--quiet" giving a negative value), but merge-recursive uses "2" as its center. This patch passes a negative value to merge-recursive rather than "1", though, as otherwise the user would have to use "-qqq" to squelch all messages (but the downside is that the user cannot distinguish between levels 0-2 if without resorting to the GIT_MERGE_VERBOSITY variable). We may want to review and renormalize the message severities in merge-recursive, but that does not have to happen now. This is at least in improvement in the sense that we are respecting "--quiet" at all. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-01push-to-deploy: allow pushing into an unborn branch and updating itLibravatar Junio C Hamano1-1/+20
Setting receive.denycurrentbranch to updateinstead and pushing into the current branch, when the working tree and the index is truly clean, is supposed to reset the working tree and the index to match the tree of the pushed commit. This did not work when pushing into an unborn branch. The code that drives push-to-checkout hook needs no change, as the interface is defined so that hook can decide what to do when the push is coming to an unborn branch and take an appropriate action since the beginning. Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-27Merge branch 'sb/leaks'Libravatar Junio C Hamano3-3/+8
* sb/leaks: http: release the memory of a http pack request as well read-cache: fix memleak add_to_index(): free unused cache-entry commit.c: fix a memory leak http-push: remove unneeded cleanup merge-recursive: fix memleaks merge-blobs.c: fix a memleak builtin/apply.c: fix a memleak update-index: fix a memleak read-cache: free cache entry in add_to_index in case of early return
2015-03-26Merge branch 'jc/report-path-error-to-dir'Libravatar Junio C Hamano1-43/+0
Code clean-up. * jc/report-path-error-to-dir: report_path_error(): move to dir.c
2015-03-25Merge branch 'jk/prune-with-corrupt-refs'Libravatar Junio C Hamano2-2/+7
"git prune" used to largely ignore broken refs when deciding which objects are still being used, which could spread an existing small damage and make it a larger one. * jk/prune-with-corrupt-refs: refs.c: drop curate_packed_refs repack: turn on "ref paranoia" when doing a destructive repack prune: turn on ref_paranoia flag refs: introduce a "ref paranoia" flag t5312: test object deletion code paths in a corrupted repository
2015-03-25Merge branch 'jk/cleanup-failed-clone'Libravatar Junio C Hamano1-5/+6
An failure early in the "git clone" that started creating the working tree and repository could have resulted in some directories and files left without getting cleaned up. * jk/cleanup-failed-clone: clone: drop period from end of die_errno message clone: initialize atexit cleanup handler earlier
2015-03-25Merge branch 'ws/grep-quiet-no-pager'Libravatar Junio C Hamano1-1/+1
Even though "git grep --quiet" is run merely to ask for the exit status, we spawned the pager regardless. Stop doing that. * ws/grep-quiet-no-pager: grep: fix "--quiet" overwriting current output
2015-03-24report_path_error(): move to dir.cLibravatar Junio C Hamano1-43/+0
The expected call sequence is for the caller to use match_pathspec() repeatedly on a set of pathspecs, accumulating the "hits" in a separate array, and then call this function to diagnose a pathspec that never matched anything, as that can indicate a typo from the command line, e.g. "git commit Maekfile". Many builtin commands use this function from builtin/ls-files.c, which is not a very healthy arrangement. ls-files might have been the first command to feel the need for such a helper, but the need is shared by everybody who uses the "match and then report" pattern. Move it to dir.c where match_pathspec() is defined. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-23Merge branch 'jk/push-config'Libravatar Junio C Hamano1-8/+13
Restructure "git push" codepath to make it easier to add new configuration bits and then add push.followTags configuration that turns --follow-tags option on by default. * jk/push-config: push: allow --follow-tags to be set by config push.followTags cmd_push: pass "flags" pointer to config callback cmd_push: set "atomic" bit directly git_push_config: drop cargo-culted wt_status pointer
2015-03-23Merge branch 'jk/tag-h-column-is-a-listing-option'Libravatar Junio C Hamano1-2/+2
"git tag -h" used to show the "--column" and "--sort" options that are about listing in a wrong section. * jk/tag-h-column-is-a-listing-option: tag: fix some mis-organized options in "-h" listing
2015-03-23commit.c: fix a memory leakLibravatar Stefan Beller1-2/+4
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-23builtin/apply.c: fix a memleakLibravatar Stefan Beller1-1/+3
oldlines is allocated earlier in the function and also freed on the successful code path. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-22update-index: fix a memleakLibravatar Stefan Beller1-0/+1
`old` is not used outside the loop and would get lost once we reach the goto. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-20Merge branch 'sb/leaks'Libravatar Junio C Hamano1-1/+2
Code cleanup. * sb/leaks: builtin/help.c: fix memory leak bundle.c: fix memory leak connect.c: do not leak "conn" after showing diagnosis
2015-03-20Merge branch 'km/bsd-shells'Libravatar Junio C Hamano1-1/+1
Portability fixes and workarounds for shell scripts have been added to help BSD-derived systems. * km/bsd-shells: t5528: do not fail with FreeBSD shell help.c: use SHELL_PATH instead of hard-coded "/bin/sh" git-compat-util.h: move SHELL_PATH default into header git-instaweb: use @SHELL_PATH@ instead of /bin/sh git-instaweb: allow running in a working tree subdirectory
2015-03-20Merge branch 'mg/detached-head-report'Libravatar Junio C Hamano1-3/+10
"git branch" on a detached HEAD always said "(detached from xyz)", even when "git status" would report "detached at xyz". The HEAD is actually at xyz and haven't been moved since it was detached in such a case, but the user cannot read what the current value of HEAD is when "detached from" is used. * mg/detached-head-report: branch: name detached HEAD analogous to status wt-status: refactor detached HEAD analysis
2015-03-20repack: turn on "ref paranoia" when doing a destructive repackLibravatar Jeff King1-2/+6
If we are repacking with "-ad", we will drop any unreachable objects. Likewise, using "-Ad --unpack-unreachable=<time>" will drop any old, unreachable objects. In these cases, we want to make sure the reachability we compute with "--all" is complete. We can do this by passing GIT_REF_PARANOIA=1 in the environment to pack-objects. Note that "-Ad" is safe already, because it only loosens unreachable objects. It is up to "git prune" to avoid deleting them. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-20prune: turn on ref_paranoia flagLibravatar Jeff King1-0/+1
Prune should know about broken objects at the tips of refs, so that we can feed them to our traversal rather than ignoring them. It's better for us to abort the operation on the broken object than it is to start deleting objects with an incomplete view of the reachability namespace. Note that for missing objects, aborting is the best we can do. For a badly-named ref, we technically could use its sha1 as a reachability tip. However, the iteration code just feeds us a null sha1, so there would be a reasonable amount of code involved to pass down our wishes. It's not really worth trying to do better, because this is a case that should happen extremely rarely, and the message we provide: fatal: unable to parse object: refs/heads/bogus:name is probably enough to point the user in the right direction. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-19clone: drop period from end of die_errno messageLibravatar Jeff King1-1/+1
We do not usually end our errors with a full stop, but it looks especially bad when you use die_errno, which adds a colon, like: fatal: could not create work tree dir 'foo'.: No such file or directory Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-19clone: initialize atexit cleanup handler earlierLibravatar Jeff King1-4/+5
If clone fails, we generally try to clean up any directories we've created. We do this by installing an atexit handler, so that we don't have to manually trigger cleanup. However, since we install this after touching the filesystem, any errors between our initial mkdir() and our atexit() call will result in us leaving a crufty directory around. We can fix this by moving our atexit() call earlier. It's OK to do it before the junk_work_tree variable is set, because remove_junk makes sure the variable is initialized. This means we "activate" the handler by assigning to the junk_work_tree variable, which we now bump down to just after we call mkdir(). We probably do not want to do it before, because a plausible reason for mkdir() to fail is EEXIST (i.e., we are racing with another "git init"), and we would not want to remove their work. OTOH, this is probably not that big a deal; we will allow cloning into an empty directory (and skip the mkdir), which is already racy (i.e., one clone may see the other's empty dir and start writing into it). Still, it does not hurt to err on the side of caution here. Note that writing into junk_work_tree and junk_git_dir after installing the handler is also technically racy, as we call our handler on an async signal. Depending on the platform, we could see a sheared write to the variables. Traditionally we have not worried about this, and indeed we already do this later in the function. If we want to address that, it can come as a separate topic. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-19grep: fix "--quiet" overwriting current outputLibravatar Wilhelm Schuermann1-1/+1
When grep is called with the --quiet option, the pager is initialized despite not being used. When the pager is "less", anything output by previous commands and not ended with a newline is overwritten: $ echo -n aaa; echo bbb aaabbb $ echo -n aaa; git grep -q foo; echo bbb bbb This can be worked around, for example, by making sure STDOUT is not a TTY or more directly by setting git's pager to "cat": $ echo -n aaa; git grep -q foo > /dev/null; echo bbb aaabbb $ echo -n aaa; PAGER=cat git grep -q foo; echo bbb aaabbb But prevent calling the pager in the first place, which would also save an unnecessary fork(). Signed-off-by: Wilhelm Schuermann <wimschuermann@googlemail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-17Merge branch 'rs/deflate-init-cleanup'Libravatar Junio C Hamano2-3/+0
Code simplification. * rs/deflate-init-cleanup: zlib: initialize git_zstream in git_deflate_init{,_gzip,_raw}
2015-03-14push: allow --follow-tags to be set by config push.followTagsLibravatar Dave Olszewski1-0/+10
Signed-off-by: Dave Olszewski <cxreg@pobox.com> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-13Merge branch 'nd/grep-exclude-standard-help-fix' into maintLibravatar Junio C Hamano1-1/+1
Description given by "grep -h" for its --exclude-standard option was phrased poorly. * nd/grep-exclude-standard-help-fix: grep: correct help string for --exclude-standard
2015-03-13Merge branch 'jc/apply-beyond-symlink' into maintLibravatar Junio C Hamano1-1/+141
"git apply" was not very careful about reading from, removing, updating and creating paths outside the working tree (under --index/--cached) or the current directory (when used as a replacement for GNU patch). * jc/apply-beyond-symlink: apply: do not touch a file beyond a symbolic link apply: do not read from beyond a symbolic link apply: do not read from the filesystem under --index apply: reject input that touches outside the working area
2015-03-12tag: fix some mis-organized options in "-h" listingLibravatar Jeff King1-2/+2
Running "git tag -h" currently prints: [...] Tag creation options [...] --column[=<style>] show tag list in columns --sort <type> sort tags Tag listing options --contains <commit> print only tags that contain the commit --points-at <object> print only tags of the object The "--column" and "--sort" options should go under the "Tag listing" group. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-10builtin/help.c: fix memory leakLibravatar Stefan Beller1-1/+2
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-10help.c: use SHELL_PATH instead of hard-coded "/bin/sh"Libravatar Kyle J. McKay1-1/+1
If the user has set SHELL_PATH in the Makefile then we should respect that value and use it. Signed-off-by: Kyle J. McKay <mackyle@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-10Merge branch 'mh/expire-updateref-fixes'Libravatar Junio C Hamano1-6/+3
Various issues around "reflog expire", e.g. using --updateref when expiring a reflog for a symbolic reference, have been corrected and/or made saner. * mh/expire-updateref-fixes: reflog_expire(): never update a reference to null_sha1 reflog_expire(): ignore --updateref for symbolic references reflog: improve and update documentation struct ref_lock: delete the force_write member lock_ref_sha1_basic(): do not set force_write for missing references write_ref_sha1(): move write elision test to callers write_ref_sha1(): remove check for lock == NULL
2015-03-06Merge branch 'ja/clean-confirm-i18n'Libravatar Junio C Hamano1-1/+2
The prompt string "remove?" used when "git clean -i" asks the user if a path should be removed was localizable, but the code always expects a substring of "yes" to tell it to go ahead. Always show [y/N] as part of this prompt to hint that the answer is not (yet) localized. * ja/clean-confirm-i18n: Add hint interactive cleaning
2015-03-06Merge branch 'nd/grep-exclude-standard-help-fix'Libravatar Junio C Hamano1-1/+1
Description given by "grep -h" for its --exclude-standard option was phrased poorly. * nd/grep-exclude-standard-help-fix: grep: correct help string for --exclude-standard
2015-03-06Merge branch 'rs/simple-cleanups' into maintLibravatar Junio C Hamano1-4/+3
Code cleanups. * rs/simple-cleanups: sha1_name: use strlcpy() to copy strings pretty: use starts_with() to check for a prefix for-each-ref: use skip_prefix() to avoid duplicate string comparison connect: use strcmp() for string comparison
2015-03-06branch: name detached HEAD analogous to statusLibravatar Michael J Gruber1-3/+10
"git status" carefully names a detached HEAD "at" resp. "from" a rev or ref depending on whether the detached HEAD has moved since. "git branch" always uses "from", which can be confusing, because a status-aware user would interpret this as moved detached HEAD. Make "git branch" use the same logic and wording. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-05zlib: initialize git_zstream in git_deflate_init{,_gzip,_raw}Libravatar René Scharfe2-3/+0
Clear the git_zstream variable at the start of git_deflate_init() etc. so that callers don't have to do that. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-05Merge branch 'es/blame-commit-info-fix' into maintLibravatar Junio C Hamano1-3/+2
"git blame" died, trying to free an uninitialized piece of memory. * es/blame-commit-info-fix: builtin/blame: destroy initialized commit_info only
2015-03-05Merge branch 'ab/merge-file-prefix' into maintLibravatar Junio C Hamano1-1/+2
"git merge-file" did not work correctly in a subdirectory. * ab/merge-file-prefix: merge-file: correctly open files when in a subdir
2015-03-05Merge branch 'dp/remove-duplicated-header-inclusion' into maintLibravatar Junio C Hamano1-1/+0
Code clean-up. * dp/remove-duplicated-header-inclusion: do not include the same header twice
2015-03-05Merge branch 'rs/simple-cleanups'Libravatar Junio C Hamano1-4/+3
Code cleanups. * rs/simple-cleanups: sha1_name: use strlcpy() to copy strings pretty: use starts_with() to check for a prefix for-each-ref: use skip_prefix() to avoid duplicate string comparison connect: use strcmp() for string comparison
2015-03-05Merge branch 'mh/refs-have-new'Libravatar Junio C Hamano6-19/+20
Simplify the ref transaction API around how "the ref should be pointing at this object" is specified. * mh/refs-have-new: refs.h: remove duplication in function docstrings update_ref(): improve documentation ref_transaction_verify(): new function to check a reference's value ref_transaction_delete(): check that old_sha1 is not null_sha1 ref_transaction_create(): check that new_sha1 is valid commit: avoid race when creating orphan commits commit: add tests of commit races ref_transaction_delete(): remove "have_old" parameter ref_transaction_update(): remove "have_old" parameter struct ref_update: move "have_old" into "flags" refs.c: change some "flags" to "unsigned int" refs: remove the gap in the REF_* constant values refs: move REF_DELETING to refs.c
2015-03-05reflog: improve and update documentationLibravatar Michael Haggerty1-6/+3
Revamp the "git reflog" usage documentation in the manpage and the command help to match the current reality and improve its clarity: * Add documentation for some options that had been left out. * Group the subcommands and options more logically and move more common subcommands/options higher. * Improve some explanations. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-03Merge branch 'jc/apply-ws-fix-expands-report'Libravatar Junio C Hamano1-0/+3
"git apply --whitespace=fix" fixed whitespace errors in the common context lines but did so without reporting. * jc/apply-ws-fix-expands-report: apply: detect and mark whitespace errors in context lines when fixing
2015-03-03Merge branch 'jc/apply-beyond-symlink'Libravatar Junio C Hamano1-1/+141
"git apply" was not very careful about reading from, removing, updating and creating paths outside the working tree (under --index/--cached) or the current directory (when used as a replacement for GNU patch). * jc/apply-beyond-symlink: apply: do not touch a file beyond a symbolic link apply: do not read from beyond a symbolic link apply: do not read from the filesystem under --index apply: reject input that touches outside the working area
2015-03-02Add hint interactive cleaningLibravatar Jean-Noel Avila1-1/+2
For translators, specify that a [y/N] reply is needed. Also capitalize the first word in the prompt, as all the other interactive prompts from this command are capitalized. Signed-off-by: Jean-Noel Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-02-27grep: correct help string for --exclude-standardLibravatar Nguyễn Thái Ngọc Duy1-1/+1
The current help string is about --no-exclude-standard. But "git grep -h" would show --exclude-standard instead. Flip the string. See 0a93fb8 (grep: teach --untracked and --exclude-standard options - 2011-09-27) for more info about these options. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-02-25Merge branch 'dp/remove-duplicated-header-inclusion'Libravatar Junio C Hamano1-1/+0
Code clean-up. * dp/remove-duplicated-header-inclusion: do not include the same header twice