[PATCH] Let index-pack help with connectivity check on cloning via smart http
This is an extension of c6807a4 (clone: open a shortcut for connectivity check - 2013-05-26) to reduce the cost of connectivity check at clone time, this time with smart http protocol. Signed-off-by: Nguyễn Thái Ngọc Duy --- Documentation/git-fetch-pack.txt| 4 Documentation/gitremote-helpers.txt | 10 ++ builtin/fetch-pack.c| 9 + remote-curl.c | 15 ++- transport-helper.c | 10 ++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt index 1e71754..444b805 100644 --- a/Documentation/git-fetch-pack.txt +++ b/Documentation/git-fetch-pack.txt @@ -90,6 +90,10 @@ be in a separate packet, and the list must end with a flush packet. --no-progress:: Do not show the progress. +--check-self-contained-and-connected:: + Output "connectivity-ok" if the received pack is + self-contained and connected. + -v:: Run verbosely. diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt index 0827f69..bc069c2 100644 --- a/Documentation/gitremote-helpers.txt +++ b/Documentation/gitremote-helpers.txt @@ -143,6 +143,10 @@ Supported commands: 'list', 'fetch'. + Supported commands: 'list', 'import'. +'check-connectivity':: + Can guarantee that when a clone is requested, the received + pack is self contained and is connected. + If a helper advertises 'connect', Git will use it if possible and fall back to another capability if the helper requests so when connecting (see the 'connect' command under COMMANDS). @@ -270,6 +274,9 @@ Optionally may output a 'lock ' line indicating a file under GIT_DIR/objects/pack which is keeping a pack until refs can be suitably updated. + +If option 'check-connectivity' is requested, the helper must output +'connectivity-ok' if the clone is self-contained and connected. ++ Supported if the helper has the "fetch" capability. 'push' +::: @@ -416,6 +423,9 @@ set by Git if the remote helper has the 'option' capability. must not rely on this option being set before connect request occurs. +'option check-connectivity' \{'true'|'false'\}:: + Request the helper to check connectivity of a clone. + SEE ALSO linkgit:git-remote[1] diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index aba4465..3e19d71 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -100,6 +100,10 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) pack_lockfile_ptr = &pack_lockfile; continue; } + if (!strcmp("--check-self-contained-and-connected", arg)) { + args.check_self_contained_and_connected = 1; + continue; + } usage(fetch_pack_usage); } @@ -152,6 +156,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) printf("lock %s\n", pack_lockfile); fflush(stdout); } + if (args.check_self_contained_and_connected && + args.self_contained_and_connected) { + printf("connectivity-ok\n"); + fflush(stdout); + } close(fd[0]); close(fd[1]); if (finish_connect(conn)) diff --git a/remote-curl.c b/remote-curl.c index 5b3ce9e..6918668 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -16,6 +16,7 @@ struct options { int verbosity; unsigned long depth; unsigned progress : 1, + check_self_contained_and_connected : 1, followtags : 1, dry_run : 1, thin : 1; @@ -67,6 +68,15 @@ static int set_option(const char *name, const char *value) return -1; return 0; } + else if (!strcmp(name, "check-connectivity")) { + if (!strcmp(value, "true")) + options.check_self_contained_and_connected = 1; + else if (!strcmp(value, "false")) + options.check_self_contained_and_connected = 0; + else + return -1; + return 0; + } else { return 1 /* unsupported */; } @@ -654,7 +664,7 @@ static int fetch_git(struct discovery *heads, struct strbuf preamble = STRBUF_INIT; char *depth_arg = NULL; int argc = 0, i, err; - const char *argv[15]; + const char *argv[16]; argv[argc++] = "fetch-pack"; argv[argc++] = "--stateless-rpc"; @@ -668,6 +678,8 @@ static int fetch_git(struct discovery *heads, argv[argc++] = "-v"; argv[argc++] = "-v"; } + if (options.check_self_contained_and_connected) + argv[argc++] = "--check-self-contained-and-connected"; if (!
[PATCH v3 3/5] contrib: contacts: interpret committish akin to format-patch
As a convenience, accept the same style committish as accepted by git-format-patch. For example: % git contacts origin will consider commits in the current branch built atop 'origin', just as "git format-patch origin" will format commits built atop 'origin'. Signed-off-by: Eric Sunshine --- contrib/contacts/git-contacts | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts index 1686ff3..4553add 100755 --- a/contrib/contacts/git-contacts +++ b/contrib/contacts/git-contacts @@ -102,9 +102,26 @@ sub scan_patch_file { close $f; } +sub parse_rev_args { + my @args = @_; + open my $f, '-|', + qw(git rev-parse --revs-only --default HEAD --symbolic), @args + or die; + my @revs; + while (<$f>) { + chomp; + push @revs, $_; + } + close $f; + return @revs if scalar(@revs) != 1; + return "^$revs[0]", 'HEAD' unless $revs[0] =~ /^-/; + return $revs[0], 'HEAD'; +} + sub scan_rev_args { my ($commits, $args) = @_; - open my $f, '-|', qw(git rev-list --reverse), @$args or die; + my @revs = parse_rev_args(@$args); + open my $f, '-|', qw(git rev-list --reverse), @revs or die; while (<$f>) { chomp; my $id = $_; -- 1.8.3.3.803.gd114dc6 -- 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 v3 5/5] contrib: contacts: add documentation
Assuming that git-contacts may some day be promoted to a core git command, the documentation is written and formatted as if it already belongs in Documentation/ even though it presently resides in contrib/contacts. Signed-off-by: Eric Sunshine --- contrib/contacts/git-contacts.txt | 94 +++ 1 file changed, 94 insertions(+) create mode 100644 contrib/contacts/git-contacts.txt diff --git a/contrib/contacts/git-contacts.txt b/contrib/contacts/git-contacts.txt new file mode 100644 index 000..dd914d1 --- /dev/null +++ b/contrib/contacts/git-contacts.txt @@ -0,0 +1,94 @@ +git-contacts(1) +=== + +NAME + +git-contacts - List people who might be interested in a set of changes + + +SYNOPSIS + +[verse] +'git contacts' (||)... + + +DESCRIPTION +--- + +Given a set of changes, specified as patch files or revisions, determine people +who might be interested in those changes. This is done by consulting the +history of each patch or revision hunk to find people mentioned by commits +which touched the lines of files under consideration. + +Input consists of one or more patch files or revision arguments. A revision +argument can be a range or a single `` which is interpreted as +`..HEAD`, thus the same revision arguments are accepted as for +linkgit:git-format-patch[1]. Patch files and revision arguments can be combined +in the same invocation. + +This command can be useful for determining the list of people with whom to +discuss proposed changes, or for finding the list of recipients to Cc: when +submitting a patch series via `git send-email`. For the latter case, `git +contacts` can be used as the argument to `git send-email`'s `--cc-cmd` option. + + +DISCUSSION +-- + +`git blame` is invoked for each hunk in a patch file or revision. For each +commit mentioned by `git blame`, the commit message is consulted for people who +authored, reviewed, signed, acknowledged, or were Cc:'d. Once the list of +participants is known, each person's relevance is computed by considering how +many commits mentioned that person compared with the total number of commits +under consideration. The final output consists only of participants who exceed +a minimum threshold of participation. + + +OUTPUT +-- + +For each person of interest, a single line is output, terminated by a newline. +If the person's name is known, ``Name '' is printed; otherwise +only ``'' is printed. + + +EXAMPLES + + +* Consult patch files: ++ + +$ git contacts feature/*.patch + + +* Revision range: ++ + +$ git contacts R1..R2 + + +* From a single revision to `HEAD`: ++ + +$ git contacts origin + + +* Helper for `git send-email`: ++ + +$ git send-email --cc-cmd='git contacts' feature/*.patch + + + +LIMITATIONS +--- + +Several conditions controlling a person's significance are currently +hard-coded, such as minimum participation level (10%), blame date-limiting (5 +years), and `-C` level for detecting moved and copied lines (a single `-C`). In +the future, these conditions may become configurable. + + +GIT +--- +Part of the linkgit:git[1] suite -- 1.8.3.3.803.gd114dc6 -- 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 v3 2/5] contrib: contacts: add ability to parse from committish
For example: % git contacts R1..R2 Committishes and patch files can be mentioned in the same invocation: % git contacts R1..R2 extra/*.patch Signed-off-by: Eric Sunshine --- contrib/contacts/git-contacts | 38 -- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts index 3e6cce8..1686ff3 100755 --- a/contrib/contacts/git-contacts +++ b/contrib/contacts/git-contacts @@ -3,7 +3,7 @@ # List people who might be interested in a patch. Useful as the argument to # git-send-email --cc-cmd option, and in other situations. # -# Usage: git contacts ... +# Usage: git contacts ... use strict; use warnings; @@ -77,8 +77,8 @@ sub get_blame { } sub scan_patches { - my ($commits, $f) = @_; - my ($id, $source); + my ($commits, $id, $f) = @_; + my $source; while (<$f>) { if (/^From ([0-9a-f]{40}) Mon Sep 17 00:00:00 2001$/) { $id = $1; @@ -98,18 +98,44 @@ sub scan_patches { sub scan_patch_file { my ($commits, $file) = @_; open my $f, '<', $file or die "read failure: $file: $!\n"; - scan_patches($commits, $f); + scan_patches($commits, undef, $f); + close $f; +} + +sub scan_rev_args { + my ($commits, $args) = @_; + open my $f, '-|', qw(git rev-list --reverse), @$args or die; + while (<$f>) { + chomp; + my $id = $_; + $seen{$id} = 1; + open my $g, '-|', qw(git show -C --oneline), $id or die; + scan_patches($commits, $id, $g); + close $g; + } close $f; } if (!@ARGV) { - die "No input patch files\n"; + die "No input revisions or patch files\n"; } -my %commits; +my (@files, @rev_args); for (@ARGV) { + if (-e) { + push @files, $_; + } else { + push @rev_args, $_; + } +} + +my %commits; +for (@files) { scan_patch_file(\%commits, $_); } +if (@rev_args) { + scan_rev_args(\%commits, \@rev_args) +} import_commits(\%commits); my $contacts = {}; -- 1.8.3.3.803.gd114dc6 -- 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 v3 1/5] contrib: add git-contacts helper
This script lists people that might be interested in a patch by going back through the history for each patch hunk, and finding people that reviewed, acknowledged, signed, authored, or were Cc:'d on the code the patch is modifying. It does this by running git-blame incrementally on each hunk and then parsing the commit message. After gathering all participants, it determines each person's relevance by considering how many commits mentioned that person compared with the total number of commits under consideration. The final output consists only of participants who pass a minimum threshold of participation. Several conditions controlling a person's significance are currently hard-coded, such as minimum participation level, blame date-limiting, and -C level for detecting moved and copied lines. In the future, these conditions may become configurable. For example: % git contacts 0001-remote-hg-trivial-cleanups.patch Felipe Contreras Jeff King Max Horn Junio C Hamano Thus, it can be invoked as git-send-email's --cc-cmd option, among other possible uses. This is a Perl rewrite of Felipe Contreras' git-related patch series[1] written in Ruby. [1]: http://thread.gmane.org/gmane.comp.version-control.git/226065/ Signed-off-by: Eric Sunshine --- contrib/contacts/git-contacts | 127 ++ 1 file changed, 127 insertions(+) create mode 100755 contrib/contacts/git-contacts diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts new file mode 100755 index 000..3e6cce8 --- /dev/null +++ b/contrib/contacts/git-contacts @@ -0,0 +1,127 @@ +#!/usr/bin/perl + +# List people who might be interested in a patch. Useful as the argument to +# git-send-email --cc-cmd option, and in other situations. +# +# Usage: git contacts ... + +use strict; +use warnings; +use IPC::Open2; + +my $since = '5-years-ago'; +my $min_percent = 10; +my $labels_rx = qr/Signed-off-by|Reviewed-by|Acked-by|Cc/i; +my %seen; + +sub format_contact { + my ($name, $email) = @_; + return "$name <$email>"; +} + +sub parse_commit { + my ($commit, $data) = @_; + my $contacts = $commit->{contacts}; + my $inbody = 0; + for (split(/^/m, $data)) { + if (not $inbody) { + if (/^author ([^<>]+) <(\S+)> .+$/) { + $contacts->{format_contact($1, $2)} = 1; + } elsif (/^$/) { + $inbody = 1; + } + } elsif (/^$labels_rx:\s+([^<>]+)\s+<(\S+?)>$/o) { + $contacts->{format_contact($1, $2)} = 1; + } + } +} + +sub import_commits { + my ($commits) = @_; + return unless %$commits; + my $pid = open2 my $reader, my $writer, qw(git cat-file --batch); + for my $id (keys(%$commits)) { + print $writer "$id\n"; + my $line = <$reader>; + if ($line =~ /^([0-9a-f]{40}) commit (\d+)/) { + my ($cid, $len) = ($1, $2); + die "expected $id but got $cid\n" unless $id eq $cid; + my $data; + # cat-file emits newline after data, so read len+1 + read $reader, $data, $len + 1; + parse_commit($commits->{$id}, $data); + } + } + close $reader; + close $writer; + waitpid($pid, 0); + die "git-cat-file error: $?\n" if $?; +} + +sub get_blame { + my ($commits, $source, $start, $len, $from) = @_; + $len = 1 unless defined($len); + return if $len == 0; + open my $f, '-|', + qw(git blame --porcelain -C), '-L', "$start,+$len", + '--since', $since, "$from^", '--', $source or die; + while (<$f>) { + if (/^([0-9a-f]{40}) \d+ \d+ \d+$/) { + my $id = $1; + $commits->{$id} = { id => $id, contacts => {} } + unless $seen{$id}; + $seen{$id} = 1; + } + } + close $f; +} + +sub scan_patches { + my ($commits, $f) = @_; + my ($id, $source); + while (<$f>) { + if (/^From ([0-9a-f]{40}) Mon Sep 17 00:00:00 2001$/) { + $id = $1; + $seen{$id} = 1; + } + next unless $id; + if (m{^--- (?:a/(.+)|/dev/null)$}) { + $source = $1; + } elsif (/^--- /) { + die "Cannot parse hunk source: $_\n"; + } elsif (/^@@ -(\d+)(?:,(\d+))?/ && $source) { + get_blame($commits, $source, $1, $2, $id); + } + } +} + +sub scan_patch_file { + my ($commits, $file) = @_; + open my $f, '<', $file or die "read failure: $file: $!\n"; + scan_patches($commits, $f); + close $f; +} +
[PATCH v3 4/5] contrib: contacts: add mailmap support
The purpose of git-contacts is to determine a list of people who might have some interest in a patch or set of changes. It can be used as git-send-email's --cc-cmd argument or the computed list might be used to ask for comments on a proposed change. As such, it is important to report up-to-date email addresses in the computed list rather than potentially outdated ones recorded with commits. Apply git's mailmap functionality to the retrieved contacts in order to achieve this goal. Signed-off-by: Eric Sunshine --- contrib/contacts/git-contacts | 18 ++ 1 file changed, 18 insertions(+) diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts index 4553add..d80f7d1 100755 --- a/contrib/contacts/git-contacts +++ b/contrib/contacts/git-contacts @@ -133,6 +133,23 @@ sub scan_rev_args { close $f; } +sub mailmap_contacts { + my ($contacts) = @_; + my %mapped; + my $pid = open2 my $reader, my $writer, qw(git check-mailmap --stdin); + for my $contact (keys(%$contacts)) { + print $writer "$contact\n"; + my $canonical = <$reader>; + chomp $canonical; + $mapped{$canonical} += $contacts->{$contact}; + } + close $reader; + close $writer; + waitpid($pid, 0); + die "git-check-mailmap error: $?\n" if $?; + return \%mapped; +} + if (!@ARGV) { die "No input revisions or patch files\n"; } @@ -161,6 +178,7 @@ for my $commit (values %commits) { $contacts->{$contact}++; } } +$contacts = mailmap_contacts($contacts); my $ncommits = scalar(keys %commits); for my $contact (keys %$contacts) { -- 1.8.3.3.803.gd114dc6 -- 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 v3 0/5] add git-contacts helper
This is v3 of the Perl rewrite of Felipe Contreras' git-related v9 patch series [1] which was written in Ruby. v2 of this series is here [2]. v3 adds git mailmap support and documentation. It requires check-mailmap [3] functionality (es/check-mailmap in 'pu'), though it does not otherwise depend upon it textually. Patch 1/5: Same as v2 except that the variable holding the commit counts for each contact has been renamed and changed from a hash to a hash reference in order to simplify patch 4/5. Patch 2/5: Same as v2. Patch 3/5: Same as v2. Patch 4/5: New. Add mailmap support. Patch 5/5: New. Add documentation. Possible future directions and considerations: * Make participation parameters (minimum-percent, blame since-date, -C level) configurable. * Optimize by enhancing git-blame to accept multiple -L's. [1]: http://thread.gmane.org/gmane.comp.version-control.git/226065/ [2]: http://thread.gmane.org/gmane.comp.version-control.git/229533/ [3]: http://git.661346.n2.nabble.com/PATCH-v3-0-2-add-git-check-mailmap-command-td7591791.html Eric Sunshine (5): contrib: add git-contacts helper contrib: contacts: add ability to parse from committish contrib: contacts: interpret committish akin to format-patch contrib: contacts: add mailmap support contrib: contacts: add documentation contrib/contacts/git-contacts | 188 ++ contrib/contacts/git-contacts.txt | 94 +++ 2 files changed, 282 insertions(+) create mode 100755 contrib/contacts/git-contacts create mode 100644 contrib/contacts/git-contacts.txt -- 1.8.3.3.803.gd114dc6 -- 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
Fwd: [PATCH] Improve font rendering on retina macbooks
Hi there I've created a very small change to git gui that considerably improves the experience on my machine at least: diff --git a/git-gui/macosx/Info.plist b/git-gui/macosx/Info.plist index b3bf15f..1ade121 100644 --- a/git-gui/macosx/Info.plist +++ b/git-gui/macosx/Info.plist @@ -24,5 +24,7 @@ GITg CFBundleVersion @@GITGUI_VERSION@@ + NSHighResolutionCapable + I've read the documentation for submitting patches to git where it says that I have to e-mail the patch to the mail list, with relevant developers as CC. Pat are you the relevant developer for this? Here is a screenshot comparison of before and after the change: https://github.com/git/git/pull/48 Please let me know how to proceed to get this patch in, if you like it. I've never contributed here before, so please me know about any procedures I have missed. Regards, Mads Dørup -- 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] gitk: Add a "Save file as" menu item
Previously, there was no easy way to save a particular file from the currently selected revision. This patch adds a menu item "Save file as" to the file list popup menu, which opens a file selection dialog to determine the name under which a file should be saved. The default filename is of the form "[shortid] basename". If the current revision is the index, the default pattern is of the form "[index] basename". This works for both, the "Patch" and "Tree" view. The menu item is disabled for the "local uncommitted changes" fake revision. Signed-off-by: Andreas Amann --- gitk | 30 ++ 1 file changed, 30 insertions(+) diff --git a/gitk b/gitk index 5cd00d8..dbedaf6 100755 --- a/gitk +++ b/gitk @@ -2595,6 +2595,7 @@ proc makewindow {} { {mc "Highlight this too" command {flist_hl 0}} {mc "Highlight this only" command {flist_hl 1}} {mc "External diff" command {external_diff}} + {mc "Save file as" command {save_file_as}} {mc "Blame parent commit" command {external_blame 1}} } $flist_menu configure -tearoff 0 @@ -3378,6 +3379,7 @@ proc sel_flist {w x y} { proc pop_flist_menu {w X Y x y} { global ctext cflist cmitmode flist_menu flist_menu_file global treediffs diffids +global nullid stopfinding set l [lindex [split [$w index "@$x,$y"] "."] 0] @@ -3395,6 +3397,12 @@ proc pop_flist_menu {w X Y x y} { } # Disable "External diff" item in tree mode $flist_menu entryconf 2 -state $xdiffstate +set savefilestate "normal" +if {[lindex $diffids 0] eq $nullid} { + set savefilestate "disabled" +} +# Disable "Save file as" item for worktree +$flist_menu entryconf 3 -state $savefilestate tk_popup $flist_menu $X $Y } @@ -3496,6 +3504,28 @@ proc external_diff_get_one_file {diffid filename diffdir} { "revision $diffid"] } +proc save_file_as {} { +global nullid nullid2 +global flist_menu_file +global diffids + +set diffid [lindex $diffids 0] +if {$diffid == $nullid} { + return +} elseif {$diffid == $nullid2} { + set diffidtext "\[index\]" + set diffid "" +} else { + set diffidtext "\[[shortids $diffid]\]" +} +set difffile "$diffidtext [file tail $flist_menu_file]" +set difffile [tk_getSaveFile -initialfile $difffile -title "Save file as" -parent .] +if {$difffile eq {}} { + return +} +save_file_from_commit $diffid:$flist_menu_file $difffile "revision $diffid" +} + proc external_diff {} { global nullid nullid2 global flist_menu_file -- 1.8.3.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
[PATCH v2 1/2] rev-parse: remove restrictions on some options
The "--local-env-vars" and "--resolve-git-dir" arguments to git-rev-parse are currently only handled if they appear first on the command line (in the case of "--local-env-vars", only if it is the only argument). While it may not make sense to use these options when any others are specified, there is no reason for this restriction and it might confuse users if these arguments appear to be ignored. There is no need for any documentation change here as the restrictions on these options are not documented. Signed-off-by: John Keeping --- builtin/rev-parse.c | 28 +--- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index de894c7..c9aa28f 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -486,21 +486,6 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) if (argc > 1 && !strcmp("--sq-quote", argv[1])) return cmd_sq_quote(argc - 2, argv + 2); - if (argc == 2 && !strcmp("--local-env-vars", argv[1])) { - int i; - for (i = 0; local_repo_env[i]; i++) - printf("%s\n", local_repo_env[i]); - return 0; - } - - if (argc > 2 && !strcmp(argv[1], "--resolve-git-dir")) { - const char *gitdir = resolve_gitdir(argv[2]); - if (!gitdir) - die("not a gitdir '%s'", argv[2]); - puts(gitdir); - return 0; - } - if (argc > 1 && !strcmp("-h", argv[1])) usage(builtin_rev_parse_usage); @@ -661,6 +646,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) for_each_remote_ref(show_reference, NULL); continue; } + if (!strcmp(arg, "--local-env-vars")) { + int i; + for (i = 0; local_repo_env[i]; i++) + printf("%s\n", local_repo_env[i]); + continue; + } if (!strcmp(arg, "--show-toplevel")) { const char *work_tree = get_git_work_tree(); if (work_tree) @@ -711,6 +702,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : ""); continue; } + if (!strcmp(arg, "--resolve-git-dir")) { + const char *gitdir = resolve_gitdir(argv[i+1]); + if (!gitdir) + die("not a gitdir '%s'", argv[i+1]); + puts(gitdir); + continue; + } if (!strcmp(arg, "--is-inside-git-dir")) { printf("%s\n", is_inside_git_dir() ? "true" : "false"); -- 1.8.3.3.972.gc83849e.dirty -- 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 v2 0/2] Improvements to rev-parse option handling
This adds a new patch to remove the restrictions on --local-env-var and --resolve-git-dir so that they do not need to appear first on the command line. The other patch is update to reflect this as well as to split up the catch-all "Options for Input" subsection a bit. John Keeping (2): rev-parse: remove restrictions on some options rev-parse(1): logically group options Documentation/git-rev-parse.txt | 104 builtin/rev-parse.c | 28 +-- 2 files changed, 77 insertions(+), 55 deletions(-) -- 1.8.3.3.972.gc83849e.dirty -- 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 v2 2/2] rev-parse(1): logically group options
The options section of the git-rev-parse manual page has grown organically so that there now does not seem to be much logic behind the ordering of the options. It also does not make it clear that certain options must appear first on the command line. Address this by reorganising the options into groups with subheadings. The text of option descriptions does not change. Signed-off-by: John Keeping --- Documentation/git-rev-parse.txt | 104 1 file changed, 64 insertions(+), 40 deletions(-) diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 993903c..34c55a7 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -24,9 +24,23 @@ distinguish between them. OPTIONS --- + +Operation Modes +~~~ + +Each of these options must appear first on the command line. + --parseopt:: Use 'git rev-parse' in option parsing mode (see PARSEOPT section below). +--sq-quote:: + Use 'git rev-parse' in shell quoting mode (see SQ-QUOTE + section below). In contrast to the `--sq` option below, this + mode does only quoting. Nothing else is done to command input. + +Options for --parseopt +~~ + --keep-dashdash:: Only meaningful in `--parseopt` mode. Tells the option parser to echo out the first `--` met instead of skipping it. @@ -36,10 +50,8 @@ OPTIONS the first non-option argument. This can be used to parse sub-commands that take options themselves. ---sq-quote:: - Use 'git rev-parse' in shell quoting mode (see SQ-QUOTE - section below). In contrast to the `--sq` option below, this - mode does only quoting. Nothing else is done to command input. +Options for Filtering +~ --revs-only:: Do not output flags and parameters not meant for @@ -55,6 +67,9 @@ OPTIONS --no-flags:: Do not output flag parameters. +Options for Output +~~ + --default :: If there is no parameter given by the user, use `` instead. @@ -110,6 +125,17 @@ can be used. strip '{caret}' prefix from the object names that already have one. +--abbrev-ref[=(strict|loose)]:: + A non-ambiguous short name of the objects name. + The option core.warnAmbiguousRefs is used to select the strict + abbreviation mode. + +--short:: +--short=number:: + Instead of outputting the full SHA-1 values of object names try to + abbreviate them to a shorter unique name. When no length is specified + 7 is used. The minimum length is 4. + --symbolic:: Usually the object names are output in SHA-1 form (with possible '{caret}' prefix); this option makes them output in a @@ -123,16 +149,8 @@ can be used. unfortunately named tag "master"), and show them as full refnames (e.g. "refs/heads/master"). ---abbrev-ref[=(strict|loose)]:: - A non-ambiguous short name of the objects name. - The option core.warnAmbiguousRefs is used to select the strict - abbreviation mode. - ---disambiguate=:: - Show every object whose name begins with the given prefix. - The must be at least 4 hexadecimal digits long to - avoid listing each and every object in the repository by - mistake. +Options for Objects +~~~ --all:: Show all refs found in `refs/`. @@ -155,18 +173,20 @@ shown. If the pattern does not contain a globbing character (`?`, character (`?`, `*`, or `[`), it is turned into a prefix match by appending `/*`. ---show-toplevel:: - Show the absolute path of the top-level directory. +--disambiguate=:: + Show every object whose name begins with the given prefix. + The must be at least 4 hexadecimal digits long to + avoid listing each and every object in the repository by + mistake. ---show-prefix:: - When the command is invoked from a subdirectory, show the - path of the current directory relative to the top-level - directory. +Options for Files +~ ---show-cdup:: - When the command is invoked from a subdirectory, show the - path of the top-level directory relative to the current - directory (typically a sequence of "../", or an empty string). +--local-env-vars:: + List the GIT_* environment variables that are local to the + repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR). + Only the names of the variables are listed, not their value, + even if they are set. --git-dir:: Show `$GIT_DIR` if defined. Otherwise show the path to @@ -188,17 +208,27 @@ print a message to stderr and exit with nonzero status. --is-bare-repository:: When the repository is bare print "true", otherwise "false". ---local-env-vars:: - List the GIT_* environment variables that are local to the - repository (e.g. GIT_DIR or
Re: [RFC/PATCH] Add the NO_SENTINEL build variable
Junio C Hamano wrote: > Ramsay Jones writes: > >> Jonathan Nieder wrote: >>> Ramsay Jones wrote: >>> One of the three gcc compilers that I use does not understand the sentinel function attribute. (so, it spews 108 warning messages) >>> >>> Do you know what version of gcc introduced the sentinel attribute? >>> Would it make sense for the ifdef in git-compat-util.h to be keyed on >>> __GNUC__ and __GNUC_MINOR__ instead of a new makefile flag? >>> >> >> I have on old (v4.2.1) gcc repo on Linux and looking at >> >> ~/gcc-4.2.1/gcc/ChangeLog-2004 >> >> I can see that the sentinel attribute was added on 2004-09-04 by >> Kaveh R. Ghazi. >> >> Also, I find "bump version string to version 4.0.0" was on 2004-09-09 >> and "bump version string to version 3.5.0" was on 2004-01-16. >> >> Several of my system header files (on Linux) imply that the >> sentinel attribute is supported by __GNUC__ >= 4. (One of them, >> ansidecl.h, states that gcc 3.5 supports it but ...) > > Perhaps a message from yesterday would have helped? > > http://article.gmane.org/gmane.comp.version-control.git/230633 > > seems to indicate that checking for version 4 is sufficient. > > Also I asked you to split the __attribute__((sentinel(n)) support > into a separate patch. We currently do not pass anything but 0 > (meaning, the sentinel is always at the end), and SENTINEL in all > capital is easy enough to grep for when somebody _does_ want to have > such a support, so I'd prefer not to see __attribute__((sentinel(n)) > until it becomes necessary. Sorry, but I didn't see any of these emails before sending this and the subsequent patch email. :( I can sometimes be away from email for several days at a time (and then spend days trying to read the backlog - I'm on *far* too many mailing lists!). [The internet went black on me last night; I couldn't see anything outside of my ISP's servers (and not all of those). I also couldn't get any answer at the support phone number, so I probably wasn't the only one ...] ATB, Ramsay Jones -- 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] Fix some sparse warnings
Jeff King wrote: > On Thu, Jul 18, 2013 at 09:25:50PM +0100, Ramsay Jones wrote: > >> Sparse issues some "Using plain integer as NULL pointer" warnings. >> Each warning relates to the use of an '{0}' initialiser expression >> in the declaration of an 'struct object_info'. The first field of >> this structure has pointer type. Thus, in order to suppress these >> warnings, we replace the initialiser expression with '{NULL}'. >> >> Signed-off-by: Ramsay Jones > > Acked-by: Jeff King > > I thought at first we would need one more for the new callsite I added > in my series, but we use memset() in that instance, so it is fine. On an almost unrelated note ... I am now getting the following sparse warnings: pack-revindex.c:105:23: warning: memset with byte count of 262144 This is a little annoying, since there is no way to turn this off. :( (which I consider a bug in sparse). Sparse has special-case code to check calls to memset(), memcpy(), copy_to_user() and copy_from_user(). The code that checks the byte count argument looks like: static void check_byte_count(struct instruction *insn, pseudo_t count) { if (!count) return; if (count->type == PSEUDO_VAL) { long long val = count->value; if (val <= 0 || val > 10) warning(insn->pos, "%s with byte count of %lld", show_ident(insn->func->sym->ident), val); return; } /* OK, we could try to do the range analysis here */ } I will just ignore this for now. ;-) ATB, Ramsay Jones -- 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] Add the GIT_SENTINEL macro
Junio C Hamano wrote: > Ramsay Jones writes: > >> The sentinel function attribute is not understood by versions of >> the gcc compiler prior to v4.0. At present, for earlier versions >> of gcc, the build issues 108 warnings related to the unknown >> attribute. In order to suppress the warnings, we conditionally >> define the GIT_SENTINEL macro to provide the sentinel attribute >> for gcc v4.0 and newer. >> >> Signed-off-by: Ramsay Jones >> --- >> >> This was built on the next branch > > It seems to apply well on the tip of jk/gcc-function-attributes. > > > - This macro is not about "git" at all, so I'll edit the patch to >call it GCC_ATTR_SENTINEL before applying. > > - Also I'll drop the (0) at the end. > > Thanks. Yes, GCC_ATTR_SENTINEL is a better name, but I like LAST_ARG_MUST_BE_NULL even more! The final commit 9fe3edc4 ("Add the LAST_ARG_MUST_BE_NULL macro", 18-07-2013) is much better than my patch and works beautifully. Thanks Junio, Jeff and Jonathan! ATB, Ramsay Jones -- 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] Cygwin has trustable filemode
Mark Levedahl wrote: > The supported Cygwin distribution on supported Windows versions provides > complete support for POSIX filemodes, so enable this by default. git as > distributed by the Cygwin project is configured this way. > > This fixes one testsuite failure: > t3300 test 17 (diff-index -M -p with mode change quotes funny filename) > > Historical notes: Cygwin version 1.7 supports Windows-XP and newer, thus > dropped support for all OS variants that lack NTFS and/or the full win32 > api, and since late 1.5 development, Cygwin maps POSIX modes to NTFS ACLs > by default. Cygwin 1.5 supported OS variants that used FAT as the native > file system, and had optional methods for providing POSIX file modes on > top of FAT12/16 and NTFS, though not FAT32. Also, support for POSIX modes > on top of FAT were dropped later in 1.5. Thus, POSIX filemode support > could not be expected by default on a Cygwin 1.5 installation, but is > expected by default on a 1.7 installation. > > Signed-off-by: Mark Levedahl > --- > Junio - The above notes are more accurate than in my previous commit message, > so if this commit survives into next/master, I would prefer this version as > opposed to the one now on pu (da875762) Again, I have to ask; should you not "revert" commit c869753e ("Force core.filemode to false on Cygwin.", 30-12-2006)? After this commit, there is no longer any user of the NO_TRUSTABLE_FILEMODE build variable, and no real prospect of anyone else wanting to use it. ATB, Ramsay Jones -- 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: What's cooking in git.git (Jul 2013, #03; Tue, 9)
Junio C Hamano wrote: > Ramsay Jones writes: > >> Junio C Hamano wrote: >> [ ... ] >>> * rr/send-email-ssl-verify (2013-07-06) 6 commits >>> - SQUASH??? update to support SSL_ca_file as well as SSL_ca_path >>> - SQUASH??? send-email: cover both smtps and starttls cases >>> - fixup! send-email: squelch warning from Net::SMTP::SSL >>> - SQUASH??? send-email giving default value to ssl-cert-path with ||= >>> assignment >>> - send-email: introduce sendemail.smtpsslcertpath >>> - send-email: squelch warning from Net::SMTP::SSL >>> >>> The issue seems a lot deeper than the initial attempt and needs >>> somebody to sit down and sort out to get the version dependencies >>> and lazy loading right. >> >> This causes test failures for me, since send-email can't load the >> IO/Socket/SSL.pm module. (on Linux, cygwin and MinGW!) > > Good ;-). > > Can you try the more recent 'pu' with 35035bbf (send-email: be > explicit with SSL certificate verification, 2013-07-18) that was > updated with help from Brian Carlson? Yes, this works fine now. I tested on Linux and cygwin. (I haven't had time to test on MinGW, but I don't expect any problems.) Thanks ATB, Ramsay Jones -- 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 v3 0/3] Switch German translation to G+E
2013/7/19 Junio C Hamano : > Thomas Rast writes: > >> Ralf Thielow writes: >> >>> This is a resend of v3 because at least one patch was >>> damaged last time for whatever reason. >>> >>> Ralf Thielow (3): >>> l10n: de.po: switch from pure German to German+English (part 1) >>> l10n: de.po: switch from pure German to German+English (part 2) >>> l10n: de.po: switch from pure German to German+English (part 3) >> >> Thanks, this one applied cleanly. >> >> Acked-by: Thomas Rast > > Let's make sure our i18n coordinator is aware of this effort. > First round of l10n for git 1.8.4 will begin right after rc0, and according to the calendar[1], it may start tomorrow. Ralf please send pull request for this as usual. [1]: https://www.google.com/calendar/embed?src=jfgbl2mrlipp4pb6ieih0qr...@group.calendar.google.com&ctz=America/Los_Angeles&gsessionid=OK -- Jiang Xin -- 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] Fix some sparse warnings
Hi, Ramsay Jones wrote: > Sparse issues some "Using plain integer as NULL pointer" warnings. > Each warning relates to the use of an '{0}' initialiser expression > in the declaration of an 'struct object_info'. The first field of > this structure has pointer type. Thus, in order to suppress these > warnings, we replace the initialiser expression with '{NULL}'. I agree that this is worth solving but the fix feels like a move in the wrong direction. Before this patch, the initialization says "= {0}", which basically means "memset it to 0". Afterward, the initializer depends on the order of fields in the struct. How about something like the following? diff --git i/cache.h w/cache.h index f2915509..ba028b75 100644 --- i/cache.h +++ w/cache.h @@ -1124,6 +1124,7 @@ struct object_info { } packed; } u; }; +#define OBJECT_INFO_INIT { NULL, NULL, OI_CACHED, { { NULL, 0, 0 } } } extern int sha1_object_info_extended(const unsigned char *, struct object_info *); /* Dumb servers support */ diff --git i/sha1_file.c w/sha1_file.c index 6baed676..2d812b8d 100644 --- i/sha1_file.c +++ w/sha1_file.c @@ -2421,7 +2421,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi) int sha1_object_info(const unsigned char *sha1, unsigned long *sizep) { - struct object_info oi = {0}; + struct object_info oi = OBJECT_INFO_INIT; oi.sizep = sizep; return sha1_object_info_extended(sha1, &oi); diff --git i/streaming.c w/streaming.c index cac282f0..b4c40ad9 100644 --- i/streaming.c +++ w/streaming.c @@ -135,7 +135,7 @@ struct git_istream *open_istream(const unsigned char *sha1, struct stream_filter *filter) { struct git_istream *st; - struct object_info oi = {0}; + struct object_info oi = OBJECT_INFO_INIT; const unsigned char *real = lookup_replace_object(sha1); enum input_source src = istream_source(real, type, &oi); -- 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] gitk: Add a "Save file as" menu item
Andreas Amann: +set difffile "$diffidtext [file tail $flist_menu_file]" +set difffile [tk_getSaveFile -initialfile $difffile -title "Save file as" -parent .] +if {$difffile eq {}} { + return +} +save_file_from_commit $diffid:$flist_menu_file $difffile "revision $diffid" I might be misunderstanding the code (this is not one of my preferred programming languages), but it looks like this is missing the gettext markers necessary to get these strings localized. -- \\// Peter - http://www.softwolves.pp.se/ -- 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] gitk: Add a "Save file as" menu item
Peter Krefting writes: > Andreas Amann: > >> +set difffile "$diffidtext [file tail $flist_menu_file]" >> +set difffile [tk_getSaveFile -initialfile $difffile -title "Save file >> as" -parent .] >> +if {$difffile eq {}} { >> +return >> +} >> +save_file_from_commit $diffid:$flist_menu_file $difffile "revision >> $diffid" > > I might be misunderstanding the code (this is not one of my preferred > programming languages), but it looks like this is missing the gettext > markers necessary to get these strings localized. thanks for pointing this out. Will resend an updated patch. -- 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] Revert "compat/unsetenv.c: Fix a sparse warning"
This reverts commit ec535cc27e6c4f5e0b1d157e04f5511f166ecd9d. POSIX explicitly states "the [environ] variable, which must be declared by the user if it is to be used directly". Not declaring it causes compilation to fail on OS X. Instead don't declare the variable on MinGW, as it causes a spurious warning there. Signed-off-by: Benoit Sigoure --- Resending as I forgot to Sign-off the previous patch. compat/unsetenv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat/unsetenv.c b/compat/unsetenv.c index 4ea1856..bf5fd70 100644 --- a/compat/unsetenv.c +++ b/compat/unsetenv.c @@ -2,6 +2,9 @@ void gitunsetenv (const char *name) { +#if !defined(__MINGW32__) + extern char **environ; +#endif int src, dst; size_t nmln; -- 1.8.2.1.539.g4196a96 -- 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 v2] gitk: Add a "Save file as" menu item
Previously, there was no easy way to save a particular file from the currently selected revision. This patch adds a menu item "Save file as" to the file list popup menu, which opens a file selection dialog to determine the name under which a file should be saved. The default filename is of the form "[shortid] basename". If the current revision is the index, the default pattern is of the form "[index] basename". This works for both, the "Patch" and "Tree" view. The menu item is disabled for the "local uncommitted changes" fake revision. Signed-off-by: Andreas Amann --- gitk | 32 1 file changed, 32 insertions(+) diff --git a/gitk b/gitk index 5cd00d8..b5a70b5 100755 --- a/gitk +++ b/gitk @@ -2595,6 +2595,7 @@ proc makewindow {} { {mc "Highlight this too" command {flist_hl 0}} {mc "Highlight this only" command {flist_hl 1}} {mc "External diff" command {external_diff}} + {mc "Save file as" command {save_file_as}} {mc "Blame parent commit" command {external_blame 1}} } $flist_menu configure -tearoff 0 @@ -3378,6 +3379,7 @@ proc sel_flist {w x y} { proc pop_flist_menu {w X Y x y} { global ctext cflist cmitmode flist_menu flist_menu_file global treediffs diffids +global nullid stopfinding set l [lindex [split [$w index "@$x,$y"] "."] 0] @@ -3395,6 +3397,12 @@ proc pop_flist_menu {w X Y x y} { } # Disable "External diff" item in tree mode $flist_menu entryconf 2 -state $xdiffstate +set savefilestate "normal" +if {[lindex $diffids 0] eq $nullid} { + set savefilestate "disabled" +} +# Disable "Save file as" item "local uncommited changes" revision +$flist_menu entryconf 3 -state $savefilestate tk_popup $flist_menu $X $Y } @@ -3496,6 +3504,30 @@ proc external_diff_get_one_file {diffid filename diffdir} { "revision $diffid"] } +proc save_file_as {} { +global nullid nullid2 +global flist_menu_file +global diffids + +set diffid [lindex $diffids 0] +if {$diffid == $nullid} { + return +} elseif {$diffid == $nullid2} { + set diffidtext [mc "index"] + set diffid "" + set whattext $diffidtext +} else { + set diffidtext [shortids $diffid] + set whattext "[mc "revision"] $diffidtext" +} +set difffile "\[$diffidtext\] [file tail $flist_menu_file]" +set difffile [tk_getSaveFile -initialfile $difffile -title [mc "Save file as"] -parent .] +if {$difffile eq {}} { + return +} +save_file_from_commit $diffid:$flist_menu_file $difffile $whattext +} + proc external_diff {} { global nullid nullid2 global flist_menu_file -- 1.8.3.3 -- 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] Fix some sparse warnings
Jonathan Nieder writes: > How about something like the following? > > diff --git i/cache.h w/cache.h > index f2915509..ba028b75 100644 > --- i/cache.h > +++ w/cache.h > @@ -1124,6 +1124,7 @@ struct object_info { > } packed; > } u; > }; > +#define OBJECT_INFO_INIT { NULL, NULL, OI_CACHED, { { NULL, 0, 0 } } } There are quite a many hits from $ git grep '= { *NULL *};' only some of which are "char *var[] = { NULL }", which is perfectly fine, but others are to initialise "struct foo" (or "foo_t" which is typedef'ed) that share the same "writing NULL means the initialiser knows the order of the fields". I doubt if the above #define is a maintainable solution, and worse yet, thinking about the fact that such a macro is necessary only for a structure whose first field happens to be of a pointer type, it strongly suggests me that it is not conceptually the right thing to do. Can't we have sparse fixed (or skip this specific warning) instead? -- 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] test-lib.sh - define and use GREP_STRIPS_CR
Ramsay Jones writes: > Mark Levedahl wrote: >> Define a common macro for grep needing -U to allow tests to not need >> to inquire of specific platforms needing this option. Change >> t3032 and t5560 to use this rather than testing explicitly for mingw. >> This fixes these two tests on Cygwin. >> >> Signed-off-by: Mark Levedahl >> --- >> This replaces my earlier patch against t3032 (8896b287 on pu) > > Yep, this looks good and (as expected) it works on cygwin 1.5 too. :-D > > Thanks. After this patch lands 'master', we may want to add a note to these SED/GREP workarounds for CRLF platforms that we assume the platform use GNU sed/grep. Incidentally, don't we also need "unset SED_OPTIONS" in t/test-lib.sh net to where we unset GREP_OPTIONS? -- 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] Cygwin has trustable filemode
Ramsay Jones writes: > Mark Levedahl wrote: >> The supported Cygwin distribution on supported Windows versions provides >> complete support for POSIX filemodes, so enable this by default. >> ... >> Historical notes: Cygwin version 1.7 supports Windows-XP and newer, thus >> dropped support for all OS variants that lack NTFS and/or ... >> ... Thus, POSIX filemode support >> could not be expected by default on a Cygwin 1.5 installation, but is >> expected by default on a 1.7 installation. >> > Again, I have to ask; should you not "revert" commit c869753e ("Force > core.filemode > to false on Cygwin.", 30-12-2006)? After this commit, there is no longer any > user > of the NO_TRUSTABLE_FILEMODE build variable, and no real prospect of anyone > else > wanting to use it. Thanks for raising this point. Reading c869753e once again: The issue is that Cygwin and NTFS correctly supports the executable mode bit, and Git properly detected that, but most native Windows applications tend to create files such that Cygwin sees the executable bit set when it probably shouldn't be. In other words, the reason why "NO_TRUSTABLE_FILEMODE" was added was not because the Cygwin did not give us reliable filemodes. It was because tools outside the control of Git and/or Cygwin that users use tend to misbehave, even when the working tree is on a filesystem on which Cygwin can give us trustable filemodes. So "1.7 always supports core.filemodes correctly because it no longer works on filesystems without trustable filemodes" is not a valid reason to justify Mark's change. There are only three possible ways going forward, I think: (A) Drop Mark's patch, and do nothing else, because breakages of other people's programs are not fixed by Cygwin 1.7's improved filesystem support, and users still use those mode breaking programs written by others; (B) Drop Mark's patch, and revert c869753e, because it is not the business of our project to sweep breakages of other people's tools under the rug by crippling our software; or (C) Drop NO_TRUSTABLE_FILEMODE for _all_ versions of Cygwin, declaring that the spirit of c869753e to work around bugs in other people's software by crippling Git is justified, but that it is no longer necessary on Cygwin because people do not use such misbehaving third-party tools anymore. These three each rely on its own precondition; I suspect it is likely that (A)'s is the most accurate description of the real world. -- 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] Revert "compat/unsetenv.c: Fix a sparse warning"
Benoit Sigoure writes: > This reverts commit ec535cc27e6c4f5e0b1d157e04f5511f166ecd9d. > > POSIX explicitly states "the [environ] variable, which > must be declared by the user if it is to be used directly". > Not declaring it causes compilation to fail on OS X. > > Instead don't declare the variable on MinGW, as it causes > a spurious warning there. > > Signed-off-by: Benoit Sigoure Thanks, will queue. > --- > > Resending as I forgot to Sign-off the previous patch. > > compat/unsetenv.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/compat/unsetenv.c b/compat/unsetenv.c > index 4ea1856..bf5fd70 100644 > --- a/compat/unsetenv.c > +++ b/compat/unsetenv.c > @@ -2,6 +2,9 @@ > > void gitunsetenv (const char *name) > { > +#if !defined(__MINGW32__) > + extern char **environ; > +#endif > int src, dst; > size_t nmln; -- 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/2] Fix generic typos in comments
Ondřej Bílka writes: > Hi, I wrote a tool that effectively fixes typos in comments and only in > comments. > It can be downloaded here: > > https://github.com/neleai/stylepp > > For typos you need identify them, write replacement dictionary and run > STYLEPP/script/stylepp_skeleton stylepp_fix_comment > > Here generic dictionary is used that was taken from wikipedia. > https://github.com/neleai/stylepp/blob/master/maintained/dictionary_wiki Thanks, but sorry we cannot use this patch as-is (even if it were signed-off and came with a proper log message). The patch touches phrases somebody may find questionable at many different levels. - "lowercase ok" and "fall thru" are quite acceptable colloquial forms; if the person who DID the real work chose to write these in such a way, I do not see a reason for us to update it to a different preference. - There are outright typoes that noboddy would disagree with, e.g. s/sinse/since/. -- 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/2] Fix typos in comments
Ondřej Bílka writes: > A dictionary that I generated is following, patch is below. Please use only "obvious and clear typo nobody would disagree with the fix" entries and drop other entries in the "I would prefer to use a different phrasing or spelling" category. For example, as already mentioned, "alloted" is a proper pp of a verb, so it falls into the latter. 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: Dead link
Thanks; the patch seems to cover all the instances. Sign off? -- 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] Improve font rendering on retina macbooks
I've been asked to close the github pull request. So instead, to see before-and-after screenshots of this change have a look here: https://github.com/cpius/git/commit/dce145c11a89be7c795815c9bd8fe2c07a5afa7d#commitcomment-3682422 Regards, Mads Dørup On Sun, Jul 21, 2013 at 2:25 PM, Mads Dørup wrote: > Hi there > > I've created a very small change to git gui that considerably improves > the experience on my machine at least: > > diff --git a/git-gui/macosx/Info.plist b/git-gui/macosx/Info.plist > index b3bf15f..1ade121 100644 > --- a/git-gui/macosx/Info.plist > +++ b/git-gui/macosx/Info.plist > @@ -24,5 +24,7 @@ > GITg > CFBundleVersion > @@GITGUI_VERSION@@ > + NSHighResolutionCapable > + > > > > > I've read the documentation for submitting patches to git where it > says that I have to e-mail the patch to the mail list, with relevant > developers as CC. Pat are you the relevant developer for this? > > Here is a screenshot comparison of before and after the change: > > https://github.com/git/git/pull/48 > > Please let me know how to proceed to get this patch in, if you like > it. I've never contributed here before, so please me know about any > procedures I have missed. > > Regards, Mads Dørup -- 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] remotes-hg: bugfix for fetching non local remotes
6796d49 introduced a bug by making shared_path == ".git/hg' which will most likely exist already, causing a new remote never to be cloned and subsequently causing hg.share to fail with error msg: "mercurial.error.RepoError: repository .git/hg not found" Changing gitdir to dirname causes shared_path == .git/hg//hg. The call to hg.share with local_path == .git/hg//clone works again. --- contrib/remote-helpers/git-remote-hg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg index 0194c67..89dd4cc 100755 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@ -390,7 +390,7 @@ def get_repo(url, alias): if not os.path.exists(dirname): os.makedirs(dirname) else: -shared_path = os.path.join(gitdir, 'hg') +shared_path = os.path.join(dirname, 'hg') if not os.path.exists(shared_path): try: hg.clone(myui, {}, url, shared_path, update=False, pull=True) -- 1.8.3.3 -- 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 v7 0/4] config: add support for http..* settings
NOTE: This patch requires the following preparatory change: f1ff763 http.c: fix parsing of http.sslCertPasswordProtected variable which is currently in pu. This patch series adds support for http..* settings. The patch is organized as a series of improvements on the functionality: 1/4 - adds basic textual matching support 2/4 - adds URL normalization before matching 3/4 - adds a test for the URL normalization function 4/4 - adds any user matching With-Feedback-From-jh: Junio C Hamano Differences from v6: 1/4 - Updated from v6's 1/4: * Added an http_init memset for http_option_max_matched_len (feedback-jh) 2/4 - Updated from v6's 2/4: * Reduce use of strchr (feedback-jh) * Correctly handle characters with high bit set during normalization * Detect some additional invalid scheme names 3/4 - Updated from v6's 3/4: * Add several additional tests for high bit set characters and invalid schemes 4/4 - Updated from v6's 4/4: * Added an http_init memset for http_option_user_matched (feedback-jh) Applicable comments from earlier cover: To better support matching URLs that are equivalent but spelled differently, a url_normalize function has been added. Currently this patch leaves it in http.c as http_options_url_normalize as I am unclear whether it should go into url.{h,c} at this time since only http.c uses it. Since the url_normalize function's behavior is non-trivial, it is presented as a separate patch on top of the basic http..* settings support. A new test for it has also been included as a separate patch. I am unclear on the proper number for this test, but have gone ahead and put it with the other http tests since this patch series places the url_normalize function into http.c. Kyle J. McKay (4): config: add support for http..* settings config: improve support for http..* settings tests: add new test for the url_normalize function config: allow http..* any user matching .gitignore | 1 + Documentation/config.txt | 19 ++ Makefile | 5 + http.c | 666 +-- t/t5200-url-normalize.sh | 182 + t/t5200/README | 9 + t/t5200/url-1| 1 + t/t5200/url-10 | 1 + t/t5200/url-11 | 1 + t/t5200/url-2| 1 + t/t5200/url-3| 1 + t/t5200/url-4| 1 + t/t5200/url-5| 1 + t/t5200/url-6| 1 + t/t5200/url-7| 1 + t/t5200/url-8| 1 + t/t5200/url-9| 1 + test-url-normalize.c | 62 + 18 files changed, 938 insertions(+), 17 deletions(-) create mode 100755 t/t5200-url-normalize.sh create mode 100644 t/t5200/README create mode 100644 t/t5200/url-1 create mode 100644 t/t5200/url-10 create mode 100644 t/t5200/url-11 create mode 100644 t/t5200/url-2 create mode 100644 t/t5200/url-3 create mode 100644 t/t5200/url-4 create mode 100644 t/t5200/url-5 create mode 100644 t/t5200/url-6 create mode 100644 t/t5200/url-7 create mode 100644 t/t5200/url-8 create mode 100644 t/t5200/url-9 create mode 100644 test-url-normalize.c -- 1.8.3 -- 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 v7 1/4] config: add support for http..* settings
The credentials configuration values already support url-specific configuration items in the form credential..*. This patch adds similar support for http configuration values. The value is considered a match to a url if the value is either an exact match or a prefix of the url which ends on a path component boundary ('/'). So "https://example.com/test"; will match "https://example.com/test"; and "https://example.com/test/too"; but not "https://example.com/testextra";. Longer matches take precedence over shorter matches with environment variable settings taking precedence over all. With this configuration: [http] useragent = other-agent noEPSV = true [http "https://example.com";] useragent = example-agent sslVerify = false [http "https://example.com/path";] useragent = path-agent The "https://other.example.com/"; url will have useragent "other-agent" and sslVerify will be on. The "https://example.com/"; url will have useragent "example-agent" and sslVerify will be off. The "https://example.com/path/sub"; url will have useragent "path-agent" and sslVerify will be off. All three of the examples will have noEPSV enabled. Signed-off-by: Kyle J. McKay --- Documentation/config.txt | 15 + http.c | 170 ++- 2 files changed, 168 insertions(+), 17 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 6e53fc5..41cab91 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1513,6 +1513,21 @@ http.useragent:: of common USER_AGENT strings (but not including those like git/1.7.1). Can be overridden by the 'GIT_HTTP_USER_AGENT' environment variable. +http..*:: + Any of the http.* options above can be applied selectively to some urls. + For example "http.https://example.com.useragent"; would set the user + agent only for https connections to example.com. The value + matches a url if it is an exact match or a prefix of the url matching + at a "/" boundary. Longer matches take precedence over shorter + ones with the environment variable settings taking precedence over all. + Note that must match the url passed to git exactly (other than + possibly being a prefix). This means any user, password and/or port + setting that appears in a url as well as any %XX escapes that are + present must also appear in to have a successful match. The urls + that are matched against are those given directly to git commands. In + other words, use exactly the same url that was passed to git (possibly + shortened) for the value of the config setting. + i18n.commitEncoding:: Character encoding the commit messages are stored in; Git itself does not care per se, but this information is necessary e.g. when diff --git a/http.c b/http.c index 37986f8..1531ffa 100644 --- a/http.c +++ b/http.c @@ -30,6 +30,34 @@ static CURL *curl_default; char curl_errorstr[CURL_ERROR_SIZE]; +enum http_option_type { + OPT_POST_BUFFER, + OPT_MIN_SESSIONS, + OPT_SSL_VERIFY, + OPT_SSL_TRY, + OPT_SSL_CERT, + OPT_SSL_CAINFO, + OPT_LOW_SPEED, + OPT_LOW_TIME, + OPT_NO_EPSV, + OPT_HTTP_PROXY, + OPT_COOKIE_FILE, + OPT_USER_AGENT, + OPT_PASSWD_REQ, +#ifdef USE_CURL_MULTI + OPT_MAX_REQUESTS, +#endif +#if LIBCURL_VERSION_NUM >= 0x070903 + OPT_SSL_KEY, +#endif +#if LIBCURL_VERSION_NUM >= 0x070908 + OPT_SSL_CAPATH, +#endif + OPT_MAX +}; + +static size_t http_option_max_matched_len[OPT_MAX]; + static int curl_ssl_verify = -1; static int curl_ssl_try; static const char *ssl_cert; @@ -141,33 +169,121 @@ static void process_curl_messages(void) } #endif +static size_t http_options_url_match_prefix(const char *url, + const char *url_prefix, + size_t url_prefix_len) +{ + /* +* url_prefix matches url if url_prefix is an exact match for url or it +* is a prefix of url and the match ends on a path component boundary. +* Both url and url_prefix are considered to have an implicit '/' on the +* end for matching purposes if they do not already. +* +* url must be NUL terminated. url_prefix_len is the length of +* url_prefix which need not be NUL terminated. +* +* The return value is the length of the match in characters (excluding +* any final '/') or 0 for no match. Passing "/" as url_prefix will +* always cause 0 to be returned. +*/ + size_t url_len; + if (url_prefix_len && url_prefix[url_prefix_len - 1] == '/') + url_prefix_len--; + if (!url_prefix_len || strncmp(url, url_prefix, url_prefix_len)) + return 0; + url_len = strlen(url); + if ((url_len == url_
[PATCH v7 3/4] tests: add new test for the url_normalize function
In order to perform sane URL matching for http..* options, http.c normalizes URLs before performing matches. A new test-url-normalize test program is introduced along with a new t5200-url-normalize.sh script to run the tests. Since the url_normalize function currently lives in http.c this test will be skipped if NO_CURL is defined since http.c is skipped in that case. Signed-off-by: Kyle J. McKay --- .gitignore | 1 + Makefile | 5 ++ t/t5200-url-normalize.sh | 182 +++ t/t5200/README | 9 +++ t/t5200/url-1| 1 + t/t5200/url-10 | 1 + t/t5200/url-11 | 1 + t/t5200/url-2| 1 + t/t5200/url-3| 1 + t/t5200/url-4| 1 + t/t5200/url-5| 1 + t/t5200/url-6| 1 + t/t5200/url-7| 1 + t/t5200/url-8| 1 + t/t5200/url-9| 1 + test-url-normalize.c | 61 16 files changed, 269 insertions(+) create mode 100755 t/t5200-url-normalize.sh create mode 100644 t/t5200/README create mode 100644 t/t5200/url-1 create mode 100644 t/t5200/url-10 create mode 100644 t/t5200/url-11 create mode 100644 t/t5200/url-2 create mode 100644 t/t5200/url-3 create mode 100644 t/t5200/url-4 create mode 100644 t/t5200/url-5 create mode 100644 t/t5200/url-6 create mode 100644 t/t5200/url-7 create mode 100644 t/t5200/url-8 create mode 100644 t/t5200/url-9 create mode 100644 test-url-normalize.c diff --git a/.gitignore b/.gitignore index 6669bf0..cd97e16 100644 --- a/.gitignore +++ b/.gitignore @@ -198,6 +198,7 @@ /test-string-list /test-subprocess /test-svn-fe +/test-url-normalize /test-wildmatch /common-cmds.h *.tar.gz diff --git a/Makefile b/Makefile index 0f931a2..f83879c 100644 --- a/Makefile +++ b/Makefile @@ -567,6 +567,7 @@ TEST_PROGRAMS_NEED_X += test-sigchain TEST_PROGRAMS_NEED_X += test-string-list TEST_PROGRAMS_NEED_X += test-subprocess TEST_PROGRAMS_NEED_X += test-svn-fe +TEST_PROGRAMS_NEED_X += test-url-normalize TEST_PROGRAMS_NEED_X += test-wildmatch TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X)) @@ -2235,6 +2236,10 @@ test-parse-options$X: parse-options.o parse-options-cb.o test-svn-fe$X: vcs-svn/lib.a +test-url-normalize$X: test-url-normalize.o GIT-LDFLAGS $(GITLIBS) + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) + .PRECIOUS: $(TEST_OBJS) test-%$X: test-%.o GIT-LDFLAGS $(GITLIBS) diff --git a/t/t5200-url-normalize.sh b/t/t5200-url-normalize.sh new file mode 100755 index 000..12ac411 --- /dev/null +++ b/t/t5200-url-normalize.sh @@ -0,0 +1,182 @@ +#!/bin/sh + +test_description='url normalization' +. ./test-lib.sh + +if test -n "$NO_CURL"; then + skip_all='skipping test, git built without http support' + test_done +fi + +# The base name of the test url files +tu="$TEST_DIRECTORY/t5200/url" + +# Note that only file: URLs should be allowed without a host + +test_expect_success 'url scheme' ' + ! test-url-normalize "" && + ! test-url-normalize "_" && + ! test-url-normalize "scheme" && + ! test-url-normalize "scheme:" && + ! test-url-normalize "scheme:/" && + ! test-url-normalize "scheme://" && + ! test-url-normalize "file" && + ! test-url-normalize "file:" && + ! test-url-normalize "file:/" && + test-url-normalize "file://" && + ! test-url-normalize "://acme.co" && + ! test-url-normalize "x_test://acme.co" && + ! test-url-normalize "-test://acme.co" && + ! test-url-normalize "0test://acme.co" && + ! test-url-normalize "+test://acme.co" && + ! test-url-normalize ".test://acme.co" && + ! test-url-normalize "schem%6e://" && + test-url-normalize "x-Test+v1.0://acme.co" && + test "$(test-url-normalize -p "AbCdeF://x.Y")" = "abcdef://x.y/" +' + +test_expect_success 'url authority' ' + ! test-url-normalize "scheme://user:pass@" && + ! test-url-normalize "scheme://?" && + ! test-url-normalize "scheme://#" && + ! test-url-normalize "scheme:///" && + ! test-url-normalize "scheme://:" && + ! test-url-normalize "scheme://:555" && + test-url-normalize "file://user:pass@" && + test-url-normalize "file://?" && + test-url-normalize "file://#" && + test-url-normalize "file:///" && + test-url-normalize "file://:" && + ! test-url-normalize "file://:555" && + test-url-normalize "scheme://user:pass@host" && + test-url-normalize "scheme://@host" && + test-url-normalize "scheme://%00@host" && + ! test-url-normalize "scheme://%%@host" && + ! test-url-normalize "scheme://host_" && + test-url-normalize "scheme://user:pass@host/" && + test-url-normalize "scheme://@host/" && + test-url-normalize "scheme://host/" && + te
[PATCH v7 4/4] config: allow http..* any user matching
Previously the had to specify an exactly matching user name and password if those were present in the url being matched against. Now the password portion is always ignored and omitting the user name from allows it to match against any user name. Signed-off-by: Kyle J. McKay --- Documentation/config.txt | 23 ++-- http.c | 281 +++ test-url-normalize.c | 11 +- 3 files changed, 255 insertions(+), 60 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index e461f32..8b32a15 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1517,15 +1517,20 @@ http..*:: Any of the http.* options above can be applied selectively to some urls. For example "http.https://example.com.useragent"; would set the user agent only for https connections to example.com. The value - matches a url if it is an exact match or if it is a prefix of the url - matching at a "/" boundary. Longer matches take precedence over - shorter ones with the environment variable settings taking precedence - over all. The urls are normalized before testing for a match. Note, - however, that any user, password and/or port setting that appears in a - url must also match that part of to have a successful match. The - urls that are matched against are those given directly to git commands. - This means any urls visited as a result of a redirection do not - participate in matching. + matches a url if it refers to the same scheme, host and port and the + path portion is an exact match or a prefix that matches at a "/" + boundary. If does not include a user name, it will match a url + with any username otherwise the user name must match as well (the + password part, if present in the url, is always ignored). Longer + path matches take precedence over shorter matches no matter what order + they occur in. For same length matches, the last one wins except that a + same-length match that includes a user name will be preferred over + a same-length match that does not. The urls are normalized before + matching so that equivalent urls that are simply spelled differently + will match properly. Environment variable settings always override any + matches. The urls that are matched against are those given directly to + git commands. This means any urls visited as a result of a redirection + do not participate in matching. i18n.commitEncoding:: Character encoding the commit messages are stored in; Git itself diff --git a/http.c b/http.c index 29e119c..c636d3c 100644 --- a/http.c +++ b/http.c @@ -56,7 +56,35 @@ enum http_option_type { OPT_MAX }; +struct url_info { + char *url; /* normalized url on success, must be freed, otherwise NULL */ + const char *err;/* if !url, a brief reason for the failure, otherwise NULL */ + + /* the rest of the fields are only set if url != NULL */ + + size_t url_len; /* total length of url (which is now normalized) */ + size_t scheme_len; /* length of scheme name (excluding final :) */ + size_t user_off;/* offset into url to start of user name (0 => none) */ + size_t user_len;/* length of user name; if user_off != 0 but + user_len == 0, an empty user name was given */ + size_t passwd_off; /* offset into url to start of passwd (0 => none) */ + size_t passwd_len; /* length of passwd; if passwd_off != 0 but + passwd_len == 0, an empty passwd was given */ + size_t host_off;/* offset into url to start of host name (0 => none) */ + size_t host_len;/* length of host name; this INCLUDES any ':portnum'; +* file urls may have host_len == 0 */ + size_t port_len;/* if a portnum is present (port_len != 0), it has +* this length (excluding the leading ':') at the +* end of the host name (always 0 for file urls) */ + size_t path_off;/* offset into url to the start of the url path; +* this will always point to a '/' character +* after the url has been normalized */ + size_t path_len;/* length of path portion excluding any trailing +* '?...' and '#...' portion; will always be >= 1 */ +}; + static size_t http_option_max_matched_len[OPT_MAX]; +static int http_option_user_matched[OPT_MAX]; static int curl_ssl_verify = -1; static int curl_ssl_try; @@ -231,7 +259,7 @@ static int append_normalized_escapes(struct strbuf *buf, return 1; } -static char *http_options_url_normalize(const char *ur
[PATCH v7 2/4] config: improve support for http..* settings
Improve on the http..* url matching behavior by first normalizing the urls before they are compared. With this change, for example, the following configuration section: [http "https://example.com/path";] useragent = example-agent sslVerify = false will properly match a "HTTPS://example.COM/p%61th" url which is equivalent. The normalization rules are based on RFC 3986 and should result in any two equivalent urls being a match. Signed-off-by: Kyle J. McKay --- Documentation/config.txt | 19 ++- http.c | 311 ++- 2 files changed, 318 insertions(+), 12 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 41cab91..e461f32 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1517,16 +1517,15 @@ http..*:: Any of the http.* options above can be applied selectively to some urls. For example "http.https://example.com.useragent"; would set the user agent only for https connections to example.com. The value - matches a url if it is an exact match or a prefix of the url matching - at a "/" boundary. Longer matches take precedence over shorter - ones with the environment variable settings taking precedence over all. - Note that must match the url passed to git exactly (other than - possibly being a prefix). This means any user, password and/or port - setting that appears in a url as well as any %XX escapes that are - present must also appear in to have a successful match. The urls - that are matched against are those given directly to git commands. In - other words, use exactly the same url that was passed to git (possibly - shortened) for the value of the config setting. + matches a url if it is an exact match or if it is a prefix of the url + matching at a "/" boundary. Longer matches take precedence over + shorter ones with the environment variable settings taking precedence + over all. The urls are normalized before testing for a match. Note, + however, that any user, password and/or port setting that appears in a + url must also match that part of to have a successful match. The + urls that are matched against are those given directly to git commands. + This means any urls visited as a result of a redirection do not + participate in matching. i18n.commitEncoding:: Character encoding the commit messages are stored in; Git itself diff --git a/http.c b/http.c index 1531ffa..29e119c 100644 --- a/http.c +++ b/http.c @@ -169,6 +169,300 @@ static void process_curl_messages(void) } #endif +#define URL_ALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +#define URL_DIGIT "0123456789" +#define URL_ALPHADIGIT URL_ALPHA URL_DIGIT +#define URL_SCHEME_CHARS URL_ALPHADIGIT "+.-" +#define URL_HOST_CHARS URL_ALPHADIGIT ".-[:]" /* IPv6 literals need [:] */ +#define URL_UNSAFE_CHARS " <>\"%{}|\\^`" /* plus 0x00-0x1F,0x7F-0xFF */ +#define URL_GEN_RESERVED ":/?#[]@" +#define URL_SUB_RESERVED "!$&'()*+,;=" +#define URL_RESERVED URL_GEN_RESERVED URL_SUB_RESERVED /* only allowed delims */ + +static int append_normalized_escapes(struct strbuf *buf, +const char *from, +size_t from_len, +const char *esc_extra, +const char *esc_ok) +{ + /* +* Append to strbuf 'buf' characters from string 'from' with length +* 'from_len' while unescaping characters that do not need to be escaped +* and escaping characters that do. The set of characters to escape +* (the complement of which is unescaped) starts out as the RFC 3986 +* unsafe characters (0x00-0x1F,0x7F-0xFF," <>\"#%{}|\\^`"). If +* 'esc_extra' is not NULL, those additional characters will also always +* be escaped. If 'esc_ok' is not NULL, those characters will be left +* escaped if found that way, but will not be unescaped otherwise (used +* for delimiters). If a %-escape sequence is encountered that is not +* followed by 2 hexadecimal digits, the sequence is invalid and +* false (0) will be returned. Otherwise true (1) will be returned for +* success. +* +* Note that all %-escape sequences will be normalized to UPPERCASE +* as indicated in RFC 3986. Unless included in esc_extra or esc_ok +* alphanumerics and "-._~" will always be unescaped as per RFC 3986. +*/ + + while (from_len) { + int ch = *from++; + int was_esc = 0; + + from_len--; + if (ch == '%') { + if (from_len < 2 || + !isxdigit((unsigned char)from[0]) || + !isxdigit((unsigned char)from[1])) +
Re: [PATCH] Cygwin has trustable filemode
On 07/21/2013 05:56 PM, Junio C Hamano wrote: Ramsay Jones writes: Mark Levedahl wrote: The supported Cygwin distribution on supported Windows versions provides complete support for POSIX filemodes, so enable this by default. ... Historical notes: Cygwin version 1.7 supports Windows-XP and newer, thus dropped support for all OS variants that lack NTFS and/or ... ... Thus, POSIX filemode support could not be expected by default on a Cygwin 1.5 installation, but is expected by default on a 1.7 installation. Again, I have to ask; should you not "revert" commit c869753e ("Force core.filemode to false on Cygwin.", 30-12-2006)? After this commit, there is no longer any user of the NO_TRUSTABLE_FILEMODE build variable, and no real prospect of anyone else wanting to use it. Thanks for raising this point. Reading c869753e once again: The issue is that Cygwin and NTFS correctly supports the executable mode bit, and Git properly detected that, but most native Windows applications tend to create files such that Cygwin sees the executable bit set when it probably shouldn't be. In other words, the reason why "NO_TRUSTABLE_FILEMODE" was added was not because the Cygwin did not give us reliable filemodes. It was because tools outside the control of Git and/or Cygwin that users use tend to misbehave, even when the working tree is on a filesystem on which Cygwin can give us trustable filemodes. So "1.7 always supports core.filemodes correctly because it no longer works on filesystems without trustable filemodes" is not a valid reason to justify Mark's change. There are only three possible ways going forward, I think: (A) Drop Mark's patch, and do nothing else, because breakages of other people's programs are not fixed by Cygwin 1.7's improved filesystem support, and users still use those mode breaking programs written by others; (B) Drop Mark's patch, and revert c869753e, because it is not the business of our project to sweep breakages of other people's tools under the rug by crippling our software; or (C) Drop NO_TRUSTABLE_FILEMODE for _all_ versions of Cygwin, declaring that the spirit of c869753e to work around bugs in other people's software by crippling Git is justified, but that it is no longer necessary on Cygwin because people do not use such misbehaving third-party tools anymore. These three each rely on its own precondition; I suspect it is likely that (A)'s is the most accurate description of the real world. Perhaps the simplest approach is to just defer to the judgement of the Cygwin project maintainers here. a) The Cygwin project has its stated objective of being as matching Linux. b) The Cygwin project has always shipped git binaries built without NO_TRUSTABLE_FILEMODE Also - users who do not want Cygwin's assumptions / environment are now free to use the msysgit version and frankly they should be so encouraged - it is faster than Cygwin's git. This option was not available in 2006. Mark -- 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] Cygwin has trustable filemode
Mark Levedahl writes: > On 07/21/2013 05:56 PM, Junio C Hamano wrote: > ... >> There are only three possible ways going forward, I think: >> >> (A) Drop Mark's patch, and do nothing else, because breakages of >> other people's programs are not fixed by Cygwin 1.7's improved >> filesystem support, and users still use those mode breaking >> programs written by others; >> >> (B) Drop Mark's patch, and revert c869753e, because it is not the >> business of our project to sweep breakages of other people's >> tools under the rug by crippling our software; or >> >> (C) Drop NO_TRUSTABLE_FILEMODE for _all_ versions of Cygwin, >> declaring that the spirit of c869753e to work around bugs in >> other people's software by crippling Git is justified, but that >> it is no longer necessary on Cygwin because people do not use >> such misbehaving third-party tools anymore. >> >> These three each rely on its own precondition; I suspect it is >> likely that (A)'s is the most accurate description of the real world. > > Perhaps the simplest approach is to just defer to the judgement of the > Cygwin project maintainers here. > > a) The Cygwin project has its stated objective of being as matching Linux. That does not say much. On Linux, third-party "native Windows applications" that necessitated c869753e (Force core.filemode to false on Cygwin., 2006-12-30) to help users is not an issue. On Cygwin, it still is. > b) The Cygwin project has always shipped git binaries built without > NO_TRUSTABLE_FILEMODE That is a fair point. So let's do this instead. -- >8 -- From: Mark Levedahl Subject: [PATCH] cygwin: stop forcing core.filemode=false We force core.filemode=false since c869753e (Force core.filemode to false on Cygwin., 2006-12-30), even when the repository is on a filesystem on which Cygwin can give us trustable filemodes, because many native Windows applications the users use to edit files in the working tree tend to (re)create files with executable bit randomly set or reset. However, binary distribution of Git that is supplied by the downstream project to its users has been built without this consideration. Drop NO_TRUSTABLE_FILEMODE from our default configuration so that hand-compiled Git out of box will match theirs. Signed-off-by: Mark Levedahl Signed-off-by: Junio C Hamano --- config.mak.uname | 1 - 1 file changed, 1 deletion(-) diff --git a/config.mak.uname b/config.mak.uname index 7ac541e..779d06a 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -163,7 +163,6 @@ ifeq ($(uname_O),Cygwin) NO_THREAD_SAFE_PREAD = YesPlease NEEDS_LIBICONV = YesPlease NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes - NO_TRUSTABLE_FILEMODE = UnfortunatelyYes NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease # There are conflicting reports about this. # On some boxes NO_MMAP is needed, and not so elsewhere. -- 1.8.3.3-1030-g100bb15 -- 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 v7 3/4] tests: add new test for the url_normalize function
"Kyle J. McKay" writes: > +test_expect_success 'url general escapes' ' > + ! test-url-normalize "http://x.y?%fg"; && > + test "$(test-url-normalize -p "X://W/%7e%41^%3a")" = "x://w/~A%5E%3A" && > + test "$(test-url-normalize -p "X://W/:/?#[]@")" = "x://w/:/?#[]@" && > + test "$(test-url-normalize -p "X://W/$&()*+,;=")" = "x://w/$&()*+,;=" && > + test "$(test-url-normalize -p "X://W/'\''")" = "x://w/'\''" && > + test "$(test-url-normalize -p "X://W?'\!'")" = "x://w/?'\!'" > +';#' Hmm,... what is the magic on the last line about? -- 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 v7 4/4] config: allow http..* any user matching
"Kyle J. McKay" writes: > diff --git a/test-url-normalize.c b/test-url-normalize.c > index d68312d..f325571 100644 > --- a/test-url-normalize.c > +++ b/test-url-normalize.c > @@ -9,7 +9,7 @@ int main() > > #include "http.c" > > -#define url_normalize(u) http_options_url_normalize(u) > +#define url_normalize(u,i) http_options_url_normalize(u,i) > > int main(int argc, char **argv) > { > @@ -40,21 +40,22 @@ int main(int argc, char **argv) > die(usage); > > if (argc == 2) { > - url1 = url_normalize(argv[1]); > + struct url_info info; > + url1 = url_normalize(argv[1], &info); > if (!url1) > return 1; > if (opt_p) > printf("%s\n", url1); > if (opt_l) > - printf("%u\n", (unsigned)strlen(url1)); > + printf("%u\n", (unsigned)info.url_len); > return 0; > } > > if (opt_p || opt_l) > die(usage); > > - url1 = url_normalize(argv[1]); > - url2 = url_normalize(argv[2]); > + url1 = url_normalize(argv[1], NULL); > + url2 = url_normalize(argv[2], NULL); > return (url1 && url2 && !strcmp(url1, url2)) ? 0 : 1; > } It looks like that this program could also drive http_options() directly, or alternatively make a call git_config(http_options, &info); in its main() to let the config parser do its work, to make sure that the machinery picks up the right values from the desired entry in the configuration file, with a bit more effort. > +static int match_is_ignored(size_t matchlen, int usermatch, enum > http_option_type opt) > { > /* > - * Compare matchlen to the last matched length of option opt and > + * Compare matchlen to the last matched path length of option opt and >* return true if matchlen is shorter than the last matched length >* (meaning the config setting should be ignored). Upon seeing the >* _same_ key (i.e. new key has the same match length which is therefore > - * not shorter) the new setting will override the previous setting. > - * Otherwise return false and record matchlen as the current last > - * matched length of option opt. > + * not shorter) the new setting will override the previous setting > + * unless the new setting did not match the user and the previous match > + * did. Otherwise return false and record matchlen as the current last > + * matched path length of option opt and usermatch as the last user > + * matching state for option opt. >*/ > if (matchlen < http_option_max_matched_len[opt]) > return 1; > - http_option_max_matched_len[opt] = matchlen; > + if (matchlen > http_option_max_matched_len[opt]) { > + http_option_max_matched_len[opt] = matchlen; > + http_option_user_matched[opt] = usermatch; > + return 0; > + } > + /* > + * If a previous match of the same length explicitly matched the user > + * name, but the current match matched on any user, ignore it. > + */ > + if (!usermatch && http_option_user_matched[opt]) > + return 1; > + http_option_user_matched[opt] = usermatch; > return 0; > } OK, so if there is a configuration for a generic URL that is longer, it defeats a shorter URL with a specific username, e.g. when talking to host.xz/name as kyle, with configuration for these two keys exist: scheme://k...@host.xz/path scheme://host.xz/path/name the value for the latter one is used. I am not complaining; just making sure that is what we want to give users, as it was not quite clear in the Documentation/config.txt part of the patch. 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 v7 3/4] tests: add new test for the url_normalize function
I suspect that files under t/t5200/ were not suiable for e-mail transmission. Can you regenerate this after running: $ echo '/t/t5200/* binary' >>.git/info/attributes or better yet with: diff --git a/t/.gitattributes b/t/.gitattributes index 1b97c54..6240ed2 100644 --- a/t/.gitattributes +++ b/t/.gitattributes @@ -1 +1,2 @@ t[0-9][0-9][0-9][0-9]/* -whitespace +t5200/* binary -- 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
What's cooking in git.git (Jul 2013, #07; Sun, 21)
Here are the topics that have been cooking. Commits prefixed with '-' are only in 'pu' (proposed updates) while commits prefixed with '+' are in 'next'. Quite a many documentation clean-up patches that are already in 'master' have been applied to 'maint'. Hopefully 1.8.3.4 will be the last of the 1.8.3.x maintenance series. You can find the changes described here in the integration branches of the repositories listed at http://git-blame.blogspot.com/p/git-public-repositories.html -- [New Topics] * mm/color-auto-default (2013-07-19) 1 commit (merged to 'next' on 2013-07-19 at 880d984) + git add -e: Explicitly specify that patch should have no color A finishing touch to fix breakage to "add -e" caused by defaulting ui.color to "auto". Will merge to 'master'. * jc/simple-add-must-be-a-no-op (2013-07-19) 1 commit (merged to 'next' on 2013-07-19 at a1543ee) + t2202: make sure "git add" (no args) stays a no-op This detected a mismerge of one of "add-2.0" topics to the 'jch' and 'pu' branches. Will merge to 'master'. * jm/doc-ref-prune (2013-07-18) 2 commits - Documentation: fix git-prune example usage - Documentation: remove --prune from pack-refs examples Will merge to 'next' and then 'master'. * rj/sparse (2013-07-21) 1 commit - Revert "compat/unsetenv.c: Fix a sparse warning" Will merge to 'next' and then 'master'. * sb/traverse-trees-bitmask-variable-name (2013-07-19) 1 commit - traverse_trees(): clarify return value of the callback Will merge to 'next' and then 'master'. -- [Stalled] * jk/fast-import-empty-ls (2013-06-23) 4 commits - fast-import: allow moving the root tree - fast-import: allow ls or filecopy of the root tree - fast-import: set valid mode on root tree in "ls" - t9300: document fast-import empty path issues Comments? * tf/gitweb-ss-tweak (2013-07-15) 4 commits - gitweb: make search help link less ugly - gitweb: omit the repository owner when it is unset - gitweb: vertically centre contents of page footer - gitweb: ensure OPML text fits inside its box Comments? * rj/read-default-config-in-show-ref-pack-refs (2013-06-17) 3 commits - ### DONTMERGE: needs better explanation on what config they need - pack-refs.c: Add missing call to git_config() - show-ref.c: Add missing call to git_config() The changes themselves are probably good, but it is unclear what basic setting needs to be read for which exact operation. Waiting for clarification. $gmane/228294 * jh/shorten-refname (2013-05-07) 4 commits - t1514: refname shortening is done after dereferencing symbolic refs - shorten_unambiguous_ref(): Fix shortening refs/remotes/origin/HEAD to origin - t1514: Demonstrate failure to correctly shorten "refs/remotes/origin/HEAD" - t1514: Add tests of shortening refnames in strict/loose mode When remotes/origin/HEAD is not a symbolic ref, "rev-parse --abbrev-ref remotes/origin/HEAD" ought to show "origin", not "origin/HEAD", which is fixed with this series (if it is a symbolic ref that points at remotes/origin/something, then it should show "origin/something" and it already does). Expecting a reroll, as an early part of a larger series. $gmane/225137 * jl/submodule-mv (2013-04-23) 5 commits . submodule.c: duplicate real_path's return value . rm: delete .gitmodules entry of submodules removed from the work tree . Teach mv to update the path entry in .gitmodules for moved submodules . Teach mv to move submodules using a gitfile . Teach mv to move submodules together with their work trees "git mv A B" when moving a submodule A does "the right thing", inclusing relocating its working tree and adjusting the paths in the .gitmodules file. Ejected from 'pu', as it conflicts with nd/magic-pathspec. * jk/list-objects-sans-blobs (2013-06-06) 4 commits . archive: ignore blob objects when checking reachability . list-objects: optimize "revs->blob_objects = 0" case . upload-archive: restrict remote objects with reachability check . clear parsed flag when we free tree buffers Attempt to allow "archive --remote=$there $arbitrary_sha1" while keeping the reachability safety. Seems to break some tests in a trivial and obvious way. * mg/more-textconv (2013-05-10) 7 commits - grep: honor --textconv for the case rev:path - grep: allow to use textconv filters - t7008: demonstrate behavior of grep with textconv - cat-file: do not die on --textconv without textconv filters - show: honor --textconv for blobs - diff_opt: track whether flags have been set explicitly - t4030: demonstrate behavior of show with textconv Make "git grep" and "git show" pay attention to --textconv when dealing with blob objects. I thought this was pretty well designed and executed, but it seems there are some doubts on the list; kicked back to 'pu'. * jc/format-patch (2013-04-22) 2 commits - format-patch: --inline-single - format-patch: