aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* branch: use write_file_buf instead of write_fileJeff King2016-07-08
| | | | | | | | | | | | | If we already have a strbuf, then using write_file_buf is a little nicer to read (no wondering whether "%s" will eat your NULs), and it's more efficient (no extra formatting step). We don't care about the newline magic of write_file(), as we have our own multi-line content. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* use write_file_buf where applicableJeff King2016-07-08
| | | | | | | | | | There are several places where we open a file, write some content from a strbuf, and close it. These can be simplified with write_file_buf(). As a bonus, many of these did not catch write problems at close() time. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* write_file: add format attributeJeff King2016-07-08
| | | | | | | | | | | | | | | | | | | This gives us compile-time checking of our format strings, which is a good thing. I had also hoped it would help with confusing write_file() and write_file_buf(), since the former's "..." can make it match the signature of the latter. But given that the buffer for write_file_buf() is generally not a string literal, the compiler won't complain unless -Wformat-nonliteral is on, and that creates a ton of false positives elsewhere in the code base. While we're there, let's also give the function a docstring, which it never had. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* write_file: add pointer+len variantJeff King2016-07-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are many callsites which could use write_file, but for which it is a little awkward because they have a strbuf or other pointer/len combo. Specifically: 1. write_file() takes a format string, so we have to use "%s" or "%.*s", which are ugly. 2. Using any form of "%s" does not handle embedded NULs in the output. That probably doesn't matter for our call-sites, but it's nicer not to have to worry. 3. It's less efficient; we format into another strbuf just to do the write. That's probably not measurably slow for our uses, but it's simply inelegant. We can fix this by providing a helper to write out the formatted buffer, and just calling it from write_file(). Note that we don't do the usual "complete with a newline" that write_file does. If the caller has their own buffer, there's a reasonable chance they're doing something more complicated than a single line, and they can call strbuf_complete_line() themselves. We could go even further and add strbuf_write_file(), but it doesn't save much: - write_file_buf(path, sb.buf, sb.len); + strbuf_write_file(&sb, path); It would also be somewhat asymmetric with strbuf_read_file, which actually returns errors rather than dying (and the error handling is most of the benefit of write_file() in the first place). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* write_file: use xopenJeff King2016-07-08
| | | | | | | | | | | | This simplifies the code a tiny bit, and provides consistent error messages with other users of xopen(). While we're here, let's also switch to using O_WRONLY. We know we're only going to open/write/close the file, so there's no point in asking for O_RDWR. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* write_file: drop "gently" formJeff King2016-07-08
| | | | | | | | | | | | | | | There are no callers left of write_file_gently(). Let's drop it, as it doesn't seem likely for new callers to be added (since its inception, the only callers who wanted the gentle form generally just died immediately themselves, and have since been converted). While we're there, let's also drop the "int" return from write_file, as it is never meaningful (in the non-gentle form, we always either die or return 0). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* branch: use non-gentle write_file for branch descriptionJeff King2016-07-08
| | | | | | | | | | | | | | | | | | | We use write_file_gently() to do this job currently. However, if we see an error, we simply complain via error_errno() and then end up exiting with an error code. By switching to the non-gentle form, the function will die for us, with a better error. It is more specific about which syscall caused the error, and that mentions the actual filename we're trying to write. Our exit code for the error case does switch from "1" to "128", but that's OK; it wasn't a meaningful documented code (and in fact it was odd that it was a different exit code than most other error conditions). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* am: ignore return value of write_file()René Scharfe2016-07-08
| | | | | | | | | | | write_file() either returns 0 or dies, so there is no point in checking its return value. The callers of the wrappers write_state_text(), write_state_count() and write_state_bool() consequently already ignore their return values. Stop pretending we care and make them void. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* config: fix bogus fd check when setting up default configJeff King2016-07-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 9830534 (config --global --edit: create a template file if needed, 2014-07-25), an edit of the global config file will try to open() it with O_EXCL, and wants to handle three cases: 1. We succeeded; the user has no config file, and we should fill in the default template. 2. We got EEXIST; they have a file already, proceed as usual. 3. We got another error; we should complain. However, the check for case 1 does "if (fd)", which will generally _always_ be true (except for the oddball case that somehow our stdin got closed and opening really did give us a new descriptor 0). So in the EEXIST case, we tried to write the default config anyway! Fortunately, this turns out to be a noop, since we just end up writing to and closing "-1", which does nothing. But in case 3, we would fail to notice any other errors, and just silently continue (given that we don't actually notice write errors for the template either, it's probably not that big a deal; we're about to spawn the editor, so it would notice any problems. But the code is clearly _trying_ to hit cover this case and failing). We can fix it easily by using "fd >= 0" for case 1. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Git 2.9v2.9.0Junio C Hamano2016-06-13
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge tag 'l10n-2.9.0-rc0' of git://github.com/git-l10n/git-poJunio C Hamano2016-06-12
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | l10n-2.9.0-rc0 * tag 'l10n-2.9.0-rc0' of git://github.com/git-l10n/git-po: l10n: ko.po: Update Korean translation l10n: ru.po: update Russian translation l10n: de.po: translate 104 new messages l10n: zh_CN: review for git v2.9.0 l10n round 1 l10n: zh_CN: for git v2.9.0 l10n round 1 l10n: pt_PT: update Portuguese translation l10n: pt_PT: update according to git-gui glossary l10n: pt_PT: merge git.pot file l10n: Updated Bulgarian translation of git (2597t,0f,0u) l10n: sv.po: Update Swedish translation (2597t0f0u) l10n: fr.po v2.9.0rnd1 l10n: Updated Vietnamese translation (2597t) l10n: git.pot: v2.9.0 round 1 (104 new, 37 removed) l10n: fr.po Fixed grammar mistake
| * l10n: ko.po: Update Korean translationChangwoo Ryu2016-06-12
| |
| * Merge branch 'russian-l10n' of https://github.com/DJm00n/git-po-ruJiang Xin2016-06-11
| |\ | | | | | | | | | | | | * 'russian-l10n' of https://github.com/DJm00n/git-po-ru: l10n: ru.po: update Russian translation
| | * l10n: ru.po: update Russian translationDimitriy Ryazantcev2016-06-11
| | | | | | | | | | | | Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
| * | l10n: de.po: translate 104 new messagesRalf Thielow2016-06-10
| |/ | | | | | | | | | | | | Translate 104 new messages came from git.pot update in f517e50 (l10n: git.pot: v2.9.0 round 1 (104 new, 37 removed)). Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
| * l10n: zh_CN: review for git v2.9.0 l10n round 1Ray Chen2016-06-09
| | | | | | | | | | Signed-off-by: Ray Chen <oldsharp@gmail.com> Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
| * l10n: zh_CN: for git v2.9.0 l10n round 1Jiang Xin2016-06-06
| | | | | | | | | | | | Update 104 new translations (2596t1f0u) for git v2.9.0-rc0. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
| * l10n: pt_PT: update Portuguese translationVasco Almeida2016-05-31
| | | | | | | | Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
| * l10n: pt_PT: update according to git-gui glossaryVasco Almeida2016-05-31
| | | | | | | | Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
| * l10n: pt_PT: merge git.pot fileVasco Almeida2016-05-31
| | | | | | | | Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
| * l10n: Updated Bulgarian translation of git (2597t,0f,0u)Alexander Shopov2016-05-29
| | | | | | | | Signed-off-by: Alexander Shopov <ash@kambanaria.org>
| * Merge branch 'v2.9.0_rnd1_fr' of git://github.com/jnavila/gitJiang Xin2016-05-29
| |\ | | | | | | | | | | | | * 'v2.9.0_rnd1_fr' of git://github.com/jnavila/git: l10n: fr.po v2.9.0rnd1
| | * l10n: fr.po v2.9.0rnd1Jean-Noel Avila2016-05-26
| | | | | | | | | | | | Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
| * | l10n: sv.po: Update Swedish translation (2597t0f0u)Peter Krefting2016-05-27
| |/ | | | | | | Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
| * Merge branch 'fix_fr' of git://github.com/jnavila/gitJiang Xin2016-05-26
| |\ | | | | | | | | | | | | * 'fix_fr' of git://github.com/jnavila/git: l10n: fr.po Fixed grammar mistake
| | * l10n: fr.po Fixed grammar mistakeAntonin2016-04-28
| | | | | | | | | | | | | | | | | | "tous le dépôts distants" -> "tous les dépôts distants" Signed-off-by: Antonin <antonin@delpeuch.eu>
| * | l10n: Updated Vietnamese translation (2597t)Tran Ngoc Quan2016-05-25
| | | | | | | | | | | | Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
| * | l10n: git.pot: v2.9.0 round 1 (104 new, 37 removed)Jiang Xin2016-05-24
| | | | | | | | | | | | | | | | | | Generate po/git.pot from v2.9.0-rc0 for git v2.9.0 l10n round 1. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
* | | Hopefully the final last-minute update before 2.9 finalJunio C Hamano2016-06-10
| | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'jk/diff-compact-heuristic'Junio C Hamano2016-06-10
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that the earlier effort to update the heuristics may want to use a bit more time to mature. Turn it off by default. * jk/diff-compact-heuristic: diff: disable compaction heuristic for now
| * | | diff: disable compaction heuristic for nowJunio C Hamano2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | http://lkml.kernel.org/g/20160610075043.GA13411@sigill.intra.peff.net reports that a change to add a new "function" with common ending with the existing one at the end of the file is shown like this: def foo do_foo_stuff() + common_ending() +end + +def bar + do_bar_stuff() + common_ending() end when the new heuristic is in use. In reality, the change is to add the blank line before "def bar" and everything below, which is what the code without the new heuristic shows. Disable the heuristics by default, and resurrect the documentation for the option and the configuration variables, while clearly marking the feature as still experimental. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'jk/shell-portability'Junio C Hamano2016-06-10
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test fixes. * jk/shell-portability: t5500 & t7403: lose bash-ism "local" test-lib: add in-shell "env" replacement
| * | | | t5500 & t7403: lose bash-ism "local"Junio C Hamano2016-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In t5500::check_prot_host_port_path(), diagport is not a variable used elsewhere and the function is not recursively called so this can simply lose the "local", which may not be supported by shell (besides, the function liberally clobbers other variables without making them "local"). t7403::reset_submodule_urls() overrides the "root" variable used in the test framework for no good reason; its use is not about temporarily relocating where the test repositories are created. This assignment can be made not to clobber the variable by moving them into the subshells it already uses. Its value is always $TRASH_DIRECTORY, so we could use it instead there, and this function that is called only once and its two subshells may not be necessary (instead, the caller can use "git -C $there config" and set a value that is derived from $TRASH_DIRECTORY), but this is a minimum fix that is needed to lose "local". Helped-by: John Keeping <john@keeping.me.uk> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | test-lib: add in-shell "env" replacementJeff King2016-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The one-shot environment variable syntax: FOO=BAR some-program is unportable when some-program is actually a shell function, like test_must_fail (on some shells FOO remains set after the function returns, and on others it does not). We sometimes get around this by using env, like: test_must_fail env FOO=BAR some-program But that only works because test_must_fail's arguments are themselves a command which can be run. You can't run: env FOO=BAR test_must_fail some-program because env does not know about our shell functions. So there is no equivalent for test_commit, for example, and one must resort to: ( FOO=BAR export FOO test_commit ) which is a bit verbose. Let's add a version of "env" that works _inside_ the shell, by creating a subshell, exporting variables from its argument list, and running the command. Its use is demonstrated on a currently-unportable case in t4014. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | Merge branch 'jc/t2300-setup'Junio C Hamano2016-06-10
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A test fix. * jc/t2300-setup: t2300: run git-sh-setup in an environment that better mimics the real life
| * | | | | t2300: run git-sh-setup in an environment that better mimics the real lifeJunio C Hamano2016-06-01
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we run scripted Porcelains, "git" potty has set up the $PATH by prepending $GIT_EXEC_PATH, the path given by "git --exec-path=$there $cmd", etc. already. Because of this, scripted Porcelains can dot-source shell script library like git-sh-setup with simple dot without specifying any path. t2300 however dot-sources git-sh-setup without adjusting $PATH like the real "git" potty does. This has not been a problem so far, but once git-sh-setup wants to rely on the $PATH adjustment, just like any scripted Porcelains already do, it would become one. It cannot for example dot-source another shell library without specifying the full path to it by prefixing $(git --exec-path). Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | Git 2.9-rc2v2.9.0-rc2Junio C Hamano2016-06-06
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | Sync with 2.8.4Junio C Hamano2016-06-06
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | * maint: Git 2.8.4
| * | | | | Git 2.8.4v2.8.4Junio C Hamano2016-06-06
| | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | Merge branch 'kb/msys2-tty' into maintJunio C Hamano2016-06-06
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "are we talking with TTY, doing an interactive session?" detection has been updated to work better for "Git for Windows". * kb/msys2-tty: mingw: make isatty() recognize MSYS2's pseudo terminals (/dev/pty*)
| * \ \ \ \ \ Merge branch 'da/difftool' into maintJunio C Hamano2016-06-06
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "git difftool" learned to handle unmerged paths correctly in dir-diff mode. * da/difftool: difftool: handle unmerged files in dir-diff mode difftool: initialize variables for readability
| * \ \ \ \ \ \ Merge branch 'tb/core-eol-fix' into maintJunio C Hamano2016-06-06
| |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A couple of bugs around core.autocrlf have been fixed. * tb/core-eol-fix: convert.c: ident + core.autocrlf didn't work t0027: test cases for combined attributes convert: allow core.autocrlf=input and core.eol=crlf t0027: make commit_chk_wrnNNO() reliable
| * \ \ \ \ \ \ \ Merge branch 'ar/diff-args-osx-precompose' into maintJunio C Hamano2016-06-06
| |\ \ \ \ \ \ \ \ | | |_|_|_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many commands normalize command line arguments from NFD to NFC variant of UTF-8 on OSX, but commands in the "diff" family did not, causing "git diff $path" to complain that no such path is known to Git. They have been taught to do the normalization. * ar/diff-args-osx-precompose: diff: run arguments through precompose_argv
* | | | | | | | | Merge branch 'sb/submodule-helper-relative-path'Junio C Hamano2016-06-06
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A bash-ism "local" has been removed from "git submodule" scripted Porcelain. * sb/submodule-helper-relative-path: submodule: remove bashism from shell script
| * | | | | | | | | submodule: remove bashism from shell scriptStefan Beller2016-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Junio pointed out `relative_path` was using bashisms via the local variables. As the longer term goal is to rewrite most of the submodule code in C, do it now. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | | | | | Merge branch 'sb/submodule-helper-list-signal-unmatch-via-exit-status'Junio C Hamano2016-06-06
|\ \ \ \ \ \ \ \ \ \ | |/ / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way how "submodule--helper list" signals unmatch error to its callers has been updated. * sb/submodule-helper-list-signal-unmatch-via-exit-status: submodule--helper: offer a consistent API
| * | | | | | | | | submodule--helper: offer a consistent APIStefan Beller2016-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 48308681 (2016-02-29, git submodule update: have a dedicated helper for cloning), the helper communicated errors back only via exit code, and dance with printing '#unmatched' in case of error was left to git-submodule.sh as it uses the output of the helper and pipes it into shell commands. This change makes the helper consistent by never printing '#unmatched' in the helper but always handling these piping issues in the actual shell script. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | | | | | Almost ready for 2.9-rc2Junio C Hamano2016-06-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | | | | | Merge branch 'rs/apply-name-terminate'Junio C Hamano2016-06-03
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code clean-up. * rs/apply-name-terminate: apply: remove unused parameters from name_terminate()
| * | | | | | | | | | apply: remove unused parameters from name_terminate()René Scharfe2016-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>