Feature request: Add word wrapping to gitk display
Hi, when working on text files with long lines, "word diff" can produce appropriate diff display. However, the long lines cannot be viewed very well in gitk (requires excessive scrolling). I found out that it is quite easy to achieve this index 805a1c7..5ba7472 100755 --- a/gitk +++ b/gitk @@ -2404,7 +2404,7 @@ proc makewindow {} { set ctext .bleft.bottom.ctext text $ctext -background $bgcolor -foreground $fgcolor \ -state disabled -font textfont \ - -yscrollcommand scrolltext -wrap none \ + -yscrollcommand scrolltext -wrap word \ -xscrollcommand ".bleft.bottom.sbhorizontal set" if {$have_tk85} { $ctext conf -tabstyle wordprocessor however I'm not otherwise knowledgeable about Tk to make this a properly configurable switch. I think it would be a very nice addition to have, a check box next to "Line diff/ color words" that says "Wrap words in display". Thanks, Nei -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git-fixup: automatically create a fixup commit
Sometimes I get a broken patch, apply it and then need to fix it up. git commit --fixup is perfect for this, but makes me look up the commit that created the breakage manually. git-fixup is a tool to speed this up. Several heuristics would be reasonable for locating the problematic commit: 1. look up the last commit that touched the file(s) affected by the fixup 2. look up the last commit that touched the line(s) affected by the fixup this implements the first heuristic. Signed-off-by: Michael S. Tsirkin --- contrib/git-fixup | 8 1 file changed, 8 insertions(+) create mode 100755 contrib/git-fixup diff --git a/contrib/git-fixup b/contrib/git-fixup new file mode 100755 index 000..79f4e34 --- /dev/null +++ b/contrib/git-fixup @@ -0,0 +1,8 @@ +if + git diff --cached --quiet +then + echo "Nothing to commit!" + exit 1 +else + git commit --fixup=$(git log --pretty=format:%H -1 $(git diff --cached --name-only)) "$@" +fi -- MST -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] connect: remove get_port()
On 2016-05-01 08.02, Mike Hommey wrote: > get_port() is only used as a fallback when get_host_and_port() does not > return a port. But get_port() does the same search as > get_host_and_port(), except get_host_and_port() starts from the end of > the host, respecting square brackets for ipv6 addresses, and get_port(), > operating after get_host_and_port(), works on a modified host string > that has square brackes removed if there were any. typo: brackets. > > I cannot think of any legal host:port string that would not have a port > returned by get_host_and_port() *and* have one returned by get_port(). > So just remove get_port(). > > Signed-off-by: Mike Hommey Does this pass the test-suite ? It doesn't pass here, t5601: not ok 39 - bracketed hostnames are still ssh # # git clone "[myhost:123]:src" ssh-bracket-clone && # expect_ssh "-p 123" myhost src # not ok 40 - uplink is not treated as putty # # copy_ssh_wrapper_as "$TRASH_DIRECTORY/uplink" && # git clone "[myhost:123]:src" ssh-bracket-clone-uplink && # expect_ssh "-p 123" myhost src # not ok 41 - plink is treated specially (as putty) # # copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" && # git clone "[myhost:123]:src" ssh-bracket-clone-plink-0 && # expect_ssh "-P 123" myhost src # not ok 42 - plink.exe is treated specially (as putty) # # copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" && # git clone "[myhost:123]:src" ssh-bracket-clone-plink-1 && # expect_ssh "-P 123" myhost src # not ok 43 - tortoiseplink is like putty, with extra arguments -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[ubuntu] gitk/git gui fail after upgrade
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 hi all, asking the experts: after upgrading one of my machines to git, gitk and git gui fail to start ... * git gui fails with "cannot determine git version" * gitk fails with "cannot find a git repository here" other git commands work fine. issue happens with git-2.7.4 and 2.8.2. though it only happens on one of my linux machines, while the other works like charm. any idea what could cause this? apparently i'm not alone with this issue [1] tia, tim [1] https://bugs.launchpad.net/ubuntu/+source/git/+bug/1574213 -BEGIN PGP SIGNATURE- Version: GnuPG v2 iQIcBAEBCAAGBQJXJdbiAAoJEAIkvWiom07D8/QP/iy9/IZaBRorwkO85bIOsrYx p2e5t0eTUJiAt3j2DLufviZnphlIFDqVQMqEM9V5lnif0/gGEjGC1cGeUNeXb0x8 vg6PP0THgZfg5ptCt9mPwrae16W3yaAR1rOjgLv8YBmtmN8M3eslTcGC0/TEH0qN gsIyREcK2FhV/KhQvPIIIfTjXlrLgBs4Xwc9AJ8nTfCX5T5tWBmnSO+hfTcEtFve pFdZPcLqNuVDlovs/EbOQo+ylkXqrMrnYLEUd79QcaDgXF99Wh0say+sVYC0+lXA OM+uIpmV5D7X/s6rxLARli3Qj30LRDe51ERmAUWrQkOztgliRX/g4cATtl/PxXtI oCQR2QE+lzdwW8wRl6RUhLMdbuw00/Os8hvJmHtqcF7YJuNRCfnhDLPy7C2tmkGT L9oHjolCNr8VXp+Uo/wcB7OWYmECwoMaM8Vd022KIJYZe4hvO4PvWXztJarTWMpu Qxjn9rK2x5hKHijJvXsbmIob69jUHptCwmZPoTktfTCTvWSk3M7BuagxT2OdzvPq LTMKak7WnUm+Gi1v7tN0hLn49algds43JHzWhUWwrlIbP4/GUHcNKZ1bBWTiapTI fSrzvs48vWQ7uI43eZv/vAIj7EmRprnJbsWLdaKWKPELjGMbSoGWTY+VStAZm3Vz ZU3jXMTZMCF1sJUnzjAT =5Oo6 -END PGP SIGNATURE- -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
pthread_sigmask() on windows (wine actualy)
I got this while compiling master today using mingw32 cross toolchain CC run-command.o run-command.c: In function 'run_thread': run-command.c:596:3: warning: implicit declaration of function 'pthread_sigmask' [-Wimplicit-function-declaration] run-command.c:596:23: error: 'SIG_BLOCK' undeclared (first use in this function) run-command.c:596:23: note: each undeclared identifier is reported only once for each function it appears in This is added in c792d7b (run-command: teach async threads to ignore SIGPIPE - 2016-04-19). From the look of it, wrapping #ifndef GIT_WINDOWS_NATIVE is probably enough? I checked gfw/master too to see how gfw deals with it, but the commit has not been merged there yet. -- Duy -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 00/41] Add and use error_errno() and warning_errno()
This is a spinoff from my worktree-move topic. This series adds die_errno() companions, error_errno() and warning_errno(), and use them where applicable to reduce the amount of typing (in future). Changes are split by file (which explains the huge number of patches). I leave builtin/apply.c and refs/files-backend.c untouched because they are currently hot zones. Nguyễn Thái Ngọc Duy (41): usage.c: move format processing out of die_errno() usage.c: add warning_errno() and error_errno() bisect.c: use die_errno() and warning_errno() builtin/am.c: use error_errno() builtin/branch.c: use error_errno() builtin/fetch.c: use error_errno() builtin/help.c: use warning_errno() builtin/mailsplit.c: use error_errno() builtin/merge-file.c: use error_errno() builtin/pack-objects.c: use die_errno() and warning_errno() builtin/rm.c: use warning_errno() builtin/update-index.c: use error_errno() builtin/upload-archive.c: use error_errno() builtin/worktree.c: use error_errno() check-racy.c: use error_errno() combine-diff.c: use error_errno() compat/win32/syslog.c: use warning_errno() config.c: use error_errno() connected.c: use error_errno() copy.c: use error_errno() credential-cache--daemon.c: use warning_errno() diff-no-index.c: use error_errno() editor.c: use error_errno() entry.c: use error_errno() fast-import.c: use error_errno() gpg-interface.c: use error_errno() grep.c: use error_errno() http.c: use error_errno() and warning_errno() ident.c: use warning_errno() mailmap.c: use error_errno() reachable.c: use error_errno() rerere.c: use error_errno() and warning_errno() run-command.c: use error_errno() sequencer.c: use error_errno() server-info.c: use error_errno() sha1_file.c: use {error,die,warning}_errno() transport-helper.c: use error_errno() unpack-trees.c: use error_errno() upload-pack.c: use error_errno() vcs-svn: use error_errno() wrapper.c: use warning_errno() bisect.c | 7 +++ builtin/am.c | 11 +-- builtin/branch.c | 3 +-- builtin/fetch.c| 4 ++-- builtin/help.c | 8 builtin/mailsplit.c| 10 +- builtin/merge-file.c | 10 +- builtin/pack-objects.c | 8 +++- builtin/rm.c | 2 +- builtin/update-index.c | 8 builtin/upload-archive.c | 3 +-- builtin/worktree.c | 2 +- check-racy.c | 2 +- combine-diff.c | 3 +-- compat/win32/syslog.c | 6 +++--- config.c | 22 +- connected.c| 9 +++-- copy.c | 6 +++--- credential-cache--daemon.c | 4 ++-- diff-no-index.c| 3 +-- editor.c | 3 +-- entry.c| 10 -- fast-import.c | 10 +- git-compat-util.h | 2 ++ gpg-interface.c| 6 ++ grep.c | 4 ++-- http.c | 10 -- ident.c| 8 +++- mailmap.c | 3 +-- reachable.c| 3 +-- rerere.c | 18 +++--- run-command.c | 15 +++ sequencer.c| 3 +-- server-info.c | 2 +- sha1_file.c| 32 +--- transport-helper.c | 6 +++--- unpack-trees.c | 6 ++ upload-pack.c | 3 +-- usage.c| 44 ++-- vcs-svn/line_buffer.c | 4 ++-- vcs-svn/sliding_window.c | 2 +- vcs-svn/svndiff.c | 4 ++-- vcs-svn/svndump.c | 4 ++-- wrapper.c | 4 ++-- 44 files changed, 161 insertions(+), 176 deletions(-) -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02/41] usage.c: add warning_errno() and error_errno()
Similar to die_errno(), these functions will append strerror() automatically. Signed-off-by: Nguyễn Thái Ngọc Duy --- git-compat-util.h | 2 ++ usage.c | 19 +++ 2 files changed, 21 insertions(+) diff --git a/git-compat-util.h b/git-compat-util.h index 1f8b5f3..49d4029 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -409,7 +409,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf, extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2))); extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); +extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); +extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2))); #ifndef NO_OPENSSL #ifdef APPLE_COMMON_CRYPTO diff --git a/usage.c b/usage.c index 0dba0c5..af1b7d1 100644 --- a/usage.c +++ b/usage.c @@ -148,6 +148,16 @@ void NORETURN die_errno(const char *fmt, ...) va_end(params); } +int error_errno(const char *fmt, ...) +{ + va_list params; + + va_start(params, fmt); + error_routine(fmt_with_err(fmt), params); + va_end(params); + return -1; +} + #undef error int error(const char *err, ...) { @@ -159,6 +169,15 @@ int error(const char *err, ...) return -1; } +void warning_errno(const char *warn, ...) +{ + va_list params; + + va_start(params, warn); + warn_routine(fmt_with_err(warn), params); + va_end(params); +} + void warning(const char *warn, ...) { va_list params; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 01/41] usage.c: move format processing out of die_errno()
fmt_with_err() will be shared with the coming error_errno() and warning_errno(). Signed-off-by: Nguyễn Thái Ngọc Duy --- usage.c | 25 +++-- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/usage.c b/usage.c index 82ff131..0dba0c5 100644 --- a/usage.c +++ b/usage.c @@ -109,19 +109,12 @@ void NORETURN die(const char *err, ...) va_end(params); } -void NORETURN die_errno(const char *fmt, ...) +static const char *fmt_with_err(const char *fmt) { - va_list params; - char fmt_with_err[1024]; + static char fmt_with_err[1024]; char str_error[256], *err; int i, j; - if (die_is_recursing()) { - fputs("fatal: recursion detected in die_errno handler\n", - stderr); - exit(128); - } - err = strerror(errno); for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) { if ((str_error[j++] = err[i++]) != '%') @@ -137,9 +130,21 @@ void NORETURN die_errno(const char *fmt, ...) } str_error[j] = 0; snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error); + return fmt_with_err; +} + +void NORETURN die_errno(const char *fmt, ...) +{ + va_list params; + + if (die_is_recursing()) { + fputs("fatal: recursion detected in die_errno handler\n", + stderr); + exit(128); + } va_start(params, fmt); - die_routine(fmt_with_err, params); + die_routine(fmt_with_err(fmt), params); va_end(params); } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/41] builtin/branch.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/branch.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index 0adba62..6f1572d 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -593,8 +593,7 @@ static int edit_branch_description(const char *branch_name) branch_name, comment_line_char); if (write_file_gently(git_path(edit_description), "%s", buf.buf)) { strbuf_release(&buf); - return error(_("could not write branch description template: %s"), -strerror(errno)); + return error_errno(_("could not write branch description template")); } strbuf_reset(&buf); if (launch_editor(git_path(edit_description), &buf, NULL)) { -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 04/41] builtin/am.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/am.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/builtin/am.c b/builtin/am.c index d003939..3dfe70b 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -769,15 +769,15 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state, in = fopen(*paths, "r"); if (!in) - return error(_("could not open '%s' for reading: %s"), - *paths, strerror(errno)); + return error_errno(_("could not open '%s' for reading"), + *paths); mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1); out = fopen(mail, "w"); if (!out) - return error(_("could not open '%s' for writing: %s"), - mail, strerror(errno)); + return error_errno(_("could not open '%s' for writing"), + mail); ret = fn(out, in, keep_cr); @@ -857,8 +857,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths, fp = fopen(*paths, "r"); if (!fp) - return error(_("could not open '%s' for reading: %s"), *paths, - strerror(errno)); + return error_errno(_("could not open '%s' for reading"), *paths); while (!strbuf_getline_lf(&sb, fp)) { if (*sb.buf == '#') -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/41] bisect.c: use die_errno() and warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- bisect.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bisect.c b/bisect.c index 7996c29..6d93edb 100644 --- a/bisect.c +++ b/bisect.c @@ -860,8 +860,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout) /* Create file BISECT_ANCESTORS_OK. */ fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600); if (fd < 0) - warning("could not create file '%s': %s", - filename, strerror(errno)); + warning_errno("could not create file '%s'", + filename); else close(fd); done: @@ -910,8 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good) *read_good = "good"; return; } else { - die("could not read file '%s': %s", filename, - strerror(errno)); + die_errno("could not read file '%s'", filename); } } else { strbuf_getline_lf(&str, fp); -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/pack-objects.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index a27de5b..e18e190 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -828,8 +828,7 @@ static void write_pack_file(void) * to preserve this property. */ if (stat(pack_tmp_name, &st) < 0) { - warning("failed to stat %s: %s", - pack_tmp_name, strerror(errno)); + warning_errno("failed to stat %s", pack_tmp_name); } else if (!last_mtime) { last_mtime = st.st_mtime; } else { @@ -837,8 +836,7 @@ static void write_pack_file(void) utb.actime = st.st_atime; utb.modtime = --last_mtime; if (utime(pack_tmp_name, &utb) < 0) - warning("failed utime() on %s: %s", - pack_tmp_name, strerror(errno)); + warning_errno("failed utime() on %s", pack_tmp_name); } strbuf_addf(&tmpname, "%s-", base_name); @@ -2020,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, ret = pthread_create(&p[i].thread, NULL, threaded_find_deltas, &p[i]); if (ret) - die("unable to create thread: %s", strerror(ret)); + die_errno("unable to create thread"); active_threads++; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09/41] builtin/merge-file.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/merge-file.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 5544705..13e22a2 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -62,8 +62,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) usage_with_options(merge_file_usage, options); if (quiet) { if (!freopen("/dev/null", "w", stderr)) - return error("failed to redirect stderr to /dev/null: " -"%s", strerror(errno)); + return error_errno("failed to redirect stderr to /dev/null"); } if (prefix) @@ -95,12 +94,13 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) FILE *f = to_stdout ? stdout : fopen(fpath, "wb"); if (!f) - ret = error("Could not open %s for writing", filename); + ret = error_errno("Could not open %s for writing", + filename); else if (result.size && fwrite(result.ptr, result.size, 1, f) != 1) - ret = error("Could not write to %s", filename); + ret = error_errno("Could not write to %s", filename); else if (fclose(f)) - ret = error("Could not close %s", filename); + ret = error_errno("Could not close %s", filename); free(result.ptr); } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06/41] builtin/fetch.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/fetch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index f8455bd..1582ca7 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, fp = fopen(filename, "a"); if (!fp) - return error(_("cannot open %s: %s\n"), filename, strerror(errno)); + return error_errno(_("cannot open %s"), filename); if (raw_url) url = transport_anonymize_url(raw_url); @@ -848,7 +848,7 @@ static int truncate_fetch_head(void) FILE *fp = fopen_for_writing(filename); if (!fp) - return error(_("cannot open %s: %s\n"), filename, strerror(errno)); + return error_errno(_("cannot open %s"), filename); fclose(fp); return 0; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 07/41] builtin/help.c: use warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/help.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/help.c b/builtin/help.c index 3c55ce4..8848013 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -127,7 +127,7 @@ static void exec_woman_emacs(const char *path, const char *page) path = "emacsclient"; strbuf_addf(&man_page, "(woman \"%s\")", page); execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL); - warning(_("failed to exec '%s': %s"), path, strerror(errno)); + warning_errno(_("failed to exec '%s'"), path); } } @@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page) path = "kfmclient"; strbuf_addf(&man_page, "man:%s(1)", page); execlp(path, filename, "newTab", man_page.buf, (char *)NULL); - warning(_("failed to exec '%s': %s"), path, strerror(errno)); + warning_errno(_("failed to exec '%s'"), path); } } @@ -157,7 +157,7 @@ static void exec_man_man(const char *path, const char *page) if (!path) path = "man"; execlp(path, "man", page, (char *)NULL); - warning(_("failed to exec '%s': %s"), path, strerror(errno)); + warning_errno(_("failed to exec '%s'"), path); } static void exec_man_cmd(const char *cmd, const char *page) @@ -165,7 +165,7 @@ static void exec_man_cmd(const char *cmd, const char *page) struct strbuf shell_cmd = STRBUF_INIT; strbuf_addf(&shell_cmd, "%s %s", cmd, page); execl(SHELL_PATH, SHELL_PATH, "-c", shell_cmd.buf, (char *)NULL); - warning(_("failed to exec '%s': %s"), cmd, strerror(errno)); + warning(_("failed to exec '%s'"), cmd); } static void add_man_viewer(const char *name) -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 11/41] builtin/rm.c: use warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/rm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/rm.c b/builtin/rm.c index 8829b09..13b9639 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only) if (lstat(ce->name, &st) < 0) { if (errno != ENOENT && errno != ENOTDIR) - warning("'%s': %s", ce->name, strerror(errno)); + warning_errno("'%s'", ce->name); /* It already vanished from the working tree */ continue; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 08/41] builtin/mailsplit.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/mailsplit.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c index 104277a..4859ede 100644 --- a/builtin/mailsplit.c +++ b/builtin/mailsplit.c @@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path) if ((dir = opendir(name)) == NULL) { if (errno == ENOENT) continue; - error("cannot opendir %s (%s)", name, strerror(errno)); + error_errno("cannot opendir %s", name); goto out; } @@ -174,12 +174,12 @@ static int split_maildir(const char *maildir, const char *dir, f = fopen(file, "r"); if (!f) { - error("cannot open mail %s (%s)", file, strerror(errno)); + error_errno("cannot open mail %s", file); goto out; } if (strbuf_getwholeline(&buf, f, '\n')) { - error("cannot read mail %s (%s)", file, strerror(errno)); + error_errno("cannot read mail %s", file); goto out; } @@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare, int file_done = 0; if (!f) { - error("cannot open mbox %s", file); + error_errno("cannot open mbox %s", file); goto out; } @@ -318,7 +318,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix) } if (stat(arg, &argstat) == -1) { - error("cannot stat %s (%s)", arg, strerror(errno)); + error_errno("cannot stat %s", arg); return 1; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 19/41] connected.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- connected.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/connected.c b/connected.c index 299c560..bf1b12e 100644 --- a/connected.c +++ b/connected.c @@ -86,17 +86,14 @@ static int check_everything_connected_real(sha1_iterate_fn fn, memcpy(commit, sha1_to_hex(sha1), 40); if (write_in_full(rev_list.in, commit, 41) < 0) { if (errno != EPIPE && errno != EINVAL) - error(_("failed write to rev-list: %s"), - strerror(errno)); + error_errno(_("failed write to rev-list")); err = -1; break; } } while (!fn(cb_data, sha1)); - if (close(rev_list.in)) { - error(_("failed to close rev-list's stdin: %s"), strerror(errno)); - err = -1; - } + if (close(rev_list.in)) + err = error_errno(_("failed to close rev-list's stdin")); sigchain_pop(SIGPIPE); return finish_command(&rev_list) || err; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 16/41] combine-diff.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- combine-diff.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/combine-diff.c b/combine-diff.c index 0e1d4b0..8f2313d 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1005,8 +1005,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, struct strbuf buf = STRBUF_INIT; if (strbuf_readlink(&buf, elem->path, st.st_size) < 0) { - error("readlink(%s): %s", elem->path, - strerror(errno)); + error_errno("readlink(%s)", elem->path); return; } result_size = buf.len; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 20/41] copy.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- copy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/copy.c b/copy.c index 574fa1f..4de6a11 100644 --- a/copy.c +++ b/copy.c @@ -42,15 +42,15 @@ int copy_file(const char *dst, const char *src, int mode) status = copy_fd(fdi, fdo); switch (status) { case COPY_READ_ERROR: - error("copy-fd: read returned %s", strerror(errno)); + error_errno("copy-fd: read returned"); break; case COPY_WRITE_ERROR: - error("copy-fd: write returned %s", strerror(errno)); + error_errno("copy-fd: write returned"); break; } close(fdi); if (close(fdo) != 0) - return error("%s: close error: %s", dst, strerror(errno)); + return error_errno("%s: close error", dst); if (!status && adjust_shared_perm(dst)) return -1; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 24/41] entry.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- entry.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/entry.c b/entry.c index a410957..519e042 100644 --- a/entry.c +++ b/entry.c @@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce, ret = symlink(new, path); free(new); if (ret) - return error("unable to create symlink %s (%s)", -path, strerror(errno)); + return error_errno("unable to create symlink %s", + path); break; } @@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce, fd = open_output_fd(path, ce, to_tempfile); if (fd < 0) { free(new); - return error("unable to create file %s (%s)", - path, strerror(errno)); + return error_errno("unable to create file %s", path); } wrote = write_in_full(fd, new, size); @@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce, return error("%s is a directory", path.buf); remove_subtree(&path); } else if (unlink(path.buf)) - return error("unable to unlink old '%s' (%s)", -path.buf, strerror(errno)); + return error_errno("unable to unlink old '%s'", path.buf); } else if (state->not_new) return 0; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 14/41] builtin/worktree.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/worktree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index d8e3795..331ecf6 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -110,7 +110,7 @@ static void prune_worktrees(void) if (ret < 0 && errno == ENOTDIR) ret = unlink(path.buf); if (ret) - error(_("failed to remove: %s"), strerror(errno)); + error_errno(_("failed to remove '%s'"), path.buf); } closedir(dir); if (!show_only) -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 12/41] builtin/update-index.c: use error_errno()
"err" is deleted because it just causes confusion when "errno" is also used directly in process_lstat_error(). Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/update-index.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index 1c94ca5..0c539ed 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -251,11 +251,11 @@ static int remove_one_path(const char *path) *succeeds. * - permission error. That's never ok. */ -static int process_lstat_error(const char *path, int err) +static int process_lstat_error(const char *path) { - if (err == ENOENT || err == ENOTDIR) + if (errno == ENOENT || errno == ENOTDIR) return remove_one_path(path); - return error("lstat(\"%s\"): %s", path, strerror(errno)); + return error_errno("lstat(\"%s\")", path); } static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st) @@ -382,7 +382,7 @@ static int process_path(const char *path) * what to do about the pathname! */ if (lstat(path, &st) < 0) - return process_lstat_error(path, errno); + return process_lstat_error(path); if (S_ISDIR(st.st_mode)) return process_directory(path, len, &st); -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 15/41] check-racy.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- check-racy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check-racy.c b/check-racy.c index 00d92a1..24b6542 100644 --- a/check-racy.c +++ b/check-racy.c @@ -12,7 +12,7 @@ int main(int ac, char **av) struct stat st; if (lstat(ce->name, &st)) { - error("lstat(%s): %s", ce->name, strerror(errno)); + error_errno("lstat(%s)", ce->name); continue; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 22/41] diff-no-index.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- diff-no-index.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/diff-no-index.c b/diff-no-index.c index 03daadb..1f8999b 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -65,8 +65,7 @@ static int populate_from_stdin(struct diff_filespec *s) size_t size = 0; if (strbuf_read(&buf, 0, 0) < 0) - return error("error while reading from stdin %s", -strerror(errno)); + return error_errno("error while reading from stdin"); s->should_munmap = 0; s->data = strbuf_detach(&buf, &size); -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 21/41] credential-cache--daemon.c: use warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- credential-cache--daemon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c index 291c0fd..1f14d56 100644 --- a/credential-cache--daemon.c +++ b/credential-cache--daemon.c @@ -179,12 +179,12 @@ static int serve_cache_loop(int fd) client = accept(fd, NULL, NULL); if (client < 0) { - warning("accept failed: %s", strerror(errno)); + warning_errno("accept failed"); return 1; } client2 = dup(client); if (client2 < 0) { - warning("dup failed: %s", strerror(errno)); + warning_errno("dup failed"); close(client); return 1; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 13/41] builtin/upload-archive.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/upload-archive.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c index dbfe14f..2caedf1 100644 --- a/builtin/upload-archive.c +++ b/builtin/upload-archive.c @@ -104,8 +104,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix) pfd[1].events = POLLIN; if (poll(pfd, 2, -1) < 0) { if (errno != EINTR) { - error("poll failed resuming: %s", - strerror(errno)); + error_errno("poll failed resuming"); sleep(1); } continue; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 17/41] compat/win32/syslog.c: use warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- compat/win32/syslog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c index b905aea..1c2ae18 100644 --- a/compat/win32/syslog.c +++ b/compat/win32/syslog.c @@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...) va_end(ap); if (str_len < 0) { - warning("vsnprintf failed: '%s'", strerror(errno)); + warning_errno("vsnprintf failed:"); return; } str = malloc(st_add(str_len, 1)); if (!str) { - warning("malloc failed: '%s'", strerror(errno)); + warning_errno("malloc failed"); return; } @@ -45,7 +45,7 @@ void syslog(int priority, const char *fmt, ...) while ((pos = strstr(str, "%1")) != NULL) { str = realloc(str, st_add(++str_len, 1)); if (!str) { - warning("realloc failed: '%s'", strerror(errno)); + warning_errno("realloc failed"); return; } memmove(pos + 2, pos + 1, strlen(pos)); -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 18/41] config.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- config.c | 22 +- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/config.c b/config.c index 10b5c95..80411e4 100644 --- a/config.c +++ b/config.c @@ -2012,7 +2012,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename, lock = xcalloc(1, sizeof(struct lock_file)); fd = hold_lock_file_for_update(lock, config_filename, 0); if (fd < 0) { - error("could not lock config file %s: %s", config_filename, strerror(errno)); + error_errno("could not lock config file %s", config_filename); free(store.key); ret = CONFIG_NO_LOCK; goto out_free; @@ -2026,8 +2026,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename, free(store.key); if ( ENOENT != errno ) { - error("opening %s: %s", config_filename, - strerror(errno)); + error_errno("opening %s", config_filename); ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */ goto out_free; } @@ -2111,8 +2110,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename, if (contents == MAP_FAILED) { if (errno == ENODEV && S_ISDIR(st.st_mode)) errno = EISDIR; - error("unable to mmap '%s': %s", - config_filename, strerror(errno)); + error_errno("unable to mmap '%s'", config_filename); ret = CONFIG_INVALID_FILE; contents = NULL; goto out_free; @@ -2121,8 +2119,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename, in_fd = -1; if (chmod(get_lock_file_path(lock), st.st_mode & 0) < 0) { - error("chmod on %s failed: %s", - get_lock_file_path(lock), strerror(errno)); + error_errno("chmod on %s failed", get_lock_file_path(lock)); ret = CONFIG_NO_WRITE; goto out_free; } @@ -2178,8 +2175,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename, } if (commit_lock_file(lock) < 0) { - error("could not write config file %s: %s", config_filename, - strerror(errno)); + error_errno("could not write config file %s", config_filename); ret = CONFIG_NO_WRITE; lock = NULL; goto out_free; @@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename, fstat(fileno(config_file), &st); if (chmod(get_lock_file_path(lock), st.st_mode & 0) < 0) { - ret = error("chmod on %s failed: %s", - get_lock_file_path(lock), strerror(errno)); + ret = error_errno("chmod on %s failed", + get_lock_file_path(lock)); goto out; } @@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename, fclose(config_file); unlock_and_out: if (commit_lock_file(lock) < 0) - ret = error("could not write config file %s: %s", - config_filename, strerror(errno)); + ret = error_errno("could not write config file %s", + config_filename); out: free(filename_buf); return ret; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 23/41] editor.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- editor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/editor.c b/editor.c index 01c644c..7519ede 100644 --- a/editor.c +++ b/editor.c @@ -63,7 +63,6 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en if (!buffer) return 0; if (strbuf_read_file(buffer, path, 0) < 0) - return error("could not read file '%s': %s", - path, strerror(errno)); + return error_errno("could not read file '%s'", path); return 0; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 28/41] http.c: use error_errno() and warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- http.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/http.c b/http.c index 4304b80..7565c93 100644 --- a/http.c +++ b/http.c @@ -446,8 +446,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type) rc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&ka, len); if (rc < 0) - warning("unable to set SO_KEEPALIVE on socket %s", - strerror(errno)); + warning_errno("unable to set SO_KEEPALIVE on socket"); return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */ } @@ -1894,8 +1893,7 @@ struct http_object_request *new_http_object_request(const char *base_url, } if (freq->localfile < 0) { - error("Couldn't create temporary file %s: %s", - freq->tmpfile, strerror(errno)); + error_errno("Couldn't create temporary file %s", freq->tmpfile); goto abort; } @@ -1940,8 +1938,8 @@ struct http_object_request *new_http_object_request(const char *base_url, prev_posn = 0; lseek(freq->localfile, 0, SEEK_SET); if (ftruncate(freq->localfile, 0) < 0) { - error("Couldn't truncate temporary file %s: %s", - freq->tmpfile, strerror(errno)); + error_errno("Couldn't truncate temporary file %s", + freq->tmpfile); goto abort; } } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 26/41] gpg-interface.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- gpg-interface.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gpg-interface.c b/gpg-interface.c index 2259938..c4b1e8c 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -219,11 +219,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size, args_gpg[0] = gpg_program; fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXX"); if (fd < 0) - return error(_("could not create temporary file '%s': %s"), -path, strerror(errno)); + return error_errno(_("could not create temporary file '%s'"), path); if (write_in_full(fd, signature, signature_size) < 0) - return error(_("failed writing detached signature to '%s': %s"), -path, strerror(errno)); + return error_errno(_("failed writing detached signature to '%s'"), path); close(fd); gpg.argv = args_gpg; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 27/41] grep.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- grep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grep.c b/grep.c index 528b652..87c1890 100644 --- a/grep.c +++ b/grep.c @@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs) if (lstat(filename, &st) < 0) { err_ret: if (errno != ENOENT) - error(_("'%s': %s"), filename, strerror(errno)); + error_errno(_("'%s'"), filename); return -1; } if (!S_ISREG(st.st_mode)) @@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs) goto err_ret; data = xmallocz(size); if (st.st_size != read_in_full(i, data, size)) { - error(_("'%s': short read %s"), filename, strerror(errno)); + error_errno(_("'%s': short read"), filename); close(i); free(data); return -1; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 25/41] fast-import.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- fast-import.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fast-import.c b/fast-import.c index 9fc7093..21881d1 100644 --- a/fast-import.c +++ b/fast-import.c @@ -414,7 +414,7 @@ static void write_crash_report(const char *err) struct recent_command *rc; if (!rpt) { - error("can't write crash report %s: %s", loc, strerror(errno)); + error_errno("can't write crash report %s", loc); free(loc); return; } @@ -1806,8 +1806,8 @@ static void dump_marks(void) return; if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) { - failure |= error("Unable to write marks file %s: %s", - export_marks_file, strerror(errno)); + failure |= error_errno("Unable to write marks file %s", + export_marks_file); return; } @@ -1822,8 +1822,8 @@ static void dump_marks(void) dump_marks_helper(f, 0, marks); if (commit_lock_file(&mark_lock)) { - failure |= error("Unable to write file %s: %s", - export_marks_file, strerror(errno)); + failure |= error_errno("Unable to write file %s", + export_marks_file); return; } } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 33/41] run-command.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- run-command.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/run-command.c b/run-command.c index e4593cd..842c8d1 100644 --- a/run-command.c +++ b/run-command.c @@ -233,7 +233,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal) if (waiting < 0) { failed_errno = errno; - error("waitpid for %s failed: %s", argv0, strerror(errno)); + error_errno("waitpid for %s failed", argv0); } else if (waiting != pid) { error("waitpid is confused (%s)", argv0); } else if (WIFSIGNALED(status)) { @@ -420,8 +420,7 @@ fail_pipe: } } if (cmd->pid < 0) - error("cannot fork() for %s: %s", cmd->argv[0], - strerror(errno)); + error_errno("cannot fork() for %s", cmd->argv[0]); else if (cmd->clean_on_exit) mark_child_for_cleanup(cmd->pid); @@ -482,7 +481,7 @@ fail_pipe: cmd->dir, fhin, fhout, fherr); failed_errno = errno; if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT)) - error("cannot spawn %s: %s", cmd->argv[0], strerror(errno)); + error_errno("cannot spawn %s", cmd->argv[0]); if (cmd->clean_on_exit && cmd->pid >= 0) mark_child_for_cleanup(cmd->pid); @@ -703,7 +702,7 @@ int start_async(struct async *async) if (pipe(fdin) < 0) { if (async->out > 0) close(async->out); - return error("cannot create pipe: %s", strerror(errno)); + return error_errno("cannot create pipe"); } async->in = fdin[1]; } @@ -715,7 +714,7 @@ int start_async(struct async *async) close_pair(fdin); else if (async->in) close(async->in); - return error("cannot create pipe: %s", strerror(errno)); + return error_errno("cannot create pipe"); } async->out = fdout[0]; } @@ -740,7 +739,7 @@ int start_async(struct async *async) async->pid = fork(); if (async->pid < 0) { - error("fork (async) failed: %s", strerror(errno)); + error_errno("fork (async) failed"); goto error; } if (!async->pid) { @@ -787,7 +786,7 @@ int start_async(struct async *async) { int err = pthread_create(&async->tid, NULL, run_thread, async); if (err) { - error("cannot create thread: %s", strerror(err)); + error_errno("cannot create thread"); goto error; } } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 32/41] rerere.c: use error_errno() and warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- rerere.c | 18 +++--- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/rerere.c b/rerere.c index c8b9f40..1810c04 100644 --- a/rerere.c +++ b/rerere.c @@ -501,8 +501,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output error("There were errors while writing %s (%s)", path, strerror(io.io.wrerror)); if (io.io.output && fclose(io.io.output)) - io.io.wrerror = error("Failed to flush %s: %s", - path, strerror(errno)); + io.io.wrerror = error_errno("Failed to flush %s", path); if (hunk_no < 0) { if (output) @@ -684,20 +683,17 @@ static int merge(const struct rerere_id *id, const char *path) * Mark that "postimage" was used to help gc. */ if (utime(rerere_path(id, "postimage"), NULL) < 0) - warning("failed utime() on %s: %s", - rerere_path(id, "postimage"), - strerror(errno)); + warning_errno("failed utime() on %s", + rerere_path(id, "postimage")); /* Update "path" with the resolution */ f = fopen(path, "w"); if (!f) - return error("Could not open %s: %s", path, -strerror(errno)); + return error_errno("Could not open %s", path); if (fwrite(result.ptr, result.size, 1, f) != 1) - error("Could not write %s: %s", path, strerror(errno)); + error_errno("Could not write %s", path); if (fclose(f)) - return error("Writing %s failed: %s", path, -strerror(errno)); + return error_errno("Writing %s failed", path); out: free(cur.ptr); @@ -1071,7 +1067,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr) if (unlink(filename)) return (errno == ENOENT ? error("no remembered resolution for %s", path) - : error("cannot unlink %s: %s", filename, strerror(errno))); + : error_errno("cannot unlink %s", filename)); /* * Update the preimage so that the user can resolve the -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 30/41] mailmap.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- mailmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mailmap.c b/mailmap.c index 9726237..b5c521f 100644 --- a/mailmap.c +++ b/mailmap.c @@ -189,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename, if (!f) { if (errno == ENOENT) return 0; - return error("unable to open mailmap at %s: %s", -filename, strerror(errno)); + return error_errno("unable to open mailmap at %s", filename); } while (fgets(buffer, sizeof(buffer), f) != NULL) -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 29/41] ident.c: use warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- ident.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ident.c b/ident.c index 4fd82d1..139c528 100644 --- a/ident.c +++ b/ident.c @@ -75,14 +75,12 @@ static int add_mailname_host(struct strbuf *buf) mailname = fopen("/etc/mailname", "r"); if (!mailname) { if (errno != ENOENT) - warning("cannot open /etc/mailname: %s", - strerror(errno)); + warning_errno("cannot open /etc/mailname"); return -1; } if (strbuf_getline(&mailnamebuf, mailname) == EOF) { if (ferror(mailname)) - warning("cannot read /etc/mailname: %s", - strerror(errno)); + warning_errno("cannot read /etc/mailname"); strbuf_release(&mailnamebuf); fclose(mailname); return -1; @@ -125,7 +123,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus) char buf[1024]; if (gethostname(buf, sizeof(buf))) { - warning("cannot get host name: %s", strerror(errno)); + warning_errno("cannot get host name"); strbuf_addstr(out, "(none)"); *is_bogus = 1; return; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 31/41] reachable.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- reachable.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reachable.c b/reachable.c index ed35201..d0199ca 100644 --- a/reachable.c +++ b/reachable.c @@ -119,8 +119,7 @@ static int add_recent_loose(const unsigned char *sha1, */ if (errno == ENOENT) return 0; - return error("unable to stat %s: %s", -sha1_to_hex(sha1), strerror(errno)); + return error_errno("unable to stat %s", sha1_to_hex(sha1)); } add_recent_object(sha1, st.st_mtime, data); -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 34/41] sequencer.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- sequencer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sequencer.c b/sequencer.c index e66f2fe..4687ad4 100644 --- a/sequencer.c +++ b/sequencer.c @@ -875,8 +875,7 @@ static int sequencer_rollback(struct replay_opts *opts) return rollback_single_pick(); } if (!f) - return error(_("cannot open %s: %s"), git_path_head_file(), - strerror(errno)); + return error_errno(_("cannot open %s"), git_path_head_file()); if (strbuf_getline_lf(&buf, f)) { error(_("cannot read %s: %s"), git_path_head_file(), ferror(f) ? strerror(errno) : _("unexpected end of file")); -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 37/41] transport-helper.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- transport-helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transport-helper.c b/transport-helper.c index b934183..f09fadc 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -1166,7 +1166,7 @@ static int udt_do_read(struct unidirectional_transfer *t) bytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse); if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR) { - error("read(%s) failed: %s", t->src_name, strerror(errno)); + error_errno("read(%s) failed", t->src_name); return -1; } else if (bytes == 0) { transfer_debug("%s EOF (with %i bytes in buffer)", @@ -1193,7 +1193,7 @@ static int udt_do_write(struct unidirectional_transfer *t) transfer_debug("%s is writable", t->dest_name); bytes = xwrite(t->dest, t->buf, t->bufuse); if (bytes < 0 && errno != EWOULDBLOCK) { - error("write(%s) failed: %s", t->dest_name, strerror(errno)); + error_errno("write(%s) failed", t->dest_name); return -1; } else if (bytes > 0) { t->bufuse -= bytes; @@ -1306,7 +1306,7 @@ static int tloop_join(pid_t pid, const char *name) { int tret; if (waitpid(pid, &tret, 0) < 0) { - error("%s process failed to wait: %s", name, strerror(errno)); + error_errno("%s process failed to wait", name); return 1; } if (!WIFEXITED(tret) || WEXITSTATUS(tret)) { -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 35/41] server-info.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- server-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-info.c b/server-info.c index 5a86e29..75dd677 100644 --- a/server-info.c +++ b/server-info.c @@ -36,7 +36,7 @@ static int update_info_file(char *path, int (*generate)(FILE *)) out: if (ret) { - error("unable to update %s: %s", path, strerror(errno)); + error_errno("unable to update %s", path); if (fp) fclose(fp); else if (fd >= 0) -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 41/41] wrapper.c: use warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- wrapper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrapper.c b/wrapper.c index 9afc1a0..3df2fe0 100644 --- a/wrapper.c +++ b/wrapper.c @@ -572,7 +572,7 @@ static int warn_if_unremovable(const char *op, const char *file, int rc) if (!rc || errno == ENOENT) return 0; err = errno; - warning("unable to %s %s: %s", op, file, strerror(errno)); + warning_errno("unable to %s %s", op, file); errno = err; return rc; } @@ -608,7 +608,7 @@ int remove_or_warn(unsigned int mode, const char *file) void warn_on_inaccessible(const char *path) { - warning(_("unable to access '%s': %s"), path, strerror(errno)); + warning_errno(_("unable to access '%s'"), path); } static int access_error_is_ok(int err, unsigned flag) -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 38/41] unpack-trees.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- unpack-trees.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/unpack-trees.c b/unpack-trees.c index 9f55cc2..bb0d142 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1499,8 +1499,7 @@ static int verify_absent_1(const struct cache_entry *ce, path = xmemdupz(ce->name, len); if (lstat(path, &st)) - ret = error("cannot stat '%s': %s", path, - strerror(errno)); + ret = error_errno("cannot stat '%s'", path); else ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st, error_type, o); @@ -1508,8 +1507,7 @@ static int verify_absent_1(const struct cache_entry *ce, return ret; } else if (lstat(ce->name, &st)) { if (errno != ENOENT) - return error("cannot stat '%s': %s", ce->name, -strerror(errno)); + return error_errno("cannot stat '%s'", ce->name); return 0; } else { return check_ok_to_remove(ce->name, ce_namelen(ce), -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 36/41] sha1_file.c: use {error,die,warning}_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- sha1_file.c | 32 +--- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/sha1_file.c b/sha1_file.c index d0f2aa0..a7f45b3 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1107,9 +1107,8 @@ unsigned char *use_pack(struct packed_git *p, PROT_READ, MAP_PRIVATE, p->pack_fd, win->offset); if (win->base == MAP_FAILED) - die("packfile %s cannot be mapped: %s", - p->pack_name, - strerror(errno)); + die_errno("packfile %s cannot be mapped", + p->pack_name); if (!win->offset && win->len == p->pack_size && !p->do_not_close) close_pack_fd(p); @@ -1279,8 +1278,8 @@ static void prepare_packed_git_one(char *objdir, int local) dir = opendir(path.buf); if (!dir) { if (errno != ENOENT) - error("unable to open object pack directory: %s: %s", - path.buf, strerror(errno)); + error_errno("unable to open object pack directory: %s", + path.buf); strbuf_release(&path); return; } @@ -2984,7 +2983,7 @@ int finalize_object_file(const char *tmpfile, const char *filename) unlink_or_warn(tmpfile); if (ret) { if (ret != EEXIST) { - return error("unable to write sha1 filename %s: %s", filename, strerror(ret)); + return error_errno("unable to write sha1 filename %s", filename); } /* FIXME!!! Collision check here ? */ } @@ -2998,7 +2997,7 @@ out: static int write_buffer(int fd, const void *buf, size_t len) { if (write_in_full(fd, buf, len) < 0) - return error("file write error (%s)", strerror(errno)); + return error_errno("file write error"); return 0; } @@ -3081,7 +3080,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen, if (errno == EACCES) return error("insufficient permission for adding an object to repository database %s", get_object_directory()); else - return error("unable to create temporary file: %s", strerror(errno)); + return error_errno("unable to create temporary file"); } /* Set it up */ @@ -3126,8 +3125,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen, utb.actime = mtime; utb.modtime = mtime; if (utime(tmp_file.buf, &utb) < 0) - warning("failed utime() on %s: %s", - tmp_file.buf, strerror(errno)); + warning_errno("failed utime() on %s", tmp_file.buf); } return finalize_object_file(tmp_file.buf, filename); @@ -3360,7 +3358,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size, if (size == read_in_full(fd, buf, size)) ret = index_mem(sha1, buf, size, type, path, flags); else - ret = error("short read %s", strerror(errno)); + ret = error_errno("short read"); free(buf); } else { void *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); @@ -3425,18 +3423,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned case S_IFREG: fd = open(path, O_RDONLY); if (fd < 0) - return error("open(\"%s\"): %s", path, -strerror(errno)); + return error_errno("open(\"%s\")", path); if (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0) return error("%s: failed to insert into database", path); break; case S_IFLNK: - if (strbuf_readlink(&sb, path, st->st_size)) { - char *errstr = strerror(errno); - return error("readlink(\"%s\"): %s", path, -errstr); - } + if (strbuf_readlink(&sb, path, st->st_size)) + return error_errno("readlink(\"%s\")", path); if (!(flags & HASH_WRITE_OBJECT)) hash_sha1_file(sb.buf, sb.len, blob_type, sha1); else if (write_sha1_file(sb.buf, sb.len, blob_type, sha1)) @@ -3492,7 +3486,7 @@ static int for_each_file_in_obj_subdir(int subdir_nr,
[PATCH 40/41] vcs-svn: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- vcs-svn/line_buffer.c| 4 ++-- vcs-svn/sliding_window.c | 2 +- vcs-svn/svndiff.c| 4 ++-- vcs-svn/svndump.c| 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c index 57cc1ce..e416caf 100644 --- a/vcs-svn/line_buffer.c +++ b/vcs-svn/line_buffer.c @@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf) { long pos = ftell(buf->infile); if (pos < 0) - return error("ftell error: %s", strerror(errno)); + return error_errno("ftell error"); if (fseek(buf->infile, 0, SEEK_SET)) - return error("seek error: %s", strerror(errno)); + return error_errno("seek error"); return pos; } diff --git a/vcs-svn/sliding_window.c b/vcs-svn/sliding_window.c index f11d490..06d273c 100644 --- a/vcs-svn/sliding_window.c +++ b/vcs-svn/sliding_window.c @@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file) { if (!buffer_ferror(file)) return error("delta preimage ends early"); - return error("cannot read delta preimage: %s", strerror(errno)); + return error_errno("cannot read delta preimage"); } static int skip_or_whine(struct line_buffer *file, off_t gap) diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c index 74c97c4..75c7531 100644 --- a/vcs-svn/svndiff.c +++ b/vcs-svn/svndiff.c @@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out) { if (fwrite(sb->buf, 1, sb->len, out) == sb->len)/* Success. */ return 0; - return error("cannot write delta postimage: %s", strerror(errno)); + return error_errno("cannot write delta postimage"); } static int error_short_read(struct line_buffer *input) { if (buffer_ferror(input)) - return error("error reading delta: %s", strerror(errno)); + return error_errno("error reading delta"); return error("invalid delta: unexpected end of file"); } diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c index 31d1d83..e4b3959 100644 --- a/vcs-svn/svndump.c +++ b/vcs-svn/svndump.c @@ -501,7 +501,7 @@ static void init(int report_fd) int svndump_init(const char *filename) { if (buffer_init(&input, filename)) - return error("cannot open %s: %s", filename ? filename : "NULL", strerror(errno)); + return error_errno("cannot open %s", filename ? filename : "NULL"); init(REPORT_FILENO); return 0; } @@ -509,7 +509,7 @@ int svndump_init(const char *filename) int svndump_init_fd(int in_fd, int back_fd) { if(buffer_fdinit(&input, xdup(in_fd))) - return error("cannot open fd %d: %s", in_fd, strerror(errno)); + return error_errno("cannot open fd %d", in_fd); init(xdup(back_fd)); return 0; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 39/41] upload-pack.c: use error_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy --- upload-pack.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index dc802a0..f19444d 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -174,8 +174,7 @@ static void create_pack_file(void) if (ret < 0) { if (errno != EINTR) { - error("poll failed, resuming: %s", - strerror(errno)); + error_errno("poll failed, resuming"); sleep(1); } continue; -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 00/41] Add and use error_errno() and warning_errno()
On Sun, May 01, 2016 at 06:14:16PM +0700, Nguyễn Thái Ngọc Duy wrote: > This is a spinoff from my worktree-move topic. This series adds > die_errno() companions, error_errno() and warning_errno(), and use them > where applicable to reduce the amount of typing (in future). I had this patch in the series but excluded it before sending because there is something wrong about it. The patch shows two code blocks that follow the same pattern: closesocket() then print an error with strerror(). The second block suggests that closesocket() can change errno. But if that's true, the first block should do the same. Which is right? Fix the first block to save errno, or drop the saving in the second block? diff --git a/compat/mingw.c b/compat/mingw.c index 0413d5c..b6de02c 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1555,8 +1555,7 @@ int mingw_socket(int domain, int type, int protocol) /* convert into a file descriptor */ if ((sockfd = _open_osfhandle(s, O_RDWR|O_BINARY)) < 0) { closesocket(s); - return error("unable to make a socket file descriptor: %s", - strerror(errno)); + return error_errno("unable to make a socket file descriptor"); } return sockfd; } @@ -1606,10 +1605,8 @@ int mingw_accept(int sockfd1, struct sockaddr *sa, socklen_t *sz) /* convert into a file descriptor */ if ((sockfd2 = _open_osfhandle(s2, O_RDWR|O_BINARY)) < 0) { - int err = errno; closesocket(s2); - return error("unable to make a socket file descriptor: %s", - strerror(err)); + return error_errno("unable to make a socket file descriptor"); } return sockfd2; } -- 2.8.0.rc0.210.gd302cd2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/6] connect: uniformize and group CONNECT_DIAG_URL handling code
On 01.05.16 08:02, Mike Hommey wrote: > The CONNECT_DIAG_URL code for PROTO_GIT and PROTO_SSH were different in > subtle ways. Yes, and there (historical) reasons for that. The first implementation did support IPV6 with SSH: commit 5ba884483fe1a5f9ce1ce5e3c5e1c37c0fd296c4 [PATCH] GIT: Try all addresses for given remote name Try all addresses for given remote name until it succeeds. Also supports IPv6. This lead to a regression, which was fixed here: commit ce6f8e7ec2bbebe2472e23b684cae0a4adf325ad Fix git protocol connection 'port' override It was broken by the IPv6 patches - we need to remove the ":" part from the hostname for a successful name lookup. Later the ssh:// syntax was added: commit c05186cc38ca4605bff1f275619d7d0faeaf2fa5 Support git+ssh:// and ssh+git:// URL Later support for [] was added: commit 356bece0a2725818191b12f6e991490d52baa1d1 GIT: Support [address] in URLs Allow IPv6address/IPvFuture enclosed by [] in URLs, like: git push '[3ffe::...:1]:GIT/git' or git push 'ssh://[3ffe::...:1]/GIT/git' Later, support for a trailing ':' was added: commit 608d48b2207a6152839a9762c7a66f217bceb440 Fix "getaddrinfo()" buglet So when somebody passes me a "please pull" request pointing to something like the following git://git.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb.git (note the extraneous colon at the end of the host name), git would happily try to connect to port 0, which would generally just cause the remote to not even answer, and the "connect()" will take a long time to time out. Then it was possible to use ssh:// with a port number: commit 2e7766655abd0312a6bf4db6a6ff141e7e4ac8b6 URL: allow port specification in ssh:// URLs Parsing of the port number was improved here: commit 8f1482536ad680fcd738158e76e254a534f2e690 connect.c: stricter port validation, silence compiler warning Then, it was possible to pass the port number to putty or plink: commit 36ad53ffee6ed5b7c277cde660f526fd8ce3d68f connect.c: Support PuTTY plink and TortoisePlink as SSH on Windows This caused a regression, see below. Later, there was a fix for [] together with a port number: commit 7acf438215d1b0e8e47a707f3585de8486a2e5fe git: Wrong parsing of ssh urls with IPv6 literals ignores port A better way to distinguish "local file system" URLS from scp like URLs, (None of them has a scheme, but they are nice to use) commit 60003340cda05f5ecd79ee8522b21eda038b994b clone: allow cloning local paths with colons in them This fix lead to another regression, which was partly resolved here (And that's where test cases came in) commit 8d3d28f5dba94a15a79975e4adc909c295c80d80 clone: tighten "local paths with colons" check a bit In order to allow diagnostics in the parser, the diag-url feature was added: commit 5610b7c0c6957cf0b236b6fac087c1f4dc209376 git fetch-pack: add --diag-url The the parser was improved: commit 6a59974869c0a6e9399101bc02223b4c00a8aff2 git fetch: support host:/~repo and refactored: commit 83b058752707a6ba4af51ebc98c47913bc7d2d25 git_connect(): refactor the port handling for ssh And more refactored: commit c59ab2e52a64abd7fded97e0983a9b7f3d0508a0 connect.c: refactor url parsing And more refactored: commit a2036d7e00ad8aa16ba010a80078e10f0e4568a3 git_connect(): use common return point Later the parser was improved: commit 86ceb337ec340c7db9b060b90bfab05a08b8251b connect.c: allow ssh://user@[2001:db8::1]/repo.git commit 3f55ccab8e0fec73c8e38b909e9bb4963bfb8f6a t5500: show user name and host in diag-url However, one of the refactoring broke a use case, which was valid before, leading to regressions around the world: commit 6b6c5f7a2f66751a93afce54277a1f30ab0dc521 connect.c: ignore extra colon after hostname Now back to the regression introduced by supporting plink/putty with ports, it was improved by a preparing commit, followed by the fix: commit baaf233755f71c057d28b9e8692e24d4fca7d22f connect: improve check for plink to reduce false positives commit 37ee646e72d7f39d61a538e21a4c2721e32cb444 connect: simplify SSH connection code path Later IPV6/IPV4 only connections had been supported: commit c915f11eb4922e154e29cf62d3b549d65c06a170 connect & http: support -4 and -6 switches for remote operations I skipped the dates and names (I was responsible for one regression) I hope this gives a half-correct overview, why I am reluctant to change any code in connect.c unless there is a fix for a real world problem. And even here, the test cases should be changed first (and reviewed) in an own commit. Marked as test_must_failure. The c-code can be changed in the next commit, and the TC are marked as "test_expect_success" Back to another topic: If you want to support the native Git-support for native HG via hg-serve, I will be happy to assist with reviews. Please, if possible, don't touch connect.c at all. (Besid
[PATCH] t5510: run auto-gc in the foreground
The last test added to 't5510-fetch' in 0898c9628104 (fetch: release pack files before garbage-collecting, 2016-01-13) may sporadically trigger following error message from the test harness: rm: cannot remove 'trash directory.t5510-fetch/auto-gc/.git': Directory not empty The test in question forces an auto-gc, which, if the system supports it, runs in the background by default, and occasionally takes long enough for the test to finish and for 'test_done' to start housekeeping. This can lead to the test's 'git gc --auto' in the background and 'test_done's 'rm -rf $trash' in the foreground racing each other to create and delete files and directories. It might just happen that 'git gc' re-creates a directory that 'rm -rf' already visited and removed, which ultimately triggers the above error. Disable detaching the auto-gc process to ensure that it finishes before the test can continue, thus avoiding this racy situation. Signed-off-by: SZEDER Gábor --- t/t5510-fetch.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 38321d19efbe..454d896390c0 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -682,6 +682,7 @@ test_expect_success 'fetching with auto-gc does not lock up' ' ( cd auto-gc && git config gc.autoPackLimit 1 && + git config gc.autoDetach false && GIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 && ! grep "Should I try again" fetch.out ) -- 2.8.2.356.ge684b1d -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v8 10/10] ce_compare_data() did not respect conversion
On 29.04.16 23:09, Junio C Hamano wrote: > Well, didn't I do exactly the above much earlier and discarded it > because that breaks the definition of "diff"? Or is this doing > something differently? Yes, and I try to sneak it in anyway ;-) I spend some time debugging how to get t6038 passed, and need some more time. If 10/10 is a no-go (and it probably should be), does it make sense to keep 1/10..4/10 and discard 5..10 for the moment ? -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 53/83] builtin/apply: make find_header() return -1 instead of die()ing
On Wed, Apr 27, 2016 at 8:08 PM, Eric Sunshine wrote: > On Sun, Apr 24, 2016 at 9:33 AM, Christian Couder > wrote: >> To be compatible with the rest of the error handling in builtin/apply.c, >> find_header() should return -1 instead of calling die(). >> >> Unfortunately find_header() already returns -1 when no header is found, >> so let's make it return -2 instead in this case. >> >> Signed-off-by: Christian Couder >> --- >> diff --git a/builtin/apply.c b/builtin/apply.c >> @@ -1588,18 +1596,18 @@ static int find_header(struct apply_state *state, >> continue; >> if (!patch->old_name && !patch->new_name) { >> if (!patch->def_name) >> - die(Q_("git diff header lacks >> filename information when removing " >> - "%d leading pathname >> component (line %d)", >> - "git diff header lacks >> filename information when removing " >> - "%d leading pathname >> components (line %d)", >> - state->p_value), >> - state->p_value, state->linenr); >> + return error(Q_("git diff header >> lacks filename information when removing " >> + "%d leading pathname >> component (line %d)", >> + "git diff header >> lacks filename information when removing " >> + "%d leading pathname >> components (line %d)", >> + state->p_value), >> +state->p_value, >> state->linenr); >> patch->old_name = xstrdup(patch->def_name); >> patch->new_name = xstrdup(patch->def_name); >> } >> if (!patch->is_delete && !patch->new_name) >> - die("git diff header lacks filename >> information " >> - "(line %d)", state->linenr); >> + return error("git diff header lacks filename >> information " >> +"(line %d)", state->linenr); > > I realize that the caller in this patch currently just die()'s, and I > haven't looked at subsequent patches yet, but is this new 'return' > going to cause the caller to start leaking patch->old_name and > patch->new_name which are xstrdup()'d just above? I think it is ok because find_header() is called only from parse_chunk() which is only called by apply_patch() and apply_patch() calls "free_patch(patch)" when parse_chunk() returns a negative integer. And free_patch() frees old_name and new_name. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 53/83] builtin/apply: make find_header() return -1 instead of die()ing
On Wed, Apr 27, 2016 at 8:10 PM, Eric Sunshine wrote: > On Mon, Apr 25, 2016 at 9:18 AM, Duy Nguyen wrote: >> On Sun, Apr 24, 2016 at 8:33 PM, Christian Couder >> wrote: >>> To be compatible with the rest of the error handling in builtin/apply.c, >>> find_header() should return -1 instead of calling die(). >>> >>> Unfortunately find_header() already returns -1 when no header is found, >>> so let's make it return -2 instead in this case. >> >> I don't think this is a good way to go. Too many magic numbers. I >> don't have a better option though. Maybe returning names instead of >> numbers would help a bit. > > I suppose 'hdrsize' could signal this extra condition. For instance, > always return -1 on error, and set hdrsize to 0 for header not found > (unless 0 is a valid size?), and -1 for any other error. > > But perhaps that's getting too clever... Yeah, I don't think it would make reading the patch simpler. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 61/83] builtin/apply: libify check_apply_state()
On Mon, Apr 25, 2016 at 3:26 PM, Duy Nguyen wrote: > On Sun, Apr 24, 2016 at 8:34 PM, Christian Couder > wrote: >> Signed-off-by: Christian Couder >> --- >> builtin/apply.c | 16 +--- >> 1 file changed, 9 insertions(+), 7 deletions(-) >> >> diff --git a/builtin/apply.c b/builtin/apply.c >> index e3ee199..7576ec5 100644 >> --- a/builtin/apply.c >> +++ b/builtin/apply.c >> @@ -4534,17 +4534,17 @@ static int option_parse_directory(const struct >> option *opt, >> return 0; >> } >> >> -static void check_apply_state(struct apply_state *state, int force_apply) >> +static int check_apply_state(struct apply_state *state, int force_apply) >> { >> int is_not_gitdir = !startup_info->have_repository; >> >> if (state->apply_with_reject && state->threeway) >> - die("--reject and --3way cannot be used together."); >> + return error("--reject and --3way cannot be used together."); >> if (state->cached && state->threeway) >> - die("--cached and --3way cannot be used together."); >> + return error("--cached and --3way cannot be used together."); > > Sweet opportunity to _() these messages since it clear shows in this > patch that other messages of the same category are _()'d in this > function. Could be done as a separate patch. But I'm also ok if you > say "no". I have added it to my todo list of things that should be done after this series. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
gitk: "lime" color incompatible with older Tk versions
Hi, git folks, I'm having trouble running gitk on Mac OS X 10.9.5. The gitk program uses the color "lime", which is not present in older versions of Tk, apparently including the Tk 8.5 which ships with 10.9. When I try to launch it, I get this error. |$ gitk Error in startup script: unknown color name "lime" (processing "-fore" option) invoked from within "$ctext tag conf m2 -fore [lindex $mergecolors 2]" (procedure "makewindow" line 347) invoked from within "makewindow" (file "/usr/local/bin/gitk" line 12434)| This compatibility problem was noted before back in 2012, in http://www.mail-archive.com/git%40vger.kernel.org/msg14496.html. Would you consider switching from lime to a hex value color, for compatibility with users of older versions of Tk? A patch to do so is below; only the file gitk-git/gitk needs to be changed. Cheers, Andrew Janke diff --git a/gitk-git/gitk b/gitk-git/gitk index 805a1c7..db5560d 100755 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -2265,7 +2265,7 @@ proc makewindow {} { set h [expr {[font metrics uifont -linespace] + 2}] set progresscanv .tf.bar.progress canvas $progresscanv -relief sunken -height $h -borderwidth 2 -set progressitem [$progresscanv create rect -1 0 0 $h -fill lime] +set progressitem [$progresscanv create rect -1 0 0 $h -fill "#99FF00"] set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow] set rprogitem [$progresscanv create rect -1 0 0 $h -fill red] } @@ -3397,7 +3397,7 @@ set rectmask { 0x00, 0x00, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0xfc, 0x0f, 0x00, 0x00}; } -image create bitmap reficon-H -background black -foreground lime \ +image create bitmap reficon-H -background black -foreground "#99FF00" \ -data $rectdata -maskdata $rectmask image create bitmap reficon-o -background black -foreground "#ff" \ -data $rectdata -maskdata $rectmask @@ -12188,7 +12188,7 @@ if {[tk windowingsystem] eq "aqua"} { set extdifftool "meld" } -set colors {lime red blue magenta darkgrey brown orange} +set colors {"#99FF00" red blue magenta darkgrey brown orange} if {[tk windowingsystem] eq "win32"} { set uicolor SystemButtonFace set uifgcolor SystemButtonText @@ -12206,12 +12206,12 @@ if {[tk windowingsystem] eq "win32"} { } set diffcolors {red "#00a000" blue} set diffcontext 3 -set mergecolors {red blue lime purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"} +set mergecolors {red blue "#99FF00" purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"} set ignorespace 0 set worddiff "" set markbgcolor "#e0e0ff" -set headbgcolor lime +set headbgcolor "#99FF00" set headfgcolor black set headoutlinecolor black set remotebgcolor #ffddaa @@ -12226,7 +12226,7 @@ set linehoverfgcolor black set linehoveroutlinecolor black set mainheadcirclecolor yellow set workingfilescirclecolor red -set indexcirclecolor lime +set indexcirclecolor "#99FF00" set circlecolors {white blue gray blue blue} set linkfgcolor blue set circleoutlinecolor $fgcolor -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: pthread_sigmask() on windows (wine actualy)
On Sun, May 01, 2016 at 06:06:07PM +0700, Duy Nguyen wrote: > I got this while compiling master today using mingw32 cross toolchain > > CC run-command.o > run-command.c: In function 'run_thread': > run-command.c:596:3: warning: implicit declaration of function > 'pthread_sigmask' [-Wimplicit-function-declaration] > run-command.c:596:23: error: 'SIG_BLOCK' undeclared (first use in this > function) > run-command.c:596:23: note: each undeclared identifier is reported > only once for each function it appears in > > This is added in c792d7b (run-command: teach async threads to ignore > SIGPIPE - 2016-04-19). From the look of it, wrapping #ifndef > GIT_WINDOWS_NATIVE is probably enough? I checked gfw/master too to see > how gfw deals with it, but the commit has not been merged there yet. I think the fix should go into compat/. See http://git.661346.n2.nabble.com/PATCH-0-5-fix-deadlock-in-git-push-tp7653666p7653818.html (sorry, gmane seems down). -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/41] usage.c: move format processing out of die_errno()
On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy wrote: > fmt_with_err() will be shared with the coming error_errno() and > warning_errno(). > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > diff --git a/usage.c b/usage.c > @@ -109,19 +109,12 @@ void NORETURN die(const char *err, ...) > -void NORETURN die_errno(const char *fmt, ...) > +static const char *fmt_with_err(const char *fmt) > { > - va_list params; > - char fmt_with_err[1024]; > + static char fmt_with_err[1024]; Rather than this static buffer, did you consider having the caller pass in the buffer? static const char *fmt_with_err(char *buf, size_t n, const char *fmt) { ... snprintf(buf, n, "%s: %s", fmt, str_error); return buf; } void die_errno(const char *fmt, ...) { char fmtbuf[1024]; ... die_routine(fmt_with_err(fmtbuf, sizeof(fmtbuf), fmt), params); ... } Better? Worse? Indifferent? > char str_error[256], *err; > int i, j; > > - if (die_is_recursing()) { > - fputs("fatal: recursion detected in die_errno handler\n", > - stderr); > - exit(128); > - } > - > err = strerror(errno); > for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) { > if ((str_error[j++] = err[i++]) != '%') > @@ -137,9 +130,21 @@ void NORETURN die_errno(const char *fmt, ...) > } > str_error[j] = 0; > snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, > str_error); > + return fmt_with_err; > +} > + > +void NORETURN die_errno(const char *fmt, ...) > +{ > + va_list params; > + > + if (die_is_recursing()) { > + fputs("fatal: recursion detected in die_errno handler\n", > + stderr); > + exit(128); > + } > > va_start(params, fmt); > - die_routine(fmt_with_err, params); > + die_routine(fmt_with_err(fmt), params); > va_end(params); > } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 08/41] builtin/mailsplit.c: use error_errno()
On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c > @@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list > *list, const char *path) > if ((dir = opendir(name)) == NULL) { > if (errno == ENOENT) > continue; > - error("cannot opendir %s (%s)", name, > strerror(errno)); > + error_errno("cannot opendir %s", name); > goto out; > } > @@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, > int allow_bare, > int file_done = 0; > > if (!f) { > - error("cannot open mbox %s", file); > + error_errno("cannot open mbox %s", file); Unlike other cases in this patch which already printed strerror(errno), this one didn't, and the patch upgrades it to do so, which is valid since errno will not be clobbered between the preceding fopen() and this error_errno(). I see other patches in the series do likewise. The error("cannot read mbox %s"" just below this code doesn't deserve the same treatment because strbuf_getwholeline() doesn't promise a meaningful errno. Okay. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 63/83] builtin/apply: make apply_all_patches() return -1 on error
On Mon, Apr 25, 2016 at 3:30 PM, Duy Nguyen wrote: > On Sun, Apr 24, 2016 at 8:34 PM, Christian Couder > wrote: >> if (state->update_index) { >> if (write_locked_index(&the_index, state->lock_file, >> COMMIT_LOCK)) >> - die(_("Unable to write new index file")); >> + return error(_("Unable to write new index file")); >> } >> >> return !!errs; >> @@ -4698,5 +4698,8 @@ int cmd_apply(int argc, const char **argv, const char >> *prefix) >> if (check_apply_state(&state, force_apply)) >> exit(1); >> >> - return apply_all_patches(&state, argc, argv, options); >> + if (apply_all_patches(&state, argc, argv, options)) >> + exit(1); > > Abusing exit() too much? This is cmd_apply(). A return should be > enough and you can do the !! trick that is used in > apply_all_patches(), shown just a little bit above. Ok, I will use: return !!apply_all_patches(&state, argc, argv, options); Thanks, Christian. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/41] builtin/update-index.c: use error_errno()
On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy wrote: > "err" is deleted because it just causes confusion when "errno" is also > used directly in process_lstat_error(). Despite the function name which may imply that it is consulting errno, this change makes me feel slightly uncomfortable since it increases coupling. Whereas consulting of errno had been explicit, with this change, it becomes implicit, and someone changing the code needs to be extra careful about ensuring that errno does not get clobbered. Not a big objection, but a nagging doubt... > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > diff --git a/builtin/update-index.c b/builtin/update-index.c > @@ -251,11 +251,11 @@ static int remove_one_path(const char *path) > -static int process_lstat_error(const char *path, int err) > +static int process_lstat_error(const char *path) > { > - if (err == ENOENT || err == ENOTDIR) > + if (errno == ENOENT || errno == ENOTDIR) > return remove_one_path(path); > - return error("lstat(\"%s\"): %s", path, strerror(errno)); > + return error_errno("lstat(\"%s\")", path); > } > > static int add_one_path(const struct cache_entry *old, const char *path, int > len, struct stat *st) > @@ -382,7 +382,7 @@ static int process_path(const char *path) > * what to do about the pathname! > */ > if (lstat(path, &st) < 0) > - return process_lstat_error(path, errno); > + return process_lstat_error(path); > > if (S_ISDIR(st.st_mode)) > return process_directory(path, len, &st); -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 17/41] compat/win32/syslog.c: use warning_errno()
On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c > @@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...) > va_end(ap); > > if (str_len < 0) { > - warning("vsnprintf failed: '%s'", strerror(errno)); > + warning_errno("vsnprintf failed:"); s/failed:/failed/ > return; > } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 27/41] grep.c: use error_errno()
On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > diff --git a/grep.c b/grep.c > @@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs) > if (lstat(filename, &st) < 0) { > err_ret: > if (errno != ENOENT) > - error(_("'%s': %s"), filename, strerror(errno)); > + error_errno(_("'%s'"), filename); Does this still need to be wrapped in _(...)? (Did it ever?) > return -1; > } > if (!S_ISREG(st.st_mode)) > @@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs) > goto err_ret; > data = xmallocz(size); > if (st.st_size != read_in_full(i, data, size)) { > - error(_("'%s': short read %s"), filename, strerror(errno)); > + error_errno(_("'%s': short read"), filename); > close(i); > free(data); > return -1; -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 54/83] builtin/apply: make parse_chunk() return a negative integer on error
On Sun, Apr 24, 2016 at 9:33 AM, Christian Couder wrote: > This negative number can be -2 if no patch header has been found, > otherwise it is -1. > > As parse_chunk() is called only by apply_patch() which already > returns -1 when an error happened, let's make it return -1 when > parse_chunk() returns -1. > > Signed-off-by: Christian Couder > --- > diff --git a/builtin/apply.c b/builtin/apply.c > @@ -4566,6 +4567,8 @@ static int apply_patch(struct apply_state *state, > nr = parse_chunk(state, buf.buf + offset, buf.len - offset, > patch); > if (nr < 0) { > free_patch(patch); > + if (nr == -1) > + return -1; Same comment as 51/83 about this leaking 'list', 'buf', and 'fn_table'. > break; > } > if (state->apply_in_reverse) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH jk/push-client-deadlock-fix] Windows: add pthread_sigmask() that does nothing
A previous change introduced a call to pthread_sigmask() in order to block SIGPIPE in a thread. Since there are no signal facilities on Windows that are similar to POSIX signals, just ignore the request to block the signal. In the particular case, the effect of blocking SIGPIPE on POSIX is that write() calls return EPIPE when the reader closes the pipe. This is how write() behaves on Windows. Signed-off-by: Johannes Sixt --- compat/mingw.h | 1 + compat/win32/pthread.h | 5 + 2 files changed, 6 insertions(+) diff --git a/compat/mingw.h b/compat/mingw.h index a950ae2..0f272fd 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -142,6 +142,7 @@ static inline int fcntl(int fd, int cmd, ...) #define sigemptyset(x) (void)0 static inline int sigaddset(sigset_t *set, int signum) { return 0; } +#define SIG_BLOCK 0 #define SIG_UNBLOCK 0 static inline int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) { return 0; } diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h index b6ed9e7..d336451 100644 --- a/compat/win32/pthread.h +++ b/compat/win32/pthread.h @@ -104,4 +104,9 @@ static inline void *pthread_getspecific(pthread_key_t key) return TlsGetValue(key); } +static inline int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) +{ + return 0; +} + #endif /* PTHREAD_H */ -- 2.7.0.118.g90056ae -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 65/83] builtin/apply: make gitdiff_verify_name() return -1 on error
On Mon, Apr 25, 2016 at 3:36 PM, Duy Nguyen wrote: > On Sun, Apr 24, 2016 at 8:34 PM, Christian Couder > wrote: >> Signed-off-by: Christian Couder >> --- >> builtin/apply.c | 52 ++-- >> 1 file changed, 30 insertions(+), 22 deletions(-) >> >> diff --git a/builtin/apply.c b/builtin/apply.c >> index 6b8ba2a..268356b 100644 >> --- a/builtin/apply.c >> +++ b/builtin/apply.c >> @@ -812,7 +812,7 @@ static int gitdiff_hdrend(struct apply_state *state, >> const char *line, >> struct patch *patch) >> { >> - return -1; >> + return 1; >> } > > These are in a function group that will be called as p->fn() in > parse_git_header(). Is it possible to isolate them in a separate > patch? This patch can follow after, which covers only > gitdiff_verify_name() returning -1 and its call sites. Yeah, I had planned to do something like that when developing the series but I forgot. Thanks, Christian. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 55/83] builtin/apply: make parse_single_patch() return -1 on error
On Sun, Apr 24, 2016 at 9:33 AM, Christian Couder wrote: > Signed-off-by: Christian Couder > --- > diff --git a/builtin/apply.c b/builtin/apply.c > @@ -1802,8 +1806,10 @@ static int parse_single_patch(struct apply_state > *state, > fragment = xcalloc(1, sizeof(*fragment)); > fragment->linenr = state->linenr; > len = parse_fragment(state, line, size, patch, fragment); > - if (len <= 0) > - die(_("corrupt patch at line %d"), state->linenr); > + if (len <= 0) { > + free(fragment); > + return error(_("corrupt patch at line %d"), > state->linenr); No fragment leak here, okay. > + } > fragment->patch = line; > fragment->size = len; > oldlines += fragment->oldlines; > @@ -1839,9 +1845,9 @@ static int parse_single_patch(struct apply_state *state, > patch->is_delete = 0; > > if (0 < patch->is_new && oldlines) > - die(_("new file %s depends on old contents"), > patch->new_name); > + return error(_("new file %s depends on old contents"), > patch->new_name); > if (0 < patch->is_delete && newlines) > - die(_("deleted file %s still has contents"), patch->old_name); > + return error(_("deleted file %s still has contents"), > patch->old_name); These two return -1 and don't manually release the fragments, which might seem like a leak, however... > if (!patch->is_delete && !newlines && context) > fprintf_ln(stderr, >_("** warning: " > @@ -2143,6 +2149,9 @@ static int parse_chunk(struct apply_state *state, char > *buffer, unsigned long si >size - offset - hdrsize, >patch); > > + if (patchsize < 0) > + return -1; This forwards -1 to its caller, and the caller, apply_patch() does release the fragments when it sees -1, so there does not seem to be any (new) leak. Good. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 59/83] builtin/apply: move init_apply_state() to apply.c
On Sun, Apr 24, 2016 at 9:33 AM, Christian Couder wrote: > Signed-off-by: Christian Couder > --- > diff --git a/apply.c b/apply.c > @@ -0,0 +1,80 @@ > +#include "cache.h" > +#include "apply.h" > + > + > + Too many blank lines? > +static void git_apply_config(void) > +{ > + git_config_get_string_const("apply.whitespace", > &apply_default_whitespace); > + git_config_get_string_const("apply.ignorewhitespace", > &apply_default_ignorewhitespace); > + git_config(git_default_config, NULL); > +} -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 54/83] builtin/apply: make parse_chunk() return a negative integer on error
On Sun, May 1, 2016 at 9:04 PM, Eric Sunshine wrote: > On Sun, Apr 24, 2016 at 9:33 AM, Christian Couder > wrote: >> This negative number can be -2 if no patch header has been found, >> otherwise it is -1. >> >> As parse_chunk() is called only by apply_patch() which already >> returns -1 when an error happened, let's make it return -1 when >> parse_chunk() returns -1. >> >> Signed-off-by: Christian Couder >> --- >> diff --git a/builtin/apply.c b/builtin/apply.c >> @@ -4566,6 +4567,8 @@ static int apply_patch(struct apply_state *state, >> nr = parse_chunk(state, buf.buf + offset, buf.len - offset, >> patch); >> if (nr < 0) { >> free_patch(patch); >> + if (nr == -1) >> + return -1; > > Same comment as 51/83 about this leaking 'list', 'buf', and 'fn_table'. Ok, thanks! -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 59/83] builtin/apply: move init_apply_state() to apply.c
On Sun, May 1, 2016 at 9:37 PM, Eric Sunshine wrote: > On Sun, Apr 24, 2016 at 9:33 AM, Christian Couder > wrote: >> Signed-off-by: Christian Couder >> --- >> diff --git a/apply.c b/apply.c >> @@ -0,0 +1,80 @@ >> +#include "cache.h" >> +#include "apply.h" >> + >> + >> + > > Too many blank lines? Ok, I will remove 2 of them. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 63/83] builtin/apply: make apply_all_patches() return -1 on error
On Sun, Apr 24, 2016 at 9:34 AM, Christian Couder wrote: > Signed-off-by: Christian Couder > --- > diff --git a/builtin/apply.c b/builtin/apply.c > @@ -4562,12 +4562,12 @@ static int apply_all_patches(struct apply_state > *state, > > fd = open(arg, O_RDONLY); > if (fd < 0) > - die_errno(_("can't open patch '%s'"), arg); > + return error(_("can't open patch '%s': %s"), arg, > strerror(errno)); > read_stdin = 0; > set_default_whitespace_mode(state); > res = apply_patch(state, fd, arg, options); > if (res < 0) > - exit(1); > + return -1; This leaks 'fd', doesn't it? > errs |= res; > close(fd); > } > @@ -4590,10 +4590,10 @@ static int apply_all_patches(struct apply_state > *state, > squelched); > } > if (state->ws_error_action == die_on_ws_error) > - die(Q_("%d line adds whitespace errors.", > - "%d lines add whitespace errors.", > - state->whitespace_error), > - state->whitespace_error); > + return error(Q_("%d line adds whitespace errors.", > + "%d lines add whitespace errors.", > + state->whitespace_error), > +state->whitespace_error); How does this new 'return' relate to the logic below which updates the index? Does the index need to be updated here now too? > if (state->applied_after_fixing_ws && state->apply) > warning("%d line%s applied after" > " fixing whitespace errors.", > @@ -4608,7 +4608,7 @@ static int apply_all_patches(struct apply_state *state, > > if (state->update_index) { > if (write_locked_index(&the_index, state->lock_file, > COMMIT_LOCK)) > - die(_("Unable to write new index file")); > + return error(_("Unable to write new index file")); > } > > return !!errs; > @@ -4698,5 +4698,8 @@ int cmd_apply(int argc, const char **argv, const char > *prefix) > if (check_apply_state(&state, force_apply)) > exit(1); > > - return apply_all_patches(&state, argc, argv, options); > + if (apply_all_patches(&state, argc, argv, options)) > + exit(1); > + > + return 0; > } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] connect: remove get_port()
On Sun, May 01, 2016 at 12:10:09PM +0200, Torsten Bögershausen wrote: > On 2016-05-01 08.02, Mike Hommey wrote: > > get_port() is only used as a fallback when get_host_and_port() does not > > return a port. But get_port() does the same search as > > get_host_and_port(), except get_host_and_port() starts from the end of > > the host, respecting square brackets for ipv6 addresses, and get_port(), > > operating after get_host_and_port(), works on a modified host string > > that has square brackes removed if there were any. > typo: brackets. > > > > I cannot think of any legal host:port string that would not have a port > > returned by get_host_and_port() *and* have one returned by get_port(). > > So just remove get_port(). > > > > Signed-off-by: Mike Hommey > Does this pass the test-suite ? > It doesn't pass here, t5601: > > not ok 39 - bracketed hostnames are still ssh > # > # git clone "[myhost:123]:src" ssh-bracket-clone && > # expect_ssh "-p 123" myhost src > # > not ok 40 - uplink is not treated as putty > # > # copy_ssh_wrapper_as "$TRASH_DIRECTORY/uplink" && > # git clone "[myhost:123]:src" ssh-bracket-clone-uplink && > # expect_ssh "-p 123" myhost src > # > not ok 41 - plink is treated specially (as putty) > # > # copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" && > # git clone "[myhost:123]:src" ssh-bracket-clone-plink-0 && > # expect_ssh "-P 123" myhost src > # > not ok 42 - plink.exe is treated specially (as putty) > # > # copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" && > # git clone "[myhost:123]:src" ssh-bracket-clone-plink-1 && > # expect_ssh "-P 123" myhost src > # > not ok 43 - tortoiseplink is like putty, with extra arguments > sigh. I was assuming all the relevant cases were tested in t5500, but apparently they aren't. Mike -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git-stash: add flag to skip "git reset --hard"
Add the "--no-reset" (same as "-r") flag to git-stash.sh. A common workflow is to use "git-stash save" and "git-stash apply" to save your work without modifying your changed files. This forces users to reload their changed files in text editors like emacs, and touches the modify time on all changed files, potentially making incremental builds slower if many files in the build depend on your changed files. Add documentation in Documentation/git-stash.txt and tests in t/t3903-stash.sh. Signed-off-by: Thomas Anderson --- Documentation/git-stash.txt | 9 ++--- git-stash.sh| 15 ++- t/t3903-stash.sh| 27 +++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 92df596..ba5ecf2 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -13,8 +13,8 @@ SYNOPSIS 'git stash' drop [-q|--quiet] [] 'git stash' ( pop | apply ) [--index] [-q|--quiet] [] 'git stash' branch [] -'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] -[-u|--include-untracked] [-a|--all] []] +'git stash' [save [-p|--patch] [-r|--no-reset] [-k|--[no-]keep-index] +[-q|--quiet] [-u|--include-untracked] [-a|--all] []] 'git stash' clear 'git stash' create [] 'git stash' store [-m|--message ] [-q|--quiet] @@ -44,7 +44,7 @@ is also possible). OPTIONS --- -save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] []:: +save [-p|--patch] [-r|--no-reset] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] []:: Save your local modifications to a new 'stash', and run `git reset --hard` to revert them. The part is optional and gives @@ -61,6 +61,9 @@ stashed and then cleaned up with `git clean`, leaving the working directory in a very clean state. If the `--all` option is used instead then the ignored files are stashed and cleaned in addition to the untracked files. + +If the `--no-reset` option is used, `git reset --hard` is skipped and the +`--[no-]keep-index`, `--include-untracked`, and `--all` flags are ignored. ++ With `--patch`, you can interactively select hunks from the diff between HEAD and the working tree to be stashed. The stash entry is constructed such that its index state is the same as the index state diff --git a/git-stash.sh b/git-stash.sh index c7c65e2..aebebb0 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -7,8 +7,9 @@ USAGE="list [] or: $dashless drop [-q|--quiet] [] or: $dashless ( pop | apply ) [--index] [-q|--quiet] [] or: $dashless branch [] - or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] - [-u|--include-untracked] [-a|--all] []] + or: $dashless [save [--patch] [-r|--no-reset] [-k|--[no-]keep-index] + [-q|--quiet] [-u|--include-untracked] [-a|--all] + []] or: $dashless clear" SUBDIRECTORY_OK=Yes @@ -194,9 +195,13 @@ save_stash () { keep_index= patch_mode= untracked= + no_reset= while test $# != 0 do case "$1" in + -r|--no-reset) + no_reset=t + ;; -k|--keep-index) keep_index=t ;; @@ -268,7 +273,7 @@ save_stash () { die "$(gettext "Cannot save the current status")" say Saved working directory and index state "$stash_msg" - if test -z "$patch_mode" + if test -z "$patch_mode" -a -z "$no_reset" then git reset --hard ${GIT_QUIET:+-q} test "$untracked" = "all" && CLEAN_X_OPTION=-x || CLEAN_X_OPTION= @@ -276,12 +281,12 @@ save_stash () { then git clean --force --quiet -d $CLEAN_X_OPTION fi - if test "$keep_index" = "t" && test -n $i_tree then git read-tree --reset -u $i_tree fi - else + elif -n "$patch_mode" + then git apply -R < "$TMP-patch" || die "$(gettext "Cannot remove worktree changes")" diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 2142c1f..3eba19a 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -248,6 +248,33 @@ test_expect_success 'stash --no-keep-index' ' test bar,bar2 = $(cat file),$(cat file2) ' +test_expect_success 'stash -r' ' + git reset && + echo foo420 > file && + echo bar420 > file2 && + git add file2 && + git stash -r && + test foo420,bar420 = $(cat file),$(cat file2) +' + +test_expect_success 'stash --no-reset' ' + git reset && + echo bar33 > file && + echo bar44 > file2 && + git add file2 && + git stash --no-reset && + test bar33,bar44 = $(cat file),$(cat file2) +' + +test_expect_success 'stash
Re: [PATCH 2/6] connect: uniformize and group CONNECT_DIAG_URL handling code
On Sun, May 01, 2016 at 03:37:24PM +0200, Torsten Bögershausen wrote: > I skipped the dates and names (I was responsible for one regression) > I hope this gives a half-correct overview, > why I am reluctant to change any code in connect.c > unless there is a fix for a real world problem. I don't agree that connect.c should be left untouched because it's fragile. On the contrary, if anything, it should be made less fragile. And the more I look at it, the more I'm tempted to just change the parse_connect_url function itself to do _all_ the parsing, instead of having some code paths invoke get_host_and_port and some others invoke get_port on top of that, for some effect that, when you look at the code, you can't know what it's supposed to be. If anything, my attempts at cleaning up the code, and partially failing are a demonstration that the code *does* need some clean up. > And even here, the test cases should be changed first (and reviewed) in an > own commit. > Marked as test_must_failure. > The c-code can be changed in the next commit, and the TC are marked as > "test_expect_success" What is the benefit from doing so? > Back to another topic: > If you want to support the native Git-support for native HG via hg-serve, > I will be happy to assist with reviews. > Please, if possible, don't touch connect.c at all. > (Beside the memory leak fix). > > It may be better to start with a real remote-helper and copy the code from > connect.c > And, later, if there are common code paths, refactor stuff. There *are* common code paths. Which is exactly why I'm trying to reuse connect.c without copying it. Mike -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/6] connect: uniformize and group CONNECT_DIAG_URL handling code
On 05/01/2016 08:02 AM, Mike Hommey wrote: + if (flags & CONNECT_DIAG_URL) { printf("Diag: url=%s\n", url ? url : "NULL"); printf("Diag: protocol=%s\n", prot_name(protocol)); printf("Diag: hostandport=%s\n", hostandport ? hostandport : "NULL"); + printf("Diag: userandhost=%s\n", host ? host : "NULL"); + printf("Diag: port=%s\n", port ? port : "NONE"); printf("Diag: path=%s\n", path ? path : "NULL"); conn = NULL; Does it make sense to write the host twice? If things are cleaned up, would something like this make sense ? printf("Diag: url=%s\n", url ? url : "NULL"); printf("Diag: protocol=%s\n", prot_name(protocol)); printf("Diag: user=%s\n", user ? user : "NULL"); printf("Diag: host=%s\n", host ? host : "NULL"); printf("Diag: port=%s\n", port ? port : "NONE"); printf("Diag: path=%s\n", path ? path : "NULL"); or printf("Diag: url=%s\n", url ? url : "NULL"); printf("Diag: protocol=%s\n", prot_name(protocol)); if (user) printf("Diag: user=%s\n", user); printf("Diag: host=%s\n", host ? host : "NULL"); printf("Diag: port=%s\n", port ? port : "NONE"); printf("Diag: path=%s\n", path ? path : "NULL"); -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] git-stash: Don't GPG sign when stashing changes
On 15 April 2016 at 01:50, Johannes Schindelin wrote: > Hi Cameron, > > On Wed, 13 Apr 2016, Cameron Currie wrote: > >> > > On Thu, 7 Apr 2016, daurnimator wrote: >> > > >> > >> Cameron Currie cameroncurrie.net> writes: >> > >> > This is helpful for folks with commit.gpgsign = true in their >> > >> > .gitconfig. >> > >> >> > >> > https://github.com/git/git/pull/186 >> > >> >> > >> I too would like this. >> > >> Bumping due to lack of attention. >> > > >> > > It lacks a Sign-off, our convention is to continue in lower-case >> > > after the colon in the commit's subject, and I think that it would >> > > be good to write so much as one paragraph in the commit message. >> >> I don't think I can find the time right now. Feel free to rewrite the >> commit message to match convention. > > I am afraid that it would be improper for anybody to add your Sign-off, as > it is *your* statement that you are indeed contributing this as Open > Source, and that you indeed are free to do so. > > If you do not find the time to take care of these small changes, I fear > the Git maintainer will *have* to drop your patch to avoid hassle for > himself. > > Ciao, > Johannes Cameron, could you please add a sign off to your commit? It should be as simple as running `git commit --amend -s` -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] git-prompt: make colors available in custom prompts
Hi Andrew sorry, I only noticed your request this morning... On 22/04/16 07:00, Andrew Schwartzmeyer wrote: This was disabled in the original implementation, probably because it does not work if the __git_ps1 function is single-quoted. However, if you double-quote per the updated documentation, you can have colors in your custom Git prompt function, no problem. Signed-off-by: Andrew Schwartzmeyer --- contrib/completion/git-prompt.sh | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index f18aedc73..ffe79168c 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -12,8 +12,8 @@ #source ~/.git-prompt.sh #3a) Change your PS1 to call __git_ps1 as #command-substitution: -#Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' -#ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' +#Bash: PS1="[\u@\h \W$(__git_ps1 ' (%s)')]\$ " +#ZSH: setopt PROMPT_SUBST ; PS1="[%n@%m %c$(__git_ps1 ' (%s)')]\$ " I haven't tested this at all, but when using double quotes, you need to at least check all the escapings, like \$ should probably be: \\\$ when used in double quotes. #the optional argument will be used as format string. #3b) Alternatively, for a slightly faster prompt, __git_ps1 can #be used for PROMPT_COMMAND in Bash or for precmd() in Zsh @@ -82,8 +82,9 @@ # # If you would like a colored hint about the current dirty state, set # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on -# the colored output of "git status -sb" and are available only when -# using __git_ps1 for PROMPT_COMMAND or precmd. +# the colored output of "git status -sb". If you are using your own +# PROMPT_COMMAND function, you must use double-quotes when calling +# __git_ps1, e.g. PS1="$(__git_ps1 '%s ')". # # If you would like __git_ps1 to do nothing in the case when the current # directory is set up to be ignored by git, then set @@ -499,8 +500,7 @@ __git_ps1 () local z="${GIT_PS1_STATESEPARATOR-" "}" - # NO color option unless in PROMPT_COMMAND mode - if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then + if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then __git_ps1_colorize_gitstring fi The original reason for not using colors in command substitution mode was that the prompt string length was not calculated correctly by bash and it messed up the commandline with very long commands (relative to the terminal width), when browsing the command history. However I think I've seen this effect even with the new code, but I've never dug into this. Cheers Simon -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html